This documentation covers both the frontend and backend SDKs for Universal Verify. Each SDK provides methods for implementing the OAuth flow and accessing user information.
Install via npm:
npm install universal-verify-js
Or use via CDN:
import FrontendSDK from 'https://cdn.jsdelivr.net/npm/universal-verify-js@0.0.2/build/universal-verify.min.js';
new FrontendSDK(clientId)
Creates a new instance of the FrontendSDK.
clientId
(string, required): Your Universal Verify client IDCreates an OAuth authorization URL.
options
(object):
codeChallenge
(string, required): The code challenge for PKCEredirectUrl
(string, required if multiple redirect URLs are configured): The redirect URL for the OAuth flow. Must match one of the URLs configured in your integration dashboard.scope
(string, optional): The OAuth scope. Defaults to 'verification openid age ...'state
(string, optional): A state parameter for securitynonce
(string, optional): A nonce for securitystring
: The complete authorization URL
Parses the OAuth redirect URL and extracts parameters.
object
: An object containing:
code
(string): The authorization codestate
(string): The state parameter (if provided)error
(string): Error code if authorization failederrorDescription
(string): Error description if authorization failedInstall via npm:
npm install universal-verify
new BackendSDK(clientId, clientSecret)
Creates a new instance of the BackendSDK.
clientId
(string, required): Your Universal Verify client IDclientSecret
(string, required): Your Universal Verify client secretCreates a PKCE code challenge from a code verifier.
codeVerifier
(string, optional): The code verifier. If not provided, a random one will be generated.object
: An object containing:
codeVerifier
(string): The code verifiercodeChallenge
(string): The generated code challengeExchanges an authorization code for access and refresh tokens.
options
(object):
code
(string, required): The authorization codecodeVerifier
(string, required): The code verifierredirectUri
(string, required): The redirect URI used in the authorization requestPromise
: The token response containing:
access_token
(string): The access tokenrefresh_token
(string): The refresh tokenid_token
(string): The OIDC ID tokenexpires_in
(number): Token expiration time in secondsscope
(string): Space-separated list of granted scopessub
(string): Unique user identifiertoken_type
(string): Always "Bearer"Retrieves user information using an access token.
accessToken
(string, required): The access tokentimezone
(string, optional): The timezone to use when age is includedPromise
: The user information object containing:
sub
(string): Unique user identifierverified
(boolean): Whether the user is verifiedverification_confidence
(number): Confidence level (1-3)age
(number): User's age (if requested)regional_info
(object): Regional information (if requested) containing:
region
(string): User's regionadditional_userinfo_url
(string): URL for additional regional informationRetrieves user's regional information using an access token.
accessToken
(string, required): The access tokenregionalUrl
(string, required): The regional URLPromise
: The regional user information object containing:
sub
(string): Unique user identifiername
(object): User's name information containing:
firstName
(string, optional): User's first namemiddleNames
(array of strings, optional): Array of user's middle nameslastName
(string, optional): User's last namesuffix
(string, optional): The suffix portion of the user's namefullName
(string, optional): User's full name with an attempt at localizationdate_of_birth
(string): User's date of birthid_type
(object): Information about the ID used containing:
country
(string): 3-letter country code that issued the IDtype
(string): Type of ID (e.g., 'state_id', 'passport')state
(string, optional): 2-letter state code that issued the ID (if applicable)Validates an ID token.
idToken
(string, required): The ID token to validatenonce
(string, optional): The nonce used in the authorization requestPromise
: The validated token claims
iss
(string): The issuer (https://api.universalverify.com)sub
(string): An ID for the user unique to the integrationaud
(string): Your integration's access keyexp
(number): The token's expiration time (unix time)iat
(number): The issued at time (unix time)verified
(boolean): Whether the user is verifiedverification_confidence
(number): Confidence level (1-3)Refreshes an access token using a refresh token.
refreshToken
(string, required): The refresh tokenPromise
: The new token response containing:
access_token
(string): The new access tokenrefresh_token
(string): The new refresh tokenexpires_in
(number): Token expiration time in secondsscope
(string): Space-separated list of granted scopessub
(string): Unique user identifiertoken_type
(string): Always "Bearer"Verifies a webhook signature and returns the parsed payload.
payload
(string, required): The webhook payloadsignature
(string, required): The webhook signaturewebhookSecret
(string, required): Your webhook secretobject
: The webhook's request body parameters containing:
type
(string): The event type (e.g. 'user.verification.updated')data
(object): The event-specific dataError
: If the webhook signature is invalid
Revokes an access or refresh token.
token
(string, required): The token to revokePromise
: The revocation result