@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 @@
1
+ {"version":3,"file":"OAuthClient.mjs","names":[],"sources":["../../src/services/OAuthClient.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport { injectable, inject } from '@credo-ts/core'\nimport { OpenBadgesOAuthRepository } from '../repository/OpenBadgesOAuthRepository'\nimport { OpenBadgesTokenRepository } from '../repository/OpenBadgesTokenRepository'\nimport { OpenBadgesTokenRecord } from '../repository/OpenBadgesTokenRecord'\n\n@injectable()\nexport class OAuthClient {\n public constructor(\n @inject(OpenBadgesOAuthRepository) private readonly repo: OpenBadgesOAuthRepository,\n @inject(OpenBadgesTokenRepository) private readonly tokens: OpenBadgesTokenRepository\n ) {}\n\n public async registerClient(agentContext: AgentContext, registrationUrl: string, body: Record<string, unknown>) {\n const res = await fetch(registrationUrl, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n })\n if (!res.ok) throw new Error(`registration_failed: ${res.status}`)\n const reg = await res.json()\n const host = new URL(registrationUrl).origin\n const rec = new (require('../repository/OpenBadgesOAuthRecord').OpenBadgesOAuthRecord)({ host, clientRegistration: reg })\n await this.repo.save(agentContext, rec)\n return reg\n }\n\n public buildAuthorizationUrl(_authorizationUrl: string, _params: Record<string, string>) {\n const url = new URL(_authorizationUrl)\n for (const [k, v] of Object.entries(_params)) url.searchParams.set(k, v)\n return url.toString()\n }\n\n public async completeAuthorizationCode(agentContext: AgentContext, tokenUrl: string, params: Record<string, string> & { host?: string }) {\n const { client_id, client_secret, host, ...rest } = params\n const basic = Buffer.from(`${client_id}:${client_secret}`).toString('base64')\n const res = await fetch(tokenUrl, {\n method: 'POST',\n headers: { 'content-type': 'application/x-www-form-urlencoded', authorization: `Basic ${basic}` },\n body: new URLSearchParams({ grant_type: 'authorization_code', ...rest }).toString(),\n })\n if (!res.ok) throw new Error(`token_failed: ${res.status}`)\n const json = (await res.json()) as {\n access_token: string\n refresh_token?: string\n scope?: string\n expires_in?: number\n }\n const pairId = Math.random().toString(36).slice(2)\n await this.tokens.save(\n agentContext as any,\n new OpenBadgesTokenRecord({\n token: json.access_token,\n tokenType: 'access',\n clientId: client_id,\n subject: 'unknown',\n scope: json.scope,\n expiresAt: new Date(Date.now() + (json.expires_in ?? 180) * 1000),\n pairId,\n host,\n })\n )\n if (json.refresh_token) {\n await this.tokens.save(\n agentContext as any,\n new OpenBadgesTokenRecord({\n token: json.refresh_token,\n tokenType: 'refresh',\n clientId: client_id,\n subject: 'unknown',\n scope: json.scope,\n expiresAt: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000),\n pairId,\n host,\n })\n )\n }\n return json\n }\n\n public async getAccessToken(agentContext: AgentContext, tokenUrl: string, params: Record<string, string> & { host?: string }) {\n const { client_id, client_secret, refresh_token, scope, host } = params\n const basic = Buffer.from(`${client_id}:${client_secret}`).toString('base64')\n const res = await fetch(tokenUrl, {\n method: 'POST',\n headers: { 'content-type': 'application/x-www-form-urlencoded', authorization: `Basic ${basic}` },\n body: new URLSearchParams({ grant_type: 'refresh_token', refresh_token, scope: scope ?? '' }).toString(),\n })\n if (!res.ok) throw new Error(`token_failed: ${res.status}`)\n const json = (await res.json()) as {\n access_token: string\n refresh_token?: string\n scope?: string\n expires_in?: number\n }\n // Rotate stored refresh token: delete old, store new; store new access token\n const pairId = Math.random().toString(36).slice(2)\n await this.tokens.save(\n agentContext as any,\n new OpenBadgesTokenRecord({\n token: json.access_token,\n tokenType: 'access',\n clientId: client_id,\n subject: 'unknown',\n scope: json.scope,\n expiresAt: new Date(Date.now() + (json.expires_in ?? 180) * 1000),\n pairId,\n host,\n })\n )\n if (json.refresh_token) {\n await this.tokens.save(\n agentContext as any,\n new OpenBadgesTokenRecord({\n token: json.refresh_token,\n tokenType: 'refresh',\n clientId: client_id,\n subject: 'unknown',\n scope: json.scope,\n expiresAt: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000),\n pairId,\n host,\n })\n )\n }\n return json\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOO,wBAAM,YAAY;CACvB,AAAO,YACL,AAAoD,MACpD,AAAoD,QACpD;EAFoD;EACA;;CAGtD,MAAa,eAAe,cAA4B,iBAAyB,MAA+B;EAC9G,MAAM,MAAM,MAAM,MAAM,iBAAiB;GACvC,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAC/C,MAAM,KAAK,UAAU,KAAK;GAC3B,CAAC;AACF,MAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,wBAAwB,IAAI,SAAS;EAClE,MAAM,MAAM,MAAM,IAAI,MAAM;EAC5B,MAAM,OAAO,IAAI,IAAI,gBAAgB,CAAC;EACtC,MAAM,MAAM,gFAAoD,sBAAuB;GAAE;GAAM,oBAAoB;GAAK,CAAC;AACzH,QAAM,KAAK,KAAK,KAAK,cAAc,IAAI;AACvC,SAAO;;CAGT,AAAO,sBAAsB,mBAA2B,SAAiC;EACvF,MAAM,MAAM,IAAI,IAAI,kBAAkB;AACtC,OAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,QAAQ,CAAE,KAAI,aAAa,IAAI,GAAG,EAAE;AACxE,SAAO,IAAI,UAAU;;CAGvB,MAAa,0BAA0B,cAA4B,UAAkB,QAAoD;EACvI,MAAM,EAAE,WAAW,eAAe,MAAM,GAAG,SAAS;EACpD,MAAM,QAAQ,OAAO,KAAK,GAAG,UAAU,GAAG,gBAAgB,CAAC,SAAS,SAAS;EAC7E,MAAM,MAAM,MAAM,MAAM,UAAU;GAChC,QAAQ;GACR,SAAS;IAAE,gBAAgB;IAAqC,eAAe,SAAS;IAAS;GACjG,MAAM,IAAI,gBAAgB;IAAE,YAAY;IAAsB,GAAG;IAAM,CAAC,CAAC,UAAU;GACpF,CAAC;AACF,MAAI,CA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GACX,UAAU;GACV,SAAS;GACT,OAAO,KAAK;GACZ,WAAW,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,cAAc,OAAO,IAAK;GACjE;GACA;GACD,CAAC,CACH;AACD,MAAI,KAAK,cACP,OAAM,KAAK,OAAO,KAChB,cACA,IAAI,sBAAsB;GACxB,OAAO,KAAK;GACZ,WAAW;GACX,UAAU;GACV,SAAS;GACT,OAAO,KAAK;GACZ,WAAW,IAAI,KAAK,KAAK,KAAK,GAAG,OAAU,KAAK,KAAK,IAAK;GAC1D;GACA;GACD,CAAC,CACH;AAEH,SAAO;;;;CAvHV,YAAY;oBAGR,OAAO,0BAA0B;oBACjC,OAAO,0BAA0B"}
@@ -0,0 +1,20 @@
1
+ import { OpenBadgesModuleConfig } from "../OpenBadgesModuleConfig.mjs";
2
+ import { CryptoDriver } from "./crypto/CryptoDriver.mjs";
3
+ import { JsonLdCryptoDriver } from "./crypto/JsonLdCryptoDriver.mjs";
4
+ import { JwtCryptoDriver } from "./crypto/JwtCryptoDriver.mjs";
5
+ import { AgentContext } from "@credo-ts/core";
6
+
7
+ //#region src/services/ProofService.d.ts
8
+ declare class ProofService implements CryptoDriver {
9
+ private driver;
10
+ constructor(config: OpenBadgesModuleConfig, jsonld: JsonLdCryptoDriver, jwt: JwtCryptoDriver);
11
+ sign(agentContext: AgentContext, document: any, keyHint?: any): Promise<any>;
12
+ verify(agentContext: AgentContext, input: any): Promise<{
13
+ verified: boolean;
14
+ credential?: any;
15
+ error?: string;
16
+ }>;
17
+ }
18
+ //#endregion
19
+ export { ProofService };
20
+ //# sourceMappingURL=ProofService.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProofService.d.mts","names":[],"sources":["../../src/services/ProofService.ts"],"mappings":";;;;;;;cAQa,YAAA,YAAwB,YAAA;EAAA,QAC3B,MAAA;cAG0B,MAAA,EAAQ,sBAAA,EACZ,MAAA,EAAQ,kBAAA,EACX,GAAA,EAAK,eAAA;EAMzB,IAAA,CAAK,YAAA,EAAc,YAAA,EAAc,QAAA,OAAe,OAAA,SAAgB,OAAA;EAKhE,MAAA,CAAO,YAAA,EAAc,YAAA,EAAc,KAAA,QAAU,OAAA"}
@@ -0,0 +1,39 @@
1
+ import { OpenBadgesModuleConfig } from "../OpenBadgesModuleConfig.mjs";
2
+ import { __decorateMetadata, init_decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
3
+ import { __decorateParam, init_decorateParam } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs";
4
+ import { __decorate, init_decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
5
+ import { JsonLdCryptoDriver } from "./crypto/JsonLdCryptoDriver.mjs";
6
+ import { JwtCryptoDriver } from "./crypto/JwtCryptoDriver.mjs";
7
+ import { inject, injectable } from "@credo-ts/core";
8
+
9
+ //#region src/services/ProofService.ts
10
+ init_decorateMetadata();
11
+ init_decorateParam();
12
+ init_decorate();
13
+ var _ref, _ref2, _ref3;
14
+ let ProofService = class ProofService {
15
+ constructor(config, jsonld, jwt) {
16
+ this.driver = config.proofType === "jwt" ? jwt : jsonld;
17
+ }
18
+ sign(agentContext, document, keyHint) {
19
+ return this.driver.sign(agentContext, document, keyHint);
20
+ }
21
+ verify(agentContext, input) {
22
+ return this.driver.verify(agentContext, input);
23
+ }
24
+ };
25
+ ProofService = __decorate([
26
+ injectable(),
27
+ __decorateParam(0, inject(OpenBadgesModuleConfig)),
28
+ __decorateParam(1, inject(JsonLdCryptoDriver)),
29
+ __decorateParam(2, inject(JwtCryptoDriver)),
30
+ __decorateMetadata("design:paramtypes", [
31
+ OpenBadgesModuleConfig,
32
+ JsonLdCryptoDriver,
33
+ JwtCryptoDriver
34
+ ])
35
+ ], ProofService);
36
+
37
+ //#endregion
38
+ export { ProofService };
39
+ //# sourceMappingURL=ProofService.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProofService.mjs","names":[],"sources":["../../src/services/ProofService.ts"],"sourcesContent":["import { injectable, inject } from '@credo-ts/core'\nimport type { AgentContext } from '@credo-ts/core'\nimport { OpenBadgesModuleConfig } from '../OpenBadgesModuleConfig'\nimport { CryptoDriver } from './crypto/CryptoDriver'\nimport { JsonLdCryptoDriver } from './crypto/JsonLdCryptoDriver'\nimport { JwtCryptoDriver } from './crypto/JwtCryptoDriver'\n\n@injectable()\nexport class ProofService implements CryptoDriver {\n private driver: CryptoDriver\n\n public constructor(\n @inject(OpenBadgesModuleConfig) config: OpenBadgesModuleConfig,\n @inject(JsonLdCryptoDriver) jsonld: JsonLdCryptoDriver,\n @inject(JwtCryptoDriver) jwt: JwtCryptoDriver\n ) {\n this.driver = config.proofType === 'jwt' ? jwt : jsonld\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public sign(agentContext: AgentContext, document: any, keyHint?: any): Promise<any> {\n return this.driver.sign(agentContext, document, keyHint)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public verify(agentContext: AgentContext, input: any) {\n return this.driver.verify(agentContext, input)\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;AAQO,yBAAM,aAAqC;CAGhD,AAAO,YACL,AAAgC,QAChC,AAA4B,QAC5B,AAAyB,KACzB;AACA,OAAK,SAAS,OAAO,cAAc,QAAQ,MAAM;;CAInD,AAAO,KAAK,cAA4B,UAAe,SAA6B;AAClF,SAAO,KAAK,OAAO,KAAK,cAAc,UAAU,QAAQ;;CAI1D,AAAO,OAAO,cAA4B,OAAY;AACpD,SAAO,KAAK,OAAO,OAAO,cAAc,MAAM;;;;CAnBjD,YAAY;oBAKR,OAAO,uBAAuB;oBAC9B,OAAO,mBAAmB;oBAC1B,OAAO,gBAAgB"}
@@ -0,0 +1,64 @@
1
+ import { OpenBadgesRevocationCacheRepository } from "../repository/OpenBadgesRevocationCacheRepository.mjs";
2
+ import { CreateStatusListInput, StatusListCredential, StatusListEntry } from "../models/StatusListCredential.mjs";
3
+ import { StatusListRecord } from "../repository/StatusListRecord.mjs";
4
+ import { StatusListRepository } from "../repository/StatusListRepository.mjs";
5
+ import { AgentContext } from "@credo-ts/core";
6
+
7
+ //#region src/services/RevocationService.d.ts
8
+ declare class RevocationService {
9
+ private readonly cacheRepo;
10
+ private readonly statusListRepo;
11
+ constructor(cacheRepo: OpenBadgesRevocationCacheRepository, statusListRepo: StatusListRepository);
12
+ isRevoked(agentContext: AgentContext, credential: any): Promise<boolean>;
13
+ private getStatusListBits;
14
+ /**
15
+ * Create a new status list for credential revocation or suspension
16
+ */
17
+ createStatusList(agentContext: AgentContext, input: CreateStatusListInput): Promise<StatusListRecord>;
18
+ /**
19
+ * Allocate the next available index in a status list for a credential
20
+ * Returns the allocated index
21
+ */
22
+ allocateIndex(agentContext: AgentContext, listId: string, credentialId?: string): Promise<number>;
23
+ /**
24
+ * Set the status (revoked/suspended or active) for a specific index
25
+ */
26
+ setStatus(agentContext: AgentContext, options: {
27
+ listId: string;
28
+ index: number;
29
+ status: boolean;
30
+ }): Promise<void>;
31
+ /**
32
+ * Revoke a credential by its credential ID (if tracked)
33
+ */
34
+ revokeByCredentialId(agentContext: AgentContext, listId: string, credentialId: string): Promise<void>;
35
+ /**
36
+ * Get the status of a specific index
37
+ */
38
+ getStatus(agentContext: AgentContext, listId: string, index: number): Promise<boolean>;
39
+ /**
40
+ * Build an unsigned StatusList2021Credential for a status list
41
+ * This can then be signed using the ProofService
42
+ */
43
+ buildStatusListCredential(record: StatusListRecord): StatusListCredential;
44
+ /**
45
+ * Create a StatusListEntry to add to a credential
46
+ */
47
+ createStatusEntry(record: StatusListRecord, index: number, entryId?: string): StatusListEntry;
48
+ /**
49
+ * Add a credentialStatus field to a credential
50
+ * This should be called before signing the credential
51
+ */
52
+ addCredentialStatus(credential: any, statusEntry: StatusListEntry): any;
53
+ /**
54
+ * Get a status list record by its ID
55
+ */
56
+ getStatusList(agentContext: AgentContext, listId: string): Promise<StatusListRecord | null>;
57
+ /**
58
+ * Get all status lists for an issuer
59
+ */
60
+ getStatusListsByIssuer(agentContext: AgentContext, issuerDid: string): Promise<StatusListRecord[]>;
61
+ }
62
+ //#endregion
63
+ export { RevocationService };
64
+ //# sourceMappingURL=RevocationService.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RevocationService.d.mts","names":[],"sources":["../../src/services/RevocationService.ts"],"mappings":";;;;;;;cAqFa,iBAAA;EAAA,iBAEqD,SAAA;EAAA,iBACf,cAAA;cADe,SAAA,EAAW,mCAAA,EAC1B,cAAA,EAAgB,oBAAA;EAGpD,SAAA,CAAU,YAAA,EAAc,YAAA,EAAc,UAAA,QAAkB,OAAA;EAAA,QAgBvD,iBAAA;EAnBmD;;;EA8DpD,gBAAA,CACX,YAAA,EAAc,YAAA,EACd,KAAA,EAAO,qBAAA,GACN,OAAA,CAAQ,gBAAA;EADF;;;;EAyBI,aAAA,CACX,YAAA,EAAc,YAAA,EACd,MAAA,UACA,YAAA,YACC,OAAA;EA0Ba;;;EADH,SAAA,CACX,YAAA,EAAc,YAAA,EACd,OAAA;IACE,MAAA;IACA,KAAA;IACA,MAAA;EAAA,IAED,OAAA;EA+FO;;;EAlEG,oBAAA,CACX,YAAA,EAAc,YAAA,EACd,MAAA,UACA,YAAA,WACC,OAAA;EAiGQ;;;EAhFE,SAAA,CACX,YAAA,EAAc,YAAA,EACd,MAAA,UACA,KAAA,WACC,OAAA;EAsFA;;;;EAxEI,yBAAA,CACL,MAAA,EAAQ,gBAAA,GACP,oBAAA;;;;EAwBI,iBAAA,CACL,MAAA,EAAQ,gBAAA,EACR,KAAA,UACA,OAAA,YACC,eAAA;EA/N8C;;;;EA+O1C,mBAAA,CACL,UAAA,OACA,WAAA,EAAa,eAAA;EA9OsD;;;EAyPxD,aAAA,CACX,YAAA,EAAc,YAAA,EACd,MAAA,WACC,OAAA,CAAQ,gBAAA;EAhMT;;;EAuMW,sBAAA,CACX,YAAA,EAAc,YAAA,EACd,SAAA,WACC,OAAA,CAAQ,gBAAA;AAAA"}
@@ -0,0 +1,253 @@
1
+ import { __decorateMetadata, init_decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
+ import { __decorateParam, init_decorateParam } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs";
3
+ import { __decorate, init_decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
4
+ import { ONE_EDTECH_REVOCATION_LIST, VC_V2_CONTEXT } from "../constants.mjs";
5
+ import { OpenBadgesRevocationCacheRepository } from "../repository/OpenBadgesRevocationCacheRepository.mjs";
6
+ import { StatusListRecord } from "../repository/StatusListRecord.mjs";
7
+ import { StatusListRepository } from "../repository/StatusListRepository.mjs";
8
+ import { DEFAULT_STATUS_LIST_CAPACITY, STATUS_LIST_2021_CONTEXT } from "../models/StatusListCredential.mjs";
9
+ import { inject, injectable } from "@credo-ts/core";
10
+ import { randomUUID } from "node:crypto";
11
+ import * as pako from "pako";
12
+
13
+ //#region src/services/RevocationService.ts
14
+ init_decorateMetadata();
15
+ init_decorateParam();
16
+ init_decorate();
17
+ var _ref, _ref2;
18
+ /**
19
+ * Convert base64url to bytes
20
+ */
21
+ function b64ToBytes(b64) {
22
+ const base64 = (b64 + (b64.length % 4 === 0 ? "" : "=".repeat(4 - b64.length % 4))).replace(/-/g, "+").replace(/_/g, "/");
23
+ return Buffer.from(base64, "base64");
24
+ }
25
+ /**
26
+ * Convert bytes to base64url
27
+ */
28
+ function bytesToB64url(bytes) {
29
+ return Buffer.from(bytes).toString("base64url");
30
+ }
31
+ /**
32
+ * Check if a bit is set at the given index
33
+ */
34
+ function isBitSet(bytes, index) {
35
+ const byteIndex = Math.floor(index / 8);
36
+ const bitIndex = index % 8;
37
+ if (byteIndex >= bytes.length) return false;
38
+ const mask = 1 << 7 - bitIndex;
39
+ return (bytes[byteIndex] & mask) !== 0;
40
+ }
41
+ /**
42
+ * Set or clear a bit at the given index
43
+ */
44
+ function setBit(bytes, index, value) {
45
+ const byteIndex = Math.floor(index / 8);
46
+ const bitIndex = index % 8;
47
+ if (byteIndex >= bytes.length) return;
48
+ const mask = 1 << 7 - bitIndex;
49
+ if (value) bytes[byteIndex] |= mask;
50
+ else bytes[byteIndex] &= ~mask;
51
+ }
52
+ /**
53
+ * Create an empty bitstring of the given capacity
54
+ */
55
+ function createBitstring(capacity) {
56
+ return new Uint8Array(Math.ceil(capacity / 8));
57
+ }
58
+ /**
59
+ * GZIP compress and base64url encode a bitstring
60
+ * Uses pako for cross-platform compatibility (Node.js + React Native)
61
+ */
62
+ function encodeStatusList(bitstring) {
63
+ return bytesToB64url(pako.gzip(bitstring));
64
+ }
65
+ let RevocationService = class RevocationService {
66
+ constructor(cacheRepo, statusListRepo) {
67
+ this.cacheRepo = cacheRepo;
68
+ this.statusListRepo = statusListRepo;
69
+ }
70
+ async isRevoked(agentContext, credential) {
71
+ const cs = credential?.credentialStatus;
72
+ const entries = Array.isArray(cs) ? cs : cs ? [cs] : [];
73
+ for (const entry of entries) {
74
+ const type = entry?.type;
75
+ if (type !== ONE_EDTECH_REVOCATION_LIST && type !== "StatusList2021Entry") continue;
76
+ const index = typeof entry?.statusListIndex === "number" ? entry.statusListIndex : parseInt(entry?.statusListIndex ?? "", 10);
77
+ const url = entry?.statusListCredential || entry?.statusListUrl || entry?.id;
78
+ if (!url || Number.isNaN(index)) continue;
79
+ const { bytes } = await this.getStatusListBits(agentContext, url);
80
+ if (isBitSet(bytes, index)) return true;
81
+ }
82
+ return false;
83
+ }
84
+ async getStatusListBits(agentContext, url) {
85
+ try {
86
+ const cached = await this.cacheRepo.findByStatusListUrl(agentContext, url);
87
+ if (cached?.bitstringBase64) return { bytes: b64ToBytes(cached.bitstringBase64) };
88
+ } catch {}
89
+ const res = await fetch(url);
90
+ if (!res.ok) throw new Error(`Failed to fetch status list: ${res.status}`);
91
+ const json = await res.json();
92
+ const encodedList = json?.encodedList ?? json?.credentialSubject?.encodedList;
93
+ if (!encodedList) throw new Error("encodedList not found in status list");
94
+ try {
95
+ const rec = await this.cacheRepo.findByStatusListUrl(agentContext, url);
96
+ if (rec) {
97
+ rec.bitstringBase64 = encodedList;
98
+ rec.lastUpdatedAt = /* @__PURE__ */ new Date();
99
+ await this.cacheRepo.update(agentContext, rec);
100
+ } else await this.cacheRepo.save(agentContext, {
101
+ statusListUrl: url,
102
+ bitstringBase64: encodedList,
103
+ lastUpdatedAt: /* @__PURE__ */ new Date()
104
+ });
105
+ } catch {}
106
+ return { bytes: b64ToBytes(encodedList) };
107
+ }
108
+ /**
109
+ * Create a new status list for credential revocation or suspension
110
+ */
111
+ async createStatusList(agentContext, input) {
112
+ const capacity = input.capacity ?? DEFAULT_STATUS_LIST_CAPACITY;
113
+ const bitstring = createBitstring(capacity);
114
+ const record = new StatusListRecord({
115
+ listId: input.listId,
116
+ issuerDid: input.issuerDid,
117
+ purpose: input.purpose,
118
+ bitstringBase64: bytesToB64url(bitstring),
119
+ capacity,
120
+ nextIndex: 0,
121
+ credentialIndexMap: {},
122
+ baseUrl: input.baseUrl
123
+ });
124
+ await this.statusListRepo.save(agentContext, record);
125
+ agentContext.config.logger.debug("[OB][RevocationService] Created status list", {
126
+ listId: input.listId,
127
+ capacity
128
+ });
129
+ return record;
130
+ }
131
+ /**
132
+ * Allocate the next available index in a status list for a credential
133
+ * Returns the allocated index
134
+ */
135
+ async allocateIndex(agentContext, listId, credentialId) {
136
+ const record = await this.statusListRepo.findByListId(agentContext, listId);
137
+ if (!record) throw new Error(`Status list not found: ${listId}`);
138
+ if (record.nextIndex >= record.capacity) throw new Error(`Status list ${listId} is full (capacity: ${record.capacity})`);
139
+ const index = record.nextIndex;
140
+ record.nextIndex++;
141
+ if (credentialId) record.credentialIndexMap[credentialId] = index;
142
+ await this.statusListRepo.update(agentContext, record);
143
+ agentContext.config.logger.debug("[OB][RevocationService] Allocated index", {
144
+ index,
145
+ listId
146
+ });
147
+ return index;
148
+ }
149
+ /**
150
+ * Set the status (revoked/suspended or active) for a specific index
151
+ */
152
+ async setStatus(agentContext, options) {
153
+ const record = await this.statusListRepo.findByListId(agentContext, options.listId);
154
+ if (!record) throw new Error(`Status list not found: ${options.listId}`);
155
+ if (options.index < 0 || options.index >= record.capacity) throw new Error(`Index ${options.index} out of range (0-${record.capacity - 1})`);
156
+ const bitstring = b64ToBytes(record.bitstringBase64);
157
+ setBit(bitstring, options.index, options.status);
158
+ record.bitstringBase64 = bytesToB64url(bitstring);
159
+ await this.statusListRepo.update(agentContext, record);
160
+ agentContext.config.logger.debug("[OB][RevocationService] Set status", {
161
+ index: options.index,
162
+ status: options.status ? "revoked" : "active"
163
+ });
164
+ }
165
+ /**
166
+ * Revoke a credential by its credential ID (if tracked)
167
+ */
168
+ async revokeByCredentialId(agentContext, listId, credentialId) {
169
+ const record = await this.statusListRepo.findByListId(agentContext, listId);
170
+ if (!record) throw new Error(`Status list not found: ${listId}`);
171
+ const index = record.credentialIndexMap[credentialId];
172
+ if (index === void 0) throw new Error(`Credential ${credentialId} not found in status list ${listId}`);
173
+ await this.setStatus(agentContext, {
174
+ listId,
175
+ index,
176
+ status: true
177
+ });
178
+ }
179
+ /**
180
+ * Get the status of a specific index
181
+ */
182
+ async getStatus(agentContext, listId, index) {
183
+ const record = await this.statusListRepo.findByListId(agentContext, listId);
184
+ if (!record) throw new Error(`Status list not found: ${listId}`);
185
+ return isBitSet(b64ToBytes(record.bitstringBase64), index);
186
+ }
187
+ /**
188
+ * Build an unsigned StatusList2021Credential for a status list
189
+ * This can then be signed using the ProofService
190
+ */
191
+ buildStatusListCredential(record) {
192
+ const encodedList = encodeStatusList(b64ToBytes(record.bitstringBase64));
193
+ const credentialId = `${record.baseUrl}/status-list/${record.listId}`;
194
+ return {
195
+ "@context": [VC_V2_CONTEXT, STATUS_LIST_2021_CONTEXT],
196
+ type: ["VerifiableCredential", "StatusList2021Credential"],
197
+ id: credentialId,
198
+ issuer: record.issuerDid,
199
+ validFrom: (/* @__PURE__ */ new Date()).toISOString(),
200
+ credentialSubject: {
201
+ id: `${credentialId}#list`,
202
+ type: "StatusList2021",
203
+ statusPurpose: record.purpose,
204
+ encodedList
205
+ }
206
+ };
207
+ }
208
+ /**
209
+ * Create a StatusListEntry to add to a credential
210
+ */
211
+ createStatusEntry(record, index, entryId) {
212
+ const statusListCredentialUrl = `${record.baseUrl}/status-list/${record.listId}`;
213
+ return {
214
+ id: entryId ?? `${statusListCredentialUrl}#${index}`,
215
+ type: "StatusList2021Entry",
216
+ statusPurpose: record.purpose,
217
+ statusListIndex: String(index),
218
+ statusListCredential: statusListCredentialUrl
219
+ };
220
+ }
221
+ /**
222
+ * Add a credentialStatus field to a credential
223
+ * This should be called before signing the credential
224
+ */
225
+ addCredentialStatus(credential, statusEntry) {
226
+ return {
227
+ ...credential,
228
+ credentialStatus: statusEntry
229
+ };
230
+ }
231
+ /**
232
+ * Get a status list record by its ID
233
+ */
234
+ async getStatusList(agentContext, listId) {
235
+ return this.statusListRepo.findByListId(agentContext, listId);
236
+ }
237
+ /**
238
+ * Get all status lists for an issuer
239
+ */
240
+ async getStatusListsByIssuer(agentContext, issuerDid) {
241
+ return this.statusListRepo.findByIssuer(agentContext, issuerDid);
242
+ }
243
+ };
244
+ RevocationService = __decorate([
245
+ injectable(),
246
+ __decorateParam(0, inject(OpenBadgesRevocationCacheRepository)),
247
+ __decorateParam(1, inject(StatusListRepository)),
248
+ __decorateMetadata("design:paramtypes", [OpenBadgesRevocationCacheRepository, StatusListRepository])
249
+ ], RevocationService);
250
+
251
+ //#endregion
252
+ export { RevocationService };
253
+ //# sourceMappingURL=RevocationService.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RevocationService.mjs","names":[],"sources":["../../src/services/RevocationService.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport { injectable, inject } from '@credo-ts/core'\nimport { OpenBadgesRevocationCacheRepository } from '../repository/OpenBadgesRevocationCacheRepository'\nimport { StatusListRepository } from '../repository/StatusListRepository'\nimport { StatusListRecord } from '../repository/StatusListRecord'\nimport { ONE_EDTECH_REVOCATION_LIST, VC_V2_CONTEXT } from '../constants'\nimport type {\n StatusPurpose,\n StatusListEntry,\n CreateStatusListInput,\n StatusListCredential,\n} from '../models/StatusListCredential'\nimport { DEFAULT_STATUS_LIST_CAPACITY, STATUS_LIST_2021_CONTEXT } from '../models/StatusListCredential'\nimport { randomUUID as uuidv4 } from 'node:crypto'\nimport * as pako from 'pako'\n\n/**\n * Convert base64url to bytes\n */\nfunction b64ToBytes(b64: string): Uint8Array {\n const pad = b64.length % 4 === 0 ? '' : '='.repeat(4 - (b64.length % 4))\n const base64 = (b64 + pad).replace(/-/g, '+').replace(/_/g, '/')\n return Buffer.from(base64, 'base64')\n}\n\n/**\n * Convert bytes to base64url\n */\nfunction bytesToB64url(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('base64url')\n}\n\n/**\n * Check if a bit is set at the given index\n */\nfunction isBitSet(bytes: Uint8Array, index: number): boolean {\n const byteIndex = Math.floor(index / 8)\n const bitIndex = index % 8\n if (byteIndex >= bytes.length) return false\n const mask = 1 << (7 - bitIndex)\n return (bytes[byteIndex] & mask) !== 0\n}\n\n/**\n * Set or clear a bit at the given index\n */\nfunction setBit(bytes: Uint8Array, index: number, value: boolean): void {\n const byteIndex = Math.floor(index / 8)\n const bitIndex = index % 8\n if (byteIndex >= bytes.length) return\n const mask = 1 << (7 - bitIndex)\n if (value) {\n bytes[byteIndex] |= mask\n } else {\n bytes[byteIndex] &= ~mask\n }\n}\n\n/**\n * Create an empty bitstring of the given capacity\n */\nfunction createBitstring(capacity: number): Uint8Array {\n return new Uint8Array(Math.ceil(capacity / 8))\n}\n\n/**\n * GZIP compress and base64url encode a bitstring\n * Uses pako for cross-platform compatibility (Node.js + React Native)\n */\nfunction encodeStatusList(bitstring: Uint8Array): string {\n const compressed = pako.gzip(bitstring)\n return bytesToB64url(compressed)\n}\n\n/**\n * Base64url decode and GZIP decompress a status list\n * Uses pako for cross-platform compatibility (Node.js + React Native)\n */\nfunction decodeStatusList(encoded: string): Uint8Array {\n const compressed = b64ToBytes(encoded)\n const decompressed = pako.ungzip(compressed)\n return new Uint8Array(decompressed)\n}\n\n@injectable()\nexport class RevocationService {\n public constructor(\n @inject(OpenBadgesRevocationCacheRepository) private readonly cacheRepo: OpenBadgesRevocationCacheRepository,\n @inject(StatusListRepository) private readonly statusListRepo: StatusListRepository\n ) {}\n\n public async isRevoked(agentContext: AgentContext, credential: any): Promise<boolean> {\n const cs = credential?.credentialStatus\n const entries = Array.isArray(cs) ? cs : cs ? [cs] : []\n for (const entry of entries) {\n const type = entry?.type\n if (type !== ONE_EDTECH_REVOCATION_LIST && type !== 'StatusList2021Entry') continue\n const index: number | undefined = typeof entry?.statusListIndex === 'number' ? entry.statusListIndex : parseInt(entry?.statusListIndex ?? '', 10)\n const url: string | undefined = entry?.statusListCredential || entry?.statusListUrl || entry?.id\n if (!url || Number.isNaN(index)) continue\n\n const { bytes } = await this.getStatusListBits(agentContext, url)\n if (isBitSet(bytes, index!)) return true\n }\n return false\n }\n\n private async getStatusListBits(agentContext: AgentContext, url: string): Promise<{ bytes: Uint8Array }> {\n try {\n const cached = await this.cacheRepo.findByStatusListUrl(agentContext, url)\n if (cached?.bitstringBase64) {\n return { bytes: b64ToBytes(cached.bitstringBase64) }\n }\n } catch {}\n\n const res = await fetch(url)\n if (!res.ok) throw new Error(`Failed to fetch status list: ${res.status}`)\n const json = (await res.json()) as {\n encodedList?: string\n credentialSubject?: { encodedList?: string }\n }\n // Try multiple shapes\n const encodedList: string | undefined = json?.encodedList ?? json?.credentialSubject?.encodedList\n if (!encodedList) throw new Error('encodedList not found in status list')\n\n try {\n const rec = await this.cacheRepo.findByStatusListUrl(agentContext, url)\n if (rec) {\n rec.bitstringBase64 = encodedList\n rec.lastUpdatedAt = new Date()\n await this.cacheRepo.update(agentContext, rec)\n } else {\n await this.cacheRepo.save(agentContext, {\n statusListUrl: url,\n bitstringBase64: encodedList,\n lastUpdatedAt: new Date(),\n } as any)\n }\n } catch {}\n\n return { bytes: b64ToBytes(encodedList) }\n }\n\n // ========================================\n // Issuer-side Status List Management\n // ========================================\n\n /**\n * Create a new status list for credential revocation or suspension\n */\n public async createStatusList(\n agentContext: AgentContext,\n input: CreateStatusListInput\n ): Promise<StatusListRecord> {\n const capacity = input.capacity ?? DEFAULT_STATUS_LIST_CAPACITY\n const bitstring = createBitstring(capacity)\n\n const record = new StatusListRecord({\n listId: input.listId,\n issuerDid: input.issuerDid,\n purpose: input.purpose,\n bitstringBase64: bytesToB64url(bitstring),\n capacity,\n nextIndex: 0,\n credentialIndexMap: {},\n baseUrl: input.baseUrl,\n })\n\n await this.statusListRepo.save(agentContext, record)\n agentContext.config.logger.debug('[OB][RevocationService] Created status list', { listId: input.listId, capacity })\n return record\n }\n\n /**\n * Allocate the next available index in a status list for a credential\n * Returns the allocated index\n */\n public async allocateIndex(\n agentContext: AgentContext,\n listId: string,\n credentialId?: string\n ): Promise<number> {\n const record = await this.statusListRepo.findByListId(agentContext, listId)\n if (!record) {\n throw new Error(`Status list not found: ${listId}`)\n }\n\n if (record.nextIndex >= record.capacity) {\n throw new Error(`Status list ${listId} is full (capacity: ${record.capacity})`)\n }\n\n const index = record.nextIndex\n record.nextIndex++\n\n if (credentialId) {\n record.credentialIndexMap[credentialId] = index\n }\n\n await this.statusListRepo.update(agentContext, record)\n agentContext.config.logger.debug('[OB][RevocationService] Allocated index', { index, listId })\n return index\n }\n\n /**\n * Set the status (revoked/suspended or active) for a specific index\n */\n public async setStatus(\n agentContext: AgentContext,\n options: {\n listId: string\n index: number\n status: boolean // true = revoked/suspended, false = active\n }\n ): Promise<void> {\n const record = await this.statusListRepo.findByListId(agentContext, options.listId)\n if (!record) {\n throw new Error(`Status list not found: ${options.listId}`)\n }\n\n if (options.index < 0 || options.index >= record.capacity) {\n throw new Error(`Index ${options.index} out of range (0-${record.capacity - 1})`)\n }\n\n // Decode the bitstring\n const bitstring = b64ToBytes(record.bitstringBase64)\n\n // Set the bit\n setBit(bitstring, options.index, options.status)\n\n // Update the record\n record.bitstringBase64 = bytesToB64url(bitstring)\n await this.statusListRepo.update(agentContext, record)\n\n agentContext.config.logger.debug('[OB][RevocationService] Set status', {\n index: options.index,\n status: options.status ? 'revoked' : 'active',\n })\n }\n\n /**\n * Revoke a credential by its credential ID (if tracked)\n */\n public async revokeByCredentialId(\n agentContext: AgentContext,\n listId: string,\n credentialId: string\n ): Promise<void> {\n const record = await this.statusListRepo.findByListId(agentContext, listId)\n if (!record) {\n throw new Error(`Status list not found: ${listId}`)\n }\n\n const index = record.credentialIndexMap[credentialId]\n if (index === undefined) {\n throw new Error(`Credential ${credentialId} not found in status list ${listId}`)\n }\n\n await this.setStatus(agentContext, { listId, index, status: true })\n }\n\n /**\n * Get the status of a specific index\n */\n public async getStatus(\n agentContext: AgentContext,\n listId: string,\n index: number\n ): Promise<boolean> {\n const record = await this.statusListRepo.findByListId(agentContext, listId)\n if (!record) {\n throw new Error(`Status list not found: ${listId}`)\n }\n\n const bitstring = b64ToBytes(record.bitstringBase64)\n return isBitSet(bitstring, index)\n }\n\n /**\n * Build an unsigned StatusList2021Credential for a status list\n * This can then be signed using the ProofService\n */\n public buildStatusListCredential(\n record: StatusListRecord\n ): StatusListCredential {\n const bitstring = b64ToBytes(record.bitstringBase64)\n const encodedList = encodeStatusList(bitstring)\n\n const credentialId = `${record.baseUrl}/status-list/${record.listId}`\n\n return {\n '@context': [VC_V2_CONTEXT, STATUS_LIST_2021_CONTEXT],\n type: ['VerifiableCredential', 'StatusList2021Credential'],\n id: credentialId,\n issuer: record.issuerDid,\n validFrom: new Date().toISOString(),\n credentialSubject: {\n id: `${credentialId}#list`,\n type: 'StatusList2021',\n statusPurpose: record.purpose,\n encodedList,\n },\n }\n }\n\n /**\n * Create a StatusListEntry to add to a credential\n */\n public createStatusEntry(\n record: StatusListRecord,\n index: number,\n entryId?: string\n ): StatusListEntry {\n const statusListCredentialUrl = `${record.baseUrl}/status-list/${record.listId}`\n\n return {\n id: entryId ?? `${statusListCredentialUrl}#${index}`,\n type: 'StatusList2021Entry',\n statusPurpose: record.purpose,\n statusListIndex: String(index),\n statusListCredential: statusListCredentialUrl,\n }\n }\n\n /**\n * Add a credentialStatus field to a credential\n * This should be called before signing the credential\n */\n public addCredentialStatus(\n credential: any,\n statusEntry: StatusListEntry\n ): any {\n return {\n ...credential,\n credentialStatus: statusEntry,\n }\n }\n\n /**\n * Get a status list record by its ID\n */\n public async getStatusList(\n agentContext: AgentContext,\n listId: string\n ): Promise<StatusListRecord | null> {\n return this.statusListRepo.findByListId(agentContext, listId)\n }\n\n /**\n * Get all status lists for an issuer\n */\n public async getStatusListsByIssuer(\n agentContext: AgentContext,\n issuerDid: string\n ): Promise<StatusListRecord[]> {\n return this.statusListRepo.findByIssuer(agentContext, issuerDid)\n }\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,SAAS,WAAW,KAAyB;CAE3C,MAAM,UAAU,OADJ,IAAI,SAAS,MAAM,IAAI,KAAK,IAAI,OAAO,IAAK,IAAI,SAAS,EAAG,GAC7C,QAAQ,MAAM,IAAI,CAAC,QAAQ,MAAM,IAAI;AAChE,QAAO,OAAO,KAAK,QAAQ,SAAS;;;;;AAMtC,SAAS,cAAc,OAA2B;AAChD,QAAO,OAAO,KAAK,MAAM,CAAC,SAAS,YAAY;;;;;AAMjD,SAAS,SAAS,OAAmB,OAAwB;CAC3D,MAAM,YAAY,KAAK,MAAM,QAAQ,EAAE;CACvC,MAAM,WAAW,QAAQ;AACzB,KAAI,aAAa,MAAM,OAAQ,QAAO;CACtC,MAAM,OAAO,KAAM,IAAI;AACvB,SAAQ,MAAM,aAAa,UAAU;;;;;AAMvC,SAAS,OAAO,OAAmB,OAAe,OAAsB;CACtE,MAAM,YAAY,KAAK,MAAM,QAAQ,EAAE;CACvC,MAAM,WAAW,QAAQ;AACzB,KAAI,aAAa,MAAM,OAAQ;CAC/B,MAAM,OAAO,KAAM,IAAI;AACvB,KAAI,MACF,OAAM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,wBAAwB,2BAA2B;GAC1D,IAAI;GACJ,QAAQ,OAAO;GACf,4BAAW,IAAI,MAAM,EAAC,aAAa;GACnC,mBAAmB;IACjB,IAAI,GAAG,aAAa;IACpB,MAAM;IACN,eAAe,OAAO;IACtB;IACD;GACF;;;;;CAMH,AAAO,kBACL,QACA,OACA,SACiB;EACjB,MAAM,0BAA0B,GAAG,OAAO,QAAQ,eAAe,OAAO;AAExE,SAAO;GACL,IAAI,WAAW,GAAG,wBAAwB,GAAG;GAC7C,MAAM;GACN,eAAe,OAAO;GACtB,iBAAiB,OAAO,MAAM;GAC9B,sBAAsB;GACvB;;;;;;CAOH,AAAO,oBACL,YACA,aACK;AACL,SAAO;GACL,GAAG;GACH,kBAAkB;GACnB;;;;;CAMH,MAAa,cACX,cACA,QACkC;AAClC,SAAO,KAAK,eAAe,aAAa,cAAc,OAAO;;;;;CAM/D,MAAa,uBACX,cACA,WAC6B;AAC7B,SAAO,KAAK,eAAe,aAAa,cAAc,UAAU;;;;CA9QnE,YAAY;oBAGR,OAAO,oCAAoC;oBAC3C,OAAO,qBAAqB"}
@@ -0,0 +1,24 @@
1
+ import { ContextService } from "./ContextService.mjs";
2
+ import { ProofService } from "./ProofService.mjs";
3
+ import { RevocationService } from "./RevocationService.mjs";
4
+ import { ValidationIssue } from "../utils/validate.mjs";
5
+ import "../index.mjs";
6
+ import { AgentContext } from "@credo-ts/core";
7
+
8
+ //#region src/services/VerifyService.d.ts
9
+ declare class VerifyService {
10
+ private readonly contextService;
11
+ private readonly revocations;
12
+ private readonly proofs;
13
+ constructor(contextService: ContextService, revocations: RevocationService, proofs: ProofService);
14
+ verify(agentContext: AgentContext, credentialOrJwt: any): Promise<{
15
+ isValidStructure: boolean;
16
+ issues: ValidationIssue[];
17
+ status: string;
18
+ proofVerified: boolean;
19
+ }>;
20
+ private evaluateStatus;
21
+ }
22
+ //#endregion
23
+ export { VerifyService };
24
+ //# sourceMappingURL=VerifyService.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VerifyService.d.mts","names":[],"sources":["../../src/services/VerifyService.ts"],"mappings":";;;;;;;;cASa,aAAA;EAAA,iBAEgC,cAAA;EAAA,iBACG,WAAA;EAAA,iBACL,MAAA;cAFE,cAAA,EAAgB,cAAA,EACb,WAAA,EAAa,iBAAA,EAClB,MAAA,EAAQ,YAAA;EAIpC,MAAA,CAAO,YAAA,EAAc,YAAA,EAAc,eAAA,QAAoB,OAAA;;YAAtB,eAAA;;;;UAShC,cAAA;AAAA"}
@@ -0,0 +1,59 @@
1
+ import { __decorateMetadata, init_decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
+ import { __decorateParam, init_decorateParam } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs";
3
+ import { __decorate, init_decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
4
+ import "../constants.mjs";
5
+ import { validateObEnvelope } from "../utils/validate.mjs";
6
+ import { ContextService } from "./ContextService.mjs";
7
+ import { ProofService } from "./ProofService.mjs";
8
+ import { RevocationService } from "./RevocationService.mjs";
9
+ import { inject, injectable } from "@credo-ts/core";
10
+
11
+ //#region src/services/VerifyService.ts
12
+ init_decorateMetadata();
13
+ init_decorateParam();
14
+ init_decorate();
15
+ var _ref, _ref2, _ref3;
16
+ let VerifyService = class VerifyService {
17
+ constructor(contextService, revocations, proofs) {
18
+ this.contextService = contextService;
19
+ this.revocations = revocations;
20
+ this.proofs = proofs;
21
+ }
22
+ async verify(agentContext, credentialOrJwt) {
23
+ const result = await this.proofs.verify(agentContext, credentialOrJwt);
24
+ const credential = result.credential ?? (typeof credentialOrJwt === "string" ? void 0 : credentialOrJwt);
25
+ const issues = credential ? validateObEnvelope(credential) : [{
26
+ code: "missing_vc_claim",
27
+ message: "VC missing"
28
+ }];
29
+ const status = credential ? await this.evaluateStatus(agentContext, credential) : "unknown";
30
+ return {
31
+ isValidStructure: issues.length === 0,
32
+ issues,
33
+ status,
34
+ proofVerified: !!result.verified
35
+ };
36
+ }
37
+ async evaluateStatus(agentContext, credential) {
38
+ const now = Date.now();
39
+ const validUntil = credential?.validUntil ? Date.parse(credential.validUntil) : void 0;
40
+ const expired = validUntil != null && now > validUntil;
41
+ const revoked = await this.revocations.isRevoked(agentContext, credential);
42
+ return expired ? "expired" : revoked ? "revoked" : "valid";
43
+ }
44
+ };
45
+ VerifyService = __decorate([
46
+ injectable(),
47
+ __decorateParam(0, inject(ContextService)),
48
+ __decorateParam(1, inject(RevocationService)),
49
+ __decorateParam(2, inject(ProofService)),
50
+ __decorateMetadata("design:paramtypes", [
51
+ ContextService,
52
+ RevocationService,
53
+ ProofService
54
+ ])
55
+ ], VerifyService);
56
+
57
+ //#endregion
58
+ export { VerifyService };
59
+ //# sourceMappingURL=VerifyService.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VerifyService.mjs","names":[],"sources":["../../src/services/VerifyService.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport { injectable, inject } from '@credo-ts/core'\nimport { ONE_EDTECH_REVOCATION_LIST } from '../constants'\nimport { validateObEnvelope } from '../utils/validate'\nimport { ContextService } from './ContextService'\nimport { ProofService } from './ProofService'\nimport { RevocationService } from './RevocationService'\n\n@injectable()\nexport class VerifyService {\n public constructor(\n @inject(ContextService) private readonly contextService: ContextService,\n @inject(RevocationService) private readonly revocations: RevocationService,\n @inject(ProofService) private readonly proofs: ProofService\n ) {}\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public async verify(agentContext: AgentContext, credentialOrJwt: any) {\n const result = await this.proofs.verify(agentContext, credentialOrJwt)\n const credential = result.credential ?? (typeof credentialOrJwt === 'string' ? undefined : credentialOrJwt)\n const issues = credential ? validateObEnvelope(credential) : [{ code: 'missing_vc_claim', message: 'VC missing' }]\n const status = credential ? await this.evaluateStatus(agentContext, credential) : 'unknown'\n return { isValidStructure: issues.length === 0, issues, status, proofVerified: !!result.verified }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private async evaluateStatus(agentContext: AgentContext, credential: any) {\n const now = Date.now()\n const validUntil = credential?.validUntil ? Date.parse(credential.validUntil) : undefined\n const expired = validUntil != null && now > validUntil\n const revoked = await this.revocations.isRevoked(agentContext, credential)\n return expired ? 'expired' : revoked ? 'revoked' : 'valid'\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AASO,0BAAM,cAAc;CACzB,AAAO,YACL,AAAyC,gBACzC,AAA4C,aAC5C,AAAuC,QACvC;EAHyC;EACG;EACL;;CAIzC,MAAa,OAAO,cAA4B,iBAAsB;EACpE,MAAM,SAAS,MAAM,KAAK,OAAO,OAAO,cAAc,gBAAgB;EACtE,MAAM,aAAa,OAAO,eAAe,OAAO,oBAAoB,WAAW,SAAY;EAC3F,MAAM,SAAS,aAAa,mBAAmB,WAAW,GAAG,CAAC;GAAE,MAAM;GAAoB,SAAS;GAAc,CAAC;EAClH,MAAM,SAAS,aAAa,MAAM,KAAK,eAAe,cAAc,WAAW,GAAG;AAClF,SAAO;GAAE,kBAAkB,OAAO,WAAW;GAAG;GAAQ;GAAQ,eAAe,CAAC,CAAC,OAAO;GAAU;;CAIpG,MAAc,eAAe,cAA4B,YAAiB;EACxE,MAAM,MAAM,KAAK,KAAK;EACtB,MAAM,aAAa,YAAY,aAAa,KAAK,MAAM,WAAW,WAAW,GAAG;EAChF,MAAM,UAAU,cAAc,QAAQ,MAAM;EAC5C,MAAM,UAAU,MAAM,KAAK,YAAY,UAAU,cAAc,WAAW;AAC1E,SAAO,UAAU,YAAY,UAAU,YAAY;;;;CAvBtD,YAAY;oBAGR,OAAO,eAAe;oBACtB,OAAO,kBAAkB;oBACzB,OAAO,aAAa"}
@@ -0,0 +1,14 @@
1
+ import { AgentContext } from "@credo-ts/core";
2
+
3
+ //#region src/services/crypto/CryptoDriver.d.ts
4
+ declare abstract class CryptoDriver {
5
+ abstract sign(agentContext: AgentContext, document: any, keyHint?: any): Promise<any>;
6
+ abstract verify(agentContext: AgentContext, input: any): Promise<{
7
+ verified: boolean;
8
+ credential?: any;
9
+ error?: string;
10
+ }>;
11
+ }
12
+ //#endregion
13
+ export { CryptoDriver };
14
+ //# sourceMappingURL=CryptoDriver.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CryptoDriver.d.mts","names":[],"sources":["../../../src/services/crypto/CryptoDriver.ts"],"mappings":";;;uBAEsB,YAAA;EAAA,SAEX,IAAA,CAAK,YAAA,EAAc,YAAA,EAAc,QAAA,OAAe,OAAA,SAAgB,OAAA;EAAA,SAEhE,MAAA,CAAO,YAAA,EAAc,YAAA,EAAc,KAAA,QAAa,OAAA;IAAU,QAAA;IAAmB,UAAA;IAAkB,KAAA;EAAA;AAAA"}
@@ -0,0 +1,6 @@
1
+ //#region src/services/crypto/CryptoDriver.ts
2
+ var CryptoDriver = class {};
3
+
4
+ //#endregion
5
+ export { CryptoDriver };
6
+ //# sourceMappingURL=CryptoDriver.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CryptoDriver.mjs","names":[],"sources":["../../../src/services/crypto/CryptoDriver.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\n\nexport abstract class CryptoDriver {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract sign(agentContext: AgentContext, document: any, keyHint?: any): Promise<any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract verify(agentContext: AgentContext, input: any): Promise<{ verified: boolean; credential?: any; error?: string }>\n}\n\n"],"mappings":";AAEA,IAAsB,eAAtB,MAAmC"}
@@ -0,0 +1,22 @@
1
+ import { CryptoDriver } from "./CryptoDriver.mjs";
2
+ import { DataIntegrityService } from "../DataIntegrityService.mjs";
3
+ import { AgentContext } from "@credo-ts/core";
4
+
5
+ //#region src/services/crypto/JsonLdCryptoDriver.d.ts
6
+ declare class JsonLdCryptoDriver extends CryptoDriver {
7
+ private readonly di;
8
+ constructor(di: DataIntegrityService);
9
+ sign(agentContext: AgentContext, document: any, keyHint?: any): Promise<any>;
10
+ verify(_agentContext: AgentContext, input: any): Promise<{
11
+ verified: boolean;
12
+ credential: any;
13
+ error?: undefined;
14
+ } | {
15
+ verified: boolean;
16
+ error: any;
17
+ credential?: undefined;
18
+ }>;
19
+ }
20
+ //#endregion
21
+ export { JsonLdCryptoDriver };
22
+ //# sourceMappingURL=JsonLdCryptoDriver.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonLdCryptoDriver.d.mts","names":[],"sources":["../../../src/services/crypto/JsonLdCryptoDriver.ts"],"mappings":";;;;;cAMa,kBAAA,SAA2B,YAAA;EAAA,iBAC4B,EAAA;cAAA,EAAA,EAAI,oBAAA;EAKzD,IAAA,CAAK,YAAA,EAAc,YAAA,EAAc,QAAA,OAAe,OAAA,SAAgB,OAAA;EAKhE,MAAA,CAAO,aAAA,EAAe,YAAA,EAAc,KAAA,QAAU,OAAA"}
@@ -0,0 +1,43 @@
1
+ import { __decorateMetadata, init_decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
+ import { __decorateParam, init_decorateParam } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs";
3
+ import { __decorate, init_decorate } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
4
+ import { CryptoDriver } from "./CryptoDriver.mjs";
5
+ import { DataIntegrityService } from "../DataIntegrityService.mjs";
6
+ import { inject, injectable } from "@credo-ts/core";
7
+
8
+ //#region src/services/crypto/JsonLdCryptoDriver.ts
9
+ init_decorateMetadata();
10
+ init_decorateParam();
11
+ init_decorate();
12
+ var _ref;
13
+ let JsonLdCryptoDriver = class JsonLdCryptoDriver extends CryptoDriver {
14
+ constructor(di) {
15
+ super();
16
+ this.di = di;
17
+ }
18
+ async sign(agentContext, document, keyHint) {
19
+ return this.di.sign(agentContext, document, keyHint);
20
+ }
21
+ async verify(_agentContext, input) {
22
+ try {
23
+ return {
24
+ verified: !!(await this.di.verify(input)).verified,
25
+ credential: input
26
+ };
27
+ } catch (e) {
28
+ return {
29
+ verified: false,
30
+ error: e?.message || String(e)
31
+ };
32
+ }
33
+ }
34
+ };
35
+ JsonLdCryptoDriver = __decorate([
36
+ injectable(),
37
+ __decorateParam(0, inject(DataIntegrityService)),
38
+ __decorateMetadata("design:paramtypes", [DataIntegrityService])
39
+ ], JsonLdCryptoDriver);
40
+
41
+ //#endregion
42
+ export { JsonLdCryptoDriver };
43
+ //# sourceMappingURL=JsonLdCryptoDriver.mjs.map