All Projects â†’ Authing â†’ authing.js

Authing / authing.js

Licence: MIT license
🖥 Authing SDK for JavaScript and Node.js

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to authing.js

Authing
🔥Authing - IDaaS/IAM solution that can Auth to web and mobile applications.
Stars: ✭ 247 (-54.26%)
Mutual labels:  auth0, user-management
nativeauthenticator
JupyterHub-native User Authenticator https://native-authenticator.readthedocs.io/en/latest/
Stars: ✭ 55 (-89.81%)
Mutual labels:  user-management
buttons
🌱 buttons is a web service to help you keep doing things everyday
Stars: ✭ 21 (-96.11%)
Mutual labels:  auth0
auth0-aspnetcore-mvc-samples
Auth0 Integration Samples for ASP.NET Core MVC Web Applications
Stars: ✭ 120 (-77.78%)
Mutual labels:  auth0
auth0-aspnet-owin-webapi-samples
Auth0 Integration Samples for ASP.NET OWIN Web API Services
Stars: ✭ 25 (-95.37%)
Mutual labels:  auth0
Kuberam
Kuberam is built on jetpack compose + Auth0 during Hashnode Hackathon.
Stars: ✭ 33 (-93.89%)
Mutual labels:  auth0
laravel-adminlte-boilerplate
Laravel 5.6+ AdminLTE
Stars: ✭ 45 (-91.67%)
Mutual labels:  user-management
auth0-vue
A simple Vue.js Demo Application that uses Auth0 for Authentication
Stars: ✭ 39 (-92.78%)
Mutual labels:  auth0
attendance-management
Attendance Management System implements the 'punch in / punch out' based concept of attendance management.
Stars: ✭ 28 (-94.81%)
Mutual labels:  user-management
drf-angular-docker-tutorial
Dockerized Django Back-end API using DRF with Angular Front-end Tutorial
Stars: ✭ 53 (-90.19%)
Mutual labels:  auth0
movie-app
App using auth0, netlify functions, + Algolia
Stars: ✭ 39 (-92.78%)
Mutual labels:  auth0
SuluCommunityBundle
Community features like Login, Registration, Password forget/reset for your sulu application.
Stars: ✭ 20 (-96.3%)
Mutual labels:  user-management
dokugaku-engineer
独学エンジニア
Stars: ✭ 184 (-65.93%)
Mutual labels:  auth0
terraform-provider-auth0
Please see https://github.com/alexkappa/terraform-provider-auth0
Stars: ✭ 28 (-94.81%)
Mutual labels:  auth0
django-act-as-auth
Django authentication backend that allows one to login as someone else
Stars: ✭ 17 (-96.85%)
Mutual labels:  user-management
django-user-management
User management model mixins and api views.
Stars: ✭ 56 (-89.63%)
Mutual labels:  user-management
rx react native starter kit
React Native/redux/observable/auth starter kit which include immutable, rxjs, auth0 integration
Stars: ✭ 20 (-96.3%)
Mutual labels:  auth0
cypress-nextjs-auth0
Cypress commands to support Auth0 and Next.js
Stars: ✭ 56 (-89.63%)
Mutual labels:  auth0
akka-jwt
Library for jwt authentication with akka
Stars: ✭ 16 (-97.04%)
Mutual labels:  auth0
graphql-sample-apps
This repository contains sample GraphQL applications powered by Dgraph.
Stars: ✭ 65 (-87.96%)
Mutual labels:  auth0

npm version download standardjs License Node

English | 简体中文

The Authing JavaScript / node SDK consists of two parts:ManagementClient and AuthenticationClient。

  • Authenticationclient includes the methods of registering and logging in, resetting the mobile phone number mailbox, and modifying the account information. It requests as your end user and is suitable for use in the browser and back-end environment.

  • Managementclient is suitable for use in the back-end or trusted front-end environment. Generally speaking, All the operations you can do in the Authing Console can be completed with this SDK

Install

Use npm:

npm install authing-js-sdk

Use yarn:

yarn add authing-js-sdk

If you want to use it in the react native environment, you need to run it in the RN project root directory first: npx rn-nodeify --install "crypto,stream",after that, a shim.js file will be generated in the project root directory, and then in the App.js first line introduction import './shim.js'.

Use CDN:

<script src="https://cdn.jsdelivr.net/npm/authing-js-sdk/build/browser/index.min.js"></script>

<script>
  /** You can obtain the Authenticationclient and Managementclient through the global variable authenticating */
  var authing = new Authing.AuthenticationClient({
    appId: 'AUTHING_APP_ID',
  });
</script>

Use Authentication module

Initialize

Authenticationclient needs to pass in 'appId' for initialization:

You can view your application list in Applications on the console

import { AuthenticationClient } from 'authing-js-sdk';

const authing = new AuthenticationClient({
  appId: 'YOUR_APP_ID',
});

The complete parameter list is as follows:

  • appId: Authing appId, requiredï¼›
  • accessToken: By user's id_token initializes the SDK (optional. You can cache the user's id_token in the front-end localstorage to realize the purpose of remembering login).
  • timeout: Request timeout, default: 10000 (10 seconds)。
  • onError: Error handling function, you can use it to catch all exceptions requested by the authoring client globally. See for complete error codes doc。The function is defined as:
(code: number, message: string, data: any) => void
  • host: Authing server address. If you are using the public cloud version, please ignore the parameter. This parameter is required if you are using the version of privatized deployment. The format is as follows: https://authing-api.mydomain.com,No `/' at the end.
  • preflight: Whether to enable network status pre check. The default value is false. This parameter is used to check whether the user's network shields the domain name of the authing server (the intranet of some enterprises shields the third-party websites). No notification will be given if the check is successful, and the incoming error handling function will be called if the check fails. The SDK initialization speed will be slow after the pre check. Please use it with caution.
  • cdnPreflight: Whether to enable CDN network status pre check. The default value is false. This parameter is used to check whether the user's network can access the qiniu cloud CDN (which cannot be accessed in some scenarios where the agent is enabled). If the check succeeds, no notification will be given. If the check fails, the incoming error handling function will be called. After performing CDN pre check, the SDK initialization speed will be slow. Please use it with caution.

Usage

If the SDK is used in the browser environment, after the user completes the login, the SDK will write the user's token to localStorage, and subsequent requests will carry the token for access.

const email = '[email protected]';
const password = 'passw0rd';
const user = await authing.loginByEmail(email, password); // Log in successfully and write the token to localStorage

//You can do this after logging in
await authing.updateProfile((nickname: 'Bob'));

Social Login

Through authenticationclient.social.authorize send an authorized login request. This method will directly open a new window and jump to the login authorization page of a third-party social login service provider (such as GitHub, wechat, dingpin, etc.). The user after the authorization is completed, this window will be automatically closed and the 'onsuccess' callback function will be triggered. Through this function, you can obtain the user information.

Example:

const authenticationClient = new AuthenticationClient({
  appId: 'YOUR_APP_ID',
});

await authenticationClient.social.authorize('github', {
  onSuccess: (user) => {
    console.log(user);
  },
  onError: (code, message) => {},
  // Customize the location of the pop-up window
  position: {
    w: 100,
    h: 100,
  },
});

Authing currently supports nearly 20 kinds of social logins at home and abroad, such as wechat, GitHub, sign in with apple, Alipay.

Small program code scanning login

Small program code scanning login refers to wechat login using authing small program Small Login, click here to learn more。

You can use 5 lines of code to realize a complete code scanning login form:

authenticationClient.wxqrcode.startScanning('qrcode', {
  onSuccess: (userInfo, ticket) => {
    console.log(userInfo, ticket);
  },
});

For complete usage and parameters, please refer to Code scanning login module。

App scan code login

App scanning login refers to using your own app scanning to login to the website,click here to learn more。

ou can use 5 lines of code to realize a complete code scanning login form:

authenticationClient.qrcode.startScanning('qrcode', {
  onSuccess: (userInfo, ticket) => {
    console.log(userInfo, ticket);
  },
});

Module list

Use management module

Initialize

ManagementClient initialization requires the user pool ID to be passed in userPoolId and user pool key secret:

Click here to learn how to get userPoolId and secret。

import { ManagementClient } from 'authing-js-sdk';

const managementClient = new ManagementClient({
  userPoolId: 'YOUR_USERPOOL_ID',
  secret: 'YOUR_USERPOOL_SECRET',
});

The complete parameter list is as follows:

  • userPoolId: User pool ID.
  • secret: User pool key.
  • accessToken: Initialize the SDK through the administrator's token。(Optional,Either secret or accesstoken must be filled in)。
  • timeout: Request timeout, in milliseconds; the default is 10000 (10 seconds).
  • onError: Error handling function, you can use it to catch all exceptions requested by the authoring client globally. The function is defined as:
(code: number, message: string, data: any) => void

See for complete error codes: doc。

  • host: Authing server address. If you are using the public cloud version, please ignore the parameter. This parameter is required if you are using the version of privatized deployment. The format is as follows: https://authing-api.mydomain.com,No / at the end。
  • preflight: Whether to enable network status pre check. The default value is false. This parameter is used to check whether the user's network shields the domain name of the authing server (the intranet of some enterprises shields the third-party websites). No notification will be given if the check is successful, and the incoming error handling function will be called if the check fails. The SDK initialization speed will be slow after the pre check. Please use it with caution.
  • cdnPreflight: Whether to enable CDN network status pre check. The default value is false. This parameter is used to check whether the user's network can access the qiniu cloud CDN (which cannot be accessed in some scenarios where the agent is enabled). If the check succeeds, no notification will be given. If the check fails, the incoming error handling function will be called. After performing CDN pre check, the SDK initialization speed will be slow. Please use it with caution.

Usage

ManagementClient. It can be used to manage users, roles, policies, groups, organizations, and user pool configurations. Theoretically, any operation you can do in the Authing Console can be completed with this SDK

Get user directory list:

// list: list of users on the current page
// totalCount: total users
const { list, totalCount } = await managementClient.users.list();

Create role:

const role = await managementClient.roles.create('code', 'Role name');

Modify user pool configuration:

const userpool = await managementClient.userpool.update({
  registerDisabled: true, // Close user pool registration
});

Module list

Error handling

You can use try catch to handle errors:

try {
  const user = await authing.loginByEmail('[email protected]', 'passw0rd');
} catch (error) {
  console.log(error.code); // 2004
  console.log(error.message); // user does not exist
}

See for complete error codes doc。

You can also specify onerror to uniformly catch all authing request exceptions, such as using antd and other front-end components to display error prompts

import { message } from 'antd';
const authing = new AuthenticationClient({
  userPoolId,
  onError: (code, msg: any) => {
    message.error(msg);
  },
});

Privatization deployment

In the scenario of privatization deployment, you need to specify the graphql endpoint of your privatized authoring service (without protocol header and path). If you are unclear, you can contact the authoring idaas service administrator.

import { AuthenticationClient, ManagementClient } from 'authing-js-sdk';

const authenticationClient = new AuthenticationClient({
  appId: 'YOUR_APP_ID',
  host: 'https://core.you-authing-service.com',
});

const managementClient = new ManagementClient({
  userPoolId: 'YOUR_USERPOOL_ID',
  secret: 'YOUR_USERPOOL_SECRET',
  host: 'https://core.you-authing-service.com',
});

Interface index

Authentication module:

Authentication core module

Code scanning login module

Multi factor authentication module

Social login module

Management module:

Manage users

Management role

Management policy

Management authority and access control

Management Group

Management organization

Manage user defined fields

Manage registration white list

Manage user pool configuration

Log

Detailed changes for each version are recorded in the document.

Contribution

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].