0.0.8 • Published 3 years ago
webextension-indieauth v0.0.8
WebExtension-IndieAuth
This package leverages the WebExtensions identity
API and
IndieAuth to sign the user in to a browser extension and optionally
acquire an access token for future Micropub and Microsub requests.
npm install webextension-indieauth
Usage
You must include the following in a background
context:
require("webextension-indieauth")
Call the following from any context (eg. popup, sidebar, ..):
const indieauth = requires("webextension-indieauth")
indieauth.signIn("exampleuser.com", "exampleclient.com")
indieauth.signOut()
Access user data from any context:
const userData = await indieauth.getUser()
It is stored in the following format:
{
me: "https://exampleuser.com",
profile: {
name: "Example User",
email: "example@exampleuser.com"
},
endpoints: {
authorization: "https://exampleuser.com/auth",
token: "https://exampleuser.com/auth/tokens",
ticket: "https://exampleuser.com/auth/tickets",
micropub: "https://exampleuser.com/pub",
microsub: "https://exampleuser.com/sub",
webmention: "https://exampleuser.com/mentions"
},
code: "hf904hkfx049fkhx943ufh3094ux09ufhnhfhf",
accessToken: "secret-token:c9q8jif4l34h",
refreshToken: "secret-token:er8j3cj49f4e"
}