@mattrglobal/verifier-sdk-web 1.1.1-unstable.154 → 1.1.1-unstable.155
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 +13 -13
- package/dist/lib/verifier-js-no-deps.cjs.js +23 -23
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +23 -23
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/index.d.ts +4 -4
- package/dist/typings/verifier/index.d.ts +1 -1
- package/dist/typings/verifier/initialize.d.ts +12 -0
- package/dist/typings/verifier/types/credential-presentation.d.ts +1 -1
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +3 -3
- package/dist/typings/verifier/utils.d.ts +3 -3
- package/dist/verifier-js.development.js +23 -23
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +1 -1
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +1 -1
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +2 -2
- package/dist/typings/verifier/initialise.d.ts +0 -12
package/dist/typings/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { initialize, requestCredentials, handleRedirectCallback, abortCredentialRequest, isDigitalCredentialsApiSupported } from "./verifier";
|
|
2
2
|
import { HandleRedirectCallbackError, HandleRedirectCallbackErrorType } from "./verifier/handleRedirectCallback";
|
|
3
|
-
import {
|
|
3
|
+
import { InitializeOptions, 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 {
|
|
5
|
+
export type { InitializeOptions, 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 {
|
|
11
|
+
export { initialize, requestCredentials, handleRedirectCallback, abortCredentialRequest, isDigitalCredentialsApiSupported, utils, };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { initialize } from "./initialize";
|
|
2
2
|
export { requestCredentials } from "./requestCredentials";
|
|
3
3
|
export { handleRedirectCallback } from "./handleRedirectCallback";
|
|
4
4
|
export { abortCredentialRequest } from "./abortCredentialRequest";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InitializeOptions } from "./types";
|
|
2
|
+
export declare enum InitializeErrorMessage {
|
|
3
|
+
SdkNotInitialized = "SDK not initialized"
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Initializes the SDK with the provided options.
|
|
7
|
+
*
|
|
8
|
+
* @param options - The options to initialize the SDK with.
|
|
9
|
+
*/
|
|
10
|
+
export declare const initialize: (options: InitializeOptions) => void;
|
|
11
|
+
export declare const getInitializeOptions: () => InitializeOptions | undefined;
|
|
12
|
+
export declare const clearInitializeOptions: () => void;
|
|
@@ -120,7 +120,7 @@ export type CredentialQuery = {
|
|
|
120
120
|
profile: OpenidPresentationCredentialProfileSupported;
|
|
121
121
|
/**
|
|
122
122
|
* the mDL’s type. Confirm with the certificate issuer for what docType they are issuing. Some common examples include:
|
|
123
|
-
* * Mobile Driver
|
|
123
|
+
* * Mobile Driver License (`org.iso.18013.5.1.mDL`).
|
|
124
124
|
* * PhotoID (`org.iso.23220.photoid.1`).
|
|
125
125
|
* * Mobile Vehicle Registration Card (`org.iso.7367.1.mVRC`).
|
|
126
126
|
* * Health certificate (`org.micov.vtr.1`).
|
|
@@ -219,13 +219,13 @@ export type HandleRedirectCallbackResponse = {
|
|
|
219
219
|
sessionId: string;
|
|
220
220
|
};
|
|
221
221
|
/**
|
|
222
|
-
* Options for the
|
|
222
|
+
* Options for the initialize function
|
|
223
223
|
*/
|
|
224
|
-
export type
|
|
224
|
+
export type InitializeOptions = {
|
|
225
225
|
apiBaseUrl: string;
|
|
226
226
|
applicationId: string;
|
|
227
227
|
};
|
|
228
|
-
export declare const
|
|
228
|
+
export declare const InitializeOptionsValidator: v.ObjectSchema<{
|
|
229
229
|
readonly apiBaseUrl: v.SchemaWithPipe<[v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">]>;
|
|
230
230
|
readonly applicationId: v.SchemaWithPipe<[v.StringSchema<undefined>, v.NonEmptyAction<string, "Must not be empty">]>;
|
|
231
231
|
}, undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
2
|
import { SafeFetchValidateResponseError } from "../common/safeFetch";
|
|
3
|
-
import { CreateSessionRequest, ExchangeSessionResultResponse, GetSessionStatusRequest, GetSessionStatusResponse, AbortSessionRequest,
|
|
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
|
*
|
|
@@ -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, walletProviderId, dcApiSupported, applicationId, }: CreateSessionRequest &
|
|
29
|
+
export declare const createSession: ({ credentialQuery, challenge, redirectUri, apiBaseUrl, walletProviderId, dcApiSupported, applicationId, }: CreateSessionRequest & InitializeOptions) => Promise<Result<CreateSessionResponse, SafeFetchValidateResponseError>>;
|
|
30
30
|
/**
|
|
31
31
|
* Abort a session with the provided parameters.
|
|
32
32
|
*
|
|
@@ -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 &
|
|
45
|
+
export declare const getSessionStatus: ({ apiBaseUrl, sessionId, sessionKey, }: GetSessionStatusRequest & InitializeOptions) => Promise<Result<GetSessionStatusResponse, SafeFetchValidateResponseError>>;
|
|
46
46
|
/**
|
|
47
47
|
* Exchange the result of a session using the provided parameters.
|
|
48
48
|
*
|
|
@@ -1427,7 +1427,7 @@
|
|
|
1427
1427
|
(function(AbortSessionErrorMessage) {
|
|
1428
1428
|
AbortSessionErrorMessage["FailedToAbortSession"] = "Failed to abort session";
|
|
1429
1429
|
})(AbortSessionErrorMessage || (AbortSessionErrorMessage = {}));
|
|
1430
|
-
const
|
|
1430
|
+
const InitializeOptionsValidator = object({
|
|
1431
1431
|
apiBaseUrl: pipe(string(), nonEmpty("Must not be empty")),
|
|
1432
1432
|
applicationId: pipe(string(), nonEmpty("Must not be empty"))
|
|
1433
1433
|
});
|
|
@@ -1464,16 +1464,16 @@
|
|
|
1464
1464
|
});
|
|
1465
1465
|
}
|
|
1466
1466
|
};
|
|
1467
|
-
let
|
|
1468
|
-
var
|
|
1469
|
-
(function(
|
|
1470
|
-
|
|
1471
|
-
})(
|
|
1472
|
-
const
|
|
1473
|
-
assertType(
|
|
1474
|
-
|
|
1467
|
+
let initializeOptions = undefined;
|
|
1468
|
+
var InitializeErrorMessage;
|
|
1469
|
+
(function(InitializeErrorMessage) {
|
|
1470
|
+
InitializeErrorMessage["SdkNotInitialized"] = "SDK not initialized";
|
|
1471
|
+
})(InitializeErrorMessage || (InitializeErrorMessage = {}));
|
|
1472
|
+
const initialize = options => {
|
|
1473
|
+
assertType(InitializeOptionsValidator, "Invalid initialize options")(options);
|
|
1474
|
+
initializeOptions = options;
|
|
1475
1475
|
};
|
|
1476
|
-
const
|
|
1476
|
+
const getInitializeOptions = () => initializeOptions;
|
|
1477
1477
|
let sessionAbortController = undefined;
|
|
1478
1478
|
let _sessionId = undefined;
|
|
1479
1479
|
let _sessionKey = undefined;
|
|
@@ -1791,11 +1791,11 @@
|
|
|
1791
1791
|
}));
|
|
1792
1792
|
};
|
|
1793
1793
|
const abortCredentialRequest = async () => {
|
|
1794
|
-
const
|
|
1795
|
-
if (!
|
|
1796
|
-
throw new Exception(
|
|
1794
|
+
const initializeOptions = getInitializeOptions();
|
|
1795
|
+
if (!initializeOptions) {
|
|
1796
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
1797
1797
|
}
|
|
1798
|
-
const {apiBaseUrl: apiBaseUrl} =
|
|
1798
|
+
const {apiBaseUrl: apiBaseUrl} = initializeOptions;
|
|
1799
1799
|
const session = getActiveSession();
|
|
1800
1800
|
if (!session || !session.sessionKey) {
|
|
1801
1801
|
return ok(undefined);
|
|
@@ -1996,12 +1996,12 @@
|
|
|
1996
1996
|
};
|
|
1997
1997
|
const requestCredentials = async options => {
|
|
1998
1998
|
var _a;
|
|
1999
|
-
const
|
|
2000
|
-
if (!
|
|
2001
|
-
throw new Exception(
|
|
1999
|
+
const initializeOptions = getInitializeOptions();
|
|
2000
|
+
if (!initializeOptions) {
|
|
2001
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
2002
2002
|
}
|
|
2003
2003
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
2004
|
-
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} =
|
|
2004
|
+
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initializeOptions;
|
|
2005
2005
|
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration} = options;
|
|
2006
2006
|
const dcApiSupported = isDigitalCredentialsApiSupported();
|
|
2007
2007
|
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
@@ -2086,11 +2086,11 @@
|
|
|
2086
2086
|
HandleRedirectCallbackErrorMessage["FailedToGetSessionResult"] = "Failed to get session result";
|
|
2087
2087
|
})(HandleRedirectCallbackErrorMessage || (HandleRedirectCallbackErrorMessage = {}));
|
|
2088
2088
|
const handleRedirectCallback = async () => {
|
|
2089
|
-
const
|
|
2090
|
-
if (!
|
|
2091
|
-
throw new Exception(
|
|
2089
|
+
const initializeOptions = getInitializeOptions();
|
|
2090
|
+
if (!initializeOptions) {
|
|
2091
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
2092
2092
|
}
|
|
2093
|
-
const {apiBaseUrl: apiBaseUrl} =
|
|
2093
|
+
const {apiBaseUrl: apiBaseUrl} = initializeOptions;
|
|
2094
2094
|
const responseCode = getHashParamValue(window.location.hash, "response_code");
|
|
2095
2095
|
if (!responseCode) {
|
|
2096
2096
|
return err({
|
|
@@ -2131,7 +2131,7 @@
|
|
|
2131
2131
|
};
|
|
2132
2132
|
exports.abortCredentialRequest = abortCredentialRequest;
|
|
2133
2133
|
exports.handleRedirectCallback = handleRedirectCallback;
|
|
2134
|
-
exports.
|
|
2134
|
+
exports.initialize = initialize;
|
|
2135
2135
|
exports.isDigitalCredentialsApiSupported = isDigitalCredentialsApiSupported;
|
|
2136
2136
|
exports.requestCredentials = requestCredentials;
|
|
2137
2137
|
exports.utils = utils;
|