@veridid/openbadges 0.0.0-stage → 1.0.0

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 (268) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +43 -2
  3. package/build/OpenBadgesModule.d.mts +15 -0
  4. package/build/OpenBadgesModule.d.mts.map +1 -0
  5. package/build/OpenBadgesModule.mjs +71 -0
  6. package/build/OpenBadgesModule.mjs.map +1 -0
  7. package/build/OpenBadgesModuleConfig.d.mts +101 -0
  8. package/build/OpenBadgesModuleConfig.d.mts.map +1 -0
  9. package/build/OpenBadgesModuleConfig.mjs +51 -0
  10. package/build/OpenBadgesModuleConfig.mjs.map +1 -0
  11. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +14 -0
  12. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +11 -0
  13. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs +13 -0
  14. package/build/_virtual/_rolldown/runtime.mjs +41 -0
  15. package/build/api/OpenBadgesApi.d.mts +77 -0
  16. package/build/api/OpenBadgesApi.d.mts.map +1 -0
  17. package/build/api/OpenBadgesApi.mjs +124 -0
  18. package/build/api/OpenBadgesApi.mjs.map +1 -0
  19. package/build/constants.d.mts +17 -0
  20. package/build/constants.d.mts.map +1 -0
  21. package/build/constants.mjs +19 -0
  22. package/build/constants.mjs.map +1 -0
  23. package/build/cryptosuites/EcdsaSd2023.d.mts +129 -0
  24. package/build/cryptosuites/EcdsaSd2023.d.mts.map +1 -0
  25. package/build/cryptosuites/EcdsaSd2023.mjs +408 -0
  26. package/build/cryptosuites/EcdsaSd2023.mjs.map +1 -0
  27. package/build/cryptosuites/EddsaRdfc2022.d.mts +118 -0
  28. package/build/cryptosuites/EddsaRdfc2022.d.mts.map +1 -0
  29. package/build/cryptosuites/EddsaRdfc2022.mjs +301 -0
  30. package/build/cryptosuites/EddsaRdfc2022.mjs.map +1 -0
  31. package/build/cryptosuites/constants.d.mts +18 -0
  32. package/build/cryptosuites/constants.d.mts.map +1 -0
  33. package/build/cryptosuites/constants.mjs +19 -0
  34. package/build/cryptosuites/constants.mjs.map +1 -0
  35. package/build/cryptosuites/contextPreprocessor.mjs +76 -0
  36. package/build/cryptosuites/contextPreprocessor.mjs.map +1 -0
  37. package/build/cryptosuites/dataIntegrityV2Context.d.mts +147 -0
  38. package/build/cryptosuites/dataIntegrityV2Context.d.mts.map +1 -0
  39. package/build/cryptosuites/dataIntegrityV2Context.mjs +82 -0
  40. package/build/cryptosuites/dataIntegrityV2Context.mjs.map +1 -0
  41. package/build/cryptosuites/index.mjs +4 -0
  42. package/build/formats/OpenBadgesCredentialFormat.d.mts +41 -0
  43. package/build/formats/OpenBadgesCredentialFormat.d.mts.map +1 -0
  44. package/build/formats/OpenBadgesCredentialFormat.mjs +7 -0
  45. package/build/formats/OpenBadgesCredentialFormat.mjs.map +1 -0
  46. package/build/formats/OpenBadgesCredentialFormatService.d.mts +79 -0
  47. package/build/formats/OpenBadgesCredentialFormatService.d.mts.map +1 -0
  48. package/build/formats/OpenBadgesCredentialFormatService.mjs +208 -0
  49. package/build/formats/OpenBadgesCredentialFormatService.mjs.map +1 -0
  50. package/build/formats/OpenBadgesProofFormat.d.mts +41 -0
  51. package/build/formats/OpenBadgesProofFormat.d.mts.map +1 -0
  52. package/build/formats/OpenBadgesProofFormat.mjs +7 -0
  53. package/build/formats/OpenBadgesProofFormat.mjs.map +1 -0
  54. package/build/formats/OpenBadgesProofFormatService.d.mts +56 -0
  55. package/build/formats/OpenBadgesProofFormatService.d.mts.map +1 -0
  56. package/build/formats/OpenBadgesProofFormatService.mjs +138 -0
  57. package/build/formats/OpenBadgesProofFormatService.mjs.map +1 -0
  58. package/build/formats/index.d.mts +4 -0
  59. package/build/formats/index.mjs +4 -0
  60. package/build/http/OpenBadgesHttpModule.d.mts +14 -0
  61. package/build/http/OpenBadgesHttpModule.d.mts.map +1 -0
  62. package/build/http/OpenBadgesHttpModule.mjs +85 -0
  63. package/build/http/OpenBadgesHttpModule.mjs.map +1 -0
  64. package/build/http/OpenBadgesHttpModuleConfig.d.mts +60 -0
  65. package/build/http/OpenBadgesHttpModuleConfig.d.mts.map +1 -0
  66. package/build/http/OpenBadgesHttpModuleConfig.mjs +80 -0
  67. package/build/http/OpenBadgesHttpModuleConfig.mjs.map +1 -0
  68. package/build/http/endpoints/authorize.mjs +69 -0
  69. package/build/http/endpoints/authorize.mjs.map +1 -0
  70. package/build/http/endpoints/consent.mjs +34 -0
  71. package/build/http/endpoints/consent.mjs.map +1 -0
  72. package/build/http/endpoints/credentials.mjs +77 -0
  73. package/build/http/endpoints/credentials.mjs.map +1 -0
  74. package/build/http/endpoints/did.mjs +44 -0
  75. package/build/http/endpoints/did.mjs.map +1 -0
  76. package/build/http/endpoints/introspect.mjs +34 -0
  77. package/build/http/endpoints/introspect.mjs.map +1 -0
  78. package/build/http/endpoints/jwks.mjs +40 -0
  79. package/build/http/endpoints/jwks.mjs.map +1 -0
  80. package/build/http/endpoints/profile.mjs +56 -0
  81. package/build/http/endpoints/profile.mjs.map +1 -0
  82. package/build/http/endpoints/refresh.mjs +99 -0
  83. package/build/http/endpoints/refresh.mjs.map +1 -0
  84. package/build/http/endpoints/registration.mjs +42 -0
  85. package/build/http/endpoints/registration.mjs.map +1 -0
  86. package/build/http/endpoints/revoke.mjs +31 -0
  87. package/build/http/endpoints/revoke.mjs.map +1 -0
  88. package/build/http/endpoints/serviceDescription.mjs +48 -0
  89. package/build/http/endpoints/serviceDescription.mjs.map +1 -0
  90. package/build/http/endpoints/statusList.mjs +91 -0
  91. package/build/http/endpoints/statusList.mjs.map +1 -0
  92. package/build/http/endpoints/token.mjs +123 -0
  93. package/build/http/endpoints/token.mjs.map +1 -0
  94. package/build/http/middleware/auth.mjs +38 -0
  95. package/build/http/middleware/auth.mjs.map +1 -0
  96. package/build/http/router.d.mts +19 -0
  97. package/build/http/router.d.mts.map +1 -0
  98. package/build/http/router.mjs +36 -0
  99. package/build/http/router.mjs.map +1 -0
  100. package/build/http/tenants.mjs +16 -0
  101. package/build/http/tenants.mjs.map +1 -0
  102. package/build/http/util/auth.mjs +38 -0
  103. package/build/http/util/auth.mjs.map +1 -0
  104. package/build/index.d.mts +57 -0
  105. package/build/index.mjs +68 -0
  106. package/build/index.mjs.map +1 -0
  107. package/build/models/ClrCredential.d.mts +116 -0
  108. package/build/models/ClrCredential.d.mts.map +1 -0
  109. package/build/models/ClrCredential.mjs +38 -0
  110. package/build/models/ClrCredential.mjs.map +1 -0
  111. package/build/models/EndorsementCredential.d.mts +93 -0
  112. package/build/models/EndorsementCredential.d.mts.map +1 -0
  113. package/build/models/StatusListCredential.d.mts +85 -0
  114. package/build/models/StatusListCredential.d.mts.map +1 -0
  115. package/build/models/StatusListCredential.mjs +29 -0
  116. package/build/models/StatusListCredential.mjs.map +1 -0
  117. package/build/models/index.mjs +2 -0
  118. package/build/repository/OpenBadgeCredentialRecord.d.mts +48 -0
  119. package/build/repository/OpenBadgeCredentialRecord.d.mts.map +1 -0
  120. package/build/repository/OpenBadgeCredentialRecord.mjs +44 -0
  121. package/build/repository/OpenBadgeCredentialRecord.mjs.map +1 -0
  122. package/build/repository/OpenBadgeCredentialRepository.d.mts +13 -0
  123. package/build/repository/OpenBadgeCredentialRepository.d.mts.map +1 -0
  124. package/build/repository/OpenBadgeCredentialRepository.mjs +34 -0
  125. package/build/repository/OpenBadgeCredentialRepository.mjs.map +1 -0
  126. package/build/repository/OpenBadgesAuthCodeRecord.d.mts +39 -0
  127. package/build/repository/OpenBadgesAuthCodeRecord.d.mts.map +1 -0
  128. package/build/repository/OpenBadgesAuthCodeRecord.mjs +40 -0
  129. package/build/repository/OpenBadgesAuthCodeRecord.mjs.map +1 -0
  130. package/build/repository/OpenBadgesAuthCodeRepository.d.mts +11 -0
  131. package/build/repository/OpenBadgesAuthCodeRepository.d.mts.map +1 -0
  132. package/build/repository/OpenBadgesAuthCodeRepository.mjs +29 -0
  133. package/build/repository/OpenBadgesAuthCodeRepository.mjs.map +1 -0
  134. package/build/repository/OpenBadgesConsentRecord.d.mts +28 -0
  135. package/build/repository/OpenBadgesConsentRecord.d.mts.map +1 -0
  136. package/build/repository/OpenBadgesConsentRecord.mjs +33 -0
  137. package/build/repository/OpenBadgesConsentRecord.mjs.map +1 -0
  138. package/build/repository/OpenBadgesConsentRepository.d.mts +11 -0
  139. package/build/repository/OpenBadgesConsentRepository.d.mts.map +1 -0
  140. package/build/repository/OpenBadgesConsentRepository.mjs +37 -0
  141. package/build/repository/OpenBadgesConsentRepository.mjs.map +1 -0
  142. package/build/repository/OpenBadgesKeyBindingRecord.d.mts +32 -0
  143. package/build/repository/OpenBadgesKeyBindingRecord.d.mts.map +1 -0
  144. package/build/repository/OpenBadgesKeyBindingRecord.mjs +37 -0
  145. package/build/repository/OpenBadgesKeyBindingRecord.mjs.map +1 -0
  146. package/build/repository/OpenBadgesKeyBindingRepository.d.mts +12 -0
  147. package/build/repository/OpenBadgesKeyBindingRepository.d.mts.map +1 -0
  148. package/build/repository/OpenBadgesKeyBindingRepository.mjs +31 -0
  149. package/build/repository/OpenBadgesKeyBindingRepository.mjs.map +1 -0
  150. package/build/repository/OpenBadgesOAuthRecord.d.mts +39 -0
  151. package/build/repository/OpenBadgesOAuthRecord.d.mts.map +1 -0
  152. package/build/repository/OpenBadgesOAuthRecord.mjs +37 -0
  153. package/build/repository/OpenBadgesOAuthRecord.mjs.map +1 -0
  154. package/build/repository/OpenBadgesOAuthRepository.d.mts +13 -0
  155. package/build/repository/OpenBadgesOAuthRepository.d.mts.map +1 -0
  156. package/build/repository/OpenBadgesOAuthRepository.mjs +35 -0
  157. package/build/repository/OpenBadgesOAuthRepository.mjs.map +1 -0
  158. package/build/repository/OpenBadgesProfileRecord.d.mts +25 -0
  159. package/build/repository/OpenBadgesProfileRecord.d.mts.map +1 -0
  160. package/build/repository/OpenBadgesProfileRecord.mjs +26 -0
  161. package/build/repository/OpenBadgesProfileRecord.mjs.map +1 -0
  162. package/build/repository/OpenBadgesProfileRepository.d.mts +11 -0
  163. package/build/repository/OpenBadgesProfileRepository.d.mts.map +1 -0
  164. package/build/repository/OpenBadgesProfileRepository.mjs +28 -0
  165. package/build/repository/OpenBadgesProfileRepository.mjs.map +1 -0
  166. package/build/repository/OpenBadgesRevocationCacheRecord.d.mts +27 -0
  167. package/build/repository/OpenBadgesRevocationCacheRecord.d.mts.map +1 -0
  168. package/build/repository/OpenBadgesRevocationCacheRecord.mjs +27 -0
  169. package/build/repository/OpenBadgesRevocationCacheRecord.mjs.map +1 -0
  170. package/build/repository/OpenBadgesRevocationCacheRepository.d.mts +11 -0
  171. package/build/repository/OpenBadgesRevocationCacheRepository.d.mts.map +1 -0
  172. package/build/repository/OpenBadgesRevocationCacheRepository.mjs +28 -0
  173. package/build/repository/OpenBadgesRevocationCacheRepository.mjs.map +1 -0
  174. package/build/repository/OpenBadgesServiceDescriptionRecord.d.mts +25 -0
  175. package/build/repository/OpenBadgesServiceDescriptionRecord.d.mts.map +1 -0
  176. package/build/repository/OpenBadgesServiceDescriptionRecord.mjs +26 -0
  177. package/build/repository/OpenBadgesServiceDescriptionRecord.mjs.map +1 -0
  178. package/build/repository/OpenBadgesServiceDescriptionRepository.d.mts +11 -0
  179. package/build/repository/OpenBadgesServiceDescriptionRepository.d.mts.map +1 -0
  180. package/build/repository/OpenBadgesServiceDescriptionRepository.mjs +28 -0
  181. package/build/repository/OpenBadgesServiceDescriptionRepository.mjs.map +1 -0
  182. package/build/repository/OpenBadgesTokenRecord.d.mts +43 -0
  183. package/build/repository/OpenBadgesTokenRecord.d.mts.map +1 -0
  184. package/build/repository/OpenBadgesTokenRecord.mjs +37 -0
  185. package/build/repository/OpenBadgesTokenRecord.mjs.map +1 -0
  186. package/build/repository/OpenBadgesTokenRepository.d.mts +14 -0
  187. package/build/repository/OpenBadgesTokenRepository.d.mts.map +1 -0
  188. package/build/repository/OpenBadgesTokenRepository.mjs +46 -0
  189. package/build/repository/OpenBadgesTokenRepository.mjs.map +1 -0
  190. package/build/repository/StatusListRecord.d.mts +40 -0
  191. package/build/repository/StatusListRecord.d.mts.map +1 -0
  192. package/build/repository/StatusListRecord.mjs +42 -0
  193. package/build/repository/StatusListRecord.mjs.map +1 -0
  194. package/build/repository/StatusListRepository.d.mts +23 -0
  195. package/build/repository/StatusListRepository.d.mts.map +1 -0
  196. package/build/repository/StatusListRepository.mjs +46 -0
  197. package/build/repository/StatusListRepository.mjs.map +1 -0
  198. package/build/services/AchievementValidator.d.mts +162 -0
  199. package/build/services/AchievementValidator.d.mts.map +1 -0
  200. package/build/services/AchievementValidator.mjs +173 -0
  201. package/build/services/AchievementValidator.mjs.map +1 -0
  202. package/build/services/ConsumerService.d.mts +29 -0
  203. package/build/services/ConsumerService.d.mts.map +1 -0
  204. package/build/services/ConsumerService.mjs +114 -0
  205. package/build/services/ConsumerService.mjs.map +1 -0
  206. package/build/services/ContextService.d.mts +17 -0
  207. package/build/services/ContextService.d.mts.map +1 -0
  208. package/build/services/ContextService.mjs +48 -0
  209. package/build/services/ContextService.mjs.map +1 -0
  210. package/build/services/DataIntegrityService.d.mts +58 -0
  211. package/build/services/DataIntegrityService.d.mts.map +1 -0
  212. package/build/services/DataIntegrityService.mjs +130 -0
  213. package/build/services/DataIntegrityService.mjs.map +1 -0
  214. package/build/services/DidCommLinkService.d.mts +12 -0
  215. package/build/services/DidCommLinkService.d.mts.map +1 -0
  216. package/build/services/DidCommLinkService.mjs +15 -0
  217. package/build/services/DidCommLinkService.mjs.map +1 -0
  218. package/build/services/DisplayMapper.d.mts +13 -0
  219. package/build/services/DisplayMapper.d.mts.map +1 -0
  220. package/build/services/DisplayMapper.mjs +23 -0
  221. package/build/services/DisplayMapper.mjs.map +1 -0
  222. package/build/services/IssuerService.d.mts +43 -0
  223. package/build/services/IssuerService.d.mts.map +1 -0
  224. package/build/services/IssuerService.mjs +230 -0
  225. package/build/services/IssuerService.mjs.map +1 -0
  226. package/build/services/JwtService.d.mts +22 -0
  227. package/build/services/JwtService.d.mts.map +1 -0
  228. package/build/services/JwtService.mjs +190 -0
  229. package/build/services/JwtService.mjs.map +1 -0
  230. package/build/services/KeyService.d.mts +122 -0
  231. package/build/services/KeyService.d.mts.map +1 -0
  232. package/build/services/KeyService.mjs +448 -0
  233. package/build/services/KeyService.mjs.map +1 -0
  234. package/build/services/OAuthClient.d.mts +31 -0
  235. package/build/services/OAuthClient.d.mts.map +1 -0
  236. package/build/services/OAuthClient.mjs +131 -0
  237. package/build/services/OAuthClient.mjs.map +1 -0
  238. package/build/services/ProofService.d.mts +20 -0
  239. package/build/services/ProofService.d.mts.map +1 -0
  240. package/build/services/ProofService.mjs +39 -0
  241. package/build/services/ProofService.mjs.map +1 -0
  242. package/build/services/RevocationService.d.mts +64 -0
  243. package/build/services/RevocationService.d.mts.map +1 -0
  244. package/build/services/RevocationService.mjs +253 -0
  245. package/build/services/RevocationService.mjs.map +1 -0
  246. package/build/services/VerifyService.d.mts +24 -0
  247. package/build/services/VerifyService.d.mts.map +1 -0
  248. package/build/services/VerifyService.mjs +59 -0
  249. package/build/services/VerifyService.mjs.map +1 -0
  250. package/build/services/crypto/CryptoDriver.d.mts +14 -0
  251. package/build/services/crypto/CryptoDriver.d.mts.map +1 -0
  252. package/build/services/crypto/CryptoDriver.mjs +6 -0
  253. package/build/services/crypto/CryptoDriver.mjs.map +1 -0
  254. package/build/services/crypto/JsonLdCryptoDriver.d.mts +22 -0
  255. package/build/services/crypto/JsonLdCryptoDriver.d.mts.map +1 -0
  256. package/build/services/crypto/JsonLdCryptoDriver.mjs +43 -0
  257. package/build/services/crypto/JsonLdCryptoDriver.mjs.map +1 -0
  258. package/build/services/crypto/JwtCryptoDriver.d.mts +18 -0
  259. package/build/services/crypto/JwtCryptoDriver.d.mts.map +1 -0
  260. package/build/services/crypto/JwtCryptoDriver.mjs +46 -0
  261. package/build/services/crypto/JwtCryptoDriver.mjs.map +1 -0
  262. package/build/services/index.d.mts +12 -0
  263. package/build/services/index.mjs +12 -0
  264. package/build/utils/validate.d.mts +21 -0
  265. package/build/utils/validate.d.mts.map +1 -0
  266. package/build/utils/validate.mjs +111 -0
  267. package/build/utils/validate.mjs.map +1 -0
  268. package/package.json +63 -3
@@ -0,0 +1,82 @@
1
+ import { DATA_INTEGRITY_V2_CONTEXT_URL } from "./constants.mjs";
2
+
3
+ //#region src/cryptosuites/dataIntegrityV2Context.ts
4
+ /**
5
+ * Data Integrity v2 Context
6
+ * https://w3id.org/security/data-integrity/v2
7
+ *
8
+ * This context defines the DataIntegrityProof and related terms.
9
+ * Simplified without @protected to avoid conflicts when combining contexts.
10
+ */
11
+ const dataIntegrityV2Context = { "@context": {
12
+ id: "@id",
13
+ type: "@type",
14
+ DataIntegrityProof: "https://w3id.org/security#DataIntegrityProof",
15
+ challenge: "https://w3id.org/security#challenge",
16
+ created: {
17
+ "@id": "http://purl.org/dc/terms/created",
18
+ "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
19
+ },
20
+ domain: "https://w3id.org/security#domain",
21
+ expires: {
22
+ "@id": "https://w3id.org/security#expiration",
23
+ "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
24
+ },
25
+ nonce: "https://w3id.org/security#nonce",
26
+ proofPurpose: {
27
+ "@id": "https://w3id.org/security#proofPurpose",
28
+ "@type": "@vocab"
29
+ },
30
+ assertionMethod: {
31
+ "@id": "https://w3id.org/security#assertionMethod",
32
+ "@type": "@id"
33
+ },
34
+ authentication: {
35
+ "@id": "https://w3id.org/security#authenticationMethod",
36
+ "@type": "@id"
37
+ },
38
+ cryptosuite: {
39
+ "@id": "https://w3id.org/security#cryptosuite",
40
+ "@type": "https://w3id.org/security#cryptosuiteString"
41
+ },
42
+ proofValue: {
43
+ "@id": "https://w3id.org/security#proofValue",
44
+ "@type": "https://w3id.org/security#multibase"
45
+ },
46
+ verificationMethod: {
47
+ "@id": "https://w3id.org/security#verificationMethod",
48
+ "@type": "@id"
49
+ },
50
+ previousProof: {
51
+ "@id": "https://w3id.org/security#previousProof",
52
+ "@type": "@id"
53
+ },
54
+ Multikey: "https://w3id.org/security#Multikey",
55
+ controller: {
56
+ "@id": "https://w3id.org/security#controller",
57
+ "@type": "@id"
58
+ },
59
+ revoked: {
60
+ "@id": "https://w3id.org/security#revoked",
61
+ "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
62
+ },
63
+ publicKeyMultibase: {
64
+ "@id": "https://w3id.org/security#publicKeyMultibase",
65
+ "@type": "https://w3id.org/security#multibase"
66
+ },
67
+ secretKeyMultibase: {
68
+ "@id": "https://w3id.org/security#secretKeyMultibase",
69
+ "@type": "https://w3id.org/security#multibase"
70
+ },
71
+ proof: {
72
+ "@id": "https://w3id.org/security#proof",
73
+ "@type": "@id",
74
+ "@container": "@graph"
75
+ }
76
+ } };
77
+ const dataIntegrityContextMap = /* @__PURE__ */ new Map();
78
+ dataIntegrityContextMap.set(DATA_INTEGRITY_V2_CONTEXT_URL, dataIntegrityV2Context);
79
+
80
+ //#endregion
81
+ export { dataIntegrityContextMap, dataIntegrityV2Context };
82
+ //# sourceMappingURL=dataIntegrityV2Context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataIntegrityV2Context.mjs","names":[],"sources":["../../src/cryptosuites/dataIntegrityV2Context.ts"],"sourcesContent":["/**\n * Data Integrity v2 Context\n * https://w3id.org/security/data-integrity/v2\n *\n * This context defines the DataIntegrityProof and related terms.\n * Simplified without @protected to avoid conflicts when combining contexts.\n */\n\nimport { DATA_INTEGRITY_V2_CONTEXT_URL } from './constants'\n\nexport const dataIntegrityV2Context = {\n '@context': {\n id: '@id',\n type: '@type',\n\n // Data Integrity Proof terms\n DataIntegrityProof: 'https://w3id.org/security#DataIntegrityProof',\n challenge: 'https://w3id.org/security#challenge',\n created: {\n '@id': 'http://purl.org/dc/terms/created',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n domain: 'https://w3id.org/security#domain',\n expires: {\n '@id': 'https://w3id.org/security#expiration',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n nonce: 'https://w3id.org/security#nonce',\n proofPurpose: {\n '@id': 'https://w3id.org/security#proofPurpose',\n '@type': '@vocab',\n },\n assertionMethod: {\n '@id': 'https://w3id.org/security#assertionMethod',\n '@type': '@id',\n },\n authentication: {\n '@id': 'https://w3id.org/security#authenticationMethod',\n '@type': '@id',\n },\n cryptosuite: {\n '@id': 'https://w3id.org/security#cryptosuite',\n '@type': 'https://w3id.org/security#cryptosuiteString',\n },\n proofValue: {\n '@id': 'https://w3id.org/security#proofValue',\n '@type': 'https://w3id.org/security#multibase',\n },\n verificationMethod: {\n '@id': 'https://w3id.org/security#verificationMethod',\n '@type': '@id',\n },\n previousProof: {\n '@id': 'https://w3id.org/security#previousProof',\n '@type': '@id',\n },\n\n // Multikey terms\n Multikey: 'https://w3id.org/security#Multikey',\n controller: {\n '@id': 'https://w3id.org/security#controller',\n '@type': '@id',\n },\n revoked: {\n '@id': 'https://w3id.org/security#revoked',\n '@type': 'http://www.w3.org/2001/XMLSchema#dateTime',\n },\n publicKeyMultibase: {\n '@id': 'https://w3id.org/security#publicKeyMultibase',\n '@type': 'https://w3id.org/security#multibase',\n },\n secretKeyMultibase: {\n '@id': 'https://w3id.org/security#secretKeyMultibase',\n '@type': 'https://w3id.org/security#multibase',\n },\n\n // Common terms\n proof: {\n '@id': 'https://w3id.org/security#proof',\n '@type': '@id',\n '@container': '@graph',\n },\n },\n}\n\nconst dataIntegrityContextMap = new Map<string, typeof dataIntegrityV2Context>()\ndataIntegrityContextMap.set(DATA_INTEGRITY_V2_CONTEXT_URL, dataIntegrityV2Context)\n\nexport { dataIntegrityContextMap }\n"],"mappings":";;;;;;;;;;AAUA,MAAa,yBAAyB,EACpC,YAAY;CACV,IAAI;CACJ,MAAM;CAGN,oBAAoB;CACpB,WAAW;CACX,SAAS;EACP,OAAO;EACP,SAAS;EACV;CACD,QAAQ;CACR,SAAS;EACP,OAAO;EACP,SAAS;EACV;CACD,OAAO;CACP,cAAc;EACZ,OAAO;EACP,SAAS;EACV;CACD,iBAAiB;EACf,OAAO;EACP,SAAS;EACV;CACD,gBAAgB;EACd,OAAO;EACP,SAAS;EACV;CACD,aAAa;EACX,OAAO;EACP,SAAS;EACV;CACD,YAAY;EACV,OAAO;EACP,SAAS;EACV;CACD,oBAAoB;EAClB,OAAO;EACP,SAAS;EACV;CACD,eAAe;EACb,OAAO;EACP,SAAS;EACV;CAGD,UAAU;CACV,YAAY;EACV,OAAO;EACP,SAAS;EACV;CACD,SAAS;EACP,OAAO;EACP,SAAS;EACV;CACD,oBAAoB;EAClB,OAAO;EACP,SAAS;EACV;CACD,oBAAoB;EAClB,OAAO;EACP,SAAS;EACV;CAGD,OAAO;EACL,OAAO;EACP,SAAS;EACT,cAAc;EACf;CACF,EACF;AAED,MAAM,0CAA0B,IAAI,KAA4C;AAChF,wBAAwB,IAAI,+BAA+B,uBAAuB"}
@@ -0,0 +1,4 @@
1
+ import { CRYPTOSUITE_ECDSA_RDFC_2019, CRYPTOSUITE_ECDSA_SD_2023, CRYPTOSUITE_EDDSA_RDFC_2022, DATA_INTEGRITY_V2_CONTEXT_URL, ED25519_2020_CONTEXT_URL, MULTIKEY_CONTEXT_URL, PROOF_TYPE_DATA_INTEGRITY, PROOF_TYPE_ED25519_2020, VM_TYPE_ECDSA_SECP256R1, VM_TYPE_ED25519_2020, VM_TYPE_MULTIKEY } from "./constants.mjs";
2
+ import { dataIntegrityContextMap, dataIntegrityV2Context } from "./dataIntegrityV2Context.mjs";
3
+ import { EddsaRdfc2022Cryptosuite } from "./EddsaRdfc2022.mjs";
4
+ import { EcdsaSd2023Cryptosuite } from "./EcdsaSd2023.mjs";
@@ -0,0 +1,41 @@
1
+ import { DidCommCredentialFormat } from "@credo-ts/didcomm";
2
+
3
+ //#region src/formats/OpenBadgesCredentialFormat.d.ts
4
+ type JsonObject = {
5
+ [key: string]: unknown;
6
+ };
7
+ interface OpenBadgesCredentialDetail {
8
+ credential: JsonObject;
9
+ options?: {
10
+ proofType?: string;
11
+ cryptosuite?: string;
12
+ proofPurpose?: string;
13
+ verificationMethod?: string;
14
+ };
15
+ }
16
+ interface OpenBadgesAcceptRequestFormat {
17
+ verificationMethod?: string;
18
+ }
19
+ interface OpenBadgesCredentialFormat extends DidCommCredentialFormat {
20
+ formatKey: 'openbadges';
21
+ credentialRecordType: 'openbadges';
22
+ credentialFormats: {
23
+ createProposal: OpenBadgesCredentialDetail;
24
+ acceptProposal: Record<string, never>;
25
+ createOffer: OpenBadgesCredentialDetail;
26
+ acceptOffer: Record<string, never>;
27
+ createRequest: OpenBadgesCredentialDetail;
28
+ acceptRequest: OpenBadgesAcceptRequestFormat;
29
+ };
30
+ formatData: {
31
+ proposal: OpenBadgesCredentialDetail;
32
+ offer: OpenBadgesCredentialDetail;
33
+ request: OpenBadgesCredentialDetail;
34
+ credential: JsonObject;
35
+ };
36
+ }
37
+ declare const OPENBADGES_CREDENTIAL_DETAIL = "ob/3.0/credential-detail@v1.0";
38
+ declare const OPENBADGES_CREDENTIAL = "ob/3.0/credential@v1.0";
39
+ //#endregion
40
+ export { JsonObject, OPENBADGES_CREDENTIAL, OPENBADGES_CREDENTIAL_DETAIL, OpenBadgesAcceptRequestFormat, OpenBadgesCredentialDetail, OpenBadgesCredentialFormat };
41
+ //# sourceMappingURL=OpenBadgesCredentialFormat.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenBadgesCredentialFormat.d.mts","names":[],"sources":["../../src/formats/OpenBadgesCredentialFormat.ts"],"mappings":";;;KAEY,UAAA;EAAA,CAAgB,GAAA;AAAA;AAAA,UAEX,0BAAA;EACf,UAAA,EAAY,UAAA;EACZ,OAAA;IACE,SAAA;IACA,WAAA;IACA,YAAA;IACA,kBAAA;EAAA;AAAA;AAAA,UAIa,6BAAA;EACf,kBAAA;AAAA;AAAA,UAGe,0BAAA,SAAmC,uBAAA;EAClD,SAAA;EACA,oBAAA;EACA,iBAAA;IACE,cAAA,EAAgB,0BAAA;IAChB,cAAA,EAAgB,MAAA;IAChB,WAAA,EAAa,0BAAA;IACb,WAAA,EAAa,MAAA;IACb,aAAA,EAAe,0BAAA;IACf,aAAA,EAAe,6BAAA;EAAA;EAEjB,UAAA;IACE,QAAA,EAAU,0BAAA;IACV,KAAA,EAAO,0BAAA;IACP,OAAA,EAAS,0BAAA;IACT,UAAA,EAAY,UAAA;EAAA;AAAA;AAAA,cAIH,4BAAA;AAAA,cACA,qBAAA"}
@@ -0,0 +1,7 @@
1
+ //#region src/formats/OpenBadgesCredentialFormat.ts
2
+ const OPENBADGES_CREDENTIAL_DETAIL = "ob/3.0/credential-detail@v1.0";
3
+ const OPENBADGES_CREDENTIAL = "ob/3.0/credential@v1.0";
4
+
5
+ //#endregion
6
+ export { OPENBADGES_CREDENTIAL, OPENBADGES_CREDENTIAL_DETAIL };
7
+ //# sourceMappingURL=OpenBadgesCredentialFormat.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenBadgesCredentialFormat.mjs","names":[],"sources":["../../src/formats/OpenBadgesCredentialFormat.ts"],"sourcesContent":["import type { DidCommCredentialFormat } from '@credo-ts/didcomm'\n\nexport type JsonObject = { [key: string]: unknown }\n\nexport interface OpenBadgesCredentialDetail {\n credential: JsonObject\n options?: {\n proofType?: string\n cryptosuite?: string\n proofPurpose?: string\n verificationMethod?: string\n }\n}\n\nexport interface OpenBadgesAcceptRequestFormat {\n verificationMethod?: string\n}\n\nexport interface OpenBadgesCredentialFormat extends DidCommCredentialFormat {\n formatKey: 'openbadges'\n credentialRecordType: 'openbadges'\n credentialFormats: {\n createProposal: OpenBadgesCredentialDetail\n acceptProposal: Record<string, never>\n createOffer: OpenBadgesCredentialDetail\n acceptOffer: Record<string, never>\n createRequest: OpenBadgesCredentialDetail\n acceptRequest: OpenBadgesAcceptRequestFormat\n }\n formatData: {\n proposal: OpenBadgesCredentialDetail\n offer: OpenBadgesCredentialDetail\n request: OpenBadgesCredentialDetail\n credential: JsonObject\n }\n}\n\nexport const OPENBADGES_CREDENTIAL_DETAIL = 'ob/3.0/credential-detail@v1.0'\nexport const OPENBADGES_CREDENTIAL = 'ob/3.0/credential@v1.0'\n"],"mappings":";AAqCA,MAAa,+BAA+B;AAC5C,MAAa,wBAAwB"}
@@ -0,0 +1,79 @@
1
+ import { OpenBadgesCredentialFormat } from "./OpenBadgesCredentialFormat.mjs";
2
+ import { AgentContext } from "@credo-ts/core";
3
+ import { DidCommCredentialFormatAcceptOfferOptions, DidCommCredentialFormatAcceptProposalOptions, DidCommCredentialFormatAcceptRequestOptions, DidCommCredentialFormatAutoRespondCredentialOptions, DidCommCredentialFormatAutoRespondOfferOptions, DidCommCredentialFormatAutoRespondProposalOptions, DidCommCredentialFormatAutoRespondRequestOptions, DidCommCredentialFormatCreateOfferOptions, DidCommCredentialFormatCreateOfferReturn, DidCommCredentialFormatCreateProposalOptions, DidCommCredentialFormatCreateProposalReturn, DidCommCredentialFormatCreateRequestOptions, DidCommCredentialFormatCreateReturn, DidCommCredentialFormatProcessCredentialOptions, DidCommCredentialFormatProcessOptions, DidCommCredentialFormatService } from "@credo-ts/didcomm";
4
+
5
+ //#region src/formats/OpenBadgesCredentialFormatService.d.ts
6
+ type JsonObject = {
7
+ [key: string]: unknown;
8
+ };
9
+ declare class OpenBadgesCredentialFormatService implements DidCommCredentialFormatService<OpenBadgesCredentialFormat> {
10
+ readonly formatKey: "openbadges";
11
+ readonly credentialRecordType: "openbadges";
12
+ createProposal(_agentContext: AgentContext, {
13
+ credentialFormats,
14
+ attachmentId
15
+ }: DidCommCredentialFormatCreateProposalOptions<OpenBadgesCredentialFormat>): Promise<DidCommCredentialFormatCreateProposalReturn>;
16
+ processProposal(_agentContext: AgentContext, {
17
+ attachment
18
+ }: DidCommCredentialFormatProcessOptions): Promise<void>;
19
+ acceptProposal(_agentContext: AgentContext, {
20
+ attachmentId,
21
+ proposalAttachment
22
+ }: DidCommCredentialFormatAcceptProposalOptions<OpenBadgesCredentialFormat>): Promise<DidCommCredentialFormatCreateOfferReturn>;
23
+ createOffer(_agentContext: AgentContext, {
24
+ credentialFormats,
25
+ attachmentId
26
+ }: DidCommCredentialFormatCreateOfferOptions<OpenBadgesCredentialFormat>): Promise<DidCommCredentialFormatCreateOfferReturn>;
27
+ processOffer(_agentContext: AgentContext, {
28
+ attachment
29
+ }: DidCommCredentialFormatProcessOptions): Promise<void>;
30
+ acceptOffer(_agentContext: AgentContext, {
31
+ attachmentId,
32
+ offerAttachment
33
+ }: DidCommCredentialFormatAcceptOfferOptions<OpenBadgesCredentialFormat>): Promise<DidCommCredentialFormatCreateReturn>;
34
+ createRequest(_agentContext: AgentContext, {
35
+ credentialFormats
36
+ }: DidCommCredentialFormatCreateRequestOptions<OpenBadgesCredentialFormat>): Promise<DidCommCredentialFormatCreateReturn>;
37
+ processRequest(_agentContext: AgentContext, {
38
+ attachment
39
+ }: DidCommCredentialFormatProcessOptions): Promise<void>;
40
+ acceptRequest(agentContext: AgentContext, {
41
+ credentialFormats,
42
+ attachmentId,
43
+ requestAttachment
44
+ }: DidCommCredentialFormatAcceptRequestOptions<OpenBadgesCredentialFormat>): Promise<DidCommCredentialFormatCreateReturn>;
45
+ processCredential(agentContext: AgentContext, {
46
+ credentialExchangeRecord,
47
+ attachment
48
+ }: DidCommCredentialFormatProcessCredentialOptions): Promise<void>;
49
+ supportsFormat(format: string): boolean;
50
+ deleteCredentialById(agentContext: AgentContext, credentialId: string): Promise<void>;
51
+ shouldAutoRespondToProposal(_agentContext: AgentContext, {
52
+ proposalAttachment,
53
+ offerAttachment
54
+ }: DidCommCredentialFormatAutoRespondProposalOptions): Promise<boolean>;
55
+ shouldAutoRespondToOffer(_agentContext: AgentContext, {
56
+ proposalAttachment,
57
+ offerAttachment
58
+ }: DidCommCredentialFormatAutoRespondOfferOptions): Promise<boolean>;
59
+ shouldAutoRespondToRequest(_agentContext: AgentContext, {
60
+ offerAttachment,
61
+ requestAttachment
62
+ }: DidCommCredentialFormatAutoRespondRequestOptions): Promise<boolean>;
63
+ shouldAutoRespondToCredential(_agentContext: AgentContext, {
64
+ requestAttachment,
65
+ credentialAttachment
66
+ }: DidCommCredentialFormatAutoRespondCredentialOptions): Promise<boolean>;
67
+ private assertValidDetail;
68
+ private toAttachment;
69
+ }
70
+ declare function extractDerivedMetadata(credential: JsonObject): {
71
+ title?: string;
72
+ description?: string;
73
+ issuerName?: string;
74
+ issuedOn?: string;
75
+ image?: string;
76
+ };
77
+ //#endregion
78
+ export { OpenBadgesCredentialFormatService, extractDerivedMetadata };
79
+ //# sourceMappingURL=OpenBadgesCredentialFormatService.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenBadgesCredentialFormatService.d.mts","names":[],"sources":["../../src/formats/OpenBadgesCredentialFormatService.ts"],"mappings":";;;;;KA8BK,UAAA;EAAA,CAAgB,GAAA;AAAA;AAAA,cAER,iCAAA,YAA6C,8BAAA,CAA+B,0BAAA;EAAA,SACvE,SAAA;EAAA,SACA,oBAAA;EAEH,cAAA,CACX,aAAA,EAAe,YAAA;IACb,iBAAA;IAAmB;EAAA,GAAgB,4CAAA,CAA6C,0BAAA,IACjF,OAAA,CAAQ,2CAAA;EAUE,eAAA,CACX,aAAA,EAAe,YAAA;IACb;EAAA,GAAc,qCAAA,GACf,OAAA;EAMU,cAAA,CACX,aAAA,EAAe,YAAA;IACb,YAAA;IAAc;EAAA,GAAsB,4CAAA,CAA6C,0BAAA,IAClF,OAAA,CAAQ,wCAAA;EAQE,WAAA,CACX,aAAA,EAAe,YAAA;IACb,iBAAA;IAAmB;EAAA,GAAgB,yCAAA,CAA0C,0BAAA,IAC9E,OAAA,CAAQ,wCAAA;EAUE,YAAA,CACX,aAAA,EAAe,YAAA;IACb;EAAA,GAAc,qCAAA,GACf,OAAA;EAMU,WAAA,CACX,aAAA,EAAe,YAAA;IACb,YAAA;IAAc;EAAA,GAAmB,yCAAA,CAA0C,0BAAA,IAC5E,OAAA,CAAQ,mCAAA;EAQE,aAAA,CACX,aAAA,EAAe,YAAA;IACb;EAAA,GAAqB,2CAAA,CAA4C,0BAAA,IAClE,OAAA,CAAQ,mCAAA;EASE,cAAA,CACX,aAAA,EAAe,YAAA;IACb;EAAA,GAAc,qCAAA,GACf,OAAA;EAMU,aAAA,CACX,YAAA,EAAc,YAAA;IAEZ,iBAAA;IACA,YAAA;IACA;EAAA,GACC,2CAAA,CAA4C,0BAAA,IAC9C,OAAA,CAAQ,mCAAA;EAgCE,iBAAA,CACX,YAAA,EAAc,YAAA;IACZ,wBAAA;IAA0B;EAAA,GAAc,+CAAA,GACzC,OAAA;EAoBI,cAAA,CAAe,MAAA;EAIT,oBAAA,CAAqB,YAAA,EAAc,YAAA,EAAc,YAAA,WAAuB,OAAA;EAMxE,2BAAA,CACX,aAAA,EAAe,YAAA;IACb,kBAAA;IAAoB;EAAA,GAAmB,iDAAA,GACxC,OAAA;EAIU,wBAAA,CACX,aAAA,EAAe,YAAA;IACb,kBAAA;IAAoB;EAAA,GAAmB,8CAAA,GACxC,OAAA;EAIU,0BAAA,CACX,aAAA,EAAe,YAAA;IACb,eAAA;IAAiB;EAAA,GAAqB,gDAAA,GACvC,OAAA;EAIU,6BAAA,CACX,aAAA,EAAe,YAAA;IACb,iBAAA;IAAmB;EAAA,GAAwB,mDAAA,GAC5C,OAAA;EAAA,QAcK,iBAAA;EAAA,QA6BA,YAAA;AAAA;AAAA,iBA4BM,sBAAA,CAAuB,UAAA,EAAY,UAAA;EACjD,KAAA;EACA,WAAA;EACA,UAAA;EACA,QAAA;EACA,KAAA;AAAA"}
@@ -0,0 +1,208 @@
1
+ import { OpenBadgeCredentialRecord } from "../repository/OpenBadgeCredentialRecord.mjs";
2
+ import { OpenBadgeCredentialRepository } from "../repository/OpenBadgeCredentialRepository.mjs";
3
+ import { IssuerService } from "../services/IssuerService.mjs";
4
+ import { VerifyService } from "../services/VerifyService.mjs";
5
+ import { OPENBADGES_CREDENTIAL, OPENBADGES_CREDENTIAL_DETAIL } from "./OpenBadgesCredentialFormat.mjs";
6
+ import { CredoError, JsonEncoder, deepEquality } from "@credo-ts/core";
7
+ import { DidCommAttachment, DidCommAttachmentData, DidCommCredentialFormatSpec } from "@credo-ts/didcomm";
8
+
9
+ //#region src/formats/OpenBadgesCredentialFormatService.ts
10
+ var OpenBadgesCredentialFormatService = class {
11
+ constructor() {
12
+ this.formatKey = "openbadges";
13
+ this.credentialRecordType = "openbadges";
14
+ }
15
+ async createProposal(_agentContext, { credentialFormats, attachmentId }) {
16
+ const detail = credentialFormats.openbadges;
17
+ if (!detail) throw new CredoError("Missing openbadges payload in createProposal");
18
+ this.assertValidDetail(detail);
19
+ const format = new DidCommCredentialFormatSpec({
20
+ attachmentId,
21
+ format: OPENBADGES_CREDENTIAL_DETAIL
22
+ });
23
+ return {
24
+ format,
25
+ attachment: this.toAttachment(detail, format.attachmentId)
26
+ };
27
+ }
28
+ async processProposal(_agentContext, { attachment }) {
29
+ const detail = attachment.getDataAsJson();
30
+ if (!detail) throw new CredoError("Missing openbadges credential proposal data payload");
31
+ this.assertValidDetail(detail);
32
+ }
33
+ async acceptProposal(_agentContext, { attachmentId, proposalAttachment }) {
34
+ const detail = proposalAttachment.getDataAsJson();
35
+ this.assertValidDetail(detail);
36
+ const format = new DidCommCredentialFormatSpec({
37
+ attachmentId,
38
+ format: OPENBADGES_CREDENTIAL_DETAIL
39
+ });
40
+ return {
41
+ format,
42
+ attachment: this.toAttachment(detail, format.attachmentId)
43
+ };
44
+ }
45
+ async createOffer(_agentContext, { credentialFormats, attachmentId }) {
46
+ const detail = credentialFormats?.openbadges;
47
+ if (!detail) throw new CredoError("Missing openbadges payload in createOffer");
48
+ this.assertValidDetail(detail);
49
+ const format = new DidCommCredentialFormatSpec({
50
+ attachmentId,
51
+ format: OPENBADGES_CREDENTIAL_DETAIL
52
+ });
53
+ return {
54
+ format,
55
+ attachment: this.toAttachment(detail, format.attachmentId)
56
+ };
57
+ }
58
+ async processOffer(_agentContext, { attachment }) {
59
+ const detail = attachment.getDataAsJson();
60
+ if (!detail) throw new CredoError("Missing openbadges credential offer data payload");
61
+ this.assertValidDetail(detail);
62
+ }
63
+ async acceptOffer(_agentContext, { attachmentId, offerAttachment }) {
64
+ const detail = offerAttachment.getDataAsJson();
65
+ this.assertValidDetail(detail);
66
+ const format = new DidCommCredentialFormatSpec({
67
+ attachmentId,
68
+ format: OPENBADGES_CREDENTIAL_DETAIL
69
+ });
70
+ return {
71
+ format,
72
+ attachment: this.toAttachment(detail, format.attachmentId)
73
+ };
74
+ }
75
+ async createRequest(_agentContext, { credentialFormats }) {
76
+ const detail = credentialFormats?.openbadges;
77
+ if (!detail) throw new CredoError("Missing openbadges payload in createRequest");
78
+ this.assertValidDetail(detail);
79
+ const format = new DidCommCredentialFormatSpec({ format: OPENBADGES_CREDENTIAL_DETAIL });
80
+ return {
81
+ format,
82
+ attachment: this.toAttachment(detail, format.attachmentId)
83
+ };
84
+ }
85
+ async processRequest(_agentContext, { attachment }) {
86
+ const detail = attachment.getDataAsJson();
87
+ if (!detail) throw new CredoError("Missing openbadges credential request data payload");
88
+ this.assertValidDetail(detail);
89
+ }
90
+ async acceptRequest(agentContext, { credentialFormats, attachmentId, requestAttachment }) {
91
+ const issuerService = agentContext.dependencyManager.resolve(IssuerService);
92
+ const detail = requestAttachment.getDataAsJson();
93
+ this.assertValidDetail(detail);
94
+ const verificationMethod = credentialFormats?.openbadges?.verificationMethod ?? detail.options?.verificationMethod ?? detail.credential?.proof?.verificationMethod;
95
+ if (!verificationMethod) throw new CredoError("Missing verificationMethod for openbadges credential issuance");
96
+ const input = {
97
+ ...detail.credential,
98
+ proof: {
99
+ ...detail.credential.proof ?? {},
100
+ verificationMethod
101
+ }
102
+ };
103
+ const record = await issuerService.issueCredential(agentContext, input);
104
+ if (!record.credential) throw new CredoError("IssuerService returned a record without a signed credential");
105
+ const format = new DidCommCredentialFormatSpec({
106
+ attachmentId,
107
+ format: OPENBADGES_CREDENTIAL
108
+ });
109
+ return {
110
+ format,
111
+ attachment: this.toAttachment(record.credential, format.attachmentId)
112
+ };
113
+ }
114
+ async processCredential(agentContext, { credentialExchangeRecord, attachment }) {
115
+ const verifyService = agentContext.dependencyManager.resolve(VerifyService);
116
+ const repository = agentContext.dependencyManager.resolve(OpenBadgeCredentialRepository);
117
+ const credential = attachment.getDataAsJson();
118
+ if (!credential) throw new CredoError("Missing openbadges credential data payload");
119
+ const verifyResult = await verifyService.verify(agentContext, credential);
120
+ const derived = extractDerivedMetadata(credential);
121
+ const record = new OpenBadgeCredentialRecord({
122
+ credential,
123
+ status: verifyResult.status ?? "unknown",
124
+ derived
125
+ });
126
+ await repository.save(agentContext, record);
127
+ credentialExchangeRecord.credentials.push({
128
+ credentialRecordType: this.credentialRecordType,
129
+ credentialRecordId: record.id
130
+ });
131
+ }
132
+ supportsFormat(format) {
133
+ return format === OPENBADGES_CREDENTIAL_DETAIL || format === OPENBADGES_CREDENTIAL;
134
+ }
135
+ async deleteCredentialById(agentContext, credentialId) {
136
+ const repository = agentContext.dependencyManager.resolve(OpenBadgeCredentialRepository);
137
+ const record = await repository.findById(agentContext, credentialId);
138
+ if (record) await repository.delete(agentContext, record);
139
+ }
140
+ async shouldAutoRespondToProposal(_agentContext, { proposalAttachment, offerAttachment }) {
141
+ return attachmentsContainEqualCredential(proposalAttachment, offerAttachment);
142
+ }
143
+ async shouldAutoRespondToOffer(_agentContext, { proposalAttachment, offerAttachment }) {
144
+ return attachmentsContainEqualCredential(proposalAttachment, offerAttachment);
145
+ }
146
+ async shouldAutoRespondToRequest(_agentContext, { offerAttachment, requestAttachment }) {
147
+ return attachmentsContainEqualCredential(offerAttachment, requestAttachment);
148
+ }
149
+ async shouldAutoRespondToCredential(_agentContext, { requestAttachment, credentialAttachment }) {
150
+ const request = requestAttachment.getDataAsJson();
151
+ const signed = credentialAttachment.getDataAsJson();
152
+ if (!request || !signed) return false;
153
+ const signedUnsigned = { ...signed };
154
+ delete signedUnsigned.proof;
155
+ return deepEquality(pickEnvelopeFields(signedUnsigned, request.credential), pickEnvelopeFields(request.credential, request.credential));
156
+ }
157
+ assertValidDetail(detail) {
158
+ if (!detail || typeof detail !== "object") throw new CredoError("Invalid openbadges credential detail: payload missing");
159
+ const credential = detail.credential;
160
+ if (!credential || typeof credential !== "object") throw new CredoError("Invalid openbadges credential detail: credential missing");
161
+ const ctx = credential["@context"];
162
+ if (!Array.isArray(ctx) || ctx.length === 0) throw new CredoError("Invalid openbadges credential detail: @context must be a non-empty array");
163
+ const type = credential.type;
164
+ if (!Array.isArray(type) || !type.includes("VerifiableCredential")) throw new CredoError("Invalid openbadges credential detail: type must include \"VerifiableCredential\"");
165
+ if (!type.some((t) => t === "OpenBadgeCredential" || t === "AchievementCredential")) throw new CredoError("Invalid openbadges credential detail: type must include \"OpenBadgeCredential\" or \"AchievementCredential\"");
166
+ const subject = credential.credentialSubject;
167
+ if (!subject || typeof subject !== "object") throw new CredoError("Invalid openbadges credential detail: credentialSubject missing");
168
+ }
169
+ toAttachment(data, id) {
170
+ return new DidCommAttachment({
171
+ id,
172
+ mimeType: "application/json",
173
+ data: new DidCommAttachmentData({ base64: JsonEncoder.toBase64(data) })
174
+ });
175
+ }
176
+ };
177
+ function attachmentsContainEqualCredential(a, b) {
178
+ if (!a || !b) return false;
179
+ const left = a.getDataAsJson();
180
+ const right = b.getDataAsJson();
181
+ if (!left?.credential || !right?.credential) return false;
182
+ return deepEquality(left.credential, right.credential);
183
+ }
184
+ function pickEnvelopeFields(source, shape) {
185
+ const out = {};
186
+ for (const key of Object.keys(shape)) if (key in source) out[key] = source[key];
187
+ return out;
188
+ }
189
+ function extractDerivedMetadata(credential) {
190
+ const achievement = credential.credentialSubject?.achievement;
191
+ const issuer = credential.issuer;
192
+ let image;
193
+ if (achievement?.image) {
194
+ if (typeof achievement.image === "string") image = achievement.image;
195
+ else if (typeof achievement.image === "object") image = achievement.image.id;
196
+ }
197
+ return {
198
+ title: achievement?.name || credential.name,
199
+ description: achievement?.description,
200
+ issuerName: typeof issuer === "string" ? issuer : issuer?.name,
201
+ issuedOn: credential.validFrom || credential.issuanceDate,
202
+ image
203
+ };
204
+ }
205
+
206
+ //#endregion
207
+ export { OpenBadgesCredentialFormatService, extractDerivedMetadata };
208
+ //# sourceMappingURL=OpenBadgesCredentialFormatService.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenBadgesCredentialFormatService.mjs","names":[],"sources":["../../src/formats/OpenBadgesCredentialFormatService.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport { CredoError, JsonEncoder, deepEquality } from '@credo-ts/core'\nimport type {\n DidCommCredentialFormatAcceptOfferOptions,\n DidCommCredentialFormatAcceptProposalOptions,\n DidCommCredentialFormatAcceptRequestOptions,\n DidCommCredentialFormatAutoRespondCredentialOptions,\n DidCommCredentialFormatAutoRespondOfferOptions,\n DidCommCredentialFormatAutoRespondProposalOptions,\n DidCommCredentialFormatAutoRespondRequestOptions,\n DidCommCredentialFormatCreateOfferOptions,\n DidCommCredentialFormatCreateOfferReturn,\n DidCommCredentialFormatCreateProposalOptions,\n DidCommCredentialFormatCreateProposalReturn,\n DidCommCredentialFormatCreateRequestOptions,\n DidCommCredentialFormatCreateReturn,\n DidCommCredentialFormatProcessCredentialOptions,\n DidCommCredentialFormatProcessOptions,\n DidCommCredentialFormatService,\n} from '@credo-ts/didcomm'\nimport { DidCommAttachment, DidCommAttachmentData, DidCommCredentialFormatSpec } from '@credo-ts/didcomm'\n\nimport { IssuerService } from '../services/IssuerService'\nimport { VerifyService } from '../services/VerifyService'\nimport { OpenBadgeCredentialRecord } from '../repository/OpenBadgeCredentialRecord'\nimport { OpenBadgeCredentialRepository } from '../repository/OpenBadgeCredentialRepository'\n\nimport { OPENBADGES_CREDENTIAL, OPENBADGES_CREDENTIAL_DETAIL } from './OpenBadgesCredentialFormat'\nimport type { OpenBadgesCredentialDetail, OpenBadgesCredentialFormat } from './OpenBadgesCredentialFormat'\n\ntype JsonObject = { [key: string]: unknown }\n\nexport class OpenBadgesCredentialFormatService implements DidCommCredentialFormatService<OpenBadgesCredentialFormat> {\n public readonly formatKey = 'openbadges' as const\n public readonly credentialRecordType = 'openbadges' as const\n\n public async createProposal(\n _agentContext: AgentContext,\n { credentialFormats, attachmentId }: DidCommCredentialFormatCreateProposalOptions<OpenBadgesCredentialFormat>\n ): Promise<DidCommCredentialFormatCreateProposalReturn> {\n const detail = credentialFormats.openbadges\n if (!detail) throw new CredoError('Missing openbadges payload in createProposal')\n this.assertValidDetail(detail)\n\n const format = new DidCommCredentialFormatSpec({ attachmentId, format: OPENBADGES_CREDENTIAL_DETAIL })\n const attachment = this.toAttachment(detail, format.attachmentId)\n return { format, attachment }\n }\n\n public async processProposal(\n _agentContext: AgentContext,\n { attachment }: DidCommCredentialFormatProcessOptions\n ): Promise<void> {\n const detail = attachment.getDataAsJson<OpenBadgesCredentialDetail>()\n if (!detail) throw new CredoError('Missing openbadges credential proposal data payload')\n this.assertValidDetail(detail)\n }\n\n public async acceptProposal(\n _agentContext: AgentContext,\n { attachmentId, proposalAttachment }: DidCommCredentialFormatAcceptProposalOptions<OpenBadgesCredentialFormat>\n ): Promise<DidCommCredentialFormatCreateOfferReturn> {\n const detail = proposalAttachment.getDataAsJson<OpenBadgesCredentialDetail>()\n this.assertValidDetail(detail)\n const format = new DidCommCredentialFormatSpec({ attachmentId, format: OPENBADGES_CREDENTIAL_DETAIL })\n const attachment = this.toAttachment(detail, format.attachmentId)\n return { format, attachment }\n }\n\n public async createOffer(\n _agentContext: AgentContext,\n { credentialFormats, attachmentId }: DidCommCredentialFormatCreateOfferOptions<OpenBadgesCredentialFormat>\n ): Promise<DidCommCredentialFormatCreateOfferReturn> {\n const detail = credentialFormats?.openbadges\n if (!detail) throw new CredoError('Missing openbadges payload in createOffer')\n this.assertValidDetail(detail)\n\n const format = new DidCommCredentialFormatSpec({ attachmentId, format: OPENBADGES_CREDENTIAL_DETAIL })\n const attachment = this.toAttachment(detail, format.attachmentId)\n return { format, attachment }\n }\n\n public async processOffer(\n _agentContext: AgentContext,\n { attachment }: DidCommCredentialFormatProcessOptions\n ): Promise<void> {\n const detail = attachment.getDataAsJson<OpenBadgesCredentialDetail>()\n if (!detail) throw new CredoError('Missing openbadges credential offer data payload')\n this.assertValidDetail(detail)\n }\n\n public async acceptOffer(\n _agentContext: AgentContext,\n { attachmentId, offerAttachment }: DidCommCredentialFormatAcceptOfferOptions<OpenBadgesCredentialFormat>\n ): Promise<DidCommCredentialFormatCreateReturn> {\n const detail = offerAttachment.getDataAsJson<OpenBadgesCredentialDetail>()\n this.assertValidDetail(detail)\n const format = new DidCommCredentialFormatSpec({ attachmentId, format: OPENBADGES_CREDENTIAL_DETAIL })\n const attachment = this.toAttachment(detail, format.attachmentId)\n return { format, attachment }\n }\n\n public async createRequest(\n _agentContext: AgentContext,\n { credentialFormats }: DidCommCredentialFormatCreateRequestOptions<OpenBadgesCredentialFormat>\n ): Promise<DidCommCredentialFormatCreateReturn> {\n const detail = credentialFormats?.openbadges\n if (!detail) throw new CredoError('Missing openbadges payload in createRequest')\n this.assertValidDetail(detail)\n const format = new DidCommCredentialFormatSpec({ format: OPENBADGES_CREDENTIAL_DETAIL })\n const attachment = this.toAttachment(detail, format.attachmentId)\n return { format, attachment }\n }\n\n public async processRequest(\n _agentContext: AgentContext,\n { attachment }: DidCommCredentialFormatProcessOptions\n ): Promise<void> {\n const detail = attachment.getDataAsJson<OpenBadgesCredentialDetail>()\n if (!detail) throw new CredoError('Missing openbadges credential request data payload')\n this.assertValidDetail(detail)\n }\n\n public async acceptRequest(\n agentContext: AgentContext,\n {\n credentialFormats,\n attachmentId,\n requestAttachment,\n }: DidCommCredentialFormatAcceptRequestOptions<OpenBadgesCredentialFormat>\n ): Promise<DidCommCredentialFormatCreateReturn> {\n const issuerService = agentContext.dependencyManager.resolve(IssuerService)\n const detail = requestAttachment.getDataAsJson<OpenBadgesCredentialDetail>()\n this.assertValidDetail(detail)\n\n const verificationMethod =\n credentialFormats?.openbadges?.verificationMethod ??\n detail.options?.verificationMethod ??\n ((detail.credential as { proof?: { verificationMethod?: string } } | undefined)?.proof?.verificationMethod)\n\n if (!verificationMethod) {\n throw new CredoError('Missing verificationMethod for openbadges credential issuance')\n }\n\n const input: JsonObject = {\n ...detail.credential,\n proof: {\n ...((detail.credential.proof as JsonObject | undefined) ?? {}),\n verificationMethod,\n },\n }\n\n const record = await issuerService.issueCredential(agentContext, input)\n if (!record.credential) {\n throw new CredoError('IssuerService returned a record without a signed credential')\n }\n\n const format = new DidCommCredentialFormatSpec({ attachmentId, format: OPENBADGES_CREDENTIAL })\n const attachment = this.toAttachment(record.credential as JsonObject, format.attachmentId)\n return { format, attachment }\n }\n\n public async processCredential(\n agentContext: AgentContext,\n { credentialExchangeRecord, attachment }: DidCommCredentialFormatProcessCredentialOptions\n ): Promise<void> {\n const verifyService = agentContext.dependencyManager.resolve(VerifyService)\n const repository = agentContext.dependencyManager.resolve(OpenBadgeCredentialRepository)\n\n const credential = attachment.getDataAsJson<JsonObject>()\n if (!credential) throw new CredoError('Missing openbadges credential data payload')\n\n const verifyResult = await verifyService.verify(agentContext, credential)\n const derived = extractDerivedMetadata(credential)\n const status = (verifyResult.status ?? 'unknown') as OpenBadgeCredentialRecord['status']\n\n const record = new OpenBadgeCredentialRecord({ credential, status, derived })\n await repository.save(agentContext, record)\n\n credentialExchangeRecord.credentials.push({\n credentialRecordType: this.credentialRecordType,\n credentialRecordId: record.id,\n })\n }\n\n public supportsFormat(format: string): boolean {\n return format === OPENBADGES_CREDENTIAL_DETAIL || format === OPENBADGES_CREDENTIAL\n }\n\n public async deleteCredentialById(agentContext: AgentContext, credentialId: string): Promise<void> {\n const repository = agentContext.dependencyManager.resolve(OpenBadgeCredentialRepository)\n const record = await repository.findById(agentContext, credentialId)\n if (record) await repository.delete(agentContext, record)\n }\n\n public async shouldAutoRespondToProposal(\n _agentContext: AgentContext,\n { proposalAttachment, offerAttachment }: DidCommCredentialFormatAutoRespondProposalOptions\n ): Promise<boolean> {\n return attachmentsContainEqualCredential(proposalAttachment, offerAttachment)\n }\n\n public async shouldAutoRespondToOffer(\n _agentContext: AgentContext,\n { proposalAttachment, offerAttachment }: DidCommCredentialFormatAutoRespondOfferOptions\n ): Promise<boolean> {\n return attachmentsContainEqualCredential(proposalAttachment, offerAttachment)\n }\n\n public async shouldAutoRespondToRequest(\n _agentContext: AgentContext,\n { offerAttachment, requestAttachment }: DidCommCredentialFormatAutoRespondRequestOptions\n ): Promise<boolean> {\n return attachmentsContainEqualCredential(offerAttachment, requestAttachment)\n }\n\n public async shouldAutoRespondToCredential(\n _agentContext: AgentContext,\n { requestAttachment, credentialAttachment }: DidCommCredentialFormatAutoRespondCredentialOptions\n ): Promise<boolean> {\n const request = requestAttachment.getDataAsJson<OpenBadgesCredentialDetail>()\n const signed = credentialAttachment.getDataAsJson<JsonObject>()\n if (!request || !signed) return false\n\n const signedUnsigned = { ...signed }\n delete signedUnsigned.proof\n\n return deepEquality(\n pickEnvelopeFields(signedUnsigned, request.credential),\n pickEnvelopeFields(request.credential, request.credential)\n )\n }\n\n private assertValidDetail(\n detail: OpenBadgesCredentialDetail | undefined\n ): asserts detail is OpenBadgesCredentialDetail {\n if (!detail || typeof detail !== 'object') {\n throw new CredoError('Invalid openbadges credential detail: payload missing')\n }\n const credential = detail.credential\n if (!credential || typeof credential !== 'object') {\n throw new CredoError('Invalid openbadges credential detail: credential missing')\n }\n const ctx = (credential as { '@context'?: unknown })['@context']\n if (!Array.isArray(ctx) || ctx.length === 0) {\n throw new CredoError('Invalid openbadges credential detail: @context must be a non-empty array')\n }\n const type = (credential as { type?: unknown }).type\n if (!Array.isArray(type) || !type.includes('VerifiableCredential')) {\n throw new CredoError('Invalid openbadges credential detail: type must include \"VerifiableCredential\"')\n }\n if (!type.some((t) => t === 'OpenBadgeCredential' || t === 'AchievementCredential')) {\n throw new CredoError(\n 'Invalid openbadges credential detail: type must include \"OpenBadgeCredential\" or \"AchievementCredential\"'\n )\n }\n const subject = (credential as { credentialSubject?: unknown }).credentialSubject\n if (!subject || typeof subject !== 'object') {\n throw new CredoError('Invalid openbadges credential detail: credentialSubject missing')\n }\n }\n\n private toAttachment(data: unknown, id: string): DidCommAttachment {\n return new DidCommAttachment({\n id,\n mimeType: 'application/json',\n data: new DidCommAttachmentData({ base64: JsonEncoder.toBase64(data) }),\n })\n }\n}\n\nfunction attachmentsContainEqualCredential(\n a: DidCommAttachment | undefined,\n b: DidCommAttachment | undefined\n): boolean {\n if (!a || !b) return false\n const left = a.getDataAsJson<OpenBadgesCredentialDetail>()\n const right = b.getDataAsJson<OpenBadgesCredentialDetail>()\n if (!left?.credential || !right?.credential) return false\n return deepEquality(left.credential, right.credential)\n}\n\nfunction pickEnvelopeFields(source: JsonObject, shape: JsonObject): JsonObject {\n const out: JsonObject = {}\n for (const key of Object.keys(shape)) {\n if (key in source) out[key] = source[key]\n }\n return out\n}\n\nexport function extractDerivedMetadata(credential: JsonObject): {\n title?: string\n description?: string\n issuerName?: string\n issuedOn?: string\n image?: string\n} {\n const credSubject = credential.credentialSubject as JsonObject | undefined\n const achievement = credSubject?.achievement as JsonObject | undefined\n const issuer = credential.issuer as JsonObject | string | undefined\n\n let image: string | undefined\n if (achievement?.image) {\n if (typeof achievement.image === 'string') image = achievement.image\n else if (typeof achievement.image === 'object') image = (achievement.image as JsonObject).id as string | undefined\n }\n\n return {\n title: (achievement?.name as string) || (credential.name as string | undefined),\n description: achievement?.description as string | undefined,\n issuerName: typeof issuer === 'string' ? issuer : (issuer?.name as string | undefined),\n issuedOn: (credential.validFrom as string) || (credential.issuanceDate as string),\n image,\n }\n}\n"],"mappings":";;;;;;;;;AAgCA,IAAa,oCAAb,MAAqH;;OACnG,YAAY;OACZ,uBAAuB;;CAEvC,MAAa,eACX,eACA,EAAE,mBAAmB,gBACiC;EACtD,MAAM,SAAS,kBAAkB;AACjC,MAAI,CAAC,OAAQ,OAAM,IAAI,WAAW,+CAA+C;AACjF,OAAK,kBAAkB,OAAO;EAE9B,MAAM,SA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S,YAAY,MAAqB;;AAG5F,QAAO;EACL,OAAQ,aAAa,QAAoB,WAAW;EACpD,aAAa,aAAa;EAC1B,YAAY,OAAO,WAAW,WAAW,SAAU,QAAQ;EAC3D,UAAW,WAAW,aAAyB,WAAW;EAC1D;EACD"}
@@ -0,0 +1,41 @@
1
+ import { OpenBadgeCredentialRecord } from "../repository/OpenBadgeCredentialRecord.mjs";
2
+ import { JsonObject } from "./OpenBadgesCredentialFormat.mjs";
3
+ import { DidCommProofFormat } from "@credo-ts/didcomm";
4
+
5
+ //#region src/formats/OpenBadgesProofFormat.d.ts
6
+ interface OpenBadgesPresentationRequest {
7
+ achievementName?: string;
8
+ achievementType?: string;
9
+ issuerId?: string;
10
+ comment?: string;
11
+ }
12
+ interface OpenBadgesAcceptRequestInput {
13
+ credentialRecordId?: string;
14
+ }
15
+ interface OpenBadgesProofFormat extends DidCommProofFormat {
16
+ formatKey: 'openbadges';
17
+ proofFormats: {
18
+ createProposal: OpenBadgesPresentationRequest;
19
+ acceptProposal: Record<string, never>;
20
+ createRequest: OpenBadgesPresentationRequest;
21
+ acceptRequest: OpenBadgesAcceptRequestInput;
22
+ getCredentialsForRequest: {
23
+ input: Record<string, never>;
24
+ output: OpenBadgeCredentialRecord[];
25
+ };
26
+ selectCredentialsForRequest: {
27
+ input: Record<string, never>;
28
+ output: OpenBadgeCredentialRecord | null;
29
+ };
30
+ };
31
+ formatData: {
32
+ proposal: OpenBadgesPresentationRequest;
33
+ request: OpenBadgesPresentationRequest;
34
+ presentation: JsonObject;
35
+ };
36
+ }
37
+ declare const OPENBADGES_PRESENTATION_REQUEST = "ob/3.0/presentation-request@v1.0";
38
+ declare const OPENBADGES_PRESENTATION = "ob/3.0/presentation@v1.0";
39
+ //#endregion
40
+ export { OPENBADGES_PRESENTATION, OPENBADGES_PRESENTATION_REQUEST, OpenBadgesAcceptRequestInput, OpenBadgesPresentationRequest, OpenBadgesProofFormat };
41
+ //# sourceMappingURL=OpenBadgesProofFormat.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenBadgesProofFormat.d.mts","names":[],"sources":["../../src/formats/OpenBadgesProofFormat.ts"],"mappings":";;;;;UAKiB,6BAAA;EACf,eAAA;EACA,eAAA;EACA,QAAA;EACA,OAAA;AAAA;AAAA,UAGe,4BAAA;EACf,kBAAA;AAAA;AAAA,UAGe,qBAAA,SAA8B,kBAAA;EAC7C,SAAA;EACA,YAAA;IACE,cAAA,EAAgB,6BAAA;IAChB,cAAA,EAAgB,MAAA;IAChB,aAAA,EAAe,6BAAA;IACf,aAAA,EAAe,4BAAA;IACf,wBAAA;MACE,KAAA,EAAO,MAAA;MACP,MAAA,EAAQ,yBAAA;IAAA;IAEV,2BAAA;MACE,KAAA,EAAO,MAAA;MACP,MAAA,EAAQ,yBAAA;IAAA;EAAA;EAGZ,UAAA;IACE,QAAA,EAAU,6BAAA;IACV,OAAA,EAAS,6BAAA;IACT,YAAA,EAAc,UAAA;EAAA;AAAA;AAAA,cAIL,+BAAA;AAAA,cACA,uBAAA"}
@@ -0,0 +1,7 @@
1
+ //#region src/formats/OpenBadgesProofFormat.ts
2
+ const OPENBADGES_PRESENTATION_REQUEST = "ob/3.0/presentation-request@v1.0";
3
+ const OPENBADGES_PRESENTATION = "ob/3.0/presentation@v1.0";
4
+
5
+ //#endregion
6
+ export { OPENBADGES_PRESENTATION, OPENBADGES_PRESENTATION_REQUEST };
7
+ //# sourceMappingURL=OpenBadgesProofFormat.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenBadgesProofFormat.mjs","names":[],"sources":["../../src/formats/OpenBadgesProofFormat.ts"],"sourcesContent":["import type { DidCommProofFormat } from '@credo-ts/didcomm'\n\nimport type { OpenBadgeCredentialRecord } from '../repository/OpenBadgeCredentialRecord'\nimport type { JsonObject } from './OpenBadgesCredentialFormat'\n\nexport interface OpenBadgesPresentationRequest {\n achievementName?: string\n achievementType?: string\n issuerId?: string\n comment?: string\n}\n\nexport interface OpenBadgesAcceptRequestInput {\n credentialRecordId?: string\n}\n\nexport interface OpenBadgesProofFormat extends DidCommProofFormat {\n formatKey: 'openbadges'\n proofFormats: {\n createProposal: OpenBadgesPresentationRequest\n acceptProposal: Record<string, never>\n createRequest: OpenBadgesPresentationRequest\n acceptRequest: OpenBadgesAcceptRequestInput\n getCredentialsForRequest: {\n input: Record<string, never>\n output: OpenBadgeCredentialRecord[]\n }\n selectCredentialsForRequest: {\n input: Record<string, never>\n output: OpenBadgeCredentialRecord | null\n }\n }\n formatData: {\n proposal: OpenBadgesPresentationRequest\n request: OpenBadgesPresentationRequest\n presentation: JsonObject\n }\n}\n\nexport const OPENBADGES_PRESENTATION_REQUEST = 'ob/3.0/presentation-request@v1.0'\nexport const OPENBADGES_PRESENTATION = 'ob/3.0/presentation@v1.0'\n"],"mappings":";AAuCA,MAAa,kCAAkC;AAC/C,MAAa,0BAA0B"}
@@ -0,0 +1,56 @@
1
+ import { OpenBadgeCredentialRecord } from "../repository/OpenBadgeCredentialRecord.mjs";
2
+ import { OpenBadgesProofFormat } from "./OpenBadgesProofFormat.mjs";
3
+ import { AgentContext } from "@credo-ts/core";
4
+ import { DidCommFormatCreateRequestOptions, DidCommProofFormatAcceptProposalOptions, DidCommProofFormatAcceptRequestOptions, DidCommProofFormatAutoRespondPresentationOptions, DidCommProofFormatAutoRespondProposalOptions, DidCommProofFormatAutoRespondRequestOptions, DidCommProofFormatCreateProposalOptions, DidCommProofFormatCreateReturn, DidCommProofFormatGetCredentialsForRequestOptions, DidCommProofFormatProcessOptions, DidCommProofFormatProcessPresentationOptions, DidCommProofFormatSelectCredentialsForRequestOptions, DidCommProofFormatService } from "@credo-ts/didcomm";
5
+
6
+ //#region src/formats/OpenBadgesProofFormatService.d.ts
7
+ declare class OpenBadgesProofFormatService implements DidCommProofFormatService<OpenBadgesProofFormat> {
8
+ readonly formatKey: "openbadges";
9
+ supportsFormat(format: string): boolean;
10
+ createProposal(_agentContext: AgentContext, {
11
+ proofFormats,
12
+ attachmentId
13
+ }: DidCommProofFormatCreateProposalOptions<OpenBadgesProofFormat>): Promise<DidCommProofFormatCreateReturn>;
14
+ processProposal(_agentContext: AgentContext, {
15
+ attachment
16
+ }: DidCommProofFormatProcessOptions): Promise<void>;
17
+ acceptProposal(_agentContext: AgentContext, {
18
+ attachmentId,
19
+ proposalAttachment
20
+ }: DidCommProofFormatAcceptProposalOptions<OpenBadgesProofFormat>): Promise<DidCommProofFormatCreateReturn>;
21
+ createRequest(_agentContext: AgentContext, {
22
+ proofFormats,
23
+ attachmentId
24
+ }: DidCommFormatCreateRequestOptions<OpenBadgesProofFormat>): Promise<DidCommProofFormatCreateReturn>;
25
+ processRequest(_agentContext: AgentContext, {
26
+ attachment
27
+ }: DidCommProofFormatProcessOptions): Promise<void>;
28
+ acceptRequest(agentContext: AgentContext, {
29
+ proofFormats,
30
+ attachmentId,
31
+ requestAttachment
32
+ }: DidCommProofFormatAcceptRequestOptions<OpenBadgesProofFormat>): Promise<DidCommProofFormatCreateReturn>;
33
+ processPresentation(agentContext: AgentContext, {
34
+ attachment,
35
+ requestAttachment
36
+ }: DidCommProofFormatProcessPresentationOptions): Promise<boolean>;
37
+ getCredentialsForRequest(agentContext: AgentContext, {
38
+ requestAttachment
39
+ }: DidCommProofFormatGetCredentialsForRequestOptions<OpenBadgesProofFormat>): Promise<OpenBadgeCredentialRecord[]>;
40
+ selectCredentialsForRequest(agentContext: AgentContext, {
41
+ requestAttachment
42
+ }: DidCommProofFormatSelectCredentialsForRequestOptions<OpenBadgesProofFormat>): Promise<OpenBadgeCredentialRecord | null>;
43
+ shouldAutoRespondToProposal(_agentContext: AgentContext, {
44
+ proposalAttachment,
45
+ requestAttachment
46
+ }: DidCommProofFormatAutoRespondProposalOptions): Promise<boolean>;
47
+ shouldAutoRespondToRequest(_agentContext: AgentContext, {
48
+ requestAttachment,
49
+ proposalAttachment
50
+ }: DidCommProofFormatAutoRespondRequestOptions): Promise<boolean>;
51
+ shouldAutoRespondToPresentation(_agentContext: AgentContext, _options: DidCommProofFormatAutoRespondPresentationOptions): Promise<boolean>;
52
+ private toAttachment;
53
+ }
54
+ //#endregion
55
+ export { OpenBadgesProofFormatService };
56
+ //# sourceMappingURL=OpenBadgesProofFormatService.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenBadgesProofFormatService.d.mts","names":[],"sources":["../../src/formats/OpenBadgesProofFormatService.ts"],"mappings":";;;;;;cA4Ba,4BAAA,YAAwC,yBAAA,CAA0B,qBAAA;EAAA,SAC7D,SAAA;EAET,cAAA,CAAe,MAAA;EAIT,cAAA,CACX,aAAA,EAAe,YAAA;IACb,YAAA;IAAc;EAAA,GAAgB,uCAAA,CAAwC,qBAAA,IACvE,OAAA,CAAQ,8BAAA;EASE,eAAA,CACX,aAAA,EAAe,YAAA;IACb;EAAA,GAAc,gCAAA,GACf,OAAA;EAOU,cAAA,CACX,aAAA,EAAe,YAAA;IACb,YAAA;IAAc;EAAA,GAAsB,uCAAA,CAAwC,qBAAA,IAC7E,OAAA,CAAQ,8BAAA;EAOE,aAAA,CACX,aAAA,EAAe,YAAA;IACb,YAAA;IAAc;EAAA,GAAgB,iCAAA,CAAkC,qBAAA,IACjE,OAAA,CAAQ,8BAAA;EAOE,cAAA,CACX,aAAA,EAAe,YAAA;IACb;EAAA,GAAc,gCAAA,GACf,OAAA;EAOU,aAAA,CACX,YAAA,EAAc,YAAA;IACZ,YAAA;IAAc,YAAA;IAAc;EAAA,GAAqB,sCAAA,CAAuC,qBAAA,IACzF,OAAA,CAAQ,8BAAA;EA0BE,mBAAA,CACX,YAAA,EAAc,YAAA;IACZ,UAAA;IAAY;EAAA,GAAqB,4CAAA,GAClC,OAAA;EAsBU,wBAAA,CACX,YAAA,EAAc,YAAA;IACZ;EAAA,GAAqB,iDAAA,CAAkD,qBAAA,IACxE,OAAA,CAAQ,yBAAA;EAME,2BAAA,CACX,YAAA,EAAc,YAAA;IACZ;EAAA,GAAqB,oDAAA,CAAqD,qBAAA,IAC3E,OA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