This packages contains:
src/
dist/node
dist/browser
<script>
tag <script src="https://cdn.blockpass.org/sdk/v2/blockpass.dev.js"></script>
const clientId = '...'
const env = 'staging|prod'
/*
Blockpass Environments:
- staging: Our testing enviroment (Blockpass partner and tester)
- prod: Live enviroment of Blockpass
*/
sdk = new window.Blockpass.WebSDK({
clientId,
env,
refreshRateMs: 1000
})
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
})}`
}
function onBlockpassProcessing(params) {
// session code invalid from now
// Show loading indicator
}
function onBlockpassSSoResult(params) {
// sso complete. handle your logic here
}
sdk.on('code-refresh', onBlockpassCodeRefresh)
sdk.on('sso-processing', onBlockpassProcessing)
sdk.on('sso-complete', onBlockpassSSoResult)
// 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
Extends EventEmitter
Blockpass WebSDK
Parameters
configData
…ConstructorParamsGenerate new SSO code and monitor status
Deconstructor
Generate appLink string Example: blockpass-local://sso/3rd_service_demo/c33ab4f2-c208-4cc0-9adf-e49cccff6d2c
###
Type: object
Properties
baseUrl
string Blockpass url.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
Properties
session
string sessionIDSession code switch to processing
Type: object
Properties
status
string status of session codeSession code switch to processing
Type: object
Properties
ApacheV2