@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,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenId4VcCNonceStateManager = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const OpenId4VcIssuerModuleConfig_1 = require("../OpenId4VcIssuerModuleConfig");
6
+ const OpenId4VcIssuanceSessionRepository_1 = require("./OpenId4VcIssuanceSessionRepository");
7
+ class OpenId4VcCNonceStateManager {
8
+ constructor(agentContext, issuerId) {
9
+ this.agentContext = agentContext;
10
+ this.issuerId = issuerId;
11
+ this.openId4VcIssuanceSessionRepository = agentContext.dependencyManager.resolve(OpenId4VcIssuanceSessionRepository_1.OpenId4VcIssuanceSessionRepository);
12
+ this.openId4VcIssuerModuleConfig = agentContext.dependencyManager.resolve(OpenId4VcIssuerModuleConfig_1.OpenId4VcIssuerModuleConfig);
13
+ }
14
+ async set(cNonce, stateValue) {
15
+ // Just to make sure that the cNonce is the same as the id as that's what we use to query
16
+ if (cNonce !== stateValue.cNonce) {
17
+ throw new core_1.CredoError('Expected the id of the cNonce state to be equal to the cNonce');
18
+ }
19
+ if (!stateValue.preAuthorizedCode) {
20
+ throw new core_1.CredoError("Expected the stateValue to have a 'preAuthorizedCode' property");
21
+ }
22
+ // Record MUST exist (otherwise there's no issuance session active yet)
23
+ const record = await this.openId4VcIssuanceSessionRepository.getSingleByQuery(this.agentContext, {
24
+ // NOTE: once we support authorized flow, we need to add an $or for the issuer state as well
25
+ issuerId: this.issuerId,
26
+ preAuthorizedCode: stateValue.preAuthorizedCode,
27
+ });
28
+ // cNonce already matches, no need to update
29
+ if (record.cNonce === stateValue.cNonce) {
30
+ return;
31
+ }
32
+ const expiresAtDate = new Date(Date.now() + this.openId4VcIssuerModuleConfig.accessTokenEndpoint.cNonceExpiresInSeconds * 1000);
33
+ record.cNonce = stateValue.cNonce;
34
+ record.cNonceExpiresAt = expiresAtDate;
35
+ await this.openId4VcIssuanceSessionRepository.update(this.agentContext, record);
36
+ }
37
+ async get(cNonce) {
38
+ const record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
39
+ issuerId: this.issuerId,
40
+ cNonce,
41
+ });
42
+ if (!record)
43
+ return undefined;
44
+ // NOTE: This should not happen as we query by the credential offer uri
45
+ // so it's mostly to make TS happy
46
+ if (!record.cNonce) {
47
+ throw new core_1.CredoError('No cNonce found on record.');
48
+ }
49
+ return {
50
+ cNonce: record.cNonce,
51
+ preAuthorizedCode: record.preAuthorizedCode,
52
+ createdAt: record.createdAt.getTime(),
53
+ };
54
+ }
55
+ async has(cNonce) {
56
+ const record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
57
+ issuerId: this.issuerId,
58
+ cNonce,
59
+ });
60
+ return record !== undefined;
61
+ }
62
+ async delete(cNonce) {
63
+ const record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
64
+ issuerId: this.issuerId,
65
+ cNonce,
66
+ });
67
+ if (!record)
68
+ return false;
69
+ // We only remove the cNonce from the record, we don't want to remove
70
+ // the whole issuance session.
71
+ record.cNonce = undefined;
72
+ record.cNonceExpiresAt = undefined;
73
+ await this.openId4VcIssuanceSessionRepository.update(this.agentContext, record);
74
+ return true;
75
+ }
76
+ async clearExpired() {
77
+ // FIXME: we should have a way to remove expired records
78
+ // or just not return the value in the get if the record is expired
79
+ throw new Error('Method not implemented.');
80
+ }
81
+ async clearAll() {
82
+ throw new Error('Method not implemented.');
83
+ }
84
+ async getAsserted(id) {
85
+ const state = await this.get(id);
86
+ if (!state) {
87
+ throw new core_1.CredoError(`No cNonce state found for id ${id}`);
88
+ }
89
+ return state;
90
+ }
91
+ async startCleanupRoutine() {
92
+ throw new Error('Method not implemented.');
93
+ }
94
+ async stopCleanupRoutine() {
95
+ throw new Error('Method not implemented.');
96
+ }
97
+ }
98
+ exports.OpenId4VcCNonceStateManager = OpenId4VcCNonceStateManager;
99
+ //# sourceMappingURL=OpenId4VcCNonceStateManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4VcCNonceStateManager.js","sourceRo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,SAAS,CAAA;QACzB,MAAM,CAAC,eAAe,GAAG,SAAS,CAAA;QAClC,MAAM,IAAI,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;QAC/E,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,wDAAwD;QACxD,mEAAmE;QACnE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,EAAU;QACjC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAEhC,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,iBAAU,CAAC,gCAAgC,EAAE,EAAE,CAAC,CAAA;SAC3D;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAEM,KAAK,CAAC,mBAAmB;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC7B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;CACF;AAjHD,kEAiHC"}
@@ -0,0 +1,21 @@
1
+ import type { AgentContext } from '@credo-ts/core';
2
+ import type { CredentialOfferSession, IStateManager } from '@sphereon/oid4vci-common';
3
+ import { OpenId4VcIssuanceSessionState } from '../OpenId4VcIssuanceSessionState';
4
+ import { OpenId4VcIssuanceSessionRecord } from './OpenId4VcIssuanceSessionRecord';
5
+ export declare class OpenId4VcCredentialOfferSessionStateManager implements IStateManager<CredentialOfferSession> {
6
+ private agentContext;
7
+ private issuerId;
8
+ private openId4VcIssuanceSessionRepository;
9
+ private eventEmitter;
10
+ constructor(agentContext: AgentContext, issuerId: string);
11
+ set(preAuthorizedCode: string, stateValue: CredentialOfferSession): Promise<void>;
12
+ get(preAuthorizedCode: string): Promise<CredentialOfferSession | undefined>;
13
+ has(preAuthorizedCode: string): Promise<boolean>;
14
+ delete(preAuthorizedCode: string): Promise<boolean>;
15
+ clearExpired(): Promise<void>;
16
+ clearAll(): Promise<void>;
17
+ getAsserted(preAuthorizedCode: string): Promise<CredentialOfferSession>;
18
+ startCleanupRoutine(): Promise<void>;
19
+ stopCleanupRoutine(): Promise<void>;
20
+ protected emitStateChangedEvent(agentContext: AgentContext, issuanceSession: OpenId4VcIssuanceSessionRecord, previousState: OpenId4VcIssuanceSessionState | null): void;
21
+ }
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenId4VcCredentialOfferSessionStateManager = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const oid4vci_common_1 = require("@sphereon/oid4vci-common");
6
+ const OpenId4VcIssuanceSessionState_1 = require("../OpenId4VcIssuanceSessionState");
7
+ const OpenId4VcIssuerEvents_1 = require("../OpenId4VcIssuerEvents");
8
+ const OpenId4VcIssuanceSessionRecord_1 = require("./OpenId4VcIssuanceSessionRecord");
9
+ const OpenId4VcIssuanceSessionRepository_1 = require("./OpenId4VcIssuanceSessionRepository");
10
+ class OpenId4VcCredentialOfferSessionStateManager {
11
+ constructor(agentContext, issuerId) {
12
+ this.agentContext = agentContext;
13
+ this.issuerId = issuerId;
14
+ this.openId4VcIssuanceSessionRepository = agentContext.dependencyManager.resolve(OpenId4VcIssuanceSessionRepository_1.OpenId4VcIssuanceSessionRepository);
15
+ this.eventEmitter = agentContext.dependencyManager.resolve(core_1.EventEmitter);
16
+ }
17
+ async set(preAuthorizedCode, stateValue) {
18
+ var _a;
19
+ // Just to make sure that the preAuthorizedCode is the same as the id as that's what we use to query
20
+ // NOTE: once we support authorized flow, we need to also allow the id to be equal to issuer state
21
+ if (preAuthorizedCode !== stateValue.preAuthorizedCode) {
22
+ throw new core_1.CredoError('Expected the id of the credential offer state to be equal to the preAuthorizedCode');
23
+ }
24
+ if (!stateValue.preAuthorizedCode) {
25
+ throw new core_1.CredoError("Expected the stateValue to have a 'preAuthorizedCode' property");
26
+ }
27
+ // Record may already exist
28
+ let record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
29
+ issuerId: this.issuerId,
30
+ preAuthorizedCode: stateValue.preAuthorizedCode,
31
+ });
32
+ const previousState = (_a = record === null || record === void 0 ? void 0 : record.state) !== null && _a !== void 0 ? _a : null;
33
+ let credentialOfferUri = stateValue.credentialOffer.credential_offer_uri;
34
+ if (!credentialOfferUri) {
35
+ throw new core_1.CredoError("Expected the stateValue to have a 'credentialOfferUri' property");
36
+ }
37
+ if (credentialOfferUri.includes('credential_offer_uri=')) {
38
+ // NOTE: it's a bit cumbersome, but the credential_offer_uri is the encoded uri. This seems
39
+ // odd to me, as this is the offer payload, which should only contain the hosted URI (I think
40
+ // this is a bug in OID4VCI). But for now we have to extract the uri from the payload.
41
+ credentialOfferUri = decodeURIComponent(credentialOfferUri.split('credential_offer_uri=')[1].split('=')[0]);
42
+ }
43
+ // NOTE: we don't use clientId at the moment, will become relevant when doing the authorized flow
44
+ if (record) {
45
+ record.issuanceMetadata = stateValue.credentialDataSupplierInput;
46
+ record.credentialOfferPayload = stateValue.credentialOffer.credential_offer;
47
+ record.userPin = stateValue.userPin;
48
+ record.preAuthorizedCode = stateValue.preAuthorizedCode;
49
+ record.errorMessage = stateValue.error;
50
+ record.credentialOfferUri = credentialOfferUri;
51
+ record.state = openId4VcIssuanceStateFromSphereon(stateValue.status);
52
+ await this.openId4VcIssuanceSessionRepository.update(this.agentContext, record);
53
+ }
54
+ else {
55
+ record = new OpenId4VcIssuanceSessionRecord_1.OpenId4VcIssuanceSessionRecord({
56
+ issuerId: this.issuerId,
57
+ preAuthorizedCode: stateValue.preAuthorizedCode,
58
+ issuanceMetadata: stateValue.credentialDataSupplierInput,
59
+ credentialOfferPayload: stateValue.credentialOffer.credential_offer,
60
+ credentialOfferUri,
61
+ userPin: stateValue.userPin,
62
+ errorMessage: stateValue.error,
63
+ state: openId4VcIssuanceStateFromSphereon(stateValue.status),
64
+ });
65
+ await this.openId4VcIssuanceSessionRepository.save(this.agentContext, record);
66
+ }
67
+ this.emitStateChangedEvent(this.agentContext, record, previousState);
68
+ }
69
+ async get(preAuthorizedCode) {
70
+ var _a, _b;
71
+ const record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
72
+ issuerId: this.issuerId,
73
+ preAuthorizedCode,
74
+ });
75
+ if (!record)
76
+ return undefined;
77
+ // NOTE: This should not happen as we query by the preAuthorizedCode
78
+ // so it's mostly to make TS happy
79
+ if (!record.preAuthorizedCode) {
80
+ throw new core_1.CredoError("No 'preAuthorizedCode' found on record.");
81
+ }
82
+ if (!record.credentialOfferPayload) {
83
+ throw new core_1.CredoError("No 'credentialOfferPayload' found on record.");
84
+ }
85
+ return {
86
+ credentialOffer: {
87
+ credential_offer: record.credentialOfferPayload,
88
+ credential_offer_uri: record.credentialOfferUri,
89
+ },
90
+ status: sphereonIssueStatusFromOpenId4VcIssuanceState(record.state),
91
+ preAuthorizedCode: record.preAuthorizedCode,
92
+ credentialDataSupplierInput: record.issuanceMetadata,
93
+ error: record.errorMessage,
94
+ userPin: record.userPin,
95
+ createdAt: record.createdAt.getTime(),
96
+ lastUpdatedAt: (_b = (_a = record.updatedAt) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : record.createdAt.getTime(),
97
+ };
98
+ }
99
+ async has(preAuthorizedCode) {
100
+ const record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
101
+ issuerId: this.issuerId,
102
+ preAuthorizedCode,
103
+ });
104
+ return record !== undefined;
105
+ }
106
+ async delete(preAuthorizedCode) {
107
+ const record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
108
+ issuerId: this.issuerId,
109
+ preAuthorizedCode,
110
+ });
111
+ if (!record)
112
+ return false;
113
+ await this.openId4VcIssuanceSessionRepository.deleteById(this.agentContext, record.id);
114
+ return true;
115
+ }
116
+ async clearExpired() {
117
+ // FIXME: we should have a way to remove expired records
118
+ // or just not return the value in the get if the record is expired
119
+ throw new Error('Method not implemented.');
120
+ }
121
+ async clearAll() {
122
+ throw new Error('Method not implemented.');
123
+ }
124
+ async getAsserted(preAuthorizedCode) {
125
+ const state = await this.get(preAuthorizedCode);
126
+ if (!state) {
127
+ throw new core_1.CredoError(`No credential offer state found for id ${preAuthorizedCode}`);
128
+ }
129
+ return state;
130
+ }
131
+ async startCleanupRoutine() {
132
+ throw new Error('Method not implemented.');
133
+ }
134
+ async stopCleanupRoutine() {
135
+ throw new Error('Method not implemented.');
136
+ }
137
+ emitStateChangedEvent(agentContext, issuanceSession, previousState) {
138
+ this.eventEmitter.emit(agentContext, {
139
+ type: OpenId4VcIssuerEvents_1.OpenId4VcIssuerEvents.IssuanceSessionStateChanged,
140
+ payload: {
141
+ issuanceSession: issuanceSession.clone(),
142
+ previousState,
143
+ },
144
+ });
145
+ }
146
+ }
147
+ exports.OpenId4VcCredentialOfferSessionStateManager = OpenId4VcCredentialOfferSessionStateManager;
148
+ function openId4VcIssuanceStateFromSphereon(stateValue) {
149
+ if (stateValue === oid4vci_common_1.IssueStatus.OFFER_CREATED)
150
+ return OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.OfferCreated;
151
+ if (stateValue === oid4vci_common_1.IssueStatus.OFFER_URI_RETRIEVED)
152
+ return OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.OfferUriRetrieved;
153
+ if (stateValue === oid4vci_common_1.IssueStatus.ACCESS_TOKEN_REQUESTED)
154
+ return OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.AccessTokenRequested;
155
+ if (stateValue === oid4vci_common_1.IssueStatus.ACCESS_TOKEN_CREATED)
156
+ return OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.AccessTokenCreated;
157
+ if (stateValue === oid4vci_common_1.IssueStatus.CREDENTIAL_REQUEST_RECEIVED)
158
+ return OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialRequestReceived;
159
+ if (stateValue === oid4vci_common_1.IssueStatus.CREDENTIAL_ISSUED)
160
+ return OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialIssued;
161
+ if (stateValue === oid4vci_common_1.IssueStatus.ERROR)
162
+ return OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.Error;
163
+ throw new core_1.CredoError(`Unknown state value: ${stateValue}`);
164
+ }
165
+ function sphereonIssueStatusFromOpenId4VcIssuanceState(state) {
166
+ if (state === OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.OfferCreated)
167
+ return oid4vci_common_1.IssueStatus.OFFER_CREATED;
168
+ if (state === OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.OfferUriRetrieved)
169
+ return oid4vci_common_1.IssueStatus.OFFER_URI_RETRIEVED;
170
+ if (state === OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.AccessTokenRequested)
171
+ return oid4vci_common_1.IssueStatus.ACCESS_TOKEN_REQUESTED;
172
+ if (state === OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.AccessTokenCreated)
173
+ return oid4vci_common_1.IssueStatus.ACCESS_TOKEN_CREATED;
174
+ if (state === OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialRequestReceived)
175
+ return oid4vci_common_1.IssueStatus.CREDENTIAL_REQUEST_RECEIVED;
176
+ if (state === OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.CredentialIssued)
177
+ return oid4vci_common_1.IssueStatus.CREDENTIAL_ISSUED;
178
+ if (state === OpenId4VcIssuanceSessionState_1.OpenId4VcIssuanceSessionState.Error)
179
+ return oid4vci_common_1.IssueStatus.ERROR;
180
+ throw new core_1.CredoError(`Unknown state value: ${state}`);
181
+ }
182
+ //# sourceMappingURL=OpenId4VcCredentialOfferSessionStateManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4VcCredentialOfferSessionStateManager.js","sourceRoot":"","sources":["../../../src/openid4vc-issuer/repository/OpenId4VcCredentialOfferSessionStateManager.ts"],"names":[],"mappings":";;;AAIA,yCAAyD;AACzD,6DAAsD;AAEtD,oFAAgF;AAChF,oEAAgE;AAEhE,qFAAiF;AACjF,6FAAyF;AAEzF,MAAa,2CAA2C;IAItD,YAA2B,YAA0B,EAAU,QAAgB;QAApD,iBAAY,GAAZ,YAAY,CAAc;QAAU,aAAQ,GAAR,QAAQ,CAAQ;QAC7E,IAAI,CAAC,kCAAkC,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,uEAAkC,CAAC,CAAA;QACpH,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,mBAAY,CAAC,CAAA;IAC1E,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,iBAAyB,EAAE,UAAkC;;QAC5E,oGAAoG;QACpG,kGAAkG;QAClG,IAAI,iBAAiB,KAAK,UAAU,CAAC,iBAAiB,EAAE;YACtD,MAAM,IAAI,iBAAU,CAAC,oFAAoF,CAAC,CAAA;SAC3G;QAED,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE;YACjC,MAAM,IAAI,iBAAU,CAAC,gEAAgE,CAAC,CAAA;SACvF;QAED,2BAA2B;QAC3B,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,kCAAkC,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,EAAE;YAC9F,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;SAChD,CAAC,CAAA;QAEF,MAAM,aAAa,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,mCAAI,IAAI,CAAA;QAE3C,IAAI,kBAAkB,GAA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AC,aAAa,CAAA;IAC1F,IAAI,KAAK,KAAK,6DAA6B,CAAC,iBAAiB;QAAE,OAAO,4BAAW,CAAC,mBAAmB,CAAA;IACrG,IAAI,KAAK,KAAK,6DAA6B,CAAC,oBAAoB;QAAE,OAAO,4BAAW,CAAC,sBAAsB,CAAA;IAC3G,IAAI,KAAK,KAAK,6DAA6B,CAAC,kBAAkB;QAAE,OAAO,4BAAW,CAAC,oBAAoB,CAAA;IACvG,IAAI,KAAK,KAAK,6DAA6B,CAAC,yBAAyB;QAAE,OAAO,4BAAW,CAAC,2BAA2B,CAAA;IACrH,IAAI,KAAK,KAAK,6DAA6B,CAAC,gBAAgB;QAAE,OAAO,4BAAW,CAAC,iBAAiB,CAAA;IAClG,IAAI,KAAK,KAAK,6DAA6B,CAAC,KAAK;QAAE,OAAO,4BAAW,CAAC,KAAK,CAAA;IAE3E,MAAM,IAAI,iBAAU,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAA;AACvD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { AgentContext } from '@credo-ts/core';
2
+ import type { IStateManager, URIState } from '@sphereon/oid4vci-common';
3
+ export declare class OpenId4VcCredentialOfferUriStateManager implements IStateManager<URIState> {
4
+ private agentContext;
5
+ private issuerId;
6
+ private openId4VcIssuanceSessionRepository;
7
+ constructor(agentContext: AgentContext, issuerId: string);
8
+ set(uri: string, stateValue: URIState): Promise<void>;
9
+ get(uri: string): Promise<URIState | undefined>;
10
+ has(uri: string): Promise<boolean>;
11
+ delete(): Promise<boolean>;
12
+ clearExpired(): Promise<void>;
13
+ clearAll(): Promise<void>;
14
+ getAsserted(id: string): Promise<URIState>;
15
+ startCleanupRoutine(): Promise<void>;
16
+ stopCleanupRoutine(): Promise<void>;
17
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenId4VcCredentialOfferUriStateManager = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const OpenId4VcIssuanceSessionRepository_1 = require("./OpenId4VcIssuanceSessionRepository");
6
+ class OpenId4VcCredentialOfferUriStateManager {
7
+ constructor(agentContext, issuerId) {
8
+ this.agentContext = agentContext;
9
+ this.issuerId = issuerId;
10
+ this.openId4VcIssuanceSessionRepository = agentContext.dependencyManager.resolve(OpenId4VcIssuanceSessionRepository_1.OpenId4VcIssuanceSessionRepository);
11
+ }
12
+ async set(uri, stateValue) {
13
+ // Just to make sure that the uri is the same as the id as that's what we use to query
14
+ if (uri !== stateValue.uri) {
15
+ throw new core_1.CredoError('Expected the uri of the uri state to be equal to the id');
16
+ }
17
+ // NOTE: we're currently not ding anything here, as we store the uri in the record
18
+ // when the credential offer session is stored.
19
+ }
20
+ async get(uri) {
21
+ const record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
22
+ issuerId: this.issuerId,
23
+ credentialOfferUri: uri,
24
+ });
25
+ if (!record)
26
+ return undefined;
27
+ return {
28
+ preAuthorizedCode: record.preAuthorizedCode,
29
+ uri: record.credentialOfferUri,
30
+ createdAt: record.createdAt.getTime(),
31
+ };
32
+ }
33
+ async has(uri) {
34
+ const record = await this.openId4VcIssuanceSessionRepository.findSingleByQuery(this.agentContext, {
35
+ issuerId: this.issuerId,
36
+ credentialOfferUri: uri,
37
+ });
38
+ return record !== undefined;
39
+ }
40
+ async delete() {
41
+ // NOTE: we're not doing anything here as the uri is stored in the credential offer session
42
+ // Not sure how to best handle this, but for now we just don't delete it
43
+ return false;
44
+ }
45
+ async clearExpired() {
46
+ // FIXME: we should have a way to remove expired records
47
+ // or just not return the value in the get if the record is expired
48
+ throw new Error('Method not implemented.');
49
+ }
50
+ async clearAll() {
51
+ throw new Error('Method not implemented.');
52
+ }
53
+ async getAsserted(id) {
54
+ const state = await this.get(id);
55
+ if (!state) {
56
+ throw new core_1.CredoError(`No uri state found for id ${id}`);
57
+ }
58
+ return state;
59
+ }
60
+ async startCleanupRoutine() {
61
+ throw new Error('Method not implemented.');
62
+ }
63
+ async stopCleanupRoutine() {
64
+ throw new Error('Method not implemented.');
65
+ }
66
+ }
67
+ exports.OpenId4VcCredentialOfferUriStateManager = OpenId4VcCredentialOfferUriStateManager;
68
+ //# sourceMappingURL=OpenId4VcCredentialOfferUriStateManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4VcCredentialOfferUriStateManager.js","sourceRoot":"","sources":["../../../src/openid4vc-issuer/repository/OpenId4VcCredentialOfferUriStateManager.ts"],"names":[],"mappings":";;;AAGA,yCAA2C;AAE3C,6FAAyF;AAEzF,MAAa,uCAAuC;IAGlD,YAA2B,YAA0B,EAAU,QAAgB;QAApD,iBAAY,GAAZ,YAAY,CAAc;QAAU,aAAQ,GAAR,QAAQ,CAAQ;QAC7E,IAAI,CAAC,kCAAkC,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,uEAAkC,CAAC,CAAA;IACtH,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,UAAoB;QAChD,sFAAsF;QACtF,IAAI,GAAG,KAAK,UAAU,CAAC,GAAG,EAAE;YAC1B,MAAM,IAAI,iBAAU,CAAC,yDAAyD,CAAC,CAAA;SAChF;QAED,kFAAkF;QAClF,+CAA+C;IACjD,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW;QAC1B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kCAAkC,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,EAAE;YAChG,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,kBAAkB,EAAE,GAAG;SACxB,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM;YAAE,OAAO,SAAS,CAAA;QAE7B,OAAO;YACL,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,GAAG,EAAE,MAAM,CAAC,kBAAkB;YAC9B,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE;SACtC,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAW;QAC1B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kCAAkC,CAAC,iBAAiB,CAAC,IAAI,CAAC,YAAY,EAAE;YAChG,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,kBAAkB,EAAE,GAAG;SACxB,CAAC,CAAA;QAEF,OAAO,MAAM,KAAK,SAAS,CAAA;IAC7B,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,2FAA2F;QAC3F,wEAAwE;QACxE,OAAO,KAAK,CAAA;IACd,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,wDAAwD;QACxD,mEAAmE;QACnE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,EAAU;QACjC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAEhC,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,iBAAU,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAA;SACxD;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAEM,KAAK,CAAC,mBAAmB;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC7B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;CACF;AA1ED,0FA0EC"}
@@ -0,0 +1,84 @@
1
+ import type { OpenId4VciCredentialOfferPayload } from '../../shared';
2
+ import type { OpenId4VcIssuanceSessionState } from '../OpenId4VcIssuanceSessionState';
3
+ import type { RecordTags, TagsBase } from '@credo-ts/core';
4
+ import { BaseRecord } from '@credo-ts/core';
5
+ export type OpenId4VcIssuanceSessionRecordTags = RecordTags<OpenId4VcIssuanceSessionRecord>;
6
+ export type DefaultOpenId4VcIssuanceSessionRecordTags = {
7
+ issuerId: string;
8
+ cNonce?: string;
9
+ preAuthorizedCode?: string;
10
+ state: OpenId4VcIssuanceSessionState;
11
+ credentialOfferUri: string;
12
+ };
13
+ export interface OpenId4VcIssuanceSessionRecordProps {
14
+ id?: string;
15
+ createdAt?: Date;
16
+ tags?: TagsBase;
17
+ issuerId: string;
18
+ cNonce?: string;
19
+ cNonceExpiresAt?: Date;
20
+ preAuthorizedCode?: string;
21
+ userPin?: string;
22
+ credentialOfferUri: string;
23
+ credentialOfferPayload: OpenId4VciCredentialOfferPayload;
24
+ issuanceMetadata?: Record<string, unknown>;
25
+ state: OpenId4VcIssuanceSessionState;
26
+ errorMessage?: string;
27
+ }
28
+ export declare class OpenId4VcIssuanceSessionRecord extends BaseRecord<DefaultOpenId4VcIssuanceSessionRecordTags> {
29
+ static readonly type = "OpenId4VcIssuanceSessionRecord";
30
+ readonly type = "OpenId4VcIssuanceSessionRecord";
31
+ /**
32
+ * The id of the issuer that this session is for.
33
+ */
34
+ issuerId: string;
35
+ /**
36
+ * The state of the issuance session.
37
+ */
38
+ state: OpenId4VcIssuanceSessionState;
39
+ /**
40
+ * cNonce that should be used in the credential request by the holder.
41
+ */
42
+ cNonce?: string;
43
+ /**
44
+ * The time at which the cNonce expires.
45
+ */
46
+ cNonceExpiresAt?: Date;
47
+ /**
48
+ * Pre authorized code used for the issuance session. Only used when a pre-authorized credential
49
+ * offer is created.
50
+ */
51
+ preAuthorizedCode?: string;
52
+ /**
53
+ * Optional user pin that needs to be provided by the user in the access token request.
54
+ */
55
+ userPin?: string;
56
+ /**
57
+ * User-defined metadata that will be provided to the credential request to credential mapper
58
+ * to allow to retrieve the needed credential input data. Can be the credential data itself,
59
+ * or some other data that is needed to retrieve the credential data.
60
+ */
61
+ issuanceMetadata?: Record<string, unknown>;
62
+ /**
63
+ * The credential offer that was used to create the issuance session.
64
+ */
65
+ credentialOfferPayload: OpenId4VciCredentialOfferPayload;
66
+ /**
67
+ * URI of the credential offer. This is the url that cn can be used to retrieve
68
+ * the credential offer
69
+ */
70
+ credentialOfferUri: string;
71
+ /**
72
+ * Optional error message of the error that occurred during the issuance session. Will be set when state is {@link OpenId4VcIssuanceSessionState.Error}
73
+ */
74
+ errorMessage?: string;
75
+ constructor(props: OpenId4VcIssuanceSessionRecordProps);
76
+ assertState(expectedStates: OpenId4VcIssuanceSessionState | OpenId4VcIssuanceSessionState[]): void;
77
+ getTags(): {
78
+ issuerId: string;
79
+ cNonce: string | undefined;
80
+ credentialOfferUri: string;
81
+ preAuthorizedCode: string | undefined;
82
+ state: OpenId4VcIssuanceSessionState;
83
+ };
84
+ }
@@ -0,0 +1,58 @@
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.OpenId4VcIssuanceSessionRecord = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ class OpenId4VcIssuanceSessionRecord extends core_1.BaseRecord {
15
+ constructor(props) {
16
+ var _a, _b, _c;
17
+ super();
18
+ this.type = OpenId4VcIssuanceSessionRecord.type;
19
+ if (props) {
20
+ this.id = (_a = props.id) !== null && _a !== void 0 ? _a : core_1.utils.uuid();
21
+ this.createdAt = (_b = props.createdAt) !== null && _b !== void 0 ? _b : new Date();
22
+ this._tags = (_c = props.tags) !== null && _c !== void 0 ? _c : {};
23
+ this.issuerId = props.issuerId;
24
+ this.cNonce = props.cNonce;
25
+ this.cNonceExpiresAt = props.cNonceExpiresAt;
26
+ this.userPin = props.userPin;
27
+ this.preAuthorizedCode = props.preAuthorizedCode;
28
+ this.credentialOfferUri = props.credentialOfferUri;
29
+ this.credentialOfferPayload = props.credentialOfferPayload;
30
+ this.issuanceMetadata = props.issuanceMetadata;
31
+ this.state = props.state;
32
+ this.errorMessage = props.errorMessage;
33
+ }
34
+ }
35
+ assertState(expectedStates) {
36
+ if (!Array.isArray(expectedStates)) {
37
+ expectedStates = [expectedStates];
38
+ }
39
+ if (!expectedStates.includes(this.state)) {
40
+ throw new core_1.CredoError(`OpenId4VcIssuanceSessionRecord is in invalid state ${this.state}. Valid states are: ${expectedStates.join(', ')}.`);
41
+ }
42
+ }
43
+ getTags() {
44
+ return Object.assign(Object.assign({}, this._tags), { issuerId: this.issuerId, cNonce: this.cNonce, credentialOfferUri: this.credentialOfferUri, preAuthorizedCode: this.preAuthorizedCode, state: this.state });
45
+ }
46
+ }
47
+ OpenId4VcIssuanceSessionRecord.type = 'OpenId4VcIssuanceSessionRecord';
48
+ __decorate([
49
+ (0, core_1.DateTransformer)(),
50
+ __metadata("design:type", Date
51
+ /**
52
+ * Pre authorized code used for the issuance session. Only used when a pre-authorized credential
53
+ * offer is created.
54
+ */
55
+ )
56
+ ], OpenId4VcIssuanceSessionRecord.prototype, "cNonceExpiresAt", void 0);
57
+ exports.OpenId4VcIssuanceSessionRecord = OpenId4VcIssuanceSessionRecord;
58
+ //# sourceMappingURL=OpenId4VcIssuanceSessionRecord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4VcIssuanceSessionRecord.js","sourceRoot":"","sources":["../../../src/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRecord.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,yCAA+E;AAiC/E,MAAa,8BAA+B,SAAQ,iBAAqD;IA2DvG,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AC,IAAI,CACxG,IAAI,CACL,GAAG,CACL,CAAA;SACF;IACH,CAAC;IAEM,OAAO;QACZ,uCACK,IAAI,CAAC,KAAK,KACb,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,EAC3C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EACzC,KAAK,EAAE,IAAI,CAAC,KAAK,IAClB;IACH,CAAC;;AAtGsB,mCAAI,GAAG,gCAAgC,CAAA;AAqB9D;IAAC,IAAA,sBAAe,GAAE;8BACO,IAAI;IAE7B;;;OAGG;;uEAL0B;AAvB/B,wEAwGC"}
@@ -0,0 +1,5 @@
1
+ import { Repository, StorageService, EventEmitter } from '@credo-ts/core';
2
+ import { OpenId4VcIssuanceSessionRecord } from './OpenId4VcIssuanceSessionRecord';
3
+ export declare class OpenId4VcIssuanceSessionRepository extends Repository<OpenId4VcIssuanceSessionRecord> {
4
+ constructor(storageService: StorageService<OpenId4VcIssuanceSessionRecord>, eventEmitter: EventEmitter);
5
+ }
@@ -0,0 +1,29 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.OpenId4VcIssuanceSessionRepository = void 0;
16
+ const core_1 = require("@credo-ts/core");
17
+ const OpenId4VcIssuanceSessionRecord_1 = require("./OpenId4VcIssuanceSessionRecord");
18
+ let OpenId4VcIssuanceSessionRepository = class OpenId4VcIssuanceSessionRepository extends core_1.Repository {
19
+ constructor(storageService, eventEmitter) {
20
+ super(OpenId4VcIssuanceSessionRecord_1.OpenId4VcIssuanceSessionRecord, storageService, eventEmitter);
21
+ }
22
+ };
23
+ OpenId4VcIssuanceSessionRepository = __decorate([
24
+ (0, core_1.injectable)(),
25
+ __param(0, (0, core_1.inject)(core_1.InjectionSymbols.StorageService)),
26
+ __metadata("design:paramtypes", [Object, core_1.EventEmitter])
27
+ ], OpenId4VcIssuanceSessionRepository);
28
+ exports.OpenId4VcIssuanceSessionRepository = OpenId4VcIssuanceSessionRepository;
29
+ //# sourceMappingURL=OpenId4VcIssuanceSessionRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenId4VcIssuanceSessionRepository.js","sourceRoot":"","sources":["../../../src/openid4vc-issuer/repository/OpenId4VcIssuanceSessionRepository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAA+G;AAE/G,qFAAiF;AAG1E,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,iBAA0C;IAChG,YAC2C,cAA8D,EACvG,YAA0B;QAE1B,KAAK,CAAC,+DAA8B,EAAE,cAAc,EAAE,YAAY,CAAC,CAAA;IACrE,CAAC;CACF,CAAA;AAPY,kCAAkC;IAD9C,IAAA,iBAAU,GAAE;IAGR,WAAA,IAAA,aAAM,EAAC,uBAAgB,CAAC,cAAc,CAAC,CAAA;6CAC1B,mBAAY;GAHjB,kCAAkC,CAO9C;AAPY,gFAAkC"}
@@ -0,0 +1,37 @@
1
+ import type { OpenId4VciCredentialSupportedWithId, OpenId4VciIssuerMetadataDisplay } from '../../shared';
2
+ import type { RecordTags, TagsBase } from '@credo-ts/core';
3
+ import { BaseRecord } from '@credo-ts/core';
4
+ export type OpenId4VcIssuerRecordTags = RecordTags<OpenId4VcIssuerRecord>;
5
+ export type DefaultOpenId4VcIssuerRecordTags = {
6
+ issuerId: string;
7
+ };
8
+ export interface OpenId4VcIssuerRecordProps {
9
+ id?: string;
10
+ createdAt?: Date;
11
+ tags?: TagsBase;
12
+ issuerId: string;
13
+ /**
14
+ * The fingerprint (multibase encoded) of the public key used to sign access tokens for
15
+ * this issuer.
16
+ */
17
+ accessTokenPublicKeyFingerprint: string;
18
+ credentialsSupported: OpenId4VciCredentialSupportedWithId[];
19
+ display?: OpenId4VciIssuerMetadataDisplay[];
20
+ }
21
+ /**
22
+ * For OID4VC you need to expos metadata files. Each issuer needs to host this metadata. This is not the case for DIDComm where we can just have one /didcomm endpoint.
23
+ * So we create a record per openid issuer/verifier that you want, and each tenant can create multiple issuers/verifiers which have different endpoints
24
+ * and metadata files
25
+ * */
26
+ export declare class OpenId4VcIssuerRecord extends BaseRecord<DefaultOpenId4VcIssuerRecordTags> {
27
+ static readonly type = "OpenId4VcIssuerRecord";
28
+ readonly type = "OpenId4VcIssuerRecord";
29
+ issuerId: string;
30
+ accessTokenPublicKeyFingerprint: string;
31
+ credentialsSupported: OpenId4VciCredentialSupportedWithId[];
32
+ display?: OpenId4VciIssuerMetadataDisplay[];
33
+ constructor(props: OpenId4VcIssuerRecordProps);
34
+ getTags(): {
35
+ issuerId: string;
36
+ };
37
+ }