Node.js

Our Verifier Toolkit is a library for Node.js developers integrating with GlobaliD as a verifier. Be sure to check out the overview for verifiers.

Usage

Installation

npm install @globalid/verifier-toolkit

createPresentationRequestUrl

The createPresentationRequestUrl function creates a deep link into the GlobaliD mobile app. It accepts a single parameter, which is a CreatePresentationRequestUrlParams object with the following properties:

  • clientId (string) - your Developer App's ID (client_id)

  • initiationUrl (string) - corresponds to the deep link's proof_request_url

  • trackingId (string; optional) - correlation ID appended to initiationUrl as a tracking_id query parameter

  • redirectUrl (string; optional) - location to redirect users on their mobile device after responding to your presentation request

The return value is a URL-string pair of the generated deep link and the corresponding tracking ID.

import { createPresentationRequestUrl } from '@globalid/verifier-toolkit';

const [url, trackingId] = createPresentationRequestUrl({
  clientId: '01234567-890a-bcde-f012-3456789abcde',
  initiationUrl: 'https://your.domain/initiate-presentation'
});

createGidVerifierClient

The createGidVerifierClient function creates instances the GidVerifierClient class. It accepts a GidVerifierClientOptions object, which has the following properties:

  • clientId (string) - your Developer App's ID (client_id)

  • clientSecret (string) - your Developer App's client secret

import { createGidVerifierClient } from '@globalid/verifier-toolkit';

const client = createGidVerifierClient({
  clientId: '01234567-890a-bcde-f012-3456789abcde',
  clientSecret: 'abcdefghijklmnopqrstuvwxyz'
});

GidVerifierClient

The GidVerifierClient class facilitates communicating with GlobaliD's API. Instances are created via the createGidVerifierClient factory function.

createPresentationRequest

The createPresentationRequest method creates a presentation request. It accepts a CreatePresentationRequestDto parameter, which has the following properties:

  • presentationRequirements (PresentationRequirements) - Submit Requirement Feature object defining the requirements of the credential you like the holder to present

  • trackingId (string) - ID used to correlate presentation requests

  • webhookUrl (string) - URL for receiving a holder response

The return value is a PresentationRequestResponseDto, which should be returned to the holder.

const response = await client.createPresentationRequest({
  presentationRequirements: { ... },
  trackingId: 'fedcba98-7654-3210-fedc-ba9876543210',
  webhookUrl: 'https://your.domain/handle-user-response'
});

verifySignature

The verifySignature method verifies a message signature.

const isValid = await client.verifySignature(signature, holderResponse);

TypeScript

The toolkit is written in TypeScript and type declarations are bundled with it.

Demo

Check out our GitHub repo for a reference implementation of a verifier utilizing out toolkit.

Last updated