@openid4vc/openid4vci 0.3.0-alpha-20251017122507 → 0.3.0-alpha-20251021082313
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.d.mts +387 -16
- package/dist/index.d.ts +387 -16
- package/dist/index.js +135 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import z from "zod";
|
|
|
4
4
|
|
|
5
5
|
//#region src/version.ts
|
|
6
6
|
let Openid4vciDraftVersion = /* @__PURE__ */ function(Openid4vciDraftVersion$1) {
|
|
7
|
-
Openid4vciDraftVersion$1["
|
|
7
|
+
Openid4vciDraftVersion$1["V1"] = "V1";
|
|
8
8
|
Openid4vciDraftVersion$1["Draft15"] = "Draft15";
|
|
9
9
|
Openid4vciDraftVersion$1["Draft14"] = "Draft14";
|
|
10
10
|
Openid4vciDraftVersion$1["Draft11"] = "Draft11";
|
|
@@ -304,7 +304,7 @@ const zLegacySdJwtVcFormatIdentifier = z.literal("vc+sd-jwt");
|
|
|
304
304
|
* of the OpenID for Verifiable Presentations specification. Please update your
|
|
305
305
|
* implementations accordingly.
|
|
306
306
|
*/
|
|
307
|
-
const
|
|
307
|
+
const zLegacySdJwtVcCredentialIssuerMetadataV1 = zCredentialConfigurationSupportedCommon.extend({
|
|
308
308
|
vct: z.string(),
|
|
309
309
|
format: zLegacySdJwtVcFormatIdentifier,
|
|
310
310
|
order: z.optional(z.array(z.string())),
|
|
@@ -581,7 +581,7 @@ const allCredentialIssuerMetadataFormats = [
|
|
|
581
581
|
zJwtVcJsonCredentialIssuerMetadata,
|
|
582
582
|
zSdJwtW3VcCredentialIssuerMetadata,
|
|
583
583
|
zSdJwtW3VcCredentialIssuerMetadataDraft15,
|
|
584
|
-
|
|
584
|
+
zLegacySdJwtVcCredentialIssuerMetadataV1,
|
|
585
585
|
zSdJwtDcCredentialIssuerMetadataDraft15,
|
|
586
586
|
zMsoMdocCredentialIssuerMetadataDraft15,
|
|
587
587
|
zJwtVcJsonLdCredentialIssuerMetadataDraft15,
|
|
@@ -613,7 +613,7 @@ const zCredentialIssuerMetadataDisplayEntry = z.object({
|
|
|
613
613
|
alt_text: z.string().optional()
|
|
614
614
|
}).loose().optional()
|
|
615
615
|
}).loose();
|
|
616
|
-
const
|
|
616
|
+
const zCredentialIssuerMetadataDraft14Draft15V1 = z.object({
|
|
617
617
|
credential_issuer: zHttpsUrl,
|
|
618
618
|
authorization_servers: z.array(zHttpsUrl).optional(),
|
|
619
619
|
credential_endpoint: zHttpsUrl,
|
|
@@ -626,7 +626,6 @@ const zCredentialIssuerMetadataDraft14Draft15Draft16 = z.object({
|
|
|
626
626
|
encryption_required: z.boolean()
|
|
627
627
|
}).loose().optional(),
|
|
628
628
|
batch_credential_issuance: z.object({ batch_size: z.number().positive() }).loose().optional(),
|
|
629
|
-
signed_metadata: zCompactJwt.optional(),
|
|
630
629
|
display: z.array(zCredentialIssuerMetadataDisplayEntry).optional(),
|
|
631
630
|
credential_configurations_supported: z.record(z.string(), zCredentialConfigurationSupportedWithFormats)
|
|
632
631
|
}).loose();
|
|
@@ -665,7 +664,7 @@ const zCredentialConfigurationSupportedDraft11To16 = z.object({
|
|
|
665
664
|
});
|
|
666
665
|
return z.NEVER;
|
|
667
666
|
}).pipe(zCredentialConfigurationSupportedWithFormats);
|
|
668
|
-
const
|
|
667
|
+
const zCredentialConfigurationSupportedV1ToDraft11 = zCredentialConfigurationSupportedWithFormats.transform(({ credential_metadata,...rest }) => ({
|
|
669
668
|
...credential_metadata,
|
|
670
669
|
...rest
|
|
671
670
|
})).and(z.object({ id: z.string() }).loose()).transform(({ id, credential_signing_alg_values_supported, display, proof_types_supported, scope,...rest }) => ({
|
|
@@ -706,17 +705,17 @@ const zCredentialIssuerMetadataDraft11To16 = z.object({
|
|
|
706
705
|
...authorization_server ? { authorization_servers: [authorization_server] } : {},
|
|
707
706
|
credential_configurations_supported: Object.fromEntries(credentials_supported.map((supported) => supported.id ? [supported.id, supported] : void 0).filter((i) => i !== void 0))
|
|
708
707
|
};
|
|
709
|
-
}).pipe(z.object({ credential_configurations_supported: z.record(z.string(), zCredentialConfigurationSupportedDraft11To16) }).loose()).pipe(
|
|
710
|
-
const zCredentialIssuerMetadataWithDraft11 =
|
|
708
|
+
}).pipe(z.object({ credential_configurations_supported: z.record(z.string(), zCredentialConfigurationSupportedDraft11To16) }).loose()).pipe(zCredentialIssuerMetadataDraft14Draft15V1);
|
|
709
|
+
const zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Draft15V1.transform((issuerMetadata) => ({
|
|
711
710
|
...issuerMetadata,
|
|
712
711
|
...issuerMetadata.authorization_servers ? { authorization_server: issuerMetadata.authorization_servers[0] } : {},
|
|
713
712
|
credentials_supported: Object.entries(issuerMetadata.credential_configurations_supported).map(([id, value]) => ({
|
|
714
713
|
...value,
|
|
715
714
|
id
|
|
716
715
|
}))
|
|
717
|
-
})).pipe(
|
|
718
|
-
const zCredentialIssuerMetadata = z.union([
|
|
719
|
-
const zCredentialIssuerMetadataWithDraftVersion = z.union([
|
|
716
|
+
})).pipe(zCredentialIssuerMetadataDraft14Draft15V1.extend({ credentials_supported: z.array(zCredentialConfigurationSupportedV1ToDraft11) }));
|
|
717
|
+
const zCredentialIssuerMetadata = z.union([zCredentialIssuerMetadataDraft14Draft15V1, zCredentialIssuerMetadataDraft11To16]);
|
|
718
|
+
const zCredentialIssuerMetadataWithDraftVersion = z.union([zCredentialIssuerMetadataDraft14Draft15V1.transform((credentialIssuerMetadata) => {
|
|
720
719
|
const credentialConfigurations = Object.values(credentialIssuerMetadata.credential_configurations_supported);
|
|
721
720
|
const isDraft15 = credentialConfigurations.some((configuration) => {
|
|
722
721
|
const knownConfiguration = configuration;
|
|
@@ -727,29 +726,83 @@ const zCredentialIssuerMetadataWithDraftVersion = z.union([zCredentialIssuerMeta
|
|
|
727
726
|
});
|
|
728
727
|
return {
|
|
729
728
|
credentialIssuerMetadata,
|
|
730
|
-
originalDraftVersion: credentialConfigurations.some((configuration) =>
|
|
731
|
-
return configuration.credential_metadata;
|
|
732
|
-
}) ? Openid4vciDraftVersion.Draft16 : isDraft15 ? Openid4vciDraftVersion.Draft15 : Openid4vciDraftVersion.Draft14
|
|
729
|
+
originalDraftVersion: credentialConfigurations.some((configuration) => configuration.credential_metadata) ? Openid4vciDraftVersion.V1 : isDraft15 ? Openid4vciDraftVersion.Draft15 : Openid4vciDraftVersion.Draft14
|
|
733
730
|
};
|
|
734
731
|
}), zCredentialIssuerMetadataDraft11To16.transform((credentialIssuerMetadata) => ({
|
|
735
732
|
credentialIssuerMetadata,
|
|
736
733
|
originalDraftVersion: Openid4vciDraftVersion.Draft11
|
|
737
734
|
}))]);
|
|
738
735
|
|
|
736
|
+
//#endregion
|
|
737
|
+
//#region src/metadata/credential-issuer/z-signed-credential-issuer-metadata.ts
|
|
738
|
+
const zSignedCredentialIssuerMetadataHeader = z.object({
|
|
739
|
+
...zJwtHeader.shape,
|
|
740
|
+
typ: z.literal("openidvci-issuer-metadata+jwt")
|
|
741
|
+
}).loose();
|
|
742
|
+
const zSignedCredentialIssuerMetadataPayload = z.object({
|
|
743
|
+
...zJwtPayload.shape,
|
|
744
|
+
iat: zInteger,
|
|
745
|
+
sub: z.string(),
|
|
746
|
+
...zCredentialIssuerMetadataDraft14Draft15V1.shape
|
|
747
|
+
}).loose();
|
|
748
|
+
|
|
739
749
|
//#endregion
|
|
740
750
|
//#region src/metadata/credential-issuer/credential-issuer-metadata.ts
|
|
741
751
|
const wellKnownCredentialIssuerSuffix = ".well-known/openid-credential-issuer";
|
|
742
752
|
/**
|
|
743
753
|
* @inheritdoc {@link fetchWellKnownMetadata}
|
|
744
754
|
*/
|
|
745
|
-
async function fetchCredentialIssuerMetadata(credentialIssuer,
|
|
755
|
+
async function fetchCredentialIssuerMetadata(credentialIssuer, options) {
|
|
746
756
|
const parsedIssuerUrl = new URL(credentialIssuer);
|
|
747
757
|
const legacyWellKnownMetadataUrl = joinUriParts(credentialIssuer, [wellKnownCredentialIssuerSuffix]);
|
|
748
758
|
const wellKnownMetadataUrl = joinUriParts(parsedIssuerUrl.origin, [wellKnownCredentialIssuerSuffix, parsedIssuerUrl.pathname]);
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
759
|
+
const acceptedContentType = options?.callbacks?.verifyJwt ? [ContentType.Jwt, ContentType.Json] : [ContentType.Json];
|
|
760
|
+
const responseSchema = zCredentialIssuerMetadataWithDraftVersion.or(zCompactJwt);
|
|
761
|
+
let result = await fetchWellKnownMetadata(wellKnownMetadataUrl, responseSchema, {
|
|
762
|
+
fetch: options?.callbacks?.fetch,
|
|
763
|
+
acceptedContentType
|
|
764
|
+
});
|
|
765
|
+
if (!result && legacyWellKnownMetadataUrl !== wellKnownMetadataUrl) result = await fetchWellKnownMetadata(legacyWellKnownMetadataUrl, responseSchema, {
|
|
766
|
+
fetch: options?.callbacks?.fetch,
|
|
767
|
+
acceptedContentType
|
|
768
|
+
});
|
|
769
|
+
let issuerMetadataWithVersion = null;
|
|
770
|
+
if (typeof result === "string") {
|
|
771
|
+
if (!options?.callbacks?.verifyJwt) throw new Oauth2Error(`Unable to verify signed credential issuer metadata, no 'verifyJwt' callback provided to fetch credential issuer metadata method.`);
|
|
772
|
+
const { header, payload, signature } = decodeJwt({
|
|
773
|
+
jwt: result,
|
|
774
|
+
headerSchema: zSignedCredentialIssuerMetadataHeader,
|
|
775
|
+
payloadSchema: zSignedCredentialIssuerMetadataPayload
|
|
776
|
+
});
|
|
777
|
+
if (payload.sub !== credentialIssuer) throw new Oauth2Error(`The 'sub' parameter '${payload.sub}' in the signed well known credential issuer metadata at '${wellKnownMetadataUrl}' does not match the provided credential issuer '${credentialIssuer}'.`);
|
|
778
|
+
const signer = jwtSignerFromJwt({
|
|
779
|
+
header,
|
|
780
|
+
payload
|
|
781
|
+
});
|
|
782
|
+
const verifyResult = await verifyJwt({
|
|
783
|
+
compact: result,
|
|
784
|
+
header,
|
|
785
|
+
payload,
|
|
786
|
+
verifyJwtCallback: options.callbacks.verifyJwt,
|
|
787
|
+
now: options.now,
|
|
788
|
+
signer,
|
|
789
|
+
errorMessage: "signed credential issuer metadata jwt verification failed"
|
|
790
|
+
});
|
|
791
|
+
issuerMetadataWithVersion = {
|
|
792
|
+
...parseWithErrorHandling(zCredentialIssuerMetadataWithDraftVersion, payload, "Unable to determine version for signed issuer metadata"),
|
|
793
|
+
signed: {
|
|
794
|
+
signer: verifyResult.signer,
|
|
795
|
+
jwt: {
|
|
796
|
+
header,
|
|
797
|
+
payload,
|
|
798
|
+
signature,
|
|
799
|
+
compact: result
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
} else if (result) issuerMetadataWithVersion = result;
|
|
804
|
+
if (issuerMetadataWithVersion && issuerMetadataWithVersion.credentialIssuerMetadata.credential_issuer !== credentialIssuer) throw new Oauth2Error(`The 'credential_issuer' parameter '${issuerMetadataWithVersion.credentialIssuerMetadata.credential_issuer}' in the well known credential issuer metadata at '${wellKnownMetadataUrl}' does not match the provided credential issuer '${credentialIssuer}'.`);
|
|
805
|
+
return issuerMetadataWithVersion;
|
|
753
806
|
}
|
|
754
807
|
/**
|
|
755
808
|
* Extract credential configuration supported entries where the `format` is known to this
|
|
@@ -908,7 +961,7 @@ function credentialsSupportedToCredentialConfigurationsSupported(credentialsSupp
|
|
|
908
961
|
//#region src/credential-request/format-payload.ts
|
|
909
962
|
function getCredentialRequestFormatPayloadForCredentialConfigurationId(options) {
|
|
910
963
|
const credentialConfiguration = getCredentialConfigurationSupportedById(options.issuerMetadata.credentialIssuer.credential_configurations_supported, options.credentialConfigurationId);
|
|
911
|
-
if (zIs(
|
|
964
|
+
if (zIs(zLegacySdJwtVcCredentialIssuerMetadataV1, credentialConfiguration) || zIs(zLegacySdJwtVcCredentialIssuerMetadataDraft14, credentialConfiguration)) return {
|
|
912
965
|
format: credentialConfiguration.format,
|
|
913
966
|
vct: credentialConfiguration.vct
|
|
914
967
|
};
|
|
@@ -1133,12 +1186,12 @@ const zOauth2ErrorResponse = z.object({
|
|
|
1133
1186
|
const zCredentialEncoding = z.union([z.string(), z.record(z.string(), z.any())]);
|
|
1134
1187
|
const zBaseCredentialResponse = z.object({
|
|
1135
1188
|
credentials: z.union([z.array(z.object({ credential: zCredentialEncoding })), z.array(zCredentialEncoding)]).optional(),
|
|
1136
|
-
|
|
1137
|
-
|
|
1189
|
+
notification_id: z.string().optional(),
|
|
1190
|
+
transaction_id: z.string().optional(),
|
|
1191
|
+
interval: z.number().int().positive().optional()
|
|
1138
1192
|
}).loose();
|
|
1139
1193
|
const zCredentialResponse = zBaseCredentialResponse.extend({
|
|
1140
1194
|
credential: z.optional(zCredentialEncoding),
|
|
1141
|
-
transaction_id: z.string().optional(),
|
|
1142
1195
|
c_nonce: z.string().optional(),
|
|
1143
1196
|
c_nonce_expires_in: z.number().int().optional()
|
|
1144
1197
|
}).loose().superRefine((value, ctx) => {
|
|
@@ -1165,15 +1218,26 @@ const zCredentialErrorResponse = z.object({
|
|
|
1165
1218
|
c_nonce: z.string().optional(),
|
|
1166
1219
|
c_nonce_expires_in: z.number().int().optional()
|
|
1167
1220
|
}).loose();
|
|
1168
|
-
const zDeferredCredentialResponse = zBaseCredentialResponse.
|
|
1169
|
-
const { credentials, interval } = value;
|
|
1170
|
-
|
|
1171
|
-
|
|
1221
|
+
const zDeferredCredentialResponse = zBaseCredentialResponse.superRefine((value, ctx) => {
|
|
1222
|
+
const { credentials, transaction_id, interval, notification_id } = value;
|
|
1223
|
+
if ([credentials, transaction_id].filter((i) => i !== void 0).length !== 1) ctx.addIssue({
|
|
1224
|
+
code: "custom",
|
|
1225
|
+
message: `Exactly one of 'credentials', or 'transaction_id' MUST be defined.`
|
|
1226
|
+
});
|
|
1227
|
+
if (transaction_id && !interval) ctx.addIssue({
|
|
1228
|
+
code: "custom",
|
|
1229
|
+
message: `'interval' MUST be defined when 'transaction_id' is defined.`
|
|
1230
|
+
});
|
|
1231
|
+
if (notification_id && credentials) ctx.addIssue({
|
|
1232
|
+
code: "custom",
|
|
1233
|
+
message: `'notification_id' MUST NOT be defined when 'credentials' is not defined.`
|
|
1234
|
+
});
|
|
1235
|
+
});
|
|
1172
1236
|
|
|
1173
1237
|
//#endregion
|
|
1174
1238
|
//#region src/credential-request/retrieve-credentials.ts
|
|
1175
1239
|
async function retrieveCredentialsWithCredentialConfigurationId(options) {
|
|
1176
|
-
if (options.issuerMetadata.originalDraftVersion !== Openid4vciDraftVersion.Draft15 && options.issuerMetadata.originalDraftVersion !== Openid4vciDraftVersion.
|
|
1240
|
+
if (options.issuerMetadata.originalDraftVersion !== Openid4vciDraftVersion.Draft15 && options.issuerMetadata.originalDraftVersion !== Openid4vciDraftVersion.V1) throw new Openid4vciError("Requesting credentials based on credential configuration ID is not supported in OpenID4VCI below draft 15. Make sure to provide the format and format specific claims in the request.");
|
|
1177
1241
|
getCredentialConfigurationSupportedById(options.issuerMetadata.credentialIssuer.credential_configurations_supported, options.credentialConfigurationId);
|
|
1178
1242
|
const credentialRequest = {
|
|
1179
1243
|
...options.additionalRequestPayload,
|
|
@@ -1190,7 +1254,7 @@ async function retrieveCredentialsWithCredentialConfigurationId(options) {
|
|
|
1190
1254
|
});
|
|
1191
1255
|
}
|
|
1192
1256
|
async function retrieveCredentialsWithFormat(options) {
|
|
1193
|
-
if (options.issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.Draft15 || options.issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.
|
|
1257
|
+
if (options.issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.Draft15 || options.issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.V1) throw new Openid4vciError("Requesting credentials based on format is not supported on OpenID4VCI above draft 15. Provide the credential configuration id directly in the request.");
|
|
1194
1258
|
const credentialRequest = {
|
|
1195
1259
|
...options.formatPayload,
|
|
1196
1260
|
...options.additionalRequestPayload,
|
|
@@ -1272,7 +1336,7 @@ async function retrieveDeferredCredentials(options) {
|
|
|
1272
1336
|
deferredCredentialErrorResponseResult
|
|
1273
1337
|
};
|
|
1274
1338
|
}
|
|
1275
|
-
const deferredCredentialResponseResult = isResponseContentType(ContentType.Json, resourceResponse.response) ? zDeferredCredentialResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1339
|
+
const deferredCredentialResponseResult = isResponseContentType(ContentType.Json, resourceResponse.response) ? zDeferredCredentialResponse.refine((response) => response.credentials || response.transaction_id === options.transactionId, { error: `Transaction id in deferred credential response does not match transaction id in deferred credential request '${options.transactionId}'` }).safeParse(await resourceResponse.response.clone().json()) : void 0;
|
|
1276
1340
|
if (!deferredCredentialResponseResult?.success) return {
|
|
1277
1341
|
...resourceResponse,
|
|
1278
1342
|
ok: false,
|
|
@@ -1363,14 +1427,17 @@ async function verifyCredentialRequestJwtProof(options) {
|
|
|
1363
1427
|
//#region src/metadata/fetch-issuer-metadata.ts
|
|
1364
1428
|
async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
1365
1429
|
const allowAuthorizationMetadataFromCredentialIssuerMetadata = options?.allowAuthorizationMetadataFromCredentialIssuerMetadata ?? true;
|
|
1366
|
-
const credentialIssuerMetadataWithDraftVersion = await fetchCredentialIssuerMetadata(credentialIssuer,
|
|
1430
|
+
const credentialIssuerMetadataWithDraftVersion = await fetchCredentialIssuerMetadata(credentialIssuer, {
|
|
1431
|
+
callbacks: options?.callbacks,
|
|
1432
|
+
now: options?.now
|
|
1433
|
+
});
|
|
1367
1434
|
if (!credentialIssuerMetadataWithDraftVersion) throw new Oauth2Error(`Well known credential issuer metadata for issuer '${credentialIssuer}' not found.`);
|
|
1368
|
-
const { credentialIssuerMetadata, originalDraftVersion } = credentialIssuerMetadataWithDraftVersion;
|
|
1435
|
+
const { credentialIssuerMetadata, originalDraftVersion, signed } = credentialIssuerMetadataWithDraftVersion;
|
|
1369
1436
|
const authorizationServers = credentialIssuerMetadata.authorization_servers ?? [credentialIssuer];
|
|
1370
1437
|
const authoriationServersMetadata = [];
|
|
1371
1438
|
for (const authorizationServer of authorizationServers) {
|
|
1372
1439
|
if (options?.restrictToAuthorizationServers && !options.restrictToAuthorizationServers.includes(authorizationServer)) continue;
|
|
1373
|
-
let authorizationServerMetadata = await fetchAuthorizationServerMetadata(authorizationServer, options?.fetch);
|
|
1440
|
+
let authorizationServerMetadata = await fetchAuthorizationServerMetadata(authorizationServer, options?.callbacks.fetch);
|
|
1374
1441
|
if (!authorizationServerMetadata && authorizationServer === credentialIssuer && allowAuthorizationMetadataFromCredentialIssuerMetadata) authorizationServerMetadata = parseWithErrorHandling(zAuthorizationServerMetadata, {
|
|
1375
1442
|
token_endpoint: credentialIssuerMetadata.token_endpoint,
|
|
1376
1443
|
issuer: credentialIssuer
|
|
@@ -1381,6 +1448,7 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
|
|
|
1381
1448
|
return {
|
|
1382
1449
|
originalDraftVersion,
|
|
1383
1450
|
credentialIssuer: credentialIssuerMetadata,
|
|
1451
|
+
signedCredentialIssuer: signed,
|
|
1384
1452
|
authorizationServers: authoriationServersMetadata
|
|
1385
1453
|
};
|
|
1386
1454
|
}
|
|
@@ -1486,7 +1554,7 @@ var Openid4vciClient = class {
|
|
|
1486
1554
|
return resolveCredentialOffer(credentialOffer, { fetch: this.options.callbacks.fetch });
|
|
1487
1555
|
}
|
|
1488
1556
|
async resolveIssuerMetadata(credentialIssuer) {
|
|
1489
|
-
return resolveIssuerMetadata(credentialIssuer, {
|
|
1557
|
+
return resolveIssuerMetadata(credentialIssuer, { callbacks: this.options.callbacks });
|
|
1490
1558
|
}
|
|
1491
1559
|
/**
|
|
1492
1560
|
* Retrieve an authorization code for a presentation during issuance session
|
|
@@ -1690,7 +1758,7 @@ var Openid4vciClient = class {
|
|
|
1690
1758
|
*/
|
|
1691
1759
|
async retrieveCredentials({ issuerMetadata, proof, proofs, credentialConfigurationId, additionalRequestPayload, accessToken, dpop }) {
|
|
1692
1760
|
let credentialResponse;
|
|
1693
|
-
if (issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.Draft15 || issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.
|
|
1761
|
+
if (issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.Draft15 || issuerMetadata.originalDraftVersion === Openid4vciDraftVersion.V1) credentialResponse = await retrieveCredentialsWithCredentialConfigurationId({
|
|
1694
1762
|
accessToken,
|
|
1695
1763
|
credentialConfigurationId,
|
|
1696
1764
|
issuerMetadata,
|
|
@@ -1765,6 +1833,7 @@ function createDeferredCredentialResponse(options) {
|
|
|
1765
1833
|
return parseWithErrorHandling(zDeferredCredentialResponse, {
|
|
1766
1834
|
credentials: options.credentials,
|
|
1767
1835
|
notification_id: options.notificationId,
|
|
1836
|
+
transaction_id: options.transactionId,
|
|
1768
1837
|
interval: options.interval,
|
|
1769
1838
|
...options.additionalPayload
|
|
1770
1839
|
});
|
|
@@ -1820,6 +1889,28 @@ async function verifyCredentialRequestAttestationProof(options) {
|
|
|
1820
1889
|
});
|
|
1821
1890
|
}
|
|
1822
1891
|
|
|
1892
|
+
//#endregion
|
|
1893
|
+
//#region src/metadata/credential-issuer/signed-credential-issuer-metadata.ts
|
|
1894
|
+
async function createSignedCredentialIssuerMetadataJwt(options) {
|
|
1895
|
+
const header = parseWithErrorHandling(zSignedCredentialIssuerMetadataHeader, {
|
|
1896
|
+
...jwtHeaderFromJwtSigner(options.signer),
|
|
1897
|
+
typ: "openidvci-issuer-metadata+jwt"
|
|
1898
|
+
});
|
|
1899
|
+
const payload = parseWithErrorHandling(zSignedCredentialIssuerMetadataPayload, {
|
|
1900
|
+
...options.credentialIssuerMetadata,
|
|
1901
|
+
sub: options.credentialIssuerMetadata.credential_issuer,
|
|
1902
|
+
iat: dateToSeconds(options.issuedAt),
|
|
1903
|
+
exp: options.expiresAt ? dateToSeconds(options.expiresAt) : void 0,
|
|
1904
|
+
iss: options.issuer,
|
|
1905
|
+
...options.additionalPayload
|
|
1906
|
+
});
|
|
1907
|
+
const { jwt } = await options.callbacks.signJwt(options.signer, {
|
|
1908
|
+
header,
|
|
1909
|
+
payload
|
|
1910
|
+
});
|
|
1911
|
+
return jwt;
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1823
1914
|
//#endregion
|
|
1824
1915
|
//#region src/Openid4vciIssuer.ts
|
|
1825
1916
|
var Openid4vciIssuer = class {
|
|
@@ -1838,6 +1929,15 @@ var Openid4vciIssuer = class {
|
|
|
1838
1929
|
createCredentialIssuerMetadata(credentialIssuerMetadata) {
|
|
1839
1930
|
return parseWithErrorHandling(zCredentialIssuerMetadata, credentialIssuerMetadata, "Error validating credential issuer metadata");
|
|
1840
1931
|
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Validates credential issuer metadata structure is correct and creates signed credential issuer metadata JWT
|
|
1934
|
+
*/
|
|
1935
|
+
createSignedCredentialIssuerMetadataJwt(options) {
|
|
1936
|
+
return createSignedCredentialIssuerMetadataJwt({
|
|
1937
|
+
callbacks: this.options.callbacks,
|
|
1938
|
+
...options
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1841
1941
|
async createCredentialOffer(options) {
|
|
1842
1942
|
return createCredentialOffer({
|
|
1843
1943
|
callbacks: this.options.callbacks,
|