@openid4vc/openid4vci 0.3.0-alpha-20250602121005 → 0.3.0-alpha-20250704115435
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.js +56 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -43,9 +43,9 @@ __export(index_exports, {
|
|
|
43
43
|
determineAuthorizationServerForCredentialOffer: () => determineAuthorizationServerForCredentialOffer,
|
|
44
44
|
extractScopesForCredentialConfigurationIds: () => extractScopesForCredentialConfigurationIds,
|
|
45
45
|
getCredentialConfigurationsMatchingRequestFormat: () => getCredentialConfigurationsMatchingRequestFormat,
|
|
46
|
-
getGlobalConfig: () =>
|
|
46
|
+
getGlobalConfig: () => import_utils21.getGlobalConfig,
|
|
47
47
|
parseKeyAttestationJwt: () => parseKeyAttestationJwt,
|
|
48
|
-
setGlobalConfig: () =>
|
|
48
|
+
setGlobalConfig: () => import_utils21.setGlobalConfig,
|
|
49
49
|
verifyKeyAttestationJwt: () => verifyKeyAttestationJwt
|
|
50
50
|
});
|
|
51
51
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -261,7 +261,7 @@ async function createCredentialOffer(options) {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
// src/index.ts
|
|
264
|
-
var
|
|
264
|
+
var import_utils21 = require("@openid4vc/utils");
|
|
265
265
|
|
|
266
266
|
// src/credential-request/credential-request-configurations.ts
|
|
267
267
|
var import_utils6 = require("@openid4vc/utils");
|
|
@@ -957,12 +957,12 @@ var Openid4vciError = class extends Error {
|
|
|
957
957
|
};
|
|
958
958
|
|
|
959
959
|
// src/error/Openid4vciRetrieveCredentialsError.ts
|
|
960
|
+
var import_utils7 = require("@openid4vc/utils");
|
|
960
961
|
var Openid4vciRetrieveCredentialsError = class extends Openid4vciError {
|
|
961
962
|
constructor(message, response, responseText) {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
${JSON.stringify(
|
|
965
|
-
);
|
|
963
|
+
const errorData = response.credentialResponseResult?.data ?? response.credentialErrorResponseResult?.data ?? (response.credentialResponseResult?.error ? (0, import_utils7.formatZodError)(response.credentialResponseResult.error) : void 0) ?? responseText;
|
|
964
|
+
super(`${message}
|
|
965
|
+
${JSON.stringify(errorData, null, 2)}`);
|
|
966
966
|
this.response = response;
|
|
967
967
|
}
|
|
968
968
|
};
|
|
@@ -978,15 +978,15 @@ var Openid4vciSendNotificationError = class extends Openid4vciError {
|
|
|
978
978
|
// src/key-attestation/key-attestation.ts
|
|
979
979
|
var import_oauth26 = require("@openid4vc/oauth2");
|
|
980
980
|
var import_oauth27 = require("@openid4vc/oauth2");
|
|
981
|
-
var
|
|
981
|
+
var import_utils8 = require("@openid4vc/utils");
|
|
982
982
|
async function createKeyAttestationJwt(options) {
|
|
983
|
-
const header = (0,
|
|
983
|
+
const header = (0, import_utils8.parseWithErrorHandling)(zKeyAttestationJwtHeader, {
|
|
984
984
|
...(0, import_oauth26.jwtHeaderFromJwtSigner)(options.signer),
|
|
985
985
|
typ: "keyattestation+jwt"
|
|
986
986
|
});
|
|
987
|
-
const payload = (0,
|
|
988
|
-
iat: (0,
|
|
989
|
-
exp: options.expiresAt ? (0,
|
|
987
|
+
const payload = (0, import_utils8.parseWithErrorHandling)(zKeyAttestationJwtPayloadForUse(options.use), {
|
|
988
|
+
iat: (0, import_utils8.dateToSeconds)(options.issuedAt),
|
|
989
|
+
exp: options.expiresAt ? (0, import_utils8.dateToSeconds)(options.expiresAt) : void 0,
|
|
990
990
|
nonce: options.nonce,
|
|
991
991
|
attested_keys: options.attestedKeys,
|
|
992
992
|
user_authentication: options.userAuthentication,
|
|
@@ -1029,7 +1029,7 @@ async function verifyKeyAttestationJwt(options) {
|
|
|
1029
1029
|
|
|
1030
1030
|
// src/metadata/credential-issuer/credential-configurations.ts
|
|
1031
1031
|
var import_oauth28 = require("@openid4vc/oauth2");
|
|
1032
|
-
var
|
|
1032
|
+
var import_utils9 = require("@openid4vc/utils");
|
|
1033
1033
|
function extractScopesForCredentialConfigurationIds(options) {
|
|
1034
1034
|
const scopes = /* @__PURE__ */ new Set();
|
|
1035
1035
|
for (const credentialConfigurationId of options.credentialConfigurationIds) {
|
|
@@ -1060,7 +1060,7 @@ function credentialsSupportedToCredentialConfigurationsSupported(credentialsSupp
|
|
|
1060
1060
|
}
|
|
1061
1061
|
const parseResult = zCredentialConfigurationSupportedDraft11To14.safeParse(credentialSupported);
|
|
1062
1062
|
if (!parseResult.success) {
|
|
1063
|
-
throw new
|
|
1063
|
+
throw new import_utils9.ValidationError(
|
|
1064
1064
|
`Error transforming credential supported with id '${credentialSupported.id}' to credential configuration supported format`,
|
|
1065
1065
|
parseResult.error
|
|
1066
1066
|
);
|
|
@@ -1074,25 +1074,25 @@ function credentialsSupportedToCredentialConfigurationsSupported(credentialsSupp
|
|
|
1074
1074
|
var import_oauth218 = require("@openid4vc/oauth2");
|
|
1075
1075
|
|
|
1076
1076
|
// src/credential-request/format-payload.ts
|
|
1077
|
-
var
|
|
1077
|
+
var import_utils10 = require("@openid4vc/utils");
|
|
1078
1078
|
function getCredentialRequestFormatPayloadForCredentialConfigurationId(options) {
|
|
1079
1079
|
const credentialConfiguration = getCredentialConfigurationSupportedById(
|
|
1080
1080
|
options.issuerMetadata.credentialIssuer.credential_configurations_supported,
|
|
1081
1081
|
options.credentialConfigurationId
|
|
1082
1082
|
);
|
|
1083
|
-
if ((0,
|
|
1083
|
+
if ((0, import_utils10.zIs)(zSdJwtVcCredentialIssuerMetadataDraft14, credentialConfiguration)) {
|
|
1084
1084
|
return {
|
|
1085
1085
|
format: credentialConfiguration.format,
|
|
1086
1086
|
vct: credentialConfiguration.vct
|
|
1087
1087
|
};
|
|
1088
1088
|
}
|
|
1089
|
-
if ((0,
|
|
1089
|
+
if ((0, import_utils10.zIs)(zMsoMdocCredentialIssuerMetadata, credentialConfiguration) || (0, import_utils10.zIs)(zMsoMdocCredentialIssuerMetadataDraft14, credentialConfiguration)) {
|
|
1090
1090
|
return {
|
|
1091
1091
|
format: credentialConfiguration.format,
|
|
1092
1092
|
doctype: credentialConfiguration.doctype
|
|
1093
1093
|
};
|
|
1094
1094
|
}
|
|
1095
|
-
if ((0,
|
|
1095
|
+
if ((0, import_utils10.zIs)(zLdpVcCredentialIssuerMetadata, credentialConfiguration) || (0, import_utils10.zIs)(zLdpVcCredentialIssuerMetadataDraft14, credentialConfiguration)) {
|
|
1096
1096
|
return {
|
|
1097
1097
|
format: credentialConfiguration.format,
|
|
1098
1098
|
credential_definition: {
|
|
@@ -1101,7 +1101,7 @@ function getCredentialRequestFormatPayloadForCredentialConfigurationId(options)
|
|
|
1101
1101
|
}
|
|
1102
1102
|
};
|
|
1103
1103
|
}
|
|
1104
|
-
if ((0,
|
|
1104
|
+
if ((0, import_utils10.zIs)(zJwtVcJsonLdCredentialIssuerMetadata, credentialConfiguration) || (0, import_utils10.zIs)(zJwtVcJsonLdCredentialIssuerMetadataDraft14, credentialConfiguration)) {
|
|
1105
1105
|
return {
|
|
1106
1106
|
format: credentialConfiguration.format,
|
|
1107
1107
|
credential_definition: {
|
|
@@ -1110,7 +1110,7 @@ function getCredentialRequestFormatPayloadForCredentialConfigurationId(options)
|
|
|
1110
1110
|
}
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
|
-
if ((0,
|
|
1113
|
+
if ((0, import_utils10.zIs)(zJwtVcJsonCredentialIssuerMetadata, credentialConfiguration) || (0, import_utils10.zIs)(zJwtVcJsonCredentialIssuerMetadataDraft14, credentialConfiguration)) {
|
|
1114
1114
|
return {
|
|
1115
1115
|
format: credentialConfiguration.format,
|
|
1116
1116
|
credential_definition: {
|
|
@@ -1118,7 +1118,7 @@ function getCredentialRequestFormatPayloadForCredentialConfigurationId(options)
|
|
|
1118
1118
|
}
|
|
1119
1119
|
};
|
|
1120
1120
|
}
|
|
1121
|
-
if ((0,
|
|
1121
|
+
if ((0, import_utils10.zIs)(zSdJwtDcCredentialIssuerMetadata, credentialConfiguration)) {
|
|
1122
1122
|
throw new Openid4vciError(
|
|
1123
1123
|
`Credential configuration id '${options.credentialConfigurationId}' with format ${zSdJwtVcFormatIdentifier.value} does not support credential request based on 'format'. Use 'credential_configuration_id' directly.`
|
|
1124
1124
|
);
|
|
@@ -1130,7 +1130,7 @@ function getCredentialRequestFormatPayloadForCredentialConfigurationId(options)
|
|
|
1130
1130
|
|
|
1131
1131
|
// src/credential-request/retrieve-credentials.ts
|
|
1132
1132
|
var import_oauth212 = require("@openid4vc/oauth2");
|
|
1133
|
-
var
|
|
1133
|
+
var import_utils12 = require("@openid4vc/utils");
|
|
1134
1134
|
|
|
1135
1135
|
// src/credential-request/z-credential-request.ts
|
|
1136
1136
|
var import_zod16 = __toESM(require("zod"));
|
|
@@ -1141,7 +1141,7 @@ var import_zod15 = __toESM(require("zod"));
|
|
|
1141
1141
|
|
|
1142
1142
|
// src/formats/proof-type/jwt/z-jwt-proof-type.ts
|
|
1143
1143
|
var import_oauth29 = require("@openid4vc/oauth2");
|
|
1144
|
-
var
|
|
1144
|
+
var import_utils11 = require("@openid4vc/utils");
|
|
1145
1145
|
var import_zod13 = __toESM(require("zod"));
|
|
1146
1146
|
var zJwtProofTypeIdentifier = import_zod13.default.literal("jwt");
|
|
1147
1147
|
var jwtProofTypeIdentifier = zJwtProofTypeIdentifier.value;
|
|
@@ -1161,8 +1161,8 @@ var zCredentialRequestJwtProofTypeHeader = import_oauth29.zJwtHeader.merge(
|
|
|
1161
1161
|
});
|
|
1162
1162
|
var zCredentialRequestJwtProofTypePayload = import_zod13.default.object({
|
|
1163
1163
|
...import_oauth29.zJwtPayload.shape,
|
|
1164
|
-
aud:
|
|
1165
|
-
iat:
|
|
1164
|
+
aud: import_utils11.zHttpsUrl,
|
|
1165
|
+
iat: import_utils11.zInteger
|
|
1166
1166
|
}).passthrough();
|
|
1167
1167
|
|
|
1168
1168
|
// src/formats/proof-type/attestation/z-attestation-proof-type.ts
|
|
@@ -1412,7 +1412,7 @@ async function retrieveCredentialsWithFormat(options) {
|
|
|
1412
1412
|
}
|
|
1413
1413
|
async function retrieveCredentials(options) {
|
|
1414
1414
|
const credentialEndpoint = options.issuerMetadata.credentialIssuer.credential_endpoint;
|
|
1415
|
-
let credentialRequest = (0,
|
|
1415
|
+
let credentialRequest = (0, import_utils12.parseWithErrorHandling)(
|
|
1416
1416
|
zCredentialRequest,
|
|
1417
1417
|
options.credentialRequest,
|
|
1418
1418
|
"Error validating credential request"
|
|
@@ -1432,7 +1432,7 @@ async function retrieveCredentials(options) {
|
|
|
1432
1432
|
}
|
|
1433
1433
|
}
|
|
1434
1434
|
if (options.issuerMetadata.originalDraftVersion === "Draft11" /* Draft11 */) {
|
|
1435
|
-
credentialRequest = (0,
|
|
1435
|
+
credentialRequest = (0, import_utils12.parseWithErrorHandling)(
|
|
1436
1436
|
zCredentialRequestDraft14To11,
|
|
1437
1437
|
credentialRequest,
|
|
1438
1438
|
`Error transforming credential request from ${"Draft14" /* Draft14 */} to ${"Draft11" /* Draft11 */}`
|
|
@@ -1446,19 +1446,19 @@ async function retrieveCredentials(options) {
|
|
|
1446
1446
|
requestOptions: {
|
|
1447
1447
|
method: "POST",
|
|
1448
1448
|
headers: {
|
|
1449
|
-
"Content-Type":
|
|
1449
|
+
"Content-Type": import_utils12.ContentType.Json
|
|
1450
1450
|
},
|
|
1451
1451
|
body: JSON.stringify(credentialRequest)
|
|
1452
1452
|
}
|
|
1453
1453
|
});
|
|
1454
1454
|
if (!resourceResponse.ok) {
|
|
1455
|
-
const credentialErrorResponseResult = (0,
|
|
1455
|
+
const credentialErrorResponseResult = (0, import_utils12.isResponseContentType)(import_utils12.ContentType.Json, resourceResponse.response) ? zCredentialErrorResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1456
1456
|
return {
|
|
1457
1457
|
...resourceResponse,
|
|
1458
1458
|
credentialErrorResponseResult
|
|
1459
1459
|
};
|
|
1460
1460
|
}
|
|
1461
|
-
const credentialResponseResult = (0,
|
|
1461
|
+
const credentialResponseResult = (0, import_utils12.isResponseContentType)(import_utils12.ContentType.Json, resourceResponse.response) ? zCredentialResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1462
1462
|
if (!credentialResponseResult?.success) {
|
|
1463
1463
|
return {
|
|
1464
1464
|
...resourceResponse,
|
|
@@ -1475,17 +1475,17 @@ async function retrieveCredentials(options) {
|
|
|
1475
1475
|
// src/formats/proof-type/jwt/jwt-proof-type.ts
|
|
1476
1476
|
var import_oauth213 = require("@openid4vc/oauth2");
|
|
1477
1477
|
var import_oauth214 = require("@openid4vc/oauth2");
|
|
1478
|
-
var
|
|
1478
|
+
var import_utils13 = require("@openid4vc/utils");
|
|
1479
1479
|
async function createCredentialRequestJwtProof(options) {
|
|
1480
|
-
const header = (0,
|
|
1480
|
+
const header = (0, import_utils13.parseWithErrorHandling)(zCredentialRequestJwtProofTypeHeader, {
|
|
1481
1481
|
...(0, import_oauth213.jwtHeaderFromJwtSigner)(options.signer),
|
|
1482
1482
|
key_attestation: options.keyAttestationJwt,
|
|
1483
1483
|
typ: "openid4vci-proof+jwt"
|
|
1484
1484
|
});
|
|
1485
|
-
const payload = (0,
|
|
1485
|
+
const payload = (0, import_utils13.parseWithErrorHandling)(zCredentialRequestJwtProofTypePayload, {
|
|
1486
1486
|
nonce: options.nonce,
|
|
1487
1487
|
aud: options.credentialIssuer,
|
|
1488
|
-
iat: (0,
|
|
1488
|
+
iat: (0, import_utils13.dateToSeconds)(options.issuedAt),
|
|
1489
1489
|
iss: options.clientId
|
|
1490
1490
|
});
|
|
1491
1491
|
const { jwt, signerJwk } = await options.callbacks.signJwt(options.signer, { header, payload });
|
|
@@ -1558,7 +1558,7 @@ async function verifyCredentialRequestJwtProof(options) {
|
|
|
1558
1558
|
|
|
1559
1559
|
// src/metadata/fetch-issuer-metadata.ts
|
|
1560
1560
|
var import_oauth215 = require("@openid4vc/oauth2");
|
|
1561
|
-
var
|
|
1561
|
+
var import_utils14 = require("@openid4vc/utils");
|
|
1562
1562
|
async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
1563
1563
|
const allowAuthorizationMetadataFromCredentialIssuerMetadata = options?.allowAuthorizationMetadataFromCredentialIssuerMetadata ?? true;
|
|
1564
1564
|
const credentialIssuerMetadataWithDraftVersion = await fetchCredentialIssuerMetadata(credentialIssuer, options?.fetch);
|
|
@@ -1574,7 +1574,7 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
|
1574
1574
|
}
|
|
1575
1575
|
let authorizationServerMetadata = await (0, import_oauth215.fetchAuthorizationServerMetadata)(authorizationServer, options?.fetch);
|
|
1576
1576
|
if (!authorizationServerMetadata && authorizationServer === credentialIssuer && allowAuthorizationMetadataFromCredentialIssuerMetadata) {
|
|
1577
|
-
authorizationServerMetadata = (0,
|
|
1577
|
+
authorizationServerMetadata = (0, import_utils14.parseWithErrorHandling)(
|
|
1578
1578
|
import_oauth215.zAuthorizationServerMetadata,
|
|
1579
1579
|
{
|
|
1580
1580
|
token_endpoint: credentialIssuerMetadata.token_endpoint,
|
|
@@ -1599,26 +1599,26 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
|
1599
1599
|
|
|
1600
1600
|
// src/nonce/nonce-request.ts
|
|
1601
1601
|
var import_oauth216 = require("@openid4vc/oauth2");
|
|
1602
|
-
var
|
|
1602
|
+
var import_utils16 = require("@openid4vc/utils");
|
|
1603
1603
|
|
|
1604
1604
|
// src/nonce/z-nonce.ts
|
|
1605
|
-
var
|
|
1605
|
+
var import_utils15 = require("@openid4vc/utils");
|
|
1606
1606
|
var import_zod19 = __toESM(require("zod"));
|
|
1607
1607
|
var zNonceResponse = import_zod19.default.object({
|
|
1608
1608
|
c_nonce: import_zod19.default.string(),
|
|
1609
|
-
c_nonce_expires_in: import_zod19.default.optional(
|
|
1609
|
+
c_nonce_expires_in: import_zod19.default.optional(import_utils15.zInteger)
|
|
1610
1610
|
}).passthrough();
|
|
1611
1611
|
|
|
1612
1612
|
// src/nonce/nonce-request.ts
|
|
1613
1613
|
async function requestNonce(options) {
|
|
1614
|
-
const fetchWithZod = (0,
|
|
1614
|
+
const fetchWithZod = (0, import_utils16.createZodFetcher)(options?.fetch);
|
|
1615
1615
|
const nonceEndpoint = options.issuerMetadata.credentialIssuer.nonce_endpoint;
|
|
1616
1616
|
if (!nonceEndpoint) {
|
|
1617
1617
|
throw new Openid4vciError(
|
|
1618
1618
|
`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not have a nonce endpoint.`
|
|
1619
1619
|
);
|
|
1620
1620
|
}
|
|
1621
|
-
const { response, result } = await fetchWithZod(zNonceResponse,
|
|
1621
|
+
const { response, result } = await fetchWithZod(zNonceResponse, import_utils16.ContentType.Json, nonceEndpoint, {
|
|
1622
1622
|
method: "POST"
|
|
1623
1623
|
});
|
|
1624
1624
|
if (!response.ok || !result) {
|
|
@@ -1629,12 +1629,12 @@ async function requestNonce(options) {
|
|
|
1629
1629
|
);
|
|
1630
1630
|
}
|
|
1631
1631
|
if (!result.success) {
|
|
1632
|
-
throw new
|
|
1632
|
+
throw new import_utils16.ValidationError("Error parsing nonce response", result.error);
|
|
1633
1633
|
}
|
|
1634
1634
|
return result.data;
|
|
1635
1635
|
}
|
|
1636
1636
|
function createNonceResponse(options) {
|
|
1637
|
-
return (0,
|
|
1637
|
+
return (0, import_utils16.parseWithErrorHandling)(zNonceResponse, {
|
|
1638
1638
|
c_nonce: options.cNonce,
|
|
1639
1639
|
c_nonce_expires_in: options.cNonceExpiresIn,
|
|
1640
1640
|
...options.additionalPayload
|
|
@@ -1643,7 +1643,7 @@ function createNonceResponse(options) {
|
|
|
1643
1643
|
|
|
1644
1644
|
// src/notification/notification.ts
|
|
1645
1645
|
var import_oauth217 = require("@openid4vc/oauth2");
|
|
1646
|
-
var
|
|
1646
|
+
var import_utils17 = require("@openid4vc/utils");
|
|
1647
1647
|
|
|
1648
1648
|
// src/notification/z-notification.ts
|
|
1649
1649
|
var import_zod20 = __toESM(require("zod"));
|
|
@@ -1665,7 +1665,7 @@ async function sendNotifcation(options) {
|
|
|
1665
1665
|
`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not have a notification endpiont configured.`
|
|
1666
1666
|
);
|
|
1667
1667
|
}
|
|
1668
|
-
const notificationRequest = (0,
|
|
1668
|
+
const notificationRequest = (0, import_utils17.parseWithErrorHandling)(
|
|
1669
1669
|
zNotificationRequest,
|
|
1670
1670
|
{
|
|
1671
1671
|
event: options.notification.event,
|
|
@@ -1682,13 +1682,13 @@ async function sendNotifcation(options) {
|
|
|
1682
1682
|
requestOptions: {
|
|
1683
1683
|
method: "POST",
|
|
1684
1684
|
headers: {
|
|
1685
|
-
"Content-Type":
|
|
1685
|
+
"Content-Type": import_utils17.ContentType.Json
|
|
1686
1686
|
},
|
|
1687
1687
|
body: JSON.stringify(notificationRequest)
|
|
1688
1688
|
}
|
|
1689
1689
|
});
|
|
1690
1690
|
if (!resourceResponse.ok) {
|
|
1691
|
-
const notificationErrorResponseResult = (0,
|
|
1691
|
+
const notificationErrorResponseResult = (0, import_utils17.isResponseContentType)(import_utils17.ContentType.Json, resourceResponse.response) ? zNotificationErrorResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1692
1692
|
return {
|
|
1693
1693
|
...resourceResponse,
|
|
1694
1694
|
notificationErrorResponseResult
|
|
@@ -2075,12 +2075,12 @@ var Openid4vciClient = class {
|
|
|
2075
2075
|
|
|
2076
2076
|
// src/Openid4vciIssuer.ts
|
|
2077
2077
|
var import_oauth219 = require("@openid4vc/oauth2");
|
|
2078
|
-
var
|
|
2078
|
+
var import_utils20 = require("@openid4vc/utils");
|
|
2079
2079
|
|
|
2080
2080
|
// src/credential-request/credential-response.ts
|
|
2081
|
-
var
|
|
2081
|
+
var import_utils18 = require("@openid4vc/utils");
|
|
2082
2082
|
function createCredentialResponse(options) {
|
|
2083
|
-
const credentialResponse = (0,
|
|
2083
|
+
const credentialResponse = (0, import_utils18.parseWithErrorHandling)(zCredentialResponse, {
|
|
2084
2084
|
c_nonce: options.cNonce,
|
|
2085
2085
|
c_nonce_expires_in: options.cNonceExpiresInSeconds,
|
|
2086
2086
|
credential: options.credential,
|
|
@@ -2095,10 +2095,10 @@ function createCredentialResponse(options) {
|
|
|
2095
2095
|
}
|
|
2096
2096
|
|
|
2097
2097
|
// src/credential-request/parse-credential-request.ts
|
|
2098
|
-
var
|
|
2098
|
+
var import_utils19 = require("@openid4vc/utils");
|
|
2099
2099
|
var import_zod21 = __toESM(require("zod"));
|
|
2100
2100
|
function parseCredentialRequest(options) {
|
|
2101
|
-
const credentialRequest = (0,
|
|
2101
|
+
const credentialRequest = (0, import_utils19.parseWithErrorHandling)(
|
|
2102
2102
|
zCredentialRequest,
|
|
2103
2103
|
options.credentialRequest,
|
|
2104
2104
|
"Error validating credential request"
|
|
@@ -2141,7 +2141,7 @@ function parseCredentialRequest(options) {
|
|
|
2141
2141
|
)) {
|
|
2142
2142
|
return {
|
|
2143
2143
|
// Removes all claims that are not specific to this format
|
|
2144
|
-
format: (0,
|
|
2144
|
+
format: (0, import_utils19.parseWithErrorHandling)(
|
|
2145
2145
|
import_zod21.default.union(allCredentialRequestFormats),
|
|
2146
2146
|
credentialRequest,
|
|
2147
2147
|
"Unable to validate format specific properties from credential request"
|
|
@@ -2171,7 +2171,7 @@ var Openid4vciIssuer = class {
|
|
|
2171
2171
|
this.options = options;
|
|
2172
2172
|
}
|
|
2173
2173
|
getCredentialIssuerMetadataDraft11(credentialIssuerMetadata) {
|
|
2174
|
-
return (0,
|
|
2174
|
+
return (0, import_utils20.parseWithErrorHandling)(zCredentialIssuerMetadataWithDraft11, credentialIssuerMetadata);
|
|
2175
2175
|
}
|
|
2176
2176
|
getKnownCredentialConfigurationsSupported(credentialIssuerMetadata) {
|
|
2177
2177
|
return extractKnownCredentialConfigurationSupportedFormats(
|
|
@@ -2182,7 +2182,7 @@ var Openid4vciIssuer = class {
|
|
|
2182
2182
|
* Create issuer metadata and validates the structure is correct
|
|
2183
2183
|
*/
|
|
2184
2184
|
createCredentialIssuerMetadata(credentialIssuerMetadata) {
|
|
2185
|
-
return (0,
|
|
2185
|
+
return (0, import_utils20.parseWithErrorHandling)(
|
|
2186
2186
|
zCredentialIssuerMetadata,
|
|
2187
2187
|
credentialIssuerMetadata,
|
|
2188
2188
|
"Error validating credential issuer metadata"
|
|
@@ -2272,7 +2272,7 @@ var Openid4vciIssuer = class {
|
|
|
2272
2272
|
error: import_oauth219.Oauth2ErrorCodes.InvalidCredentialRequest,
|
|
2273
2273
|
error_description: (
|
|
2274
2274
|
// TODO: error should have a internalErrorMessage and a publicErrorMessage
|
|
2275
|
-
error instanceof
|
|
2275
|
+
error instanceof import_utils20.ValidationError ? error.message : "Invalid request"
|
|
2276
2276
|
)
|
|
2277
2277
|
},
|
|
2278
2278
|
{
|