...
\uD83D\uDCD8 Instructions
Library options
ssi-auth-lib
library shows QR for desktop browsers and Web-link button for mobile browsers to trigger the interaction. It has two options:Show QR/Web-link to trigger an interaction with QR initiation media selected.
Show QR/Web-link to trigger an interaction with QR initiation media selected and support SSI OAuth flow configured on the dashboard for this particular interaction.
Library can be included
<script src="<path_to_lib>/wl.js"></script>
or as npm library https://www.npmjs.com/package/ssi-auth-lib
npm install ssi-auth-lib –save
const ProofSpace = require(‘ssi-auth-lib’)
Usage
For the pure interaction without SSI OAuth flow
Code Block language typescript ProofSpace.WebLinker.start(elem, { serviceDid: <YOUR_SERVICE_DID>, interactionId: <YOUR_OAUTH_ACTION_ID>, instanceId: <YOUR_OAUTH_INSTANCE_ID>, size: 300 // size of QR code in pixels }).then(() => { console.log(‘QR Initialized’); });
For the interaction with SSI OAuth flow
Code Block language typescript ProofSpace.WebLinker.startWithSSIOAuth(elem, { serviceDid: <YOUR_SERVICE_DID>, interactionId: <YOUR_OAUTH_ACTION_ID>, instanceId: <YOUR_OAUTH_INSTANCE_ID>, size: 300 // size of QR code in pixels }).then((result) => { console.log(result.access_token); });
Both start and startWithSSIOAuth has 3 parameters:
start(element, config, preFilledCredentials)
where
...
Code Block | ||
---|---|---|
| ||
{ size?: number; // size of QR-code in pixels env?: Env; // environment config, usefulused for test, stage or local environment. Prod by default serviceDid: string; // your service did interactionId: string; // id of your interaction instanceId: string; // id of your interaction instance button?: BtnConfig; // config for styling button for mobile web link timer?: Style; // style for timer element (for SSIOAuth) qr?: Style; // style for QR element returnToBrowser?: boolean; // use callback for return to browser page popOverMode?: boolean; // use PopOver with QR code for desktop log?: LogFn; // function for logs (debug info) } |
...
Info |
---|
Note: the attribute values should all be string. According to the attribute type, which is set in the credential schema, values should be set to: Actual value types will be casted on credential attribute display in the app according to the credential schema attribute types. |
env : Env
is required if you want to use own OAuth server or service container, by default it uses ProofSpace PROD URIs.
Env template:
Code Block |
---|
{ containerURIPrefix: string SSIAuthenticationCredDefId: string; authServiceUrl: string; nativeURIPrefix: string } |
...