@mattrglobal/verifier-sdk-web 1.1.1-unstable.154 → 1.1.1-unstable.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/dist/lib/verifier-js-no-deps.cjs.js +24 -24
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +24 -24
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/index.d.ts +4 -4
- package/dist/typings/verifier/index.d.ts +1 -1
- package/dist/typings/verifier/initialize.d.ts +12 -0
- package/dist/typings/verifier/types/credential-presentation.d.ts +1 -1
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +3 -3
- package/dist/typings/verifier/utils.d.ts +3 -3
- package/dist/verifier-js.development.js +24 -24
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +2 -2
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +2 -2
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +2 -2
- package/dist/typings/verifier/initialise.d.ts +0 -12
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
- [Web project with an existing bundler set up](#web-project-with-an-existing-bundler-set-up)
|
|
13
13
|
- [Loading directly from script tag](#loading-directly-from-script-tag)
|
|
14
14
|
- [Usage](#usage)
|
|
15
|
-
- [
|
|
15
|
+
- [Initialize the SDK](#initialize-the-sdk)
|
|
16
16
|
- [Prepare a credential query](#prepare-a-credential-query)
|
|
17
17
|
- [Generate challenge](#generate-challenge)
|
|
18
18
|
- [Determine supported presentation flows](#determine-supported-presentation-flows)
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
## Licensing
|
|
30
30
|
|
|
31
31
|
Request or download the
|
|
32
|
-
[MATTR Pi SDK Trial
|
|
32
|
+
[MATTR Pi SDK Trial License Agreement](https://learn.mattr.global/docs/terms/mattr-pi-sdk-licence-agreement) and the
|
|
33
33
|
[MATTR Customer Agreement](https://learn.mattr.global/docs/terms/customer-agreement) and review these terms carefully.
|
|
34
34
|
|
|
35
35
|
## Overview
|
|
@@ -69,7 +69,7 @@ yarn add @mattrglobal/verifier-sdk-web
|
|
|
69
69
|
```javascript
|
|
70
70
|
import * as MATTRVerifierSDK from "@mattrglobal/verifier-sdk-web";
|
|
71
71
|
|
|
72
|
-
MATTRVerifierSDK.
|
|
72
|
+
MATTRVerifierSDK.initialize(...);
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
### Loading directly from script tag
|
|
@@ -86,26 +86,26 @@ MATTRVerifierSDK.initialise(...);
|
|
|
86
86
|
|
|
87
87
|
```javascript
|
|
88
88
|
<script>
|
|
89
|
-
MATTRVerifierSDK.
|
|
89
|
+
MATTRVerifierSDK.initialize(...);
|
|
90
90
|
</script>
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
# Usage
|
|
94
94
|
|
|
95
95
|
The SDK can make a request to create a presentation session with a configured MATTR VII verifier tenant. This requires the following configurations and settings:
|
|
96
|
-
*
|
|
96
|
+
* Initialize the SDK with the URL of the MATTR VII tenant that will handle the verification request.
|
|
97
97
|
* Prepare a credential query that defines what claims are required for verification.
|
|
98
98
|
* Generate a unique challenge for the presentation session.
|
|
99
99
|
* Determine what presentation flows are supported in the session.
|
|
100
100
|
* Define what wallets can be used to respond to the verification request.
|
|
101
101
|
* Configure the URI the user will be redirected to when the verification workflow is completed (only required for same-device flows).
|
|
102
102
|
|
|
103
|
-
##
|
|
103
|
+
## Initialize the SDK
|
|
104
104
|
|
|
105
|
-
You must
|
|
105
|
+
You must initialize the SDK before you can use any of its functions and methods:
|
|
106
106
|
|
|
107
107
|
```javascript
|
|
108
|
-
MATTRVerifierSDK.
|
|
108
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
- `apiBaseUrl` (required): URL of the MATTR VII verifier tenant.
|
|
@@ -144,7 +144,7 @@ const credentialQuery = [
|
|
|
144
144
|
```
|
|
145
145
|
* `profile`: Credential format of the credential that will be verified. Currently only mobile (mDocs) is supported.
|
|
146
146
|
* `docType`: the mDL’s type. Confirm with the certificate issuer for what docType they are issuing. Some common examples include:
|
|
147
|
-
* Mobile Driver
|
|
147
|
+
* Mobile Driver License (`org.iso.18013.5.1.mDL`).
|
|
148
148
|
* PhotoID (`org.iso.23220.photoid.1`).
|
|
149
149
|
* Mobile Vehicle Registration Card (`org.iso.7367.1.mVRC`).
|
|
150
150
|
* Health certificate (`org.micov.vtr.1`).
|
|
@@ -197,7 +197,7 @@ When using the same-device presentation flow, the SDK must define what URI to re
|
|
|
197
197
|
## Request credentials with automatic flow selection
|
|
198
198
|
|
|
199
199
|
```javascript
|
|
200
|
-
MATTRVerifierSDK.
|
|
200
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId }); // Initialize the SDK
|
|
201
201
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
202
202
|
credentialQuery: [credentialQuery], // Define what credential query to use
|
|
203
203
|
challenge: MATTRVerifierSDK.utils.generateChallenge(), // Pass a unique challenge
|
|
@@ -221,7 +221,7 @@ if (result.isErr()) {
|
|
|
221
221
|
## Request credentials with explicit same-device flow
|
|
222
222
|
|
|
223
223
|
```javascript
|
|
224
|
-
MATTRVerifierSDK.
|
|
224
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
225
225
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
226
226
|
credentialQuery: [credentialQuery],
|
|
227
227
|
challenge: MATTRVerifierSDK.utils.generateChallenge(),
|
|
@@ -232,7 +232,7 @@ const result = await MATTRVerifierSDK.requestCredentials({
|
|
|
232
232
|
|
|
233
233
|
// result can be retrieved on redirect uri page. for example
|
|
234
234
|
window.addEventListener("load", async () => {
|
|
235
|
-
MATTRVerifierSDK.
|
|
235
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
236
236
|
const result = await MATTRVerifierSDK.handleRedirectCallback();
|
|
237
237
|
});
|
|
238
238
|
```
|
|
@@ -244,7 +244,7 @@ window.addEventListener("load", async () => {
|
|
|
244
244
|
## Request credentials with explicit cross-device flow
|
|
245
245
|
|
|
246
246
|
```javascript
|
|
247
|
-
MATTRVerifierSDK.
|
|
247
|
+
MATTRVerifierSDK.initialize({ apiBaseUrl, applicationId });
|
|
248
248
|
const result = await MATTRVerifierSDK.requestCredentials({
|
|
249
249
|
credentialQuery: [credentialQuery],
|
|
250
250
|
challenge: MATTRVerifierSDK.utils.generateChallenge(),
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2025-05-
|
|
10
|
+
* Generated: 2025-05-19
|
|
11
11
|
* Version: 1.1.0
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*/
|
|
@@ -307,7 +307,7 @@ var AbortSessionErrorMessage;
|
|
|
307
307
|
AbortSessionErrorMessage["FailedToAbortSession"] = "Failed to abort session";
|
|
308
308
|
})(AbortSessionErrorMessage || (AbortSessionErrorMessage = {}));
|
|
309
309
|
|
|
310
|
-
const
|
|
310
|
+
const InitializeOptionsValidator = v__namespace.object({
|
|
311
311
|
apiBaseUrl: v__namespace.pipe(v__namespace.string(), v__namespace.nonEmpty("Must not be empty")),
|
|
312
312
|
applicationId: v__namespace.pipe(v__namespace.string(), v__namespace.nonEmpty("Must not be empty"))
|
|
313
313
|
});
|
|
@@ -350,20 +350,20 @@ const safeFetch = async (input, init) => {
|
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
352
|
|
|
353
|
-
let
|
|
353
|
+
let initializeOptions = undefined;
|
|
354
354
|
|
|
355
|
-
var
|
|
355
|
+
var InitializeErrorMessage;
|
|
356
356
|
|
|
357
|
-
(function(
|
|
358
|
-
|
|
359
|
-
})(
|
|
357
|
+
(function(InitializeErrorMessage) {
|
|
358
|
+
InitializeErrorMessage["SdkNotInitialized"] = "SDK not initialized";
|
|
359
|
+
})(InitializeErrorMessage || (InitializeErrorMessage = {}));
|
|
360
360
|
|
|
361
|
-
const
|
|
362
|
-
assertType(
|
|
363
|
-
|
|
361
|
+
const initialize = options => {
|
|
362
|
+
assertType(InitializeOptionsValidator, "Invalid initialize options")(options);
|
|
363
|
+
initializeOptions = options;
|
|
364
364
|
};
|
|
365
365
|
|
|
366
|
-
const
|
|
366
|
+
const getInitializeOptions = () => initializeOptions;
|
|
367
367
|
|
|
368
368
|
let sessionAbortController = undefined;
|
|
369
369
|
|
|
@@ -687,11 +687,11 @@ const requestCredentialsWithCrossDevice = async options => {
|
|
|
687
687
|
};
|
|
688
688
|
|
|
689
689
|
const abortCredentialRequest = async () => {
|
|
690
|
-
const
|
|
691
|
-
if (!
|
|
692
|
-
throw new Exception(
|
|
690
|
+
const initializeOptions = getInitializeOptions();
|
|
691
|
+
if (!initializeOptions) {
|
|
692
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
693
693
|
}
|
|
694
|
-
const {apiBaseUrl: apiBaseUrl} =
|
|
694
|
+
const {apiBaseUrl: apiBaseUrl} = initializeOptions;
|
|
695
695
|
const session = getActiveSession();
|
|
696
696
|
if (!session || !session.sessionKey) {
|
|
697
697
|
return neverthrow.ok(undefined);
|
|
@@ -905,12 +905,12 @@ const requestCredentialsSameDevice = async options => {
|
|
|
905
905
|
|
|
906
906
|
const requestCredentials = async options => {
|
|
907
907
|
var _a;
|
|
908
|
-
const
|
|
909
|
-
if (!
|
|
910
|
-
throw new Exception(
|
|
908
|
+
const initializeOptions = getInitializeOptions();
|
|
909
|
+
if (!initializeOptions) {
|
|
910
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
911
911
|
}
|
|
912
912
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
913
|
-
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} =
|
|
913
|
+
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initializeOptions;
|
|
914
914
|
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration} = options;
|
|
915
915
|
const dcApiSupported = isDigitalCredentialsApiSupported();
|
|
916
916
|
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
@@ -1001,11 +1001,11 @@ var HandleRedirectCallbackErrorMessage;
|
|
|
1001
1001
|
})(HandleRedirectCallbackErrorMessage || (HandleRedirectCallbackErrorMessage = {}));
|
|
1002
1002
|
|
|
1003
1003
|
const handleRedirectCallback = async () => {
|
|
1004
|
-
const
|
|
1005
|
-
if (!
|
|
1006
|
-
throw new Exception(
|
|
1004
|
+
const initializeOptions = getInitializeOptions();
|
|
1005
|
+
if (!initializeOptions) {
|
|
1006
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
1007
1007
|
}
|
|
1008
|
-
const {apiBaseUrl: apiBaseUrl} =
|
|
1008
|
+
const {apiBaseUrl: apiBaseUrl} = initializeOptions;
|
|
1009
1009
|
const responseCode = getHashParamValue(window.location.hash, "response_code");
|
|
1010
1010
|
if (!responseCode) {
|
|
1011
1011
|
return neverthrow.err({
|
|
@@ -1050,7 +1050,7 @@ exports.abortCredentialRequest = abortCredentialRequest;
|
|
|
1050
1050
|
|
|
1051
1051
|
exports.handleRedirectCallback = handleRedirectCallback;
|
|
1052
1052
|
|
|
1053
|
-
exports.
|
|
1053
|
+
exports.initialize = initialize;
|
|
1054
1054
|
|
|
1055
1055
|
exports.isDigitalCredentialsApiSupported = isDigitalCredentialsApiSupported;
|
|
1056
1056
|
|