@sphereon/oid4vci-common 0.19.1-feature.DIIPv4.2 → 0.19.1-feature.DIIPv4.34
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 +238 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +306 -24
- package/dist/index.d.ts +306 -24
- package/dist/index.js +235 -81
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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,14 @@ 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
|
+
"jwt_vc",
|
|
242
|
+
"mso_mdoc"
|
|
243
|
+
];
|
|
232
244
|
var PRE_AUTH_CODE_LITERAL = "pre-authorized_code";
|
|
233
245
|
var PRE_AUTH_GRANT_LITERAL = "urn:ietf:params:oauth:grant-type:pre-authorized_code";
|
|
234
246
|
|
|
@@ -349,6 +361,26 @@ var credentialIssuerMetadataFieldNames = [
|
|
|
349
361
|
"signed_metadata"
|
|
350
362
|
];
|
|
351
363
|
|
|
364
|
+
// lib/types/v1_0_15.types.ts
|
|
365
|
+
init_cjs_shims();
|
|
366
|
+
var credentialIssuerMetadataFieldNamesV1_0_15 = [
|
|
367
|
+
"credential_issuer",
|
|
368
|
+
"credential_configurations_supported",
|
|
369
|
+
"credential_endpoint",
|
|
370
|
+
"nonce_endpoint",
|
|
371
|
+
"deferred_credential_endpoint",
|
|
372
|
+
"notification_endpoint",
|
|
373
|
+
"credential_response_encryption",
|
|
374
|
+
"batch_credential_issuance",
|
|
375
|
+
"authorization_servers",
|
|
376
|
+
"token_endpoint",
|
|
377
|
+
"display",
|
|
378
|
+
"credential_supplier_config",
|
|
379
|
+
"credential_identifiers_supported",
|
|
380
|
+
"signed_metadata",
|
|
381
|
+
"authorization_challenge_endpoint"
|
|
382
|
+
];
|
|
383
|
+
|
|
352
384
|
// lib/types/ServerMetadata.ts
|
|
353
385
|
init_cjs_shims();
|
|
354
386
|
var authorizationServerMetadataFieldNames = [
|
|
@@ -431,6 +463,7 @@ var OpenId4VCIVersion = /* @__PURE__ */ function(OpenId4VCIVersion2) {
|
|
|
431
463
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_11"] = 1011] = "VER_1_0_11";
|
|
432
464
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_12"] = 1012] = "VER_1_0_12";
|
|
433
465
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_13"] = 1013] = "VER_1_0_13";
|
|
466
|
+
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_1_0_15"] = 1015] = "VER_1_0_15";
|
|
434
467
|
OpenId4VCIVersion2[OpenId4VCIVersion2["VER_UNKNOWN"] = Number.MAX_VALUE] = "VER_UNKNOWN";
|
|
435
468
|
return OpenId4VCIVersion2;
|
|
436
469
|
}({});
|
|
@@ -491,57 +524,12 @@ var TokenError = class _TokenError extends Error {
|
|
|
491
524
|
// lib/types/QRCode.types.ts
|
|
492
525
|
init_cjs_shims();
|
|
493
526
|
|
|
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
527
|
// lib/functions/CredentialRequestUtil.ts
|
|
540
|
-
function getTypesFromRequest(credentialRequest, opts) {
|
|
528
|
+
function getTypesFromRequest(credentialRequest, format, opts) {
|
|
541
529
|
let types = [];
|
|
542
530
|
if ("credential_identifier" in credentialRequest && credentialRequest.credential_identifier) {
|
|
543
531
|
throw Error(`Cannot get types from request when it contains a credential_identifier`);
|
|
544
|
-
} else if (
|
|
532
|
+
} else if (format === "jwt_vc_json-ld" || format === "ldp_vc" || format === "jwt_vc" || format === "jwt_vc_json") {
|
|
545
533
|
if ("credential_definition" in credentialRequest && credentialRequest.credential_definition) {
|
|
546
534
|
types = "types" in credentialRequest.credential_definition ? credentialRequest.credential_definition.types : credentialRequest.credential_definition.type;
|
|
547
535
|
}
|
|
@@ -551,11 +539,11 @@ function getTypesFromRequest(credentialRequest, opts) {
|
|
|
551
539
|
if ("types" in credentialRequest && Array.isArray(credentialRequest.types)) {
|
|
552
540
|
types = credentialRequest.types;
|
|
553
541
|
}
|
|
554
|
-
} else if (
|
|
542
|
+
} else if (format === "dc+sd-jwt" && "vct" in credentialRequest) {
|
|
555
543
|
types = [
|
|
556
544
|
credentialRequest.vct
|
|
557
545
|
];
|
|
558
|
-
} else if (
|
|
546
|
+
} else if (format === "mso_mdoc" && "doctype" in credentialRequest) {
|
|
559
547
|
types = [
|
|
560
548
|
credentialRequest.doctype
|
|
561
549
|
];
|
|
@@ -569,17 +557,16 @@ function getTypesFromRequest(credentialRequest, opts) {
|
|
|
569
557
|
return types;
|
|
570
558
|
}
|
|
571
559
|
__name(getTypesFromRequest, "getTypesFromRequest");
|
|
572
|
-
function getCredentialRequestForVersion(credentialRequest, version) {
|
|
560
|
+
function getCredentialRequestForVersion(credentialRequest, format, version) {
|
|
573
561
|
if (version === OpenId4VCIVersion.VER_1_0_08) {
|
|
574
|
-
const
|
|
575
|
-
const types = getTypesFromRequest(credentialRequest, {
|
|
562
|
+
const types = getTypesFromRequest(credentialRequest, format, {
|
|
576
563
|
filterVerifiableCredential: true
|
|
577
564
|
});
|
|
578
565
|
if (credentialRequest.credential_subject_issuance) {
|
|
579
566
|
throw Error("Experimental subject issuance is not supported for older versions of the spec");
|
|
580
567
|
}
|
|
581
568
|
return {
|
|
582
|
-
format
|
|
569
|
+
format,
|
|
583
570
|
proof: credentialRequest.proof,
|
|
584
571
|
type: types[0]
|
|
585
572
|
};
|
|
@@ -792,6 +779,7 @@ __name(acquireDeferredCredentialImpl, "acquireDeferredCredentialImpl");
|
|
|
792
779
|
init_cjs_shims();
|
|
793
780
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
794
781
|
var import_jwt_decode = require("jwt-decode");
|
|
782
|
+
var import_oid4vc_common = require("@sphereon/oid4vc-common");
|
|
795
783
|
var logger2 = import_ssi_types2.Loggers.DEFAULT.get("sphereon:oid4vci:offer");
|
|
796
784
|
function determineSpecVersionFromURI(uri) {
|
|
797
785
|
let version = determineSpecVersionFromScheme(uri, OpenId4VCIVersion.VER_UNKNOWN) ?? OpenId4VCIVersion.VER_UNKNOWN;
|
|
@@ -811,42 +799,100 @@ function determineSpecVersionFromURI(uri) {
|
|
|
811
799
|
OpenId4VCIVersion.VER_1_0_11
|
|
812
800
|
], "grants.user_pin_required");
|
|
813
801
|
version = getVersionFromURIParam(uri, version, [
|
|
814
|
-
OpenId4VCIVersion.VER_1_0_13
|
|
802
|
+
OpenId4VCIVersion.VER_1_0_13,
|
|
803
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
815
804
|
], "credential_configuration_ids");
|
|
816
805
|
version = getVersionFromURIParam(uri, version, [
|
|
817
|
-
OpenId4VCIVersion.VER_1_0_13
|
|
806
|
+
OpenId4VCIVersion.VER_1_0_13,
|
|
807
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
818
808
|
], "tx_code");
|
|
809
|
+
version = getVersionFromURIParam(uri, version, [
|
|
810
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
811
|
+
], "credential_offer_uri ");
|
|
819
812
|
if (version === OpenId4VCIVersion.VER_UNKNOWN) {
|
|
820
|
-
version = OpenId4VCIVersion.
|
|
813
|
+
version = OpenId4VCIVersion.VER_1_0_15;
|
|
821
814
|
}
|
|
822
815
|
return version;
|
|
823
816
|
}
|
|
824
817
|
__name(determineSpecVersionFromURI, "determineSpecVersionFromURI");
|
|
825
818
|
function determineSpecVersionFromScheme(credentialOfferURI, openId4VCIVersion) {
|
|
826
819
|
const scheme = getScheme(credentialOfferURI);
|
|
827
|
-
|
|
820
|
+
const url = toUrlWithDummyBase(credentialOfferURI);
|
|
821
|
+
const qp = url.searchParams;
|
|
822
|
+
if (scheme === DefaultURISchemes.INITIATE_ISSUANCE) {
|
|
823
|
+
if (qp.has("credential_offer") || qp.has("credential_offer_uri")) {
|
|
824
|
+
return recordVersion(openId4VCIVersion, [
|
|
825
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
826
|
+
], scheme);
|
|
827
|
+
}
|
|
828
|
+
if (qp.has("credential_type") || qp.has("issuer")) {
|
|
829
|
+
return recordVersion(openId4VCIVersion, [
|
|
830
|
+
OpenId4VCIVersion.VER_1_0_08
|
|
831
|
+
], scheme);
|
|
832
|
+
}
|
|
828
833
|
return recordVersion(openId4VCIVersion, [
|
|
829
|
-
OpenId4VCIVersion.
|
|
834
|
+
OpenId4VCIVersion.VER_UNKNOWN
|
|
830
835
|
], scheme);
|
|
831
836
|
}
|
|
832
|
-
if (
|
|
833
|
-
|
|
834
|
-
} else if (credentialOfferURI.includes(DefaultURISchemes.CREDENTIAL_OFFER)) {
|
|
835
|
-
if (credentialOfferURI.includes("credentials:") || credentialOfferURI.includes("credentials%22")) {
|
|
837
|
+
if (scheme === DefaultURISchemes.CREDENTIAL_OFFER) {
|
|
838
|
+
if (qp.has("credential_offer_uri")) {
|
|
836
839
|
return recordVersion(openId4VCIVersion, [
|
|
837
|
-
OpenId4VCIVersion.
|
|
840
|
+
OpenId4VCIVersion.VER_1_0_15
|
|
838
841
|
], scheme);
|
|
839
842
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
843
|
+
const rawParam = getParamValueLoose(qp, "credential_offer");
|
|
844
|
+
if (rawParam) {
|
|
845
|
+
const decoded = tryDecodeOffer(rawParam);
|
|
846
|
+
const version = sniffOfferVersion(decoded);
|
|
847
|
+
if (version !== OpenId4VCIVersion.VER_UNKNOWN) {
|
|
848
|
+
return recordVersion(openId4VCIVersion, [
|
|
849
|
+
version
|
|
850
|
+
], scheme);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
844
853
|
return recordVersion(openId4VCIVersion, [
|
|
845
854
|
OpenId4VCIVersion.VER_UNKNOWN
|
|
846
855
|
], scheme);
|
|
847
856
|
}
|
|
857
|
+
return recordVersion(openId4VCIVersion, [
|
|
858
|
+
OpenId4VCIVersion.VER_UNKNOWN
|
|
859
|
+
], scheme);
|
|
848
860
|
}
|
|
849
861
|
__name(determineSpecVersionFromScheme, "determineSpecVersionFromScheme");
|
|
862
|
+
function toUrlWithDummyBase(uri) {
|
|
863
|
+
const normalized = uri.replace(/^openid-[^?]+:\/\//, "https://dummy/?");
|
|
864
|
+
return new URL(normalized);
|
|
865
|
+
}
|
|
866
|
+
__name(toUrlWithDummyBase, "toUrlWithDummyBase");
|
|
867
|
+
function getParamValueLoose(qp, key) {
|
|
868
|
+
if (qp.has(key)) return qp.get(key);
|
|
869
|
+
if (qp.has(`?${key}`)) return qp.get(`?${key}`);
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
__name(getParamValueLoose, "getParamValueLoose");
|
|
873
|
+
function tryDecodeOffer(input) {
|
|
874
|
+
let candidate = input;
|
|
875
|
+
try {
|
|
876
|
+
candidate = decodeURIComponent(candidate);
|
|
877
|
+
} catch {
|
|
878
|
+
}
|
|
879
|
+
if (!/[{}]/.test(candidate) && /^[A-Za-z0-9\-_]+$/.test(candidate)) {
|
|
880
|
+
try {
|
|
881
|
+
const b64 = candidate.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(candidate.length / 4) * 4, "=");
|
|
882
|
+
candidate = atob(b64);
|
|
883
|
+
} catch {
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
return candidate;
|
|
887
|
+
}
|
|
888
|
+
__name(tryDecodeOffer, "tryDecodeOffer");
|
|
889
|
+
function sniffOfferVersion(jsonLike) {
|
|
890
|
+
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
|
+
return OpenId4VCIVersion.VER_UNKNOWN;
|
|
894
|
+
}
|
|
895
|
+
__name(sniffOfferVersion, "sniffOfferVersion");
|
|
850
896
|
function getScheme(credentialOfferURI) {
|
|
851
897
|
if (!credentialOfferURI || !credentialOfferURI.includes("://")) {
|
|
852
898
|
throw Error("Invalid credential offer URI");
|
|
@@ -902,7 +948,9 @@ var getStateFromCredentialOfferPayload = /* @__PURE__ */ __name((credentialOffer
|
|
|
902
948
|
return;
|
|
903
949
|
}, "getStateFromCredentialOfferPayload");
|
|
904
950
|
function determineSpecVersionFromOffer(offer) {
|
|
905
|
-
if (
|
|
951
|
+
if (isCredentialOfferV1_0_15(offer)) {
|
|
952
|
+
return OpenId4VCIVersion.VER_1_0_15;
|
|
953
|
+
} else if (isCredentialOfferV1_0_13(offer)) {
|
|
906
954
|
return OpenId4VCIVersion.VER_1_0_13;
|
|
907
955
|
} else if (isCredentialOfferV1_0_11(offer)) {
|
|
908
956
|
return OpenId4VCIVersion.VER_1_0_11;
|
|
@@ -983,6 +1031,20 @@ function isCredentialOfferV1_0_13(offer) {
|
|
|
983
1031
|
return "credential_offer_uri" in offer;
|
|
984
1032
|
}
|
|
985
1033
|
__name(isCredentialOfferV1_0_13, "isCredentialOfferV1_0_13");
|
|
1034
|
+
function isCredentialOfferV1_0_15(offer) {
|
|
1035
|
+
if (!offer) {
|
|
1036
|
+
return false;
|
|
1037
|
+
}
|
|
1038
|
+
offer = normalizeOfferInput(offer);
|
|
1039
|
+
if ("credential_issuer" in offer && "credential_configuration_ids" in offer) {
|
|
1040
|
+
return Array.isArray(offer.credential_configuration_ids);
|
|
1041
|
+
}
|
|
1042
|
+
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1043
|
+
return isCredentialOfferV1_0_15(offer["credential_offer"]);
|
|
1044
|
+
}
|
|
1045
|
+
return "credential_offer_uri" in offer;
|
|
1046
|
+
}
|
|
1047
|
+
__name(isCredentialOfferV1_0_15, "isCredentialOfferV1_0_15");
|
|
986
1048
|
async function toUniformCredentialOfferRequest(offer, opts) {
|
|
987
1049
|
let version = opts?.version ?? determineSpecVersionFromOffer(offer);
|
|
988
1050
|
let originalCredentialOffer = offer.credential_offer;
|
|
@@ -1018,6 +1080,7 @@ async function toUniformCredentialOfferRequest(offer, opts) {
|
|
|
1018
1080
|
}
|
|
1019
1081
|
__name(toUniformCredentialOfferRequest, "toUniformCredentialOfferRequest");
|
|
1020
1082
|
function isPreAuthCode(request) {
|
|
1083
|
+
request = normalizeOfferInput(request);
|
|
1021
1084
|
const payload = "credential_offer" in request ? request.credential_offer : request;
|
|
1022
1085
|
return payload?.grants?.[PRE_AUTH_GRANT_LITERAL]?.[PRE_AUTH_CODE_LITERAL] !== void 0;
|
|
1023
1086
|
}
|
|
@@ -1051,7 +1114,8 @@ async function resolveCredentialOfferURI(uri) {
|
|
|
1051
1114
|
return response.successBody;
|
|
1052
1115
|
}
|
|
1053
1116
|
__name(resolveCredentialOfferURI, "resolveCredentialOfferURI");
|
|
1054
|
-
function toUniformCredentialOfferPayload(
|
|
1117
|
+
function toUniformCredentialOfferPayload(rawOffer, opts) {
|
|
1118
|
+
const offer = normalizeOfferInput(rawOffer);
|
|
1055
1119
|
const version = opts?.version ?? determineSpecVersionFromOffer(offer);
|
|
1056
1120
|
if (version >= OpenId4VCIVersion.VER_1_0_11) {
|
|
1057
1121
|
const orig = offer;
|
|
@@ -1120,6 +1184,7 @@ function determineFlowType(suppliedOffer, version) {
|
|
|
1120
1184
|
}
|
|
1121
1185
|
__name(determineFlowType, "determineFlowType");
|
|
1122
1186
|
function getCredentialOfferPayload(offer) {
|
|
1187
|
+
offer = normalizeOfferInput(offer);
|
|
1123
1188
|
let payload;
|
|
1124
1189
|
if ("credential_offer" in offer && offer["credential_offer"]) {
|
|
1125
1190
|
payload = offer.credential_offer;
|
|
@@ -1130,6 +1195,7 @@ function getCredentialOfferPayload(offer) {
|
|
|
1130
1195
|
}
|
|
1131
1196
|
__name(getCredentialOfferPayload, "getCredentialOfferPayload");
|
|
1132
1197
|
function determineGrantTypes(offer) {
|
|
1198
|
+
offer = normalizeOfferInput(offer);
|
|
1133
1199
|
let grants;
|
|
1134
1200
|
if ("grants" in offer && offer.grants) {
|
|
1135
1201
|
grants = offer.grants;
|
|
@@ -1202,6 +1268,25 @@ function getTypesFromOfferV1_0_11(credentialOffer, opts) {
|
|
|
1202
1268
|
return types;
|
|
1203
1269
|
}
|
|
1204
1270
|
__name(getTypesFromOfferV1_0_11, "getTypesFromOfferV1_0_11");
|
|
1271
|
+
function getCredentialConfigurationIdsFromOfferV1_0_15(offer) {
|
|
1272
|
+
return offer.credential_configuration_ids ?? [];
|
|
1273
|
+
}
|
|
1274
|
+
__name(getCredentialConfigurationIdsFromOfferV1_0_15, "getCredentialConfigurationIdsFromOfferV1_0_15");
|
|
1275
|
+
function normalizeOfferInput(input) {
|
|
1276
|
+
if (typeof input !== "string") {
|
|
1277
|
+
return input;
|
|
1278
|
+
}
|
|
1279
|
+
if (import_ssi_types2.ObjectUtils.isString(input) && input.startsWith("ey")) {
|
|
1280
|
+
const payload = (0, import_oid4vc_common.base64urlToString)(input);
|
|
1281
|
+
return JSON.parse(payload);
|
|
1282
|
+
}
|
|
1283
|
+
try {
|
|
1284
|
+
return JSON.parse(input);
|
|
1285
|
+
} catch {
|
|
1286
|
+
}
|
|
1287
|
+
return input;
|
|
1288
|
+
}
|
|
1289
|
+
__name(normalizeOfferInput, "normalizeOfferInput");
|
|
1205
1290
|
|
|
1206
1291
|
// lib/functions/Encoding.ts
|
|
1207
1292
|
init_cjs_shims();
|
|
@@ -1425,7 +1510,7 @@ function getTypesFromCredentialSupported(credentialSupported, opts) {
|
|
|
1425
1510
|
let types = [];
|
|
1426
1511
|
if (credentialSupported.format === "jwt_vc_json" || credentialSupported.format === "jwt_vc" || credentialSupported.format === "jwt_vc_json-ld" || credentialSupported.format === "ldp_vc") {
|
|
1427
1512
|
types = getTypesFromObject(credentialSupported) ?? [];
|
|
1428
|
-
} else if (credentialSupported.format === "vc+sd-jwt") {
|
|
1513
|
+
} else if (credentialSupported.format === "dc+sd-jwt" || credentialSupported.format === "vc+sd-jwt") {
|
|
1429
1514
|
types = [
|
|
1430
1515
|
credentialSupported.vct
|
|
1431
1516
|
];
|
|
@@ -1447,7 +1532,7 @@ __name(getTypesFromCredentialSupported, "getTypesFromCredentialSupported");
|
|
|
1447
1532
|
// lib/functions/IssuerMetadataUtils.ts
|
|
1448
1533
|
init_cjs_shims();
|
|
1449
1534
|
function getSupportedCredentials(opts) {
|
|
1450
|
-
const { version = OpenId4VCIVersion.
|
|
1535
|
+
const { version = OpenId4VCIVersion.VER_1_0_15, types } = opts ?? {};
|
|
1451
1536
|
if (types && Array.isArray(types)) {
|
|
1452
1537
|
if (version < OpenId4VCIVersion.VER_1_0_13) {
|
|
1453
1538
|
return types.flatMap((typeSet) => getSupportedCredential({
|
|
@@ -1476,7 +1561,9 @@ function getSupportedCredentials(opts) {
|
|
|
1476
1561
|
__name(getSupportedCredentials, "getSupportedCredentials");
|
|
1477
1562
|
function determineVersionsFromIssuerMetadata(issuerMetadata) {
|
|
1478
1563
|
const versions = /* @__PURE__ */ new Set();
|
|
1479
|
-
if ("
|
|
1564
|
+
if ("credential_configurations_supported" in issuerMetadata) {
|
|
1565
|
+
versions.add(OpenId4VCIVersion.VER_1_0_15);
|
|
1566
|
+
} else if ("authorization_server" in issuerMetadata) {
|
|
1480
1567
|
versions.add(OpenId4VCIVersion.VER_1_0_11);
|
|
1481
1568
|
} else if ("authorization_servers" in issuerMetadata) {
|
|
1482
1569
|
versions.add(OpenId4VCIVersion.VER_1_0_13);
|
|
@@ -1499,9 +1586,10 @@ function determineVersionsFromIssuerMetadata(issuerMetadata) {
|
|
|
1499
1586
|
}
|
|
1500
1587
|
__name(determineVersionsFromIssuerMetadata, "determineVersionsFromIssuerMetadata");
|
|
1501
1588
|
function getSupportedCredential(opts) {
|
|
1502
|
-
const { issuerMetadata, types, format, version = OpenId4VCIVersion.
|
|
1589
|
+
const { issuerMetadata, types, format, version = OpenId4VCIVersion.VER_1_0_15 } = opts ?? {};
|
|
1503
1590
|
let credentialConfigurationsV11 = void 0;
|
|
1504
1591
|
let credentialConfigurationsV13 = void 0;
|
|
1592
|
+
let credentialConfigurationsV15 = void 0;
|
|
1505
1593
|
if (version < OpenId4VCIVersion.VER_1_0_12 || issuerMetadata?.credential_configurations_supported === void 0 && issuerMetadata?.credentials_supported) {
|
|
1506
1594
|
if (issuerMetadata?.credentials_supported && !Array.isArray(issuerMetadata?.credentials_supported)) {
|
|
1507
1595
|
credentialConfigurationsV11 = [];
|
|
@@ -1511,15 +1599,25 @@ function getSupportedCredential(opts) {
|
|
|
1511
1599
|
}
|
|
1512
1600
|
credentialConfigurationsV11?.push(supported);
|
|
1513
1601
|
});
|
|
1602
|
+
} else if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1603
|
+
credentialConfigurationsV15 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1514
1604
|
} else {
|
|
1515
1605
|
credentialConfigurationsV11 = issuerMetadata?.credentials_supported ?? [];
|
|
1516
1606
|
}
|
|
1517
|
-
} else {
|
|
1607
|
+
} else if (version == OpenId4VCIVersion.VER_1_0_13) {
|
|
1518
1608
|
credentialConfigurationsV13 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1609
|
+
} else {
|
|
1610
|
+
credentialConfigurationsV15 = issuerMetadata?.credential_configurations_supported ?? {};
|
|
1519
1611
|
}
|
|
1520
1612
|
if (!issuerMetadata || !issuerMetadata.credential_configurations_supported && !issuerMetadata.credentials_supported) {
|
|
1521
1613
|
VCI_LOG_COMMON.warning(`No credential issuer metadata or supported credentials found for issuer}`);
|
|
1522
|
-
|
|
1614
|
+
if (version < OpenId4VCIVersion.VER_1_0_13) {
|
|
1615
|
+
return credentialConfigurationsV11;
|
|
1616
|
+
} else if (version >= OpenId4VCIVersion.VER_1_0_15) {
|
|
1617
|
+
return credentialConfigurationsV15;
|
|
1618
|
+
} else {
|
|
1619
|
+
return credentialConfigurationsV15;
|
|
1620
|
+
}
|
|
1523
1621
|
}
|
|
1524
1622
|
const normalizedTypes = Array.isArray(types) ? types : types ? [
|
|
1525
1623
|
types
|
|
@@ -1536,12 +1634,14 @@ function getSupportedCredential(opts) {
|
|
|
1536
1634
|
} else if (types2) {
|
|
1537
1635
|
isTypeMatch = normalizedTypes.every((type) => types2.includes(type));
|
|
1538
1636
|
} else {
|
|
1539
|
-
|
|
1540
|
-
|
|
1637
|
+
const hasValidCredentialDefinition = isW3cCredentialSupported(config) && "credential_definition" in config && config.credential_definition && typeof config.credential_definition === "object" && true && "type" in config.credential_definition && Array.isArray(config.credential_definition.type);
|
|
1638
|
+
if (hasValidCredentialDefinition) {
|
|
1639
|
+
const credDef = config.credential_definition;
|
|
1640
|
+
isTypeMatch = normalizedTypes.every((type) => credDef.type.includes(type));
|
|
1541
1641
|
} else if (isW3cCredentialSupported(config) && "type" in config && Array.isArray(config.type)) {
|
|
1542
1642
|
isTypeMatch = normalizedTypes.every((type) => config.type.includes(type));
|
|
1543
|
-
} else if (isW3cCredentialSupported(config) && "types" in config) {
|
|
1544
|
-
isTypeMatch = normalizedTypes.every((type) => config.types
|
|
1643
|
+
} else if (isW3cCredentialSupported(config) && "types" in config && Array.isArray(config.types)) {
|
|
1644
|
+
isTypeMatch = normalizedTypes.every((type) => config.types.includes(type));
|
|
1545
1645
|
}
|
|
1546
1646
|
}
|
|
1547
1647
|
}
|
|
@@ -1549,7 +1649,17 @@ function getSupportedCredential(opts) {
|
|
|
1549
1649
|
return isTypeMatch && isFormatMatch ? config : void 0;
|
|
1550
1650
|
}
|
|
1551
1651
|
__name(filterMatchingConfig, "filterMatchingConfig");
|
|
1552
|
-
if (
|
|
1652
|
+
if (credentialConfigurationsV15) {
|
|
1653
|
+
return Object.entries(credentialConfigurationsV15).reduce((filteredConfigs, [id, config]) => {
|
|
1654
|
+
if (filterMatchingConfig(config)) {
|
|
1655
|
+
filteredConfigs[id] = config;
|
|
1656
|
+
if (!config.id) {
|
|
1657
|
+
config.id = id;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
return filteredConfigs;
|
|
1661
|
+
}, {});
|
|
1662
|
+
} else if (credentialConfigurationsV13) {
|
|
1553
1663
|
return Object.entries(credentialConfigurationsV13).reduce((filteredConfigs, [id, config]) => {
|
|
1554
1664
|
if (filterMatchingConfig(config)) {
|
|
1555
1665
|
filteredConfigs[id] = config;
|
|
@@ -1612,6 +1722,51 @@ function getIssuerName(url, credentialIssuerMetadata) {
|
|
|
1612
1722
|
}
|
|
1613
1723
|
__name(getIssuerName, "getIssuerName");
|
|
1614
1724
|
|
|
1725
|
+
// lib/functions/FormatUtils.ts
|
|
1726
|
+
init_cjs_shims();
|
|
1727
|
+
function isFormat(formatObject, format) {
|
|
1728
|
+
return formatObject.format === format;
|
|
1729
|
+
}
|
|
1730
|
+
__name(isFormat, "isFormat");
|
|
1731
|
+
function isNotFormat(formatObject, format) {
|
|
1732
|
+
return formatObject.format !== format;
|
|
1733
|
+
}
|
|
1734
|
+
__name(isNotFormat, "isNotFormat");
|
|
1735
|
+
var isUniformFormat = /* @__PURE__ */ __name((format) => {
|
|
1736
|
+
return [
|
|
1737
|
+
"jwt_vc_json",
|
|
1738
|
+
"jwt_vc_json-ld",
|
|
1739
|
+
"ldp_vc",
|
|
1740
|
+
"dc+sd-jwt",
|
|
1741
|
+
"mso_mdoc"
|
|
1742
|
+
].includes(format);
|
|
1743
|
+
}, "isUniformFormat");
|
|
1744
|
+
function getUniformFormat(format) {
|
|
1745
|
+
if (isUniformFormat(format)) {
|
|
1746
|
+
return format;
|
|
1747
|
+
}
|
|
1748
|
+
if (format.toLocaleLowerCase() === "jwt_vc" || format.toLocaleLowerCase() === "jwt") {
|
|
1749
|
+
return "jwt_vc";
|
|
1750
|
+
}
|
|
1751
|
+
if (format === "ldp_vc" || format === "ldp") {
|
|
1752
|
+
return "ldp_vc";
|
|
1753
|
+
}
|
|
1754
|
+
throw new Error(`Invalid format: ${format}`);
|
|
1755
|
+
}
|
|
1756
|
+
__name(getUniformFormat, "getUniformFormat");
|
|
1757
|
+
function getFormatForVersion(format, version) {
|
|
1758
|
+
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
|
+
return uniformFormat;
|
|
1767
|
+
}
|
|
1768
|
+
__name(getFormatForVersion, "getFormatForVersion");
|
|
1769
|
+
|
|
1615
1770
|
// lib/functions/ProofUtil.ts
|
|
1616
1771
|
init_cjs_shims();
|
|
1617
1772
|
var import_ssi_types3 = require("@sphereon/ssi-types");
|
|
@@ -1623,7 +1778,7 @@ var createProofOfPossession = /* @__PURE__ */ __name(async (popMode, callbacks,
|
|
|
1623
1778
|
throw new Error(BAD_PARAMS);
|
|
1624
1779
|
}
|
|
1625
1780
|
const jwtPayload = createJWT(popMode, jwtProps, existingJwt);
|
|
1626
|
-
const jwt = await callbacks.signCallback(jwtPayload, jwtPayload.header.kid);
|
|
1781
|
+
const jwt = await callbacks.signCallback(jwtPayload, jwtPayload.header.kid, popMode === "pop");
|
|
1627
1782
|
const proof = {
|
|
1628
1783
|
proof_type: "jwt",
|
|
1629
1784
|
jwt
|
|
@@ -1779,7 +1934,7 @@ var toAuthorizationResponsePayload = /* @__PURE__ */ __name((input) => {
|
|
|
1779
1934
|
|
|
1780
1935
|
// lib/functions/RandomUtils.ts
|
|
1781
1936
|
init_cjs_shims();
|
|
1782
|
-
var
|
|
1937
|
+
var import_oid4vc_common2 = require("@sphereon/oid4vc-common");
|
|
1783
1938
|
var u8a = __toESM(require("uint8arrays"), 1);
|
|
1784
1939
|
var import_randomBytes = __toESM(require_randomBytes(), 1);
|
|
1785
1940
|
var { toString } = u8a;
|
|
@@ -1800,7 +1955,7 @@ var createCodeChallenge = /* @__PURE__ */ __name((codeVerifier, codeChallengeMet
|
|
|
1800
1955
|
if (codeChallengeMethod === CodeChallengeMethod.plain) {
|
|
1801
1956
|
return codeVerifier;
|
|
1802
1957
|
} else if (!codeChallengeMethod || codeChallengeMethod === CodeChallengeMethod.S256) {
|
|
1803
|
-
return toString((0,
|
|
1958
|
+
return toString((0, import_oid4vc_common2.defaultHasher)(codeVerifier, "sha256"), "base64url");
|
|
1804
1959
|
} else {
|
|
1805
1960
|
throw Error(`code challenge method ${codeChallengeMethod} not implemented`);
|
|
1806
1961
|
}
|