
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@sumsub/id-connect
Advanced tools
[](https://www.npmjs.com/package/@sumsub/id-connect) [](https://opensource.org/licenses/MIT) [. When authorization is successful, the onSuccess
callback receives an authorization code that must be exchanged for tokens by your backend service.
Important: The authorization code is short-lived and should be exchanged for tokens as soon as possible.
onSuccess
callbackFor security reasons, all token exchange operations should be performed on your backend, never in the browser.
There are two main ways to use this library:
import { createButton } from '@sumsub/id-connect';
createButton({
clientId: 'your-client-id',
container: document.getElementById('button-container'),
onSuccess: (response) => console.log('Authorization successful:', response.code),
onError: (error) => console.error('Authorization error:', error.message),
className: 'custom-button-class',
text: 'Sign in with Sumsub ID'
});
import { openModal } from '@sumsub/id-connect';
document.getElementById('your-custom-button').addEventListener('click', () => {
openModal({
clientId: 'your-client-id',
onSuccess: (response) => console.log('Authorization successful:', response.code),
onError: (error) => console.error('Authorization error:', error.message),
onLoading: (isLoading) => console.log('Loading state:', isLoading)
});
});
You can also use the UMD build by including it directly in your HTML:
<script src="https://unpkg.com/@sumsub/id-connect/dist/index.umd.js"></script>
<script>
SumsubIdConnect.createButton({
clientId: 'your-client-id',
container: document.getElementById('button-container'),
onSuccess: (response) => console.log('Authorization successful:', response.code),
onError: (error) => console.error('Authorization error:', error.message)
// onLoading is automatically managed by the button
});
</script>
Opens a popup window for OAuth authorization with Sumsub ID.
options
(Object):
clientId
(string): Your Sumsub ID client idonSuccess
(function): Callback function that receives the authorization responseonError
(function, optional): Callback function that receives any errorsonLoading
(function, optional): Callback function that receives a boolean indicating loading statestate
(string, optional): OAuth state parameter for securitycodeChallenge
(string, optional): PKCE code challengebaseUrl
(string, optional): Custom base URL for the OAuth serverVoid. The function opens a popup window and handles the authorization flow through callbacks.
openModal({
clientId: 'your-client-id',
onSuccess: (response) => console.log('Authorization successful:', response.code),
onError: (error) => console.error('Authorization error:', error.message),
onLoading: (isLoading) => console.log('Loading state:', isLoading),
state: 'random-state-string', // Optional
codeChallenge: 'code-challenge-string' // Optional
});
Creates a button that triggers the OAuth authorization flow when clicked.
options
(Object):
clientId
(string): Your Sumsub ID client idcontainer
(HTMLElement): The HTML element where the button will be appendedonSuccess
(function): Callback function that receives the authorization responseonError
(function, optional): Callback function that receives any errorsonLoading
(function, optional): Callback function for loading state (automatically managed by the button)className
(string, optional): CSS class name for styling the buttontext
(string, optional): Button text (default: 'Connect')state
(string, optional): OAuth state parameter for securitycodeChallenge
(string, optional): PKCE code challengebaseUrl
(string, optional): Custom base URL for the OAuth serverVoid. The function creates a button in the specified container and sets up the authorization flow.
createButton({
clientId: 'your-client-id',
container: document.getElementById('button-container'),
onSuccess: (response) => console.log('Authorization successful:', response.code),
onError: (error) => console.error('Authorization error:', error.message),
className: 'custom-button',
text: 'Login with Sumsub ID'
// onLoading is automatically managed by the button
});
The response object received after successful authorization.
type AuthorizeResponse = {
code?: string; // Authorization code
state?: string; // State parameter (if provided in the request)
};
To integrate with Sumsub ID Connect, you need to:
Exchange the authorization code for a Sumsub ID Connect token on your backend:
Endpoint: /resources/snsId/api/connect/token
Method: POST
Request Body:
{
"code": "authorization_code_from_frontend",
"codeVerifier": "code_verifier_used_during_authorization"
}
Response: { "token": "sumsub_id_connect_token_value" }
Example (cURL):
curl -X POST https://api.sumsub.com/resources/snsId/api/connect/token \
-H "Content-Type: application/json" \
-d '{
"code": "authorization_code_from_frontend",
"codeVerifier": "code_verifier_used_during_authorization"
}'
Use the Sumsub ID Connect token to obtain a Sumsub ID Share Token (generated by client1 for client2):
Endpoint: /resources/accessTokens/sumsubIdShareToken
Method: POST
Request Body:
{
"forClientId": "client2_id",
"sumsubIdConnectToken": "sumsub_id_connect_token_from_previous_step"
}
Response: { "token": "sumsub_id_share_token_value" }
Example (cURL):
curl -X POST https://api.sumsub.com/resources/accessTokens/sumsubIdShareToken \
-H "Content-Type: application/json" \
-d '{
"forClientId": "client2_id",
"sumsubIdConnectToken": "sumsub_id_connect_token_from_previous_step"
}'
After client2 receives the Sumsub ID Share Token from client1, they can generate a SDK Access token:
Endpoint: /resources/accessTokens/sdk
Method: POST
Request Body:
{
"userId": "unique_user_identifier",
"levelName": "verification_level_name",
"sumsubIdShareToken": "sumsub_id_share_token_from_client1"
}
Response: { "token": "sdk_access_token_value" }
Example:
async function getSdkToken(levelName, sumsubIdShareToken) {
return client2Api('/resources/accessTokens/sdk', {
method: 'POST',
body: {
userId: new Date().getTime().toString(), // Unique user ID
levelName, // Verification level
sumsubIdShareToken,
},
});
}
This SDK Access token is used to initialize and launch the WebSDK2.
Here's a simplified example of integrating the Sumsub ID Connect button:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sumsub ID Connect Example</title>
<style>
.sumsub-button {
background-color: #4285f4;
color: white;
padding: 10px 20px;
border-radius: 4px;
border: none;
cursor: pointer;
}
.sumsub-button:hover { background-color: #3367d6; }
.sumsub-button:disabled { background-color: #cccccc; }
</style>
</head>
<body>
<div id="button-container"></div>
<script type="module">
import { createButton } from '@sumsub/id-connect';
createButton({
clientId: 'your-client-id',
container: document.getElementById('button-container'),
className: 'sumsub-button',
text: 'Sign in with Sumsub ID',
onSuccess: (response) => console.log('Authorization successful:', response),
onError: (error) => console.error('Authorization error:', error.message)
});
</script>
</body>
</html>
See the CHANGELOG.md file for details on all changes to the library.
This package is MIT licensed.
The library is compatible with all modern web browsers (Chrome, Firefox, Safari, Edge, Opera) but has not been tested in native mobile applications.
If you encounter any issues or have questions about this package, please contact Sumsub support.
FAQs
[](https://www.npmjs.com/package/@sumsub/id-connect) [](https://opensource.org/licenses/MIT) [![TypeScript](https://img.sh
We found that @sumsub/id-connect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.