Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@authing/guard

Package Overview
Dependencies
Maintainers
1
Versions
295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@authing/guard

Authing Guard for Native

  • 6.0.0-alpha.14
  • npm
  • Socket score

Version published
Weekly downloads
92
decreased by-22.03%
Maintainers
1
Weekly downloads
 
Created
Source

English | 简体中文


Guard is a portable authentication component provided by authing. You can embed it in any application to handle complex user authentication processes in one stop.

Prepare your native JavaScript project and follow the guide to connect Guard to your native JavaScript project!

Install

From CDN:

<link rel="stylesheet" href="https://cdn.authing.co/packages/guard/5.0.7/guard.min.css" />
<script src="https://cdn.authing.co/packages/guard/5.0.7/guard.min.js"></script>

From NPM:

npm install --save @authing/guard

Initialize

KeyTypeDefaultRequires
appIdString-Y
hostString-N
redirectUriString-N
modenormal / modalnormalN
defaultSceneGuardModuleTypeloginN
tenantIdString-N
langzh-CN / en-USzh-CNN
isSSOBooleantrueN
configPartial-N
// From CDN
const guard = new GuardFactory.Guard({
  appId: '62e22721c889dd44bad1dda2',
  host: 'https://guard-test-2022.authing.cn',
  redirectUri: 'http://localhost:3000/callback'
})

// From npm
const guard = new Guard({
  appId: '62e22721c889dd44bad1dda2',
  host: 'https://guard-test-2022.authing.cn',
  redirectUri: 'http://localhost:3000/callback'
})

Guard provides three login modes

Embed mode

Render Guard component

guard.start('#root').then(userInfo => {
  console.log(userInfo)
})

modal mode

When the parameter 'mode' of Guard instantiation is' modal ', the modal mode is started, and the following API can be used to display and hide the guard.

guard.show()
guard.hide()

Redirect mode

Login by code, redirect to login page

guard.startWithRedirect()

Auto handle redirect callback

guard.handleRedirectCallback()

Logout

guard.logout()

Regist events

guard.on('load', e => {
  console.log(e)
})

guard.on('login', userInfo => {
  console.log(userInfo)
})

// ......

Integrate authing js sdk instance

Guard integrated AuthenticationClient, so you can access all apis of AuthenticationClient, etc:

guard.getAuthClient().then(authClient => {
  authClient.registerByEmail()
  authClient.validateToken()
  // .........
})
// ....

Refer to Authentication SDK

Documentation

To check out live examples and docs, visit docs

FAQs

Package last updated on 05 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc