@mattrglobal/verifier-sdk-web 2.0.0-preview-digital-credential-api.4 → 2.0.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 +608 -336
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +911 -511
- 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 +136 -37
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +153 -214
- package/dist/typings/verifier/utils.d.ts +23 -37
- package/dist/verifier-js.development.js +866 -499
- 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,238 +1,137 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { BaseError } from "../../common";
|
|
3
|
-
import {
|
|
4
|
-
import { CredentialQuery, 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[];
|
|
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[];
|
|
58
|
-
crossDeviceCallback: CrossDeviceCallback;
|
|
59
24
|
challenge: string;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export type DigitalCredentialsApiRequestOptions = {
|
|
65
|
-
credentialQuery: CredentialQuery[];
|
|
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>]>;
|
|
113
|
-
readonly redirectUri: v.StringSchema<undefined>;
|
|
114
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
115
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
116
|
-
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>;
|
|
117
72
|
}, undefined>;
|
|
118
73
|
/**
|
|
119
|
-
* Options for the
|
|
74
|
+
* Options for openid4vpConfiguration which allow to auto-detect the device mode
|
|
120
75
|
*/
|
|
121
|
-
export type
|
|
122
|
-
/**
|
|
123
|
-
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
124
|
-
*/
|
|
125
|
-
credentialQuery: CredentialQuery[];
|
|
126
|
-
/**
|
|
127
|
-
* The callback functions to be executed on success or failure of the credential request in cross device mode.
|
|
128
|
-
*/
|
|
129
|
-
crossDeviceCallback: CrossDeviceCallback;
|
|
130
|
-
/**
|
|
131
|
-
* 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.
|
|
132
|
-
*/
|
|
133
|
-
challenge?: string;
|
|
76
|
+
export type OpenId4vpConfigurationAutoDetectOptions = {
|
|
134
77
|
/**
|
|
135
78
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
136
79
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
137
80
|
*/
|
|
138
81
|
walletProviderId?: string;
|
|
139
82
|
/**
|
|
140
|
-
*
|
|
83
|
+
* redirect uri to use for same device mode
|
|
84
|
+
*/
|
|
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
|
+
|
|
141
93
|
*/
|
|
142
|
-
mode
|
|
94
|
+
mode?: Mode;
|
|
143
95
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
153
|
-
nameSpaces: {
|
|
154
|
-
[x: string]: {
|
|
155
|
-
[x: string]: {
|
|
156
|
-
intentToRetain?: boolean | undefined;
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
docType: string;
|
|
161
|
-
}[], undefined>]>;
|
|
162
|
-
readonly crossDeviceCallback: v.ObjectSchema<{
|
|
163
|
-
readonly onComplete: v.FunctionSchema<undefined>;
|
|
164
|
-
readonly onFailure: v.FunctionSchema<undefined>;
|
|
165
|
-
}, undefined>;
|
|
166
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
167
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
168
|
-
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>;
|
|
169
104
|
}, undefined>;
|
|
170
105
|
/**
|
|
171
|
-
* Options for
|
|
106
|
+
* Options for the requestCredentials function.
|
|
172
107
|
*/
|
|
173
|
-
export type
|
|
108
|
+
export type RequestCredentialsOptions = {
|
|
174
109
|
/**
|
|
175
|
-
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
110
|
+
* An array of {@link CredentialQuery} objects that specify the credentials to be requested.
|
|
176
111
|
*/
|
|
177
112
|
credentialQuery: CredentialQuery[];
|
|
178
113
|
/**
|
|
179
|
-
*
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
* The URI to which the user will be redirected after the credential request is completed.
|
|
184
|
-
*/
|
|
185
|
-
redirectUri: string;
|
|
186
|
-
/**
|
|
187
|
-
* 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()
|
|
188
118
|
*/
|
|
189
119
|
challenge?: string;
|
|
190
120
|
/**
|
|
191
|
-
*
|
|
192
|
-
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
193
|
-
*/
|
|
194
|
-
walletProviderId?: string;
|
|
195
|
-
/**
|
|
196
|
-
* 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
|
|
197
122
|
*/
|
|
198
|
-
|
|
123
|
+
openid4vpConfiguration?: OpenIdvpConfiguration;
|
|
199
124
|
};
|
|
200
|
-
export declare const
|
|
201
|
-
|
|
202
|
-
* Options for the requestCredentials function
|
|
203
|
-
*/
|
|
204
|
-
export type RequestCredentialsOptions = RequestCredentialsSameDeviceOptions | RequestCredentialsCrossDeviceDeviceOptions | RequestCredentialsAutoDetectOptions;
|
|
205
|
-
export declare const RequestCredentialsOptionsValidator: v.UnionSchema<[v.ObjectSchema<{
|
|
206
|
-
readonly credentialQuery: v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
125
|
+
export declare const RequestCredentialsOptionsValidator: v.ObjectSchema<{
|
|
126
|
+
readonly credentialQuery: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
207
127
|
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
208
128
|
readonly docType: v.StringSchema<undefined>;
|
|
209
129
|
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
210
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>,
|
|
130
|
+
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
211
131
|
}, undefined>, undefined>, undefined>;
|
|
212
132
|
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
213
133
|
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
214
|
-
nameSpaces: {
|
|
215
|
-
[x: string]: {
|
|
216
|
-
[x: string]: {
|
|
217
|
-
intentToRetain?: boolean | undefined;
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
134
|
docType: string;
|
|
222
|
-
}[], undefined>]>;
|
|
223
|
-
readonly redirectUri: v.StringSchema<undefined>;
|
|
224
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
225
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
226
|
-
readonly mode: v.PicklistSchema<[Mode.sameDevice], undefined>;
|
|
227
|
-
}, undefined>, v.ObjectSchema<{
|
|
228
|
-
readonly credentialQuery: v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
229
|
-
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
230
|
-
readonly docType: v.StringSchema<undefined>;
|
|
231
|
-
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
232
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
233
|
-
}, undefined>, undefined>, undefined>;
|
|
234
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
235
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
236
135
|
nameSpaces: {
|
|
237
136
|
[x: string]: {
|
|
238
137
|
[x: string]: {
|
|
@@ -240,22 +139,21 @@ export declare const RequestCredentialsOptionsValidator: v.UnionSchema<[v.Object
|
|
|
240
139
|
};
|
|
241
140
|
};
|
|
242
141
|
};
|
|
243
|
-
docType: string;
|
|
244
142
|
}[], undefined>]>;
|
|
245
|
-
readonly
|
|
246
|
-
|
|
247
|
-
readonly
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
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>;
|
|
259
157
|
export type MessageEvent = {
|
|
260
158
|
data: {
|
|
261
159
|
type: MessageEventDataType;
|
|
@@ -265,32 +163,59 @@ export type MessageEvent = {
|
|
|
265
163
|
origin: string;
|
|
266
164
|
};
|
|
267
165
|
/**
|
|
268
|
-
* The response from the
|
|
269
|
-
*/
|
|
270
|
-
export type CrossDeviceRequestCredentialsResponse = {
|
|
271
|
-
sessionId: string;
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* The response from the digital credentials api requestCredentials function
|
|
166
|
+
* The response from the requestCredentials function when credentials were requested with OpenId4vp
|
|
275
167
|
*/
|
|
276
|
-
export type
|
|
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
|
+
*/
|
|
277
177
|
sessionId: string;
|
|
278
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Indicates that session is completed and the flow will continue on the redirected page
|
|
180
|
+
*/
|
|
181
|
+
sessionCompletedInRedirect?: boolean;
|
|
279
182
|
};
|
|
280
|
-
/**
|
|
281
|
-
* The response from the requestCredentials function
|
|
282
|
-
*/
|
|
283
|
-
export type RequestCredentialsResponse = SameDeviceRequestCredentialsResponse | CrossDeviceRequestCredentialsResponse | DigitalCredentialsApiRequestCredentialsResponse;
|
|
284
183
|
/**
|
|
285
184
|
* The error type for the requestCredentials function
|
|
286
185
|
*/
|
|
287
186
|
export declare enum RequestCredentialsErrorType {
|
|
288
|
-
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"
|
|
289
210
|
}
|
|
290
211
|
/**
|
|
291
212
|
* The error response from the requestCredentials function
|
|
292
213
|
*/
|
|
293
214
|
export type RequestCredentialsError = BaseError<RequestCredentialsErrorType>;
|
|
215
|
+
/**
|
|
216
|
+
* The error response from the requestCredentials function
|
|
217
|
+
*/
|
|
218
|
+
export type AbortSessionError = BaseError<AbortSessionErrorType>;
|
|
294
219
|
/**
|
|
295
220
|
* The response from the handleRedirectCallback function
|
|
296
221
|
*/
|
|
@@ -298,24 +223,38 @@ export type HandleRedirectCallbackResponse = {
|
|
|
298
223
|
/**
|
|
299
224
|
* Contains the result of the presentation session if result is configured to be available in the front channel
|
|
300
225
|
*/
|
|
301
|
-
result
|
|
302
|
-
|
|
303
|
-
|
|
226
|
+
result?: PresentationSessionResult;
|
|
227
|
+
/**
|
|
228
|
+
* Session identifier which can be used to fetch a presentation result via a back channel.
|
|
229
|
+
*/
|
|
304
230
|
sessionId: string;
|
|
305
231
|
};
|
|
306
232
|
/**
|
|
307
|
-
* Options for the
|
|
233
|
+
* Options for the initialize function
|
|
308
234
|
*/
|
|
309
|
-
export type
|
|
235
|
+
export type InitializeOptions = {
|
|
236
|
+
/** MATTR VII Tenant or base URL */
|
|
310
237
|
apiBaseUrl: string;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
enableDigitalCredentialsApiSameDeviceFlow?: boolean;
|
|
314
|
-
enableDigitalCredentialsApiCrossDeviceFlow?: boolean;
|
|
238
|
+
/** MATTR VII configured Verifier application identifier */
|
|
239
|
+
applicationId: string;
|
|
315
240
|
};
|
|
316
|
-
export declare const
|
|
317
|
-
readonly apiBaseUrl: v.StringSchema<undefined>;
|
|
318
|
-
readonly applicationId: v.
|
|
319
|
-
readonly enableDigitalCredentialsApiSameDeviceFlow: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
320
|
-
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">]>;
|
|
321
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;
|