@authbird/client-sdk
v1.0.1
Published
<h1 align="center"> <b> <a href="https://axios-http.com"> <img src="assets/authbird_logo.png" alt="AuthBird Logo"/> </a> </b> </h1>
Downloads
14
Readme
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/[email protected]/lib/cjs/index.js"></script>
jsDelivr.com
<script src="https://cdn.jsdelivr.net/npm/@authbird/[email protected]/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 message | Release type |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|
| fix(pencil): stop graphite breaking when too much pressure applied
| Fix Release (Patch) |
| feat(pencil): add 'graphiteWidth' option
| Feature Release (Minor) |
| perf(pencil): remove graphiteWidth option
BREAKING 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!