@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.
- package/LICENSE +202 -0
- package/README.md +43 -2
- package/build/OpenBadgesModule.d.mts +15 -0
- package/build/OpenBadgesModule.d.mts.map +1 -0
- package/build/OpenBadgesModule.mjs +71 -0
- package/build/OpenBadgesModule.mjs.map +1 -0
- package/build/OpenBadgesModuleConfig.d.mts +101 -0
- package/build/OpenBadgesModuleConfig.d.mts.map +1 -0
- package/build/OpenBadgesModuleConfig.mjs +51 -0
- package/build/OpenBadgesModuleConfig.mjs.map +1 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +14 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +11 -0
- package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs +13 -0
- package/build/_virtual/_rolldown/runtime.mjs +41 -0
- package/build/api/OpenBadgesApi.d.mts +77 -0
- package/build/api/OpenBadgesApi.d.mts.map +1 -0
- package/build/api/OpenBadgesApi.mjs +124 -0
- package/build/api/OpenBadgesApi.mjs.map +1 -0
- package/build/constants.d.mts +17 -0
- package/build/constants.d.mts.map +1 -0
- package/build/constants.mjs +19 -0
- package/build/constants.mjs.map +1 -0
- package/build/cryptosuites/EcdsaSd2023.d.mts +129 -0
- package/build/cryptosuites/EcdsaSd2023.d.mts.map +1 -0
- package/build/cryptosuites/EcdsaSd2023.mjs +408 -0
- package/build/cryptosuites/EcdsaSd2023.mjs.map +1 -0
- package/build/cryptosuites/EddsaRdfc2022.d.mts +118 -0
- package/build/cryptosuites/EddsaRdfc2022.d.mts.map +1 -0
- package/build/cryptosuites/EddsaRdfc2022.mjs +301 -0
- package/build/cryptosuites/EddsaRdfc2022.mjs.map +1 -0
- package/build/cryptosuites/constants.d.mts +18 -0
- package/build/cryptosuites/constants.d.mts.map +1 -0
- package/build/cryptosuites/constants.mjs +19 -0
- package/build/cryptosuites/constants.mjs.map +1 -0
- package/build/cryptosuites/contextPreprocessor.mjs +76 -0
- package/build/cryptosuites/contextPreprocessor.mjs.map +1 -0
- package/build/cryptosuites/dataIntegrityV2Context.d.mts +147 -0
- package/build/cryptosuites/dataIntegrityV2Context.d.mts.map +1 -0
- package/build/cryptosuites/dataIntegrityV2Context.mjs +82 -0
- package/build/cryptosuites/dataIntegrityV2Context.mjs.map +1 -0
- package/build/cryptosuites/index.mjs +4 -0
- package/build/formats/OpenBadgesCredentialFormat.d.mts +41 -0
- package/build/formats/OpenBadgesCredentialFormat.d.mts.map +1 -0
- package/build/formats/OpenBadgesCredentialFormat.mjs +7 -0
- package/build/formats/OpenBadgesCredentialFormat.mjs.map +1 -0
- package/build/formats/OpenBadgesCredentialFormatService.d.mts +79 -0
- package/build/formats/OpenBadgesCredentialFormatService.d.mts.map +1 -0
- package/build/formats/OpenBadgesCredentialFormatService.mjs +208 -0
- package/build/formats/OpenBadgesCredentialFormatService.mjs.map +1 -0
- package/build/formats/OpenBadgesProofFormat.d.mts +41 -0
- package/build/formats/OpenBadgesProofFormat.d.mts.map +1 -0
- package/build/formats/OpenBadgesProofFormat.mjs +7 -0
- package/build/formats/OpenBadgesProofFormat.mjs.map +1 -0
- package/build/formats/OpenBadgesProofFormatService.d.mts +56 -0
- package/build/formats/OpenBadgesProofFormatService.d.mts.map +1 -0
- package/build/formats/OpenBadgesProofFormatService.mjs +138 -0
- package/build/formats/OpenBadgesProofFormatService.mjs.map +1 -0
- package/build/formats/index.d.mts +4 -0
- package/build/formats/index.mjs +4 -0
- package/build/http/OpenBadgesHttpModule.d.mts +14 -0
- package/build/http/OpenBadgesHttpModule.d.mts.map +1 -0
- package/build/http/OpenBadgesHttpModule.mjs +85 -0
- package/build/http/OpenBadgesHttpModule.mjs.map +1 -0
- package/build/http/OpenBadgesHttpModuleConfig.d.mts +60 -0
- package/build/http/OpenBadgesHttpModuleConfig.d.mts.map +1 -0
- package/build/http/OpenBadgesHttpModuleConfig.mjs +80 -0
- package/build/http/OpenBadgesHttpModuleConfig.mjs.map +1 -0
- package/build/http/endpoints/authorize.mjs +69 -0
- package/build/http/endpoints/authorize.mjs.map +1 -0
- package/build/http/endpoints/consent.mjs +34 -0
- package/build/http/endpoints/consent.mjs.map +1 -0
- package/build/http/endpoints/credentials.mjs +77 -0
- package/build/http/endpoints/credentials.mjs.map +1 -0
- package/build/http/endpoints/did.mjs +44 -0
- package/build/http/endpoints/did.mjs.map +1 -0
- package/build/http/endpoints/introspect.mjs +34 -0
- package/build/http/endpoints/introspect.mjs.map +1 -0
- package/build/http/endpoints/jwks.mjs +40 -0
- package/build/http/endpoints/jwks.mjs.map +1 -0
- package/build/http/endpoints/profile.mjs +56 -0
- package/build/http/endpoints/profile.mjs.map +1 -0
- package/build/http/endpoints/refresh.mjs +99 -0
- package/build/http/endpoints/refresh.mjs.map +1 -0
- package/build/http/endpoints/registration.mjs +42 -0
- package/build/http/endpoints/registration.mjs.map +1 -0
- package/build/http/endpoints/revoke.mjs +31 -0
- package/build/http/endpoints/revoke.mjs.map +1 -0
- package/build/http/endpoints/serviceDescription.mjs +48 -0
- package/build/http/endpoints/serviceDescription.mjs.map +1 -0
- package/build/http/endpoints/statusList.mjs +91 -0
- package/build/http/endpoints/statusList.mjs.map +1 -0
- package/build/http/endpoints/token.mjs +123 -0
- package/build/http/endpoints/token.mjs.map +1 -0
- package/build/http/middleware/auth.mjs +38 -0
- package/build/http/middleware/auth.mjs.map +1 -0
- package/build/http/router.d.mts +19 -0
- package/build/http/router.d.mts.map +1 -0
- package/build/http/router.mjs +36 -0
- package/build/http/router.mjs.map +1 -0
- package/build/http/tenants.mjs +16 -0
- package/build/http/tenants.mjs.map +1 -0
- package/build/http/util/auth.mjs +38 -0
- package/build/http/util/auth.mjs.map +1 -0
- package/build/index.d.mts +57 -0
- package/build/index.mjs +68 -0
- package/build/index.mjs.map +1 -0
- package/build/models/ClrCredential.d.mts +116 -0
- package/build/models/ClrCredential.d.mts.map +1 -0
- package/build/models/ClrCredential.mjs +38 -0
- package/build/models/ClrCredential.mjs.map +1 -0
- package/build/models/EndorsementCredential.d.mts +93 -0
- package/build/models/EndorsementCredential.d.mts.map +1 -0
- package/build/models/StatusListCredential.d.mts +85 -0
- package/build/models/StatusListCredential.d.mts.map +1 -0
- package/build/models/StatusListCredential.mjs +29 -0
- package/build/models/StatusListCredential.mjs.map +1 -0
- package/build/models/index.mjs +2 -0
- package/build/repository/OpenBadgeCredentialRecord.d.mts +48 -0
- package/build/repository/OpenBadgeCredentialRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgeCredentialRecord.mjs +44 -0
- package/build/repository/OpenBadgeCredentialRecord.mjs.map +1 -0
- package/build/repository/OpenBadgeCredentialRepository.d.mts +13 -0
- package/build/repository/OpenBadgeCredentialRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgeCredentialRepository.mjs +34 -0
- package/build/repository/OpenBadgeCredentialRepository.mjs.map +1 -0
- package/build/repository/OpenBadgesAuthCodeRecord.d.mts +39 -0
- package/build/repository/OpenBadgesAuthCodeRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgesAuthCodeRecord.mjs +40 -0
- package/build/repository/OpenBadgesAuthCodeRecord.mjs.map +1 -0
- package/build/repository/OpenBadgesAuthCodeRepository.d.mts +11 -0
- package/build/repository/OpenBadgesAuthCodeRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgesAuthCodeRepository.mjs +29 -0
- package/build/repository/OpenBadgesAuthCodeRepository.mjs.map +1 -0
- package/build/repository/OpenBadgesConsentRecord.d.mts +28 -0
- package/build/repository/OpenBadgesConsentRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgesConsentRecord.mjs +33 -0
- package/build/repository/OpenBadgesConsentRecord.mjs.map +1 -0
- package/build/repository/OpenBadgesConsentRepository.d.mts +11 -0
- package/build/repository/OpenBadgesConsentRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgesConsentRepository.mjs +37 -0
- package/build/repository/OpenBadgesConsentRepository.mjs.map +1 -0
- package/build/repository/OpenBadgesKeyBindingRecord.d.mts +32 -0
- package/build/repository/OpenBadgesKeyBindingRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgesKeyBindingRecord.mjs +37 -0
- package/build/repository/OpenBadgesKeyBindingRecord.mjs.map +1 -0
- package/build/repository/OpenBadgesKeyBindingRepository.d.mts +12 -0
- package/build/repository/OpenBadgesKeyBindingRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgesKeyBindingRepository.mjs +31 -0
- package/build/repository/OpenBadgesKeyBindingRepository.mjs.map +1 -0
- package/build/repository/OpenBadgesOAuthRecord.d.mts +39 -0
- package/build/repository/OpenBadgesOAuthRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgesOAuthRecord.mjs +37 -0
- package/build/repository/OpenBadgesOAuthRecord.mjs.map +1 -0
- package/build/repository/OpenBadgesOAuthRepository.d.mts +13 -0
- package/build/repository/OpenBadgesOAuthRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgesOAuthRepository.mjs +35 -0
- package/build/repository/OpenBadgesOAuthRepository.mjs.map +1 -0
- package/build/repository/OpenBadgesProfileRecord.d.mts +25 -0
- package/build/repository/OpenBadgesProfileRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgesProfileRecord.mjs +26 -0
- package/build/repository/OpenBadgesProfileRecord.mjs.map +1 -0
- package/build/repository/OpenBadgesProfileRepository.d.mts +11 -0
- package/build/repository/OpenBadgesProfileRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgesProfileRepository.mjs +28 -0
- package/build/repository/OpenBadgesProfileRepository.mjs.map +1 -0
- package/build/repository/OpenBadgesRevocationCacheRecord.d.mts +27 -0
- package/build/repository/OpenBadgesRevocationCacheRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgesRevocationCacheRecord.mjs +27 -0
- package/build/repository/OpenBadgesRevocationCacheRecord.mjs.map +1 -0
- package/build/repository/OpenBadgesRevocationCacheRepository.d.mts +11 -0
- package/build/repository/OpenBadgesRevocationCacheRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgesRevocationCacheRepository.mjs +28 -0
- package/build/repository/OpenBadgesRevocationCacheRepository.mjs.map +1 -0
- package/build/repository/OpenBadgesServiceDescriptionRecord.d.mts +25 -0
- package/build/repository/OpenBadgesServiceDescriptionRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgesServiceDescriptionRecord.mjs +26 -0
- package/build/repository/OpenBadgesServiceDescriptionRecord.mjs.map +1 -0
- package/build/repository/OpenBadgesServiceDescriptionRepository.d.mts +11 -0
- package/build/repository/OpenBadgesServiceDescriptionRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgesServiceDescriptionRepository.mjs +28 -0
- package/build/repository/OpenBadgesServiceDescriptionRepository.mjs.map +1 -0
- package/build/repository/OpenBadgesTokenRecord.d.mts +43 -0
- package/build/repository/OpenBadgesTokenRecord.d.mts.map +1 -0
- package/build/repository/OpenBadgesTokenRecord.mjs +37 -0
- package/build/repository/OpenBadgesTokenRecord.mjs.map +1 -0
- package/build/repository/OpenBadgesTokenRepository.d.mts +14 -0
- package/build/repository/OpenBadgesTokenRepository.d.mts.map +1 -0
- package/build/repository/OpenBadgesTokenRepository.mjs +46 -0
- package/build/repository/OpenBadgesTokenRepository.mjs.map +1 -0
- package/build/repository/StatusListRecord.d.mts +40 -0
- package/build/repository/StatusListRecord.d.mts.map +1 -0
- package/build/repository/StatusListRecord.mjs +42 -0
- package/build/repository/StatusListRecord.mjs.map +1 -0
- package/build/repository/StatusListRepository.d.mts +23 -0
- package/build/repository/StatusListRepository.d.mts.map +1 -0
- package/build/repository/StatusListRepository.mjs +46 -0
- package/build/repository/StatusListRepository.mjs.map +1 -0
- package/build/services/AchievementValidator.d.mts +162 -0
- package/build/services/AchievementValidator.d.mts.map +1 -0
- package/build/services/AchievementValidator.mjs +173 -0
- package/build/services/AchievementValidator.mjs.map +1 -0
- package/build/services/ConsumerService.d.mts +29 -0
- package/build/services/ConsumerService.d.mts.map +1 -0
- package/build/services/ConsumerService.mjs +114 -0
- package/build/services/ConsumerService.mjs.map +1 -0
- package/build/services/ContextService.d.mts +17 -0
- package/build/services/ContextService.d.mts.map +1 -0
- package/build/services/ContextService.mjs +48 -0
- package/build/services/ContextService.mjs.map +1 -0
- package/build/services/DataIntegrityService.d.mts +58 -0
- package/build/services/DataIntegrityService.d.mts.map +1 -0
- package/build/services/DataIntegrityService.mjs +130 -0
- package/build/services/DataIntegrityService.mjs.map +1 -0
- package/build/services/DidCommLinkService.d.mts +12 -0
- package/build/services/DidCommLinkService.d.mts.map +1 -0
- package/build/services/DidCommLinkService.mjs +15 -0
- package/build/services/DidCommLinkService.mjs.map +1 -0
- package/build/services/DisplayMapper.d.mts +13 -0
- package/build/services/DisplayMapper.d.mts.map +1 -0
- package/build/services/DisplayMapper.mjs +23 -0
- package/build/services/DisplayMapper.mjs.map +1 -0
- package/build/services/IssuerService.d.mts +43 -0
- package/build/services/IssuerService.d.mts.map +1 -0
- package/build/services/IssuerService.mjs +230 -0
- package/build/services/IssuerService.mjs.map +1 -0
- package/build/services/JwtService.d.mts +22 -0
- package/build/services/JwtService.d.mts.map +1 -0
- package/build/services/JwtService.mjs +190 -0
- package/build/services/JwtService.mjs.map +1 -0
- package/build/services/KeyService.d.mts +122 -0
- package/build/services/KeyService.d.mts.map +1 -0
- package/build/services/KeyService.mjs +448 -0
- package/build/services/KeyService.mjs.map +1 -0
- package/build/services/OAuthClient.d.mts +31 -0
- package/build/services/OAuthClient.d.mts.map +1 -0
- package/build/services/OAuthClient.mjs +131 -0
- package/build/services/OAuthClient.mjs.map +1 -0
- package/build/services/ProofService.d.mts +20 -0
- package/build/services/ProofService.d.mts.map +1 -0
- package/build/services/ProofService.mjs +39 -0
- package/build/services/ProofService.mjs.map +1 -0
- package/build/services/RevocationService.d.mts +64 -0
- package/build/services/RevocationService.d.mts.map +1 -0
- package/build/services/RevocationService.mjs +253 -0
- package/build/services/RevocationService.mjs.map +1 -0
- package/build/services/VerifyService.d.mts +24 -0
- package/build/services/VerifyService.d.mts.map +1 -0
- package/build/services/VerifyService.mjs +59 -0
- package/build/services/VerifyService.mjs.map +1 -0
- package/build/services/crypto/CryptoDriver.d.mts +14 -0
- package/build/services/crypto/CryptoDriver.d.mts.map +1 -0
- package/build/services/crypto/CryptoDriver.mjs +6 -0
- package/build/services/crypto/CryptoDriver.mjs.map +1 -0
- package/build/services/crypto/JsonLdCryptoDriver.d.mts +22 -0
- package/build/services/crypto/JsonLdCryptoDriver.d.mts.map +1 -0
- package/build/services/crypto/JsonLdCryptoDriver.mjs +43 -0
- package/build/services/crypto/JsonLdCryptoDriver.mjs.map +1 -0
- package/build/services/crypto/JwtCryptoDriver.d.mts +18 -0
- package/build/services/crypto/JwtCryptoDriver.d.mts.map +1 -0
- package/build/services/crypto/JwtCryptoDriver.mjs +46 -0
- package/build/services/crypto/JwtCryptoDriver.mjs.map +1 -0
- package/build/services/index.d.mts +12 -0
- package/build/services/index.mjs +12 -0
- package/build/utils/validate.d.mts +21 -0
- package/build/utils/validate.d.mts.map +1 -0
- package/build/utils/validate.mjs +111 -0
- package/build/utils/validate.mjs.map +1 -0
- package/package.json +63 -3
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ProofService } from "../../services/ProofService.mjs";
|
|
2
|
+
import { RevocationService } from "../../services/RevocationService.mjs";
|
|
3
|
+
import { getRequestContext, init_router, sendError, sendJson } from "../router.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/http/endpoints/statusList.ts
|
|
6
|
+
init_router();
|
|
7
|
+
/**
|
|
8
|
+
* Configure the StatusList2021 endpoint
|
|
9
|
+
*
|
|
10
|
+
* GET /status-list/:id - Returns a signed StatusList2021Credential
|
|
11
|
+
* POST /status-list/:id/status - Update status for a credential index (issuer only)
|
|
12
|
+
*/
|
|
13
|
+
function configureStatusListEndpoint(router, config, _module) {
|
|
14
|
+
const basePath = config.statusListPath;
|
|
15
|
+
router.get(`${basePath}/:id`, async (req, res) => {
|
|
16
|
+
try {
|
|
17
|
+
const { agentContext } = getRequestContext(req);
|
|
18
|
+
const listId = String(req.params.id);
|
|
19
|
+
const revocationService = agentContext.dependencyManager.resolve(RevocationService);
|
|
20
|
+
const proofService = agentContext.dependencyManager.resolve(ProofService);
|
|
21
|
+
const record = await revocationService.getStatusList(agentContext, listId);
|
|
22
|
+
if (!record) return sendError(res, 404, "not_found", `Status list not found: ${listId}`);
|
|
23
|
+
const unsignedCredential = revocationService.buildStatusListCredential(record);
|
|
24
|
+
const verificationMethod = `${record.issuerDid}#key-1`;
|
|
25
|
+
return sendJson(res, await proofService.sign(agentContext, unsignedCredential, {
|
|
26
|
+
id: verificationMethod,
|
|
27
|
+
controller: record.issuerDid
|
|
28
|
+
}), 200, "application/vc+ld+json");
|
|
29
|
+
} catch (e) {
|
|
30
|
+
try {
|
|
31
|
+
getRequestContext(req).agentContext.config.logger.error("[OB][StatusList] GET error", { error: e?.message || String(e) });
|
|
32
|
+
} catch {}
|
|
33
|
+
return sendError(res, 500, "server_error", e?.message || "Unexpected error");
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
router.post(`${basePath}/:id/status`, async (req, res) => {
|
|
37
|
+
try {
|
|
38
|
+
const { agentContext } = getRequestContext(req);
|
|
39
|
+
const listId = String(req.params.id);
|
|
40
|
+
const { index, status } = req.body;
|
|
41
|
+
if (typeof index !== "number" || typeof status !== "boolean") return sendError(res, 400, "invalid_request", "Missing required fields: index (number), status (boolean)");
|
|
42
|
+
await agentContext.dependencyManager.resolve(RevocationService).setStatus(agentContext, {
|
|
43
|
+
listId,
|
|
44
|
+
index,
|
|
45
|
+
status
|
|
46
|
+
});
|
|
47
|
+
return sendJson(res, {
|
|
48
|
+
success: true,
|
|
49
|
+
listId,
|
|
50
|
+
index,
|
|
51
|
+
status: status ? "revoked" : "active"
|
|
52
|
+
});
|
|
53
|
+
} catch (e) {
|
|
54
|
+
try {
|
|
55
|
+
getRequestContext(req).agentContext.config.logger.error("[OB][StatusList] POST error", { error: e?.message || String(e) });
|
|
56
|
+
} catch {}
|
|
57
|
+
if (e?.message?.includes("not found")) return sendError(res, 404, "not_found", e.message);
|
|
58
|
+
return sendError(res, 500, "server_error", e?.message || "Unexpected error");
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
router.post(basePath, async (req, res) => {
|
|
62
|
+
try {
|
|
63
|
+
const { agentContext } = getRequestContext(req);
|
|
64
|
+
const { listId, issuerDid, purpose, capacity } = req.body;
|
|
65
|
+
if (!listId || !issuerDid) return sendError(res, 400, "invalid_request", "Missing required fields: listId, issuerDid");
|
|
66
|
+
const record = await agentContext.dependencyManager.resolve(RevocationService).createStatusList(agentContext, {
|
|
67
|
+
listId,
|
|
68
|
+
issuerDid,
|
|
69
|
+
purpose: purpose || "revocation",
|
|
70
|
+
capacity,
|
|
71
|
+
baseUrl: config.baseUrl
|
|
72
|
+
});
|
|
73
|
+
return sendJson(res, {
|
|
74
|
+
success: true,
|
|
75
|
+
listId: record.listId,
|
|
76
|
+
purpose: record.purpose,
|
|
77
|
+
capacity: record.capacity,
|
|
78
|
+
statusListCredentialUrl: `${config.baseUrl}${basePath}/${listId}`
|
|
79
|
+
}, 201);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
try {
|
|
82
|
+
getRequestContext(req).agentContext.config.logger.error("[OB][StatusList] POST create error", { error: e?.message || String(e) });
|
|
83
|
+
} catch {}
|
|
84
|
+
return sendError(res, 500, "server_error", e?.message || "Unexpected error");
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { configureStatusListEndpoint };
|
|
91
|
+
//# sourceMappingURL=statusList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusList.mjs","names":[],"sources":["../../../src/http/endpoints/statusList.ts"],"sourcesContent":["import type { Router, Response } from 'express'\nimport type { OpenBadgesHttpModuleConfig } from '../OpenBadgesHttpModuleConfig'\nimport type { OpenBadgesHttpModule } from '../OpenBadgesHttpModule'\nimport type { ObRequest } from '../router'\n\nimport { getRequestContext, sendError, sendJson } from '../router'\nimport { RevocationService } from '../../services/RevocationService'\nimport { ProofService } from '../../services/ProofService'\n\n/**\n * Configure the StatusList2021 endpoint\n *\n * GET /status-list/:id - Returns a signed StatusList2021Credential\n * POST /status-list/:id/status - Update status for a credential index (issuer only)\n */\nexport function configureStatusListEndpoint(\n router: Router,\n config: OpenBadgesHttpModuleConfig,\n _module: OpenBadgesHttpModule\n) {\n const basePath = config.statusListPath\n\n // GET /status-list/:id - Return signed StatusList2021Credential\n router.get(`${basePath}/:id`, async (req: ObRequest, res: Response) => {\n try {\n const { agentContext } = getRequestContext(req)\n const listId = String(req.params.id)\n\n const revocationService = agentContext.dependencyManager.resolve(RevocationService)\n const proofService = agentContext.dependencyManager.resolve(ProofService)\n\n // Get the status list record\n const record = await revocationService.getStatusList(agentContext, listId)\n if (!record) {\n return sendError(res, 404, 'not_found', `Status list not found: ${listId}`)\n }\n\n // Build the unsigned StatusList2021Credential\n const unsignedCredential = revocationService.buildStatusListCredential(record)\n\n // Sign the credential\n const verificationMethod = `${record.issuerDid}#key-1`\n const signedCredential = await proofService.sign(agentContext, unsignedCredential, {\n id: verificationMethod,\n controller: record.issuerDid,\n })\n\n // Return with proper content type\n return sendJson(res, signedCredential, 200, 'application/vc+ld+json')\n } catch (e: any) {\n try { getRequestContext(req).agentContext.config.logger.error('[OB][StatusList] GET error', { error: e?.message || String(e) }) } catch {}\n return sendError(res, 500, 'server_error', e?.message || 'Unexpected error')\n }\n })\n\n // POST /status-list/:id/status - Update status for an index (issuer operation)\n router.post(`${basePath}/:id/status`, async (req: ObRequest, res: Response) => {\n try {\n const { agentContext } = getRequestContext(req)\n const listId = String(req.params.id)\n const { index, status } = req.body as { index?: number; status?: boolean }\n\n if (typeof index !== 'number' || typeof status !== 'boolean') {\n return sendError(res, 400, 'invalid_request', 'Missing required fields: index (number), status (boolean)')\n }\n\n const revocationService = agentContext.dependencyManager.resolve(RevocationService)\n\n // Update the status\n await revocationService.setStatus(agentContext, { listId, index, status })\n\n return sendJson(res, { success: true, listId, index, status: status ? 'revoked' : 'active' })\n } catch (e: any) {\n try { getRequestContext(req).agentContext.config.logger.error('[OB][StatusList] POST error', { error: e?.message || String(e) }) } catch {}\n if (e?.message?.includes('not found')) {\n return sendError(res, 404, 'not_found', e.message)\n }\n return sendError(res, 500, 'server_error', e?.message || 'Unexpected error')\n }\n })\n\n // POST /status-list - Create a new status list\n router.post(basePath, async (req: ObRequest, res: Response) => {\n try {\n const { agentContext } = getRequestContext(req)\n const { listId, issuerDid, purpose, capacity } = req.body as {\n listId?: string\n issuerDid?: string\n purpose?: 'revocation' | 'suspension'\n capacity?: number\n }\n\n if (!listId || !issuerDid) {\n return sendError(res, 400, 'invalid_request', 'Missing required fields: listId, issuerDid')\n }\n\n const revocationService = agentContext.dependencyManager.resolve(RevocationService)\n\n const record = await revocationService.createStatusList(agentContext, {\n listId,\n issuerDid,\n purpose: purpose || 'revocation',\n capacity,\n baseUrl: config.baseUrl,\n })\n\n return sendJson(res, {\n success: true,\n listId: record.listId,\n purpose: record.purpose,\n capacity: record.capacity,\n statusListCredentialUrl: `${config.baseUrl}${basePath}/${listId}`,\n }, 201)\n } catch (e: any) {\n try { getRequestContext(req).agentContext.config.logger.error('[OB][StatusList] POST create error', { error: e?.message || String(e) }) } catch {}\n return sendError(res, 500, 'server_error', e?.message || 'Unexpected error')\n }\n })\n}\n"],"mappings":";;;;;aAKkE;;;;;;;AAUlE,SAAgB,4BACd,QACA,QACA,SACA;CACA,MAAM,WAAW,OAAO;AAGxB,QAAO,IAAI,GAAG,SAAS,OAAO,OAAO,KAAgB,QAAkB;AACrE,MAAI;GACF,MAAM,EAAE,iBAAiB,kBAAkB,IAAI;GAC/C,MAAM,SAAS,OAAO,IAAI,OAAO,GAAG;GAEpC,MAAM,oBAAoB,aAAa,kBAAkB,QAAQ,kBAAkB;GACnF,MAAM,eAAe,aAAa,kBAAkB,QAAQ,aAAa;GAGzE,MAAM,SAAS,MAAM,kBAAkB,cAAc,cAAc,OAAO;AAC1E,OAAI,CAAC,OACH,QAAO,UAAU,KAAK,KAAK,aAAa,0BAA0B,SAAS;GAI7E,MAAM,qBAAqB,kBAAkB,0BAA0B,OAAO;GAG9E,MAAM,qBAAqB,GAAG,OAAO,UAAU;AAO/C,UAAO,SAAS,KANS,MAAM,aAAa,KAAK,cAAc,oBAAoB;IACjF,IAAI;IACJ,YAAY,OAAO;IACpB,CAAC,EAGqC,KAAK,yBAAyB;WAC9D,GAAQ;AACf,OAAI;AAAE,sBAAkB,IAAI,CAAC,aAAa,OAAO,OAAO,MAAM,8BAA8B,EAAE,OAAO,GAAG,WAAW,OAAO,EAAE,EAAE,CAAC;WAAS;AACxI,UAAO,UAAU,KAAK,KAAK,gBAAgB,GAAG,WAAW,mBAAmB;;GAE9E;AAGF,QAAO,KAAK,GAAG,SAAS,cAAc,OAAO,KAAgB,QAAkB;AAC7E,MAAI;GACF,MAAM,EAAE,iBAAiB,kBAAkB,IAAI;GAC/C,MAAM,SAAS,OAAO,IAAI,OAAO,GAAG;GACpC,MAAM,EAAE,OAAO,WAAW,IAAI;AAE9B,OAAI,OAAO,UAAU,YAAY,OAAO,WAAW,UACjD,QAAO,UAAU,KAAK,KAAK,mBAAmB,4DAA4D;AAM5G,SAH0B,aAAa,kBAAkB,QAAQ,kBAAkB,CAG3D,UAAU,cAAc;IAAE;IAAQ;IAAO;IAAQ,CAAC;AAE1E,UAAO,SAAS,KAAK;IAAE,SAAS;IAAM;IAAQ;IAAO,QAAQ,SAAS,YAAY;IAAU,CAAC;WACtF,GAAQ;AACf,OAAI;AAAE,sBAAkB,IAAI,CAAC,aAAa,OAAO,OAAO,MAAM,+BAA+B,EAAE,OAAO,GAAG,WAAW,OAAO,EAAE,EAAE,CAAC;WAAS;AACzI,OAAI,GAAG,SAAS,SAAS,YAAY,CACnC,QAAO,UAAU,KAAK,KAAK,aAAa,EAAE,QAAQ;AAEpD,UAAO,UAAU,KAAK,KAAK,gBAAgB,GAAG,WAAW,mBAAmB;;GAE9E;AAGF,QAAO,KAAK,UAAU,OAAO,KAAgB,QAAkB;AAC7D,MAAI;GACF,MAAM,EAAE,iBAAiB,kBAAkB,IAAI;GAC/C,MAAM,EAAE,QAAQ,WAAW,SAAS,aAAa,IAAI;AAOrD,OAAI,CAAC,UAAU,CAAC,UACd,QAAO,UAAU,KAAK,KAAK,mBAAmB,6CAA6C;GAK7F,MAAM,SAAS,MAFW,aAAa,kBAAkB,QAAQ,kBAAkB,CAE5C,iBAAiB,cAAc;IACpE;IACA;IACA,SAAS,WAAW;IACpB;IACA,SAAS,OAAO;IACjB,CAAC;AAEF,UAAO,SAAS,KAAK;IACnB,SAAS;IACT,QAAQ,OAAO;IACf,SAAS,OAAO;IAChB,UAAU,OAAO;IACjB,yBAAyB,GAAG,OAAO,UAAU,SAAS,GAAG;IAC1D,EAAE,IAAI;WACA,GAAQ;AACf,OAAI;AAAE,sBAAkB,IAAI,CAAC,aAAa,OAAO,OAAO,MAAM,sCAAsC,EAAE,OAAO,GAAG,WAAW,OAAO,EAAE,EAAE,CAAC;WAAS;AAChJ,UAAO,UAAU,KAAK,KAAK,gBAAgB,GAAG,WAAW,mBAAmB;;GAE9E"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { OpenBadgesOAuthRepository } from "../../repository/OpenBadgesOAuthRepository.mjs";
|
|
2
|
+
import { OpenBadgesTokenRecord } from "../../repository/OpenBadgesTokenRecord.mjs";
|
|
3
|
+
import { OpenBadgesTokenRepository } from "../../repository/OpenBadgesTokenRepository.mjs";
|
|
4
|
+
import { OpenBadgesAuthCodeRepository } from "../../repository/OpenBadgesAuthCodeRepository.mjs";
|
|
5
|
+
import { getRequestContext, init_router, sendError, sendJson } from "../router.mjs";
|
|
6
|
+
import { parseBasicAuth, parseBodyClientAuth } from "../util/auth.mjs";
|
|
7
|
+
import { Hasher, TypedArrayEncoder } from "@credo-ts/core";
|
|
8
|
+
|
|
9
|
+
//#region src/http/endpoints/token.ts
|
|
10
|
+
init_router();
|
|
11
|
+
function randomToken(prefix = "") {
|
|
12
|
+
return prefix + Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
|
|
13
|
+
}
|
|
14
|
+
function configureTokenEndpoint(router, module) {
|
|
15
|
+
router.post(module.config.tokenPath, async (req, res) => {
|
|
16
|
+
const { agentContext } = getRequestContext(req);
|
|
17
|
+
const grant_type = String(req.body?.grant_type ?? "");
|
|
18
|
+
if (grant_type === "authorization_code") {
|
|
19
|
+
const basic = parseBasicAuth(req) ?? parseBodyClientAuth(req);
|
|
20
|
+
if (!basic) return sendError(res, 401, "invalid_client", "Client authentication required");
|
|
21
|
+
const clientRec = await agentContext.dependencyManager.resolve(OpenBadgesOAuthRepository).findByClientId(agentContext, basic.clientId);
|
|
22
|
+
const reg = clientRec?.clientRegistration || {};
|
|
23
|
+
if (!clientRec || reg.client_secret !== basic.clientSecret) return sendError(res, 401, "invalid_client", "Invalid client credentials");
|
|
24
|
+
const code = String(req.body?.code ?? "");
|
|
25
|
+
const redirect_uri = String(req.body?.redirect_uri ?? "");
|
|
26
|
+
const code_verifier = req.body?.code_verifier ? String(req.body.code_verifier) : void 0;
|
|
27
|
+
if (!code || !redirect_uri) return sendError(res, 400, "invalid_request", "code and redirect_uri required");
|
|
28
|
+
const codeRepo = agentContext.dependencyManager.resolve(OpenBadgesAuthCodeRepository);
|
|
29
|
+
const entry = await codeRepo.findByCode(agentContext, code);
|
|
30
|
+
if (!entry || entry.expiresAt.getTime() < Date.now()) return sendError(res, 400, "invalid_grant", "Invalid or expired code");
|
|
31
|
+
if (entry.redirectUri !== redirect_uri) return sendError(res, 400, "invalid_grant", "redirect_uri mismatch");
|
|
32
|
+
if (entry.clientId !== basic.clientId) return sendError(res, 400, "invalid_grant", "client mismatch");
|
|
33
|
+
if (entry.codeChallenge) {
|
|
34
|
+
if (!code_verifier) return sendError(res, 400, "invalid_request", "code_verifier required");
|
|
35
|
+
if (entry.codeChallengeMethod === "S256") {
|
|
36
|
+
const hashBytes = Hasher.hash(TypedArrayEncoder.fromUtf8String(code_verifier), "sha-256");
|
|
37
|
+
if (TypedArrayEncoder.toBase64Url(hashBytes) !== entry.codeChallenge) return sendError(res, 400, "invalid_grant", "PKCE verification failed");
|
|
38
|
+
} else if (code_verifier !== entry.codeChallenge) return sendError(res, 400, "invalid_grant", "PKCE verification failed");
|
|
39
|
+
}
|
|
40
|
+
const accessToken = randomToken("at_");
|
|
41
|
+
const refreshToken = randomToken("rt_");
|
|
42
|
+
const expiresIn = 180;
|
|
43
|
+
const pairId = randomToken("pair_");
|
|
44
|
+
const tokenRepo = agentContext.dependencyManager.resolve(OpenBadgesTokenRepository);
|
|
45
|
+
await tokenRepo.save(agentContext, new OpenBadgesTokenRecord({
|
|
46
|
+
token: accessToken,
|
|
47
|
+
tokenType: "access",
|
|
48
|
+
clientId: entry.clientId,
|
|
49
|
+
subject: entry.subject,
|
|
50
|
+
scope: entry.scope,
|
|
51
|
+
expiresAt: new Date(Date.now() + expiresIn * 1e3),
|
|
52
|
+
pairId,
|
|
53
|
+
host: new URL(module.config.baseUrl).origin
|
|
54
|
+
}));
|
|
55
|
+
await tokenRepo.save(agentContext, new OpenBadgesTokenRecord({
|
|
56
|
+
token: refreshToken,
|
|
57
|
+
tokenType: "refresh",
|
|
58
|
+
clientId: entry.clientId,
|
|
59
|
+
subject: entry.subject,
|
|
60
|
+
scope: entry.scope,
|
|
61
|
+
expiresAt: new Date(Date.now() + 2160 * 60 * 60 * 1e3),
|
|
62
|
+
pairId,
|
|
63
|
+
host: new URL(module.config.baseUrl).origin
|
|
64
|
+
}));
|
|
65
|
+
await codeRepo.deleteById(agentContext, entry.id);
|
|
66
|
+
return sendJson(res, {
|
|
67
|
+
access_token: accessToken,
|
|
68
|
+
token_type: "Bearer",
|
|
69
|
+
expires_in: expiresIn,
|
|
70
|
+
refresh_token: refreshToken,
|
|
71
|
+
scope: entry.scope
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (grant_type === "refresh_token") {
|
|
75
|
+
const basic = parseBasicAuth(req) ?? parseBodyClientAuth(req);
|
|
76
|
+
if (!basic) return sendError(res, 401, "invalid_client", "Client authentication required");
|
|
77
|
+
const clientRec = await agentContext.dependencyManager.resolve(OpenBadgesOAuthRepository).findByClientId(agentContext, basic.clientId);
|
|
78
|
+
const reg = clientRec?.clientRegistration || {};
|
|
79
|
+
if (!clientRec || reg.client_secret !== basic.clientSecret) return sendError(res, 401, "invalid_client", "Invalid client credentials");
|
|
80
|
+
const refresh_token = String(req.body?.refresh_token ?? "");
|
|
81
|
+
const tokenRepo = agentContext.dependencyManager.resolve(OpenBadgesTokenRepository);
|
|
82
|
+
const stored = await tokenRepo.findByToken(agentContext, refresh_token);
|
|
83
|
+
if (!stored || stored.tokenType !== "refresh" || stored.expiresAt.getTime() < Date.now()) return sendError(res, 400, "invalid_grant", "Invalid or expired refresh token");
|
|
84
|
+
if (stored.clientId !== basic.clientId) return sendError(res, 400, "invalid_grant", "client mismatch");
|
|
85
|
+
const accessToken = randomToken("at_");
|
|
86
|
+
const newRefreshToken = randomToken("rt_");
|
|
87
|
+
const expiresIn = 180;
|
|
88
|
+
await tokenRepo.save(agentContext, new OpenBadgesTokenRecord({
|
|
89
|
+
token: accessToken,
|
|
90
|
+
tokenType: "access",
|
|
91
|
+
clientId: stored.clientId,
|
|
92
|
+
subject: stored.subject,
|
|
93
|
+
scope: stored.scope,
|
|
94
|
+
expiresAt: new Date(Date.now() + expiresIn * 1e3),
|
|
95
|
+
pairId: stored.pairId,
|
|
96
|
+
host: stored.host
|
|
97
|
+
}));
|
|
98
|
+
await tokenRepo.deleteById(agentContext, stored.id);
|
|
99
|
+
await tokenRepo.save(agentContext, new OpenBadgesTokenRecord({
|
|
100
|
+
token: newRefreshToken,
|
|
101
|
+
tokenType: "refresh",
|
|
102
|
+
clientId: stored.clientId,
|
|
103
|
+
subject: stored.subject,
|
|
104
|
+
scope: stored.scope,
|
|
105
|
+
expiresAt: new Date(Date.now() + 2160 * 60 * 60 * 1e3),
|
|
106
|
+
pairId: stored.pairId,
|
|
107
|
+
host: stored.host
|
|
108
|
+
}));
|
|
109
|
+
return sendJson(res, {
|
|
110
|
+
access_token: accessToken,
|
|
111
|
+
token_type: "Bearer",
|
|
112
|
+
expires_in: expiresIn,
|
|
113
|
+
refresh_token: newRefreshToken,
|
|
114
|
+
scope: stored.scope
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return sendError(res, 400, "unsupported_grant_type", "Only authorization_code and refresh_token supported");
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
export { configureTokenEndpoint };
|
|
123
|
+
//# sourceMappingURL=token.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.mjs","names":[],"sources":["../../../src/http/endpoints/token.ts"],"sourcesContent":["import type { Router, Response } from 'express'\nimport type { OpenBadgesHttpModule } from '../OpenBadgesHttpModule'\nimport type { ObRequest } from '../router'\n\nimport { sendError, sendJson, getRequestContext } from '../router'\nimport { Hasher, TypedArrayEncoder } from '@credo-ts/core'\nimport { OpenBadgesAuthCodeRepository } from '../../repository/OpenBadgesAuthCodeRepository'\nimport { OpenBadgesTokenRepository } from '../../repository/OpenBadgesTokenRepository'\nimport { OpenBadgesTokenRecord } from '../../repository/OpenBadgesTokenRecord'\nimport { OpenBadgesOAuthRepository } from '../../repository/OpenBadgesOAuthRepository'\nimport { parseBasicAuth, parseBodyClientAuth } from '../util/auth'\n\nfunction randomToken(prefix = '') {\n return prefix + Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)\n}\n\nexport function configureTokenEndpoint(router: Router, module: OpenBadgesHttpModule) {\n router.post(module.config.tokenPath, async (req: ObRequest, res: Response) => {\n const { agentContext } = getRequestContext(req)\n const grant_type = String(req.body?.grant_type ?? '')\n\n if (grant_type === 'authorization_code') {\n // Client auth\n const basic = parseBasicAuth(req) ?? parseBodyClientAuth(req)\n if (!basic) return sendError(res, 401, 'invalid_client', 'Client authentication required')\n const oauthRepo = agentContext.dependencyManager.resolve(OpenBadgesOAuthRepository)\n const clientRec = await oauthRepo.findByClientId(agentContext, basic.clientId)\n const reg = (clientRec?.clientRegistration as any) || {}\n if (!clientRec || reg.client_secret !== basic.clientSecret)\n return sendError(res, 401, 'invalid_client', 'Invalid client credentials')\n\n const code = String(req.body?.code ?? '')\n const redirect_uri = String(req.body?.redirect_uri ?? '')\n const code_verifier = req.body?.code_verifier ? String(req.body.code_verifier) : undefined\n if (!code || !redirect_uri) return sendError(res, 400, 'invalid_request', 'code and redirect_uri required')\n\n const codeRepo = agentContext.dependencyManager.resolve(OpenBadgesAuthCodeRepository)\n const entry = await codeRepo.findByCode(agentContext, code)\n if (!entry || entry.expiresAt.getTime() < Date.now()) return sendError(res, 400, 'invalid_grant', 'Invalid or expired code')\n if (entry.redirectUri !== redirect_uri) return sendError(res, 400, 'invalid_grant', 'redirect_uri mismatch')\n if (entry.clientId !== basic.clientId) return sendError(res, 400, 'invalid_grant', 'client mismatch')\n\n // PKCE check when a code_challenge was provided\n if (entry.codeChallenge) {\n if (!code_verifier) return sendError(res, 400, 'invalid_request', 'code_verifier required')\n if (entry.codeChallengeMethod === 'S256') {\n // Use cross-platform Hasher instead of Node crypto\n const hashBytes = Hasher.hash(TypedArrayEncoder.fromUtf8String(code_verifier), 'sha-256')\n const expected = TypedArrayEncoder.toBase64Url(hashBytes)\n if (expected !== entry.codeChallenge) return sendError(res, 400, 'invalid_grant', 'PKCE verification failed')\n } else {\n // plain\n if (code_verifier !== entry.codeChallenge) return sendError(res, 400, 'invalid_grant', 'PKCE verification failed')\n }\n }\n\n const accessToken = randomToken('at_')\n const refreshToken = randomToken('rt_')\n const expiresIn = 3 * 60\n const pairId = randomToken('pair_')\n const tokenRepo = agentContext.dependencyManager.resolve(OpenBadgesTokenRepository)\n await tokenRepo.save(\n agentContext,\n new OpenBadgesTokenRecord({\n token: accessToken,\n tokenType: 'access',\n clientId: entry.clientId,\n subject: entry.subject,\n scope: entry.scope,\n expiresAt: new Date(Date.now() + expiresIn * 1000),\n pairId,\n host: new URL(module.config.baseUrl).origin,\n })\n )\n await tokenRepo.save(\n agentContext,\n new OpenBadgesTokenRecord({\n token: refreshToken,\n tokenType: 'refresh',\n clientId: entry.clientId,\n subject: entry.subject,\n scope: entry.scope,\n expiresAt: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000),\n pairId,\n host: new URL(module.config.baseUrl).origin,\n })\n )\n await codeRepo.deleteById(agentContext, entry.id)\n\n return sendJson(res, {\n access_token: accessToken,\n token_type: 'Bearer',\n expires_in: expiresIn,\n refresh_token: refreshToken,\n scope: entry.scope,\n })\n }\n\n if (grant_type === 'refresh_token') {\n const basic = parseBasicAuth(req) ?? parseBodyClientAuth(req)\n if (!basic) return sendError(res, 401, 'invalid_client', 'Client authentication required')\n const oauthRepo = agentContext.dependencyManager.resolve(OpenBadgesOAuthRepository)\n const clientRec = await oauthRepo.findByClientId(agentContext, basic.clientId)\n const reg = (clientRec?.clientRegistration as any) || {}\n if (!clientRec || reg.client_secret !== basic.clientSecret)\n return sendError(res, 401, 'invalid_client', 'Invalid client credentials')\n\n const refresh_token = String(req.body?.refresh_token ?? '')\n const tokenRepo = agentContext.dependencyManager.resolve(OpenBadgesTokenRepository)\n const stored = await tokenRepo.findByToken(agentContext, refresh_token)\n if (!stored || stored.tokenType !== 'refresh' || stored.expiresAt.getTime() < Date.now())\n return sendError(res, 400, 'invalid_grant', 'Invalid or expired refresh token')\n if (stored.clientId !== basic.clientId) return sendError(res, 400, 'invalid_grant', 'client mismatch')\n\n const accessToken = randomToken('at_')\n const newRefreshToken = randomToken('rt_')\n const expiresIn = 3 * 60\n await tokenRepo.save(\n agentContext,\n new OpenBadgesTokenRecord({\n token: accessToken,\n tokenType: 'access',\n clientId: stored.clientId,\n subject: stored.subject,\n scope: stored.scope,\n expiresAt: new Date(Date.now() + expiresIn * 1000),\n pairId: stored.pairId,\n host: stored.host,\n })\n )\n // Rotate refresh token: delete old, create new one\n await tokenRepo.deleteById(agentContext, stored.id)\n await tokenRepo.save(\n agentContext,\n new OpenBadgesTokenRecord({\n token: newRefreshToken,\n tokenType: 'refresh',\n clientId: stored.clientId,\n subject: stored.subject,\n scope: stored.scope,\n expiresAt: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000),\n pairId: stored.pairId,\n host: stored.host,\n })\n )\n\n return sendJson(res, {\n access_token: accessToken,\n token_type: 'Bearer',\n expires_in: expiresIn,\n refresh_token: newRefreshToken,\n scope: stored.scope,\n })\n }\n\n return sendError(res, 400, 'unsupported_grant_type', 'Only authorization_code and refresh_token supported')\n })\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OpenBadgesTokenRepository } from "../../repository/OpenBadgesTokenRepository.mjs";
|
|
2
|
+
import { getRequestContext, init_router, sendError } from "../router.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/http/middleware/auth.ts
|
|
5
|
+
init_router();
|
|
6
|
+
function bearerAuth(module) {
|
|
7
|
+
return async function(req, res, next) {
|
|
8
|
+
const header = req.headers["authorization"] || "";
|
|
9
|
+
if (!header || typeof header !== "string" || !header.startsWith("Bearer ")) return sendError(res, 401, "unauthorized", "Missing bearer token");
|
|
10
|
+
const token = header.slice(7);
|
|
11
|
+
try {
|
|
12
|
+
const { agentContext } = getRequestContext(req);
|
|
13
|
+
const tokenEntry = await agentContext.dependencyManager.resolve(OpenBadgesTokenRepository).findByToken(agentContext, token);
|
|
14
|
+
if (!tokenEntry || tokenEntry.tokenType !== "access" || tokenEntry.expiresAt.getTime() < Date.now()) return sendError(res, 401, "unauthorized", "Invalid or expired token");
|
|
15
|
+
req.requestContext.auth = {
|
|
16
|
+
subject: tokenEntry.subject,
|
|
17
|
+
scope: tokenEntry.scope,
|
|
18
|
+
clientId: tokenEntry.clientId,
|
|
19
|
+
scopes: new Set(String(tokenEntry.scope || "").split(/\s+/).filter(Boolean))
|
|
20
|
+
};
|
|
21
|
+
return next();
|
|
22
|
+
} catch (_e) {
|
|
23
|
+
return sendError(res, 401, "unauthorized", "Invalid or expired token");
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function requireScopes(required) {
|
|
28
|
+
return function(req, res, next) {
|
|
29
|
+
const scopes = (req.requestContext?.auth)?.scopes;
|
|
30
|
+
if (!scopes) return sendError(res, 403, "insufficient_scope", "No scopes present");
|
|
31
|
+
for (const s of required) if (!scopes.has(s)) return sendError(res, 403, "insufficient_scope", `Missing scope: ${s}`);
|
|
32
|
+
next();
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { bearerAuth, requireScopes };
|
|
38
|
+
//# sourceMappingURL=auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.mjs","names":[],"sources":["../../../src/http/middleware/auth.ts"],"sourcesContent":["import type { NextFunction, Response } from 'express'\nimport type { ObRequest } from '../router'\nimport type { OpenBadgesHttpModule } from '../OpenBadgesHttpModule'\n\nimport { getRequestContext, sendError } from '../router'\nimport { OpenBadgesTokenRepository } from '../../repository/OpenBadgesTokenRepository'\n\nexport function bearerAuth(module: OpenBadgesHttpModule) {\n return async function (req: ObRequest, res: Response, next: NextFunction) {\n const header = req.headers['authorization'] || ''\n if (!header || typeof header !== 'string' || !header.startsWith('Bearer ')) {\n return sendError(res, 401, 'unauthorized', 'Missing bearer token')\n }\n const token = header.slice('Bearer '.length)\n try {\n const { agentContext } = getRequestContext(req)\n const repo = agentContext.dependencyManager.resolve(OpenBadgesTokenRepository)\n const tokenEntry = await repo.findByToken(agentContext, token)\n if (!tokenEntry || tokenEntry.tokenType !== 'access' || tokenEntry.expiresAt.getTime() < Date.now()) {\n return sendError(res, 401, 'unauthorized', 'Invalid or expired token')\n }\n ;(req.requestContext as any).auth = {\n subject: tokenEntry.subject,\n scope: tokenEntry.scope,\n clientId: tokenEntry.clientId,\n scopes: new Set(String(tokenEntry.scope || '').split(/\\s+/).filter(Boolean)),\n }\n return next()\n } catch (_e) {\n return sendError(res, 401, 'unauthorized', 'Invalid or expired token')\n }\n }\n}\n\nexport function requireScopes(required: string[]) {\n return function (req: ObRequest, res: Response, next: NextFunction) {\n const auth = (req.requestContext as any)?.auth\n const scopes: Set<string> | undefined = auth?.scopes\n if (!scopes) return sendError(res, 403, 'insufficient_scope', 'No scopes present')\n for (const s of required) {\n if (!scopes.has(s)) return sendError(res, 403, 'insufficient_scope', `Missing scope: ${s}`)\n }\n next()\n }\n}\n"],"mappings":";;;;aAIwD;AAGxD,SAAgB,WAAW,QAA8B;AACvD,QAAO,eAAgB,KAAgB,KAAe,MAAoB;EACxE,MAAM,SAAS,IAAI,QAAQ,oBAAoB;AAC/C,MAAI,CAAC,UAAU,OAAO,WAAW,YAAY,CAAC,OAAO,WAAW,UAAU,CACxE,QAAO,UAAU,KAAK,KAAK,gBAAgB,uBAAuB;EAEpE,MAAM,QAAQ,OAAO,MAAM,EAAiB;AAC5C,MAAI;GACF,MAAM,EAAE,iBAAiB,kBAAkB,IAAI;GAE/C,MAAM,aAAa,MADN,aAAa,kBAAkB,QAAQ,0BAA0B,CAChD,YAAY,cAAc,MAAM;AAC9D,OAAI,CAAC,cAAc,WAAW,cAAc,YAAY,WAAW,UAAU,SAAS,GAAG,KAAK,KAAK,CACjG,QAAO,UAAU,KAAK,KAAK,gBAAgB,2BAA2B;AAEvE,GAAC,IAAI,eAAuB,OAAO;IAClC,SAAS,WAAW;IACpB,OAAO,WAAW;IAClB,UAAU,WAAW;IACrB,QAAQ,IAAI,IAAI,OAAO,WAAW,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,QAAQ,CAAC;IAC7E;AACD,UAAO,MAAM;WACN,IAAI;AACX,UAAO,UAAU,KAAK,KAAK,gBAAgB,2BAA2B;;;;AAK5E,SAAgB,cAAc,UAAoB;AAChD,QAAO,SAAU,KAAgB,KAAe,MAAoB;EAElE,MAAM,UADQ,IAAI,gBAAwB,OACI;AAC9C,MAAI,CAAC,OAAQ,QAAO,UAAU,KAAK,KAAK,sBAAsB,oBAAoB;AAClF,OAAK,MAAM,KAAK,SACd,KAAI,CAAC,OAAO,IAAI,EAAE,CAAE,QAAO,UAAU,KAAK,KAAK,sBAAsB,kBAAkB,IAAI;AAE7F,QAAM"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AgentContext } from "@credo-ts/core";
|
|
2
|
+
import * as express from "express";
|
|
3
|
+
import { NextFunction, Request, Response } from "express";
|
|
4
|
+
|
|
5
|
+
//#region src/http/router.d.ts
|
|
6
|
+
declare function importExpress(): typeof express;
|
|
7
|
+
type RequestContext = {
|
|
8
|
+
agentContext: AgentContext;
|
|
9
|
+
};
|
|
10
|
+
interface ObRequest<T = Record<string, unknown>> extends Request {
|
|
11
|
+
requestContext?: RequestContext & T;
|
|
12
|
+
}
|
|
13
|
+
declare function setRequestContext(agentContext: AgentContext): (req: ObRequest, _res: Response, next: NextFunction) => void;
|
|
14
|
+
declare function getRequestContext<T extends ObRequest<any>>(request: T): any;
|
|
15
|
+
declare function sendJson(res: Response, body: unknown, status?: number, contentType?: string): void;
|
|
16
|
+
declare function sendError(res: Response, status: number, error: string, error_description?: string): void;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ObRequest, RequestContext, getRequestContext, importExpress, sendError, sendJson, setRequestContext };
|
|
19
|
+
//# sourceMappingURL=router.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.mts","names":[],"sources":["../../src/http/router.ts"],"mappings":";;;;;iBAGgB,aAAA,CAAA,UAAa,OAAA;AAAA,KAUjB,cAAA;EAAmB,YAAA,EAAc,YAAA;AAAA;AAAA,UAE5B,SAAA,KAAc,MAAA,2BAAiC,OAAA;EAC9D,cAAA,GAAiB,cAAA,GAAiB,CAAA;AAAA;AAAA,iBAGpB,iBAAA,CAAkB,YAAA,EAAc,YAAA,IAC7B,GAAA,EAAK,SAAA,EAAW,IAAA,EAAM,QAAA,EAAU,IAAA,EAAM,YAAA;AAAA,iBAMzC,iBAAA,WAA4B,SAAA,MAAA,CAAgB,OAAA,EAAS,CAAA;AAAA,iBAMrD,QAAA,CAAS,GAAA,EAAK,QAAA,EAAU,IAAA,WAAe,MAAA,WAAc,WAAA;AAAA,iBAIrD,SAAA,CAAU,GAAA,EAAK,QAAA,EAAU,MAAA,UAAgB,KAAA,UAAe,iBAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __esmMin, __require } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/http/router.ts
|
|
4
|
+
function importExpress() {
|
|
5
|
+
try {
|
|
6
|
+
return __require("express");
|
|
7
|
+
} catch {
|
|
8
|
+
throw new Error("Express must be installed as a dependency to use OpenBadges HTTP module");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function setRequestContext(agentContext) {
|
|
12
|
+
return function(req, _res, next) {
|
|
13
|
+
req.requestContext = { agentContext };
|
|
14
|
+
next();
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getRequestContext(request) {
|
|
18
|
+
const ctx = request.requestContext;
|
|
19
|
+
if (!ctx) throw new Error("Request context not set");
|
|
20
|
+
return ctx;
|
|
21
|
+
}
|
|
22
|
+
function sendJson(res, body, status = 200, contentType = "application/json") {
|
|
23
|
+
res.setHeader("Content-Type", contentType).status(status).send(JSON.stringify(body));
|
|
24
|
+
}
|
|
25
|
+
function sendError(res, status, error, error_description) {
|
|
26
|
+
sendJson(res, {
|
|
27
|
+
error,
|
|
28
|
+
error_description
|
|
29
|
+
}, status);
|
|
30
|
+
}
|
|
31
|
+
var init_router = __esmMin(() => {});
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
init_router();
|
|
35
|
+
export { getRequestContext, importExpress, init_router, sendError, sendJson, setRequestContext };
|
|
36
|
+
//# sourceMappingURL=router.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.mjs","names":[],"sources":["../../src/http/router.ts"],"sourcesContent":["import type { Request, Response, NextFunction } from 'express'\nimport type { AgentContext } from '@credo-ts/core'\n\nexport function importExpress() {\n try {\n // 'express' is a peer dependency; required by the host app\n const express = require('express') as typeof import('express')\n return express\n } catch {\n throw new Error('Express must be installed as a dependency to use OpenBadges HTTP module')\n }\n}\n\nexport type RequestContext = { agentContext: AgentContext }\n\nexport interface ObRequest<T = Record<string, unknown>> extends Request {\n requestContext?: RequestContext & T\n}\n\nexport function setRequestContext(agentContext: AgentContext) {\n return function (req: ObRequest, _res: Response, next: NextFunction) {\n req.requestContext = { agentContext }\n next()\n }\n}\n\nexport function getRequestContext<T extends ObRequest<any>>(request: T) {\n const ctx = request.requestContext\n if (!ctx) throw new Error('Request context not set')\n return ctx\n}\n\nexport function sendJson(res: Response, body: unknown, status = 200, contentType = 'application/json') {\n res.setHeader('Content-Type', contentType).status(status).send(JSON.stringify(body))\n}\n\nexport function sendError(res: Response, status: number, error: string, error_description?: string) {\n sendJson(res, { error, error_description }, status)\n}\n\n"],"mappings":";;;AAGA,SAAgB,gBAAgB;AAC9B,KAAI;AAGF,mBADwB,UAAU;SAE5B;AACN,QAAM,IAAI,MAAM,0EAA0E;;;AAU9F,SAAgB,kBAAkB,cAA4B;AAC5D,QAAO,SAAU,KAAgB,MAAgB,MAAoB;AACnE,MAAI,iBAAiB,EAAE,cAAc;AACrC,QAAM;;;AAIV,SAAgB,kBAA4C,SAAY;CACtE,MAAM,MAAM,QAAQ;AACpB,KAAI,CAAC,IAAK,OAAM,IAAI,MAAM,0BAA0B;AACpD,QAAO;;AAGT,SAAgB,SAAS,KAAe,MAAe,SAAS,KAAK,cAAc,oBAAoB;AACrG,KAAI,UAAU,gBAAgB,YAAY,CAAC,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU,KAAK,CAAC;;AAGtF,SAAgB,UAAU,KAAe,QAAgB,OAAe,mBAA4B;AAClG,UAAS,KAAK;EAAE;EAAO;EAAmB,EAAE,OAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InjectionSymbols, getApiForModuleByName } from "@credo-ts/core";
|
|
2
|
+
|
|
3
|
+
//#region src/http/tenants.ts
|
|
4
|
+
const OPENID4VC_ACTOR_IDS_METADATA_KEY = "_openid4vc/openId4VcActorIds";
|
|
5
|
+
async function getAgentContextForActorId(rootAgentContext, actorId) {
|
|
6
|
+
const tenantsApi = getApiForModuleByName(rootAgentContext, "TenantsModule");
|
|
7
|
+
if (tenantsApi) {
|
|
8
|
+
const [tenant] = await tenantsApi.findTenantsByQuery({ [OPENID4VC_ACTOR_IDS_METADATA_KEY]: [actorId] });
|
|
9
|
+
if (tenant) return rootAgentContext.dependencyManager.resolve(InjectionSymbols.AgentContextProvider).getAgentContextForContextCorrelationId(`tenant-${tenant.id}`);
|
|
10
|
+
}
|
|
11
|
+
return rootAgentContext;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { getAgentContextForActorId };
|
|
16
|
+
//# sourceMappingURL=tenants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenants.mjs","names":[],"sources":["../../src/http/tenants.ts"],"sourcesContent":["import type { AgentContext, AgentContextProvider } from '@credo-ts/core'\nimport { InjectionSymbols, getApiForModuleByName } from '@credo-ts/core'\n\nconst OPENID4VC_ACTOR_IDS_METADATA_KEY = '_openid4vc/openId4VcActorIds'\n\nexport async function getAgentContextForActorId(rootAgentContext: AgentContext, actorId: string) {\n // Try to use TenantsModule if available; map actor id to tenant\n const tenantsApi = getApiForModuleByName<any>(rootAgentContext, 'TenantsModule')\n if (tenantsApi) {\n const [tenant] = await tenantsApi.findTenantsByQuery({\n [OPENID4VC_ACTOR_IDS_METADATA_KEY]: [actorId],\n })\n\n if (tenant) {\n const agentContextProvider = rootAgentContext.dependencyManager.resolve<AgentContextProvider>(\n InjectionSymbols.AgentContextProvider\n )\n return agentContextProvider.getAgentContextForContextCorrelationId(`tenant-${tenant.id}`)\n }\n }\n\n return rootAgentContext\n}\n\n"],"mappings":";;;AAGA,MAAM,mCAAmC;AAEzC,eAAsB,0BAA0B,kBAAgC,SAAiB;CAE/F,MAAM,aAAa,sBAA2B,kBAAkB,gBAAgB;AAChF,KAAI,YAAY;EACd,MAAM,CAAC,UAAU,MAAM,WAAW,mBAAmB,GAClD,mCAAmC,CAAC,QAAQ,EAC9C,CAAC;AAEF,MAAI,OAIF,QAH6B,iBAAiB,kBAAkB,QAC9D,iBAAiB,qBAClB,CAC2B,uCAAuC,UAAU,OAAO,KAAK;;AAI7F,QAAO"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/http/util/auth.ts
|
|
2
|
+
function parseBasicAuth(req) {
|
|
3
|
+
const header = req.headers["authorization"];
|
|
4
|
+
if (!header || typeof header !== "string") return null;
|
|
5
|
+
const [scheme, value] = header.split(" ");
|
|
6
|
+
if (!scheme || scheme.toLowerCase() !== "basic" || !value) return null;
|
|
7
|
+
try {
|
|
8
|
+
const decoded = Buffer.from(value, "base64").toString("utf8");
|
|
9
|
+
const idx = decoded.indexOf(":");
|
|
10
|
+
if (idx === -1) return null;
|
|
11
|
+
return {
|
|
12
|
+
clientId: decoded.slice(0, idx),
|
|
13
|
+
clientSecret: decoded.slice(idx + 1)
|
|
14
|
+
};
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function parseBodyClientAuth(req) {
|
|
20
|
+
const clientId = req.body?.client_id;
|
|
21
|
+
const clientSecret = req.body?.client_secret;
|
|
22
|
+
if (typeof clientId === "string" && typeof clientSecret === "string") return {
|
|
23
|
+
clientId,
|
|
24
|
+
clientSecret
|
|
25
|
+
};
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function isScopeSubset(requested, allowed) {
|
|
29
|
+
if (!requested) return true;
|
|
30
|
+
const reqSet = new Set(requested.split(/\s+/).filter(Boolean));
|
|
31
|
+
const allowSet = new Set((allowed ?? "").split(/\s+/).filter(Boolean));
|
|
32
|
+
for (const s of reqSet) if (!allowSet.has(s)) return false;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { isScopeSubset, parseBasicAuth, parseBodyClientAuth };
|
|
38
|
+
//# sourceMappingURL=auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.mjs","names":[],"sources":["../../../src/http/util/auth.ts"],"sourcesContent":["import type { ObRequest } from '../router'\n\nexport type BasicAuth = { clientId: string; clientSecret: string }\n\nexport function parseBasicAuth(req: ObRequest): BasicAuth | null {\n const header = req.headers['authorization']\n if (!header || typeof header !== 'string') return null\n const [scheme, value] = header.split(' ')\n if (!scheme || scheme.toLowerCase() !== 'basic' || !value) return null\n try {\n const decoded = Buffer.from(value, 'base64').toString('utf8')\n const idx = decoded.indexOf(':')\n if (idx === -1) return null\n const clientId = decoded.slice(0, idx)\n const clientSecret = decoded.slice(idx + 1)\n return { clientId, clientSecret }\n } catch {\n return null\n }\n}\n\nexport function parseBodyClientAuth(req: ObRequest): BasicAuth | null {\n const clientId = req.body?.client_id\n const clientSecret = req.body?.client_secret\n if (typeof clientId === 'string' && typeof clientSecret === 'string') return { clientId, clientSecret }\n return null\n}\n\nexport function isScopeSubset(requested: string | undefined, allowed: string | undefined) {\n if (!requested) return true\n const reqSet = new Set(requested.split(/\\s+/).filter(Boolean))\n const allowSet = new Set((allowed ?? '').split(/\\s+/).filter(Boolean))\n for (const s of reqSet) if (!allowSet.has(s)) return false\n return true\n}\n\n"],"mappings":";AAIA,SAAgB,eAAe,KAAkC;CAC/D,MAAM,SAAS,IAAI,QAAQ;AAC3B,KAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;CAClD,MAAM,CAAC,QAAQ,SAAS,OAAO,MAAM,IAAI;AACzC,KAAI,CAAC,UAAU,OAAO,aAAa,KAAK,WAAW,CAAC,MAAO,QAAO;AAClE,KAAI;EACF,MAAM,UAAU,OAAO,KAAK,OAAO,SAAS,CAAC,SAAS,OAAO;EAC7D,MAAM,MAAM,QAAQ,QAAQ,IAAI;AAChC,MAAI,QAAQ,GAAI,QAAO;AAGvB,SAAO;GAAE,UAFQ,QAAQ,MAAM,GAAG,IAAI;GAEnB,cADE,QAAQ,MAAM,MAAM,EAAE;GACV;SAC3B;AACN,SAAO;;;AAIX,SAAgB,oBAAoB,KAAkC;CACpE,MAAM,WAAW,IAAI,MAAM;CAC3B,MAAM,eAAe,IAAI,MAAM;AAC/B,KAAI,OAAO,aAAa,YAAY,OAAO,iBAAiB,SAAU,QAAO;EAAE;EAAU;EAAc;AACvG,QAAO;;AAGT,SAAgB,cAAc,WAA+B,SAA6B;AACxF,KAAI,CAAC,UAAW,QAAO;CACvB,MAAM,SAAS,IAAI,IAAI,UAAU,MAAM,MAAM,CAAC,OAAO,QAAQ,CAAC;CAC9D,MAAM,WAAW,IAAI,KAAK,WAAW,IAAI,MAAM,MAAM,CAAC,OAAO,QAAQ,CAAC;AACtE,MAAK,MAAM,KAAK,OAAQ,KAAI,CAAC,SAAS,IAAI,EAAE,CAAE,QAAO;AACrD,QAAO"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { OpenBadgesHttpModuleConfig, OpenBadgesHttpModuleConfigOptions } from "./http/OpenBadgesHttpModuleConfig.mjs";
|
|
2
|
+
import { OpenBadgesHttpModule } from "./http/OpenBadgesHttpModule.mjs";
|
|
3
|
+
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 "./cryptosuites/constants.mjs";
|
|
4
|
+
import { dataIntegrityContextMap, dataIntegrityV2Context } from "./cryptosuites/dataIntegrityV2Context.mjs";
|
|
5
|
+
import { EddsaRdfc2022Cryptosuite, EddsaRdfc2022KeyPair, EddsaRdfc2022Proof, SignOptions as SignOptions$1, VerifyOptions as VerifyOptions$1 } from "./cryptosuites/EddsaRdfc2022.mjs";
|
|
6
|
+
import { DeriveOptions, EcdsaSd2023Cryptosuite, EcdsaSd2023KeyPair, EcdsaSd2023Proof, SignOptions, VerifyOptions } from "./cryptosuites/EcdsaSd2023.mjs";
|
|
7
|
+
import { Cryptosuite, DidMethod, OpenBadgesModuleConfig, OpenBadgesModuleConfigOptions, SelectiveDisclosureConfig, StatusListConfig } from "./OpenBadgesModuleConfig.mjs";
|
|
8
|
+
import { CustomOpenBadgeCredentialTags, DefaultOpenBadgeCredentialTags, OpenBadgeCredentialRecord, OpenBadgeCredentialRecordProps } from "./repository/OpenBadgeCredentialRecord.mjs";
|
|
9
|
+
import { OpenBadgeCredentialRepository } from "./repository/OpenBadgeCredentialRepository.mjs";
|
|
10
|
+
import { EndorsementCredential, EndorsementCredentialInput, EndorsementSubject, EndorserProfile, SignedEndorsementCredential } from "./models/EndorsementCredential.mjs";
|
|
11
|
+
import { AchievementReference, Association, AssociationType, ClrCredential, ClrCredentialInput, ClrSubject, VerifiableCredentialReference, buildClrContexts, validateClrCredential } from "./models/ClrCredential.mjs";
|
|
12
|
+
import { CryptoDriver } from "./services/crypto/CryptoDriver.mjs";
|
|
13
|
+
import { ContextService } from "./services/ContextService.mjs";
|
|
14
|
+
import { DefaultOpenBadgesKeyBindingTags, OpenBadgesKeyBindingRecord, OpenBadgesKeyBindingRecordProps } from "./repository/OpenBadgesKeyBindingRecord.mjs";
|
|
15
|
+
import { OpenBadgesKeyBindingRepository } from "./repository/OpenBadgesKeyBindingRepository.mjs";
|
|
16
|
+
import { EnsureBindingOptions, KeyService, KeyType, OpenBadgesKey, SupportedDidMethod } from "./services/KeyService.mjs";
|
|
17
|
+
import { DataIntegrityService } from "./services/DataIntegrityService.mjs";
|
|
18
|
+
import { JsonLdCryptoDriver } from "./services/crypto/JsonLdCryptoDriver.mjs";
|
|
19
|
+
import { JwtService } from "./services/JwtService.mjs";
|
|
20
|
+
import { JwtCryptoDriver } from "./services/crypto/JwtCryptoDriver.mjs";
|
|
21
|
+
import { ProofService } from "./services/ProofService.mjs";
|
|
22
|
+
import { IssuerService } from "./services/IssuerService.mjs";
|
|
23
|
+
import { DefaultOpenBadgesRevocationCacheTags, OpenBadgesRevocationCacheRecord, OpenBadgesRevocationCacheRecordProps } from "./repository/OpenBadgesRevocationCacheRecord.mjs";
|
|
24
|
+
import { OpenBadgesRevocationCacheRepository } from "./repository/OpenBadgesRevocationCacheRepository.mjs";
|
|
25
|
+
import { CreateStatusListInput, DEFAULT_STATUS_LIST_CAPACITY, STATUS_LIST_2021_CONTEXT, StatusListCredential, StatusListCredentialSubject, StatusListEntry, StatusPurpose, buildStatusListContexts } from "./models/StatusListCredential.mjs";
|
|
26
|
+
import { DefaultStatusListTags, StatusListRecord, StatusListRecordProps } from "./repository/StatusListRecord.mjs";
|
|
27
|
+
import { StatusListRepository } from "./repository/StatusListRepository.mjs";
|
|
28
|
+
import { RevocationService } from "./services/RevocationService.mjs";
|
|
29
|
+
import { VerifyService } from "./services/VerifyService.mjs";
|
|
30
|
+
import { DefaultOpenBadgesServiceDescriptionTags, OpenBadgesServiceDescriptionRecord, OpenBadgesServiceDescriptionRecordProps } from "./repository/OpenBadgesServiceDescriptionRecord.mjs";
|
|
31
|
+
import { OpenBadgesServiceDescriptionRepository } from "./repository/OpenBadgesServiceDescriptionRepository.mjs";
|
|
32
|
+
import { DefaultOpenBadgesOAuthTags, OpenBadgesOAuthRecord, OpenBadgesOAuthRecordProps } from "./repository/OpenBadgesOAuthRecord.mjs";
|
|
33
|
+
import { OpenBadgesOAuthRepository } from "./repository/OpenBadgesOAuthRepository.mjs";
|
|
34
|
+
import { DefaultOpenBadgesTokenTags, OpenBadgesTokenRecord, OpenBadgesTokenRecordProps, TokenType } from "./repository/OpenBadgesTokenRecord.mjs";
|
|
35
|
+
import { OpenBadgesTokenRepository } from "./repository/OpenBadgesTokenRepository.mjs";
|
|
36
|
+
import { OAuthClient } from "./services/OAuthClient.mjs";
|
|
37
|
+
import { ConsumerService } from "./services/ConsumerService.mjs";
|
|
38
|
+
import { DidCommLinkService } from "./services/DidCommLinkService.mjs";
|
|
39
|
+
import { DisplayMapper } from "./services/DisplayMapper.mjs";
|
|
40
|
+
import { OpenBadgesApi } from "./api/OpenBadgesApi.mjs";
|
|
41
|
+
import { OpenBadgesModule } from "./OpenBadgesModule.mjs";
|
|
42
|
+
import { CLR_TYPES, CLR_V2_CONTEXT, DATA_INTEGRITY_V2_CONTEXT, DI_ECDSA_SD_2023, DI_EDDSA_RDFC_2022, ENDORSEMENT_TYPES, OBV3_CONTEXT, ONE_EDTECH_REVOCATION_LIST, REQUIRED_TYPES, STATUS_LIST_2021, VC_V2_CONTEXT } from "./constants.mjs";
|
|
43
|
+
import { DefaultOpenBadgesProfileTags, OpenBadgesProfileRecord, OpenBadgesProfileRecordProps } from "./repository/OpenBadgesProfileRecord.mjs";
|
|
44
|
+
import { OpenBadgesProfileRepository } from "./repository/OpenBadgesProfileRepository.mjs";
|
|
45
|
+
import { DefaultOpenBadgesAuthCodeTags, OpenBadgesAuthCodeRecord, OpenBadgesAuthCodeRecordProps } from "./repository/OpenBadgesAuthCodeRecord.mjs";
|
|
46
|
+
import { OpenBadgesAuthCodeRepository } from "./repository/OpenBadgesAuthCodeRepository.mjs";
|
|
47
|
+
import { DefaultOpenBadgesConsentTags, OpenBadgesConsentRecord, OpenBadgesConsentRecordProps } from "./repository/OpenBadgesConsentRecord.mjs";
|
|
48
|
+
import { OpenBadgesConsentRepository } from "./repository/OpenBadgesConsentRepository.mjs";
|
|
49
|
+
import { Achievement, AchievementCriteria, AchievementImage, AchievementValidator, Alignment, Related, ResultDescription, ValidationResult } from "./services/AchievementValidator.mjs";
|
|
50
|
+
import { ObRequest, RequestContext, getRequestContext, importExpress, sendError, sendJson, setRequestContext } from "./http/router.mjs";
|
|
51
|
+
import { JsonObject, OPENBADGES_CREDENTIAL, OPENBADGES_CREDENTIAL_DETAIL, OpenBadgesAcceptRequestFormat, OpenBadgesCredentialDetail, OpenBadgesCredentialFormat } from "./formats/OpenBadgesCredentialFormat.mjs";
|
|
52
|
+
import { OpenBadgesCredentialFormatService, extractDerivedMetadata } from "./formats/OpenBadgesCredentialFormatService.mjs";
|
|
53
|
+
import { OPENBADGES_PRESENTATION, OPENBADGES_PRESENTATION_REQUEST, OpenBadgesAcceptRequestInput, OpenBadgesPresentationRequest, OpenBadgesProofFormat } from "./formats/OpenBadgesProofFormat.mjs";
|
|
54
|
+
import { OpenBadgesProofFormatService } from "./formats/OpenBadgesProofFormatService.mjs";
|
|
55
|
+
import "./formats/index.mjs";
|
|
56
|
+
import { ValidationIssue, ensureContexts, ensureEndorsementTypes, ensureTypes, isObject, validateEndorsementEnvelope, validateObEnvelope } from "./utils/validate.mjs";
|
|
57
|
+
export { Achievement, AchievementCriteria, AchievementImage, AchievementReference, AchievementValidator, Alignment, Association, AssociationType, CLR_TYPES, CLR_V2_CONTEXT, CRYPTOSUITE_ECDSA_RDFC_2019, CRYPTOSUITE_ECDSA_SD_2023, CRYPTOSUITE_EDDSA_RDFC_2022, ClrCredential, ClrCredentialInput, ClrSubject, ConsumerService, ContextService, CreateStatusListInput, CryptoDriver, Cryptosuite, CustomOpenBadgeCredentialTags, DATA_INTEGRITY_V2_CONTEXT, DATA_INTEGRITY_V2_CONTEXT_URL, DEFAULT_STATUS_LIST_CAPACITY, DI_ECDSA_SD_2023, DI_EDDSA_RDFC_2022, DataIntegrityService, DefaultOpenBadgeCredentialTags, DefaultOpenBadgesAuthCodeTags, DefaultOpenBadgesConsentTags, DefaultOpenBadgesKeyBindingTags, DefaultOpenBadgesOAuthTags, DefaultOpenBadgesProfileTags, DefaultOpenBadgesRevocationCacheTags, DefaultOpenBadgesServiceDescriptionTags, DefaultOpenBadgesTokenTags, DefaultStatusListTags, DidCommLinkService, DidMethod, DisplayMapper, ED25519_2020_CONTEXT_URL, ENDORSEMENT_TYPES, EcdsaSd2023Cryptosuite, DeriveOptions as EcdsaSd2023DeriveOptions, EcdsaSd2023KeyPair, EcdsaSd2023Proof, SignOptions as EcdsaSd2023SignOptions, VerifyOptions as EcdsaSd2023VerifyOptions, EddsaRdfc2022Cryptosuite, EddsaRdfc2022KeyPair, EddsaRdfc2022Proof, SignOptions$1 as EddsaRdfc2022SignOptions, VerifyOptions$1 as EddsaRdfc2022VerifyOptions, EndorsementCredential, EndorsementCredentialInput, EndorsementSubject, EndorserProfile, EnsureBindingOptions, IssuerService, JsonLdCryptoDriver, JsonObject, JwtCryptoDriver, JwtService, KeyService, KeyType, MULTIKEY_CONTEXT_URL, OAuthClient, OBV3_CONTEXT, ONE_EDTECH_REVOCATION_LIST, OPENBADGES_CREDENTIAL, OPENBADGES_CREDENTIAL_DETAIL, OPENBADGES_PRESENTATION, OPENBADGES_PRESENTATION_REQUEST, ObRequest, OpenBadgeCredentialRecord, OpenBadgeCredentialRecordProps, OpenBadgeCredentialRepository, OpenBadgesAcceptRequestFormat, OpenBadgesAcceptRequestInput, OpenBadgesApi, OpenBadgesAuthCodeRecord, OpenBadgesAuthCodeRecordProps, OpenBadgesAuthCodeRepository, OpenBadgesConsentRecord, OpenBadgesConsentRecordProps, OpenBadgesConsentRepository, OpenBadgesCredentialDetail, OpenBadgesCredentialFormat, OpenBadgesCredentialFormatService, OpenBadgesHttpModule, OpenBadgesHttpModuleConfig, OpenBadgesHttpModuleConfigOptions, OpenBadgesKey, OpenBadgesKeyBindingRecord, OpenBadgesKeyBindingRecordProps, OpenBadgesKeyBindingRepository, OpenBadgesModule, OpenBadgesModuleConfig, OpenBadgesModuleConfigOptions, OpenBadgesOAuthRecord, OpenBadgesOAuthRecordProps, OpenBadgesOAuthRepository, OpenBadgesPresentationRequest, OpenBadgesProfileRecord, OpenBadgesProfileRecordProps, OpenBadgesProfileRepository, OpenBadgesProofFormat, OpenBadgesProofFormatService, OpenBadgesRevocationCacheRecord, OpenBadgesRevocationCacheRecordProps, OpenBadgesRevocationCacheRepository, OpenBadgesServiceDescriptionRecord, OpenBadgesServiceDescriptionRecordProps, OpenBadgesServiceDescriptionRepository, OpenBadgesTokenRecord, OpenBadgesTokenRecordProps, OpenBadgesTokenRepository, PROOF_TYPE_DATA_INTEGRITY, PROOF_TYPE_ED25519_2020, ProofService, REQUIRED_TYPES, Related, RequestContext, ResultDescription, RevocationService, STATUS_LIST_2021, STATUS_LIST_2021_CONTEXT, SelectiveDisclosureConfig, SignedEndorsementCredential, StatusListConfig, StatusListCredential, StatusListCredentialSubject, StatusListEntry, StatusListRecord, StatusListRecordProps, StatusListRepository, StatusPurpose, SupportedDidMethod, TokenType, VC_V2_CONTEXT, VM_TYPE_ECDSA_SECP256R1, VM_TYPE_ED25519_2020, VM_TYPE_MULTIKEY, ValidationIssue, ValidationResult, VerifiableCredentialReference, VerifyService, buildClrContexts, buildStatusListContexts, dataIntegrityContextMap, dataIntegrityV2Context, ensureContexts, ensureEndorsementTypes, ensureTypes, extractDerivedMetadata, getRequestContext, importExpress, isObject, sendError, sendJson, setRequestContext, validateClrCredential, validateEndorsementEnvelope, validateObEnvelope };
|
package/build/index.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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 "./cryptosuites/constants.mjs";
|
|
2
|
+
import { dataIntegrityContextMap, dataIntegrityV2Context } from "./cryptosuites/dataIntegrityV2Context.mjs";
|
|
3
|
+
import { EddsaRdfc2022Cryptosuite } from "./cryptosuites/EddsaRdfc2022.mjs";
|
|
4
|
+
import { EcdsaSd2023Cryptosuite } from "./cryptosuites/EcdsaSd2023.mjs";
|
|
5
|
+
import "./cryptosuites/index.mjs";
|
|
6
|
+
import { OpenBadgesModuleConfig } from "./OpenBadgesModuleConfig.mjs";
|
|
7
|
+
import { OpenBadgeCredentialRecord } from "./repository/OpenBadgeCredentialRecord.mjs";
|
|
8
|
+
import { OpenBadgeCredentialRepository } from "./repository/OpenBadgeCredentialRepository.mjs";
|
|
9
|
+
import { CLR_TYPES, CLR_V2_CONTEXT, DATA_INTEGRITY_V2_CONTEXT, DI_ECDSA_SD_2023, DI_EDDSA_RDFC_2022, ENDORSEMENT_TYPES, OBV3_CONTEXT, ONE_EDTECH_REVOCATION_LIST, REQUIRED_TYPES, STATUS_LIST_2021, VC_V2_CONTEXT } from "./constants.mjs";
|
|
10
|
+
import { ensureContexts, ensureEndorsementTypes, ensureTypes, isObject, validateEndorsementEnvelope, validateObEnvelope } from "./utils/validate.mjs";
|
|
11
|
+
import { buildClrContexts, validateClrCredential } from "./models/ClrCredential.mjs";
|
|
12
|
+
import { CryptoDriver } from "./services/crypto/CryptoDriver.mjs";
|
|
13
|
+
import { ContextService } from "./services/ContextService.mjs";
|
|
14
|
+
import { OpenBadgesKeyBindingRecord } from "./repository/OpenBadgesKeyBindingRecord.mjs";
|
|
15
|
+
import { OpenBadgesKeyBindingRepository } from "./repository/OpenBadgesKeyBindingRepository.mjs";
|
|
16
|
+
import { KeyService, KeyType } from "./services/KeyService.mjs";
|
|
17
|
+
import { DataIntegrityService } from "./services/DataIntegrityService.mjs";
|
|
18
|
+
import { JsonLdCryptoDriver } from "./services/crypto/JsonLdCryptoDriver.mjs";
|
|
19
|
+
import { JwtService } from "./services/JwtService.mjs";
|
|
20
|
+
import { JwtCryptoDriver } from "./services/crypto/JwtCryptoDriver.mjs";
|
|
21
|
+
import { ProofService } from "./services/ProofService.mjs";
|
|
22
|
+
import { IssuerService } from "./services/IssuerService.mjs";
|
|
23
|
+
import { OpenBadgesRevocationCacheRecord } from "./repository/OpenBadgesRevocationCacheRecord.mjs";
|
|
24
|
+
import { OpenBadgesRevocationCacheRepository } from "./repository/OpenBadgesRevocationCacheRepository.mjs";
|
|
25
|
+
import { StatusListRecord } from "./repository/StatusListRecord.mjs";
|
|
26
|
+
import { StatusListRepository } from "./repository/StatusListRepository.mjs";
|
|
27
|
+
import { DEFAULT_STATUS_LIST_CAPACITY, STATUS_LIST_2021_CONTEXT, buildStatusListContexts } from "./models/StatusListCredential.mjs";
|
|
28
|
+
import { RevocationService } from "./services/RevocationService.mjs";
|
|
29
|
+
import { VerifyService } from "./services/VerifyService.mjs";
|
|
30
|
+
import { OpenBadgesServiceDescriptionRecord } from "./repository/OpenBadgesServiceDescriptionRecord.mjs";
|
|
31
|
+
import { OpenBadgesServiceDescriptionRepository } from "./repository/OpenBadgesServiceDescriptionRepository.mjs";
|
|
32
|
+
import { OpenBadgesOAuthRecord, init_OpenBadgesOAuthRecord } from "./repository/OpenBadgesOAuthRecord.mjs";
|
|
33
|
+
import { OpenBadgesOAuthRepository } from "./repository/OpenBadgesOAuthRepository.mjs";
|
|
34
|
+
import { OpenBadgesTokenRecord } from "./repository/OpenBadgesTokenRecord.mjs";
|
|
35
|
+
import { OpenBadgesTokenRepository } from "./repository/OpenBadgesTokenRepository.mjs";
|
|
36
|
+
import { OAuthClient } from "./services/OAuthClient.mjs";
|
|
37
|
+
import { ConsumerService } from "./services/ConsumerService.mjs";
|
|
38
|
+
import { DidCommLinkService } from "./services/DidCommLinkService.mjs";
|
|
39
|
+
import { DisplayMapper } from "./services/DisplayMapper.mjs";
|
|
40
|
+
import { OpenBadgesApi } from "./api/OpenBadgesApi.mjs";
|
|
41
|
+
import { OpenBadgesProfileRecord } from "./repository/OpenBadgesProfileRecord.mjs";
|
|
42
|
+
import { OpenBadgesProfileRepository } from "./repository/OpenBadgesProfileRepository.mjs";
|
|
43
|
+
import { OpenBadgesAuthCodeRecord, init_OpenBadgesAuthCodeRecord } from "./repository/OpenBadgesAuthCodeRecord.mjs";
|
|
44
|
+
import { OpenBadgesAuthCodeRepository } from "./repository/OpenBadgesAuthCodeRepository.mjs";
|
|
45
|
+
import { OpenBadgesConsentRecord, init_OpenBadgesConsentRecord } from "./repository/OpenBadgesConsentRecord.mjs";
|
|
46
|
+
import { OpenBadgesConsentRepository, init_OpenBadgesConsentRepository } from "./repository/OpenBadgesConsentRepository.mjs";
|
|
47
|
+
import { AchievementValidator } from "./services/AchievementValidator.mjs";
|
|
48
|
+
import { OpenBadgesModule } from "./OpenBadgesModule.mjs";
|
|
49
|
+
import "./models/index.mjs";
|
|
50
|
+
import { getRequestContext, importExpress, init_router, sendError, sendJson, setRequestContext } from "./http/router.mjs";
|
|
51
|
+
import { OpenBadgesHttpModuleConfig } from "./http/OpenBadgesHttpModuleConfig.mjs";
|
|
52
|
+
import { OpenBadgesHttpModule } from "./http/OpenBadgesHttpModule.mjs";
|
|
53
|
+
import { OPENBADGES_CREDENTIAL, OPENBADGES_CREDENTIAL_DETAIL } from "./formats/OpenBadgesCredentialFormat.mjs";
|
|
54
|
+
import { OpenBadgesCredentialFormatService, extractDerivedMetadata } from "./formats/OpenBadgesCredentialFormatService.mjs";
|
|
55
|
+
import { OPENBADGES_PRESENTATION, OPENBADGES_PRESENTATION_REQUEST } from "./formats/OpenBadgesProofFormat.mjs";
|
|
56
|
+
import { OpenBadgesProofFormatService } from "./formats/OpenBadgesProofFormatService.mjs";
|
|
57
|
+
import "./formats/index.mjs";
|
|
58
|
+
|
|
59
|
+
//#region src/index.ts
|
|
60
|
+
init_OpenBadgesOAuthRecord();
|
|
61
|
+
init_OpenBadgesAuthCodeRecord();
|
|
62
|
+
init_OpenBadgesConsentRecord();
|
|
63
|
+
init_OpenBadgesConsentRepository();
|
|
64
|
+
init_router();
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { AchievementValidator, CLR_TYPES, CLR_V2_CONTEXT, CRYPTOSUITE_ECDSA_RDFC_2019, CRYPTOSUITE_ECDSA_SD_2023, CRYPTOSUITE_EDDSA_RDFC_2022, ConsumerService, ContextService, CryptoDriver, DATA_INTEGRITY_V2_CONTEXT, DATA_INTEGRITY_V2_CONTEXT_URL, DEFAULT_STATUS_LIST_CAPACITY, DI_ECDSA_SD_2023, DI_EDDSA_RDFC_2022, DataIntegrityService, DidCommLinkService, DisplayMapper, ED25519_2020_CONTEXT_URL, ENDORSEMENT_TYPES, EcdsaSd2023Cryptosuite, EddsaRdfc2022Cryptosuite, IssuerService, JsonLdCryptoDriver, JwtCryptoDriver, JwtService, KeyService, KeyType, MULTIKEY_CONTEXT_URL, OAuthClient, OBV3_CONTEXT, ONE_EDTECH_REVOCATION_LIST, OPENBADGES_CREDENTIAL, OPENBADGES_CREDENTIAL_DETAIL, OPENBADGES_PRESENTATION, OPENBADGES_PRESENTATION_REQUEST, OpenBadgeCredentialRecord, OpenBadgeCredentialRepository, OpenBadgesApi, OpenBadgesAuthCodeRecord, OpenBadgesAuthCodeRepository, OpenBadgesConsentRecord, OpenBadgesConsentRepository, OpenBadgesCredentialFormatService, OpenBadgesHttpModule, OpenBadgesHttpModuleConfig, OpenBadgesKeyBindingRecord, OpenBadgesKeyBindingRepository, OpenBadgesModule, OpenBadgesModuleConfig, OpenBadgesOAuthRecord, OpenBadgesOAuthRepository, OpenBadgesProfileRecord, OpenBadgesProfileRepository, OpenBadgesProofFormatService, OpenBadgesRevocationCacheRecord, OpenBadgesRevocationCacheRepository, OpenBadgesServiceDescriptionRecord, OpenBadgesServiceDescriptionRepository, OpenBadgesTokenRecord, OpenBadgesTokenRepository, PROOF_TYPE_DATA_INTEGRITY, PROOF_TYPE_ED25519_2020, ProofService, REQUIRED_TYPES, RevocationService, STATUS_LIST_2021, STATUS_LIST_2021_CONTEXT, StatusListRecord, StatusListRepository, VC_V2_CONTEXT, VM_TYPE_ECDSA_SECP256R1, VM_TYPE_ED25519_2020, VM_TYPE_MULTIKEY, VerifyService, buildClrContexts, buildStatusListContexts, dataIntegrityContextMap, dataIntegrityV2Context, ensureContexts, ensureEndorsementTypes, ensureTypes, extractDerivedMetadata, getRequestContext, importExpress, isObject, sendError, sendJson, setRequestContext, validateClrCredential, validateEndorsementEnvelope, validateObEnvelope };
|
|
68
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["// OpenBadges Module - Main exports\nexport * from './OpenBadgesModule'\nexport * from './OpenBadgesModuleConfig'\nexport * from './constants'\n\n// Models (credential types)\nexport * from './models'\n\n// Cryptosuites (OBv3 certification required)\nexport * from './cryptosuites'\n\n// API\nexport * from './api/OpenBadgesApi'\n\n// Repository - Records\nexport * from './repository/OpenBadgeCredentialRecord'\nexport * from './repository/OpenBadgeCredentialRepository'\nexport * from './repository/OpenBadgesProfileRecord'\nexport * from './repository/OpenBadgesProfileRepository'\nexport * from './repository/OpenBadgesServiceDescriptionRecord'\nexport * from './repository/OpenBadgesServiceDescriptionRepository'\nexport * from './repository/OpenBadgesOAuthRecord'\nexport * from './repository/OpenBadgesOAuthRepository'\nexport * from './repository/OpenBadgesRevocationCacheRecord'\nexport * from './repository/OpenBadgesRevocationCacheRepository'\nexport * from './repository/OpenBadgesAuthCodeRecord'\nexport * from './repository/OpenBadgesAuthCodeRepository'\nexport * from './repository/OpenBadgesTokenRecord'\nexport * from './repository/OpenBadgesTokenRepository'\nexport * from './repository/OpenBadgesConsentRecord'\nexport * from './repository/OpenBadgesConsentRepository'\nexport * from './repository/OpenBadgesKeyBindingRecord'\nexport * from './repository/OpenBadgesKeyBindingRepository'\nexport * from './repository/StatusListRecord'\nexport * from './repository/StatusListRepository'\n\n// Services\nexport * from './services/IssuerService'\nexport * from './services/VerifyService'\nexport * from './services/ConsumerService'\nexport * from './services/OAuthClient'\nexport * from './services/DidCommLinkService'\nexport * from './services/DisplayMapper'\nexport * from './services/RevocationService'\nexport * from './services/JwtService'\nexport * from './services/ProofService'\nexport * from './services/KeyService'\nexport * from './services/ContextService'\nexport * from './services/DataIntegrityService'\nexport * from './services/AchievementValidator'\nexport * from './services/crypto/CryptoDriver'\nexport * from './services/crypto/JsonLdCryptoDriver'\nexport * from './services/crypto/JwtCryptoDriver'\n\n// HTTP Module\nexport * from './http/OpenBadgesHttpModule'\nexport * from './http/OpenBadgesHttpModuleConfig'\nexport * from './http/router'\n\n// Issue Credentials v2 format extension\nexport * from './formats'\n\n// Utils\nexport * from './utils/validate'\n"],"mappings":""}
|