@ajna-inc/openbadges 0.1.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/build/OpenBadgesModule.d.ts +10 -0
- package/build/OpenBadgesModule.js +75 -0
- package/build/OpenBadgesModule.js.map +1 -0
- package/build/OpenBadgesModuleConfig.d.ts +96 -0
- package/build/OpenBadgesModuleConfig.js +50 -0
- package/build/OpenBadgesModuleConfig.js.map +1 -0
- package/build/api/OpenBadgesApi.d.ts +48 -0
- package/build/api/OpenBadgesApi.js +81 -0
- package/build/api/OpenBadgesApi.js.map +1 -0
- package/build/api/index.d.ts +1 -0
- package/build/api/index.js +18 -0
- package/build/api/index.js.map +1 -0
- package/build/constants.d.ts +12 -0
- package/build/constants.js +27 -0
- package/build/constants.js.map +1 -0
- package/build/cryptosuites/EcdsaSd2023.d.ts +143 -0
- package/build/cryptosuites/EcdsaSd2023.js +518 -0
- package/build/cryptosuites/EcdsaSd2023.js.map +1 -0
- package/build/cryptosuites/EddsaRdfc2022.d.ts +112 -0
- package/build/cryptosuites/EddsaRdfc2022.js +356 -0
- package/build/cryptosuites/EddsaRdfc2022.js.map +1 -0
- package/build/cryptosuites/constants.d.ts +14 -0
- package/build/cryptosuites/constants.js +22 -0
- package/build/cryptosuites/constants.js.map +1 -0
- package/build/cryptosuites/contextPreprocessor.d.ts +24 -0
- package/build/cryptosuites/contextPreprocessor.js +127 -0
- package/build/cryptosuites/contextPreprocessor.js.map +1 -0
- package/build/cryptosuites/dataIntegrityV2Context.d.ts +144 -0
- package/build/cryptosuites/dataIntegrityV2Context.js +86 -0
- package/build/cryptosuites/dataIntegrityV2Context.js.map +1 -0
- package/build/cryptosuites/index.d.ts +11 -0
- package/build/cryptosuites/index.js +33 -0
- package/build/cryptosuites/index.js.map +1 -0
- package/build/http/OpenBadgesHttpModule.d.ts +9 -0
- package/build/http/OpenBadgesHttpModule.js +120 -0
- package/build/http/OpenBadgesHttpModule.js.map +1 -0
- package/build/http/OpenBadgesHttpModuleConfig.d.ts +55 -0
- package/build/http/OpenBadgesHttpModuleConfig.js +78 -0
- package/build/http/OpenBadgesHttpModuleConfig.js.map +1 -0
- package/build/http/endpoints/authorize.d.ts +3 -0
- package/build/http/endpoints/authorize.js +79 -0
- package/build/http/endpoints/authorize.js.map +1 -0
- package/build/http/endpoints/consent.d.ts +3 -0
- package/build/http/endpoints/consent.js +25 -0
- package/build/http/endpoints/consent.js.map +1 -0
- package/build/http/endpoints/credentials.d.ts +4 -0
- package/build/http/endpoints/credentials.js +85 -0
- package/build/http/endpoints/credentials.js.map +1 -0
- package/build/http/endpoints/did.d.ts +3 -0
- package/build/http/endpoints/did.js +48 -0
- package/build/http/endpoints/did.js.map +1 -0
- package/build/http/endpoints/introspect.d.ts +3 -0
- package/build/http/endpoints/introspect.js +37 -0
- package/build/http/endpoints/introspect.js.map +1 -0
- package/build/http/endpoints/jwks.d.ts +3 -0
- package/build/http/endpoints/jwks.js +46 -0
- package/build/http/endpoints/jwks.js.map +1 -0
- package/build/http/endpoints/profile.d.ts +4 -0
- package/build/http/endpoints/profile.js +58 -0
- package/build/http/endpoints/profile.js.map +1 -0
- package/build/http/endpoints/refresh.d.ts +15 -0
- package/build/http/endpoints/refresh.js +134 -0
- package/build/http/endpoints/refresh.js.map +1 -0
- package/build/http/endpoints/registration.d.ts +3 -0
- package/build/http/endpoints/registration.js +42 -0
- package/build/http/endpoints/registration.js.map +1 -0
- package/build/http/endpoints/revoke.d.ts +3 -0
- package/build/http/endpoints/revoke.js +38 -0
- package/build/http/endpoints/revoke.js.map +1 -0
- package/build/http/endpoints/serviceDescription.d.ts +3 -0
- package/build/http/endpoints/serviceDescription.js +52 -0
- package/build/http/endpoints/serviceDescription.js.map +1 -0
- package/build/http/endpoints/statusList.d.ts +10 -0
- package/build/http/endpoints/statusList.js +95 -0
- package/build/http/endpoints/statusList.js.map +1 -0
- package/build/http/endpoints/token.d.ts +3 -0
- package/build/http/endpoints/token.js +147 -0
- package/build/http/endpoints/token.js.map +1 -0
- package/build/http/middleware/auth.d.ts +5 -0
- package/build/http/middleware/auth.js +48 -0
- package/build/http/middleware/auth.js.map +1 -0
- package/build/http/router.d.ts +13 -0
- package/build/http/router.js +36 -0
- package/build/http/router.js.map +1 -0
- package/build/http/tenants.d.ts +2 -0
- package/build/http/tenants.js +20 -0
- package/build/http/tenants.js.map +1 -0
- package/build/http/util/auth.d.ts +8 -0
- package/build/http/util/auth.js +43 -0
- package/build/http/util/auth.js.map +1 -0
- package/build/index.d.ts +46 -0
- package/build/index.js +71 -0
- package/build/index.js.map +1 -0
- package/build/models/ClrCredential.d.ts +112 -0
- package/build/models/ClrCredential.js +52 -0
- package/build/models/ClrCredential.js.map +1 -0
- package/build/models/EndorsementCredential.d.ts +89 -0
- package/build/models/EndorsementCredential.js +11 -0
- package/build/models/EndorsementCredential.js.map +1 -0
- package/build/models/StatusListCredential.d.ts +81 -0
- package/build/models/StatusListCredential.js +28 -0
- package/build/models/StatusListCredential.js.map +1 -0
- package/build/models/index.d.ts +8 -0
- package/build/models/index.js +25 -0
- package/build/models/index.js.map +1 -0
- package/build/repository/OpenBadgeCredentialRecord.d.ts +44 -0
- package/build/repository/OpenBadgeCredentialRecord.js +46 -0
- package/build/repository/OpenBadgeCredentialRecord.js.map +1 -0
- package/build/repository/OpenBadgeCredentialRepository.d.ts +8 -0
- package/build/repository/OpenBadgeCredentialRepository.js +38 -0
- package/build/repository/OpenBadgeCredentialRepository.js.map +1 -0
- package/build/repository/OpenBadgesAuthCodeRecord.d.ts +35 -0
- package/build/repository/OpenBadgesAuthCodeRecord.js +28 -0
- package/build/repository/OpenBadgesAuthCodeRecord.js.map +1 -0
- package/build/repository/OpenBadgesAuthCodeRepository.d.ts +6 -0
- package/build/repository/OpenBadgesAuthCodeRepository.js +32 -0
- package/build/repository/OpenBadgesAuthCodeRepository.js.map +1 -0
- package/build/repository/OpenBadgesConsentRecord.d.ts +24 -0
- package/build/repository/OpenBadgesConsentRecord.js +23 -0
- package/build/repository/OpenBadgesConsentRecord.js.map +1 -0
- package/build/repository/OpenBadgesConsentRepository.d.ts +6 -0
- package/build/repository/OpenBadgesConsentRepository.js +32 -0
- package/build/repository/OpenBadgesConsentRepository.js.map +1 -0
- package/build/repository/OpenBadgesKeyBindingRecord.d.ts +24 -0
- package/build/repository/OpenBadgesKeyBindingRecord.js +32 -0
- package/build/repository/OpenBadgesKeyBindingRecord.js.map +1 -0
- package/build/repository/OpenBadgesKeyBindingRepository.d.ts +7 -0
- package/build/repository/OpenBadgesKeyBindingRepository.js +35 -0
- package/build/repository/OpenBadgesKeyBindingRepository.js.map +1 -0
- package/build/repository/OpenBadgesOAuthRecord.d.ts +35 -0
- package/build/repository/OpenBadgesOAuthRecord.js +25 -0
- package/build/repository/OpenBadgesOAuthRecord.js.map +1 -0
- package/build/repository/OpenBadgesOAuthRepository.d.ts +8 -0
- package/build/repository/OpenBadgesOAuthRepository.js +38 -0
- package/build/repository/OpenBadgesOAuthRepository.js.map +1 -0
- package/build/repository/OpenBadgesProfileRecord.d.ts +21 -0
- package/build/repository/OpenBadgesProfileRecord.js +22 -0
- package/build/repository/OpenBadgesProfileRecord.js.map +1 -0
- package/build/repository/OpenBadgesProfileRepository.d.ts +6 -0
- package/build/repository/OpenBadgesProfileRepository.js +32 -0
- package/build/repository/OpenBadgesProfileRepository.js.map +1 -0
- package/build/repository/OpenBadgesRevocationCacheRecord.d.ts +23 -0
- package/build/repository/OpenBadgesRevocationCacheRecord.js +23 -0
- package/build/repository/OpenBadgesRevocationCacheRecord.js.map +1 -0
- package/build/repository/OpenBadgesRevocationCacheRepository.d.ts +6 -0
- package/build/repository/OpenBadgesRevocationCacheRepository.js +32 -0
- package/build/repository/OpenBadgesRevocationCacheRepository.js.map +1 -0
- package/build/repository/OpenBadgesServiceDescriptionRecord.d.ts +21 -0
- package/build/repository/OpenBadgesServiceDescriptionRecord.js +22 -0
- package/build/repository/OpenBadgesServiceDescriptionRecord.js.map +1 -0
- package/build/repository/OpenBadgesServiceDescriptionRepository.d.ts +6 -0
- package/build/repository/OpenBadgesServiceDescriptionRepository.js +32 -0
- package/build/repository/OpenBadgesServiceDescriptionRepository.js.map +1 -0
- package/build/repository/OpenBadgesTokenRecord.d.ts +39 -0
- package/build/repository/OpenBadgesTokenRecord.js +36 -0
- package/build/repository/OpenBadgesTokenRecord.js.map +1 -0
- package/build/repository/OpenBadgesTokenRepository.d.ts +9 -0
- package/build/repository/OpenBadgesTokenRepository.js +45 -0
- package/build/repository/OpenBadgesTokenRepository.js.map +1 -0
- package/build/repository/StatusListRecord.d.ts +49 -0
- package/build/repository/StatusListRecord.js +47 -0
- package/build/repository/StatusListRecord.js.map +1 -0
- package/build/repository/StatusListRepository.d.ts +24 -0
- package/build/repository/StatusListRepository.js +52 -0
- package/build/repository/StatusListRepository.js.map +1 -0
- package/build/repository/index.d.ts +18 -0
- package/build/repository/index.js +35 -0
- package/build/repository/index.js.map +1 -0
- package/build/services/AchievementValidator.d.ts +158 -0
- package/build/services/AchievementValidator.js +238 -0
- package/build/services/AchievementValidator.js.map +1 -0
- package/build/services/ConsumerService.d.ts +24 -0
- package/build/services/ConsumerService.js +143 -0
- package/build/services/ConsumerService.js.map +1 -0
- package/build/services/ContextService.d.ts +14 -0
- package/build/services/ContextService.js +54 -0
- package/build/services/ContextService.js.map +1 -0
- package/build/services/DataIntegrityService.d.ts +51 -0
- package/build/services/DataIntegrityService.js +134 -0
- package/build/services/DataIntegrityService.js.map +1 -0
- package/build/services/DidCommLinkService.d.ts +7 -0
- package/build/services/DidCommLinkService.js +20 -0
- package/build/services/DidCommLinkService.js.map +1 -0
- package/build/services/DisplayMapper.d.ts +9 -0
- package/build/services/DisplayMapper.js +26 -0
- package/build/services/DisplayMapper.js.map +1 -0
- package/build/services/IssuerService.d.ts +38 -0
- package/build/services/IssuerService.js +225 -0
- package/build/services/IssuerService.js.map +1 -0
- package/build/services/JwtService.d.ts +19 -0
- package/build/services/JwtService.js +229 -0
- package/build/services/JwtService.js.map +1 -0
- package/build/services/KeyService.d.ts +102 -0
- package/build/services/KeyService.js +439 -0
- package/build/services/KeyService.js.map +1 -0
- package/build/services/OAuthClient.d.ts +26 -0
- package/build/services/OAuthClient.js +127 -0
- package/build/services/OAuthClient.js.map +1 -0
- package/build/services/ProofService.d.ts +15 -0
- package/build/services/ProofService.js +43 -0
- package/build/services/ProofService.js.map +1 -0
- package/build/services/RevocationService.d.ts +59 -0
- package/build/services/RevocationService.js +319 -0
- package/build/services/RevocationService.js.map +1 -0
- package/build/services/VerifyService.d.ts +17 -0
- package/build/services/VerifyService.js +54 -0
- package/build/services/VerifyService.js.map +1 -0
- package/build/services/crypto/CryptoDriver.d.ts +9 -0
- package/build/services/crypto/CryptoDriver.js +7 -0
- package/build/services/crypto/CryptoDriver.js.map +1 -0
- package/build/services/crypto/JsonLdCryptoDriver.d.ts +17 -0
- package/build/services/crypto/JsonLdCryptoDriver.js +45 -0
- package/build/services/crypto/JsonLdCryptoDriver.js.map +1 -0
- package/build/services/crypto/JwtCryptoDriver.d.ts +13 -0
- package/build/services/crypto/JwtCryptoDriver.js +42 -0
- package/build/services/crypto/JwtCryptoDriver.js.map +1 -0
- package/build/services/index.d.ts +12 -0
- package/build/services/index.js +29 -0
- package/build/services/index.js.map +1 -0
- package/build/utils/validate.d.ts +17 -0
- package/build/utils/validate.js +107 -0
- package/build/utils/validate.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bearerAuth = bearerAuth;
|
|
4
|
+
exports.requireScopes = requireScopes;
|
|
5
|
+
const router_1 = require("../router");
|
|
6
|
+
const OpenBadgesTokenRepository_1 = require("../../repository/OpenBadgesTokenRepository");
|
|
7
|
+
function bearerAuth(module) {
|
|
8
|
+
return async function (req, res, next) {
|
|
9
|
+
const header = req.headers['authorization'] || '';
|
|
10
|
+
if (!header || typeof header !== 'string' || !header.startsWith('Bearer ')) {
|
|
11
|
+
return (0, router_1.sendError)(res, 401, 'unauthorized', 'Missing bearer token');
|
|
12
|
+
}
|
|
13
|
+
const token = header.slice('Bearer '.length);
|
|
14
|
+
try {
|
|
15
|
+
const { agentContext } = (0, router_1.getRequestContext)(req);
|
|
16
|
+
const repo = agentContext.dependencyManager.resolve(OpenBadgesTokenRepository_1.OpenBadgesTokenRepository);
|
|
17
|
+
const tokenEntry = await repo.findByToken(agentContext, token);
|
|
18
|
+
if (!tokenEntry || tokenEntry.tokenType !== 'access' || tokenEntry.expiresAt.getTime() < Date.now()) {
|
|
19
|
+
return (0, router_1.sendError)(res, 401, 'unauthorized', 'Invalid or expired token');
|
|
20
|
+
}
|
|
21
|
+
;
|
|
22
|
+
req.requestContext.auth = {
|
|
23
|
+
subject: tokenEntry.subject,
|
|
24
|
+
scope: tokenEntry.scope,
|
|
25
|
+
clientId: tokenEntry.clientId,
|
|
26
|
+
scopes: new Set(String(tokenEntry.scope || '').split(/\s+/).filter(Boolean)),
|
|
27
|
+
};
|
|
28
|
+
return next();
|
|
29
|
+
}
|
|
30
|
+
catch (_e) {
|
|
31
|
+
return (0, router_1.sendError)(res, 401, 'unauthorized', 'Invalid or expired token');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function requireScopes(required) {
|
|
36
|
+
return function (req, res, next) {
|
|
37
|
+
const auth = req.requestContext?.auth;
|
|
38
|
+
const scopes = auth?.scopes;
|
|
39
|
+
if (!scopes)
|
|
40
|
+
return (0, router_1.sendError)(res, 403, 'insufficient_scope', 'No scopes present');
|
|
41
|
+
for (const s of required) {
|
|
42
|
+
if (!scopes.has(s))
|
|
43
|
+
return (0, router_1.sendError)(res, 403, 'insufficient_scope', `Missing scope: ${s}`);
|
|
44
|
+
}
|
|
45
|
+
next();
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 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AAU,CAAC,KAAK;gBACvB,QAAQ,EAAE,UAAU,CAAC,QAAQ;gBAC7B,MAAM,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;aAC7E,CAAA;YACD,OAAO,IAAI,EAAE,CAAA;QACf,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,OAAO,IAAA,kBAAS,EAAC,GAAG,EAAE,GAAG,EAAE,cAAc,EAAE,0BAA0B,CAAC,CAAA;QACxE,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED,SAAgB,aAAa,CAAC,QAAkB;IAC9C,OAAO,UAAU,GAAc,EAAE,GAAa,EAAE,IAAkB;QAChE,MAAM,IAAI,GAAI,GAAG,CAAC,cAAsB,EAAE,IAAI,CAAA;QAC9C,MAAM,MAAM,GAA4B,IAAI,EAAE,MAAM,CAAA;QACpD,IAAI,CAAC,MAAM;YAAE,OAAO,IAAA,kBAAS,EAAC,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAE,mBAAmB,CAAC,CAAA;QAClF,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,OAAO,IAAA,kBAAS,EAAC,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAE,kBAAkB,CAAC,EAAE,CAAC,CAAA;QAC7F,CAAC;QACD,IAAI,EAAE,CAAA;IACR,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Request, Response, NextFunction } from 'express';
|
|
2
|
+
import type { AgentContext } from '@credo-ts/core';
|
|
3
|
+
export declare function importExpress(): typeof import("express");
|
|
4
|
+
export type RequestContext = {
|
|
5
|
+
agentContext: AgentContext;
|
|
6
|
+
};
|
|
7
|
+
export interface ObRequest<T = Record<string, unknown>> extends Request {
|
|
8
|
+
requestContext?: RequestContext & T;
|
|
9
|
+
}
|
|
10
|
+
export declare function setRequestContext(agentContext: AgentContext): (req: ObRequest, _res: Response, next: NextFunction) => void;
|
|
11
|
+
export declare function getRequestContext<T extends ObRequest<any>>(request: T): any;
|
|
12
|
+
export declare function sendJson(res: Response, body: unknown, status?: number, contentType?: string): void;
|
|
13
|
+
export declare function sendError(res: Response, status: number, error: string, error_description?: string): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importExpress = importExpress;
|
|
4
|
+
exports.setRequestContext = setRequestContext;
|
|
5
|
+
exports.getRequestContext = getRequestContext;
|
|
6
|
+
exports.sendJson = sendJson;
|
|
7
|
+
exports.sendError = sendError;
|
|
8
|
+
function importExpress() {
|
|
9
|
+
try {
|
|
10
|
+
// 'express' is a peer dependency; required by the host app
|
|
11
|
+
const express = require('express');
|
|
12
|
+
return express;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new Error('Express must be installed as a dependency to use OpenBadges HTTP module');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function setRequestContext(agentContext) {
|
|
19
|
+
return function (req, _res, next) {
|
|
20
|
+
req.requestContext = { agentContext };
|
|
21
|
+
next();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getRequestContext(request) {
|
|
25
|
+
const ctx = request.requestContext;
|
|
26
|
+
if (!ctx)
|
|
27
|
+
throw new Error('Request context not set');
|
|
28
|
+
return ctx;
|
|
29
|
+
}
|
|
30
|
+
function sendJson(res, body, status = 200, contentType = 'application/json') {
|
|
31
|
+
res.setHeader('Content-Type', contentType).status(status).send(JSON.stringify(body));
|
|
32
|
+
}
|
|
33
|
+
function sendError(res, status, error, error_description) {
|
|
34
|
+
sendJson(res, { error, error_description }, status);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=router.js.map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@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAgentContextForActorId = getAgentContextForActorId;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const OPENID4VC_ACTOR_IDS_METADATA_KEY = '_openid4vc/openId4VcActorIds';
|
|
6
|
+
async function getAgentContextForActorId(rootAgentContext, actorId) {
|
|
7
|
+
// Try to use TenantsModule if available; map actor id to tenant
|
|
8
|
+
const tenantsApi = (0, core_1.getApiForModuleByName)(rootAgentContext, 'TenantsModule');
|
|
9
|
+
if (tenantsApi) {
|
|
10
|
+
const [tenant] = await tenantsApi.findTenantsByQuery({
|
|
11
|
+
[OPENID4VC_ACTOR_IDS_METADATA_KEY]: [actorId],
|
|
12
|
+
});
|
|
13
|
+
if (tenant) {
|
|
14
|
+
const agentContextProvider = rootAgentContext.dependencyManager.resolve(core_1.InjectionSymbols.AgentContextProvider);
|
|
15
|
+
return agentContextProvider.getAgentContextForContextCorrelationId(`tenant-${tenant.id}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return rootAgentContext;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=tenants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenants.js","sourceRoot":"","sources":["../../src/http/tenants.ts"],"names":[],"mappings":";;AAKA,8DAiBC;AArBD,yCAAwE;AAExE,MAAM,gCAAgC,GAAG,8BAA8B,CAAA;AAEhE,KAAK,UAAU,yBAAyB,CAAC,gBAA8B,EAAE,OAAe;IAC7F,gEAAgE;IAChE,MAAM,UAAU,GAAG,IAAA,4BAAqB,EAAM,gBAAgB,EAAE,eAAe,CAAC,CAAA;IAChF,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;YACnD,CAAC,gCAAgC,CAAC,EAAE,CAAC,OAAO,CAAC;SAC9C,CAAC,CAAA;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,CACrE,uBAAgB,CAAC,oBAAoB,CACtC,CAAA;YACD,OAAO,oBAAoB,CAAC,sCAAsC,CAAC,UAAU,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;QAC3F,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ObRequest } from '../router';
|
|
2
|
+
export type BasicAuth = {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientSecret: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function parseBasicAuth(req: ObRequest): BasicAuth | null;
|
|
7
|
+
export declare function parseBodyClientAuth(req: ObRequest): BasicAuth | null;
|
|
8
|
+
export declare function isScopeSubset(requested: string | undefined, allowed: string | undefined): boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseBasicAuth = parseBasicAuth;
|
|
4
|
+
exports.parseBodyClientAuth = parseBodyClientAuth;
|
|
5
|
+
exports.isScopeSubset = isScopeSubset;
|
|
6
|
+
function parseBasicAuth(req) {
|
|
7
|
+
const header = req.headers['authorization'];
|
|
8
|
+
if (!header || typeof header !== 'string')
|
|
9
|
+
return null;
|
|
10
|
+
const [scheme, value] = header.split(' ');
|
|
11
|
+
if (!scheme || scheme.toLowerCase() !== 'basic' || !value)
|
|
12
|
+
return null;
|
|
13
|
+
try {
|
|
14
|
+
const decoded = Buffer.from(value, 'base64').toString('utf8');
|
|
15
|
+
const idx = decoded.indexOf(':');
|
|
16
|
+
if (idx === -1)
|
|
17
|
+
return null;
|
|
18
|
+
const clientId = decoded.slice(0, idx);
|
|
19
|
+
const clientSecret = decoded.slice(idx + 1);
|
|
20
|
+
return { clientId, clientSecret };
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function parseBodyClientAuth(req) {
|
|
27
|
+
const clientId = req.body?.client_id;
|
|
28
|
+
const clientSecret = req.body?.client_secret;
|
|
29
|
+
if (typeof clientId === 'string' && typeof clientSecret === 'string')
|
|
30
|
+
return { clientId, clientSecret };
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function isScopeSubset(requested, allowed) {
|
|
34
|
+
if (!requested)
|
|
35
|
+
return true;
|
|
36
|
+
const reqSet = new Set(requested.split(/\s+/).filter(Boolean));
|
|
37
|
+
const allowSet = new Set((allowed ?? '').split(/\s+/).filter(Boolean));
|
|
38
|
+
for (const s of reqSet)
|
|
39
|
+
if (!allowSet.has(s))
|
|
40
|
+
return false;
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/http/util/auth.ts"],"names":[],"mappings":";;AAIA,wCAeC;AAED,kDAKC;AAED,sCAMC;AA9BD,SAAgB,cAAc,CAAC,GAAc;IAC3C,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IAC3C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IACtD,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACzC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,OAAO,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACtE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC7D,MAAM,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d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export * from './OpenBadgesModule';
|
|
2
|
+
export * from './OpenBadgesModuleConfig';
|
|
3
|
+
export * from './constants';
|
|
4
|
+
export * from './models';
|
|
5
|
+
export * from './cryptosuites';
|
|
6
|
+
export * from './api/OpenBadgesApi';
|
|
7
|
+
export * from './repository/OpenBadgeCredentialRecord';
|
|
8
|
+
export * from './repository/OpenBadgeCredentialRepository';
|
|
9
|
+
export * from './repository/OpenBadgesProfileRecord';
|
|
10
|
+
export * from './repository/OpenBadgesProfileRepository';
|
|
11
|
+
export * from './repository/OpenBadgesServiceDescriptionRecord';
|
|
12
|
+
export * from './repository/OpenBadgesServiceDescriptionRepository';
|
|
13
|
+
export * from './repository/OpenBadgesOAuthRecord';
|
|
14
|
+
export * from './repository/OpenBadgesOAuthRepository';
|
|
15
|
+
export * from './repository/OpenBadgesRevocationCacheRecord';
|
|
16
|
+
export * from './repository/OpenBadgesRevocationCacheRepository';
|
|
17
|
+
export * from './repository/OpenBadgesAuthCodeRecord';
|
|
18
|
+
export * from './repository/OpenBadgesAuthCodeRepository';
|
|
19
|
+
export * from './repository/OpenBadgesTokenRecord';
|
|
20
|
+
export * from './repository/OpenBadgesTokenRepository';
|
|
21
|
+
export * from './repository/OpenBadgesConsentRecord';
|
|
22
|
+
export * from './repository/OpenBadgesConsentRepository';
|
|
23
|
+
export * from './repository/OpenBadgesKeyBindingRecord';
|
|
24
|
+
export * from './repository/OpenBadgesKeyBindingRepository';
|
|
25
|
+
export * from './repository/StatusListRecord';
|
|
26
|
+
export * from './repository/StatusListRepository';
|
|
27
|
+
export * from './services/IssuerService';
|
|
28
|
+
export * from './services/VerifyService';
|
|
29
|
+
export * from './services/ConsumerService';
|
|
30
|
+
export * from './services/OAuthClient';
|
|
31
|
+
export * from './services/DidCommLinkService';
|
|
32
|
+
export * from './services/DisplayMapper';
|
|
33
|
+
export * from './services/RevocationService';
|
|
34
|
+
export * from './services/JwtService';
|
|
35
|
+
export * from './services/ProofService';
|
|
36
|
+
export * from './services/KeyService';
|
|
37
|
+
export * from './services/ContextService';
|
|
38
|
+
export * from './services/DataIntegrityService';
|
|
39
|
+
export * from './services/AchievementValidator';
|
|
40
|
+
export * from './services/crypto/CryptoDriver';
|
|
41
|
+
export * from './services/crypto/JsonLdCryptoDriver';
|
|
42
|
+
export * from './services/crypto/JwtCryptoDriver';
|
|
43
|
+
export * from './http/OpenBadgesHttpModule';
|
|
44
|
+
export * from './http/OpenBadgesHttpModuleConfig';
|
|
45
|
+
export * from './http/router';
|
|
46
|
+
export * from './utils/validate';
|
package/build/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// OpenBadges Module - Main exports
|
|
18
|
+
__exportStar(require("./OpenBadgesModule"), exports);
|
|
19
|
+
__exportStar(require("./OpenBadgesModuleConfig"), exports);
|
|
20
|
+
__exportStar(require("./constants"), exports);
|
|
21
|
+
// Models (credential types)
|
|
22
|
+
__exportStar(require("./models"), exports);
|
|
23
|
+
// Cryptosuites (OBv3 certification required)
|
|
24
|
+
__exportStar(require("./cryptosuites"), exports);
|
|
25
|
+
// API
|
|
26
|
+
__exportStar(require("./api/OpenBadgesApi"), exports);
|
|
27
|
+
// Repository - Records
|
|
28
|
+
__exportStar(require("./repository/OpenBadgeCredentialRecord"), exports);
|
|
29
|
+
__exportStar(require("./repository/OpenBadgeCredentialRepository"), exports);
|
|
30
|
+
__exportStar(require("./repository/OpenBadgesProfileRecord"), exports);
|
|
31
|
+
__exportStar(require("./repository/OpenBadgesProfileRepository"), exports);
|
|
32
|
+
__exportStar(require("./repository/OpenBadgesServiceDescriptionRecord"), exports);
|
|
33
|
+
__exportStar(require("./repository/OpenBadgesServiceDescriptionRepository"), exports);
|
|
34
|
+
__exportStar(require("./repository/OpenBadgesOAuthRecord"), exports);
|
|
35
|
+
__exportStar(require("./repository/OpenBadgesOAuthRepository"), exports);
|
|
36
|
+
__exportStar(require("./repository/OpenBadgesRevocationCacheRecord"), exports);
|
|
37
|
+
__exportStar(require("./repository/OpenBadgesRevocationCacheRepository"), exports);
|
|
38
|
+
__exportStar(require("./repository/OpenBadgesAuthCodeRecord"), exports);
|
|
39
|
+
__exportStar(require("./repository/OpenBadgesAuthCodeRepository"), exports);
|
|
40
|
+
__exportStar(require("./repository/OpenBadgesTokenRecord"), exports);
|
|
41
|
+
__exportStar(require("./repository/OpenBadgesTokenRepository"), exports);
|
|
42
|
+
__exportStar(require("./repository/OpenBadgesConsentRecord"), exports);
|
|
43
|
+
__exportStar(require("./repository/OpenBadgesConsentRepository"), exports);
|
|
44
|
+
__exportStar(require("./repository/OpenBadgesKeyBindingRecord"), exports);
|
|
45
|
+
__exportStar(require("./repository/OpenBadgesKeyBindingRepository"), exports);
|
|
46
|
+
__exportStar(require("./repository/StatusListRecord"), exports);
|
|
47
|
+
__exportStar(require("./repository/StatusListRepository"), exports);
|
|
48
|
+
// Services
|
|
49
|
+
__exportStar(require("./services/IssuerService"), exports);
|
|
50
|
+
__exportStar(require("./services/VerifyService"), exports);
|
|
51
|
+
__exportStar(require("./services/ConsumerService"), exports);
|
|
52
|
+
__exportStar(require("./services/OAuthClient"), exports);
|
|
53
|
+
__exportStar(require("./services/DidCommLinkService"), exports);
|
|
54
|
+
__exportStar(require("./services/DisplayMapper"), exports);
|
|
55
|
+
__exportStar(require("./services/RevocationService"), exports);
|
|
56
|
+
__exportStar(require("./services/JwtService"), exports);
|
|
57
|
+
__exportStar(require("./services/ProofService"), exports);
|
|
58
|
+
__exportStar(require("./services/KeyService"), exports);
|
|
59
|
+
__exportStar(require("./services/ContextService"), exports);
|
|
60
|
+
__exportStar(require("./services/DataIntegrityService"), exports);
|
|
61
|
+
__exportStar(require("./services/AchievementValidator"), exports);
|
|
62
|
+
__exportStar(require("./services/crypto/CryptoDriver"), exports);
|
|
63
|
+
__exportStar(require("./services/crypto/JsonLdCryptoDriver"), exports);
|
|
64
|
+
__exportStar(require("./services/crypto/JwtCryptoDriver"), exports);
|
|
65
|
+
// HTTP Module
|
|
66
|
+
__exportStar(require("./http/OpenBadgesHttpModule"), exports);
|
|
67
|
+
__exportStar(require("./http/OpenBadgesHttpModuleConfig"), exports);
|
|
68
|
+
__exportStar(require("./http/router"), exports);
|
|
69
|
+
// Utils
|
|
70
|
+
__exportStar(require("./utils/validate"), exports);
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mCAAmC;AACnC,qDAAkC;AAClC,2DAAwC;AACxC,8CAA2B;AAE3B,4BAA4B;AAC5B,2CAAwB;AAExB,6CAA6C;AAC7C,iDAA8B;AAE9B,MAAM;AACN,sDAAmC;AAEnC,uBAAuB;AACvB,yEAAsD;AACtD,6EAA0D;AAC1D,uEAAoD;AACpD,2EAAwD;AACxD,kFAA+D;AAC/D,sFAAmE;AACnE,qEAAkD;AAClD,yEAAsD;AACtD,+EAA4D;AAC5D,mFAAgE;AAChE,wEAAqD;AACrD,4EAAyD;AACzD,qEAAkD;AAClD,yEAAsD;AACtD,uEAAoD;AACpD,2EAAwD;AACxD,0EAAuD;AACvD,8EAA2D;AAC3D,gEAA6C;AAC7C,oEAAiD;AAEjD,WAAW;AACX,2DAAwC;AACxC,2DAAwC;AACxC,6DAA0C;AAC1C,yDAAsC;AACtC,gEAA6C;AAC7C,2DAAwC;AACxC,+DAA4C;AAC5C,wDAAqC;AACrC,0DAAuC;AACvC,wDAAqC;AACrC,4DAAyC;AACzC,kEAA+C;AAC/C,kEAA+C;AAC/C,iEAA8C;AAC9C,uEAAoD;AACpD,oEAAiD;AAEjD,cAAc;AACd,8DAA2C;AAC3C,oEAAiD;AACjD,gDAA6B;AAE7B,QAAQ;AACR,mDAAgC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLR 2.0 (Comprehensive Learner Record) Credential Types
|
|
3
|
+
*
|
|
4
|
+
* A ClrCredential bundles multiple OpenBadgeCredentials into a single
|
|
5
|
+
* verifiable credential representing a learner's complete achievement record.
|
|
6
|
+
*
|
|
7
|
+
* Spec: https://www.imsglobal.org/spec/clr/v2p0
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The subject of a CLR credential - represents the learner
|
|
11
|
+
*/
|
|
12
|
+
export interface ClrSubject {
|
|
13
|
+
id: string;
|
|
14
|
+
type: 'ClrSubject';
|
|
15
|
+
verifiableCredential: VerifiableCredentialReference[];
|
|
16
|
+
achievement?: AchievementReference[];
|
|
17
|
+
association?: Association[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A reference to or embedded verifiable credential
|
|
21
|
+
*/
|
|
22
|
+
export interface VerifiableCredentialReference {
|
|
23
|
+
'@context'?: string | string[];
|
|
24
|
+
type: string[];
|
|
25
|
+
id?: string;
|
|
26
|
+
issuer: string | {
|
|
27
|
+
id: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
validFrom?: string;
|
|
31
|
+
validUntil?: string;
|
|
32
|
+
credentialSubject: Record<string, unknown>;
|
|
33
|
+
proof?: Record<string, unknown>;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Summary reference to an achievement
|
|
38
|
+
*/
|
|
39
|
+
export interface AchievementReference {
|
|
40
|
+
id: string;
|
|
41
|
+
type: 'Achievement';
|
|
42
|
+
name: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
achievementType?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Association between credentials in a CLR
|
|
48
|
+
*/
|
|
49
|
+
export interface Association {
|
|
50
|
+
type: 'Association';
|
|
51
|
+
associationType: AssociationType;
|
|
52
|
+
sourceCredentialId: string;
|
|
53
|
+
targetCredentialId: string;
|
|
54
|
+
}
|
|
55
|
+
export type AssociationType = 'isChildOf' | 'isParentOf' | 'isRelatedTo' | 'replacedBy' | 'precedes' | 'isEqualTo';
|
|
56
|
+
/**
|
|
57
|
+
* Input for creating a CLR credential
|
|
58
|
+
*/
|
|
59
|
+
export interface ClrCredentialInput {
|
|
60
|
+
/** Optional credential ID (auto-generated if not provided) */
|
|
61
|
+
id?: string;
|
|
62
|
+
/** The learner's identifier (DID or URL) */
|
|
63
|
+
learnerId: string;
|
|
64
|
+
/** The issuer's profile (DID or profile object) */
|
|
65
|
+
issuerProfile: string | {
|
|
66
|
+
id: string;
|
|
67
|
+
type?: 'Profile';
|
|
68
|
+
name?: string;
|
|
69
|
+
description?: string;
|
|
70
|
+
url?: string;
|
|
71
|
+
image?: string;
|
|
72
|
+
};
|
|
73
|
+
/** Array of OpenBadgeCredentials to include */
|
|
74
|
+
verifiableCredentials: VerifiableCredentialReference[];
|
|
75
|
+
/** Optional associations between credentials */
|
|
76
|
+
associations?: Association[];
|
|
77
|
+
/** Verification method for signing */
|
|
78
|
+
verificationMethod: string;
|
|
79
|
+
/** Optional validity dates */
|
|
80
|
+
validFrom?: string;
|
|
81
|
+
validUntil?: string;
|
|
82
|
+
/** Optional name for the CLR */
|
|
83
|
+
name?: string;
|
|
84
|
+
/** Optional description */
|
|
85
|
+
description?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The full CLR credential structure
|
|
89
|
+
*/
|
|
90
|
+
export interface ClrCredential {
|
|
91
|
+
'@context': string[];
|
|
92
|
+
type: ['VerifiableCredential', 'ClrCredential'];
|
|
93
|
+
id: string;
|
|
94
|
+
issuer: string | {
|
|
95
|
+
id: string;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
};
|
|
98
|
+
validFrom: string;
|
|
99
|
+
validUntil?: string;
|
|
100
|
+
name?: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
credentialSubject: ClrSubject;
|
|
103
|
+
proof?: Record<string, unknown>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Build the @context array for a CLR credential
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildClrContexts(): string[];
|
|
109
|
+
/**
|
|
110
|
+
* Validate a CLR credential structure
|
|
111
|
+
*/
|
|
112
|
+
export declare function validateClrCredential(credential: Partial<ClrCredential>): string[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLR 2.0 (Comprehensive Learner Record) Credential Types
|
|
4
|
+
*
|
|
5
|
+
* A ClrCredential bundles multiple OpenBadgeCredentials into a single
|
|
6
|
+
* verifiable credential representing a learner's complete achievement record.
|
|
7
|
+
*
|
|
8
|
+
* Spec: https://www.imsglobal.org/spec/clr/v2p0
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.buildClrContexts = buildClrContexts;
|
|
12
|
+
exports.validateClrCredential = validateClrCredential;
|
|
13
|
+
const constants_1 = require("../constants");
|
|
14
|
+
/**
|
|
15
|
+
* Build the @context array for a CLR credential
|
|
16
|
+
*/
|
|
17
|
+
function buildClrContexts() {
|
|
18
|
+
return [constants_1.VC_V2_CONTEXT, constants_1.CLR_V2_CONTEXT];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Validate a CLR credential structure
|
|
22
|
+
*/
|
|
23
|
+
function validateClrCredential(credential) {
|
|
24
|
+
const errors = [];
|
|
25
|
+
// Check required fields
|
|
26
|
+
if (!credential['@context']) {
|
|
27
|
+
errors.push('Missing @context');
|
|
28
|
+
}
|
|
29
|
+
if (!credential.type?.includes('ClrCredential')) {
|
|
30
|
+
errors.push('type must include ClrCredential');
|
|
31
|
+
}
|
|
32
|
+
if (!credential.issuer) {
|
|
33
|
+
errors.push('Missing issuer');
|
|
34
|
+
}
|
|
35
|
+
if (!credential.credentialSubject) {
|
|
36
|
+
errors.push('Missing credentialSubject');
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const subject = credential.credentialSubject;
|
|
40
|
+
if (!subject.id) {
|
|
41
|
+
errors.push('credentialSubject.id is required');
|
|
42
|
+
}
|
|
43
|
+
if (subject.type !== 'ClrSubject') {
|
|
44
|
+
errors.push('credentialSubject.type must be ClrSubject');
|
|
45
|
+
}
|
|
46
|
+
if (!Array.isArray(subject.verifiableCredential) || subject.verifiableCredential.length === 0) {
|
|
47
|
+
errors.push('credentialSubject.verifiableCredential must be a non-empty array');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return errors;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=ClrCredential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClrCredential.js","sourceRoot":"","sources":["../../src/models/ClrCredential.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AA8GH,4CAEC;AAKD,sDAmCC;AAtJD,4CAA4D;AAyG5D;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,CAAC,yBAAa,EAAE,0BAAc,CAAC,CAAA;AACxC,CAAC;AAED;;GAEG;AACH,SAAg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+
* to provide external endorsement of achievements, profiles, or other credentials.
|
|
6
|
+
*
|
|
7
|
+
* @see https://www.imsglobal.org/spec/ob/v3p0/#endorsementcredential
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The subject of an endorsement - what is being endorsed
|
|
11
|
+
*/
|
|
12
|
+
export interface EndorsementSubject {
|
|
13
|
+
/** The ID of the entity being endorsed (DID or URL) */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Must be 'EndorsementSubject' */
|
|
16
|
+
type: 'EndorsementSubject';
|
|
17
|
+
/** Optional comment explaining the endorsement */
|
|
18
|
+
endorsementComment?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Profile information for the endorser (issuer of the endorsement)
|
|
22
|
+
*/
|
|
23
|
+
export interface EndorserProfile {
|
|
24
|
+
/** DID or URL identifying the endorser */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Must include 'Profile' */
|
|
27
|
+
type?: 'Profile' | ['Profile', ...string[]];
|
|
28
|
+
/** Name of the endorsing organization/individual */
|
|
29
|
+
name?: string;
|
|
30
|
+
/** Description of the endorser */
|
|
31
|
+
description?: string;
|
|
32
|
+
/** URL to the endorser's website */
|
|
33
|
+
url?: string;
|
|
34
|
+
/** Image representing the endorser */
|
|
35
|
+
image?: string | {
|
|
36
|
+
id: string;
|
|
37
|
+
type?: 'Image';
|
|
38
|
+
};
|
|
39
|
+
/** Email of the endorser */
|
|
40
|
+
email?: string;
|
|
41
|
+
/** Phone number of the endorser */
|
|
42
|
+
phone?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Input for creating an EndorsementCredential
|
|
46
|
+
*/
|
|
47
|
+
export interface EndorsementCredentialInput {
|
|
48
|
+
/** The entity being endorsed (DID or URL) - becomes credentialSubject.id */
|
|
49
|
+
endorsedEntity: string;
|
|
50
|
+
/** Optional comment explaining the endorsement */
|
|
51
|
+
endorsementComment?: string;
|
|
52
|
+
/** Profile information for the endorser (becomes the issuer) */
|
|
53
|
+
issuerProfile: EndorserProfile;
|
|
54
|
+
/** Verification method ID for signing */
|
|
55
|
+
verificationMethod: string;
|
|
56
|
+
/** ISO 8601 date string when the endorsement becomes valid */
|
|
57
|
+
validFrom?: string;
|
|
58
|
+
/** ISO 8601 date string when the endorsement expires */
|
|
59
|
+
validUntil?: string;
|
|
60
|
+
/** Optional credential ID (auto-generated if not provided) */
|
|
61
|
+
id?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Full EndorsementCredential structure (unsigned)
|
|
65
|
+
*/
|
|
66
|
+
export interface EndorsementCredential {
|
|
67
|
+
'@context': string[];
|
|
68
|
+
type: ['VerifiableCredential', 'EndorsementCredential'];
|
|
69
|
+
id: string;
|
|
70
|
+
issuer: EndorserProfile;
|
|
71
|
+
validFrom: string;
|
|
72
|
+
validUntil?: string;
|
|
73
|
+
credentialSubject: EndorsementSubject;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Signed EndorsementCredential with proof
|
|
77
|
+
*/
|
|
78
|
+
export interface SignedEndorsementCredential extends EndorsementCredential {
|
|
79
|
+
proof: {
|
|
80
|
+
type: string;
|
|
81
|
+
cryptosuite?: string;
|
|
82
|
+
created: string;
|
|
83
|
+
verificationMethod: string;
|
|
84
|
+
proofPurpose: string;
|
|
85
|
+
proofValue: string;
|
|
86
|
+
challenge?: string;
|
|
87
|
+
domain?: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* EndorsementCredential Types
|
|
4
|
+
*
|
|
5
|
+
* EndorsementCredentials are third-party validation credentials used in OpenBadges 3.0
|
|
6
|
+
* to provide external endorsement of achievements, profiles, or other credentials.
|
|
7
|
+
*
|
|
8
|
+
* @see https://www.imsglobal.org/spec/ob/v3p0/#endorsementcredential
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
//# sourceMappingURL=EndorsementCredential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndorsementCredential.js","sourceRoot":"","sources":["../../src/models/EndorsementCredential.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG"}
|