chore: update docs

This commit is contained in:
Darrel O'Pry 2021-03-18 15:55:47 -04:00
parent f21e54d8a8
commit 5401fed671

View file

@ -7,6 +7,7 @@ An Oidc Client Component for Svelte.
## Getting Started ## Getting Started
Setup an OIDC Sever Setup an OIDC Sever
* https://www.ory.sh/ * https://www.ory.sh/
* https://www.keycloak.org/ * https://www.keycloak.org/
* https://www.okta.com/ * https://www.okta.com/
@ -17,10 +18,13 @@ Setup an OIDC Sever
`npm install @dopry/svelte-oidc` `npm install @dopry/svelte-oidc`
App.svelte App.svelte
``` ```svelte
# App.svelte # App.svelte
import { import {
OidcContext, OidcContext,
LoginButton,
LogoutButton,
RefreshTokenButton,
authError, authError,
accessToken, accessToken,
idToken, idToken,
@ -47,8 +51,9 @@ const metadata = {
metadata={metadata} metadata={metadata}
> >
<button on:click|preventDefault='{() => login() }'>Login</button> <LoginButton>Login</LoginButton>
<button on:click|preventDefault='{() => logout() }'>Logout</button><br /> <LogoutButton>Logout</LogoutButton>
<RefreshTokenButton>RefreshToken<RefreshTokenButton><br />
<pre>isLoading: {$isLoading}</pre> <pre>isLoading: {$isLoading}</pre>
<pre>isAuthenticated: {$isAuthenticated}</pre> <pre>isAuthenticated: {$isAuthenticated}</pre>
<pre>authToken: {$accessToken}</pre> <pre>authToken: {$accessToken}</pre>
@ -87,6 +92,7 @@ the migration hard.
## Docs ## Docs
### Components ### Components
* OidcContext - component to initiate the OIDC client. You only need one instance in your DOM tree at the root. * OidcContext - component to initiate the OIDC client. You only need one instance in your DOM tree at the root.
Attributes: Attributes:
@ -96,12 +102,27 @@ the migration hard.
* post_logout_redirect_uri - override the default url that OIDC will redirect to after logout. default: window.location.href * post_logout_redirect_uri - override the default url that OIDC will redirect to after logout. default: window.location.href
* metadata - set default metadata or metadata missing from authority. * metadata - set default metadata or metadata missing from authority.
* LoginButton - log out the current context
Attributes:
* preserve_route - tell the callback handler to return to the current url after login. default: true
* callback_url - override the context callback_url
* LogoutButton - log in the current context
Attributes:
* logout_url - override the context logout_url
* RefreshTokenButton - refresh the current token
### Functions ### Functions
* login(preseveRoute = true, callback_url = null) - begin a user login.
* logout(logout_url = null) - logout a user. * login(oidcPromise, preseveRoute = true, callback_url = null) - begin a user login.
* refreshToken - function to refresh a token. * logout(oidcPromise, logout_url = null) - logout a user.
* refreshToken(oidcPromise) - function to refresh a token.
### Stores ### Stores
* isLoading - if true OIDC Context is still loading. * isLoading - if true OIDC Context is still loading.
* isAuthenticated - true if user is currently authenticated * isAuthenticated - true if user is currently authenticated
* accessToken - access token for connecting to apis. * accessToken - access token for connecting to apis.
@ -110,15 +131,19 @@ the migration hard.
* authError - the last authentication error. * authError - the last authentication error.
### Constants ### Constants
* OIDC_CONTEXT_CALLBACK_URL * OIDC_CONTEXT_CALLBACK_URL
* OIDC_CONTEXT_CLIENT_PROMISE - key for the OIDC client in setContext/getContext. * OIDC_CONTEXT_CLIENT_PROMISE - key for the OIDC client in setContext/getContext.
* OIDC_CONTEXT_LOGOUT_URL, * OIDC_CONTEXT_LOGOUT_URL,
## Development ## Development
npm run showcase:dev npm run showcase:dev
## Release ## Release
**use semver**
use semver
1. npm publish 1. npm publish
2. npm showcase:build 2. npm run showcase:build
3. npm showcase:publish 3. npm run showcase:publish