@sphereon/oid4vci-common 0.19.1-feature.DIIPv4.83 → 0.19.1-feature.DIIPv4.96
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/index.cjs +32 -401
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -337
- package/dist/index.d.ts +14 -337
- package/dist/index.js +28 -391
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -151,10 +151,7 @@ __export(index_exports, {
|
|
|
151
151
|
convertURIToJsonObject: () => convertURIToJsonObject,
|
|
152
152
|
createCodeChallenge: () => createCodeChallenge,
|
|
153
153
|
createProofOfPossession: () => createProofOfPossession,
|
|
154
|
-
credentialIssuerMetadataFieldNames: () => credentialIssuerMetadataFieldNames,
|
|
155
154
|
credentialIssuerMetadataFieldNamesV1_0_15: () => credentialIssuerMetadataFieldNamesV1_0_15,
|
|
156
|
-
credentialSupportedV8ToV13: () => credentialSupportedV8ToV13,
|
|
157
|
-
credentialsSupportedV8ToV13: () => credentialsSupportedV8ToV13,
|
|
158
155
|
decodeJsonProperties: () => decodeJsonProperties,
|
|
159
156
|
determineFlowType: () => determineFlowType,
|
|
160
157
|
determineGrantTypes: () => determineGrantTypes,
|
|
@@ -170,7 +167,6 @@ __export(index_exports, {
|
|
|
170
167
|
getClientIdFromCredentialOfferPayload: () => getClientIdFromCredentialOfferPayload,
|
|
171
168
|
getCredentialConfigurationIdsFromOfferV1_0_15: () => getCredentialConfigurationIdsFromOfferV1_0_15,
|
|
172
169
|
getCredentialOfferPayload: () => getCredentialOfferPayload,
|
|
173
|
-
getCredentialRequestForVersion: () => getCredentialRequestForVersion,
|
|
174
170
|
getFormatForVersion: () => getFormatForVersion,
|
|
175
171
|
getIssuerDisplays: () => getIssuerDisplays,
|
|
176
172
|
getIssuerFromCredentialOfferPayload: () => getIssuerFromCredentialOfferPayload,
|
|
@@ -185,12 +181,8 @@ __export(index_exports, {
|
|
|
185
181
|
getTypesFromCredentialOffer: () => getTypesFromCredentialOffer,
|
|
186
182
|
getTypesFromCredentialSupported: () => getTypesFromCredentialSupported,
|
|
187
183
|
getTypesFromObject: () => getTypesFromObject,
|
|
188
|
-
getTypesFromOfferV1_0_11: () => getTypesFromOfferV1_0_11,
|
|
189
|
-
getTypesFromRequest: () => getTypesFromRequest,
|
|
190
184
|
getURIComponentsAsArray: () => getURIComponentsAsArray,
|
|
191
185
|
getUniformFormat: () => getUniformFormat,
|
|
192
|
-
isAuthorizationRequestV1_0_09: () => isAuthorizationRequestV1_0_09,
|
|
193
|
-
isAuthorizationRequestV1_0_11: () => isAuthorizationRequestV1_0_11,
|
|
194
186
|
isCredentialOfferVersion: () => isCredentialOfferVersion,
|
|
195
187
|
isDeferredCredentialIssuancePending: () => isDeferredCredentialIssuancePending,
|
|
196
188
|
isDeferredCredentialResponse: () => isDeferredCredentialResponse,
|
|
@@ -222,6 +214,14 @@ init_cjs_shims();
|
|
|
222
214
|
// lib/functions/CredentialRequestUtil.ts
|
|
223
215
|
init_cjs_shims();
|
|
224
216
|
|
|
217
|
+
// lib/functions/CredentialResponseUtil.ts
|
|
218
|
+
init_cjs_shims();
|
|
219
|
+
|
|
220
|
+
// lib/functions/HttpUtils.ts
|
|
221
|
+
init_cjs_shims();
|
|
222
|
+
var import_ssi_types = require("@sphereon/ssi-types");
|
|
223
|
+
var import_cross_fetch = require("cross-fetch");
|
|
224
|
+
|
|
225
225
|
// lib/types/index.ts
|
|
226
226
|
init_cjs_shims();
|
|
227
227
|
|
|
@@ -323,44 +323,6 @@ var Alg = /* @__PURE__ */ function(Alg2) {
|
|
|
323
323
|
return Alg2;
|
|
324
324
|
}({});
|
|
325
325
|
|
|
326
|
-
// lib/types/v1_0_08.types.ts
|
|
327
|
-
init_cjs_shims();
|
|
328
|
-
|
|
329
|
-
// lib/types/v1_0_09.types.ts
|
|
330
|
-
init_cjs_shims();
|
|
331
|
-
function isAuthorizationRequestV1_0_09(request) {
|
|
332
|
-
return request && "op_state" in request;
|
|
333
|
-
}
|
|
334
|
-
__name(isAuthorizationRequestV1_0_09, "isAuthorizationRequestV1_0_09");
|
|
335
|
-
|
|
336
|
-
// lib/types/v1_0_11.types.ts
|
|
337
|
-
init_cjs_shims();
|
|
338
|
-
function isAuthorizationRequestV1_0_11(request) {
|
|
339
|
-
return request && "issuer_state" in request;
|
|
340
|
-
}
|
|
341
|
-
__name(isAuthorizationRequestV1_0_11, "isAuthorizationRequestV1_0_11");
|
|
342
|
-
|
|
343
|
-
// lib/types/v1_0_13.types.ts
|
|
344
|
-
init_cjs_shims();
|
|
345
|
-
var credentialIssuerMetadataFieldNames = [
|
|
346
|
-
// Required fields
|
|
347
|
-
"credential_issuer",
|
|
348
|
-
"credential_configurations_supported",
|
|
349
|
-
"credential_endpoint",
|
|
350
|
-
// Optional fields from CredentialIssuerMetadataOpts
|
|
351
|
-
"batch_credential_endpoint",
|
|
352
|
-
"deferred_credential_endpoint",
|
|
353
|
-
"notification_endpoint",
|
|
354
|
-
"credential_response_encryption",
|
|
355
|
-
"authorization_servers",
|
|
356
|
-
"token_endpoint",
|
|
357
|
-
"display",
|
|
358
|
-
"credential_supplier_config",
|
|
359
|
-
// Optional fields from v1.0.13
|
|
360
|
-
"credential_identifiers_supported",
|
|
361
|
-
"signed_metadata"
|
|
362
|
-
];
|
|
363
|
-
|
|
364
326
|
// lib/types/v1_0_15.types.ts
|
|
365
327
|
init_cjs_shims();
|
|
366
328
|
var credentialIssuerMetadataFieldNamesV1_0_15 = [
|
|
@@ -458,11 +420,6 @@ var WRONG_METADATA_FORMAT = "Wrong metadata format";
|
|
|
458
420
|
// lib/types/OpenID4VCIVersions.types.ts
|
|
459
421
|
init_cjs_shims();
|
|
460
422
|
var OpenId4VCIVersion = /* @__PURE__ */ function(OpenId4VCIVersion2) {
|
|
461
|
-
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_08"] = 1008] = "VER_1_0_08";
|
|
462
|
-
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_09"] = 1009] = "VER_1_0_09";
|
|
463
|
-
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_11"] = 1011] = "VER_1_0_11";
|
|
464
|
-
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_12"] = 1012] = "VER_1_0_12";
|
|
465
|
-
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_13"] = 1013] = "VER_1_0_13";
|
|
466
423
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_15"] = 1015] = "VER_1_0_15";
|
|
467
424
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_UNKNOWN"] = Number.MAX_VALUE] = "VER_UNKNOWN";
|
|
468
425
|
return OpenId4VCIVersion2;
|
|
@@ -524,64 +481,7 @@ var TokenError = class _TokenError extends Error {
|
|
|
524
481
|
// lib/types/QRCode.types.ts
|
|
525
482
|
init_cjs_shims();
|
|
526
483
|
|
|
527
|
-
// lib/functions/CredentialRequestUtil.ts
|
|
528
|
-
function getTypesFromRequest(credentialRequest, format, opts) {
|
|
529
|
-
let types = [];
|
|
530
|
-
if ("credential_identifier" in credentialRequest && credentialRequest.credential_identifier) {
|
|
531
|
-
throw Error(`Cannot get types from request when it contains a credential_identifier`);
|
|
532
|
-
} else if (format === "jwt_vc_json-ld" || format === "ldp_vc" || format === "jwt_vc" || format === "jwt_vc_json") {
|
|
533
|
-
if ("credential_definition" in credentialRequest && credentialRequest.credential_definition) {
|
|
534
|
-
types = "types" in credentialRequest.credential_definition ? credentialRequest.credential_definition.types : credentialRequest.credential_definition.type;
|
|
535
|
-
}
|
|
536
|
-
if ("type" in credentialRequest && Array.isArray(credentialRequest.type)) {
|
|
537
|
-
types = credentialRequest.type;
|
|
538
|
-
}
|
|
539
|
-
if ("types" in credentialRequest && Array.isArray(credentialRequest.types)) {
|
|
540
|
-
types = credentialRequest.types;
|
|
541
|
-
}
|
|
542
|
-
} else if (format === "dc+sd-jwt" && "vct" in credentialRequest) {
|
|
543
|
-
types = [
|
|
544
|
-
credentialRequest.vct
|
|
545
|
-
];
|
|
546
|
-
} else if (format === "mso_mdoc" && "doctype" in credentialRequest) {
|
|
547
|
-
types = [
|
|
548
|
-
credentialRequest.doctype
|
|
549
|
-
];
|
|
550
|
-
}
|
|
551
|
-
if (!types || types.length === 0) {
|
|
552
|
-
throw Error("Could not deduce types from credential request");
|
|
553
|
-
}
|
|
554
|
-
if (opts?.filterVerifiableCredential) {
|
|
555
|
-
return types.filter((type) => type !== "VerifiableCredential");
|
|
556
|
-
}
|
|
557
|
-
return types;
|
|
558
|
-
}
|
|
559
|
-
__name(getTypesFromRequest, "getTypesFromRequest");
|
|
560
|
-
function getCredentialRequestForVersion(credentialRequest, format, version) {
|
|
561
|
-
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
562
|
-
const types = getTypesFromRequest(credentialRequest, format, {
|
|
563
|
-
filterVerifiableCredential: true
|
|
564
|
-
});
|
|
565
|
-
if (credentialRequest.credential_subject_issuance) {
|
|
566
|
-
throw Error("Experimental subject issuance is not supported for older versions of the spec");
|
|
567
|
-
}
|
|
568
|
-
return {
|
|
569
|
-
format,
|
|
570
|
-
proof: credentialRequest.proof,
|
|
571
|
-
type: types[0]
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
return credentialRequest;
|
|
575
|
-
}
|
|
576
|
-
__name(getCredentialRequestForVersion, "getCredentialRequestForVersion");
|
|
577
|
-
|
|
578
|
-
// lib/functions/CredentialResponseUtil.ts
|
|
579
|
-
init_cjs_shims();
|
|
580
|
-
|
|
581
484
|
// lib/functions/HttpUtils.ts
|
|
582
|
-
init_cjs_shims();
|
|
583
|
-
var import_ssi_types = require("@sphereon/ssi-types");
|
|
584
|
-
var import_cross_fetch = require("cross-fetch");
|
|
585
485
|
var logger = import_ssi_types.Loggers.DEFAULT.get("sphereon:openid4vci:http");
|
|
586
486
|
var getJson = /* @__PURE__ */ __name(async (URL1, opts) => {
|
|
587
487
|
return await openIdFetch(URL1, void 0, {
|
|
@@ -705,7 +605,7 @@ var adjustUrl = /* @__PURE__ */ __name((urlOrPath, opts) => {
|
|
|
705
605
|
// lib/functions/CredentialResponseUtil.ts
|
|
706
606
|
function isDeferredCredentialResponse(credentialResponse) {
|
|
707
607
|
const orig = credentialResponse.successBody;
|
|
708
|
-
return credentialResponse.origResponse.status % 200 <= 2 && !!orig && !orig.
|
|
608
|
+
return credentialResponse.origResponse.status % 200 <= 2 && !!orig && !orig.credentials && (!!orig.acceptance_token || !!orig.transaction_id);
|
|
709
609
|
}
|
|
710
610
|
__name(isDeferredCredentialResponse, "isDeferredCredentialResponse");
|
|
711
611
|
function assertNonFatalError(credentialResponse) {
|
|
@@ -743,12 +643,12 @@ async function acquireDeferredCredential({ bearerToken, transactionId, deferredC
|
|
|
743
643
|
deferredCredentialEndpoint
|
|
744
644
|
});
|
|
745
645
|
const DEFAULT_SLEEP_IN_MS = 5e3;
|
|
746
|
-
while (!credentialResponse.successBody?.
|
|
646
|
+
while (!credentialResponse.successBody?.credentials && deferredCredentialAwait) {
|
|
747
647
|
assertNonFatalError(credentialResponse);
|
|
748
648
|
const pending = isDeferredCredentialIssuancePending(credentialResponse);
|
|
749
649
|
console.log(`Issuance still pending?: ${pending}`);
|
|
750
650
|
if (!pending) {
|
|
751
|
-
|
|
651
|
+
return Promise.reject(Error(`Issuance isn't pending anymore: ${credentialResponse}`));
|
|
752
652
|
}
|
|
753
653
|
await sleep(deferredCredentialIntervalInMS ?? DEFAULT_SLEEP_IN_MS);
|
|
754
654
|
credentialResponse = await acquireDeferredCredentialImpl({
|
|
@@ -783,32 +683,6 @@ var import_oid4vc_common = require("@sphereon/oid4vc-common");
|
|
|
783
683
|
var logger2 = import_ssi_types2.Loggers.DEFAULT.get("sphereon:oid4vci:offer");
|
|
784
684
|
function determineSpecVersionFromURI(uri) {
|
|
785
685
|
let version = determineSpecVersionFromScheme(uri, OpenId4VCIVersion.VER_UNKNOWN) ?? OpenId4VCIVersion.VER_UNKNOWN;
|
|
786
|
-
version = getVersionFromURIParam(uri, version, [
|
|
787
|
-
OpenId4VCIVersion.VER_1_0_08
|
|
788
|
-
], "initiate_issuance");
|
|
789
|
-
version = getVersionFromURIParam(uri, version, [
|
|
790
|
-
OpenId4VCIVersion.VER_1_0_08
|
|
791
|
-
], "credential_type");
|
|
792
|
-
version = getVersionFromURIParam(uri, version, [
|
|
793
|
-
OpenId4VCIVersion.VER_1_0_08
|
|
794
|
-
], "op_state");
|
|
795
|
-
version = getVersionFromURIParam(uri, version, [
|
|
796
|
-
OpenId4VCIVersion.VER_1_0_11
|
|
797
|
-
], "credentials");
|
|
798
|
-
version = getVersionFromURIParam(uri, version, [
|
|
799
|
-
OpenId4VCIVersion.VER_1_0_11
|
|
800
|
-
], "grants.user_pin_required");
|
|
801
|
-
version = getVersionFromURIParam(uri, version, [
|
|
802
|
-
OpenId4VCIVersion.VER_1_0_13,
|
|
803
|
-
OpenId4VCIVersion.VER_1_0_15
|
|
804
|
-
], "credential_configuration_ids");
|
|
805
|
-
version = getVersionFromURIParam(uri, version, [
|
|
806
|
-
OpenId4VCIVersion.VER_1_0_13,
|
|
807
|
-
OpenId4VCIVersion.VER_1_0_15
|
|
808
|
-
], "tx_code");
|
|
809
|
-
version = getVersionFromURIParam(uri, version, [
|
|
810
|
-
OpenId4VCIVersion.VER_1_0_15
|
|
811
|
-
], "credential_offer_uri ");
|
|
812
686
|
if (version === OpenId4VCIVersion.VER_UNKNOWN) {
|
|
813
687
|
version = OpenId4VCIVersion.VER_1_0_15;
|
|
814
688
|
}
|
|
@@ -825,11 +699,6 @@ function determineSpecVersionFromScheme(credentialOfferURI, openId4VCIVersion) {
|
|
|
825
699
|
OpenId4VCIVersion.VER_1_0_15
|
|
826
700
|
], scheme);
|
|
827
701
|
}
|
|
828
|
-
if (qp.has("credential_type") || qp.has("issuer")) {
|
|
829
|
-
return recordVersion(openId4VCIVersion, [
|
|
830
|
-
OpenId4VCIVersion.VER_1_0_08
|
|
831
|
-
], scheme);
|
|
832
|
-
}
|
|
833
702
|
return recordVersion(openId4VCIVersion, [
|
|
834
703
|
OpenId4VCIVersion.VER_UNKNOWN
|
|
835
704
|
], scheme);
|
|
@@ -888,8 +757,6 @@ function tryDecodeOffer(input) {
|
|
|
888
757
|
__name(tryDecodeOffer, "tryDecodeOffer");
|
|
889
758
|
function sniffOfferVersion(jsonLike) {
|
|
890
759
|
if (!jsonLike) return OpenId4VCIVersion.VER_UNKNOWN;
|
|
891
|
-
const has = /* @__PURE__ */ __name((k) => new RegExp(`"${k}"\\s*:`, "i").test(jsonLike), "has");
|
|
892
|
-
if (has("credentials")) return OpenId4VCIVersion.VER_1_0_11;
|
|
893
760
|
return OpenId4VCIVersion.VER_UNKNOWN;
|
|
894
761
|
}
|
|
895
762
|
__name(sniffOfferVersion, "sniffOfferVersion");
|
|
@@ -950,14 +817,6 @@ var getStateFromCredentialOfferPayload = /* @__PURE__ */ __name((credentialOffer
|
|
|
950
817
|
function determineSpecVersionFromOffer(offer) {
|
|
951
818
|
if (isCredentialOfferV1_0_15(offer)) {
|
|
952
819
|
return OpenId4VCIVersion.VER_1_0_15;
|
|
953
|
-
} else if (isCredentialOfferV1_0_13(offer)) {
|
|
954
|
-
return OpenId4VCIVersion.VER_1_0_13;
|
|
955
|
-
} else if (isCredentialOfferV1_0_11(offer)) {
|
|
956
|
-
return OpenId4VCIVersion.VER_1_0_11;
|
|
957
|
-
} else if (isCredentialOfferV1_0_09(offer)) {
|
|
958
|
-
return OpenId4VCIVersion.VER_1_0_09;
|
|
959
|
-
} else if (isCredentialOfferV1_0_08(offer)) {
|
|
960
|
-
return OpenId4VCIVersion.VER_1_0_08;
|
|
961
820
|
}
|
|
962
821
|
return OpenId4VCIVersion.VER_UNKNOWN;
|
|
963
822
|
}
|
|
@@ -977,60 +836,6 @@ function isCredentialOfferVersion(offer, min, max) {
|
|
|
977
836
|
return true;
|
|
978
837
|
}
|
|
979
838
|
__name(isCredentialOfferVersion, "isCredentialOfferVersion");
|
|
980
|
-
function isCredentialOfferV1_0_08(offer) {
|
|
981
|
-
if (!offer) {
|
|
982
|
-
return false;
|
|
983
|
-
}
|
|
984
|
-
if ("issuer" in offer && "credential_type" in offer) {
|
|
985
|
-
return true;
|
|
986
|
-
}
|
|
987
|
-
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
988
|
-
return isCredentialOfferV1_0_08(offer["credential_offer"]);
|
|
989
|
-
}
|
|
990
|
-
return false;
|
|
991
|
-
}
|
|
992
|
-
__name(isCredentialOfferV1_0_08, "isCredentialOfferV1_0_08");
|
|
993
|
-
function isCredentialOfferV1_0_09(offer) {
|
|
994
|
-
if (!offer) {
|
|
995
|
-
return false;
|
|
996
|
-
}
|
|
997
|
-
if ("issuer" in offer && "credentials" in offer) {
|
|
998
|
-
return true;
|
|
999
|
-
}
|
|
1000
|
-
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1001
|
-
return isCredentialOfferV1_0_09(offer["credential_offer"]);
|
|
1002
|
-
}
|
|
1003
|
-
return false;
|
|
1004
|
-
}
|
|
1005
|
-
__name(isCredentialOfferV1_0_09, "isCredentialOfferV1_0_09");
|
|
1006
|
-
function isCredentialOfferV1_0_11(offer) {
|
|
1007
|
-
if (!offer) {
|
|
1008
|
-
return false;
|
|
1009
|
-
}
|
|
1010
|
-
if ("credential_issuer" in offer && "credentials" in offer) {
|
|
1011
|
-
return true;
|
|
1012
|
-
}
|
|
1013
|
-
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1014
|
-
return isCredentialOfferV1_0_11(offer["credential_offer"]);
|
|
1015
|
-
}
|
|
1016
|
-
return "credential_offer_uri" in offer;
|
|
1017
|
-
}
|
|
1018
|
-
__name(isCredentialOfferV1_0_11, "isCredentialOfferV1_0_11");
|
|
1019
|
-
function isCredentialOfferV1_0_13(offer) {
|
|
1020
|
-
if (!offer) {
|
|
1021
|
-
return false;
|
|
1022
|
-
} else if (typeof offer === "string" && offer.startsWith("{")) {
|
|
1023
|
-
offer = JSON.parse(offer);
|
|
1024
|
-
}
|
|
1025
|
-
if ("credential_issuer" in offer && "credential_configuration_ids" in offer) {
|
|
1026
|
-
return true;
|
|
1027
|
-
}
|
|
1028
|
-
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1029
|
-
return isCredentialOfferV1_0_13(offer["credential_offer"]);
|
|
1030
|
-
}
|
|
1031
|
-
return "credential_offer_uri" in offer;
|
|
1032
|
-
}
|
|
1033
|
-
__name(isCredentialOfferV1_0_13, "isCredentialOfferV1_0_13");
|
|
1034
839
|
function isCredentialOfferV1_0_15(offer) {
|
|
1035
840
|
if (!offer) {
|
|
1036
841
|
return false;
|
|
@@ -1117,54 +922,12 @@ __name(resolveCredentialOfferURI, "resolveCredentialOfferURI");
|
|
|
1117
922
|
function toUniformCredentialOfferPayload(rawOffer, opts) {
|
|
1118
923
|
const offer = normalizeOfferInput(rawOffer);
|
|
1119
924
|
const version = opts?.version ?? determineSpecVersionFromOffer(offer);
|
|
1120
|
-
if (version >= OpenId4VCIVersion.
|
|
925
|
+
if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1121
926
|
const orig = offer;
|
|
1122
927
|
return {
|
|
1123
928
|
...orig
|
|
1124
929
|
};
|
|
1125
930
|
}
|
|
1126
|
-
const grants = "grants" in offer ? offer.grants : {};
|
|
1127
|
-
let offerPayloadAsV8V9 = offer;
|
|
1128
|
-
if (isCredentialOfferVersion(offer, OpenId4VCIVersion.VER_1_0_08, OpenId4VCIVersion.VER_1_0_09)) {
|
|
1129
|
-
if (offerPayloadAsV8V9.op_state) {
|
|
1130
|
-
grants.authorization_code = {
|
|
1131
|
-
...grants.authorization_code,
|
|
1132
|
-
issuer_state: offerPayloadAsV8V9.op_state
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
let user_pin_required = false;
|
|
1136
|
-
if (typeof offerPayloadAsV8V9.user_pin_required === "string") {
|
|
1137
|
-
user_pin_required = offerPayloadAsV8V9.user_pin_required === "true" || offerPayloadAsV8V9.user_pin_required === "yes";
|
|
1138
|
-
} else if (offerPayloadAsV8V9.user_pin_required !== void 0) {
|
|
1139
|
-
user_pin_required = offerPayloadAsV8V9.user_pin_required;
|
|
1140
|
-
}
|
|
1141
|
-
if (offerPayloadAsV8V9[PRE_AUTH_CODE_LITERAL]) {
|
|
1142
|
-
grants[PRE_AUTH_GRANT_LITERAL] = {
|
|
1143
|
-
"pre-authorized_code": offerPayloadAsV8V9[PRE_AUTH_CODE_LITERAL],
|
|
1144
|
-
user_pin_required
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
const issuer = getIssuerFromCredentialOfferPayload(offer);
|
|
1149
|
-
if (version === OpenId4VCIVersion.VER_1_0_09) {
|
|
1150
|
-
offerPayloadAsV8V9 = offer;
|
|
1151
|
-
return {
|
|
1152
|
-
// credential_definition: getCredentialsSupported(never, offerPayloadAsV8V9.credentials).map(sup => {credentialSubject: sup.credentialSubject})[0],
|
|
1153
|
-
credential_issuer: issuer ?? offerPayloadAsV8V9.issuer,
|
|
1154
|
-
credentials: offerPayloadAsV8V9.credentials,
|
|
1155
|
-
grants
|
|
1156
|
-
};
|
|
1157
|
-
}
|
|
1158
|
-
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
1159
|
-
offerPayloadAsV8V9 = offer;
|
|
1160
|
-
return {
|
|
1161
|
-
credential_issuer: issuer ?? offerPayloadAsV8V9.issuer,
|
|
1162
|
-
credentials: Array.isArray(offerPayloadAsV8V9.credential_type) ? offerPayloadAsV8V9.credential_type : [
|
|
1163
|
-
offerPayloadAsV8V9.credential_type
|
|
1164
|
-
],
|
|
1165
|
-
grants
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
931
|
throw Error(`Could not create uniform payload for version ${version}`);
|
|
1169
932
|
}
|
|
1170
933
|
__name(toUniformCredentialOfferPayload, "toUniformCredentialOfferPayload");
|
|
@@ -1177,9 +940,6 @@ function determineFlowType(suppliedOffer, version) {
|
|
|
1177
940
|
if (payload.grants?.[PRE_AUTH_GRANT_LITERAL]?.[PRE_AUTH_CODE_LITERAL]) {
|
|
1178
941
|
supportedFlows.push(AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW);
|
|
1179
942
|
}
|
|
1180
|
-
if (supportedFlows.length === 0 && version < OpenId4VCIVersion.VER_1_0_09) {
|
|
1181
|
-
supportedFlows.push(AuthzFlowType.AUTHORIZATION_CODE_FLOW);
|
|
1182
|
-
}
|
|
1183
943
|
return supportedFlows;
|
|
1184
944
|
}
|
|
1185
945
|
__name(determineFlowType, "determineFlowType");
|
|
@@ -1214,13 +974,6 @@ function determineGrantTypes(offer) {
|
|
|
1214
974
|
return types;
|
|
1215
975
|
}
|
|
1216
976
|
__name(determineGrantTypes, "determineGrantTypes");
|
|
1217
|
-
function getVersionFromURIParam(credentialOfferURI, currentVersion, matchingVersion, param, allowUpgrade = true) {
|
|
1218
|
-
if (credentialOfferURI.includes(param)) {
|
|
1219
|
-
return recordVersion(currentVersion, matchingVersion, param, allowUpgrade);
|
|
1220
|
-
}
|
|
1221
|
-
return currentVersion;
|
|
1222
|
-
}
|
|
1223
|
-
__name(getVersionFromURIParam, "getVersionFromURIParam");
|
|
1224
977
|
function recordVersion(currentVersion, matchingVersion, key, allowUpgrade = true) {
|
|
1225
978
|
matchingVersion = matchingVersion.sort().reverse();
|
|
1226
979
|
if (currentVersion === OpenId4VCIVersion.VER_UNKNOWN) {
|
|
@@ -1234,40 +987,6 @@ function recordVersion(currentVersion, matchingVersion, key, allowUpgrade = true
|
|
|
1234
987
|
throw new Error(`Invalid param. Some keys have been used from version: ${currentVersion} version while '${key}' is used from version: ${JSON.stringify(matchingVersion)}`);
|
|
1235
988
|
}
|
|
1236
989
|
__name(recordVersion, "recordVersion");
|
|
1237
|
-
function getTypesFromOfferV1_0_11(credentialOffer, opts) {
|
|
1238
|
-
const types = credentialOffer.credentials.reduce((prev, curr) => {
|
|
1239
|
-
if (typeof curr === "string") {
|
|
1240
|
-
return [
|
|
1241
|
-
...prev,
|
|
1242
|
-
curr
|
|
1243
|
-
];
|
|
1244
|
-
} else if (curr.format === "jwt_vc_json-ld" || curr.format === "ldp_vc") {
|
|
1245
|
-
return [
|
|
1246
|
-
...prev,
|
|
1247
|
-
...curr.credential_definition.types
|
|
1248
|
-
];
|
|
1249
|
-
} else if (curr.format === "jwt_vc_json" || curr.format === "jwt_vc") {
|
|
1250
|
-
return [
|
|
1251
|
-
...prev,
|
|
1252
|
-
...curr.types
|
|
1253
|
-
];
|
|
1254
|
-
} else if (curr.format === "vc+sd-jwt") {
|
|
1255
|
-
return [
|
|
1256
|
-
...prev,
|
|
1257
|
-
curr.vct
|
|
1258
|
-
];
|
|
1259
|
-
}
|
|
1260
|
-
return prev;
|
|
1261
|
-
}, []);
|
|
1262
|
-
if (!types || types.length === 0) {
|
|
1263
|
-
throw Error("Could not deduce types from credential offer");
|
|
1264
|
-
}
|
|
1265
|
-
if (opts?.filterVerifiableCredential) {
|
|
1266
|
-
return types.filter((type) => type !== "VerifiableCredential");
|
|
1267
|
-
}
|
|
1268
|
-
return types;
|
|
1269
|
-
}
|
|
1270
|
-
__name(getTypesFromOfferV1_0_11, "getTypesFromOfferV1_0_11");
|
|
1271
990
|
function getCredentialConfigurationIdsFromOfferV1_0_15(offer) {
|
|
1272
991
|
return offer.credential_configuration_ids ?? [];
|
|
1273
992
|
}
|
|
@@ -1300,7 +1019,7 @@ function convertJsonToURI(json, opts) {
|
|
|
1300
1019
|
}
|
|
1301
1020
|
__name(encodeAndStripWhitespace, "encodeAndStripWhitespace");
|
|
1302
1021
|
let components;
|
|
1303
|
-
if (opts?.
|
|
1022
|
+
if (opts?.mode === JsonURIMode.JSON_STRINGIFY) {
|
|
1304
1023
|
components = encodeAndStripWhitespace(JSON.stringify(json));
|
|
1305
1024
|
} else {
|
|
1306
1025
|
for (const [key, value] of Object.entries(json)) {
|
|
@@ -1510,7 +1229,7 @@ function getTypesFromCredentialSupported(credentialSupported, opts) {
|
|
|
1510
1229
|
let types = [];
|
|
1511
1230
|
if (credentialSupported.format === "jwt_vc_json" || credentialSupported.format === "jwt_vc" || credentialSupported.format === "jwt_vc_json-ld" || credentialSupported.format === "ldp_vc") {
|
|
1512
1231
|
types = getTypesFromObject(credentialSupported) ?? [];
|
|
1513
|
-
} else if (credentialSupported.format === "dc+sd-jwt"
|
|
1232
|
+
} else if (credentialSupported.format === "dc+sd-jwt") {
|
|
1514
1233
|
types = [
|
|
1515
1234
|
credentialSupported.vct
|
|
1516
1235
|
];
|
|
@@ -1534,24 +1253,16 @@ init_cjs_shims();
|
|
|
1534
1253
|
function getSupportedCredentials(opts) {
|
|
1535
1254
|
const { version = OpenId4VCIVersion.VER_1_0_15, types } = opts ?? {};
|
|
1536
1255
|
if (types && Array.isArray(types)) {
|
|
1537
|
-
|
|
1538
|
-
return
|
|
1256
|
+
return types.map((typeSet) => {
|
|
1257
|
+
return getSupportedCredential({
|
|
1539
1258
|
...opts,
|
|
1540
1259
|
version,
|
|
1541
1260
|
types: typeSet
|
|
1542
|
-
})
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
version,
|
|
1548
|
-
types: typeSet
|
|
1549
|
-
});
|
|
1550
|
-
}).reduce((acc, result) => {
|
|
1551
|
-
Object.assign(acc, result);
|
|
1552
|
-
return acc;
|
|
1553
|
-
}, {});
|
|
1554
|
-
}
|
|
1261
|
+
});
|
|
1262
|
+
}).reduce((acc, result) => {
|
|
1263
|
+
Object.assign(acc, result);
|
|
1264
|
+
return acc;
|
|
1265
|
+
}, {});
|
|
1555
1266
|
}
|
|
1556
1267
|
return getSupportedCredential(opts ? {
|
|
1557
1268
|
...opts,
|
|
@@ -1563,21 +1274,6 @@ function determineVersionsFromIssuerMetadata(issuerMetadata) {
|
|
|
1563
1274
|
const versions = /* @__PURE__ */ new Set();
|
|
1564
1275
|
if ("credential_configurations_supported" in issuerMetadata) {
|
|
1565
1276
|
versions.add(OpenId4VCIVersion.VER_1_0_15);
|
|
1566
|
-
} else if ("authorization_server" in issuerMetadata) {
|
|
1567
|
-
versions.add(OpenId4VCIVersion.VER_1_0_11);
|
|
1568
|
-
} else if ("authorization_servers" in issuerMetadata) {
|
|
1569
|
-
versions.add(OpenId4VCIVersion.VER_1_0_13);
|
|
1570
|
-
}
|
|
1571
|
-
if (versions.size === 0) {
|
|
1572
|
-
if ("credential_configurations_supported" in issuerMetadata) {
|
|
1573
|
-
versions.add(OpenId4VCIVersion.VER_1_0_13);
|
|
1574
|
-
} else if ("credentials_supported" in issuerMetadata) {
|
|
1575
|
-
if (typeof issuerMetadata.credentials_supported === "object") {
|
|
1576
|
-
versions.add(OpenId4VCIVersion.VER_1_0_08);
|
|
1577
|
-
} else {
|
|
1578
|
-
versions.add(OpenId4VCIVersion.VER_1_0_09).add(OpenId4VCIVersion.VER_1_0_11);
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
1277
|
}
|
|
1582
1278
|
if (versions.size === 0) {
|
|
1583
1279
|
versions.add(OpenId4VCIVersion.VER_UNKNOWN);
|
|
@@ -1587,36 +1283,16 @@ function determineVersionsFromIssuerMetadata(issuerMetadata) {
|
|
|
1587
1283
|
__name(determineVersionsFromIssuerMetadata, "determineVersionsFromIssuerMetadata");
|
|
1588
1284
|
function getSupportedCredential(opts) {
|
|
1589
1285
|
const { issuerMetadata, types, format, version = OpenId4VCIVersion.VER_1_0_15 } = opts ?? {};
|
|
1590
|
-
let credentialConfigurationsV11 = void 0;
|
|
1591
|
-
let credentialConfigurationsV13 = void 0;
|
|
1592
1286
|
let credentialConfigurationsV15 = void 0;
|
|
1593
|
-
if (
|
|
1594
|
-
|
|
1595
|
-
credentialConfigurationsV11 = [];
|
|
1596
|
-
Object.entries(issuerMetadata.credentials_supported).forEach(([id, supported]) => {
|
|
1597
|
-
if (!supported.id) {
|
|
1598
|
-
supported.id = id;
|
|
1599
|
-
}
|
|
1600
|
-
credentialConfigurationsV11?.push(supported);
|
|
1601
|
-
});
|
|
1602
|
-
} else if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1603
|
-
credentialConfigurationsV15 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1604
|
-
} else {
|
|
1605
|
-
credentialConfigurationsV11 = issuerMetadata?.credentials_supported ?? [];
|
|
1606
|
-
}
|
|
1607
|
-
} else if (version == OpenId4VCIVersion.VER_1_0_13) {
|
|
1608
|
-
credentialConfigurationsV13 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1609
|
-
} else {
|
|
1610
|
-
credentialConfigurationsV15 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1287
|
+
if (issuerMetadata?.credential_configurations_supported && version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1288
|
+
credentialConfigurationsV15 = issuerMetadata.credential_configurations_supported;
|
|
1611
1289
|
}
|
|
1612
1290
|
if (!issuerMetadata || !issuerMetadata.credential_configurations_supported && !issuerMetadata.credentials_supported) {
|
|
1613
|
-
VCI_LOG_COMMON.warning(`No credential issuer metadata or supported credentials found for issuer
|
|
1614
|
-
if (version
|
|
1615
|
-
return
|
|
1616
|
-
} else if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1617
|
-
return credentialConfigurationsV15;
|
|
1291
|
+
VCI_LOG_COMMON.warning(`No credential issuer metadata or supported credentials found for issuer`);
|
|
1292
|
+
if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1293
|
+
return credentialConfigurationsV15 ?? {};
|
|
1618
1294
|
} else {
|
|
1619
|
-
return
|
|
1295
|
+
return [];
|
|
1620
1296
|
}
|
|
1621
1297
|
}
|
|
1622
1298
|
const normalizedTypes = Array.isArray(types) ? types : types ? [
|
|
@@ -1634,7 +1310,7 @@ function getSupportedCredential(opts) {
|
|
|
1634
1310
|
} else if (types2) {
|
|
1635
1311
|
isTypeMatch = normalizedTypes.every((type) => types2.includes(type));
|
|
1636
1312
|
} else {
|
|
1637
|
-
const hasValidCredentialDefinition = isW3cCredentialSupported(config) && "credential_definition" in config && config.credential_definition && typeof config.credential_definition === "object" &&
|
|
1313
|
+
const hasValidCredentialDefinition = isW3cCredentialSupported(config) && "credential_definition" in config && config.credential_definition && typeof config.credential_definition === "object" && "type" in config.credential_definition && Array.isArray(config.credential_definition.type);
|
|
1638
1314
|
if (hasValidCredentialDefinition) {
|
|
1639
1315
|
const credDef = config.credential_definition;
|
|
1640
1316
|
isTypeMatch = normalizedTypes.every((type) => credDef.type.includes(type));
|
|
@@ -1659,51 +1335,13 @@ function getSupportedCredential(opts) {
|
|
|
1659
1335
|
}
|
|
1660
1336
|
return filteredConfigs;
|
|
1661
1337
|
}, {});
|
|
1662
|
-
} else if (credentialConfigurationsV13) {
|
|
1663
|
-
return Object.entries(credentialConfigurationsV13).reduce((filteredConfigs, [id, config]) => {
|
|
1664
|
-
if (filterMatchingConfig(config)) {
|
|
1665
|
-
filteredConfigs[id] = config;
|
|
1666
|
-
if (!config.id) {
|
|
1667
|
-
config.id = id;
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
return filteredConfigs;
|
|
1671
|
-
}, {});
|
|
1672
|
-
} else if (credentialConfigurationsV11) {
|
|
1673
|
-
return credentialConfigurationsV11.filter((config) => filterMatchingConfig(config));
|
|
1674
1338
|
}
|
|
1675
|
-
|
|
1339
|
+
if (issuerMetadata.credentials_supported && Array.isArray(issuerMetadata.credentials_supported)) {
|
|
1340
|
+
return issuerMetadata.credentials_supported.filter(filterMatchingConfig);
|
|
1341
|
+
}
|
|
1342
|
+
return version >= OpenId4VCIVersion.VER_1_0_15 ? {} : [];
|
|
1676
1343
|
}
|
|
1677
1344
|
__name(getSupportedCredential, "getSupportedCredential");
|
|
1678
|
-
function credentialsSupportedV8ToV13(supportedV8) {
|
|
1679
|
-
const credentialConfigsSupported = {};
|
|
1680
|
-
Object.entries(supportedV8).flatMap((entry) => {
|
|
1681
|
-
const type = entry[0];
|
|
1682
|
-
const supportedV82 = entry[1];
|
|
1683
|
-
Object.assign(credentialConfigsSupported, credentialSupportedV8ToV13(type, supportedV82));
|
|
1684
|
-
});
|
|
1685
|
-
return credentialConfigsSupported;
|
|
1686
|
-
}
|
|
1687
|
-
__name(credentialsSupportedV8ToV13, "credentialsSupportedV8ToV13");
|
|
1688
|
-
function credentialSupportedV8ToV13(key, supportedV8) {
|
|
1689
|
-
const credentialConfigsSupported = {};
|
|
1690
|
-
Object.entries(supportedV8.formats).map((entry) => {
|
|
1691
|
-
const format = entry[0];
|
|
1692
|
-
const credentialSupportBrief = entry[1];
|
|
1693
|
-
if (typeof format !== "string") {
|
|
1694
|
-
throw Error(`Unknown format received ${JSON.stringify(format)}`);
|
|
1695
|
-
}
|
|
1696
|
-
const credentialConfigSupported = {
|
|
1697
|
-
format,
|
|
1698
|
-
display: supportedV8.display,
|
|
1699
|
-
...credentialSupportBrief,
|
|
1700
|
-
credentialSubject: supportedV8.claims
|
|
1701
|
-
};
|
|
1702
|
-
credentialConfigsSupported[key] = credentialConfigSupported;
|
|
1703
|
-
});
|
|
1704
|
-
return credentialConfigsSupported;
|
|
1705
|
-
}
|
|
1706
|
-
__name(credentialSupportedV8ToV13, "credentialSupportedV8ToV13");
|
|
1707
1345
|
function getIssuerDisplays(metadata, opts) {
|
|
1708
1346
|
const matchedDisplays = metadata.display?.filter((item) => !opts?.prefLocales || opts.prefLocales.length === 0 || item.locale && opts.prefLocales.includes(item.locale) || !item.locale) ?? [];
|
|
1709
1347
|
return matchedDisplays.sort((item) => item.locale ? opts?.prefLocales.indexOf(item.locale) ?? 1 : Number.MAX_VALUE);
|
|
@@ -1756,13 +1394,6 @@ function getUniformFormat(format) {
|
|
|
1756
1394
|
__name(getUniformFormat, "getUniformFormat");
|
|
1757
1395
|
function getFormatForVersion(format, version) {
|
|
1758
1396
|
const uniformFormat = isUniformFormat(format) ? format : getUniformFormat(format);
|
|
1759
|
-
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
1760
|
-
if (uniformFormat === "jwt_vc_json") {
|
|
1761
|
-
return "jwt_vc";
|
|
1762
|
-
} else if (uniformFormat === "ldp_vc" || uniformFormat === "jwt_vc_json-ld") {
|
|
1763
|
-
return "ldp_vc";
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
1397
|
return uniformFormat;
|
|
1767
1398
|
}
|
|
1768
1399
|
__name(getFormatForVersion, "getFormatForVersion");
|