@mattrglobal/verifier-sdk-web 2.0.0-preview-digital-credential-api.5 → 2.0.1-unstable.0
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 +71 -86
- package/dist/lib/verifier-js-no-deps.cjs.js +609 -353
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +912 -528
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/common/safeFetch.d.ts +6 -3
- package/dist/typings/common/sleep.d.ts +1 -0
- package/dist/typings/index.d.ts +6 -7
- package/dist/typings/verifier/abortCredentialRequest.d.ts +6 -0
- package/dist/typings/verifier/handleRedirectCallback.d.ts +1 -1
- package/dist/typings/verifier/index.d.ts +3 -1
- package/dist/typings/verifier/initialize.d.ts +12 -0
- package/dist/typings/verifier/instanceContext.d.ts +7 -0
- package/dist/typings/verifier/requestCredentials.d.ts +2 -2
- package/dist/typings/verifier/requestCredentialsCrossDevice.d.ts +3 -47
- package/dist/typings/verifier/requestCredentialsDigitalCredentialsApi.d.ts +17 -0
- package/dist/typings/verifier/requestCredentialsSameDevice.d.ts +1 -1
- package/dist/typings/verifier/types/credential-presentation.d.ts +140 -85
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +155 -272
- package/dist/typings/verifier/utils.d.ts +23 -37
- package/dist/verifier-js.development.js +868 -516
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +4 -4
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +4 -4
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +3 -3
- package/dist/typings/verifier/initialise.d.ts +0 -12
- package/dist/typings/verifier/requestCredentialsViaDigitalCredentialsApi.d.ts +0 -7
|
@@ -1,280 +1,137 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { BaseError } from "../../common";
|
|
3
|
-
import {
|
|
4
|
-
import { CredentialQuery, DcqlCredentialQuery, PresentationSessionResult } from "./credential-presentation";
|
|
3
|
+
import { CredentialQuery, Mode, PresentationSessionResult } from "./credential-presentation";
|
|
5
4
|
export declare enum LocalStorageKey {
|
|
6
5
|
challenge = "mattr_chg",
|
|
7
6
|
sessionId = "mattr_sid"
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
export declare enum Mode {
|
|
13
|
-
/**
|
|
14
|
-
* The credentials are requested on the same device
|
|
15
|
-
*/
|
|
16
|
-
sameDevice = "sameDevice",
|
|
17
|
-
/**
|
|
18
|
-
* The credentials are requested on a different device
|
|
19
|
-
*/
|
|
20
|
-
crossDevice = "crossDevice"
|
|
21
|
-
}
|
|
8
|
+
export declare const MATTR_SDK_VERSION_HEADER = "x-mattr-sdk-version";
|
|
9
|
+
export declare const MATTR_SDK_VERSION_VALUE = "2.0.0";
|
|
22
10
|
export declare enum MessageEventDataType {
|
|
23
11
|
PresentationCompleted = "PresentationCompleted",// { type: "PresentationCompleted", responseCode, sessionId }
|
|
24
12
|
PresentationTimeout = "PresentationTimeout",// { type: "PresentationTimeout", sessionId }
|
|
25
13
|
PresentationAbort = "PresentationAbort"
|
|
26
14
|
}
|
|
27
15
|
export type SameDeviceRequestCredentialsOptions = {
|
|
28
|
-
credentialQuery: CredentialQuery[] | DcqlCredentialQuery;
|
|
29
|
-
redirectUri: string;
|
|
30
16
|
challenge: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export type CrossDeviceCallbackOnCompleteResponse = {
|
|
36
|
-
/**
|
|
37
|
-
* Contains the result of the presentation session if result is configured to be available in the front channel
|
|
38
|
-
*/
|
|
39
|
-
result: PresentationSessionResult | {
|
|
40
|
-
sessionId: string;
|
|
41
|
-
};
|
|
17
|
+
apiBaseUrl: string;
|
|
18
|
+
applicationId: string;
|
|
19
|
+
sessionUrl: string;
|
|
20
|
+
sessionKey: string;
|
|
42
21
|
sessionId: string;
|
|
43
22
|
};
|
|
44
|
-
export type CrossDeviceCallback = {
|
|
45
|
-
/**
|
|
46
|
-
* The function to be executed on completion of the credential request.
|
|
47
|
-
* @param result
|
|
48
|
-
*/
|
|
49
|
-
onComplete: (result: CrossDeviceCallbackOnCompleteResponse) => void;
|
|
50
|
-
/**
|
|
51
|
-
* The function to be executed on failure of the credential request.
|
|
52
|
-
* @param error
|
|
53
|
-
*/
|
|
54
|
-
onFailure: (error: CrossDeviceCallbackError) => void;
|
|
55
|
-
};
|
|
56
23
|
export type CrossDeviceRequestCredentialsOptions = {
|
|
57
|
-
credentialQuery: CredentialQuery[] | DcqlCredentialQuery;
|
|
58
|
-
crossDeviceCallback: CrossDeviceCallback;
|
|
59
24
|
challenge: string;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export type DigitalCredentialsApiRequestOptions = {
|
|
65
|
-
credentialQuery: CredentialQuery[] | DcqlCredentialQuery;
|
|
66
|
-
challenge: string;
|
|
67
|
-
initialiseOptions: InitialiseOptions;
|
|
25
|
+
apiBaseUrl: string;
|
|
26
|
+
sessionUrl: string;
|
|
27
|
+
sessionKey: string;
|
|
28
|
+
sessionId: string;
|
|
68
29
|
};
|
|
69
30
|
/**
|
|
70
|
-
* Options for
|
|
31
|
+
* Options for openid4vpConfiguration to request credentials via a same-device flow.
|
|
71
32
|
*/
|
|
72
|
-
export type
|
|
33
|
+
export type OpenId4vpConfigurationSameDeviceOptions = {
|
|
73
34
|
/**
|
|
74
|
-
* An
|
|
35
|
+
* An optional identifier for MATTR VII wallet provider configuration.
|
|
36
|
+
*
|
|
37
|
+
* If not provided, defaults to the global wallet schema 'mdoc-openid4vp://'.
|
|
75
38
|
*/
|
|
76
|
-
|
|
39
|
+
walletProviderId?: string;
|
|
77
40
|
/**
|
|
78
|
-
*
|
|
41
|
+
* A mode in which the credentials are requested. Set to Mode.SameDevice for this type.
|
|
42
|
+
* Can be undefined
|
|
79
43
|
*/
|
|
80
|
-
|
|
44
|
+
mode: Mode.SameDevice;
|
|
81
45
|
/**
|
|
82
|
-
*
|
|
46
|
+
* redirectUri is required if mode is same device or undefined
|
|
83
47
|
*/
|
|
84
|
-
|
|
48
|
+
redirectUri: string;
|
|
49
|
+
};
|
|
50
|
+
export declare const OpenId4vpConfigSameDeviceOptionsValidator: v.ObjectSchema<{
|
|
51
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
52
|
+
readonly mode: v.LiteralSchema<Mode.SameDevice, undefined>;
|
|
53
|
+
readonly redirectUri: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">, v.UrlAction<string, undefined>]>;
|
|
54
|
+
}, undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Options for openid4vpConfiguration to request credentials via a cross-device flow.
|
|
57
|
+
*/
|
|
58
|
+
export type OpenId4vpConfigurationCrossDeviceOptions = {
|
|
85
59
|
/**
|
|
86
60
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
87
61
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
88
62
|
*/
|
|
89
63
|
walletProviderId?: string;
|
|
90
64
|
/**
|
|
91
|
-
*
|
|
65
|
+
* A mode in which the credentials are requested. Set to Mode.CrossDevice for this type.
|
|
92
66
|
*/
|
|
93
|
-
mode: Mode.
|
|
67
|
+
mode: Mode.CrossDevice;
|
|
94
68
|
};
|
|
95
|
-
export declare const
|
|
96
|
-
readonly
|
|
97
|
-
|
|
98
|
-
readonly docType: v.StringSchema<undefined>;
|
|
99
|
-
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
100
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
101
|
-
}, undefined>, undefined>, undefined>;
|
|
102
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
103
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
104
|
-
nameSpaces: {
|
|
105
|
-
[x: string]: {
|
|
106
|
-
[x: string]: {
|
|
107
|
-
intentToRetain?: boolean | undefined;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
docType: string;
|
|
112
|
-
}[], undefined>]>, v.ObjectSchema<{
|
|
113
|
-
readonly credentials: v.ArraySchema<v.ObjectSchema<{
|
|
114
|
-
readonly id: v.StringSchema<undefined>;
|
|
115
|
-
readonly format: v.StringSchema<undefined>;
|
|
116
|
-
readonly meta: v.OptionalSchema<v.UnknownSchema, never>;
|
|
117
|
-
readonly claims: v.ArraySchema<v.ObjectSchema<{
|
|
118
|
-
readonly path: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
119
|
-
}, undefined>, undefined>;
|
|
120
|
-
}, undefined>, undefined>;
|
|
121
|
-
readonly credential_sets: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
122
|
-
readonly options: v.ArraySchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
123
|
-
readonly required: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
124
|
-
readonly purpose: v.OptionalSchema<v.UnknownSchema, never>;
|
|
125
|
-
}, undefined>, undefined>, never>;
|
|
126
|
-
}, undefined>], undefined>;
|
|
127
|
-
readonly redirectUri: v.StringSchema<undefined>;
|
|
128
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
129
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
130
|
-
readonly mode: v.PicklistSchema<[Mode.sameDevice], undefined>;
|
|
69
|
+
export declare const OpenId4vpConfigCrossDeviceOptionsValidator: v.ObjectSchema<{
|
|
70
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
71
|
+
readonly mode: v.LiteralSchema<Mode.CrossDevice, undefined>;
|
|
131
72
|
}, undefined>;
|
|
132
73
|
/**
|
|
133
|
-
* Options for the
|
|
74
|
+
* Options for openid4vpConfiguration which allow to auto-detect the device mode
|
|
134
75
|
*/
|
|
135
|
-
export type
|
|
136
|
-
/**
|
|
137
|
-
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
138
|
-
*/
|
|
139
|
-
credentialQuery: CredentialQuery[] | DcqlCredentialQuery;
|
|
140
|
-
/**
|
|
141
|
-
* The callback functions to be executed on success or failure of the credential request in cross device mode.
|
|
142
|
-
*/
|
|
143
|
-
crossDeviceCallback: CrossDeviceCallback;
|
|
144
|
-
/**
|
|
145
|
-
* An optional challenge string that is used to ensure the security and integrity of the credential request. If not provided, a challenge will be generated by default.
|
|
146
|
-
*/
|
|
147
|
-
challenge?: string;
|
|
76
|
+
export type OpenId4vpConfigurationAutoDetectOptions = {
|
|
148
77
|
/**
|
|
149
78
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
150
79
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
151
80
|
*/
|
|
152
81
|
walletProviderId?: string;
|
|
153
82
|
/**
|
|
154
|
-
*
|
|
83
|
+
* redirect uri to use for same device mode
|
|
155
84
|
*/
|
|
156
|
-
|
|
85
|
+
redirectUri: string;
|
|
86
|
+
/**
|
|
87
|
+
* An optional mode in which the credentials are requested.
|
|
88
|
+
*
|
|
89
|
+
* If not provided, the mode will be automatically detected based off the end users device.
|
|
90
|
+
*
|
|
91
|
+
* @example isMobileDetect(navigator.userAgent)
|
|
92
|
+
|
|
93
|
+
*/
|
|
94
|
+
mode?: Mode;
|
|
157
95
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
167
|
-
nameSpaces: {
|
|
168
|
-
[x: string]: {
|
|
169
|
-
[x: string]: {
|
|
170
|
-
intentToRetain?: boolean | undefined;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
docType: string;
|
|
175
|
-
}[], undefined>]>, v.ObjectSchema<{
|
|
176
|
-
readonly credentials: v.ArraySchema<v.ObjectSchema<{
|
|
177
|
-
readonly id: v.StringSchema<undefined>;
|
|
178
|
-
readonly format: v.StringSchema<undefined>;
|
|
179
|
-
readonly meta: v.OptionalSchema<v.UnknownSchema, never>;
|
|
180
|
-
readonly claims: v.ArraySchema<v.ObjectSchema<{
|
|
181
|
-
readonly path: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
182
|
-
}, undefined>, undefined>;
|
|
183
|
-
}, undefined>, undefined>;
|
|
184
|
-
readonly credential_sets: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
185
|
-
readonly options: v.ArraySchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
186
|
-
readonly required: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
187
|
-
readonly purpose: v.OptionalSchema<v.UnknownSchema, never>;
|
|
188
|
-
}, undefined>, undefined>, never>;
|
|
189
|
-
}, undefined>], undefined>;
|
|
190
|
-
readonly crossDeviceCallback: v.ObjectSchema<{
|
|
191
|
-
readonly onComplete: v.FunctionSchema<undefined>;
|
|
192
|
-
readonly onFailure: v.FunctionSchema<undefined>;
|
|
193
|
-
}, undefined>;
|
|
194
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
195
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
196
|
-
readonly mode: v.PicklistSchema<[Mode.crossDevice], undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* Configuration for OpenID4VP presentation flow both same-device and cross-device flows.
|
|
98
|
+
*/
|
|
99
|
+
export type OpenIdvpConfiguration = OpenId4vpConfigurationSameDeviceOptions | OpenId4vpConfigurationCrossDeviceOptions | OpenId4vpConfigurationAutoDetectOptions;
|
|
100
|
+
export declare const OpenId4vpConfigAutoDetectOptionsValidator: v.ObjectSchema<{
|
|
101
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
102
|
+
readonly redirectUri: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">, v.UrlAction<string, undefined>]>;
|
|
103
|
+
readonly mode: v.OptionalSchema<v.PicklistSchema<[Mode.CrossDevice, Mode.SameDevice], undefined>, undefined>;
|
|
197
104
|
}, undefined>;
|
|
198
105
|
/**
|
|
199
|
-
* Options for
|
|
106
|
+
* Options for the requestCredentials function.
|
|
200
107
|
*/
|
|
201
|
-
export type
|
|
202
|
-
/**
|
|
203
|
-
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
204
|
-
*/
|
|
205
|
-
credentialQuery: CredentialQuery[] | DcqlCredentialQuery;
|
|
108
|
+
export type RequestCredentialsOptions = {
|
|
206
109
|
/**
|
|
207
|
-
*
|
|
110
|
+
* An array of {@link CredentialQuery} objects that specify the credentials to be requested.
|
|
208
111
|
*/
|
|
209
|
-
|
|
112
|
+
credentialQuery: CredentialQuery[];
|
|
210
113
|
/**
|
|
211
|
-
*
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* An optional challenge string that is used to ensure the security and integrity of the credential request. If not provided, a challenge will be generated by default.
|
|
114
|
+
* An optional unique challenge allowing association and verification of a specific session.
|
|
115
|
+
*
|
|
116
|
+
* If not provided a generated challenge will be created.
|
|
117
|
+
* @example MATTRVerifierSDK.utils.generateChallenge()
|
|
216
118
|
*/
|
|
217
119
|
challenge?: string;
|
|
218
120
|
/**
|
|
219
|
-
*
|
|
220
|
-
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
221
|
-
*/
|
|
222
|
-
walletProviderId?: string;
|
|
223
|
-
/**
|
|
224
|
-
* An optional mode in which the credentials are requested. If not provided, the mode is determined based on the device (isMobileDetect(navigator.userAgent)).
|
|
121
|
+
* Optional configuration for openid4vp presentation flow
|
|
225
122
|
*/
|
|
226
|
-
|
|
123
|
+
openid4vpConfiguration?: OpenIdvpConfiguration;
|
|
227
124
|
};
|
|
228
|
-
export declare const
|
|
229
|
-
|
|
230
|
-
* Options for the requestCredentials function
|
|
231
|
-
*/
|
|
232
|
-
export type RequestCredentialsOptions = RequestCredentialsSameDeviceOptions | RequestCredentialsCrossDeviceDeviceOptions | RequestCredentialsAutoDetectOptions;
|
|
233
|
-
export declare const RequestCredentialsOptionsValidator: v.UnionSchema<[v.ObjectSchema<{
|
|
234
|
-
readonly credentialQuery: v.UnionSchema<[v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
125
|
+
export declare const RequestCredentialsOptionsValidator: v.ObjectSchema<{
|
|
126
|
+
readonly credentialQuery: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
235
127
|
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
236
128
|
readonly docType: v.StringSchema<undefined>;
|
|
237
129
|
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
238
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>,
|
|
130
|
+
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
239
131
|
}, undefined>, undefined>, undefined>;
|
|
240
132
|
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
241
133
|
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
242
|
-
nameSpaces: {
|
|
243
|
-
[x: string]: {
|
|
244
|
-
[x: string]: {
|
|
245
|
-
intentToRetain?: boolean | undefined;
|
|
246
|
-
};
|
|
247
|
-
};
|
|
248
|
-
};
|
|
249
134
|
docType: string;
|
|
250
|
-
}[], undefined>]>, v.ObjectSchema<{
|
|
251
|
-
readonly credentials: v.ArraySchema<v.ObjectSchema<{
|
|
252
|
-
readonly id: v.StringSchema<undefined>;
|
|
253
|
-
readonly format: v.StringSchema<undefined>;
|
|
254
|
-
readonly meta: v.OptionalSchema<v.UnknownSchema, never>;
|
|
255
|
-
readonly claims: v.ArraySchema<v.ObjectSchema<{
|
|
256
|
-
readonly path: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
257
|
-
}, undefined>, undefined>;
|
|
258
|
-
}, undefined>, undefined>;
|
|
259
|
-
readonly credential_sets: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
260
|
-
readonly options: v.ArraySchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
261
|
-
readonly required: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
262
|
-
readonly purpose: v.OptionalSchema<v.UnknownSchema, never>;
|
|
263
|
-
}, undefined>, undefined>, never>;
|
|
264
|
-
}, undefined>], undefined>;
|
|
265
|
-
readonly redirectUri: v.StringSchema<undefined>;
|
|
266
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
267
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
268
|
-
readonly mode: v.PicklistSchema<[Mode.sameDevice], undefined>;
|
|
269
|
-
}, undefined>, v.ObjectSchema<{
|
|
270
|
-
readonly credentialQuery: v.UnionSchema<[v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
271
|
-
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
272
|
-
readonly docType: v.StringSchema<undefined>;
|
|
273
|
-
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
274
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
275
|
-
}, undefined>, undefined>, undefined>;
|
|
276
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
277
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
278
135
|
nameSpaces: {
|
|
279
136
|
[x: string]: {
|
|
280
137
|
[x: string]: {
|
|
@@ -282,36 +139,21 @@ export declare const RequestCredentialsOptionsValidator: v.UnionSchema<[v.Object
|
|
|
282
139
|
};
|
|
283
140
|
};
|
|
284
141
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
readonly
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}, undefined>], undefined>;
|
|
301
|
-
readonly crossDeviceCallback: v.ObjectSchema<{
|
|
302
|
-
readonly onComplete: v.FunctionSchema<undefined>;
|
|
303
|
-
readonly onFailure: v.FunctionSchema<undefined>;
|
|
304
|
-
}, undefined>;
|
|
305
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
306
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
307
|
-
readonly mode: v.PicklistSchema<[Mode.crossDevice], undefined>;
|
|
308
|
-
}, undefined>, v.GenericSchema<RequestCredentialsAutoDetectOptions, RequestCredentialsAutoDetectOptions, v.BaseIssue<unknown>>], undefined>;
|
|
309
|
-
/**
|
|
310
|
-
* The response from the same device requestCredentials function
|
|
311
|
-
*/
|
|
312
|
-
export type SameDeviceRequestCredentialsResponse = {
|
|
313
|
-
sessionId: string;
|
|
314
|
-
};
|
|
142
|
+
}[], undefined>]>;
|
|
143
|
+
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
144
|
+
readonly openid4vpConfiguration: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
145
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
146
|
+
readonly mode: v.LiteralSchema<Mode.SameDevice, undefined>;
|
|
147
|
+
readonly redirectUri: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">, v.UrlAction<string, undefined>]>;
|
|
148
|
+
}, undefined>, v.ObjectSchema<{
|
|
149
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
150
|
+
readonly mode: v.LiteralSchema<Mode.CrossDevice, undefined>;
|
|
151
|
+
}, undefined>, v.ObjectSchema<{
|
|
152
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
153
|
+
readonly redirectUri: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">, v.UrlAction<string, undefined>]>;
|
|
154
|
+
readonly mode: v.OptionalSchema<v.PicklistSchema<[Mode.CrossDevice, Mode.SameDevice], undefined>, undefined>;
|
|
155
|
+
}, undefined>], undefined>, undefined>;
|
|
156
|
+
}, undefined>;
|
|
315
157
|
export type MessageEvent = {
|
|
316
158
|
data: {
|
|
317
159
|
type: MessageEventDataType;
|
|
@@ -321,32 +163,59 @@ export type MessageEvent = {
|
|
|
321
163
|
origin: string;
|
|
322
164
|
};
|
|
323
165
|
/**
|
|
324
|
-
* The response from the
|
|
166
|
+
* The response from the requestCredentials function when credentials were requested with OpenId4vp
|
|
325
167
|
*/
|
|
326
|
-
export type
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
168
|
+
export type RequestCredentialsResponse = {
|
|
169
|
+
/**
|
|
170
|
+
* Contains the result of the presentation session if the associated MATTR VII verifier application is configured
|
|
171
|
+
* to return results to the front channel (`frontChannelResultAvailable` set to `true`).
|
|
172
|
+
*/
|
|
173
|
+
result?: PresentationSessionResult;
|
|
174
|
+
/**
|
|
175
|
+
* Session identifier which can be used to fetch a presentation result via a back channel.
|
|
176
|
+
*/
|
|
333
177
|
sessionId: string;
|
|
334
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Indicates that session is completed and the flow will continue on the redirected page
|
|
180
|
+
*/
|
|
181
|
+
sessionCompletedInRedirect?: boolean;
|
|
335
182
|
};
|
|
336
|
-
/**
|
|
337
|
-
* The response from the requestCredentials function
|
|
338
|
-
*/
|
|
339
|
-
export type RequestCredentialsResponse = SameDeviceRequestCredentialsResponse | CrossDeviceRequestCredentialsResponse | DigitalCredentialsApiRequestCredentialsResponse;
|
|
340
183
|
/**
|
|
341
184
|
* The error type for the requestCredentials function
|
|
342
185
|
*/
|
|
343
186
|
export declare enum RequestCredentialsErrorType {
|
|
344
|
-
RequestCredentialsFailed = "RequestCredentialsFailed"
|
|
187
|
+
RequestCredentialsFailed = "RequestCredentialsFailed",
|
|
188
|
+
Timeout = "Timeout",
|
|
189
|
+
Abort = "Abort"
|
|
190
|
+
}
|
|
191
|
+
export declare enum RequestCredentialsErrorMessage {
|
|
192
|
+
FailedToGetSessionResult = "Failed to get session result",
|
|
193
|
+
FailedToGetSessionStatus = "Failed to get session status",
|
|
194
|
+
FailedToCreateSession = "Failed to create session",
|
|
195
|
+
FailedToVerifyCredentialResponse = "Failed to verify credential response",
|
|
196
|
+
MissingOpenId4vpConfig = "Identified openid4vp session, but missing openId4vpConfiguration on `requestCredentials`",
|
|
197
|
+
DcApiError = "Failed to request credentials with Digital Credentials API",
|
|
198
|
+
DcApiResponseParseError = "Failed to parse response from Digital Credentials API",
|
|
199
|
+
Abort = "User aborted the session",
|
|
200
|
+
Timeout = "User session timeout"
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The error type for the `abortCredentialRequest` function
|
|
204
|
+
*/
|
|
205
|
+
export declare enum AbortSessionErrorType {
|
|
206
|
+
AbortSessionFailed = "AbortSessionFailed"
|
|
207
|
+
}
|
|
208
|
+
export declare enum AbortSessionErrorMessage {
|
|
209
|
+
FailedToAbortSession = "Failed to abort session"
|
|
345
210
|
}
|
|
346
211
|
/**
|
|
347
212
|
* The error response from the requestCredentials function
|
|
348
213
|
*/
|
|
349
214
|
export type RequestCredentialsError = BaseError<RequestCredentialsErrorType>;
|
|
215
|
+
/**
|
|
216
|
+
* The error response from the requestCredentials function
|
|
217
|
+
*/
|
|
218
|
+
export type AbortSessionError = BaseError<AbortSessionErrorType>;
|
|
350
219
|
/**
|
|
351
220
|
* The response from the handleRedirectCallback function
|
|
352
221
|
*/
|
|
@@ -354,24 +223,38 @@ export type HandleRedirectCallbackResponse = {
|
|
|
354
223
|
/**
|
|
355
224
|
* Contains the result of the presentation session if result is configured to be available in the front channel
|
|
356
225
|
*/
|
|
357
|
-
result
|
|
358
|
-
|
|
359
|
-
|
|
226
|
+
result?: PresentationSessionResult;
|
|
227
|
+
/**
|
|
228
|
+
* Session identifier which can be used to fetch a presentation result via a back channel.
|
|
229
|
+
*/
|
|
360
230
|
sessionId: string;
|
|
361
231
|
};
|
|
362
232
|
/**
|
|
363
|
-
* Options for the
|
|
233
|
+
* Options for the initialize function
|
|
364
234
|
*/
|
|
365
|
-
export type
|
|
235
|
+
export type InitializeOptions = {
|
|
236
|
+
/** MATTR VII Tenant or base URL */
|
|
366
237
|
apiBaseUrl: string;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
enableDigitalCredentialsApiSameDeviceFlow?: boolean;
|
|
370
|
-
enableDigitalCredentialsApiCrossDeviceFlow?: boolean;
|
|
238
|
+
/** MATTR VII configured Verifier application identifier */
|
|
239
|
+
applicationId: string;
|
|
371
240
|
};
|
|
372
|
-
export declare const
|
|
373
|
-
readonly apiBaseUrl: v.StringSchema<undefined>;
|
|
374
|
-
readonly applicationId: v.
|
|
375
|
-
readonly enableDigitalCredentialsApiSameDeviceFlow: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
376
|
-
readonly enableDigitalCredentialsApiCrossDeviceFlow: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
241
|
+
export declare const InitializeOptionsValidator: v.ObjectSchema<{
|
|
242
|
+
readonly apiBaseUrl: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">, v.UrlAction<string, undefined>]>;
|
|
243
|
+
readonly applicationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">]>;
|
|
377
244
|
}, undefined>;
|
|
245
|
+
/**
|
|
246
|
+
* Struct for a presentation session
|
|
247
|
+
*/
|
|
248
|
+
export type CreatePresentationSession = {
|
|
249
|
+
readonly sessionId: string;
|
|
250
|
+
readonly sessionKey: string;
|
|
251
|
+
readonly sessionTimeoutId?: number;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Struct for a stored presentation session
|
|
255
|
+
*/
|
|
256
|
+
export type StoredPresentationSession = {
|
|
257
|
+
readonly sessionId: string;
|
|
258
|
+
readonly sessionKey?: string;
|
|
259
|
+
readonly sessionTimeoutId?: number;
|
|
260
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
|
-
import {
|
|
3
|
-
import { CreateSessionRequest,
|
|
2
|
+
import { SafeFetchValidateResponseError } from "../common/safeFetch";
|
|
3
|
+
import { CreateSessionRequest, ExchangeSessionResultResponse, GetSessionStatusRequest, GetSessionStatusResponse, AbortSessionRequest, InitializeOptions, CreateSessionResponse } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* Generates a challenge string using the window.crypto API.
|
|
6
6
|
*
|
|
@@ -22,11 +22,27 @@ export declare const getHashParamValue: (hash: string, param: string) => string
|
|
|
22
22
|
* @param challenge - The challenge for the session.
|
|
23
23
|
* @param redirectUri - The redirect URI for the session.
|
|
24
24
|
* @param apiBaseUrl - The base URL of the API.
|
|
25
|
-
* @param applicationId -
|
|
25
|
+
* @param applicationId - The ID of the verifier application.
|
|
26
26
|
* @param walletProviderId - optional, The ID of the wallet provider, if not provided the default wallet provider will be used.
|
|
27
27
|
* @returns A promise that resolves to a result containing either the created session response or an error.
|
|
28
28
|
*/
|
|
29
|
-
export declare const createSession: ({ credentialQuery, challenge, redirectUri, apiBaseUrl,
|
|
29
|
+
export declare const createSession: ({ credentialQuery, challenge, redirectUri, apiBaseUrl, walletProviderId, dcApiSupported, applicationId, }: CreateSessionRequest & InitializeOptions) => Promise<Result<CreateSessionResponse, SafeFetchValidateResponseError>>;
|
|
30
|
+
/**
|
|
31
|
+
* Abort a session with the provided parameters.
|
|
32
|
+
*
|
|
33
|
+
* @param sessionId - The unique identifier for the session.
|
|
34
|
+
* @param sessionKey - The authorization key for performing operations for the session.
|
|
35
|
+
* @returns A promise that resolves to a ok result when succeed or an error.
|
|
36
|
+
*/
|
|
37
|
+
export declare const abortSession: ({ apiBaseUrl, sessionId, sessionKey, }: AbortSessionRequest) => Promise<Result<void, SafeFetchValidateResponseError>>;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the status for a session with the provided parameters.
|
|
40
|
+
*
|
|
41
|
+
* @param sessionId - The unique identifier for the session.
|
|
42
|
+
* @param sessionKey - The authorization key for performing operations for the session.
|
|
43
|
+
* @returns A promise that resolves to a result containing either the session status response or an error.
|
|
44
|
+
*/
|
|
45
|
+
export declare const getSessionStatus: ({ apiBaseUrl, sessionId, sessionKey, }: GetSessionStatusRequest & InitializeOptions) => Promise<Result<GetSessionStatusResponse, SafeFetchValidateResponseError>>;
|
|
30
46
|
/**
|
|
31
47
|
* Exchange the result of a session using the provided parameters.
|
|
32
48
|
*
|
|
@@ -41,7 +57,7 @@ export declare const exchangeSessionResult: ({ challenge, responseCode, sessionI
|
|
|
41
57
|
responseCode: string;
|
|
42
58
|
sessionId: string;
|
|
43
59
|
apiBaseUrl: string;
|
|
44
|
-
}) => Promise<Result<ExchangeSessionResultResponse,
|
|
60
|
+
}) => Promise<Result<ExchangeSessionResultResponse, SafeFetchValidateResponseError>>;
|
|
45
61
|
/**
|
|
46
62
|
* Detects if the user agent is a mobile device.
|
|
47
63
|
*
|
|
@@ -50,36 +66,6 @@ export declare const exchangeSessionResult: ({ challenge, responseCode, sessionI
|
|
|
50
66
|
*/
|
|
51
67
|
export declare const isMobileDetect: (userAgent: string) => boolean;
|
|
52
68
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @returns A boolean indicating whether the user agent supports the digital credential api.
|
|
69
|
+
* Returns the value that is being set in the x-mattr-sdk-version header
|
|
56
70
|
*/
|
|
57
|
-
export declare const
|
|
58
|
-
/**
|
|
59
|
-
* Creates a new digital credentials api session with the provided parameters.
|
|
60
|
-
*
|
|
61
|
-
* @param credentialQuery - The credential query for the session.
|
|
62
|
-
* @param challenge - The challenge for the session.
|
|
63
|
-
* @param apiBaseUrl - The base URL of the API.
|
|
64
|
-
* @returns A promise that resolves to a result containing either the created session response or an error.
|
|
65
|
-
*/
|
|
66
|
-
export declare const createDigitalCredentialsApiSession: ({ credentialQuery, challenge, apiBaseUrl, protocol, }: CreateSessionRequest & {
|
|
67
|
-
apiBaseUrl: string;
|
|
68
|
-
protocol?: string;
|
|
69
|
-
}) => Promise<Result<CreateDigitalCredentialsApiSessionResponse, SafeFetchValidateRespondError>>;
|
|
70
|
-
/**
|
|
71
|
-
* Retrieves the result of a session using the provided parameters.
|
|
72
|
-
*
|
|
73
|
-
* @param challenge - The challenge for the session.
|
|
74
|
-
* @param sessionId - The ID of the session.
|
|
75
|
-
* @param response - The response from the digital credentials api.
|
|
76
|
-
* @param apiBaseUrl - The base URL of the API.
|
|
77
|
-
* @returns A promise that resolves to a result containing either the session result response or an error.
|
|
78
|
-
*/
|
|
79
|
-
export declare const getDigitalCredentialsApiSessionResult: ({ challenge, sessionId, response, apiBaseUrl, protocol, }: {
|
|
80
|
-
challenge: string;
|
|
81
|
-
sessionId: string;
|
|
82
|
-
response: any;
|
|
83
|
-
apiBaseUrl: string;
|
|
84
|
-
protocol: string;
|
|
85
|
-
}) => Promise<Result<any, SafeFetchValidateRespondError>>;
|
|
71
|
+
export declare const getVersion: () => string;
|