psbalaji777.github.io

Blockpass SdkWeb

Structure

This packages contains:

Getting started (browser)

  1. Add blockpass-web package via <script> tag
    <script src="https://cdn.blockpass.org/sdk/v2/blockpass.dev.js"></script>
  1. Init SDK
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
})
  1. 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
  })}`
}

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()

Development Instalation

$ yarn install

Development Commands

$ 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

API

Table of Contents

WebSDK

Extends EventEmitter

Blockpass WebSDK

Parameters

generateSSOData

Generate new SSO code and monitor status

destroy

Deconstructor

Generate appLink string Example: blockpass-local://sso/3rd_service_demo/c33ab4f2-c208-4cc0-9adf-e49cccff6d2c

Returns Promise<string?>

###


ConstructorParams

Type: object

Properties

WebSDK#code-refresh

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

WebSDK#sso-processing

Session code switch to processing

Type: object

Properties

WebSDK#sso-complete

Session code switch to processing

Type: object

Properties

License

ApacheV2