@mattrglobal/verifier-sdk-web 0.1.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 +31 -0
- package/dist/dependencies.txt +67 -0
- package/dist/lib/verifier-js.cjs.js +6685 -0
- package/dist/lib/verifier-js.cjs.js.map +1 -0
- package/dist/typings/common/error.d.ts +74 -0
- package/dist/typings/common/index.d.ts +3 -0
- package/dist/typings/common/safeFetch.d.ts +23 -0
- package/dist/typings/common/validation.d.ts +11 -0
- package/dist/typings/index.d.ts +11 -0
- package/dist/typings/verifier/handleRedirectCallback.d.ts +14 -0
- package/dist/typings/verifier/index.d.ts +5 -0
- package/dist/typings/verifier/initialise.d.ts +7 -0
- package/dist/typings/verifier/requestCredentials.d.ts +12 -0
- package/dist/typings/verifier/types/credential-presentation.d.ts +222 -0
- package/dist/typings/verifier/types/index.d.ts +4 -0
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +29 -0
- package/dist/typings/verifier/utils.d.ts +23 -0
- package/dist/verifier-js.development.js +6419 -0
- package/dist/verifier-js.development.js.map +1 -0
- package/dist/verifier-js.production.esm.js +35 -0
- package/dist/verifier-js.production.esm.js.map +1 -0
- package/dist/verifier-js.production.js +35 -0
- package/dist/verifier-js.production.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Result } from "neverthrow";
|
|
2
|
+
/**
|
|
3
|
+
* Base error type used for all sdk error responses
|
|
4
|
+
* @typeParam T - the error type
|
|
5
|
+
*/
|
|
6
|
+
export declare type BaseError<T = string> = {
|
|
7
|
+
/**
|
|
8
|
+
* Error type
|
|
9
|
+
*/
|
|
10
|
+
readonly type: T;
|
|
11
|
+
/**
|
|
12
|
+
* Message containing error description
|
|
13
|
+
*/
|
|
14
|
+
readonly message: string;
|
|
15
|
+
/**
|
|
16
|
+
* Information about underlying root cause
|
|
17
|
+
*/
|
|
18
|
+
readonly cause?: Error | unknown;
|
|
19
|
+
/**
|
|
20
|
+
* Additional details
|
|
21
|
+
*/
|
|
22
|
+
readonly details?: unknown;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Instance of an exception
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Used to raise exception when something unexpeced occurs
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```
|
|
32
|
+
* throw new Exception();
|
|
33
|
+
* throw new Exception(erorr);
|
|
34
|
+
* throw new Exception("Unexpected error occur signing", error);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class Exception extends Error {
|
|
38
|
+
readonly cause?: unknown;
|
|
39
|
+
constructor(message: string);
|
|
40
|
+
constructor(cause: unknown);
|
|
41
|
+
constructor(message: string | unknown, cause: unknown);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A utility function to get the value from a {@link Result} or throw if there was an error
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Allows you to get the value of a result directly or handle an error {@link Result} as an exception
|
|
48
|
+
*
|
|
49
|
+
* @param result - The {@link Result} to unwrap
|
|
50
|
+
* @param errMessage - Error message used when unwrap failed
|
|
51
|
+
* @typeParam T - the expected value of an ok result
|
|
52
|
+
*/
|
|
53
|
+
export declare const unwrap: <T = unknown>(result: Result<T, unknown>, errMessage?: string) => T;
|
|
54
|
+
/**
|
|
55
|
+
* Used for exhaustive if/switch statements
|
|
56
|
+
* Example:
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* enum Fruit {
|
|
60
|
+
* orange = "orange",
|
|
61
|
+
* apple = "apple",
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
|
+
* const getFruitName = (fruit: Fruit): string => {
|
|
65
|
+
* if (fruit === Fruit.orange) {
|
|
66
|
+
* return "Orange";
|
|
67
|
+
* }
|
|
68
|
+
*
|
|
69
|
+
* // Should fail TS compilation as Fruit.apple is not being handled in the code above
|
|
70
|
+
* return assertUnreachable(fruit);
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare const assertUnreachable: (_: never) => never;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Result } from "neverthrow";
|
|
2
|
+
import { BaseError } from "./error";
|
|
3
|
+
export declare enum SafeFetchCommonRespondErrorType {
|
|
4
|
+
/**
|
|
5
|
+
* Unexpected response from the remote server
|
|
6
|
+
*/
|
|
7
|
+
UnexpectedRespond = "UnexpectedRespond"
|
|
8
|
+
}
|
|
9
|
+
export declare enum SafeFetchErrorType {
|
|
10
|
+
/**
|
|
11
|
+
* Http error from the remote server with non 2XX response
|
|
12
|
+
*/
|
|
13
|
+
HttpError = "HttpError",
|
|
14
|
+
/**
|
|
15
|
+
* Other uncategorised errors
|
|
16
|
+
*/
|
|
17
|
+
UnknownError = "UnknownError"
|
|
18
|
+
}
|
|
19
|
+
export declare type SafeFetchValidateRespondError = BaseError<SafeFetchErrorType | SafeFetchCommonRespondErrorType.UnexpectedRespond>;
|
|
20
|
+
/**
|
|
21
|
+
* Safe fetch function that wraps the fetch function and returns a Result type
|
|
22
|
+
*/
|
|
23
|
+
export declare const safeFetch: (input: RequestInfo, init?: RequestInit) => Promise<Result<Response, BaseError<SafeFetchErrorType>>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ZodType } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Provide typeguards and boolean result of a zod validator
|
|
4
|
+
* @param validator
|
|
5
|
+
*/
|
|
6
|
+
export declare const isType: <T>(validator: ZodType<T, import("zod").ZodTypeDef, T>) => (value: unknown) => value is T;
|
|
7
|
+
/**
|
|
8
|
+
* Asserts data against either internal Validator functions or Zod object schemas
|
|
9
|
+
* Throws CoreTypeError if assertion fails
|
|
10
|
+
*/
|
|
11
|
+
export declare const assertType: <T, InputData = T>(validator: ZodType<T, import("zod").ZodTypeDef, T>, message: string) => (data: InputData) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { initialise, requestCredentials, handleRedirectCallback } from "./verifier";
|
|
2
|
+
import { HandleRedirectCallbackError, HandleRedirectCallbackErrorType } from "./verifier/handleRedirectCallback";
|
|
3
|
+
import { RequestCredentialsError, RequestCredentialsErrorType } from "./verifier/requestCredentials";
|
|
4
|
+
import { InitialiseOptions, RequestCredentialsOptions, CredentialQuery, OpenidPresentationCredentialProfileSupported, Mode, RequestCredentialsResponse, HandleRedirectCallbackResponse, ClaimType, PresentationSuccessResult, MobileCredentialPresentationCredential, ValidityInfoRequest, CredentialBranding, MobileCredentialResponseErrorCode, MobileCredentialVerificationResult, MobileCredentialVerificationReasonType, CredentialBrandingImageFormat } from "./verifier/types";
|
|
5
|
+
export { Mode, OpenidPresentationCredentialProfileSupported, MobileCredentialVerificationReasonType, RequestCredentialsErrorType, HandleRedirectCallbackErrorType, CredentialBrandingImageFormat, ClaimType, };
|
|
6
|
+
export type { InitialiseOptions, RequestCredentialsOptions, CredentialQuery, RequestCredentialsResponse, RequestCredentialsError, HandleRedirectCallbackResponse, PresentationSuccessResult, MobileCredentialPresentationCredential, ValidityInfoRequest, CredentialBranding, MobileCredentialResponseErrorCode, MobileCredentialVerificationResult, HandleRedirectCallbackError, };
|
|
7
|
+
declare const utils: {
|
|
8
|
+
generateChallenge: () => string;
|
|
9
|
+
unwrap: <T = unknown>(result: import("neverthrow").Result<T, unknown>, errMessage?: string | undefined) => T;
|
|
10
|
+
};
|
|
11
|
+
export { initialise, requestCredentials, handleRedirectCallback, utils };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Result } from "neverthrow";
|
|
2
|
+
import { BaseError } from "../common";
|
|
3
|
+
import { HandleRedirectCallbackResponse } from "./types";
|
|
4
|
+
export declare enum HandleRedirectCallbackErrorType {
|
|
5
|
+
HandleRedirectCallbackFailed = "HandleRedirectCallbackFailed"
|
|
6
|
+
}
|
|
7
|
+
export declare enum HandleRedirectCallbackErrorMessage {
|
|
8
|
+
FailedToFindResponseCode = "Failed to find response code",
|
|
9
|
+
FailedToFindChallenge = "Failed to find challenge",
|
|
10
|
+
FailedToFindSessionId = "Failed to find sessionId",
|
|
11
|
+
FailedToGetSessionResult = "Failed to get session result"
|
|
12
|
+
}
|
|
13
|
+
export declare type HandleRedirectCallbackError = BaseError<HandleRedirectCallbackErrorType>;
|
|
14
|
+
export declare const handleRedirectCallback: () => Promise<Result<HandleRedirectCallbackResponse, HandleRedirectCallbackError>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InitialiseOptions } from "./types";
|
|
2
|
+
export declare enum InitialiseErrorMessage {
|
|
3
|
+
SdkNotInitialised = "SDK not initialised"
|
|
4
|
+
}
|
|
5
|
+
export declare const initialise: (options: InitialiseOptions) => void;
|
|
6
|
+
export declare const getInitialiseOptions: () => InitialiseOptions | undefined;
|
|
7
|
+
export declare const clearInitialiseOptions: () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Result } from "neverthrow";
|
|
2
|
+
import { BaseError } from "../common";
|
|
3
|
+
import { RequestCredentialsOptions, RequestCredentialsResponse } from "./types";
|
|
4
|
+
export declare enum RequestCredentialsErrorType {
|
|
5
|
+
RequestCredentialsFailed = "RequestCredentialsFailed"
|
|
6
|
+
}
|
|
7
|
+
export declare enum RequestCredentialsErrorMessage {
|
|
8
|
+
FailedToStoreChallenge = "Failed to store challenge",
|
|
9
|
+
FailedToCreateSession = "Failed to create session"
|
|
10
|
+
}
|
|
11
|
+
export declare type RequestCredentialsError = BaseError<RequestCredentialsErrorType>;
|
|
12
|
+
export declare const requestCredentials: (options: RequestCredentialsOptions) => Promise<Result<RequestCredentialsResponse, RequestCredentialsError>>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/*** mobile-credential-framework https://github.com/mattrinternal/opencore/tree/master/packages/mobile-credential-framework/src/types ***/
|
|
3
|
+
export declare enum MobileCredentialVerificationReasonType {
|
|
4
|
+
Expired = "expired",
|
|
5
|
+
Inactive = "inactive"
|
|
6
|
+
}
|
|
7
|
+
export declare enum ClaimType {
|
|
8
|
+
Boolean = "boolean",
|
|
9
|
+
Number = "number",
|
|
10
|
+
String = "string",
|
|
11
|
+
Binary = "binary",
|
|
12
|
+
Date = "date",
|
|
13
|
+
DateTime = "dateTime",
|
|
14
|
+
Array = "array",
|
|
15
|
+
Object = "object"
|
|
16
|
+
}
|
|
17
|
+
export declare enum CredentialBrandingImageFormat {
|
|
18
|
+
svg = "svg",
|
|
19
|
+
png = "png"
|
|
20
|
+
}
|
|
21
|
+
export declare enum MobileCredentialResponseErrorCode {
|
|
22
|
+
NotReturned = "notReturned"
|
|
23
|
+
}
|
|
24
|
+
export declare type MobileCredentialError = {
|
|
25
|
+
readonly docType: string;
|
|
26
|
+
readonly errorCode: MobileCredentialResponseErrorCode;
|
|
27
|
+
};
|
|
28
|
+
/*** mobile-credential-framework end ***/
|
|
29
|
+
/*** credential-presentation https://github.com/mattrinternal/platform/tree/master/libraries/platform-api-types/src/api-types/credential-presentation ***/
|
|
30
|
+
export declare enum OpenidPresentationCredentialProfileSupported {
|
|
31
|
+
MOBILE = "mobile"
|
|
32
|
+
}
|
|
33
|
+
export declare type CredentialQueryClaim = {
|
|
34
|
+
intentToRetain?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* {
|
|
38
|
+
* "format":"mso_mdoc",
|
|
39
|
+
* "docType":"org.iso.18013.5.1.mDL",
|
|
40
|
+
* "nameSpaces":{
|
|
41
|
+
* "org.iso.18013.5.1":{
|
|
42
|
+
* "birthdate":{
|
|
43
|
+
* "intentToRetain":true
|
|
44
|
+
* },
|
|
45
|
+
* "portrait":{
|
|
46
|
+
* "intentToRetain":true
|
|
47
|
+
* },
|
|
48
|
+
* "resident_postal_code":{
|
|
49
|
+
* "intentToRetain":true
|
|
50
|
+
* }
|
|
51
|
+
* },
|
|
52
|
+
* "org.iso.18013.5.1.aamva":{
|
|
53
|
+
* "DHS_compliance":{
|
|
54
|
+
* "intentToRetain":true
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
*/
|
|
60
|
+
export declare type CredentialQuery = {
|
|
61
|
+
profile: OpenidPresentationCredentialProfileSupported;
|
|
62
|
+
docType: string;
|
|
63
|
+
nameSpaces: {
|
|
64
|
+
[nameSpace: string]: {
|
|
65
|
+
[claim: string]: CredentialQueryClaim;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export declare const CredentialQueryValidator: z.ZodType<CredentialQuery>;
|
|
70
|
+
/**
|
|
71
|
+
* List of error types for presentation failure result
|
|
72
|
+
*/
|
|
73
|
+
export declare enum PresentationErrorType {
|
|
74
|
+
/**
|
|
75
|
+
* User aborted the session explicitly before it timed-out
|
|
76
|
+
*/
|
|
77
|
+
SessionAborted = "SessionAborted",
|
|
78
|
+
/**
|
|
79
|
+
* The submitted presentation response is invalid
|
|
80
|
+
* @category Verification Error
|
|
81
|
+
*/
|
|
82
|
+
VerificationError = "VerificationError",
|
|
83
|
+
/**
|
|
84
|
+
* Received an error presentation response
|
|
85
|
+
*/
|
|
86
|
+
ResponseError = "ResponseError",
|
|
87
|
+
/**
|
|
88
|
+
* Encountered an unknown error while processing a presentation response
|
|
89
|
+
*/
|
|
90
|
+
Unknown = "Unknown"
|
|
91
|
+
}
|
|
92
|
+
/*** credential-presentation end ***/
|
|
93
|
+
/*** mobile-credential https://github.com/mattrinternal/platform/tree/master/libraries/platform-api-types/src/api-types/mobile-credential ***/
|
|
94
|
+
export declare type ValidityInfoRequest = {
|
|
95
|
+
signed: string;
|
|
96
|
+
validFrom: string;
|
|
97
|
+
validUntil: string;
|
|
98
|
+
expectedUpdate?: string;
|
|
99
|
+
};
|
|
100
|
+
export declare type CredentialBrandingImage = {
|
|
101
|
+
format: CredentialBrandingImageFormat;
|
|
102
|
+
data: string;
|
|
103
|
+
};
|
|
104
|
+
export declare type CredentialBranding = {
|
|
105
|
+
name?: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
backgroundColor?: string;
|
|
108
|
+
watermarkImage?: CredentialBrandingImage;
|
|
109
|
+
issuerLogo?: CredentialBrandingImage;
|
|
110
|
+
issuerIcon?: CredentialBrandingImage;
|
|
111
|
+
};
|
|
112
|
+
export declare type MobileCredentialVerificationResult = {
|
|
113
|
+
readonly verified: true;
|
|
114
|
+
} | {
|
|
115
|
+
readonly verified: false;
|
|
116
|
+
readonly reason: {
|
|
117
|
+
readonly type: MobileCredentialVerificationReasonType;
|
|
118
|
+
readonly message: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export declare type ClaimData = boolean | number | string | ClaimData[] | {
|
|
122
|
+
[key: string]: ClaimData;
|
|
123
|
+
};
|
|
124
|
+
export declare type DrivingPrivilegesClaim = {
|
|
125
|
+
vehicle_category_code: string;
|
|
126
|
+
issue_date: string;
|
|
127
|
+
expiry_date: string;
|
|
128
|
+
}[];
|
|
129
|
+
export declare type Claim = {
|
|
130
|
+
readonly type?: ClaimType.Boolean;
|
|
131
|
+
readonly value: boolean;
|
|
132
|
+
} | {
|
|
133
|
+
readonly type?: ClaimType.Number;
|
|
134
|
+
readonly value: number;
|
|
135
|
+
} | {
|
|
136
|
+
readonly type?: ClaimType.String;
|
|
137
|
+
readonly value: string;
|
|
138
|
+
} | {
|
|
139
|
+
readonly type: ClaimType.Binary;
|
|
140
|
+
readonly value: string;
|
|
141
|
+
} | {
|
|
142
|
+
readonly type: ClaimType.Date;
|
|
143
|
+
readonly value: string;
|
|
144
|
+
} | {
|
|
145
|
+
readonly type: ClaimType.DateTime;
|
|
146
|
+
readonly value: string;
|
|
147
|
+
} | {
|
|
148
|
+
readonly type: ClaimType.Object;
|
|
149
|
+
readonly value: Record<string, ClaimData>;
|
|
150
|
+
} | {
|
|
151
|
+
readonly type: ClaimType.Array;
|
|
152
|
+
readonly value: Array<ClaimData>;
|
|
153
|
+
};
|
|
154
|
+
export declare type MobileCredentialPresentationCredential = {
|
|
155
|
+
docType: string;
|
|
156
|
+
validityInfo: ValidityInfoRequest;
|
|
157
|
+
branding?: CredentialBranding;
|
|
158
|
+
claims?: Record<string, Record<string, Claim>>;
|
|
159
|
+
claimErrors?: Record<string, Record<string, MobileCredentialResponseErrorCode>>;
|
|
160
|
+
verificationResult: MobileCredentialVerificationResult;
|
|
161
|
+
issuerInfo: {
|
|
162
|
+
commonName: string;
|
|
163
|
+
trustedIssuerId: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/*** mobile-credential end ***/
|
|
167
|
+
/*** session result https://github.com/mattrinternal/platform/tree/master/libraries/platform-api-types/src/api-types/credential-presentation/sessionResult.ts ***/
|
|
168
|
+
export declare type PresentationSuccessResult = {
|
|
169
|
+
sessionId: string;
|
|
170
|
+
challenge: string;
|
|
171
|
+
credentialQuery: CredentialQuery[];
|
|
172
|
+
credentials?: MobileCredentialPresentationCredential[];
|
|
173
|
+
credentialErrors?: MobileCredentialError[];
|
|
174
|
+
};
|
|
175
|
+
export declare type PresentationSuccessResultRelax = {
|
|
176
|
+
sessionId: string;
|
|
177
|
+
challenge: string;
|
|
178
|
+
credentialQuery?: unknown;
|
|
179
|
+
credentials?: unknown;
|
|
180
|
+
credentialErrors?: unknown;
|
|
181
|
+
};
|
|
182
|
+
export declare const PresentationSuccessResultRelaxValidator: z.ZodType<PresentationSuccessResultRelax>;
|
|
183
|
+
export declare type PresentationFailureResult = {
|
|
184
|
+
sessionId: string;
|
|
185
|
+
challenge: string;
|
|
186
|
+
credentialQuery: CredentialQuery[];
|
|
187
|
+
error: {
|
|
188
|
+
type: PresentationErrorType;
|
|
189
|
+
message: string;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
export declare type PresentationSessionResult = PresentationSuccessResult | PresentationFailureResult;
|
|
193
|
+
export declare type ExchangeSessionResultParams = {
|
|
194
|
+
readonly sessionId: string;
|
|
195
|
+
};
|
|
196
|
+
export declare type ExchangeSessionResultRequest = {
|
|
197
|
+
readonly challenge: string;
|
|
198
|
+
readonly responseCode: string;
|
|
199
|
+
};
|
|
200
|
+
export declare type ExchangeSessionResultResponse = PresentationSessionResult;
|
|
201
|
+
/*** session result end ***/
|
|
202
|
+
/*** session https://github.com/mattrinternal/platform/tree/master/libraries/platform-api-types/src/api-types/credential-presentation/session.ts ***/
|
|
203
|
+
export declare type CreateSessionRequest = z.infer<typeof CreateSessionRequestValidator>;
|
|
204
|
+
export declare const CreateSessionRequestValidator: z.ZodObject<{
|
|
205
|
+
credentialQuery: z.ZodArray<z.ZodType<CredentialQuery, z.ZodTypeDef, CredentialQuery>, "many">;
|
|
206
|
+
challenge: z.ZodString;
|
|
207
|
+
redirectUri: z.ZodOptional<z.ZodString>;
|
|
208
|
+
}, "strip", z.ZodTypeAny, {
|
|
209
|
+
challenge: string;
|
|
210
|
+
credentialQuery: CredentialQuery[];
|
|
211
|
+
redirectUri?: string | undefined;
|
|
212
|
+
}, {
|
|
213
|
+
challenge: string;
|
|
214
|
+
credentialQuery: CredentialQuery[];
|
|
215
|
+
redirectUri?: string | undefined;
|
|
216
|
+
}>;
|
|
217
|
+
export declare type CreateSessionResponse = {
|
|
218
|
+
sessionId: string;
|
|
219
|
+
sessionUrl: string;
|
|
220
|
+
};
|
|
221
|
+
export declare const CreateSessionResponseValidator: z.ZodType<CreateSessionResponse>;
|
|
222
|
+
/*** session end ***/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CredentialQuery, PresentationSuccessResult } from "./credential-presentation";
|
|
3
|
+
export declare enum LocalStorageKey {
|
|
4
|
+
challenge = "mattr_chg",
|
|
5
|
+
sessionId = "mattr_sid"
|
|
6
|
+
}
|
|
7
|
+
export declare enum Mode {
|
|
8
|
+
sameDevice = "sameDevice",
|
|
9
|
+
crossDevice = "crossDevice"
|
|
10
|
+
}
|
|
11
|
+
export declare type SameDeviceRequestCredentialsOptions = {
|
|
12
|
+
credentialQuery: CredentialQuery[];
|
|
13
|
+
challenge?: string;
|
|
14
|
+
redirectUri: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const SameDeviceRequestCredentialsOptionsValidator: z.ZodType<SameDeviceRequestCredentialsOptions>;
|
|
17
|
+
export declare type RequestCredentialsOptions = SameDeviceRequestCredentialsOptions;
|
|
18
|
+
export declare const RequestCredentialsOptionsValidator: z.ZodType<RequestCredentialsOptions>;
|
|
19
|
+
export declare type SameDeviceRequestCredentialsResponse = {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
};
|
|
22
|
+
export declare type RequestCredentialsResponse = SameDeviceRequestCredentialsResponse;
|
|
23
|
+
export declare type HandleRedirectCallbackResponse = {
|
|
24
|
+
result: PresentationSuccessResult;
|
|
25
|
+
};
|
|
26
|
+
export declare type InitialiseOptions = {
|
|
27
|
+
apiBaseUrl: string;
|
|
28
|
+
};
|
|
29
|
+
export declare const InitialiseOptionsValidator: z.ZodType<InitialiseOptions>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Result } from "neverthrow";
|
|
2
|
+
import { SafeFetchValidateRespondError } from "../common/safeFetch";
|
|
3
|
+
import { CreateSessionRequest, CreateSessionResponse, PresentationSuccessResult } from "./types";
|
|
4
|
+
export declare const generateChallenge: () => string;
|
|
5
|
+
/**
|
|
6
|
+
* e.g. #response_code=456
|
|
7
|
+
* @param hash window.location.hash
|
|
8
|
+
* @param param
|
|
9
|
+
*/
|
|
10
|
+
export declare const getHashParamValue: (hash: string, param: string) => string | null;
|
|
11
|
+
export declare const createSession: ({ credentialQuery, challenge, redirectUri, apiBaseUrl, }: {
|
|
12
|
+
credentialQuery: import("./types").CredentialQuery[];
|
|
13
|
+
challenge: string;
|
|
14
|
+
redirectUri?: string | undefined;
|
|
15
|
+
} & {
|
|
16
|
+
apiBaseUrl: string;
|
|
17
|
+
}) => Promise<Result<CreateSessionResponse, SafeFetchValidateRespondError>>;
|
|
18
|
+
export declare const getSessionResult: ({ challenge, responseCode, sessionId, apiBaseUrl, }: {
|
|
19
|
+
challenge: string;
|
|
20
|
+
responseCode: string;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
apiBaseUrl: string;
|
|
23
|
+
}) => Promise<Result<PresentationSuccessResult, SafeFetchValidateRespondError>>;
|