@mattrglobal/verifier-sdk-web 1.1.1-unstable.145 → 1.1.1-unstable.153
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/dist/lib/verifier-js-no-deps.cjs.js +263 -91
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +314 -90
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/common/safeFetch.d.ts +3 -3
- package/dist/typings/index.d.ts +4 -4
- package/dist/typings/verifier/index.d.ts +1 -0
- package/dist/typings/verifier/requestCredentialsCrossDevice.d.ts +1 -1
- package/dist/typings/verifier/requestCredentialsDigitalCredentialsApi.d.ts +16 -0
- package/dist/typings/verifier/types/credential-presentation.d.ts +45 -7
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +77 -128
- package/dist/typings/verifier/utils.d.ts +6 -6
- package/dist/verifier-js.development.js +297 -87
- 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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
2
|
import { BaseError } from "./error";
|
|
3
|
-
export declare enum
|
|
3
|
+
export declare enum SafeFetchCommonResponseErrorType {
|
|
4
4
|
/**
|
|
5
5
|
* Unexpected response from the remote server
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
UnexpectedResponse = "UnexpectedResponse"
|
|
8
8
|
}
|
|
9
9
|
export declare enum SafeFetchErrorType {
|
|
10
10
|
/**
|
|
@@ -16,7 +16,7 @@ export declare enum SafeFetchErrorType {
|
|
|
16
16
|
*/
|
|
17
17
|
UnknownError = "UnknownError"
|
|
18
18
|
}
|
|
19
|
-
export type
|
|
19
|
+
export type SafeFetchValidateResponseError = BaseError<SafeFetchErrorType | SafeFetchCommonResponseErrorType.UnexpectedResponse> & {
|
|
20
20
|
status?: number;
|
|
21
21
|
};
|
|
22
22
|
export type SafeFetchError = BaseError<SafeFetchErrorType> & {
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { initialise, requestCredentials, handleRedirectCallback, abortCredentialRequest } from "./verifier";
|
|
1
|
+
import { initialise, requestCredentials, handleRedirectCallback, abortCredentialRequest, isDigitalCredentialsApiSupported } from "./verifier";
|
|
2
2
|
import { HandleRedirectCallbackError, HandleRedirectCallbackErrorType } from "./verifier/handleRedirectCallback";
|
|
3
|
-
import { InitialiseOptions, RequestCredentialsOptions,
|
|
3
|
+
import { InitialiseOptions, RequestCredentialsOptions, OpenId4vpConfigurationSameDeviceOptions, OpenId4vpConfigurationCrossDeviceOptions, OpenId4vpConfigurationAutoDetectOptions, RequestCredentialsError, RequestCredentialsErrorType, CredentialQuery, CredentialQueryClaim, OpenidPresentationCredentialProfileSupported, Mode, RequestCredentialsResponse, AbortSessionErrorType, HandleRedirectCallbackResponse, Claim, ClaimData, ClaimType, PresentationSessionResult, PresentationSuccessResult, PresentationFailureResult, PresentationHiddenResult, PresentationErrorType, MobileCredentialPresentationCredential, MobileCredentialError, MobileCredentialResponseErrorCode, ValidityInfoRequest, CredentialBranding, CredentialBrandingImage, MobileCredentialVerificationResult, MobileCredentialVerificationReasonType, CredentialBrandingImageFormat } from "./verifier/types";
|
|
4
4
|
export { Mode, OpenidPresentationCredentialProfileSupported, MobileCredentialVerificationReasonType, RequestCredentialsErrorType, AbortSessionErrorType, HandleRedirectCallbackErrorType, CredentialBrandingImageFormat, ClaimType, MobileCredentialResponseErrorCode, };
|
|
5
|
-
export type { InitialiseOptions, RequestCredentialsOptions,
|
|
5
|
+
export type { InitialiseOptions, RequestCredentialsOptions, OpenId4vpConfigurationSameDeviceOptions, OpenId4vpConfigurationCrossDeviceOptions, OpenId4vpConfigurationAutoDetectOptions, CredentialQuery, CredentialQueryClaim, RequestCredentialsResponse, RequestCredentialsError, Claim, ClaimData, HandleRedirectCallbackResponse, PresentationSessionResult, PresentationSuccessResult, PresentationFailureResult, PresentationHiddenResult, PresentationErrorType, MobileCredentialPresentationCredential, MobileCredentialError, ValidityInfoRequest, CredentialBranding, CredentialBrandingImage, MobileCredentialVerificationResult, HandleRedirectCallbackError, };
|
|
6
6
|
declare const utils: {
|
|
7
7
|
generateChallenge: () => string;
|
|
8
8
|
getVersion: () => string;
|
|
9
9
|
unwrap: <T = unknown>(result: import("neverthrow").Result<T, unknown>, errMessage?: string) => T;
|
|
10
10
|
};
|
|
11
|
-
export { initialise, requestCredentials, handleRedirectCallback, abortCredentialRequest, utils };
|
|
11
|
+
export { initialise, requestCredentials, handleRedirectCallback, abortCredentialRequest, isDigitalCredentialsApiSupported, utils, };
|
|
@@ -2,5 +2,6 @@ export { initialise } from "./initialise";
|
|
|
2
2
|
export { requestCredentials } from "./requestCredentials";
|
|
3
3
|
export { handleRedirectCallback } from "./handleRedirectCallback";
|
|
4
4
|
export { abortCredentialRequest } from "./abortCredentialRequest";
|
|
5
|
+
export { isDigitalCredentialsApiSupported } from "./requestCredentialsDigitalCredentialsApi";
|
|
5
6
|
export * as types from "./types";
|
|
6
7
|
export * as utils from "./utils";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
2
|
import { CrossDeviceRequestCredentialsOptions, MessageEvent, RequestCredentialsError, RequestCredentialsResponse } from "./types";
|
|
3
3
|
export declare let listener: ((event: MessageEvent) => Promise<void>) | undefined;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const requestCredentialsWithCrossDevice: (options: CrossDeviceRequestCredentialsOptions) => Promise<Result<RequestCredentialsResponse, RequestCredentialsError>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Result } from "neverthrow";
|
|
2
|
+
import { BaseError } from "../common";
|
|
3
|
+
import { ExchangeSessionResultResponse, RequestCredentialsErrorType, RequestCredentialsWithDcApiOptions } from "./types";
|
|
4
|
+
export declare const requestCredentialsWithDigitalCredentialsApi: (options: RequestCredentialsWithDcApiOptions) => Promise<Result<ExchangeSessionResultResponse, BaseError<RequestCredentialsErrorType.RequestCredentialsFailed>>>;
|
|
5
|
+
/**
|
|
6
|
+
* TypeScript does not know that window.DigitalCredential is a valid property,
|
|
7
|
+
* even though it might exist at runtime, because the feature is experimental
|
|
8
|
+
*
|
|
9
|
+
* @returns boolean.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Checks if Digital Credentials API feature is supported for the current browser.
|
|
13
|
+
*
|
|
14
|
+
* @returns boolean.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isDigitalCredentialsApiSupported: () => boolean;
|
|
@@ -290,7 +290,40 @@ export type ExchangeSessionResultRequest = {
|
|
|
290
290
|
readonly challenge: string;
|
|
291
291
|
readonly responseCode: string;
|
|
292
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* The mode in which the credentials are requested
|
|
295
|
+
*/
|
|
296
|
+
export declare enum Mode {
|
|
297
|
+
/**
|
|
298
|
+
* The credentials are requested on the same device
|
|
299
|
+
*/
|
|
300
|
+
SameDevice = "sameDevice",
|
|
301
|
+
/**
|
|
302
|
+
* The credentials are requested on a different device
|
|
303
|
+
*/
|
|
304
|
+
CrossDevice = "crossDevice"
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The type of presentation flow type to proceed with, defined by MATTR VII
|
|
308
|
+
*/
|
|
309
|
+
export declare enum SessionType {
|
|
310
|
+
/**
|
|
311
|
+
* SDK should proceed with presentation flow via Digital Credentials API
|
|
312
|
+
*/
|
|
313
|
+
DigitalCredentialsApi = "digital-credentials-api",
|
|
314
|
+
/**
|
|
315
|
+
* SDK should proceed with presentation flow via openId4vci
|
|
316
|
+
*/
|
|
317
|
+
Openid4vp = "openid4vp"
|
|
318
|
+
}
|
|
293
319
|
export type ExchangeSessionResultResponse = PresentationSessionResult | PresentationHiddenResult;
|
|
320
|
+
export type RequestCredentialsWithDcApiOptions = {
|
|
321
|
+
apiBaseUrl: string;
|
|
322
|
+
sessionId: string;
|
|
323
|
+
sessionKey: string;
|
|
324
|
+
challenge: string;
|
|
325
|
+
request: Record<string, unknown>;
|
|
326
|
+
};
|
|
294
327
|
export type CreateSessionRequest = v.InferOutput<typeof CreateSessionRequestValidator>;
|
|
295
328
|
export declare const CreateSessionRequestValidator: v.ObjectSchema<{
|
|
296
329
|
readonly credentialQuery: v.ArraySchema<v.ObjectSchema<{
|
|
@@ -303,21 +336,26 @@ export declare const CreateSessionRequestValidator: v.ObjectSchema<{
|
|
|
303
336
|
readonly challenge: v.StringSchema<undefined>;
|
|
304
337
|
readonly redirectUri: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
305
338
|
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
339
|
+
readonly dcApiSupported: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
306
340
|
}, undefined>;
|
|
307
|
-
export type CreateSessionResponse =
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
341
|
+
export type CreateSessionResponse = v.InferOutput<typeof CreateSessionResponseValidator>;
|
|
342
|
+
export declare const CreateSessionResponseValidator: v.UnionSchema<[v.ObjectSchema<{
|
|
343
|
+
readonly type: v.LiteralSchema<SessionType.DigitalCredentialsApi, undefined>;
|
|
344
|
+
readonly sessionId: v.StringSchema<undefined>;
|
|
345
|
+
readonly sessionKey: v.StringSchema<undefined>;
|
|
346
|
+
readonly sessionTtl: v.NumberSchema<undefined>;
|
|
347
|
+
readonly request: v.RecordSchema<v.StringSchema<undefined>, v.AnySchema, undefined>;
|
|
348
|
+
}, undefined>, v.ObjectSchema<{
|
|
349
|
+
readonly type: v.OptionalSchema<v.LiteralSchema<SessionType.Openid4vp, undefined>, never>;
|
|
313
350
|
readonly sessionId: v.StringSchema<undefined>;
|
|
314
351
|
readonly sessionKey: v.StringSchema<undefined>;
|
|
315
352
|
readonly sessionUrl: v.StringSchema<undefined>;
|
|
316
|
-
}, undefined>;
|
|
353
|
+
}, undefined>], undefined>;
|
|
317
354
|
export type AbortSessionRequest = v.InferOutput<typeof AbortSessionRequestValidator>;
|
|
318
355
|
export declare const AbortSessionRequestValidator: v.ObjectSchema<{
|
|
319
356
|
readonly sessionId: v.StringSchema<undefined>;
|
|
320
357
|
readonly sessionKey: v.StringSchema<undefined>;
|
|
358
|
+
readonly apiBaseUrl: v.StringSchema<undefined>;
|
|
321
359
|
}, undefined>;
|
|
322
360
|
export type GetSessionStatusRequest = v.InferOutput<typeof GetSessionStatusRequestValidator>;
|
|
323
361
|
export declare const GetSessionStatusRequestValidator: v.ObjectSchema<{
|
|
@@ -1,49 +1,37 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { BaseError } from "../../common";
|
|
3
|
-
import { CredentialQuery, PresentationSessionResult } from "./credential-presentation";
|
|
3
|
+
import { CredentialQuery, Mode, PresentationSessionResult } from "./credential-presentation";
|
|
4
4
|
export declare enum LocalStorageKey {
|
|
5
5
|
challenge = "mattr_chg",
|
|
6
6
|
sessionId = "mattr_sid"
|
|
7
7
|
}
|
|
8
8
|
export declare const MATTR_SDK_VERSION_HEADER = "x-mattr-sdk-version";
|
|
9
9
|
export declare const MATTR_SDK_VERSION_VALUE = "2.0.0";
|
|
10
|
-
/**
|
|
11
|
-
* The mode in which the credentials are requested
|
|
12
|
-
*/
|
|
13
|
-
export declare enum Mode {
|
|
14
|
-
/**
|
|
15
|
-
* The credentials are requested on the same device
|
|
16
|
-
*/
|
|
17
|
-
sameDevice = "sameDevice",
|
|
18
|
-
/**
|
|
19
|
-
* The credentials are requested on a different device
|
|
20
|
-
*/
|
|
21
|
-
crossDevice = "crossDevice"
|
|
22
|
-
}
|
|
23
10
|
export declare enum MessageEventDataType {
|
|
24
11
|
PresentationCompleted = "PresentationCompleted",// { type: "PresentationCompleted", responseCode, sessionId }
|
|
25
12
|
PresentationTimeout = "PresentationTimeout",// { type: "PresentationTimeout", sessionId }
|
|
26
13
|
PresentationAbort = "PresentationAbort"
|
|
27
14
|
}
|
|
28
15
|
export type SameDeviceRequestCredentialsOptions = {
|
|
29
|
-
credentialQuery: CredentialQuery[];
|
|
30
|
-
redirectUri: string;
|
|
31
16
|
challenge: string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
apiBaseUrl: string;
|
|
18
|
+
applicationId: string;
|
|
19
|
+
sessionUrl: string;
|
|
20
|
+
sessionKey: string;
|
|
21
|
+
sessionId: string;
|
|
35
22
|
};
|
|
36
23
|
export type CrossDeviceRequestCredentialsOptions = {
|
|
37
|
-
credentialQuery: CredentialQuery[];
|
|
38
24
|
challenge: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
apiBaseUrl: string;
|
|
26
|
+
sessionUrl: string;
|
|
27
|
+
sessionKey: string;
|
|
28
|
+
sessionId: string;
|
|
42
29
|
};
|
|
43
30
|
/**
|
|
44
|
-
* 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
|
|
45
33
|
*/
|
|
46
|
-
export type
|
|
34
|
+
export type RequestCredentialsBaseOptions = {
|
|
47
35
|
/**
|
|
48
36
|
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
49
37
|
*/
|
|
@@ -51,142 +39,83 @@ export type RequestCredentialsSameDeviceOptions = {
|
|
|
51
39
|
/**
|
|
52
40
|
* The URI to which the user will be redirected after the credential request is completed.
|
|
53
41
|
*/
|
|
54
|
-
redirectUri: string;
|
|
55
|
-
/**
|
|
56
|
-
* 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.
|
|
57
|
-
*/
|
|
58
42
|
challenge?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Options for openid4vpConfiguration to request credentials with same device
|
|
46
|
+
*/
|
|
47
|
+
export type OpenId4vpConfigurationSameDeviceOptions = {
|
|
59
48
|
/**
|
|
60
49
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
61
50
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
62
51
|
*/
|
|
63
52
|
walletProviderId?: string;
|
|
64
53
|
/**
|
|
65
|
-
*
|
|
54
|
+
* A mode in which the credentials are requested. Set to Mode.SameDevice for this type.
|
|
55
|
+
* Can be undefined
|
|
66
56
|
*/
|
|
67
|
-
mode: Mode.
|
|
57
|
+
mode: Mode.SameDevice;
|
|
58
|
+
/**
|
|
59
|
+
* redirectUri is required if mode is same device or undefined
|
|
60
|
+
*/
|
|
61
|
+
redirectUri: string;
|
|
68
62
|
};
|
|
69
|
-
export declare const
|
|
70
|
-
readonly credentialQuery: v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
71
|
-
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
72
|
-
readonly docType: v.StringSchema<undefined>;
|
|
73
|
-
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
74
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
75
|
-
}, undefined>, undefined>, undefined>;
|
|
76
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
77
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
78
|
-
nameSpaces: {
|
|
79
|
-
[x: string]: {
|
|
80
|
-
[x: string]: {
|
|
81
|
-
intentToRetain?: boolean | undefined;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
docType: string;
|
|
86
|
-
}[], undefined>]>;
|
|
87
|
-
readonly redirectUri: v.StringSchema<undefined>;
|
|
88
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
63
|
+
export declare const OpenId4vpConfigSameDeviceOptionsValidator: v.ObjectSchema<{
|
|
89
64
|
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
90
|
-
readonly mode: v.
|
|
65
|
+
readonly mode: v.LiteralSchema<Mode.SameDevice, undefined>;
|
|
66
|
+
readonly redirectUri: v.StringSchema<undefined>;
|
|
91
67
|
}, undefined>;
|
|
92
68
|
/**
|
|
93
|
-
* Options for
|
|
69
|
+
* Options for openid4vpConfiguration to request credentials with cross device
|
|
94
70
|
*/
|
|
95
|
-
export type
|
|
96
|
-
/**
|
|
97
|
-
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
98
|
-
*/
|
|
99
|
-
credentialQuery: CredentialQuery[];
|
|
100
|
-
/**
|
|
101
|
-
* 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.
|
|
102
|
-
*/
|
|
103
|
-
challenge?: string;
|
|
71
|
+
export type OpenId4vpConfigurationCrossDeviceOptions = {
|
|
104
72
|
/**
|
|
105
73
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
106
74
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
107
75
|
*/
|
|
108
76
|
walletProviderId?: string;
|
|
109
77
|
/**
|
|
110
|
-
*
|
|
78
|
+
* A mode in which the credentials are requested. Set to Mode.CrossDevice for this type.
|
|
111
79
|
*/
|
|
112
|
-
mode: Mode.
|
|
80
|
+
mode: Mode.CrossDevice;
|
|
113
81
|
};
|
|
114
|
-
export declare const
|
|
115
|
-
readonly credentialQuery: v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
116
|
-
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
117
|
-
readonly docType: v.StringSchema<undefined>;
|
|
118
|
-
readonly nameSpaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.StrictObjectSchema<{
|
|
119
|
-
readonly intentToRetain: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
120
|
-
}, undefined>, undefined>, undefined>;
|
|
121
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
122
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
123
|
-
nameSpaces: {
|
|
124
|
-
[x: string]: {
|
|
125
|
-
[x: string]: {
|
|
126
|
-
intentToRetain?: boolean | undefined;
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
docType: string;
|
|
131
|
-
}[], undefined>]>;
|
|
132
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
82
|
+
export declare const OpenId4vpConfigCrossDeviceOptionsValidator: v.ObjectSchema<{
|
|
133
83
|
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
134
|
-
readonly mode: v.
|
|
84
|
+
readonly mode: v.LiteralSchema<Mode.CrossDevice, undefined>;
|
|
135
85
|
}, undefined>;
|
|
136
86
|
/**
|
|
137
|
-
* Options for auto
|
|
87
|
+
* Options for openid4vpConfiguration which allow to auto-detect the device mode
|
|
138
88
|
*/
|
|
139
|
-
export type
|
|
140
|
-
/**
|
|
141
|
-
* An array of CredentialQuery objects that specify the credentials to be requested.
|
|
142
|
-
*/
|
|
143
|
-
credentialQuery: CredentialQuery[];
|
|
144
|
-
/**
|
|
145
|
-
* The URI to which the user will be redirected after the credential request is completed.
|
|
146
|
-
*/
|
|
147
|
-
redirectUri: string;
|
|
148
|
-
/**
|
|
149
|
-
* 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.
|
|
150
|
-
*/
|
|
151
|
-
challenge?: string;
|
|
89
|
+
export type OpenId4vpConfigurationAutoDetectOptions = {
|
|
152
90
|
/**
|
|
153
91
|
* An optional identifier for wallet configuration. If not provided, the default wallet will be used.
|
|
154
92
|
* This parameter is defined as part of your MATTR VII tenant verifier configuration
|
|
155
93
|
*/
|
|
156
94
|
walletProviderId?: string;
|
|
95
|
+
/**
|
|
96
|
+
* redirect uri to use for same device mode
|
|
97
|
+
*/
|
|
98
|
+
redirectUri: string;
|
|
157
99
|
/**
|
|
158
100
|
* An optional mode in which the credentials are requested. If not provided, the mode is determined based on the device (isMobileDetect(navigator.userAgent)).
|
|
159
101
|
*/
|
|
160
102
|
mode?: Mode;
|
|
161
103
|
};
|
|
162
|
-
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>;
|
|
163
109
|
/**
|
|
164
110
|
* Options for the requestCredentials function
|
|
165
111
|
*/
|
|
166
|
-
export type RequestCredentialsOptions =
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}, undefined>, undefined>, undefined>;
|
|
174
|
-
}, undefined>, undefined>, v.NonEmptyAction<{
|
|
175
|
-
profile: import("./credential-presentation").OpenidPresentationCredentialProfileSupported;
|
|
176
|
-
nameSpaces: {
|
|
177
|
-
[x: string]: {
|
|
178
|
-
[x: string]: {
|
|
179
|
-
intentToRetain?: boolean | undefined;
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
docType: string;
|
|
184
|
-
}[], undefined>]>;
|
|
185
|
-
readonly redirectUri: v.StringSchema<undefined>;
|
|
186
|
-
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
187
|
-
readonly walletProviderId: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
188
|
-
readonly mode: v.PicklistSchema<[Mode.sameDevice], undefined>;
|
|
189
|
-
}, 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<{
|
|
190
119
|
readonly credentialQuery: v.SchemaWithPipe<[v.ArraySchema<v.ObjectSchema<{
|
|
191
120
|
readonly profile: v.PicklistSchema<[import("./credential-presentation").OpenidPresentationCredentialProfileSupported], undefined>;
|
|
192
121
|
readonly docType: v.StringSchema<undefined>;
|
|
@@ -205,9 +134,19 @@ export declare const RequestCredentialsOptionsValidator: v.UnionSchema<[v.Object
|
|
|
205
134
|
docType: string;
|
|
206
135
|
}[], undefined>]>;
|
|
207
136
|
readonly challenge: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
208
|
-
readonly
|
|
209
|
-
|
|
210
|
-
|
|
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>;
|
|
211
150
|
export type MessageEvent = {
|
|
212
151
|
data: {
|
|
213
152
|
type: MessageEventDataType;
|
|
@@ -217,15 +156,21 @@ export type MessageEvent = {
|
|
|
217
156
|
origin: string;
|
|
218
157
|
};
|
|
219
158
|
/**
|
|
220
|
-
* The response from the requestCredentials function
|
|
159
|
+
* The response from the requestCredentials function when credentials were requested with OpenId4vp
|
|
221
160
|
*/
|
|
222
161
|
export type RequestCredentialsResponse = {
|
|
223
162
|
/**
|
|
224
163
|
* Contains the result of the presentation session if result is configured to be available in the front channel
|
|
225
164
|
*/
|
|
226
165
|
result?: PresentationSessionResult;
|
|
166
|
+
/**
|
|
167
|
+
* when frontChannelResultAvailable is set to true
|
|
168
|
+
*/
|
|
227
169
|
sessionId: string;
|
|
228
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Indicates that session is completed and the flow will continue on the redirected page
|
|
172
|
+
*/
|
|
173
|
+
sessionCompletedInRedirect?: boolean;
|
|
229
174
|
};
|
|
230
175
|
/**
|
|
231
176
|
* The error type for the requestCredentials function
|
|
@@ -239,6 +184,10 @@ export declare enum RequestCredentialsErrorMessage {
|
|
|
239
184
|
FailedToGetSessionResult = "Failed to get session result",
|
|
240
185
|
FailedToGetSessionStatus = "Failed to get session status",
|
|
241
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",
|
|
242
191
|
Abort = "User aborted the session",
|
|
243
192
|
Timeout = "User session timeout"
|
|
244
193
|
}
|
|
@@ -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, InitialiseOptions, CreateSessionResponse } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* Generates a challenge string using the window.crypto API.
|
|
6
6
|
*
|
|
@@ -26,7 +26,7 @@ export declare const getHashParamValue: (hash: string, param: string) => string
|
|
|
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 & InitialiseOptions) => Promise<Result<CreateSessionResponse, SafeFetchValidateResponseError>>;
|
|
30
30
|
/**
|
|
31
31
|
* Abort a session with the provided parameters.
|
|
32
32
|
*
|
|
@@ -34,7 +34,7 @@ export declare const createSession: ({ credentialQuery, challenge, redirectUri,
|
|
|
34
34
|
* @param sessionKey - The authorization key for performing operations for the session.
|
|
35
35
|
* @returns A promise that resolves to a ok result when succeed or an error.
|
|
36
36
|
*/
|
|
37
|
-
export declare const abortSession: ({ apiBaseUrl, sessionId, sessionKey, }: AbortSessionRequest
|
|
37
|
+
export declare const abortSession: ({ apiBaseUrl, sessionId, sessionKey, }: AbortSessionRequest) => Promise<Result<void, SafeFetchValidateResponseError>>;
|
|
38
38
|
/**
|
|
39
39
|
* Retrieve the status for a session with the provided parameters.
|
|
40
40
|
*
|
|
@@ -42,7 +42,7 @@ export declare const abortSession: ({ apiBaseUrl, sessionId, sessionKey, }: Abor
|
|
|
42
42
|
* @param sessionKey - The authorization key for performing operations for the session.
|
|
43
43
|
* @returns A promise that resolves to a result containing either the session status response or an error.
|
|
44
44
|
*/
|
|
45
|
-
export declare const getSessionStatus: ({ apiBaseUrl, sessionId, sessionKey, }: GetSessionStatusRequest & InitialiseOptions) => Promise<Result<GetSessionStatusResponse,
|
|
45
|
+
export declare const getSessionStatus: ({ apiBaseUrl, sessionId, sessionKey, }: GetSessionStatusRequest & InitialiseOptions) => Promise<Result<GetSessionStatusResponse, SafeFetchValidateResponseError>>;
|
|
46
46
|
/**
|
|
47
47
|
* Exchange the result of a session using the provided parameters.
|
|
48
48
|
*
|
|
@@ -57,7 +57,7 @@ export declare const exchangeSessionResult: ({ challenge, responseCode, sessionI
|
|
|
57
57
|
responseCode: string;
|
|
58
58
|
sessionId: string;
|
|
59
59
|
apiBaseUrl: string;
|
|
60
|
-
}) => Promise<Result<ExchangeSessionResultResponse,
|
|
60
|
+
}) => Promise<Result<ExchangeSessionResultResponse, SafeFetchValidateResponseError>>;
|
|
61
61
|
/**
|
|
62
62
|
* Detects if the user agent is a mobile device.
|
|
63
63
|
*
|