@sphereon/oid4vci-common 0.19.0 → 0.19.1-feature.SSISDK.13.18
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 +230 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +291 -18
- package/dist/index.d.ts +291 -18
- package/dist/index.js +227 -74
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -152,6 +152,7 @@ __export(index_exports, {
|
|
|
152
152
|
createCodeChallenge: () => createCodeChallenge,
|
|
153
153
|
createProofOfPossession: () => createProofOfPossession,
|
|
154
154
|
credentialIssuerMetadataFieldNames: () => credentialIssuerMetadataFieldNames,
|
|
155
|
+
credentialIssuerMetadataFieldNamesV1_0_15: () => credentialIssuerMetadataFieldNamesV1_0_15,
|
|
155
156
|
credentialSupportedV8ToV13: () => credentialSupportedV8ToV13,
|
|
156
157
|
credentialsSupportedV8ToV13: () => credentialsSupportedV8ToV13,
|
|
157
158
|
decodeJsonProperties: () => decodeJsonProperties,
|
|
@@ -167,6 +168,7 @@ __export(index_exports, {
|
|
|
167
168
|
generateNonce: () => generateNonce,
|
|
168
169
|
generateRandomString: () => generateRandomString,
|
|
169
170
|
getClientIdFromCredentialOfferPayload: () => getClientIdFromCredentialOfferPayload,
|
|
171
|
+
getCredentialConfigurationIdsFromOfferV1_0_15: () => getCredentialConfigurationIdsFromOfferV1_0_15,
|
|
170
172
|
getCredentialOfferPayload: () => getCredentialOfferPayload,
|
|
171
173
|
getCredentialRequestForVersion: () => getCredentialRequestForVersion,
|
|
172
174
|
getFormatForVersion: () => getFormatForVersion,
|
|
@@ -198,8 +200,10 @@ __export(index_exports, {
|
|
|
198
200
|
isPreAuthCode: () => isPreAuthCode,
|
|
199
201
|
isValidURL: () => isValidURL,
|
|
200
202
|
isW3cCredentialSupported: () => isW3cCredentialSupported,
|
|
203
|
+
normalizeOfferInput: () => normalizeOfferInput,
|
|
201
204
|
post: () => post,
|
|
202
205
|
resolveCredentialOfferURI: () => resolveCredentialOfferURI,
|
|
206
|
+
supportedOID4VCICredentialFormat: () => supportedOID4VCICredentialFormat,
|
|
203
207
|
toAuthorizationResponsePayload: () => toAuthorizationResponsePayload,
|
|
204
208
|
toUniformCredentialOfferPayload: () => toUniformCredentialOfferPayload,
|
|
205
209
|
toUniformCredentialOfferRequest: () => toUniformCredentialOfferRequest,
|
|
@@ -229,6 +233,15 @@ init_cjs_shims();
|
|
|
229
233
|
|
|
230
234
|
// lib/types/Generic.types.ts
|
|
231
235
|
init_cjs_shims();
|
|
236
|
+
var supportedOID4VCICredentialFormat = [
|
|
237
|
+
"jwt_vc_json",
|
|
238
|
+
"jwt_vc_json-ld",
|
|
239
|
+
"ldp_vc",
|
|
240
|
+
"dc+sd-jwt",
|
|
241
|
+
"vc+sd-jwt",
|
|
242
|
+
"jwt_vc",
|
|
243
|
+
"mso_mdoc"
|
|
244
|
+
];
|
|
232
245
|
var PRE_AUTH_CODE_LITERAL = "pre-authorized_code";
|
|
233
246
|
var PRE_AUTH_GRANT_LITERAL = "urn:ietf:params:oauth:grant-type:pre-authorized_code";
|
|
234
247
|
|
|
@@ -349,6 +362,26 @@ var credentialIssuerMetadataFieldNames = [
|
|
|
349
362
|
"signed_metadata"
|
|
350
363
|
];
|
|
351
364
|
|
|
365
|
+
// lib/types/v1_0_15.types.ts
|
|
366
|
+
init_cjs_shims();
|
|
367
|
+
var credentialIssuerMetadataFieldNamesV1_0_15 = [
|
|
368
|
+
"credential_issuer",
|
|
369
|
+
"credential_configurations_supported",
|
|
370
|
+
"credential_endpoint",
|
|
371
|
+
"nonce_endpoint",
|
|
372
|
+
"deferred_credential_endpoint",
|
|
373
|
+
"notification_endpoint",
|
|
374
|
+
"credential_response_encryption",
|
|
375
|
+
"batch_credential_issuance",
|
|
376
|
+
"authorization_servers",
|
|
377
|
+
"token_endpoint",
|
|
378
|
+
"display",
|
|
379
|
+
"credential_supplier_config",
|
|
380
|
+
"credential_identifiers_supported",
|
|
381
|
+
"signed_metadata",
|
|
382
|
+
"authorization_challenge_endpoint"
|
|
383
|
+
];
|
|
384
|
+
|
|
352
385
|
// lib/types/ServerMetadata.ts
|
|
353
386
|
init_cjs_shims();
|
|
354
387
|
var authorizationServerMetadataFieldNames = [
|
|
@@ -431,6 +464,7 @@ var OpenId4VCIVersion = /* @__PURE__ */ function(OpenId4VCIVersion2) {
|
|
|
431
464
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_11"] = 1011] = "VER_1_0_11";
|
|
432
465
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_12"] = 1012] = "VER_1_0_12";
|
|
433
466
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_13"] = 1013] = "VER_1_0_13";
|
|
467
|
+
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_15"] = 1015] = "VER_1_0_15";
|
|
434
468
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_UNKNOWN"] = Number.MAX_VALUE] = "VER_UNKNOWN";
|
|
435
469
|
return OpenId4VCIVersion2;
|
|
436
470
|
}({});
|
|
@@ -491,57 +525,12 @@ var TokenError = class _TokenError extends Error {
|
|
|
491
525
|
// lib/types/QRCode.types.ts
|
|
492
526
|
init_cjs_shims();
|
|
493
527
|
|
|
494
|
-
// lib/functions/FormatUtils.ts
|
|
495
|
-
init_cjs_shims();
|
|
496
|
-
function isFormat(formatObject, format) {
|
|
497
|
-
return formatObject.format === format;
|
|
498
|
-
}
|
|
499
|
-
__name(isFormat, "isFormat");
|
|
500
|
-
function isNotFormat(formatObject, format) {
|
|
501
|
-
return formatObject.format !== format;
|
|
502
|
-
}
|
|
503
|
-
__name(isNotFormat, "isNotFormat");
|
|
504
|
-
var isUniformFormat = /* @__PURE__ */ __name((format) => {
|
|
505
|
-
return [
|
|
506
|
-
"jwt_vc_json",
|
|
507
|
-
"jwt_vc_json-ld",
|
|
508
|
-
"ldp_vc",
|
|
509
|
-
"vc+sd-jwt",
|
|
510
|
-
"mso_mdoc"
|
|
511
|
-
].includes(format);
|
|
512
|
-
}, "isUniformFormat");
|
|
513
|
-
function getUniformFormat(format) {
|
|
514
|
-
if (isUniformFormat(format)) {
|
|
515
|
-
return format;
|
|
516
|
-
}
|
|
517
|
-
if (format.toLocaleLowerCase() === "jwt_vc" || format.toLocaleLowerCase() === "jwt") {
|
|
518
|
-
return "jwt_vc";
|
|
519
|
-
}
|
|
520
|
-
if (format === "ldp_vc" || format === "ldp") {
|
|
521
|
-
return "ldp_vc";
|
|
522
|
-
}
|
|
523
|
-
throw new Error(`Invalid format: ${format}`);
|
|
524
|
-
}
|
|
525
|
-
__name(getUniformFormat, "getUniformFormat");
|
|
526
|
-
function getFormatForVersion(format, version) {
|
|
527
|
-
const uniformFormat = isUniformFormat(format) ? format : getUniformFormat(format);
|
|
528
|
-
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
529
|
-
if (uniformFormat === "jwt_vc_json") {
|
|
530
|
-
return "jwt_vc";
|
|
531
|
-
} else if (uniformFormat === "ldp_vc" || uniformFormat === "jwt_vc_json-ld") {
|
|
532
|
-
return "ldp_vc";
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
return uniformFormat;
|
|
536
|
-
}
|
|
537
|
-
__name(getFormatForVersion, "getFormatForVersion");
|
|
538
|
-
|
|
539
528
|
// lib/functions/CredentialRequestUtil.ts
|
|
540
|
-
function getTypesFromRequest(credentialRequest, opts) {
|
|
529
|
+
function getTypesFromRequest(credentialRequest, format, opts) {
|
|
541
530
|
let types = [];
|
|
542
531
|
if ("credential_identifier" in credentialRequest && credentialRequest.credential_identifier) {
|
|
543
532
|
throw Error(`Cannot get types from request when it contains a credential_identifier`);
|
|
544
|
-
} else if (
|
|
533
|
+
} else if (format === "jwt_vc_json-ld" || format === "ldp_vc" || format === "jwt_vc" || format === "jwt_vc_json") {
|
|
545
534
|
if ("credential_definition" in credentialRequest && credentialRequest.credential_definition) {
|
|
546
535
|
types = "types" in credentialRequest.credential_definition ? credentialRequest.credential_definition.types : credentialRequest.credential_definition.type;
|
|
547
536
|
}
|
|
@@ -551,11 +540,11 @@ function getTypesFromRequest(credentialRequest, opts) {
|
|
|
551
540
|
if ("types" in credentialRequest && Array.isArray(credentialRequest.types)) {
|
|
552
541
|
types = credentialRequest.types;
|
|
553
542
|
}
|
|
554
|
-
} else if (
|
|
543
|
+
} else if (format === "vc+sd-jwt" && "vct" in credentialRequest) {
|
|
555
544
|
types = [
|
|
556
545
|
credentialRequest.vct
|
|
557
546
|
];
|
|
558
|
-
} else if (
|
|
547
|
+
} else if (format === "mso_mdoc" && "doctype" in credentialRequest) {
|
|
559
548
|
types = [
|
|
560
549
|
credentialRequest.doctype
|
|
561
550
|
];
|
|
@@ -569,17 +558,16 @@ function getTypesFromRequest(credentialRequest, opts) {
|
|
|
569
558
|
return types;
|
|
570
559
|
}
|
|
571
560
|
__name(getTypesFromRequest, "getTypesFromRequest");
|
|
572
|
-
function getCredentialRequestForVersion(credentialRequest, version) {
|
|
561
|
+
function getCredentialRequestForVersion(credentialRequest, format, version) {
|
|
573
562
|
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
574
|
-
const
|
|
575
|
-
const types = getTypesFromRequest(credentialRequest, {
|
|
563
|
+
const types = getTypesFromRequest(credentialRequest, format, {
|
|
576
564
|
filterVerifiableCredential: true
|
|
577
565
|
});
|
|
578
566
|
if (credentialRequest.credential_subject_issuance) {
|
|
579
567
|
throw Error("Experimental subject issuance is not supported for older versions of the spec");
|
|
580
568
|
}
|
|
581
569
|
return {
|
|
582
|
-
format
|
|
570
|
+
format,
|
|
583
571
|
proof: credentialRequest.proof,
|
|
584
572
|
type: types[0]
|
|
585
573
|
};
|
|
@@ -792,6 +780,7 @@ __name(acquireDeferredCredentialImpl, "acquireDeferredCredentialImpl");
|
|
|
792
780
|
init_cjs_shims();
|
|
793
781
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
794
782
|
var import_jwt_decode = require("jwt-decode");
|
|
783
|
+
var import_oid4vc_common = require("@sphereon/oid4vc-common");
|
|
795
784
|
var logger2 = import_ssi_types2.Loggers.DEFAULT.get("sphereon:oid4vci:offer");
|
|
796
785
|
function determineSpecVersionFromURI(uri) {
|
|
797
786
|
let version = determineSpecVersionFromScheme(uri, OpenId4VCIVersion.VER_UNKNOWN) ?? OpenId4VCIVersion.VER_UNKNOWN;
|
|
@@ -811,42 +800,102 @@ function determineSpecVersionFromURI(uri) {
|
|
|
811
800
|
OpenId4VCIVersion.VER_1_0_11
|
|
812
801
|
], "grants.user_pin_required");
|
|
813
802
|
version = getVersionFromURIParam(uri, version, [
|
|
814
|
-
OpenId4VCIVersion.VER_1_0_13
|
|
803
|
+
OpenId4VCIVersion.VER_1_0_13,
|
|
804
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
815
805
|
], "credential_configuration_ids");
|
|
816
806
|
version = getVersionFromURIParam(uri, version, [
|
|
817
|
-
OpenId4VCIVersion.VER_1_0_13
|
|
807
|
+
OpenId4VCIVersion.VER_1_0_13,
|
|
808
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
818
809
|
], "tx_code");
|
|
810
|
+
version = getVersionFromURIParam(uri, version, [
|
|
811
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
812
|
+
], "credential_offer_uri ");
|
|
819
813
|
if (version === OpenId4VCIVersion.VER_UNKNOWN) {
|
|
820
|
-
version = OpenId4VCIVersion.
|
|
814
|
+
version = OpenId4VCIVersion.VER_1_0_15;
|
|
821
815
|
}
|
|
822
816
|
return version;
|
|
823
817
|
}
|
|
824
818
|
__name(determineSpecVersionFromURI, "determineSpecVersionFromURI");
|
|
825
819
|
function determineSpecVersionFromScheme(credentialOfferURI, openId4VCIVersion) {
|
|
826
820
|
const scheme = getScheme(credentialOfferURI);
|
|
827
|
-
|
|
821
|
+
const url = toUrlWithDummyBase(credentialOfferURI);
|
|
822
|
+
const qp = url.searchParams;
|
|
823
|
+
if (scheme === DefaultURISchemes.INITIATE_ISSUANCE) {
|
|
824
|
+
if (qp.has("credential_offer") || qp.has("credential_offer_uri")) {
|
|
825
|
+
return recordVersion(openId4VCIVersion, [
|
|
826
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
827
|
+
], scheme);
|
|
828
|
+
}
|
|
829
|
+
if (qp.has("credential_type") || qp.has("issuer")) {
|
|
830
|
+
return recordVersion(openId4VCIVersion, [
|
|
831
|
+
OpenId4VCIVersion.VER_1_0_08
|
|
832
|
+
], scheme);
|
|
833
|
+
}
|
|
828
834
|
return recordVersion(openId4VCIVersion, [
|
|
829
|
-
OpenId4VCIVersion.
|
|
835
|
+
OpenId4VCIVersion.VER_UNKNOWN
|
|
830
836
|
], scheme);
|
|
831
837
|
}
|
|
832
|
-
if (
|
|
833
|
-
|
|
834
|
-
} else if (credentialOfferURI.includes(DefaultURISchemes.CREDENTIAL_OFFER)) {
|
|
835
|
-
if (credentialOfferURI.includes("credentials:") || credentialOfferURI.includes("credentials%22")) {
|
|
838
|
+
if (scheme === DefaultURISchemes.CREDENTIAL_OFFER) {
|
|
839
|
+
if (qp.has("credential_offer_uri")) {
|
|
836
840
|
return recordVersion(openId4VCIVersion, [
|
|
837
|
-
OpenId4VCIVersion.
|
|
841
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
838
842
|
], scheme);
|
|
839
843
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
+
const rawParam = getParamValueLoose(qp, "credential_offer");
|
|
845
|
+
if (rawParam) {
|
|
846
|
+
const decoded = tryDecodeOffer(rawParam);
|
|
847
|
+
const version = sniffOfferVersion(decoded);
|
|
848
|
+
if (version !== OpenId4VCIVersion.VER_UNKNOWN) {
|
|
849
|
+
return recordVersion(openId4VCIVersion, [
|
|
850
|
+
version
|
|
851
|
+
], scheme);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
844
854
|
return recordVersion(openId4VCIVersion, [
|
|
845
855
|
OpenId4VCIVersion.VER_UNKNOWN
|
|
846
856
|
], scheme);
|
|
847
857
|
}
|
|
858
|
+
return recordVersion(openId4VCIVersion, [
|
|
859
|
+
OpenId4VCIVersion.VER_UNKNOWN
|
|
860
|
+
], scheme);
|
|
848
861
|
}
|
|
849
862
|
__name(determineSpecVersionFromScheme, "determineSpecVersionFromScheme");
|
|
863
|
+
function toUrlWithDummyBase(uri) {
|
|
864
|
+
const normalized = uri.replace(/^openid-[^?]+:\/\//, "https://dummy/?");
|
|
865
|
+
return new URL(normalized);
|
|
866
|
+
}
|
|
867
|
+
__name(toUrlWithDummyBase, "toUrlWithDummyBase");
|
|
868
|
+
function getParamValueLoose(qp, key) {
|
|
869
|
+
if (qp.has(key)) return qp.get(key);
|
|
870
|
+
if (qp.has(`?${key}`)) return qp.get(`?${key}`);
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
__name(getParamValueLoose, "getParamValueLoose");
|
|
874
|
+
function tryDecodeOffer(input) {
|
|
875
|
+
let candidate = input;
|
|
876
|
+
try {
|
|
877
|
+
candidate = decodeURIComponent(candidate);
|
|
878
|
+
} catch {
|
|
879
|
+
}
|
|
880
|
+
if (!/[{}]/.test(candidate) && /^[A-Za-z0-9\-_]+$/.test(candidate)) {
|
|
881
|
+
try {
|
|
882
|
+
const b64 = candidate.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(candidate.length / 4) * 4, "=");
|
|
883
|
+
candidate = atob(b64);
|
|
884
|
+
} catch {
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
return candidate;
|
|
888
|
+
}
|
|
889
|
+
__name(tryDecodeOffer, "tryDecodeOffer");
|
|
890
|
+
function sniffOfferVersion(jsonLike) {
|
|
891
|
+
if (!jsonLike) return OpenId4VCIVersion.VER_UNKNOWN;
|
|
892
|
+
const has = /* @__PURE__ */ __name((k) => new RegExp(`"${k}"\\s*:`, "i").test(jsonLike), "has");
|
|
893
|
+
if (has("credentials")) return OpenId4VCIVersion.VER_1_0_11;
|
|
894
|
+
if (has("credential_configuration_id")) return OpenId4VCIVersion.VER_1_0_13;
|
|
895
|
+
if (has("credential_configuration_ids")) return OpenId4VCIVersion.VER_1_0_15;
|
|
896
|
+
return OpenId4VCIVersion.VER_UNKNOWN;
|
|
897
|
+
}
|
|
898
|
+
__name(sniffOfferVersion, "sniffOfferVersion");
|
|
850
899
|
function getScheme(credentialOfferURI) {
|
|
851
900
|
if (!credentialOfferURI || !credentialOfferURI.includes("://")) {
|
|
852
901
|
throw Error("Invalid credential offer URI");
|
|
@@ -902,7 +951,9 @@ var getStateFromCredentialOfferPayload = /* @__PURE__ */ __name((credentialOffer
|
|
|
902
951
|
return;
|
|
903
952
|
}, "getStateFromCredentialOfferPayload");
|
|
904
953
|
function determineSpecVersionFromOffer(offer) {
|
|
905
|
-
if (
|
|
954
|
+
if (isCredentialOfferV1_0_15(offer)) {
|
|
955
|
+
return OpenId4VCIVersion.VER_1_0_15;
|
|
956
|
+
} else if (isCredentialOfferV1_0_13(offer)) {
|
|
906
957
|
return OpenId4VCIVersion.VER_1_0_13;
|
|
907
958
|
} else if (isCredentialOfferV1_0_11(offer)) {
|
|
908
959
|
return OpenId4VCIVersion.VER_1_0_11;
|
|
@@ -983,6 +1034,20 @@ function isCredentialOfferV1_0_13(offer) {
|
|
|
983
1034
|
return "credential_offer_uri" in offer;
|
|
984
1035
|
}
|
|
985
1036
|
__name(isCredentialOfferV1_0_13, "isCredentialOfferV1_0_13");
|
|
1037
|
+
function isCredentialOfferV1_0_15(offer) {
|
|
1038
|
+
if (!offer) {
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
offer = normalizeOfferInput(offer);
|
|
1042
|
+
if ("credential_issuer" in offer && "credential_configuration_ids" in offer) {
|
|
1043
|
+
return Array.isArray(offer.credential_configuration_ids);
|
|
1044
|
+
}
|
|
1045
|
+
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1046
|
+
return isCredentialOfferV1_0_15(offer["credential_offer"]);
|
|
1047
|
+
}
|
|
1048
|
+
return "credential_offer_uri" in offer;
|
|
1049
|
+
}
|
|
1050
|
+
__name(isCredentialOfferV1_0_15, "isCredentialOfferV1_0_15");
|
|
986
1051
|
async function toUniformCredentialOfferRequest(offer, opts) {
|
|
987
1052
|
let version = opts?.version ?? determineSpecVersionFromOffer(offer);
|
|
988
1053
|
let originalCredentialOffer = offer.credential_offer;
|
|
@@ -1018,6 +1083,7 @@ async function toUniformCredentialOfferRequest(offer, opts) {
|
|
|
1018
1083
|
}
|
|
1019
1084
|
__name(toUniformCredentialOfferRequest, "toUniformCredentialOfferRequest");
|
|
1020
1085
|
function isPreAuthCode(request) {
|
|
1086
|
+
request = normalizeOfferInput(request);
|
|
1021
1087
|
const payload = "credential_offer" in request ? request.credential_offer : request;
|
|
1022
1088
|
return payload?.grants?.[PRE_AUTH_GRANT_LITERAL]?.[PRE_AUTH_CODE_LITERAL] !== void 0;
|
|
1023
1089
|
}
|
|
@@ -1051,7 +1117,8 @@ async function resolveCredentialOfferURI(uri) {
|
|
|
1051
1117
|
return response.successBody;
|
|
1052
1118
|
}
|
|
1053
1119
|
__name(resolveCredentialOfferURI, "resolveCredentialOfferURI");
|
|
1054
|
-
function toUniformCredentialOfferPayload(
|
|
1120
|
+
function toUniformCredentialOfferPayload(rawOffer, opts) {
|
|
1121
|
+
const offer = normalizeOfferInput(rawOffer);
|
|
1055
1122
|
const version = opts?.version ?? determineSpecVersionFromOffer(offer);
|
|
1056
1123
|
if (version >= OpenId4VCIVersion.VER_1_0_11) {
|
|
1057
1124
|
const orig = offer;
|
|
@@ -1120,6 +1187,7 @@ function determineFlowType(suppliedOffer, version) {
|
|
|
1120
1187
|
}
|
|
1121
1188
|
__name(determineFlowType, "determineFlowType");
|
|
1122
1189
|
function getCredentialOfferPayload(offer) {
|
|
1190
|
+
offer = normalizeOfferInput(offer);
|
|
1123
1191
|
let payload;
|
|
1124
1192
|
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1125
1193
|
payload = offer.credential_offer;
|
|
@@ -1130,6 +1198,7 @@ function getCredentialOfferPayload(offer) {
|
|
|
1130
1198
|
}
|
|
1131
1199
|
__name(getCredentialOfferPayload, "getCredentialOfferPayload");
|
|
1132
1200
|
function determineGrantTypes(offer) {
|
|
1201
|
+
offer = normalizeOfferInput(offer);
|
|
1133
1202
|
let grants;
|
|
1134
1203
|
if ("grants" in offer && offer.grants) {
|
|
1135
1204
|
grants = offer.grants;
|
|
@@ -1202,6 +1271,25 @@ function getTypesFromOfferV1_0_11(credentialOffer, opts) {
|
|
|
1202
1271
|
return types;
|
|
1203
1272
|
}
|
|
1204
1273
|
__name(getTypesFromOfferV1_0_11, "getTypesFromOfferV1_0_11");
|
|
1274
|
+
function getCredentialConfigurationIdsFromOfferV1_0_15(offer) {
|
|
1275
|
+
return offer.credential_configuration_ids ?? [];
|
|
1276
|
+
}
|
|
1277
|
+
__name(getCredentialConfigurationIdsFromOfferV1_0_15, "getCredentialConfigurationIdsFromOfferV1_0_15");
|
|
1278
|
+
function normalizeOfferInput(input) {
|
|
1279
|
+
if (typeof input !== "string") {
|
|
1280
|
+
return input;
|
|
1281
|
+
}
|
|
1282
|
+
if (import_ssi_types2.ObjectUtils.isString(input) && input.startsWith("ey")) {
|
|
1283
|
+
const payload = (0, import_oid4vc_common.base64urlToString)(input);
|
|
1284
|
+
return JSON.parse(payload);
|
|
1285
|
+
}
|
|
1286
|
+
try {
|
|
1287
|
+
return JSON.parse(input);
|
|
1288
|
+
} catch {
|
|
1289
|
+
}
|
|
1290
|
+
return input;
|
|
1291
|
+
}
|
|
1292
|
+
__name(normalizeOfferInput, "normalizeOfferInput");
|
|
1205
1293
|
|
|
1206
1294
|
// lib/functions/Encoding.ts
|
|
1207
1295
|
init_cjs_shims();
|
|
@@ -1447,7 +1535,7 @@ __name(getTypesFromCredentialSupported, "getTypesFromCredentialSupported");
|
|
|
1447
1535
|
// lib/functions/IssuerMetadataUtils.ts
|
|
1448
1536
|
init_cjs_shims();
|
|
1449
1537
|
function getSupportedCredentials(opts) {
|
|
1450
|
-
const { version = OpenId4VCIVersion.
|
|
1538
|
+
const { version = OpenId4VCIVersion.VER_1_0_15, types } = opts ?? {};
|
|
1451
1539
|
if (types && Array.isArray(types)) {
|
|
1452
1540
|
if (version < OpenId4VCIVersion.VER_1_0_13) {
|
|
1453
1541
|
return types.flatMap((typeSet) => getSupportedCredential({
|
|
@@ -1499,9 +1587,10 @@ function determineVersionsFromIssuerMetadata(issuerMetadata) {
|
|
|
1499
1587
|
}
|
|
1500
1588
|
__name(determineVersionsFromIssuerMetadata, "determineVersionsFromIssuerMetadata");
|
|
1501
1589
|
function getSupportedCredential(opts) {
|
|
1502
|
-
const { issuerMetadata, types, format, version = OpenId4VCIVersion.
|
|
1590
|
+
const { issuerMetadata, types, format, version = OpenId4VCIVersion.VER_1_0_15 } = opts ?? {};
|
|
1503
1591
|
let credentialConfigurationsV11 = void 0;
|
|
1504
1592
|
let credentialConfigurationsV13 = void 0;
|
|
1593
|
+
let credentialConfigurationsV15 = void 0;
|
|
1505
1594
|
if (version < OpenId4VCIVersion.VER_1_0_12 || issuerMetadata?.credential_configurations_supported === void 0 && issuerMetadata?.credentials_supported) {
|
|
1506
1595
|
if (issuerMetadata?.credentials_supported && !Array.isArray(issuerMetadata?.credentials_supported)) {
|
|
1507
1596
|
credentialConfigurationsV11 = [];
|
|
@@ -1511,15 +1600,25 @@ function getSupportedCredential(opts) {
|
|
|
1511
1600
|
}
|
|
1512
1601
|
credentialConfigurationsV11?.push(supported);
|
|
1513
1602
|
});
|
|
1603
|
+
} else if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1604
|
+
credentialConfigurationsV15 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1514
1605
|
} else {
|
|
1515
1606
|
credentialConfigurationsV11 = issuerMetadata?.credentials_supported ?? [];
|
|
1516
1607
|
}
|
|
1517
|
-
} else {
|
|
1608
|
+
} else if (version == OpenId4VCIVersion.VER_1_0_13) {
|
|
1518
1609
|
credentialConfigurationsV13 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1610
|
+
} else {
|
|
1611
|
+
credentialConfigurationsV15 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1519
1612
|
}
|
|
1520
1613
|
if (!issuerMetadata || !issuerMetadata.credential_configurations_supported && !issuerMetadata.credentials_supported) {
|
|
1521
1614
|
VCI_LOG_COMMON.warning(`No credential issuer metadata or supported credentials found for issuer}`);
|
|
1522
|
-
|
|
1615
|
+
if (version < OpenId4VCIVersion.VER_1_0_13) {
|
|
1616
|
+
return credentialConfigurationsV11;
|
|
1617
|
+
} else if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1618
|
+
return credentialConfigurationsV15;
|
|
1619
|
+
} else {
|
|
1620
|
+
return credentialConfigurationsV15;
|
|
1621
|
+
}
|
|
1523
1622
|
}
|
|
1524
1623
|
const normalizedTypes = Array.isArray(types) ? types : types ? [
|
|
1525
1624
|
types
|
|
@@ -1549,7 +1648,17 @@ function getSupportedCredential(opts) {
|
|
|
1549
1648
|
return isTypeMatch && isFormatMatch ? config : void 0;
|
|
1550
1649
|
}
|
|
1551
1650
|
__name(filterMatchingConfig, "filterMatchingConfig");
|
|
1552
|
-
if (
|
|
1651
|
+
if (credentialConfigurationsV15) {
|
|
1652
|
+
return Object.entries(credentialConfigurationsV15).reduce((filteredConfigs, [id, config]) => {
|
|
1653
|
+
if (filterMatchingConfig(config)) {
|
|
1654
|
+
filteredConfigs[id] = config;
|
|
1655
|
+
if (!config.id) {
|
|
1656
|
+
config.id = id;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
return filteredConfigs;
|
|
1660
|
+
}, {});
|
|
1661
|
+
} else if (credentialConfigurationsV13) {
|
|
1553
1662
|
return Object.entries(credentialConfigurationsV13).reduce((filteredConfigs, [id, config]) => {
|
|
1554
1663
|
if (filterMatchingConfig(config)) {
|
|
1555
1664
|
filteredConfigs[id] = config;
|
|
@@ -1612,6 +1721,51 @@ function getIssuerName(url, credentialIssuerMetadata) {
|
|
|
1612
1721
|
}
|
|
1613
1722
|
__name(getIssuerName, "getIssuerName");
|
|
1614
1723
|
|
|
1724
|
+
// lib/functions/FormatUtils.ts
|
|
1725
|
+
init_cjs_shims();
|
|
1726
|
+
function isFormat(formatObject, format) {
|
|
1727
|
+
return formatObject.format === format;
|
|
1728
|
+
}
|
|
1729
|
+
__name(isFormat, "isFormat");
|
|
1730
|
+
function isNotFormat(formatObject, format) {
|
|
1731
|
+
return formatObject.format !== format;
|
|
1732
|
+
}
|
|
1733
|
+
__name(isNotFormat, "isNotFormat");
|
|
1734
|
+
var isUniformFormat = /* @__PURE__ */ __name((format) => {
|
|
1735
|
+
return [
|
|
1736
|
+
"jwt_vc_json",
|
|
1737
|
+
"jwt_vc_json-ld",
|
|
1738
|
+
"ldp_vc",
|
|
1739
|
+
"vc+sd-jwt",
|
|
1740
|
+
"mso_mdoc"
|
|
1741
|
+
].includes(format);
|
|
1742
|
+
}, "isUniformFormat");
|
|
1743
|
+
function getUniformFormat(format) {
|
|
1744
|
+
if (isUniformFormat(format)) {
|
|
1745
|
+
return format;
|
|
1746
|
+
}
|
|
1747
|
+
if (format.toLocaleLowerCase() === "jwt_vc" || format.toLocaleLowerCase() === "jwt") {
|
|
1748
|
+
return "jwt_vc";
|
|
1749
|
+
}
|
|
1750
|
+
if (format === "ldp_vc" || format === "ldp") {
|
|
1751
|
+
return "ldp_vc";
|
|
1752
|
+
}
|
|
1753
|
+
throw new Error(`Invalid format: ${format}`);
|
|
1754
|
+
}
|
|
1755
|
+
__name(getUniformFormat, "getUniformFormat");
|
|
1756
|
+
function getFormatForVersion(format, version) {
|
|
1757
|
+
const uniformFormat = isUniformFormat(format) ? format : getUniformFormat(format);
|
|
1758
|
+
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
1759
|
+
if (uniformFormat === "jwt_vc_json") {
|
|
1760
|
+
return "jwt_vc";
|
|
1761
|
+
} else if (uniformFormat === "ldp_vc" || uniformFormat === "jwt_vc_json-ld") {
|
|
1762
|
+
return "ldp_vc";
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
return uniformFormat;
|
|
1766
|
+
}
|
|
1767
|
+
__name(getFormatForVersion, "getFormatForVersion");
|
|
1768
|
+
|
|
1615
1769
|
// lib/functions/ProofUtil.ts
|
|
1616
1770
|
init_cjs_shims();
|
|
1617
1771
|
var import_ssi_types3 = require("@sphereon/ssi-types");
|
|
@@ -1779,7 +1933,7 @@ var toAuthorizationResponsePayload = /* @__PURE__ */ __name((input) => {
|
|
|
1779
1933
|
|
|
1780
1934
|
// lib/functions/RandomUtils.ts
|
|
1781
1935
|
init_cjs_shims();
|
|
1782
|
-
var
|
|
1936
|
+
var import_oid4vc_common2 = require("@sphereon/oid4vc-common");
|
|
1783
1937
|
var u8a = __toESM(require("uint8arrays"), 1);
|
|
1784
1938
|
var import_randomBytes = __toESM(require_randomBytes(), 1);
|
|
1785
1939
|
var { toString } = u8a;
|
|
@@ -1800,7 +1954,7 @@ var createCodeChallenge = /* @__PURE__ */ __name((codeVerifier, codeChallengeMet
|
|
|
1800
1954
|
if (codeChallengeMethod === CodeChallengeMethod.plain) {
|
|
1801
1955
|
return codeVerifier;
|
|
1802
1956
|
} else if (!codeChallengeMethod || codeChallengeMethod === CodeChallengeMethod.S256) {
|
|
1803
|
-
return toString((0,
|
|
1957
|
+
return toString((0, import_oid4vc_common2.defaultHasher)(codeVerifier, "sha256"), "base64url");
|
|
1804
1958
|
} else {
|
|
1805
1959
|
throw Error(`code challenge method ${codeChallengeMethod} not implemented`);
|
|
1806
1960
|
}
|