Skip to main content

Authenticate UWL Session

Authenticate UWL Session Data

After creating a UWL session and fetching UWL session information, users can submit and authenticate user data.

Parameters

  • dns (required): Your BlockID tenant domain as shown in the dashboard
  • communityName (required): Your BlockID tenant community as shown in the dashboard
  • licenseKey (required): BlockID license key as shown in the dashboard
  • appID (required): Name of the application submiting the request (i.e.: devx, com.yourapp.name)
  • data (required): Authentication data to be submitted (see below for example)
  • did (required): Unique decentralized identifier for a user (a uuid)
  • publicKey (required): Public key of the requesting application (see below for example)
  • sessionId (required): UWL session ID string (required)
  • sessionPublicKey (required): UWL session public key (created when fetching UWL session info)
  • eventData (optional): Optional event data (i.e., user device information)
  • ial (optional): Identity Assurance Level of a user

Request Format

  • Set tenant info and authenticate UWL session data
const BIDSessions = require('blockid-nodejs-helpers/BIDSessions');

let authenticatedResponse = await BIDSessions.authenticateSession({ "dns": "<dns>", "communityName": "<communityName>" }, <sessionId>, <publicKey>, <appId>, <did>, <data>, <ial>, <eventData>);

Example UWL Request

In order to show the complete request cycle, we are first:

After fetching the session information, we can submit and authenticating our UWL session data.

Example - Submit and authenticate UWL session data

// Create keyset (required to fetch our public key), and define metadata  
const BIDSessions = require('blockid-nodejs-helpers/BIDSessions');
const keySet = BIDTenant.getKeySet();

// Optional: Define metadata. Developers can pass "null" if defining metadata is not desired
let metadata = {
"purpose": "authentication"
}

// Set tenant info
let createdSessionResponse = await BIDSessions.createNewSession({ "dns": "blockid-trial.1kosmos.net", "communityName": "devx", "licenseKey": "0005c9f8-1918-40be-aa00-e319043f7xxx" }, null, null, metadata);

// Define required session information necessary for authentication
let sessionId = createdSessionResponse.sessionId;
let sessionsPublicKey = "CE8kpAxwLCGlFj2rGEADuHe7L2KtUncZqOccwlHWrQmr86bWivPljL5ReEIr/lr4ES3wFP446VtdYT/qtSOAOA==";
let appId = "devx.uwl.blockid";
let did = "1bfc3725-24d8-45fb-ad67-89f912a966a3";

// Create a shared key to encrypt session data
let sharedKey = BIDECDSA.createSharedKey(keySet.prKey, sessionsPublicKey);

// Define user data to be authenticated
let data = BIDECDSA.encrypt(JSON.stringify({ "username": "jenish", "firstName": "jenish", "lastName": "patel" }), sharedKey);

//Optionally set user IAL and event data. Developers can pass "null" if not needed
let ial = "IAL1";

let eventData = BIDECDSA.encrypt(JSON.stringify({ "deviceName": "iphone 14", "deviceId": "1211901109", "appId": "AB111CD11" }), sharedKey);

//Submit authentication data
let authenticatedResponse = await BIDSessions.authenticateSession({ "dns": "blockid-trial.1kosmos.net", "communityName": "devx", "licenseKey": "0005c9f8-1918-40be-aa00-e319043f7xxx" }, sessionId, publicKey, appId, did, data, ial, eventData);

Example Server Response

The SDK will return an immediate response from our API. The responses are the same across each SDK and are JSON formatted.

Server Responses

200 OK
{
"id": "65029ebe8592bc62ac45e85a",
"status": 200,
"message": "Session data submitted successfully"
}

The session data to be authenticated was successfully received. The submitted data will be returned during the UWL poll session response.