0.0.3 • Published 4 years ago

@capsulajs/capsulahub-service-auth v0.0.3

Weekly downloads
12
License
MIT
Repository
-
Last release
4 years ago

Auth service

The purpose of this service is to provide a utility tool that allows user to implement authentication logic using auth0 service.

Take a look at Lock.js documentation in order to get the whole list of lockOptions.

Usage

// You should call init as soon as possible in order to get the current auth status of a user
// If you call login method before init, login popup will not be shown until init resolves

authService.init({}).then((authStatusDataAfterInit) => {
  if (!authStatusDataAfterInit.token) {
    return authStatusDataAfterInit.login({}).then((authStatusDataAfterLogin) => {
      console.info(authStatusDataAfterLogin);
    })
  }
});

Install

NPM

To install the package from NPM registry you should run

yarn add @capsulajs/capsulahub-service-auth

or

npm install @capsulajs/capsulahub-service-auth

CDN

You can get the default export from the link

https://capsulajs.s3.amazonaws.com/develop/capsulahub-service-auth/index.js

WorkspaceConfiguration example

{
  "services": [
    {
      "serviceName": "AuthService",
      "path": "https://capsulajs.s3.amazonaws.com/develop/capsulahub-service-auth/index.js",
      "definition": {
        "serviceName": "AuthService",
        "methods": {
          "init": { "asyncModel": "requestResponse" },
          "login": { "asyncModel": "requestResponse" },
          "logout": { "asyncModel": "requestResponse" },
          "authStatus$": { "asyncModel": "requestStream" }
        }
      },
      "config": {
        "serviceName": "AuthService",
        "domain": "dev-f8nw441q.auth0.com",
        "clientId": "RS6FSurmbVq9B31sJ57Px4NZpcdyCnHQ"
      }
    }
  ]
}

Exports

Default

Bootstrap function of the extension.

Named (API)

The public API of the extension.

API

CDN

The documentation about public API.

Local

Run

yarn doc

And open doc/index.html in browser.

Test

npm run test or yarn test

Licence

CapsulaHub and related services are released under MIT Licence.

Back to the Main Page