@neiro21/solid-client-authn-webext
v0.1.2
Published
Solid client auth library for web browser extensions
Maintainers
Readme
Solid authentication for web browser extensions
solid-client-authn-webext is a fork of Inrupt's Solid client authentication libraries adapted for web browser extensions. This library implementation is mostly based on @inrupt/solid-client-authn-browser, and is inspired by WebClip Chrome extension.
solid-client-authn-webext uses browser's Identity API to perform the first part of OAuth2 flow and obtain an authorization code - the rest is the same as in @inrupt/solid-client-authn-browser. See Browser compatibility table for the list of supported browsers.
Usage
solid-client-authn-webext's interface is almost identical to the ones of Inrupt's solid-client-authn libraries: the main difference is that redirects during the login process are handled internally by the library, so Session.handleIncomingRedirect() method is absent. Besides that, IDP logout isn't supported at the moment.
See Inrupt JS SDK documentation for information on using client libraries and building Solid applications.
Installation
npm install @neiro21/solid-client-authn-webextCode example
const solidSession = new Session();
solidSession
.login({
oidcIssuer: "https://solidcommunity.net",
clientName: "TestWebExt",
})
.then(() => {
if (solidSession.info.isLoggedIn) {
// access a Solid pod e.g.
const myDataset = await getSolidDataset(
"https://somepod.solidcommunity.net/somepath",
{ fetch: solidSession.fetch },
);
} else {
// shouldn't ever happen
log.error("Login did not succeed for an unknown reason");
}
})
.catch((err) => {
console.error(err);
});Required polyfills
The library requires events Node.js module, so if you do not use Webpack or use version 5+, you'll need to install events npm package.
webextension-polyfill is also required on Chrome / Opera / Edge.
node-solid-server compatibility
node-solid-server 5.3.0 or higher.
