@mattrglobal/verifier-sdk-web 1.1.1-unstable.16 → 1.1.1-unstable.160
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 +63 -42
- package/dist/lib/verifier-js-no-deps.cjs.js +610 -198
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +736 -312
- 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 -6
- 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/requestCredentialsCrossDevice.d.ts +3 -47
- package/dist/typings/verifier/requestCredentialsDigitalCredentialsApi.d.ts +16 -0
- package/dist/typings/verifier/requestCredentialsSameDevice.d.ts +1 -1
- package/dist/typings/verifier/types/credential-presentation.d.ts +156 -21
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +129 -186
- package/dist/typings/verifier/utils.d.ts +25 -5
- package/dist/verifier-js.development.js +678 -294
- 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
|
@@ -1,70 +1,37 @@
|
|
|
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
|
-
|
|
25
|
+
apiBaseUrl: string;
|
|
26
|
+
sessionUrl: string;
|
|
27
|
+
sessionKey: string;
|
|
28
|
+
sessionId: string;
|
|
63
29
|
};
|
|
64
30
|
/**
|
|
65
|
-
* Options for
|
|
31
|
+
* Options for requestCredentials function without openId4vp configuration.
|
|
32
|
+
* Can be used for requesting credential with Digital Credentials API or with openId4vp cross-device flow
|
|
66
33
|
*/
|
|
67
|
-
export type
|
|
34
|
+
export type RequestCredentialsBaseOptions = {
|
|
68
35
|
/**
|
|
69
36
|
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
70
37
|
*/
|
|
@@ -72,154 +39,83 @@ export type RequestCredentialsSameDeviceOptions = {
|
|
|
72
39
|
/**
|
|
73
40
|
* The URI to which the user will be redirected after the credential request is completed.
|
|
74
41
|
*/
|
|
75
|
-
redirectUri: string;
|
|
76
|
-
/**
|
|
77
|
-
* 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.
|
|
78
|
-
*/
|
|
79
42
|
challenge?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Options for openid4vpConfiguration to request credentials with same device
|
|
46
|
+
*/
|
|
47
|
+
export type OpenId4vpConfigurationSameDeviceOptions = {
|
|
80
48
|
/**
|
|
81
49
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
82
50
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
83
51
|
*/
|
|
84
52
|
walletProviderId?: string;
|
|
85
53
|
/**
|
|
86
|
-
*
|
|
54
|
+
* A mode in which the credentials are requested. Set to Mode.SameDevice for this type.
|
|
55
|
+
* Can be undefined
|
|
56
|
+
*/
|
|
57
|
+
mode: Mode.SameDevice;
|
|
58
|
+
/**
|
|
59
|
+
* redirectUri is required if mode is same device or undefined
|
|
87
60
|
*/
|
|
88
|
-
|
|
61
|
+
redirectUri: string;
|
|
89
62
|
};
|
|
90
|
-
export declare const
|
|
91
|
-
readonly credentialQuery: v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
92
|
-
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
93
|
-
readonly docType: v.StringSchema<undefined>;
|
|
94
|
-
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
95
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
96
|
-
}, undefined>, undefined>, undefined>;
|
|
97
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
98
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
99
|
-
nameSpaces: {
|
|
100
|
-
[x: string]: {
|
|
101
|
-
[x: string]: {
|
|
102
|
-
intentToRetain?: boolean | undefined;
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
docType: string;
|
|
107
|
-
}[], undefined>]>;
|
|
108
|
-
readonly redirectUri: v.StringSchema<undefined>;
|
|
109
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
63
|
+
export declare const OpenId4vpConfigSameDeviceOptionsValidator: v.ObjectSchema<{
|
|
110
64
|
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
111
|
-
readonly mode: v.
|
|
65
|
+
readonly mode: v.LiteralSchema<Mode.SameDevice, undefined>;
|
|
66
|
+
readonly redirectUri: v.StringSchema<undefined>;
|
|
112
67
|
}, undefined>;
|
|
113
68
|
/**
|
|
114
|
-
* Options for
|
|
69
|
+
* Options for openid4vpConfiguration to request credentials with cross device
|
|
115
70
|
*/
|
|
116
|
-
export type
|
|
117
|
-
/**
|
|
118
|
-
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
119
|
-
*/
|
|
120
|
-
credentialQuery: CredentialQuery[];
|
|
121
|
-
/**
|
|
122
|
-
* The callback functions to be executed on success or failure of the credential request in cross device mode.
|
|
123
|
-
*/
|
|
124
|
-
crossDeviceCallback: CrossDeviceCallback;
|
|
125
|
-
/**
|
|
126
|
-
* 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.
|
|
127
|
-
*/
|
|
128
|
-
challenge?: string;
|
|
71
|
+
export type OpenId4vpConfigurationCrossDeviceOptions = {
|
|
129
72
|
/**
|
|
130
73
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
131
74
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
132
75
|
*/
|
|
133
76
|
walletProviderId?: string;
|
|
134
77
|
/**
|
|
135
|
-
*
|
|
78
|
+
* A mode in which the credentials are requested. Set to Mode.CrossDevice for this type.
|
|
136
79
|
*/
|
|
137
|
-
mode: Mode.
|
|
80
|
+
mode: Mode.CrossDevice;
|
|
138
81
|
};
|
|
139
|
-
export declare const
|
|
140
|
-
readonly credentialQuery: v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
141
|
-
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
142
|
-
readonly docType: v.StringSchema<undefined>;
|
|
143
|
-
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
144
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
145
|
-
}, undefined>, undefined>, undefined>;
|
|
146
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
147
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
148
|
-
nameSpaces: {
|
|
149
|
-
[x: string]: {
|
|
150
|
-
[x: string]: {
|
|
151
|
-
intentToRetain?: boolean | undefined;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
docType: string;
|
|
156
|
-
}[], undefined>]>;
|
|
157
|
-
readonly crossDeviceCallback: v.ObjectSchema<{
|
|
158
|
-
readonly onComplete: v.FunctionSchema<undefined>;
|
|
159
|
-
readonly onFailure: v.FunctionSchema<undefined>;
|
|
160
|
-
}, undefined>;
|
|
161
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
82
|
+
export declare const OpenId4vpConfigCrossDeviceOptionsValidator: v.ObjectSchema<{
|
|
162
83
|
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
163
|
-
readonly mode: v.
|
|
84
|
+
readonly mode: v.LiteralSchema<Mode.CrossDevice, undefined>;
|
|
164
85
|
}, undefined>;
|
|
165
86
|
/**
|
|
166
|
-
* Options for auto
|
|
87
|
+
* Options for openid4vpConfiguration which allow to auto-detect the device mode
|
|
167
88
|
*/
|
|
168
|
-
export type
|
|
169
|
-
/**
|
|
170
|
-
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
171
|
-
*/
|
|
172
|
-
credentialQuery: CredentialQuery[];
|
|
173
|
-
/**
|
|
174
|
-
* The callback functions to be executed on success or failure of the credential request in cross device mode.
|
|
175
|
-
*/
|
|
176
|
-
crossDeviceCallback: CrossDeviceCallback;
|
|
177
|
-
/**
|
|
178
|
-
* The URI to which the user will be redirected after the credential request is completed.
|
|
179
|
-
*/
|
|
180
|
-
redirectUri: string;
|
|
181
|
-
/**
|
|
182
|
-
* 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.
|
|
183
|
-
*/
|
|
184
|
-
challenge?: string;
|
|
89
|
+
export type OpenId4vpConfigurationAutoDetectOptions = {
|
|
185
90
|
/**
|
|
186
91
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
187
92
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
188
93
|
*/
|
|
189
94
|
walletProviderId?: string;
|
|
95
|
+
/**
|
|
96
|
+
* redirect uri to use for same device mode
|
|
97
|
+
*/
|
|
98
|
+
redirectUri: string;
|
|
190
99
|
/**
|
|
191
100
|
* An optional mode in which the credentials are requested. If not provided, the mode is determined based on the device (isMobileDetect(navigator.userAgent)).
|
|
192
101
|
*/
|
|
193
102
|
mode?: Mode;
|
|
194
103
|
};
|
|
195
|
-
export declare const
|
|
104
|
+
export declare const OpenId4vpConfigAutoDetectOptionsValidator: v.ObjectSchema<{
|
|
105
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
106
|
+
readonly redirectUri: v.StringSchema<undefined>;
|
|
107
|
+
readonly mode: v.OptionalSchema<v.PicklistSchema<[Mode.CrossDevice, Mode.SameDevice], undefined>, never>;
|
|
108
|
+
}, undefined>;
|
|
196
109
|
/**
|
|
197
110
|
* Options for the requestCredentials function
|
|
198
111
|
*/
|
|
199
|
-
export type RequestCredentialsOptions =
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}, undefined>, undefined>, undefined>;
|
|
207
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
208
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
209
|
-
nameSpaces: {
|
|
210
|
-
[x: string]: {
|
|
211
|
-
[x: string]: {
|
|
212
|
-
intentToRetain?: boolean | undefined;
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
docType: string;
|
|
217
|
-
}[], undefined>]>;
|
|
218
|
-
readonly redirectUri: v.StringSchema<undefined>;
|
|
219
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
220
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
221
|
-
readonly mode: v.PicklistSchema<[Mode.sameDevice], undefined>;
|
|
222
|
-
}, undefined>, v.ObjectSchema<{
|
|
112
|
+
export type RequestCredentialsOptions = RequestCredentialsBaseOptions & {
|
|
113
|
+
/**
|
|
114
|
+
* Optional configuration for openid4vp presentation flow
|
|
115
|
+
*/
|
|
116
|
+
openid4vpConfiguration?: OpenId4vpConfigurationSameDeviceOptions | OpenId4vpConfigurationCrossDeviceOptions | OpenId4vpConfigurationAutoDetectOptions;
|
|
117
|
+
};
|
|
118
|
+
export declare const RequestCredentialsOptionsValidator: v.ObjectSchema<{
|
|
223
119
|
readonly credentialQuery: v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
224
120
|
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
225
121
|
readonly docType: v.StringSchema<undefined>;
|
|
@@ -237,20 +133,20 @@ export declare const RequestCredentialsOptionsValidator: v.UnionSchema<[v.Object
|
|
|
237
133
|
};
|
|
238
134
|
docType: string;
|
|
239
135
|
}[], undefined>]>;
|
|
240
|
-
readonly crossDeviceCallback: v.ObjectSchema<{
|
|
241
|
-
readonly onComplete: v.FunctionSchema<undefined>;
|
|
242
|
-
readonly onFailure: v.FunctionSchema<undefined>;
|
|
243
|
-
}, undefined>;
|
|
244
136
|
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
245
|
-
readonly
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
137
|
+
readonly openid4vpConfiguration: v.OptionalSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
138
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
139
|
+
readonly mode: v.LiteralSchema<Mode.SameDevice, undefined>;
|
|
140
|
+
readonly redirectUri: v.StringSchema<undefined>;
|
|
141
|
+
}, undefined>, v.ObjectSchema<{
|
|
142
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
143
|
+
readonly mode: v.LiteralSchema<Mode.CrossDevice, undefined>;
|
|
144
|
+
}, undefined>, v.ObjectSchema<{
|
|
145
|
+
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
146
|
+
readonly redirectUri: v.StringSchema<undefined>;
|
|
147
|
+
readonly mode: v.OptionalSchema<v.PicklistSchema<[Mode.CrossDevice, Mode.SameDevice], undefined>, never>;
|
|
148
|
+
}, undefined>], undefined>, never>;
|
|
149
|
+
}, undefined>;
|
|
254
150
|
export type MessageEvent = {
|
|
255
151
|
data: {
|
|
256
152
|
type: MessageEventDataType;
|
|
@@ -260,25 +156,58 @@ export type MessageEvent = {
|
|
|
260
156
|
origin: string;
|
|
261
157
|
};
|
|
262
158
|
/**
|
|
263
|
-
* The response from the
|
|
159
|
+
* The response from the requestCredentials function when credentials were requested with OpenId4vp
|
|
264
160
|
*/
|
|
265
|
-
export type
|
|
161
|
+
export type RequestCredentialsResponse = {
|
|
162
|
+
/**
|
|
163
|
+
* Contains the result of the presentation session if result is configured to be available in the front channel
|
|
164
|
+
*/
|
|
165
|
+
result?: PresentationSessionResult;
|
|
166
|
+
/**
|
|
167
|
+
* when frontChannelResultAvailable is set to true
|
|
168
|
+
*/
|
|
266
169
|
sessionId: string;
|
|
170
|
+
/**
|
|
171
|
+
* Indicates that session is completed and the flow will continue on the redirected page
|
|
172
|
+
*/
|
|
173
|
+
sessionCompletedInRedirect?: boolean;
|
|
267
174
|
};
|
|
268
|
-
/**
|
|
269
|
-
* The response from the requestCredentials function
|
|
270
|
-
*/
|
|
271
|
-
export type RequestCredentialsResponse = SameDeviceRequestCredentialsResponse | CrossDeviceRequestCredentialsResponse;
|
|
272
175
|
/**
|
|
273
176
|
* The error type for the requestCredentials function
|
|
274
177
|
*/
|
|
275
178
|
export declare enum RequestCredentialsErrorType {
|
|
276
|
-
RequestCredentialsFailed = "RequestCredentialsFailed"
|
|
179
|
+
RequestCredentialsFailed = "RequestCredentialsFailed",
|
|
180
|
+
Timeout = "Timeout",
|
|
181
|
+
Abort = "Abort"
|
|
182
|
+
}
|
|
183
|
+
export declare enum RequestCredentialsErrorMessage {
|
|
184
|
+
FailedToGetSessionResult = "Failed to get session result",
|
|
185
|
+
FailedToGetSessionStatus = "Failed to get session status",
|
|
186
|
+
FailedToCreateSession = "Failed to create session",
|
|
187
|
+
FailedToVerifyCredentialResponse = "Failed to verify credential response",
|
|
188
|
+
MissingOpenId4vpConfig = "Identified openid4vp session, but missing openId4vpConfiguration on `requestCredentials`",
|
|
189
|
+
DcApiError = "Failed to request credentials with Digital Credentials API",
|
|
190
|
+
DcApiResponseParseError = "Failed to parse response from Digital Credentials API",
|
|
191
|
+
Abort = "User aborted the session",
|
|
192
|
+
Timeout = "User session timeout"
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The error type for the `abortCredentialRequest` function
|
|
196
|
+
*/
|
|
197
|
+
export declare enum AbortSessionErrorType {
|
|
198
|
+
AbortSessionFailed = "AbortSessionFailed"
|
|
199
|
+
}
|
|
200
|
+
export declare enum AbortSessionErrorMessage {
|
|
201
|
+
FailedToAbortSession = "Failed to abort session"
|
|
277
202
|
}
|
|
278
203
|
/**
|
|
279
204
|
* The error response from the requestCredentials function
|
|
280
205
|
*/
|
|
281
206
|
export type RequestCredentialsError = BaseError<RequestCredentialsErrorType>;
|
|
207
|
+
/**
|
|
208
|
+
* The error response from the requestCredentials function
|
|
209
|
+
*/
|
|
210
|
+
export type AbortSessionError = BaseError<AbortSessionErrorType>;
|
|
282
211
|
/**
|
|
283
212
|
* The response from the handleRedirectCallback function
|
|
284
213
|
*/
|
|
@@ -286,19 +215,33 @@ export type HandleRedirectCallbackResponse = {
|
|
|
286
215
|
/**
|
|
287
216
|
* Contains the result of the presentation session if result is configured to be available in the front channel
|
|
288
217
|
*/
|
|
289
|
-
result
|
|
290
|
-
sessionId: string;
|
|
291
|
-
};
|
|
218
|
+
result?: PresentationSessionResult;
|
|
292
219
|
sessionId: string;
|
|
293
220
|
};
|
|
294
221
|
/**
|
|
295
|
-
* Options for the
|
|
222
|
+
* Options for the initialize function
|
|
296
223
|
*/
|
|
297
|
-
export type
|
|
224
|
+
export type InitializeOptions = {
|
|
298
225
|
apiBaseUrl: string;
|
|
299
|
-
applicationId
|
|
226
|
+
applicationId: string;
|
|
300
227
|
};
|
|
301
|
-
export declare const
|
|
302
|
-
readonly apiBaseUrl: v.StringSchema<undefined>;
|
|
303
|
-
readonly applicationId: v.
|
|
228
|
+
export declare const InitializeOptionsValidator: v.ObjectSchema<{
|
|
229
|
+
readonly apiBaseUrl: v.SchemaWithPipe<[v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">]>;
|
|
230
|
+
readonly applicationId: v.SchemaWithPipe<[v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">]>;
|
|
304
231
|
}, undefined>;
|
|
232
|
+
/**
|
|
233
|
+
* Struct for a presentation session
|
|
234
|
+
*/
|
|
235
|
+
export type CreatePresentationSession = {
|
|
236
|
+
readonly sessionId: string;
|
|
237
|
+
readonly sessionKey: string;
|
|
238
|
+
readonly sessionTimeoutId?: number;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Struct for a stored presentation session
|
|
242
|
+
*/
|
|
243
|
+
export type StoredPresentationSession = {
|
|
244
|
+
readonly sessionId: string;
|
|
245
|
+
readonly sessionKey?: string;
|
|
246
|
+
readonly sessionTimeoutId?: number;
|
|
247
|
+
};
|
|
@@ -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
|
*
|
|
@@ -49,3 +65,7 @@ export declare const exchangeSessionResult: ({ challenge, responseCode, sessionI
|
|
|
49
65
|
* @returns A boolean indicating whether the user agent is a mobile device.
|
|
50
66
|
*/
|
|
51
67
|
export declare const isMobileDetect: (userAgent: string) => boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the value that is being set in the x-mattr-sdk-version header
|
|
70
|
+
*/
|
|
71
|
+
export declare const getVersion: () => string;
|