@mattrglobal/verifier-sdk-web 1.1.1-unstable.153 → 1.1.1-unstable.154
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 +56 -46
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +56 -46
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/verifier/types/credential-presentation.d.ts +1 -0
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +2 -0
- package/dist/verifier-js.development.js +54 -45
- 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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2025-05-
|
|
10
|
+
* Generated: 2025-05-18
|
|
11
11
|
* Version: 1.1.0
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*/
|
|
@@ -371,22 +371,27 @@ let _sessionId = undefined;
|
|
|
371
371
|
|
|
372
372
|
let _sessionKey = undefined;
|
|
373
373
|
|
|
374
|
+
let _sessionTimeoutId = undefined;
|
|
375
|
+
|
|
374
376
|
const getActiveSession = () => {
|
|
375
377
|
const sessionId = _sessionId;
|
|
376
378
|
const sessionKey = _sessionKey;
|
|
379
|
+
const sessionTimeoutId = _sessionTimeoutId;
|
|
377
380
|
if (sessionId) {
|
|
378
381
|
return {
|
|
379
382
|
sessionId: sessionId,
|
|
380
|
-
sessionKey: sessionKey
|
|
383
|
+
sessionKey: sessionKey,
|
|
384
|
+
sessionTimeoutId: sessionTimeoutId
|
|
381
385
|
};
|
|
382
386
|
}
|
|
383
387
|
return undefined;
|
|
384
388
|
};
|
|
385
389
|
|
|
386
390
|
const setActiveSession = session => {
|
|
387
|
-
const {sessionId: sessionId, sessionKey: sessionKey} = session;
|
|
391
|
+
const {sessionId: sessionId, sessionKey: sessionKey, sessionTimeoutId: sessionTimeoutId} = session;
|
|
388
392
|
_sessionId = sessionId;
|
|
389
393
|
_sessionKey = sessionKey;
|
|
394
|
+
_sessionTimeoutId = sessionTimeoutId;
|
|
390
395
|
const abortController = new AbortController;
|
|
391
396
|
sessionAbortController = abortController;
|
|
392
397
|
return abortController;
|
|
@@ -394,9 +399,13 @@ const setActiveSession = session => {
|
|
|
394
399
|
|
|
395
400
|
const removeActiveSession = () => {
|
|
396
401
|
sessionAbortController === null || sessionAbortController === void 0 ? void 0 : sessionAbortController.abort();
|
|
402
|
+
if (_sessionTimeoutId) {
|
|
403
|
+
window.clearTimeout(_sessionTimeoutId);
|
|
404
|
+
}
|
|
397
405
|
sessionAbortController = undefined;
|
|
398
406
|
_sessionKey = undefined;
|
|
399
407
|
_sessionId = undefined;
|
|
408
|
+
_sessionTimeoutId = undefined;
|
|
400
409
|
};
|
|
401
410
|
|
|
402
411
|
const defaultRetryDelay = attempt => Math.pow(2, attempt) * 1e3;
|
|
@@ -677,25 +686,50 @@ const requestCredentialsWithCrossDevice = async options => {
|
|
|
677
686
|
}));
|
|
678
687
|
};
|
|
679
688
|
|
|
689
|
+
const abortCredentialRequest = async () => {
|
|
690
|
+
const initialiseOptions = getInitialiseOptions();
|
|
691
|
+
if (!initialiseOptions) {
|
|
692
|
+
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
693
|
+
}
|
|
694
|
+
const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
|
|
695
|
+
const session = getActiveSession();
|
|
696
|
+
if (!session || !session.sessionKey) {
|
|
697
|
+
return neverthrow.ok(undefined);
|
|
698
|
+
}
|
|
699
|
+
const {sessionId: sessionId, sessionKey: sessionKey} = session;
|
|
700
|
+
removeActiveSession();
|
|
701
|
+
const abortSessionResult = await abortSession({
|
|
702
|
+
apiBaseUrl: apiBaseUrl,
|
|
703
|
+
sessionId: sessionId,
|
|
704
|
+
sessionKey: sessionKey
|
|
705
|
+
});
|
|
706
|
+
if (abortSessionResult.isErr()) {
|
|
707
|
+
return neverthrow.err({
|
|
708
|
+
type: exports.AbortSessionErrorType.AbortSessionFailed,
|
|
709
|
+
message: AbortSessionErrorMessage.FailedToAbortSession,
|
|
710
|
+
cause: abortSessionResult.error
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
return neverthrow.ok(undefined);
|
|
714
|
+
};
|
|
715
|
+
|
|
680
716
|
const requestCredentialsWithDigitalCredentialsApi = async options => {
|
|
681
|
-
const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, request: request} = options;
|
|
682
|
-
const
|
|
717
|
+
const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, request: request, sessionTtl: sessionTtl} = options;
|
|
718
|
+
const sessionTimeoutId = window.setTimeout((() => removeActiveSession()), sessionTtl * 1e3);
|
|
719
|
+
const abortController = setActiveSession({
|
|
720
|
+
sessionId: sessionId,
|
|
721
|
+
sessionKey: sessionKey,
|
|
722
|
+
sessionTimeoutId: sessionTimeoutId
|
|
723
|
+
});
|
|
724
|
+
const credentialResponseResult = await getCredentials(request, abortController);
|
|
683
725
|
if (credentialResponseResult.isErr()) {
|
|
684
|
-
await
|
|
685
|
-
apiBaseUrl: apiBaseUrl,
|
|
686
|
-
sessionId: sessionId,
|
|
687
|
-
sessionKey: sessionKey
|
|
688
|
-
});
|
|
726
|
+
await abortCredentialRequest();
|
|
689
727
|
return neverthrow.err(credentialResponseResult.error);
|
|
690
728
|
}
|
|
691
729
|
const credentialResponse = credentialResponseResult.value;
|
|
692
730
|
const parsedCredentialResponseResult = parseCredentialResponse(credentialResponse);
|
|
693
731
|
if (parsedCredentialResponseResult.isErr()) {
|
|
694
|
-
await
|
|
695
|
-
apiBaseUrl: apiBaseUrl,
|
|
696
|
-
sessionId: sessionId,
|
|
697
|
-
sessionKey: sessionKey
|
|
698
|
-
});
|
|
732
|
+
await abortCredentialRequest();
|
|
699
733
|
return neverthrow.err(parsedCredentialResponseResult.error);
|
|
700
734
|
}
|
|
701
735
|
const parsedCredentialResponse = parsedCredentialResponseResult.value;
|
|
@@ -717,9 +751,11 @@ const requestCredentialsWithDigitalCredentialsApi = async options => {
|
|
|
717
751
|
return neverthrow.ok(credentialVerificationResult.value);
|
|
718
752
|
};
|
|
719
753
|
|
|
720
|
-
const getCredentials = async request => {
|
|
754
|
+
const getCredentials = async (request, abortController) => {
|
|
721
755
|
try {
|
|
722
|
-
const credentialResponse = await navigator.credentials.get(request)
|
|
756
|
+
const credentialResponse = await navigator.credentials.get(Object.assign(Object.assign({}, request), {
|
|
757
|
+
signal: abortController.signal
|
|
758
|
+
}));
|
|
723
759
|
return neverthrow.ok(credentialResponse);
|
|
724
760
|
} catch (exception) {
|
|
725
761
|
return neverthrow.err({
|
|
@@ -897,13 +933,14 @@ const requestCredentials = async options => {
|
|
|
897
933
|
const session = createSessionResult.value;
|
|
898
934
|
const {sessionKey: sessionKey, sessionId: sessionId} = session;
|
|
899
935
|
if (session.type === SessionType.DigitalCredentialsApi) {
|
|
900
|
-
const {request: request} = session;
|
|
936
|
+
const {request: request, sessionTtl: sessionTtl} = session;
|
|
901
937
|
return await requestCredentialsWithDigitalCredentialsApi({
|
|
902
938
|
apiBaseUrl: apiBaseUrl,
|
|
903
939
|
request: request,
|
|
904
940
|
sessionId: sessionId,
|
|
905
941
|
sessionKey: sessionKey,
|
|
906
|
-
challenge: challenge
|
|
942
|
+
challenge: challenge,
|
|
943
|
+
sessionTtl: sessionTtl
|
|
907
944
|
});
|
|
908
945
|
}
|
|
909
946
|
if (!openid4vpConfiguration) {
|
|
@@ -1003,33 +1040,6 @@ const handleRedirectCallback = async () => {
|
|
|
1003
1040
|
});
|
|
1004
1041
|
};
|
|
1005
1042
|
|
|
1006
|
-
const abortCredentialRequest = async () => {
|
|
1007
|
-
const initialiseOptions = getInitialiseOptions();
|
|
1008
|
-
if (!initialiseOptions) {
|
|
1009
|
-
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
1010
|
-
}
|
|
1011
|
-
const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
|
|
1012
|
-
const session = getActiveSession();
|
|
1013
|
-
if (!session || !session.sessionKey) {
|
|
1014
|
-
return neverthrow.ok(undefined);
|
|
1015
|
-
}
|
|
1016
|
-
const {sessionId: sessionId, sessionKey: sessionKey} = session;
|
|
1017
|
-
removeActiveSession();
|
|
1018
|
-
const abortSessionResult = await abortSession({
|
|
1019
|
-
apiBaseUrl: apiBaseUrl,
|
|
1020
|
-
sessionId: sessionId,
|
|
1021
|
-
sessionKey: sessionKey
|
|
1022
|
-
});
|
|
1023
|
-
if (abortSessionResult.isErr()) {
|
|
1024
|
-
return neverthrow.err({
|
|
1025
|
-
type: exports.AbortSessionErrorType.AbortSessionFailed,
|
|
1026
|
-
message: AbortSessionErrorMessage.FailedToAbortSession,
|
|
1027
|
-
cause: abortSessionResult.error
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
return neverthrow.ok(undefined);
|
|
1031
|
-
};
|
|
1032
|
-
|
|
1033
1043
|
const utils = {
|
|
1034
1044
|
generateChallenge: generateChallenge,
|
|
1035
1045
|
getVersion: getVersion,
|