This packages contains:
- ES6 source code
src/
- Transpiler for node (below 6)
dist/node
- Transpiler for web-browser
dist/browser
- Add blockpass-web package via
<script>
tag
<script src="https://cdn.blockpass.org/sdk/v2.0.1/blockpass.dev.js"></script>
- Init SDK
/*
Blockpass Clientid
*/
const clientId = "...";
/*
Blockpass Environments:
- staging: Our testing enviroment (Blockpass partner and tester)
- prod: Live enviroment of Blockpass
*/
const env = "staging|prod";
/*
Reference Id: Your generated code. Which use to match KycRecord with your userId
*/
const refId = "";
sdk = new window.Blockpass.WebSDK({
clientId,
env,
refreshRateMs: 1000
});
- Subscribe to SDK events
function onBlockpassCodeRefresh(params) {
// session code ready to use now
// demo qrcode images ( using demo online qrserver ).
// DON'T USE THIS FOR YOUR SERVICE
document.getElementById(
"step1-qr"
).src = `http://api.qrserver.com/v1/create-qr-code/?data=${JSON.stringify({
clientId: "...",
session: params.session,
refId
})}`;
}
function onBlockpassProcessing(params) {
// session code invalid from now
// Show loading indicator
}
function onBlockpassSSoResult(params) {
// sso complete. handle your logic here
}
function onBlockpassSessionExpired() {
// session code expired.
// Note: You can reset new code via
// sdk.generateSSOData()
//
}
// Setup events handler
sdk.on("code-refresh", onBlockpassCodeRefresh);
sdk.on("sso-processing", onBlockpassProcessing);
sdk.on("sso-complete", onBlockpassSSoResult);
sdk.on("code-expired", onBlockpassSessionExpired);
// request for new sso code
sdk.generateSSOData();
$ yarn install
$ npm test # run tests with Jest
$ npm run coverage # run tests with coverage and open it on browser
$ npm run lint # lint code
$ npm run docs # generate docs
$ npm run build # generate docs and transpile code
$ npm run watch # watch code changes and run scripts automatically
- WebSDK
- ConstructorParams
- WebSDK#code-refresh
- WebSDK#sso-processing
- WebSDK#sso-complete
- WebSDK#code-expired
Extends EventEmitter
Blockpass WebSDK
configData
...ConstructorParams
Generate new SSO code and monitor status
Deconstructor
Generate appLink string Example: blockpass-local://service-register/3rd_service_demo?session=c33ab4f2-c208-4cc0-9adf-e49cccff6d2c
Type: object
env
string Deployment env (local|staging|prod).clientId
string Blockpass ClientId (obtain when register with Blockpass platform).
Generated session code, can only be used once. Life cycles (created -> processing -> success|failed) Client must refresh code after sso failed / timeout
Type: object
session
string sessionID
Session code switch to processing
Type: object
status
string status of session code
Session code switch to processing
Type: object
Session code expired
Type: object
ApacheV2