@credo-ts/openid4vc 0.4.1-alpha.157

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 (192) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +31 -0
  3. package/build/index.d.ts +4 -0
  4. package/build/index.js +21 -0
  5. package/build/index.js.map +1 -0
  6. package/build/openid4vc-holder/OpenId4VcHolderApi.d.ts +83 -0
  7. package/build/openid4vc-holder/OpenId4VcHolderApi.js +115 -0
  8. package/build/openid4vc-holder/OpenId4VcHolderApi.js.map +1 -0
  9. package/build/openid4vc-holder/OpenId4VcHolderModule.d.ts +13 -0
  10. package/build/openid4vc-holder/OpenId4VcHolderModule.js +30 -0
  11. package/build/openid4vc-holder/OpenId4VcHolderModule.js.map +1 -0
  12. package/build/openid4vc-holder/OpenId4VciHolderService.d.ts +33 -0
  13. package/build/openid4vc-holder/OpenId4VciHolderService.js +512 -0
  14. package/build/openid4vc-holder/OpenId4VciHolderService.js.map +1 -0
  15. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.d.ts +153 -0
  16. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js +11 -0
  17. package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js.map +1 -0
  18. package/build/openid4vc-holder/OpenId4vcSiopHolderService.d.ts +18 -0
  19. package/build/openid4vc-holder/OpenId4vcSiopHolderService.js +228 -0
  20. package/build/openid4vc-holder/OpenId4vcSiopHolderService.js.map +1 -0
  21. package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.d.ts +43 -0
  22. package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js +3 -0
  23. package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js.map +1 -0
  24. package/build/openid4vc-holder/index.d.ts +6 -0
  25. package/build/openid4vc-holder/index.js +23 -0
  26. package/build/openid4vc-holder/index.js.map +1 -0
  27. package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.d.ts +9 -0
  28. package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.js +14 -0
  29. package/build/openid4vc-issuer/OpenId4VcIssuanceSessionState.js.map +1 -0
  30. package/build/openid4vc-issuer/OpenId4VcIssuerApi.d.ts +60 -0
  31. package/build/openid4vc-issuer/OpenId4VcIssuerApi.js +106 -0
  32. package/build/openid4vc-issuer/OpenId4VcIssuerApi.js.map +1 -0
  33. package/build/openid4vc-issuer/OpenId4VcIssuerEvents.d.ts +13 -0
  34. package/build/openid4vc-issuer/OpenId4VcIssuerEvents.js +8 -0
  35. package/build/openid4vc-issuer/OpenId4VcIssuerEvents.js.map +1 -0
  36. package/build/openid4vc-issuer/OpenId4VcIssuerModule.d.ts +21 -0
  37. package/build/openid4vc-issuer/OpenId4VcIssuerModule.js +106 -0
  38. package/build/openid4vc-issuer/OpenId4VcIssuerModule.js.map +1 -0
  39. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +41 -0
  40. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +46 -0
  41. package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +1 -0
  42. package/build/openid4vc-issuer/OpenId4VcIssuerService.d.ts +54 -0
  43. package/build/openid4vc-issuer/OpenId4VcIssuerService.js +425 -0
  44. package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +1 -0
  45. package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +88 -0
  46. package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.js +3 -0
  47. package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.js.map +1 -0
  48. package/build/openid4vc-issuer/index.d.ts +8 -0
  49. package/build/openid4vc-issuer/index.js +27 -0
  50. package/build/openid4vc-issuer/index.js.map +1 -0
  51. package/build/openid4vc-issuer/repository/OpenId4VcCNonceStateManager.d.ts +18 -0
  52. package/build/openid4vc-issuer/repository/OpenId4VcCNonceStateManager.js +99 -0
  53. package/build/openid4vc-issuer/repository/OpenId4VcCNonceStateManager.js.map +1 -0
  54. package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferSessionStateManager.d.ts +21 -0
  55. package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferSessionStateManager.js +182 -0
  56. package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferSessionStateManager.js.map +1 -0
  57. package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferUriStateManager.d.ts +17 -0
  58. package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferUriStateManager.js +68 -0
  59. package/build/openid4vc-issuer/repository/OpenId4VcCredentialOfferUriStateManager.js.map +1 -0
  60. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.d.ts +84 -0
  61. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js +58 -0
  62. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.js.map +1 -0
  63. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.d.ts +5 -0
  64. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.js +29 -0
  65. package/build/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.js.map +1 -0
  66. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.d.ts +37 -0
  67. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js +31 -0
  68. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js.map +1 -0
  69. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.d.ts +8 -0
  70. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.js +35 -0
  71. package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.js.map +1 -0
  72. package/build/openid4vc-issuer/repository/index.d.ts +4 -0
  73. package/build/openid4vc-issuer/repository/index.js +21 -0
  74. package/build/openid4vc-issuer/repository/index.js.map +1 -0
  75. package/build/openid4vc-issuer/router/accessTokenEndpoint.d.ts +34 -0
  76. package/build/openid4vc-issuer/router/accessTokenEndpoint.js +111 -0
  77. package/build/openid4vc-issuer/router/accessTokenEndpoint.js.map +1 -0
  78. package/build/openid4vc-issuer/router/credentialEndpoint.d.ts +16 -0
  79. package/build/openid4vc-issuer/router/credentialEndpoint.js +44 -0
  80. package/build/openid4vc-issuer/router/credentialEndpoint.js.map +1 -0
  81. package/build/openid4vc-issuer/router/credentialOfferEndpoint.d.ts +11 -0
  82. package/build/openid4vc-issuer/router/credentialOfferEndpoint.js +61 -0
  83. package/build/openid4vc-issuer/router/credentialOfferEndpoint.js.map +1 -0
  84. package/build/openid4vc-issuer/router/index.d.ts +5 -0
  85. package/build/openid4vc-issuer/router/index.js +12 -0
  86. package/build/openid4vc-issuer/router/index.js.map +1 -0
  87. package/build/openid4vc-issuer/router/metadataEndpoint.d.ts +2 -0
  88. package/build/openid4vc-issuer/router/metadataEndpoint.js +30 -0
  89. package/build/openid4vc-issuer/router/metadataEndpoint.js.map +1 -0
  90. package/build/openid4vc-issuer/router/requestContext.d.ts +5 -0
  91. package/build/openid4vc-issuer/router/requestContext.js +3 -0
  92. package/build/openid4vc-issuer/router/requestContext.js.map +1 -0
  93. package/build/openid4vc-issuer/router/verifyAccessToken.d.ts +3 -0
  94. package/build/openid4vc-issuer/router/verifyAccessToken.js +33 -0
  95. package/build/openid4vc-issuer/router/verifyAccessToken.js.map +1 -0
  96. package/build/openid4vc-issuer/util/credentialRequest.d.ts +5 -0
  97. package/build/openid4vc-issuer/util/credentialRequest.js +18 -0
  98. package/build/openid4vc-issuer/util/credentialRequest.js.map +1 -0
  99. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.d.ts +43 -0
  100. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js +357 -0
  101. package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js.map +1 -0
  102. package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.d.ts +45 -0
  103. package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js +3 -0
  104. package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js.map +1 -0
  105. package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.d.ts +6 -0
  106. package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.js +11 -0
  107. package/build/openid4vc-verifier/OpenId4VcVerificationSessionState.js.map +1 -0
  108. package/build/openid4vc-verifier/OpenId4VcVerifierApi.d.ts +60 -0
  109. package/build/openid4vc-verifier/OpenId4VcVerifierApi.js +102 -0
  110. package/build/openid4vc-verifier/OpenId4VcVerifierApi.js.map +1 -0
  111. package/build/openid4vc-verifier/OpenId4VcVerifierEvents.d.ts +13 -0
  112. package/build/openid4vc-verifier/OpenId4VcVerifierEvents.js +8 -0
  113. package/build/openid4vc-verifier/OpenId4VcVerifierEvents.js.map +1 -0
  114. package/build/openid4vc-verifier/OpenId4VcVerifierModule.d.ts +21 -0
  115. package/build/openid4vc-verifier/OpenId4VcVerifierModule.js +103 -0
  116. package/build/openid4vc-verifier/OpenId4VcVerifierModule.js.map +1 -0
  117. package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.d.ts +31 -0
  118. package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js +28 -0
  119. package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js.map +1 -0
  120. package/build/openid4vc-verifier/index.d.ts +8 -0
  121. package/build/openid4vc-verifier/index.js +25 -0
  122. package/build/openid4vc-verifier/index.js.map +1 -0
  123. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.d.ts +50 -0
  124. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js +229 -0
  125. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartyEventEmitter.js.map +1 -0
  126. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.d.ts +19 -0
  127. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js +146 -0
  128. package/build/openid4vc-verifier/repository/OpenId4VcRelyingPartySessionManager.js.map +1 -0
  129. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.d.ts +61 -0
  130. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js +45 -0
  131. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRecord.js.map +1 -0
  132. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.d.ts +5 -0
  133. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.js +29 -0
  134. package/build/openid4vc-verifier/repository/OpenId4VcVerificationSessionRepository.js.map +1 -0
  135. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.d.ts +26 -0
  136. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js +28 -0
  137. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js.map +1 -0
  138. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.d.ts +8 -0
  139. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.js +35 -0
  140. package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.js.map +1 -0
  141. package/build/openid4vc-verifier/repository/index.d.ts +4 -0
  142. package/build/openid4vc-verifier/repository/index.js +21 -0
  143. package/build/openid4vc-verifier/repository/index.js.map +1 -0
  144. package/build/openid4vc-verifier/router/authorizationEndpoint.d.ts +11 -0
  145. package/build/openid4vc-verifier/router/authorizationEndpoint.js +37 -0
  146. package/build/openid4vc-verifier/router/authorizationEndpoint.js.map +1 -0
  147. package/build/openid4vc-verifier/router/authorizationRequestEndpoint.d.ts +11 -0
  148. package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js +65 -0
  149. package/build/openid4vc-verifier/router/authorizationRequestEndpoint.js.map +1 -0
  150. package/build/openid4vc-verifier/router/index.d.ts +2 -0
  151. package/build/openid4vc-verifier/router/index.js +6 -0
  152. package/build/openid4vc-verifier/router/index.js.map +1 -0
  153. package/build/openid4vc-verifier/router/requestContext.d.ts +5 -0
  154. package/build/openid4vc-verifier/router/requestContext.js +3 -0
  155. package/build/openid4vc-verifier/router/requestContext.js.map +1 -0
  156. package/build/shared/index.d.ts +2 -0
  157. package/build/shared/index.js +19 -0
  158. package/build/shared/index.js.map +1 -0
  159. package/build/shared/issuerMetadataUtils.d.ts +14 -0
  160. package/build/shared/issuerMetadataUtils.js +69 -0
  161. package/build/shared/issuerMetadataUtils.js.map +1 -0
  162. package/build/shared/models/CredentialHolderBinding.d.ts +10 -0
  163. package/build/shared/models/CredentialHolderBinding.js +3 -0
  164. package/build/shared/models/CredentialHolderBinding.js.map +1 -0
  165. package/build/shared/models/OpenId4VcJwtIssuer.d.ts +6 -0
  166. package/build/shared/models/OpenId4VcJwtIssuer.js +3 -0
  167. package/build/shared/models/OpenId4VcJwtIssuer.js.map +1 -0
  168. package/build/shared/models/OpenId4VciCredentialFormatProfile.d.ts +6 -0
  169. package/build/shared/models/OpenId4VciCredentialFormatProfile.js +11 -0
  170. package/build/shared/models/OpenId4VciCredentialFormatProfile.js.map +1 -0
  171. package/build/shared/models/index.d.ts +21 -0
  172. package/build/shared/models/index.js +20 -0
  173. package/build/shared/models/index.js.map +1 -0
  174. package/build/shared/router/context.d.ts +10 -0
  175. package/build/shared/router/context.js +22 -0
  176. package/build/shared/router/context.js.map +1 -0
  177. package/build/shared/router/express.d.ts +2 -0
  178. package/build/shared/router/express.js +16 -0
  179. package/build/shared/router/express.js.map +1 -0
  180. package/build/shared/router/index.d.ts +3 -0
  181. package/build/shared/router/index.js +20 -0
  182. package/build/shared/router/index.js.map +1 -0
  183. package/build/shared/router/tenants.d.ts +13 -0
  184. package/build/shared/router/tenants.js +50 -0
  185. package/build/shared/router/tenants.js.map +1 -0
  186. package/build/shared/transform.d.ts +5 -0
  187. package/build/shared/transform.js +61 -0
  188. package/build/shared/transform.js.map +1 -0
  189. package/build/shared/utils.d.ts +21 -0
  190. package/build/shared/utils.js +85 -0
  191. package/build/shared/utils.js.map +1 -0
  192. package/package.json +44 -0
@@ -0,0 +1,425 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OpenId4VcIssuerService = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const oid4vci_issuer_1 = require("@sphereon/oid4vci-issuer");
15
+ const shared_1 = require("../shared");
16
+ const router_1 = require("../shared/router");
17
+ const transform_1 = require("../shared/transform");
18
+ const utils_1 = require("../shared/utils");
19
+ const OpenId4VcIssuanceSessionState_1 = require("./OpenId4VcIssuanceSessionState");
20
+ const OpenId4VcIssuerModuleConfig_1 = require("./OpenId4VcIssuerModuleConfig");
21
+ const repository_1 = require("./repository");
22
+ const OpenId4VcCNonceStateManager_1 = require("./repository/OpenId4VcCNonceStateManager");
23
+ const OpenId4VcCredentialOfferSessionStateManager_1 = require("./repository/OpenId4VcCredentialOfferSessionStateManager");
24
+ const OpenId4VcCredentialOfferUriStateManager_1 = require("./repository/OpenId4VcCredentialOfferUriStateManager");
25
+ const credentialRequest_1 = require("./util/credentialRequest");
26
+ const w3cOpenId4VcFormats = [
27
+ shared_1.OpenId4VciCredentialFormatProfile.JwtVcJson,
28
+ shared_1.OpenId4VciCredentialFormatProfile.JwtVcJsonLd,
29
+ shared_1.OpenId4VciCredentialFormatProfile.LdpVc,
30
+ ];
31
+ /**
32
+ * @internal
33
+ */
34
+ let OpenId4VcIssuerService = class OpenId4VcIssuerService {
35
+ constructor(w3cCredentialService, jwsService, openId4VcIssuerConfig, openId4VcIssuerRepository, openId4VcIssuanceSessionRepository) {
36
+ this.getJwtVerifyCallback = (agentContext) => {
37
+ return async (opts) => {
38
+ let didDocument = undefined;
39
+ const { isValid, jws } = await this.jwsService.verifyJws(agentContext, {
40
+ jws: opts.jwt,
41
+ // Only handles kid as did resolution. JWK is handled by jws service
42
+ jwkResolver: async ({ protectedHeader: { kid } }) => {
43
+ if (!kid)
44
+ throw new core_1.CredoError('Missing kid in protected header.');
45
+ if (!kid.startsWith('did:'))
46
+ throw new core_1.CredoError('Only did is supported for kid identifier');
47
+ const didsApi = agentContext.dependencyManager.resolve(core_1.DidsApi);
48
+ didDocument = await didsApi.resolveDidDocument(kid);
49
+ const verificationMethod = didDocument.dereferenceKey(kid, ['authentication', 'assertionMethod']);
50
+ const key = (0, core_1.getKeyFromVerificationMethod)(verificationMethod);
51
+ return (0, core_1.getJwkFromKey)(key);
52
+ },
53
+ });
54
+ if (!isValid)
55
+ throw new core_1.CredoError('Could not verify JWT signature.');
56
+ // TODO: the jws service should return some better decoded metadata also from the resolver
57
+ // as currently is less useful if you afterwards need properties from the JWS
58
+ const firstJws = jws.signatures[0];
59
+ const protectedHeader = core_1.JsonEncoder.fromBase64(firstJws.protected);
60
+ return {
61
+ jwt: { header: protectedHeader, payload: core_1.JsonEncoder.fromBase64(jws.payload) },
62
+ kid: protectedHeader.kid,
63
+ jwk: protectedHeader.jwk ? (0, core_1.getJwkFromJson)(protectedHeader.jwk) : undefined,
64
+ did: didDocument === null || didDocument === void 0 ? void 0 : didDocument.id,
65
+ alg: protectedHeader.alg,
66
+ didDocument,
67
+ };
68
+ };
69
+ };
70
+ this.getSdJwtVcCredentialSigningCallback = (agentContext, options) => {
71
+ return async () => {
72
+ const sdJwtVcApi = agentContext.dependencyManager.resolve(core_1.SdJwtVcApi);
73
+ const sdJwtVc = await sdJwtVcApi.sign(options);
74
+ return (0, transform_1.getSphereonVerifiableCredential)(sdJwtVc);
75
+ };
76
+ };
77
+ this.getW3cCredentialSigningCallback = (agentContext, options) => {
78
+ return async (opts) => {
79
+ const { jwtVerifyResult, format } = opts;
80
+ const { kid, didDocument: holderDidDocument } = jwtVerifyResult;
81
+ if (!kid)
82
+ throw new core_1.CredoError('Missing Kid. Cannot create the holder binding');
83
+ if (!holderDidDocument)
84
+ throw new core_1.CredoError('Missing did document. Cannot create the holder binding.');
85
+ if (!format)
86
+ throw new core_1.CredoError('Missing format. Cannot issue credential.');
87
+ const formatMap = {
88
+ [shared_1.OpenId4VciCredentialFormatProfile.JwtVcJson]: core_1.ClaimFormat.JwtVc,
89
+ [shared_1.OpenId4VciCredentialFormatProfile.JwtVcJsonLd]: core_1.ClaimFormat.JwtVc,
90
+ [shared_1.OpenId4VciCredentialFormatProfile.LdpVc]: core_1.ClaimFormat.LdpVc,
91
+ };
92
+ const w3cServiceFormat = formatMap[format];
93
+ // Set the binding on the first credential subject if not set yet
94
+ // on any subject
95
+ if (!options.credential.credentialSubjectIds.includes(holderDidDocument.id)) {
96
+ const credentialSubject = Array.isArray(options.credential.credentialSubject)
97
+ ? options.credential.credentialSubject[0]
98
+ : options.credential.credentialSubject;
99
+ credentialSubject.id = holderDidDocument.id;
100
+ }
101
+ const didsApi = agentContext.dependencyManager.resolve(core_1.DidsApi);
102
+ const issuerDidDocument = await didsApi.resolveDidDocument(options.verificationMethod);
103
+ const verificationMethod = issuerDidDocument.dereferenceVerificationMethod(options.verificationMethod);
104
+ if (w3cServiceFormat === core_1.ClaimFormat.JwtVc) {
105
+ const key = (0, core_1.getKeyFromVerificationMethod)(verificationMethod);
106
+ const alg = (0, core_1.getJwkFromKey)(key).supportedSignatureAlgorithms[0];
107
+ if (!alg) {
108
+ throw new core_1.CredoError(`No supported JWA signature algorithms for key type ${key.keyType}`);
109
+ }
110
+ const signed = await this.w3cCredentialService.signCredential(agentContext, {
111
+ format: w3cServiceFormat,
112
+ credential: options.credential,
113
+ verificationMethod: options.verificationMethod,
114
+ alg,
115
+ });
116
+ return (0, transform_1.getSphereonVerifiableCredential)(signed);
117
+ }
118
+ else {
119
+ const key = (0, core_1.getKeyFromVerificationMethod)(verificationMethod);
120
+ const proofType = (0, utils_1.getProofTypeFromKey)(agentContext, key);
121
+ const signed = await this.w3cCredentialService.signCredential(agentContext, {
122
+ format: w3cServiceFormat,
123
+ credential: options.credential,
124
+ verificationMethod: options.verificationMethod,
125
+ proofType: proofType,
126
+ });
127
+ return (0, transform_1.getSphereonVerifiableCredential)(signed);
128
+ }
129
+ };
130
+ };
131
+ this.getCredentialDataSupplier = (agentContext, options) => {
132
+ return async (args) => {
133
+ var _a;
134
+ const { credentialRequest, credentialOffer } = args;
135
+ const issuerMetadata = this.getIssuerMetadata(agentContext, options.issuer);
136
+ const offeredCredentialsMatchingRequest = this.findOfferedCredentialsMatchingRequest(credentialOffer.credential_offer, credentialRequest, issuerMetadata.credentialsSupported);
137
+ if (offeredCredentialsMatchingRequest.length === 0) {
138
+ throw new core_1.CredoError('No offered credentials match the credential request.');
139
+ }
140
+ if (offeredCredentialsMatchingRequest.length > 1) {
141
+ agentContext.config.logger.debug('Multiple credentials from credentials supported matching request, picking first one.');
142
+ }
143
+ const holderBinding = await this.getHolderBindingFromRequest(credentialRequest);
144
+ const mapper = (_a = options.credentialRequestToCredentialMapper) !== null && _a !== void 0 ? _a : this.openId4VcIssuerConfig.credentialEndpoint.credentialRequestToCredentialMapper;
145
+ const signOptions = await mapper({
146
+ agentContext,
147
+ issuanceSession: options.issuanceSession,
148
+ holderBinding,
149
+ credentialOffer,
150
+ credentialRequest: credentialRequest,
151
+ credentialsSupported: offeredCredentialsMatchingRequest,
152
+ });
153
+ if (signOptions.format === core_1.ClaimFormat.JwtVc || signOptions.format === core_1.ClaimFormat.LdpVc) {
154
+ if (!w3cOpenId4VcFormats.includes(credentialRequest.format)) {
155
+ throw new core_1.CredoError(`The credential to be issued does not match the request. Cannot issue a W3cCredential if the client expects a credential of format '${credentialRequest.format}'.`);
156
+ }
157
+ return {
158
+ format: credentialRequest.format,
159
+ credential: core_1.JsonTransformer.toJSON(signOptions.credential),
160
+ signCallback: this.getW3cCredentialSigningCallback(agentContext, signOptions),
161
+ };
162
+ }
163
+ else if (signOptions.format === core_1.ClaimFormat.SdJwtVc) {
164
+ if (credentialRequest.format !== shared_1.OpenId4VciCredentialFormatProfile.SdJwtVc) {
165
+ throw new core_1.CredoError(`Invalid credential format. Expected '${shared_1.OpenId4VciCredentialFormatProfile.SdJwtVc}', received '${credentialRequest.format}'.`);
166
+ }
167
+ if (credentialRequest.vct !== signOptions.payload.vct) {
168
+ throw new core_1.CredoError(`The types of the offered credentials do not match the types of the requested credential. Offered '${signOptions.payload.vct}' Requested '${credentialRequest.vct}'.`);
169
+ }
170
+ return {
171
+ format: credentialRequest.format,
172
+ // NOTE: we don't use the credential value here as we pass the credential directly to the singer
173
+ credential: Object.assign({}, signOptions.payload),
174
+ signCallback: this.getSdJwtVcCredentialSigningCallback(agentContext, signOptions),
175
+ };
176
+ }
177
+ else {
178
+ throw new core_1.CredoError(`Unsupported credential format`);
179
+ }
180
+ };
181
+ };
182
+ this.w3cCredentialService = w3cCredentialService;
183
+ this.jwsService = jwsService;
184
+ this.openId4VcIssuerConfig = openId4VcIssuerConfig;
185
+ this.openId4VcIssuerRepository = openId4VcIssuerRepository;
186
+ this.openId4VcIssuanceSessionRepository = openId4VcIssuanceSessionRepository;
187
+ }
188
+ async createCredentialOffer(agentContext, options) {
189
+ const { preAuthorizedCodeFlowConfig, issuer, offeredCredentials } = options;
190
+ const vcIssuer = this.getVcIssuer(agentContext, issuer);
191
+ // this checks if the structure of the credentials is correct
192
+ // it throws an error if a offered credential cannot be found in the credentialsSupported
193
+ (0, shared_1.getOfferedCredentials)(options.offeredCredentials, vcIssuer.issuerMetadata.credentials_supported);
194
+ // We always use shortened URIs currently
195
+ const hostedCredentialOfferUri = (0, core_1.joinUriParts)(vcIssuer.issuerMetadata.credential_issuer, [
196
+ this.openId4VcIssuerConfig.credentialOfferEndpoint.endpointPath,
197
+ // It doesn't really matter what the url is, as long as it's unique
198
+ core_1.utils.uuid(),
199
+ ]);
200
+ let { uri } = await vcIssuer.createCredentialOfferURI({
201
+ grants: await this.getGrantsFromConfig(agentContext, preAuthorizedCodeFlowConfig),
202
+ credentials: offeredCredentials,
203
+ credentialOfferUri: hostedCredentialOfferUri,
204
+ baseUri: options.baseUri,
205
+ credentialDataSupplierInput: options.issuanceMetadata,
206
+ });
207
+ // FIXME: https://github.com/Sphereon-Opensource/OID4VCI/issues/102
208
+ if (uri.includes(hostedCredentialOfferUri)) {
209
+ uri = uri.replace(hostedCredentialOfferUri, encodeURIComponent(hostedCredentialOfferUri));
210
+ }
211
+ const issuanceSession = await this.openId4VcIssuanceSessionRepository.getSingleByQuery(agentContext, {
212
+ credentialOfferUri: hostedCredentialOfferUri,
213
+ });
214
+ return {
215
+ issuanceSession,
216
+ credentialOffer: uri,
217
+ };
218
+ }
219
+ /**
220
+ * find the issuance session associated with a credential request. You can optionally provide a issuer id if
221
+ * the issuer that the request is associated with is already known.
222
+ */
223
+ async findIssuanceSessionForCredentialRequest(agentContext, { credentialRequest, issuerId }) {
224
+ const cNonce = (0, credentialRequest_1.getCNonceFromCredentialRequest)(credentialRequest);
225
+ const issuanceSession = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(agentContext, {
226
+ issuerId,
227
+ cNonce,
228
+ });
229
+ return issuanceSession;
230
+ }
231
+ async createCredentialResponse(agentContext, options) {
232
+ options.issuanceSession.assertState([
233
+ OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.AccessTokenCreated,
234
+ OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialRequestReceived,
235
+ // It is possible to issue multiple credentials in one session
236
+ OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialIssued,
237
+ ]);
238
+ const { credentialRequest, issuanceSession } = options;
239
+ if (!credentialRequest.proof)
240
+ throw new core_1.CredoError('No proof defined in the credentialRequest.');
241
+ const issuer = await this.getIssuerByIssuerId(agentContext, options.issuanceSession.issuerId);
242
+ const cNonce = (0, credentialRequest_1.getCNonceFromCredentialRequest)(credentialRequest);
243
+ if (issuanceSession.cNonce !== cNonce) {
244
+ throw new core_1.CredoError('The cNonce in the credential request does not match the cNonce in the issuance session.');
245
+ }
246
+ if (!issuanceSession.cNonceExpiresAt) {
247
+ throw new core_1.CredoError('Missing required cNonceExpiresAt in the issuance session. Assuming cNonce is not valid');
248
+ }
249
+ if (Date.now() > issuanceSession.cNonceExpiresAt.getTime()) {
250
+ throw new core_1.CredoError('The cNonce has expired.');
251
+ }
252
+ const vcIssuer = this.getVcIssuer(agentContext, issuer);
253
+ const credentialResponse = await vcIssuer.issueCredential({
254
+ credentialRequest,
255
+ tokenExpiresIn: this.openId4VcIssuerConfig.accessTokenEndpoint.tokenExpiresInSeconds,
256
+ // This can just be combined with signing callback right?
257
+ credentialDataSupplier: this.getCredentialDataSupplier(agentContext, Object.assign(Object.assign({}, options), { issuer })),
258
+ credentialDataSupplierInput: issuanceSession.issuanceMetadata,
259
+ responseCNonce: undefined,
260
+ });
261
+ const updatedIssuanceSession = await this.openId4VcIssuanceSessionRepository.getById(agentContext, issuanceSession.id);
262
+ if (!credentialResponse.credential) {
263
+ updatedIssuanceSession.state = OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.Error;
264
+ updatedIssuanceSession.errorMessage = 'No credential found in the issueCredentialResponse.';
265
+ await this.openId4VcIssuanceSessionRepository.update(agentContext, updatedIssuanceSession);
266
+ throw new core_1.CredoError(updatedIssuanceSession.errorMessage);
267
+ }
268
+ if (credentialResponse.acceptance_token) {
269
+ updatedIssuanceSession.state = OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.Error;
270
+ updatedIssuanceSession.errorMessage = 'Acceptance token not yet supported.';
271
+ await this.openId4VcIssuanceSessionRepository.update(agentContext, updatedIssuanceSession);
272
+ throw new core_1.CredoError(updatedIssuanceSession.errorMessage);
273
+ }
274
+ return {
275
+ credentialResponse,
276
+ issuanceSession: updatedIssuanceSession,
277
+ };
278
+ }
279
+ async findIssuanceSessionsByQuery(agentContext, query) {
280
+ return this.openId4VcIssuanceSessionRepository.findByQuery(agentContext, query);
281
+ }
282
+ async getIssuanceSessionById(agentContext, issuanceSessionId) {
283
+ return this.openId4VcIssuanceSessionRepository.getById(agentContext, issuanceSessionId);
284
+ }
285
+ async getAllIssuers(agentContext) {
286
+ return this.openId4VcIssuerRepository.getAll(agentContext);
287
+ }
288
+ async getIssuerByIssuerId(agentContext, issuerId) {
289
+ return this.openId4VcIssuerRepository.getByIssuerId(agentContext, issuerId);
290
+ }
291
+ async updateIssuer(agentContext, issuer) {
292
+ return this.openId4VcIssuerRepository.update(agentContext, issuer);
293
+ }
294
+ async createIssuer(agentContext, options) {
295
+ var _a;
296
+ // TODO: ideally we can store additional data with a key, such as:
297
+ // - createdAt
298
+ // - purpose
299
+ const accessTokenSignerKey = await agentContext.wallet.createKey({
300
+ keyType: core_1.KeyType.Ed25519,
301
+ });
302
+ const openId4VcIssuer = new repository_1.OpenId4VcIssuerRecord({
303
+ issuerId: (_a = options.issuerId) !== null && _a !== void 0 ? _a : core_1.utils.uuid(),
304
+ display: options.display,
305
+ accessTokenPublicKeyFingerprint: accessTokenSignerKey.fingerprint,
306
+ credentialsSupported: options.credentialsSupported,
307
+ });
308
+ await this.openId4VcIssuerRepository.save(agentContext, openId4VcIssuer);
309
+ await (0, router_1.storeActorIdForContextCorrelationId)(agentContext, openId4VcIssuer.issuerId);
310
+ return openId4VcIssuer;
311
+ }
312
+ async rotateAccessTokenSigningKey(agentContext, issuer) {
313
+ const accessTokenSignerKey = await agentContext.wallet.createKey({
314
+ keyType: core_1.KeyType.Ed25519,
315
+ });
316
+ // TODO: ideally we can remove the previous key
317
+ issuer.accessTokenPublicKeyFingerprint = accessTokenSignerKey.fingerprint;
318
+ await this.openId4VcIssuerRepository.update(agentContext, issuer);
319
+ }
320
+ getIssuerMetadata(agentContext, issuerRecord) {
321
+ const config = agentContext.dependencyManager.resolve(OpenId4VcIssuerModuleConfig_1.OpenId4VcIssuerModuleConfig);
322
+ const issuerUrl = (0, core_1.joinUriParts)(config.baseUrl, [issuerRecord.issuerId]);
323
+ const issuerMetadata = {
324
+ issuerUrl,
325
+ tokenEndpoint: (0, core_1.joinUriParts)(issuerUrl, [config.accessTokenEndpoint.endpointPath]),
326
+ credentialEndpoint: (0, core_1.joinUriParts)(issuerUrl, [config.credentialEndpoint.endpointPath]),
327
+ credentialsSupported: issuerRecord.credentialsSupported,
328
+ issuerDisplay: issuerRecord.display,
329
+ };
330
+ return issuerMetadata;
331
+ }
332
+ getVcIssuer(agentContext, issuer) {
333
+ const issuerMetadata = this.getIssuerMetadata(agentContext, issuer);
334
+ const builder = new oid4vci_issuer_1.VcIssuerBuilder()
335
+ .withCredentialIssuer(issuerMetadata.issuerUrl)
336
+ .withCredentialEndpoint(issuerMetadata.credentialEndpoint)
337
+ .withTokenEndpoint(issuerMetadata.tokenEndpoint)
338
+ .withCredentialsSupported(issuerMetadata.credentialsSupported)
339
+ .withCNonceStateManager(new OpenId4VcCNonceStateManager_1.OpenId4VcCNonceStateManager(agentContext, issuer.issuerId))
340
+ .withCredentialOfferStateManager(new OpenId4VcCredentialOfferSessionStateManager_1.OpenId4VcCredentialOfferSessionStateManager(agentContext, issuer.issuerId))
341
+ .withCredentialOfferURIStateManager(new OpenId4VcCredentialOfferUriStateManager_1.OpenId4VcCredentialOfferUriStateManager(agentContext, issuer.issuerId))
342
+ .withJWTVerifyCallback(this.getJwtVerifyCallback(agentContext))
343
+ .withCredentialSignerCallback(() => {
344
+ throw new core_1.CredoError('Credential signer callback should be overwritten. This is a no-op');
345
+ });
346
+ if (issuerMetadata.authorizationServer) {
347
+ builder.withAuthorizationServer(issuerMetadata.authorizationServer);
348
+ }
349
+ if (issuerMetadata.issuerDisplay) {
350
+ builder.withIssuerDisplay(issuerMetadata.issuerDisplay);
351
+ }
352
+ return builder.build();
353
+ }
354
+ async getGrantsFromConfig(agentContext, preAuthorizedCodeFlowConfig) {
355
+ var _a, _b;
356
+ const grants = {
357
+ 'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
358
+ 'pre-authorized_code': (_a = preAuthorizedCodeFlowConfig.preAuthorizedCode) !== null && _a !== void 0 ? _a : (await agentContext.wallet.generateNonce()),
359
+ user_pin_required: (_b = preAuthorizedCodeFlowConfig.userPinRequired) !== null && _b !== void 0 ? _b : false,
360
+ },
361
+ };
362
+ return grants;
363
+ }
364
+ findOfferedCredentialsMatchingRequest(credentialOffer, credentialRequest, credentialsSupported) {
365
+ const offeredCredentials = (0, shared_1.getOfferedCredentials)(credentialOffer.credentials, credentialsSupported);
366
+ return offeredCredentials.filter((offeredCredential) => {
367
+ if (offeredCredential.format !== credentialRequest.format)
368
+ return false;
369
+ if (credentialRequest.format === shared_1.OpenId4VciCredentialFormatProfile.JwtVcJson &&
370
+ offeredCredential.format === credentialRequest.format) {
371
+ return (0, core_1.equalsIgnoreOrder)(offeredCredential.types, credentialRequest.types);
372
+ }
373
+ else if (credentialRequest.format === shared_1.OpenId4VciCredentialFormatProfile.JwtVcJsonLd &&
374
+ offeredCredential.format === credentialRequest.format) {
375
+ return (0, core_1.equalsIgnoreOrder)(offeredCredential.types, credentialRequest.credential_definition.types);
376
+ }
377
+ else if (credentialRequest.format === shared_1.OpenId4VciCredentialFormatProfile.LdpVc &&
378
+ offeredCredential.format === credentialRequest.format) {
379
+ return (0, core_1.equalsIgnoreOrder)(offeredCredential.types, credentialRequest.credential_definition.types);
380
+ }
381
+ else if (credentialRequest.format === shared_1.OpenId4VciCredentialFormatProfile.SdJwtVc &&
382
+ offeredCredential.format === credentialRequest.format) {
383
+ return offeredCredential.vct === credentialRequest.vct;
384
+ }
385
+ return false;
386
+ });
387
+ }
388
+ async getHolderBindingFromRequest(credentialRequest) {
389
+ var _a;
390
+ if (!((_a = credentialRequest.proof) === null || _a === void 0 ? void 0 : _a.jwt))
391
+ throw new core_1.CredoError('Received a credential request without a proof');
392
+ const jwt = core_1.Jwt.fromSerializedJwt(credentialRequest.proof.jwt);
393
+ if (jwt.header.kid) {
394
+ if (!jwt.header.kid.startsWith('did:')) {
395
+ throw new core_1.CredoError("Only did is supported for 'kid' identifier");
396
+ }
397
+ else if (!jwt.header.kid.includes('#')) {
398
+ throw new core_1.CredoError(`kid containing did MUST point to a specific key within the did document: ${jwt.header.kid}`);
399
+ }
400
+ return {
401
+ method: 'did',
402
+ didUrl: jwt.header.kid,
403
+ };
404
+ }
405
+ else if (jwt.header.jwk) {
406
+ return {
407
+ method: 'jwk',
408
+ jwk: (0, core_1.getJwkFromJson)(jwt.header.jwk),
409
+ };
410
+ }
411
+ else {
412
+ throw new core_1.CredoError('Either kid or jwk must be present in credential request proof header');
413
+ }
414
+ }
415
+ };
416
+ OpenId4VcIssuerService = __decorate([
417
+ (0, core_1.injectable)(),
418
+ __metadata("design:paramtypes", [core_1.W3cCredentialService,
419
+ core_1.JwsService,
420
+ OpenId4VcIssuerModuleConfig_1.OpenId4VcIssuerModuleConfig,
421
+ repository_1.OpenId4VcIssuerRepository,
422
+ repository_1.OpenId4VcIssuanceSessionRepository])
423
+ ], OpenId4VcIssuerService);
424
+ exports.OpenId4VcIssuerService = OpenId4VcIssuerService;
425
+ //# sourceMappingURL=OpenId4VcIssuerService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4VcIssuerService.js","sourceRoot":"","sources":["../../src/openid4vc-issuer/OpenId4VcIssuerService.ts"],"names":[],"mappings":";;;;;;;;;;;;AA0BA,yCAkBuB;AACvB,6DAA0D;AAE1D,sCAAoF;AACpF,6CAAsE;AACtE,mDAAqE;AACrE,2CAAqD;AAErD,mFAA+E;AAC/E,+EAA2E;AAC3E,6CAAmH;AACnH,0FAAsF;AACtF,0HAAsH;AACtH,kHAA8G;AAC9G,gEAAyE;AAEzE,MAAM,mBAAmB,GAAG;IAC1B,0CAAiC,CAA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AAC,+CAA+C,CAAC,CAAA;QAExG,MAAM,GAAG,GAAG,UAAG,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAE9D,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE;YAClB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;gBACtC,MAAM,IAAI,iBAAU,CAAC,4CAA4C,CAAC,CAAA;aACnE;iBAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACxC,MAAM,IAAI,iBAAU,CAClB,4EAA4E,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAC7F,CAAA;aACF;YAED,OAAO;gBACL,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG;aACoB,CAAA;SAC7C;aAAM,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE;YACzB,OAAO;gBACL,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,IAAA,qBAAc,EAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC;aACO,CAAA;SAC7C;aAAM;YACL,MAAM,IAAI,iBAAU,CAAC,sEAAsE,CAAC,CAAA;SAC7F;IACH,CAAC;CA+EF,CAAA;AAtfY,sBAAsB;IADlC,IAAA,iBAAU,GAAE;qCASa,2BAAoB;QAC9B,iBAAU;QACC,yDAA2B;QACvB,sCAAyB;QAChB,+CAAkC;GAZ7D,sBAAsB,CAsflC;AAtfY,wDAAsB"}
@@ -0,0 +1,88 @@
1
+ import type { OpenId4VcIssuanceSessionRecord } from './repository';
2
+ import type { OpenId4VcCredentialHolderBinding, OpenId4VciCredentialOffer, OpenId4VciCredentialRequest, OpenId4VciCredentialSupported, OpenId4VciCredentialSupportedWithId, OpenId4VciIssuerMetadataDisplay } from '../shared';
3
+ import type { AgentContext, ClaimFormat, W3cCredential, SdJwtVcSignOptions } from '@credo-ts/core';
4
+ export interface OpenId4VciPreAuthorizedCodeFlowConfig {
5
+ preAuthorizedCode?: string;
6
+ userPinRequired?: boolean;
7
+ }
8
+ export type OpenId4VcIssuerMetadata = {
9
+ issuerUrl: string;
10
+ credentialEndpoint: string;
11
+ tokenEndpoint: string;
12
+ authorizationServer?: string;
13
+ issuerDisplay?: OpenId4VciIssuerMetadataDisplay[];
14
+ credentialsSupported: OpenId4VciCredentialSupported[];
15
+ };
16
+ export interface OpenId4VciCreateCredentialOfferOptions {
17
+ offeredCredentials: string[];
18
+ /**
19
+ * baseUri for the credential offer uri. By default `openid-credential-offer://` will be used
20
+ * if no value is provided. If a value is provided, make sure it contains the scheme as well as `://`.
21
+ */
22
+ baseUri?: string;
23
+ preAuthorizedCodeFlowConfig: OpenId4VciPreAuthorizedCodeFlowConfig;
24
+ /**
25
+ * Metadata about the issuance, that will be stored in the issuance session record and
26
+ * passed to the credential request to credential mapper. This can be used to e.g. store an
27
+ * user identifier so user data can be fetched in the credential mapper, or the actual credential
28
+ * data.
29
+ */
30
+ issuanceMetadata?: Record<string, unknown>;
31
+ }
32
+ export interface OpenId4VciCreateCredentialResponseOptions {
33
+ credentialRequest: OpenId4VciCredentialRequest;
34
+ /**
35
+ * You can optionally provide a credential request to credential mapper that will be
36
+ * dynamically invoked to return credential data based on the credential request.
37
+ *
38
+ * If not provided, the `credentialRequestToCredentialMapper` from the agent config
39
+ * will be used.
40
+ */
41
+ credentialRequestToCredentialMapper?: OpenId4VciCredentialRequestToCredentialMapper;
42
+ }
43
+ export type OpenId4VciCredentialRequestToCredentialMapper = (options: {
44
+ agentContext: AgentContext;
45
+ /**
46
+ * The issuance session associated with the credential request. You can extract the
47
+ * issuance metadata from this record if passed in the offer creation method.
48
+ */
49
+ issuanceSession: OpenId4VcIssuanceSessionRecord;
50
+ /**
51
+ * The credential request received from the wallet
52
+ */
53
+ credentialRequest: OpenId4VciCredentialRequest;
54
+ /**
55
+ * The offer associated with the credential request
56
+ */
57
+ credentialOffer: OpenId4VciCredentialOffer;
58
+ /**
59
+ * Verified key binding material that should be included in the credential
60
+ *
61
+ * Can either be bound to did or a JWK (in case of for ex. SD-JWT)
62
+ */
63
+ holderBinding: OpenId4VcCredentialHolderBinding;
64
+ /**
65
+ * The credentials supported entries from the issuer metadata that were offered
66
+ * and match the incoming request
67
+ *
68
+ * NOTE: in v12 this will probably become a single entry, as it will be matched on id
69
+ */
70
+ credentialsSupported: OpenId4VciCredentialSupported[];
71
+ }) => Promise<OpenId4VciSignCredential> | OpenId4VciSignCredential;
72
+ export type OpenId4VciSignCredential = OpenId4VciSignSdJwtCredential | OpenId4VciSignW3cCredential;
73
+ export interface OpenId4VciSignSdJwtCredential extends SdJwtVcSignOptions {
74
+ format: ClaimFormat.SdJwtVc | `${ClaimFormat.SdJwtVc}`;
75
+ }
76
+ export interface OpenId4VciSignW3cCredential {
77
+ format: ClaimFormat.JwtVc | `${ClaimFormat.JwtVc}` | ClaimFormat.LdpVc | `${ClaimFormat.LdpVc}`;
78
+ verificationMethod: string;
79
+ credential: W3cCredential;
80
+ }
81
+ export interface OpenId4VciCreateIssuerOptions {
82
+ /**
83
+ * Id of the issuer, not the id of the issuer record. Will be exposed publicly
84
+ */
85
+ issuerId?: string;
86
+ credentialsSupported: OpenId4VciCredentialSupportedWithId[];
87
+ display?: OpenId4VciIssuerMetadataDisplay[];
88
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=OpenId4VcIssuerServiceOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4VcIssuerServiceOptions.js","sourceRoot":"","sources":["../../src/openid4vc-issuer/OpenId4VcIssuerServiceOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export * from './OpenId4VcIssuerApi';
2
+ export * from './OpenId4VcIssuerModule';
3
+ export * from './OpenId4VcIssuerService';
4
+ export * from './OpenId4VcIssuerModuleConfig';
5
+ export * from './OpenId4VcIssuerServiceOptions';
6
+ export * from './OpenId4VcIssuerEvents';
7
+ export * from './OpenId4VcIssuanceSessionState';
8
+ export { OpenId4VcIssuerRecord, OpenId4VcIssuerRecordProps, OpenId4VcIssuerRecordTags } from './repository';
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.OpenId4VcIssuerRecord = void 0;
18
+ __exportStar(require("./OpenId4VcIssuerApi"), exports);
19
+ __exportStar(require("./OpenId4VcIssuerModule"), exports);
20
+ __exportStar(require("./OpenId4VcIssuerService"), exports);
21
+ __exportStar(require("./OpenId4VcIssuerModuleConfig"), exports);
22
+ __exportStar(require("./OpenId4VcIssuerServiceOptions"), exports);
23
+ __exportStar(require("./OpenId4VcIssuerEvents"), exports);
24
+ __exportStar(require("./OpenId4VcIssuanceSessionState"), exports);
25
+ var repository_1 = require("./repository");
26
+ Object.defineProperty(exports, "OpenId4VcIssuerRecord", { enumerable: true, get: function () { return repository_1.OpenId4VcIssuerRecord; } });
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openid4vc-issuer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uDAAoC;AACpC,0DAAuC;AACvC,2DAAwC;AACxC,gEAA6C;AAC7C,kEAA+C;AAC/C,0DAAuC;AACvC,kEAA+C;AAC/C,2CAA2G;AAAlG,mHAAA,qBAAqB,OAAA"}
@@ -0,0 +1,18 @@
1
+ import type { AgentContext } from '@credo-ts/core';
2
+ import type { CNonceState, IStateManager } from '@sphereon/oid4vci-common';
3
+ export declare class OpenId4VcCNonceStateManager implements IStateManager<CNonceState> {
4
+ private agentContext;
5
+ private issuerId;
6
+ private openId4VcIssuanceSessionRepository;
7
+ private openId4VcIssuerModuleConfig;
8
+ constructor(agentContext: AgentContext, issuerId: string);
9
+ set(cNonce: string, stateValue: CNonceState): Promise<void>;
10
+ get(cNonce: string): Promise<CNonceState | undefined>;
11
+ has(cNonce: string): Promise<boolean>;
12
+ delete(cNonce: string): Promise<boolean>;
13
+ clearExpired(): Promise<void>;
14
+ clearAll(): Promise<void>;
15
+ getAsserted(id: string): Promise<CNonceState>;
16
+ startCleanupRoutine(): Promise<void>;
17
+ stopCleanupRoutine(): Promise<void>;
18
+ }