@credo-ts/openid4vc 0.6.0-pr-2195-20250322195244 → 0.6.0-pr-2324-20250625125220

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.
Files changed (56) hide show
  1. package/build/openid4vc-holder/OpenId4VcHolderApi.d.ts +10 -6
  2. package/build/openid4vc-holder/OpenId4VcHolderApi.js +2 -4
  3. package/build/openid4vc-holder/OpenId4VcHolderApi.js.map +1 -1
  4. package/build/openid4vc-holder/OpenId4VciHolderService.d.ts +14 -19
  5. package/build/openid4vc-holder/OpenId4VciHolderService.js +425 -203
  6. package/build/openid4vc-holder/OpenId4VciHolderService.js.map +1 -1
  7. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.d.ts +117 -37
  8. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js +1 -0
  9. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js.map +1 -1
  10. package/build/openid4vc-holder/OpenId4vpHolderService.js +24 -15
  11. package/build/openid4vc-holder/OpenId4vpHolderService.js.map +1 -1
  12. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +21 -0
  13. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +11 -0
  14. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +1 -1
  15. package/build/openid4vc-issuer/OpenId4VcIssuerService.d.ts +7 -3
  16. package/build/openid4vc-issuer/OpenId4VcIssuerService.js +387 -167
  17. package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +1 -1
  18. package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +67 -27
  19. package/build/openid4vc-issuer/index.d.ts +1 -1
  20. package/build/openid4vc-issuer/index.js +2 -1
  21. package/build/openid4vc-issuer/index.js.map +1 -1
  22. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.d.ts +29 -5
  23. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js +2 -0
  24. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js.map +1 -1
  25. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.d.ts +12 -7
  26. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js +15 -3
  27. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js.map +1 -1
  28. package/build/openid4vc-issuer/router/accessTokenEndpoint.js +41 -13
  29. package/build/openid4vc-issuer/router/accessTokenEndpoint.js.map +1 -1
  30. package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.js +102 -33
  31. package/build/openid4vc-issuer/router/authorizationChallengeEndpoint.js.map +1 -1
  32. package/build/openid4vc-issuer/router/credentialEndpoint.js +42 -10
  33. package/build/openid4vc-issuer/router/credentialEndpoint.js.map +1 -1
  34. package/build/openid4vc-issuer/router/jwksEndpoint.js +2 -2
  35. package/build/openid4vc-issuer/router/jwksEndpoint.js.map +1 -1
  36. package/build/openid4vc-issuer/util/txCode.d.ts +1 -1
  37. package/build/openid4vc-issuer/util/txCode.js +3 -1
  38. package/build/openid4vc-issuer/util/txCode.js.map +1 -1
  39. package/build/openid4vc-verifier/OpenId4VpVerifierService.d.ts +1 -1
  40. package/build/openid4vc-verifier/OpenId4VpVerifierService.js +70 -65
  41. package/build/openid4vc-verifier/OpenId4VpVerifierService.js.map +1 -1
  42. package/build/openid4vc-verifier/OpenId4VpVerifierServiceOptions.d.ts +7 -1
  43. package/build/shared/callbacks.d.ts +6 -4
  44. package/build/shared/callbacks.js +212 -69
  45. package/build/shared/callbacks.js.map +1 -1
  46. package/build/shared/models/CredentialHolderBinding.d.ts +65 -11
  47. package/build/shared/models/OpenId4VcJwtIssuer.d.ts +10 -5
  48. package/build/shared/models/OpenId4VciCredentialFormatProfile.d.ts +1 -0
  49. package/build/shared/models/OpenId4VciCredentialFormatProfile.js +1 -0
  50. package/build/shared/models/OpenId4VciCredentialFormatProfile.js.map +1 -1
  51. package/build/shared/router/tenants.js +2 -2
  52. package/build/shared/router/tenants.js.map +1 -1
  53. package/build/shared/utils.d.ts +4 -9
  54. package/build/shared/utils.js +27 -44
  55. package/build/shared/utils.js.map +1 -1
  56. package/package.json +14 -14
@@ -7,101 +7,237 @@ exports.getOid4vcJwtSignCallback = getOid4vcJwtSignCallback;
7
7
  exports.getOid4vcCallbacks = getOid4vcCallbacks;
8
8
  exports.dynamicOid4vciClientAuthentication = dynamicOid4vciClientAuthentication;
9
9
  const core_1 = require("@credo-ts/core");
10
+ const core_2 = require("@credo-ts/core");
10
11
  const oauth2_1 = require("@openid4vc/oauth2");
11
12
  const utils_1 = require("./utils");
12
13
  function getOid4vcJwtVerifyCallback(agentContext, options) {
13
- const jwsService = agentContext.dependencyManager.resolve(core_1.JwsService);
14
+ const jwsService = agentContext.dependencyManager.resolve(core_2.JwsService);
14
15
  return async (signer, { compact, header, payload }) => {
15
16
  let trustedCertificates = options?.trustedCertificates;
16
17
  if (signer.method === 'x5c' &&
17
18
  (header.typ === 'oauth-authz-req+jwt' || options?.isAuthorizationRequestJwt) &&
18
19
  !trustedCertificates) {
19
- const x509Config = agentContext.dependencyManager.resolve(core_1.X509ModuleConfig);
20
- const certificateChain = signer.x5c?.map((cert) => core_1.X509Certificate.fromEncodedCertificate(cert));
20
+ const x509Config = agentContext.dependencyManager.resolve(core_2.X509ModuleConfig);
21
+ const certificateChain = signer.x5c?.map((cert) => core_2.X509Certificate.fromEncodedCertificate(cert));
21
22
  trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {
22
23
  certificateChain,
23
24
  verification: {
24
25
  type: 'oauth2SecuredAuthorizationRequest',
25
26
  authorizationRequest: {
26
27
  jwt: compact,
27
- payload: core_1.JwtPayload.fromJson(payload),
28
+ payload: core_2.JwtPayload.fromJson(payload),
28
29
  },
29
30
  },
30
31
  });
31
32
  }
32
- const { isValid, signerKeys } = await jwsService.verifyJws(agentContext, {
33
+ if (signer.method === 'x5c' &&
34
+ (header.typ === 'keyattestation+jwt' || header.typ === 'key-attestation+jwt') &&
35
+ options?.issuanceSessionId &&
36
+ !trustedCertificates) {
37
+ const x509Config = agentContext.dependencyManager.resolve(core_2.X509ModuleConfig);
38
+ const certificateChain = signer.x5c?.map((cert) => core_2.X509Certificate.fromEncodedCertificate(cert));
39
+ trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {
40
+ certificateChain,
41
+ verification: {
42
+ type: 'openId4VciKeyAttestation',
43
+ openId4VcIssuanceSessionId: options.issuanceSessionId,
44
+ keyAttestation: {
45
+ jwt: compact,
46
+ payload: core_2.JwtPayload.fromJson(payload),
47
+ },
48
+ },
49
+ });
50
+ }
51
+ if (signer.method === 'x5c' &&
52
+ header.typ === 'oauth-client-attestation+jwt' &&
53
+ options?.issuanceSessionId &&
54
+ !trustedCertificates) {
55
+ const x509Config = agentContext.dependencyManager.resolve(core_2.X509ModuleConfig);
56
+ const certificateChain = signer.x5c?.map((cert) => core_2.X509Certificate.fromEncodedCertificate(cert));
57
+ trustedCertificates = await x509Config.getTrustedCertificatesForVerification?.(agentContext, {
58
+ certificateChain,
59
+ verification: {
60
+ type: 'oauth2ClientAttestation',
61
+ openId4VcIssuanceSessionId: options.issuanceSessionId,
62
+ clientAttestation: {
63
+ jwt: compact,
64
+ payload: core_2.JwtPayload.fromJson(payload),
65
+ },
66
+ },
67
+ });
68
+ }
69
+ const alg = signer.alg;
70
+ if (!Object.values(core_1.Kms.KnownJwaSignatureAlgorithms).includes(alg)) {
71
+ throw new core_2.CredoError(`Unsupported jwa signatre algorithm '${alg}'`);
72
+ }
73
+ const jwsSigner = signer.method === 'did'
74
+ ? {
75
+ method: 'did',
76
+ didUrl: signer.didUrl,
77
+ jwk: await (0, utils_1.getPublicJwkFromDid)(agentContext, signer.didUrl),
78
+ }
79
+ : signer.method === 'jwk'
80
+ ? {
81
+ method: 'jwk',
82
+ jwk: core_1.Kms.PublicJwk.fromUnknown(signer.publicJwk),
83
+ }
84
+ : signer.method === 'x5c'
85
+ ? {
86
+ method: 'x5c',
87
+ x5c: signer.x5c,
88
+ jwk: core_2.X509Certificate.fromEncodedCertificate(signer.x5c[0]).publicJwk,
89
+ }
90
+ : undefined;
91
+ if (!jwsSigner) {
92
+ throw new core_2.CredoError(`Unable to verify jws with unsupported jws signer method '${signer.method}'`);
93
+ }
94
+ const { isValid, jwsSigners } = await jwsService.verifyJws(agentContext, {
33
95
  jws: compact,
34
96
  trustedCertificates,
35
- // Only handles kid as did resolution. JWK is handled by jws service
36
- jwkResolver: async () => {
37
- if (signer.method === 'jwk') {
38
- return (0, core_1.getJwkFromJson)(signer.publicJwk);
39
- }
40
- if (signer.method === 'did') {
41
- const key = await (0, utils_1.getKeyFromDid)(agentContext, signer.didUrl);
42
- return (0, core_1.getJwkFromKey)(key);
43
- }
44
- throw new core_1.CredoError(`Unexpected call to jwk resolver for signer method ${signer.method}`);
45
- },
97
+ jwsSigner,
46
98
  });
47
99
  if (!isValid) {
48
100
  return { verified: false, signerJwk: undefined };
49
101
  }
50
- const signerKey = signerKeys[0];
51
- const signerJwk = (0, core_1.getJwkFromKey)(signerKey).toJson();
52
- if (signer.method === 'did') {
53
- signerJwk.kid = signer.didUrl;
54
- }
102
+ const signerJwk = jwsSigners[0].jwk.toJson();
55
103
  return { verified: true, signerJwk };
56
104
  };
57
105
  }
58
106
  function getOid4vcEncryptJweCallback(agentContext) {
107
+ const kms = agentContext.dependencyManager.resolve(core_1.Kms.KeyManagementApi);
59
108
  return async (jweEncryptor, compact) => {
60
109
  if (jweEncryptor.method !== 'jwk') {
61
- throw new core_1.CredoError(`Jwt encryption method '${jweEncryptor.method}' is not supported for jwt signer. Only 'jwk' is supported.`);
110
+ throw new core_2.CredoError(`Jwt encryption method '${jweEncryptor.method}' is not supported for jwt signer. Only 'jwk' is supported.`);
111
+ }
112
+ // TODO: we should probably add a key id or ference to the jweEncryptor/jwsSigner in
113
+ // oid4vc-ts so we can keep a reference to the key
114
+ const jwk = core_1.Kms.PublicJwk.fromUnknown(jweEncryptor.publicJwk);
115
+ if (!jwk.hasKeyId) {
116
+ throw new core_2.CredoError('Expected kid to be defined on the JWK');
62
117
  }
63
- const jwk = (0, core_1.getJwkFromJson)(jweEncryptor.publicJwk);
64
- const key = jwk.key;
65
118
  if (jweEncryptor.alg !== 'ECDH-ES') {
66
- throw new core_1.CredoError("Only 'ECDH-ES' is supported as 'alg' value for JARM response encryption");
119
+ throw new core_2.CredoError("Only 'ECDH-ES' is supported as 'alg' value for JARM response encryption");
67
120
  }
68
121
  if (jweEncryptor.enc !== 'A256GCM' && jweEncryptor.enc !== 'A128GCM' && jweEncryptor.enc !== 'A128CBC-HS256') {
69
- throw new core_1.CredoError("Only 'A256GCM', 'A128GCM', and 'A128CBC-HS256' is supported as 'enc' value for JARM response encryption");
122
+ throw new core_2.CredoError("Only 'A256GCM', 'A128GCM', and 'A128CBC-HS256' is supported as 'enc' value for JARM response encryption");
70
123
  }
71
- if (key.keyType !== core_1.KeyType.P256) {
72
- throw new core_1.CredoError(`Only '${core_1.KeyType.P256}' key type is supported for JARM response encryption`);
124
+ const jwkJson = jwk.toJson();
125
+ if (jwkJson.kty !== 'EC' && jwkJson.kty !== 'OKP') {
126
+ throw new core_2.CredoError(`Expected EC or OKP jwk for encryption, found ${core_1.Kms.getJwkHumanDescription(jwkJson)}`);
73
127
  }
74
- if (!agentContext.wallet.directEncryptCompactJweEcdhEs) {
75
- throw new core_1.CredoError('Cannot decrypt Jarm Response, wallet does not support directEncryptCompactJweEcdhEs. You need to upgrade your wallet implementation.');
128
+ if (jwkJson.crv === 'Ed25519') {
129
+ throw new core_2.CredoError(`Expected ${jwkJson.kty} with crv X25519, found ${core_1.Kms.getJwkHumanDescription(jwkJson)}`);
76
130
  }
77
- const jwe = await agentContext.wallet.directEncryptCompactJweEcdhEs({
78
- data: core_1.Buffer.from(compact),
79
- recipientKey: key,
80
- header: { kid: jweEncryptor.publicJwk.kid },
81
- encryptionAlgorithm: jweEncryptor.enc,
82
- apu: jweEncryptor.apu ? core_1.TypedArrayEncoder.toBase64URL(core_1.TypedArrayEncoder.fromString(jweEncryptor.apu)) : undefined,
83
- apv: jweEncryptor.apv ? core_1.TypedArrayEncoder.toBase64URL(core_1.TypedArrayEncoder.fromString(jweEncryptor.apv)) : undefined,
131
+ // TODO: create a JWE service that handles this
132
+ const ephmeralKey = await kms.createKey({
133
+ type: jwkJson,
84
134
  });
85
- return { encryptionJwk: jweEncryptor.publicJwk, jwe };
135
+ try {
136
+ const header = {
137
+ kid: jweEncryptor.publicJwk.kid,
138
+ apu: jweEncryptor.apu,
139
+ apv: jweEncryptor.apv,
140
+ enc: jweEncryptor.enc,
141
+ alg: 'ECDH-ES',
142
+ epk: ephmeralKey.publicJwk,
143
+ };
144
+ const encodedHeader = core_2.JsonEncoder.toBase64URL(header);
145
+ const encrypted = await kms.encrypt({
146
+ key: {
147
+ keyAgreement: {
148
+ // FIXME: We can make the keyId optional for ECDH-ES
149
+ // That way we don't have to store the key
150
+ keyId: ephmeralKey.keyId,
151
+ algorithm: 'ECDH-ES',
152
+ apu: jweEncryptor.apu ? core_2.TypedArrayEncoder.fromBase64(jweEncryptor.apu) : undefined,
153
+ apv: jweEncryptor.apv ? core_2.TypedArrayEncoder.fromBase64(jweEncryptor.apv) : undefined,
154
+ externalPublicJwk: jwkJson,
155
+ },
156
+ },
157
+ data: core_2.Buffer.from(compact),
158
+ encryption: {
159
+ algorithm: jweEncryptor.enc,
160
+ aad: core_2.Buffer.from(encodedHeader),
161
+ },
162
+ });
163
+ if (!encrypted.iv || !encrypted.tag) {
164
+ throw new core_2.CredoError("Expected 'iv' and 'tag' to be defined");
165
+ }
166
+ const compactJwe = `${encodedHeader}..${core_2.TypedArrayEncoder.toBase64URL(encrypted.iv)}.${core_2.TypedArrayEncoder.toBase64URL(encrypted.encrypted)}.${core_2.TypedArrayEncoder.toBase64URL(encrypted.tag)}`;
167
+ return { encryptionJwk: jweEncryptor.publicJwk, jwe: compactJwe };
168
+ }
169
+ finally {
170
+ // Delete the key
171
+ await kms.deleteKey({
172
+ keyId: ephmeralKey.keyId,
173
+ });
174
+ }
86
175
  };
87
176
  }
88
177
  function getOid4vcDecryptJweCallback(agentContext) {
178
+ const kms = agentContext.resolve(core_1.Kms.KeyManagementApi);
89
179
  return async (jwe, options) => {
180
+ // TODO: use custom header zod schema to limit which algorithms can be used
90
181
  const { header } = (0, oauth2_1.decodeJwtHeader)({ jwt: jwe });
91
- const kid = options?.jwk?.kid ?? header.kid;
182
+ let kid = options?.jwk?.kid ?? header.kid;
92
183
  if (!kid) {
93
- throw new core_1.CredoError('Uanbel to decrypt jwe. No kid or jwk found');
184
+ throw new core_2.CredoError('Uanbel to decrypt jwe. No kid or jwk found');
94
185
  }
95
- const key = core_1.Key.fromFingerprint(kid);
96
- if (!agentContext.wallet.directDecryptCompactJweEcdhEs) {
97
- throw new core_1.CredoError('Cannot decrypt Jarm Response, wallet does not support directDecryptCompactJweEcdhEs');
186
+ // Previously we used the fingerprint as the kid for JARM
187
+ // We try to parse it as fingerprint if it starts with z (base58 encoding)
188
+ // It's not 100%
189
+ if (kid.startsWith('z')) {
190
+ try {
191
+ const publicJwk = core_1.Kms.PublicJwk.fromFingerprint(kid);
192
+ if (publicJwk)
193
+ kid = publicJwk.legacyKeyId;
194
+ }
195
+ catch {
196
+ // no-op
197
+ }
198
+ }
199
+ // TODO: decodeJwe method in oid4vc-ts
200
+ // encryption key is not used (we don't use key wrapping)
201
+ const [encodedHeader /* encryptionKey */, , encodedIv, encodedCiphertext, encodedTag] = jwe.split('.');
202
+ if (header.alg !== 'ECDH-ES') {
203
+ throw new core_2.CredoError("Only 'ECDH-ES' is supported as 'alg' value for JARM response decryption");
204
+ }
205
+ if (header.enc !== 'A256GCM' && header.enc !== 'A128GCM' && header.enc !== 'A128CBC-HS256') {
206
+ throw new core_2.CredoError("Only 'A256GCM', 'A128GCM', and 'A128CBC-HS256' is supported as 'enc' value for JARM response decryption");
98
207
  }
99
208
  let decryptedPayload;
209
+ let publicJwk;
210
+ const epk = core_1.Kms.PublicJwk.fromUnknown(header.epk);
100
211
  try {
101
- const decrypted = await agentContext.wallet.directDecryptCompactJweEcdhEs({ compactJwe: jwe, recipientKey: key });
102
- decryptedPayload = core_1.TypedArrayEncoder.toUtf8String(decrypted.data);
212
+ const decrypted = await kms.decrypt({
213
+ encrypted: core_2.TypedArrayEncoder.fromBase64(encodedCiphertext),
214
+ decryption: {
215
+ algorithm: header.enc,
216
+ // aad is the base64 encoded bytes (not just the bytes)
217
+ aad: core_2.TypedArrayEncoder.fromString(encodedHeader),
218
+ iv: core_2.TypedArrayEncoder.fromBase64(encodedIv),
219
+ tag: core_2.TypedArrayEncoder.fromBase64(encodedTag),
220
+ },
221
+ key: {
222
+ keyAgreement: {
223
+ algorithm: header.alg,
224
+ externalPublicJwk: epk.toJson(),
225
+ keyId: kid,
226
+ apu: typeof header.apu === 'string' ? core_2.TypedArrayEncoder.fromBase64(header.apu) : undefined,
227
+ apv: typeof header.apv === 'string' ? core_2.TypedArrayEncoder.fromBase64(header.apv) : undefined,
228
+ },
229
+ },
230
+ });
231
+ // TODO: decrypt should return the public jwk instance
232
+ publicJwk = core_1.Kms.PublicJwk.fromUnknown(await kms.getPublicKey({
233
+ keyId: kid,
234
+ }));
235
+ decryptedPayload = core_2.TypedArrayEncoder.toUtf8String(decrypted.data);
103
236
  }
104
- catch (_error) {
237
+ catch (error) {
238
+ agentContext.config.logger.error('Error decrypting JWE', {
239
+ error,
240
+ });
105
241
  return {
106
242
  decrypted: false,
107
243
  encryptionJwk: options?.jwk,
@@ -111,58 +247,65 @@ function getOid4vcDecryptJweCallback(agentContext) {
111
247
  }
112
248
  return {
113
249
  decrypted: true,
114
- decryptionJwk: (0, core_1.getJwkFromKey)(key).toJson(),
250
+ decryptionJwk: publicJwk.toJson(),
115
251
  payload: decryptedPayload,
116
252
  header,
117
253
  };
118
254
  };
119
255
  }
120
256
  function getOid4vcJwtSignCallback(agentContext) {
121
- const jwsService = agentContext.dependencyManager.resolve(core_1.JwsService);
257
+ const jwsService = agentContext.dependencyManager.resolve(core_2.JwsService);
122
258
  return async (signer, { payload, header }) => {
123
- if (signer.method === 'custom' || signer.method === 'trustChain') {
124
- throw new core_1.CredoError(`Jwt signer method 'custom' and 'x5c' are not supported for jwt signer.`);
259
+ if (signer.method === 'custom' || signer.method === 'federation') {
260
+ throw new core_2.CredoError(`Jwt signer method 'custom' and 'federation' are not supported for jwt signer.`);
125
261
  }
126
262
  if (signer.method === 'x5c') {
127
- const leafCertificate = core_1.X509Service.getLeafCertificate(agentContext, { certificateChain: signer.x5c });
263
+ const leafCertificate = core_2.X509Service.getLeafCertificate(agentContext, { certificateChain: signer.x5c });
128
264
  const jws = await jwsService.createJwsCompact(agentContext, {
129
265
  protectedHeaderOptions: { ...header, alg: signer.alg, jwk: undefined },
130
- payload: core_1.JwtPayload.fromJson(payload),
131
- key: leafCertificate.publicKey,
266
+ payload: core_2.JwtPayload.fromJson(payload),
267
+ keyId: signer.kid ?? leafCertificate.publicJwk.keyId,
132
268
  });
133
- return { jwt: jws, signerJwk: (0, core_1.getJwkFromKey)(leafCertificate.publicKey).toJson() };
269
+ return { jwt: jws, signerJwk: leafCertificate.publicJwk.toJson() };
134
270
  }
135
- const key = signer.method === 'did' ? await (0, utils_1.getKeyFromDid)(agentContext, signer.didUrl) : (0, core_1.getJwkFromJson)(signer.publicJwk).key;
136
- const jwk = (0, core_1.getJwkFromKey)(key);
137
- if (!jwk.supportsSignatureAlgorithm(signer.alg)) {
138
- throw new core_1.CredoError(`key type '${jwk.keyType}', does not support the JWS signature alg '${signer.alg}'`);
271
+ // TOOD: createJwsCompact should return the Jwk, so we don't have to reoslve it here
272
+ const publicJwk = signer.method === 'did'
273
+ ? await (0, utils_1.getPublicJwkFromDid)(agentContext, signer.didUrl)
274
+ : core_1.Kms.PublicJwk.fromUnknown(signer.publicJwk);
275
+ if (!publicJwk.supportedSignatureAlgorithms.includes(signer.alg)) {
276
+ throw new core_2.CredoError(`jwk ${publicJwk.jwkTypehumanDescription} does not support JWS signature alg '${signer.alg}'`);
139
277
  }
140
278
  const jwt = await jwsService.createJwsCompact(agentContext, {
141
279
  protectedHeaderOptions: {
142
280
  ...header,
143
- jwk: header.jwk ? (0, core_1.getJwkFromJson)(header.jwk) : undefined,
281
+ jwk: header.jwk ? publicJwk : undefined,
282
+ alg: signer.alg,
144
283
  },
145
- payload: core_1.JsonEncoder.toBuffer(payload),
146
- key,
284
+ payload: core_2.JsonEncoder.toBuffer(payload),
285
+ keyId: signer.kid ?? publicJwk.keyId,
147
286
  });
148
- return { jwt, signerJwk: (0, core_1.getJwkFromKey)(key).toJson() };
287
+ return { jwt, signerJwk: publicJwk.toJson() };
149
288
  };
150
289
  }
151
290
  function getOid4vcCallbacks(agentContext, options) {
291
+ const kms = agentContext.resolve(core_1.Kms.KeyManagementApi);
152
292
  return {
153
- hash: (data, alg) => core_1.Hasher.hash(data, alg.toLowerCase()),
154
- generateRandom: (length) => agentContext.wallet.getRandomValues(length),
293
+ hash: (data, alg) => core_2.Hasher.hash(data, alg.toLowerCase()),
294
+ generateRandom: (length) => kms.randomBytes({ length }),
155
295
  signJwt: getOid4vcJwtSignCallback(agentContext),
156
- clientAuthentication: (0, oauth2_1.clientAuthenticationNone)(),
296
+ clientAuthentication: () => {
297
+ throw new core_2.CredoError('Did not expect client authentication to be called.');
298
+ },
157
299
  verifyJwt: getOid4vcJwtVerifyCallback(agentContext, {
158
300
  trustedCertificates: options?.trustedCertificates,
159
301
  isAuthorizationRequestJwt: options?.isVerifyOpenId4VpAuthorizationRequest,
302
+ issuanceSessionId: options?.issuanceSessionId,
160
303
  }),
161
304
  fetch: agentContext.config.agentDependencies.fetch,
162
305
  encryptJwe: getOid4vcEncryptJweCallback(agentContext),
163
306
  decryptJwe: getOid4vcDecryptJweCallback(agentContext),
164
307
  getX509CertificateMetadata: (certificate) => {
165
- const leafCertificate = core_1.X509Service.getLeafCertificate(agentContext, { certificateChain: [certificate] });
308
+ const leafCertificate = core_2.X509Service.getLeafCertificate(agentContext, { certificateChain: [certificate] });
166
309
  return {
167
310
  sanDnsNames: leafCertificate.sanDnsNames,
168
311
  sanUriNames: leafCertificate.sanUriNames,
@@ -176,14 +319,14 @@ function getOid4vcCallbacks(agentContext, options) {
176
319
  */
177
320
  function dynamicOid4vciClientAuthentication(agentContext, issuerRecord) {
178
321
  return (callbackOptions) => {
179
- const authorizationServer = issuerRecord.authorizationServerConfigs?.find((a) => a.issuer === callbackOptions.authorizationServerMetata.issuer);
322
+ const authorizationServer = issuerRecord.authorizationServerConfigs?.find((a) => a.issuer === callbackOptions.authorizationServerMetadata.issuer);
180
323
  if (!authorizationServer) {
181
324
  // No client authentication if authorization server is not configured
182
- agentContext.config.logger.debug(`Unknown authorization server '${callbackOptions.authorizationServerMetata.issuer}' for issuer '${issuerRecord.issuerId}' for request to '${callbackOptions.url}'`);
325
+ agentContext.config.logger.debug(`Unknown authorization server '${callbackOptions.authorizationServerMetadata.issuer}' for issuer '${issuerRecord.issuerId}' for request to '${callbackOptions.url}'`);
183
326
  return;
184
327
  }
185
328
  if (!authorizationServer.clientAuthentication) {
186
- throw new core_1.CredoError(`Unable to authenticate to authorization server '${authorizationServer.issuer}' for issuer '${issuerRecord.issuerId}' for request to '${callbackOptions.url}'. Make sure to configure a 'clientId' and 'clientSecret' for the authorization server on the issuer record.`);
329
+ throw new core_2.CredoError(`Unable to authenticate to authorization server '${authorizationServer.issuer}' for issuer '${issuerRecord.issuerId}' for request to '${callbackOptions.url}'. Make sure to configure a 'clientId' and 'clientSecret' for the authorization server on the issuer record.`);
187
330
  }
188
331
  return (0, oauth2_1.clientAuthenticationDynamic)({
189
332
  clientId: authorizationServer.clientAuthentication.clientId,
@@ -1 +1 @@
1
- {"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../src/shared/callbacks.ts"],"names":[],"mappings":";;AA+BA,gEAmEC;AAED,kEA0CC;AAED,kEAmCC;AAED,4DAuCC;AAED,gDA2BC;AAMD,gFA4BC;AAhRD,yCAeuB;AACvB,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ED,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,CAAC;YAC9C,MAAM,IAAI,iBAAU,CAClB,mDAAmD,mBAAmB,CAAC,MAAM,iBAAiB,YAAY,CAAC,QAAQ,qBAAqB,eAAe,CAAC,GAAG,8GAA8G,CAC1Q,CAAA;QACH,CAAC;QAED,OAAO,IAAA,oCAA2B,EAAC;YACjC,QAAQ,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ;YAC3D,YAAY,EAAE,mBAAmB,CAAC,oBAAoB,CAAC,YAAY;SACpE,CAAC,CAAC,eAAe,CAAC,CAAA;IACrB,CAAC,CAAA;AACH,CAAC"}
@@ -1,13 +1,67 @@
1
- import type { Jwk, Key } from '@credo-ts/core';
2
- export type OpenId4VcCredentialHolderDidBinding = {
3
- method: 'did';
4
- didUrl: string;
1
+ import type { Kms } from '@credo-ts/core';
2
+ import { Openid4vciIssuer } from '@openid4vc/openid4vci';
3
+ type VerifiedCredentialRequestAttestationProof = Awaited<ReturnType<InstanceType<typeof Openid4vciIssuer>['verifyCredentialRequestAttestationProof']>>;
4
+ type VerifiedCredentialRequestJwtProof = Awaited<ReturnType<InstanceType<typeof Openid4vciIssuer>['verifyCredentialRequestJwtProof']>>['keyAttestation'];
5
+ export type OpenId4VcCredentialHolderAttestationBinding = {
6
+ method: 'attestation';
7
+ /**
8
+ * The key attestation JWT to use to request issuance of the credentials based
9
+ * on the attested_keys.
10
+ *
11
+ * When the `keyAttestationJwt` contains a `nonce` payload value it will be sent
12
+ * as an `attestation` proof (without signing using a key in the attested key).
13
+ * NOTE that the `nonce` value must match with the `c_nonce` value from the issuer.
14
+ *
15
+ * If no nonce is provided, the `jwt` proof type will be used and the proof will be
16
+ * signed using the first key from the `attested_keys` array.
17
+ */
18
+ keyAttestationJwt: string;
5
19
  };
6
- export type OpenId4VcCredentialHolderJwkBinding = {
20
+ export interface OpenId4VcCredentialHolderDidBinding {
21
+ method: 'did';
22
+ didUrls: string[];
23
+ }
24
+ export interface OpenId4VcCredentialHolderJwkBinding {
7
25
  method: 'jwk';
8
- jwk: Jwk;
9
- };
10
- export type OpenId4VcCredentialHolderBinding = OpenId4VcCredentialHolderDidBinding | OpenId4VcCredentialHolderJwkBinding;
11
- export type OpenId4VcCredentialHolderBindingWithKey = OpenId4VcCredentialHolderBinding & {
12
- key: Key;
13
- };
26
+ keys: Kms.PublicJwk[];
27
+ }
28
+ export type VerifiedOpenId4VcCredentialHolderBinding = {
29
+ proofType: 'jwt' | 'attestation';
30
+ /**
31
+ * The key attestation that was provided to attest the keys.
32
+ * Always defined if `proofType` is `attestation`, as well
33
+ * as when `key_attestations_required` is defined in the
34
+ * credential issuer metadata
35
+ */
36
+ keyAttestation?: VerifiedCredentialRequestAttestationProof | VerifiedCredentialRequestJwtProof;
37
+ /**
38
+ * The binding method of the keys.
39
+ *
40
+ * Binding method `did` is only supported for proof type `jwt`.
41
+ */
42
+ bindingMethod: 'did' | 'jwk';
43
+ } & ({
44
+ bindingMethod: 'did';
45
+ /**
46
+ * The DIDs that were provided as part of the `jwt` proofs in the credential request
47
+ */
48
+ keys: Array<{
49
+ method: 'did';
50
+ jwk: Kms.PublicJwk;
51
+ didUrl: string;
52
+ }>;
53
+ } | {
54
+ bindingMethod: 'jwk';
55
+ /**
56
+ * The keys that were provided as part of the credential request proof.
57
+ * - If `proofType` is `attestation` these keys were extracted from the signed key attestation, but no proof was signed using one of the attested keys
58
+ * - If `proofType` is `jwt` and `attestation` is defined, the keys were extracted from the attestation, and proof was signed using one of the attested keys
59
+ * - Otherwise if `proofType` is `jwt` and no `attestation` is defined, the keys were not attested, and for each individual key a proof was signed using that key.
60
+ */
61
+ keys: Array<{
62
+ method: 'jwk';
63
+ jwk: Kms.PublicJwk;
64
+ }>;
65
+ });
66
+ export type OpenId4VcCredentialHolderBinding = OpenId4VcCredentialHolderDidBinding | OpenId4VcCredentialHolderJwkBinding | OpenId4VcCredentialHolderAttestationBinding;
67
+ export {};
@@ -1,17 +1,22 @@
1
- import type { Jwk } from '@credo-ts/core';
1
+ import { Kms, X509Certificate } from '@credo-ts/core';
2
2
  export interface OpenId4VcJwtIssuerDid {
3
3
  method: 'did';
4
+ /**
5
+ * The did url pointing to a specific verification method.
6
+ *
7
+ * Note a created DID record MUST exist for the did url, enabling extraction of the KMS key id from the did record.
8
+ */
4
9
  didUrl: string;
5
10
  }
6
11
  export interface OpenId4VcIssuerX5c {
7
12
  method: 'x5c';
8
13
  /**
9
- *
10
- * Array of base64-encoded certificate strings in the DER-format.
14
+ * Array of X.509 certificates
11
15
  *
12
16
  * The certificate containing the public key corresponding to the key used to digitally sign the JWS MUST be the first certificate.
17
+ * The first certificate MUST also have a key id configured on the public key to enable signing with the KMS.
13
18
  */
14
- x5c: string[];
19
+ x5c: X509Certificate[];
15
20
  /**
16
21
  * The issuer of the JWT. Should be a HTTPS URI.
17
22
  *
@@ -22,6 +27,6 @@ export interface OpenId4VcIssuerX5c {
22
27
  }
23
28
  export interface OpenId4VcJwtIssuerJwk {
24
29
  method: 'jwk';
25
- jwk: Jwk;
30
+ jwk: Kms.PublicJwk;
26
31
  }
27
32
  export type OpenId4VcJwtIssuer = OpenId4VcJwtIssuerDid | OpenId4VcIssuerX5c | OpenId4VcJwtIssuerJwk;
@@ -3,5 +3,6 @@ export declare enum OpenId4VciCredentialFormatProfile {
3
3
  JwtVcJsonLd = "jwt_vc_json-ld",
4
4
  LdpVc = "ldp_vc",
5
5
  SdJwtVc = "vc+sd-jwt",
6
+ SdJwtDc = "dc+sd-jwt",
6
7
  MsoMdoc = "mso_mdoc"
7
8
  }
@@ -7,6 +7,7 @@ var OpenId4VciCredentialFormatProfile;
7
7
  OpenId4VciCredentialFormatProfile["JwtVcJsonLd"] = "jwt_vc_json-ld";
8
8
  OpenId4VciCredentialFormatProfile["LdpVc"] = "ldp_vc";
9
9
  OpenId4VciCredentialFormatProfile["SdJwtVc"] = "vc+sd-jwt";
10
+ OpenId4VciCredentialFormatProfile["SdJwtDc"] = "dc+sd-jwt";
10
11
  OpenId4VciCredentialFormatProfile["MsoMdoc"] = "mso_mdoc";
11
12
  })(OpenId4VciCredentialFormatProfile || (exports.OpenId4VciCredentialFormatProfile = OpenId4VciCredentialFormatProfile = {}));
12
13
  //# sourceMappingURL=OpenId4VciCredentialFormatProfile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenId4VciCredentialFormatProfile.js","sourceRoot":"","sources":["../../../src/shared/models/OpenId4VciCredentialFormatProfile.ts"],"names":[],"mappings":";;;AAAA,IAAY,iCAMX;AAND,WAAY,iCAAiC;IAC3C,8DAAyB,CAAA;IACzB,mEAA8B,CAAA;IAC9B,qDAAgB,CAAA;IAChB,0DAAqB,CAAA;IACrB,yDAAoB,CAAA;AACtB,CAAC,EANW,iCAAiC,iDAAjC,iCAAiC,QAM5C"}
1
+ {"version":3,"file":"OpenId4VciCredentialFormatProfile.js","sourceRoot":"","sources":["../../../src/shared/models/OpenId4VciCredentialFormatProfile.ts"],"names":[],"mappings":";;;AAAA,IAAY,iCAOX;AAPD,WAAY,iCAAiC;IAC3C,8DAAyB,CAAA;IACzB,mEAA8B,CAAA;IAC9B,qDAAgB,CAAA;IAChB,0DAAqB,CAAA;IACrB,0DAAqB,CAAA;IACrB,yDAAoB,CAAA;AACtB,CAAC,EAPW,iCAAiC,iDAAjC,iCAAiC,QAO5C"}
@@ -15,7 +15,7 @@ async function getAgentContextForActorId(rootAgentContext, actorId) {
15
15
  });
16
16
  if (tenant) {
17
17
  const agentContextProvider = rootAgentContext.dependencyManager.resolve(core_1.InjectionSymbols.AgentContextProvider);
18
- return agentContextProvider.getAgentContextForContextCorrelationId(tenant.id);
18
+ return agentContextProvider.getAgentContextForContextCorrelationId(`tenant-${tenant.id}`);
19
19
  }
20
20
  }
21
21
  return rootAgentContext;
@@ -37,7 +37,7 @@ async function storeActorIdForContextCorrelationId(agentContext, actorId) {
37
37
  const tenantsApi = (0, core_1.getApiForModuleByName)(agentContext, 'TenantsModule');
38
38
  // We don't want to query the tenant record if the current context is the root context
39
39
  if (tenantsApi && tenantsApi.rootAgentContext.contextCorrelationId !== agentContext.contextCorrelationId) {
40
- const tenantRecord = await tenantsApi.getTenantById(agentContext.contextCorrelationId);
40
+ const tenantRecord = await tenantsApi.getTenantById(agentContext.contextCorrelationId.replace('tenant-', ''));
41
41
  const currentOpenId4VcActorIds = tenantRecord.metadata.get(OPENID4VC_ACTOR_IDS_METADATA_KEY) ?? [];
42
42
  const openId4VcActorIds = [...currentOpenId4VcActorIds, actorId];
43
43
  tenantRecord.metadata.set(OPENID4VC_ACTOR_IDS_METADATA_KEY, openId4VcActorIds);
@@ -1 +1 @@
1
- {"version":3,"file":"tenants.js","sourceRoot":"","sources":["../../../src/shared/router/tenants.ts"],"names":[],"mappings":";;AAOA,8DAmBC;AAYD,kFAiBC;AApDD,yCAAwE;AAExE,MAAM,gCAAgC,GAAG,8BAA8B,CAAA;AAEhE,KAAK,UAAU,yBAAyB,CAAC,gBAA8B,EAAE,OAAe;IAC7F,uFAAuF;IACvF,oFAAoF;IACpF,uFAAuF;IACvF,MAAM,UAAU,GAAG,IAAA,4BAAqB,EAAgB,gBAAgB,EAAE,eAAe,CAAC,CAAA;IAC1F,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;YACnD,CAAC,gCAAgC,CAAC,EAAE,CAAC,OAAO,CAAC;SAC9C,CAAC,CAAA;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CACrE,uBAAgB,CAAC,oBAAoB,CACtC,CAAA;YACD,OAAO,oBAAoB,CAAC,sCAAsC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC/E,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,mCAAmC,CAAC,YAA0B,EAAE,OAAe;I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AAM,EAAE,CAAC;YACX,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CACrE,uBAAgB,CAAC,oBAAoB,CACtC,CAAA;YACD,OAAO,oBAAoB,CAAC,sCAAsC,CAAC,UAAU,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;QAC3F,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,mCAAmC,CAAC,YAA0B,EAAE,OAAe;IACnG,uGAAuG;IACvG,wGAAwG;IACxG,kCAAkC;IAClC,MAAM,UAAU,GAAG,IAAA,4BAAqB,EAAgB,YAAY,EAAE,eAAe,CAAC,CAAA;IAEtF,sFAAsF;IACtF,IAAI,UAAU,IAAI,UAAU,CAAC,gBAAgB,CAAC,oBAAoB,KAAK,YAAY,CAAC,oBAAoB,EAAE,CAAC;QACzG,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,oBAAoB,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAA;QAE7G,MAAM,wBAAwB,GAAG,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAW,gCAAgC,CAAC,IAAI,EAAE,CAAA;QAC5G,MAAM,iBAAiB,GAAG,CAAC,GAAG,wBAAwB,EAAE,OAAO,CAAC,CAAA;QAEhE,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,gCAAgC,EAAE,iBAAiB,CAAC,CAAA;QAC9E,YAAY,CAAC,MAAM,CAAC,gCAAgC,EAAE,iBAAiB,CAAC,CAAA;QACxE,MAAM,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC"}
@@ -1,20 +1,15 @@
1
- import type { AgentContext, DidPurpose, JwaSignatureAlgorithm, Key } from '@credo-ts/core';
1
+ import { AgentContext, DidPurpose, Kms } from '@credo-ts/core';
2
2
  import type { JwtSigner, JwtSignerX5c } from '@openid4vc/oauth2';
3
3
  import type { OpenId4VcJwtIssuer } from './models';
4
4
  /**
5
5
  * Returns the JWA Signature Algorithms that are supported by the wallet.
6
- *
7
- * This is an approximation based on the supported key types of the wallet.
8
- * This is not 100% correct as a supporting a key type does not mean you support
9
- * all the algorithms for that key type. However, this needs refactoring of the wallet
10
- * that is planned for the 0.5.0 release.
11
6
  */
12
- export declare function getSupportedJwaSignatureAlgorithms(agentContext: AgentContext): JwaSignatureAlgorithm[];
13
- export declare function getKeyFromDid(agentContext: AgentContext, didUrl: string, allowedPurposes?: DidPurpose[]): Promise<Key>;
7
+ export declare function getSupportedJwaSignatureAlgorithms(agentContext: AgentContext): Kms.KnownJwaSignatureAlgorithm[];
8
+ export declare function getPublicJwkFromDid(agentContext: AgentContext, didUrl: string, allowedPurposes?: DidPurpose[]): Promise<Kms.PublicJwk<import("@credo-ts/core/src/modules/kms/jwk/PublicJwk").SupportedPublicJwk>>;
14
9
  export declare function requestSignerToJwtIssuer(agentContext: AgentContext, requestSigner: OpenId4VcJwtIssuer): Promise<Exclude<JwtSigner, JwtSignerX5c> | (JwtSignerX5c & {
15
10
  issuer: string;
16
11
  })>;
17
- export declare function getProofTypeFromKey(agentContext: AgentContext, key: Key): string;
12
+ export declare function getProofTypeFromPublicJwk(agentContext: AgentContext, key: Kms.PublicJwk): string;
18
13
  export declare function addSecondsToDate(date: Date, seconds: number): Date;
19
14
  export declare function dateToSeconds(date: Date): number;
20
15
  export declare function parseIfJson<T>(input: T): T | Record<string, unknown>;