¶ Main authentication module
Update Time: 2024-10-10 07:28:40
This module is used to conduct body authentication, such as personal authentication or corporate certification.
Sample code:
import { AuthenticationClient } from 'authing-js-sdk'
const authenticationClient = new AuthenticationClient({
appId: 'AUTHING_APP_ID',
appHost: 'https://{YOUR_DOMAIN}.authing.cn',
})
authenticationClient.principal.detail
authenticationClient.principal.authenticate
¶ Obtain certification details
PrincipalAuthentication().detail()
Get the main authentication details
¶ parameter
without
¶ Example
const authenticationClient = new AuthenticationClient({
appId: 'AUTHING_APP_ID',
appHost: 'https://{YOUR_DOMAIN}.authing.cn',
})
const authenticators = await authenticationClient.principal.detail()
¶ return value
Promise<PrincipalDetail | null>
, return when not authenticatednull
¶ Sample data
{
"id": "60b4d72f56b49fb97281001b",
"createdAt": "2021-05-31T12:31:43.416Z",
"updatedAt": "2021-05-31T12:31:43.416Z",
"userPoolId": "607fe30c14d1650eb1d888ca",
"userId": "60a336dc179abb512dd64ae7",
"principalType": "P", // "P" represents personal authentication, "E" individual authentication
"principalName": "xxx",
"principalCode": "xxxxxxxxxxxxxxx",
"authenticationTime": "2021-05-31T12:31:43.414Z"
}
¶ Subject authentication
PrincipalAuthentication().authenticate(principalInfo)
Subject authentication
¶ parameter
The parameters that are incorporated when performing personal authentication and corporate certification, as follows.
¶ Personal authentication
principalInfo
: <object>principalInfo.type
: <string> Personal certification should be passed to the fixed string "P"principalInfo.name
: <string> Personal real nameprincipalInfo.idCard
: <string> Personal ID numberprincipalInfo.bankCard
: <string> Personal bank card number
¶ Enterprise Certification
principalInfo
: <object>principalInfo.type
: <string> Companies should pass authentication fixed string "E"principalInfo.enterpriseName
: <string> Company NameprincipalInfo.enterpriseCode
: <string> Enterprise unified social credit codeprincipalInfo.legalPersonName
: <string> Corporate legal name
¶ Example
const authenticationClient = new AuthenticationClient({
appId: 'AUTHING_APP_ID',
appHost: 'https://{YOUR_DOMAIN}.authing.cn',
})
await authenticationClient.principal.authenticate({
type: 'P',
name: 'xxx',
idCard: 'xxxxxxxxxxxxxxxx',
bankCard: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
})
¶ return value
Promise<boolean>
, the authentication is successful returntrue
¶ Sample data
true