1.0.1 • Published 11 months ago

@authbird/client-sdk v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

npm version Build status

AuthBird Client SDK

Getting Started

Before you can use this SDK, you need to create an account on authbird.com.

Please check out the detailed docs.

1. Installation

npm install @authbird/client-sdk

CDN

UNPKG.com

<script src="https://unpkg.com/@authbird/client-sdk@1.0.0/lib/cjs/index.js"></script>

jsDelivr.com

<script src="https://cdn.jsdelivr.net/npm/@authbird/client-sdk@1.0.0/lib/cjs/index.js"></script>

Usage

After the package is installed, the library can be imported using import or require approach:

2. Import the SDK

const authbird = require('@authbird/client-sdk');

or

import {init, session, browser} from '@authbird/client-sdk';

Init the SDK

Initialize the SDK with your appId and appSecret.

authbird.init({
  appId: '<your appId>',
  appSecret: '<your appSecret>'
});

3. Authentication flow

a) Browser flow

To simplify the user login process for the browser, we have developed a straightforward function.

const user = await authbird.browser.loginUser('<login provider>');

Example response data:

{
 "accessToken": "<accessToken>",
 "profile": {
  "photoUrl": "<photoUrl>",
  "provider": "<provider>",
  "displayName": "<displayName>",
  "id": "<id>",
  "email": "<email>"
 }
}

b) Session flow

If you desire greater control, you have the option to manage sessions on your own.

Create Session
const newSession = await authbird.session.create();

Example response data:

{
 "sessionId": "<sessionId>",
 "sessionSecret": "<sessionSecret>",
 "loginUrls": {
  "google": "https://api.authbird.com/auth/google?sessionId=<sessionId>",
  "facebook": "https://api.authbird.com/auth/facebook?sessionId=<sessionId>"
 }
}
Retrieve user session data
const userAuthData = await authbird.session.getUserData('<sessionSecret>');

Example response data:

{
 "accessToken": "<accessToken>",
 "profile": {
  "photoUrl": "<photoUrl>",
  "provider": "<provider>",
  "displayName": "<displayName>",
  "id": "<id>",
  "email": "<email>"
 }
}

Continuous Integration and Continuous Delivery (CI/CD)

The Test pipeline is triggered in push and pull requests to the main branch.

The Release pipeline is triggered when merging PR to the main branch. It does the Github release, builds the library and publish it on npm.

The release version is calculated automatically based on commit messages using semantic release. The example table below shows which commit message gets you which release type:

Commit messageRelease type
fix(pencil): stop graphite breaking when too much pressure appliedFix Release (Patch)
feat(pencil): add 'graphiteWidth' optionFeature Release (Minor)
perf(pencil): remove graphiteWidth optionBREAKING CHANGE: The graphiteWidth option has been removed.The default graphite width of 10mm is always used for performance reasons.Breaking Release (Major) (Note that the BREAKING CHANGE: token must be in the footer of the commit)

Please remember that for the CD (Continuous Deployment) to function correctly, it is essential to provide a proper commit message.

Contributing

Authbird welcomes all kinds of contributions! Whether it's code fixes, feature enhancements, documentation updates, additional tests, or helping with pull requests and issues, we appreciate any support you can provide. Your contributions play a vital role in improving our project.

Join us and make a difference!

License

MIT

1.0.1

11 months ago

1.0.0

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago

0.0.0

11 months ago