@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,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Context Preprocessor
|
|
4
|
+
*
|
|
5
|
+
* Strips @protected flags from JSON-LD contexts to allow combining
|
|
6
|
+
* multiple contexts that define the same terms identically.
|
|
7
|
+
*
|
|
8
|
+
* This is necessary because:
|
|
9
|
+
* - VC v2 and OBv3 contexts both define terms like "description"
|
|
10
|
+
* - Both map to the same IRIs (e.g., https://schema.org/description)
|
|
11
|
+
* - But both use @protected: true, which prevents redefinition
|
|
12
|
+
* - Stripping @protected allows compatible contexts to work together
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.createPreprocessingDocumentLoader = createPreprocessingDocumentLoader;
|
|
39
|
+
exports.clearContextCache = clearContextCache;
|
|
40
|
+
exports.prewarmContextCache = prewarmContextCache;
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
const jsonld = __importStar(require("@digitalcredentials/jsonld"));
|
|
44
|
+
// Cache for preprocessed contexts
|
|
45
|
+
const processedContextCache = {};
|
|
46
|
+
/**
|
|
47
|
+
* Recursively remove @protected from a context object
|
|
48
|
+
*/
|
|
49
|
+
function stripProtected(obj) {
|
|
50
|
+
if (obj === null || obj === undefined) {
|
|
51
|
+
return obj;
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(obj)) {
|
|
54
|
+
return obj.map(stripProtected);
|
|
55
|
+
}
|
|
56
|
+
if (typeof obj === 'object') {
|
|
57
|
+
const result = {};
|
|
58
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
59
|
+
// Skip @protected keys
|
|
60
|
+
if (key === '@protected') {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
result[key] = stripProtected(value);
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
return obj;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a document loader that preprocesses contexts to remove @protected
|
|
71
|
+
*/
|
|
72
|
+
function createPreprocessingDocumentLoader() {
|
|
73
|
+
const jld = jsonld.default ?? jsonld;
|
|
74
|
+
const nodeDocumentLoader = jld.documentLoaders?.node?.();
|
|
75
|
+
return async (url) => {
|
|
76
|
+
// Check cache first
|
|
77
|
+
if (processedContextCache[url]) {
|
|
78
|
+
return {
|
|
79
|
+
contextUrl: null,
|
|
80
|
+
document: processedContextCache[url],
|
|
81
|
+
documentUrl: url,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Fetch from network
|
|
85
|
+
if (nodeDocumentLoader) {
|
|
86
|
+
try {
|
|
87
|
+
const result = await nodeDocumentLoader(url);
|
|
88
|
+
if (result?.document) {
|
|
89
|
+
// Strip @protected from the context
|
|
90
|
+
const processed = stripProtected(result.document);
|
|
91
|
+
processedContextCache[url] = processed;
|
|
92
|
+
return {
|
|
93
|
+
contextUrl: null,
|
|
94
|
+
document: processed,
|
|
95
|
+
documentUrl: url,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.warn(`[ContextPreprocessor] Failed to fetch context: ${url}`, e?.message);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Return empty context if fetch fails
|
|
105
|
+
return {
|
|
106
|
+
contextUrl: null,
|
|
107
|
+
document: { '@context': {} },
|
|
108
|
+
documentUrl: url,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Clear the processed context cache
|
|
114
|
+
*/
|
|
115
|
+
function clearContextCache() {
|
|
116
|
+
for (const key of Object.keys(processedContextCache)) {
|
|
117
|
+
delete processedContextCache[key];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Pre-warm the context cache by fetching common contexts
|
|
122
|
+
*/
|
|
123
|
+
async function prewarmContextCache(urls) {
|
|
124
|
+
const loader = createPreprocessingDocumentLoader();
|
|
125
|
+
await Promise.all(urls.map((url) => loader(url).catch(() => null)));
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=contextPreprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextPreprocessor.js","sourceRoot":"","sources":["../../src/cryptosuites/contextPreprocessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;AAuCH,8EA2CC;AAKD,8CAIC;AAKD,kDAGC;AAjGD,6DAA6D;AAC7D,aAAa;AACb,mEAAoD;AAEpD,kCAAkC;AAClC,MAAM,qBAAqB,GAA2B,EAAE,CAAA;AAExD;;GAEG;AACH,SAAS,cAAc,CAAC,GAAY;IAClC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAChC,CAAC;IAED,IAAI,OAAO,GAAG,KAAK,QAA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,MAAM,CAAA;YACf,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,kDAAkD,GAAG,EAAE,EAAG,CAAW,EAAE,OAAO,CAAC,CAAA;YAC9F,CAAC;QACH,CAAC;QAED,sCAAsC;QACtC,OAAO;YACL,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;YAC5B,WAAW,EAAE,GAAG;SACjB,CAAA;IACH,CAAC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,CAAC;QACrD,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAA;IACnC,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,mBAAmB,CAAC,IAAc;IACtD,MAAM,MAAM,GAAG,iCAAiC,EAAE,CAAA;IAClD,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACrE,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Integrity v2 Context
|
|
3
|
+
* https://w3id.org/security/data-integrity/v2
|
|
4
|
+
*
|
|
5
|
+
* This context defines the DataIntegrityProof and related terms.
|
|
6
|
+
* Simplified without @protected to avoid conflicts when combining contexts.
|
|
7
|
+
*/
|
|
8
|
+
export declare const dataIntegrityV2Context: {
|
|
9
|
+
'@context': {
|
|
10
|
+
id: string;
|
|
11
|
+
type: string;
|
|
12
|
+
DataIntegrityProof: string;
|
|
13
|
+
challenge: string;
|
|
14
|
+
created: {
|
|
15
|
+
'@id': string;
|
|
16
|
+
'@type': string;
|
|
17
|
+
};
|
|
18
|
+
domain: string;
|
|
19
|
+
expires: {
|
|
20
|
+
'@id': string;
|
|
21
|
+
'@type': string;
|
|
22
|
+
};
|
|
23
|
+
nonce: string;
|
|
24
|
+
proofPurpose: {
|
|
25
|
+
'@id': string;
|
|
26
|
+
'@type': string;
|
|
27
|
+
};
|
|
28
|
+
assertionMethod: {
|
|
29
|
+
'@id': string;
|
|
30
|
+
'@type': string;
|
|
31
|
+
};
|
|
32
|
+
authentication: {
|
|
33
|
+
'@id': string;
|
|
34
|
+
'@type': string;
|
|
35
|
+
};
|
|
36
|
+
cryptosuite: {
|
|
37
|
+
'@id': string;
|
|
38
|
+
'@type': string;
|
|
39
|
+
};
|
|
40
|
+
proofValue: {
|
|
41
|
+
'@id': string;
|
|
42
|
+
'@type': string;
|
|
43
|
+
};
|
|
44
|
+
verificationMethod: {
|
|
45
|
+
'@id': string;
|
|
46
|
+
'@type': string;
|
|
47
|
+
};
|
|
48
|
+
previousProof: {
|
|
49
|
+
'@id': string;
|
|
50
|
+
'@type': string;
|
|
51
|
+
};
|
|
52
|
+
Multikey: string;
|
|
53
|
+
controller: {
|
|
54
|
+
'@id': string;
|
|
55
|
+
'@type': string;
|
|
56
|
+
};
|
|
57
|
+
revoked: {
|
|
58
|
+
'@id': string;
|
|
59
|
+
'@type': string;
|
|
60
|
+
};
|
|
61
|
+
publicKeyMultibase: {
|
|
62
|
+
'@id': string;
|
|
63
|
+
'@type': string;
|
|
64
|
+
};
|
|
65
|
+
secretKeyMultibase: {
|
|
66
|
+
'@id': string;
|
|
67
|
+
'@type': string;
|
|
68
|
+
};
|
|
69
|
+
proof: {
|
|
70
|
+
'@id': string;
|
|
71
|
+
'@type': string;
|
|
72
|
+
'@container': string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
declare const dataIntegrityContextMap: Map<string, {
|
|
77
|
+
'@context': {
|
|
78
|
+
id: string;
|
|
79
|
+
type: string;
|
|
80
|
+
DataIntegrityProof: string;
|
|
81
|
+
challenge: string;
|
|
82
|
+
created: {
|
|
83
|
+
'@id': string;
|
|
84
|
+
'@type': string;
|
|
85
|
+
};
|
|
86
|
+
domain: string;
|
|
87
|
+
expires: {
|
|
88
|
+
'@id': string;
|
|
89
|
+
'@type': string;
|
|
90
|
+
};
|
|
91
|
+
nonce: string;
|
|
92
|
+
proofPurpose: {
|
|
93
|
+
'@id': string;
|
|
94
|
+
'@type': string;
|
|
95
|
+
};
|
|
96
|
+
assertionMethod: {
|
|
97
|
+
'@id': string;
|
|
98
|
+
'@type': string;
|
|
99
|
+
};
|
|
100
|
+
authentication: {
|
|
101
|
+
'@id': string;
|
|
102
|
+
'@type': string;
|
|
103
|
+
};
|
|
104
|
+
cryptosuite: {
|
|
105
|
+
'@id': string;
|
|
106
|
+
'@type': string;
|
|
107
|
+
};
|
|
108
|
+
proofValue: {
|
|
109
|
+
'@id': string;
|
|
110
|
+
'@type': string;
|
|
111
|
+
};
|
|
112
|
+
verificationMethod: {
|
|
113
|
+
'@id': string;
|
|
114
|
+
'@type': string;
|
|
115
|
+
};
|
|
116
|
+
previousProof: {
|
|
117
|
+
'@id': string;
|
|
118
|
+
'@type': string;
|
|
119
|
+
};
|
|
120
|
+
Multikey: string;
|
|
121
|
+
controller: {
|
|
122
|
+
'@id': string;
|
|
123
|
+
'@type': string;
|
|
124
|
+
};
|
|
125
|
+
revoked: {
|
|
126
|
+
'@id': string;
|
|
127
|
+
'@type': string;
|
|
128
|
+
};
|
|
129
|
+
publicKeyMultibase: {
|
|
130
|
+
'@id': string;
|
|
131
|
+
'@type': string;
|
|
132
|
+
};
|
|
133
|
+
secretKeyMultibase: {
|
|
134
|
+
'@id': string;
|
|
135
|
+
'@type': string;
|
|
136
|
+
};
|
|
137
|
+
proof: {
|
|
138
|
+
'@id': string;
|
|
139
|
+
'@type': string;
|
|
140
|
+
'@container': string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
}>;
|
|
144
|
+
export { dataIntegrityContextMap };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Data Integrity v2 Context
|
|
4
|
+
* https://w3id.org/security/data-integrity/v2
|
|
5
|
+
*
|
|
6
|
+
* This context defines the DataIntegrityProof and related terms.
|
|
7
|
+
* Simplified without @protected to avoid conflicts when combining contexts.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.dataIntegrityContextMap = exports.dataIntegrityV2Context = void 0;
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
exports.dataIntegrityV2Context = {
|
|
13
|
+
'@context': {
|
|
14
|
+
id: '@id',
|
|
15
|
+
type: '@type',
|
|
16
|
+
// Data Integrity Proof terms
|
|
17
|
+
DataIntegrityProof: 'https://w3id.org/security#DataIntegrityProof',
|
|
18
|
+
challenge: 'https://w3id.org/security#challenge',
|
|
19
|
+
created: {
|
|
20
|
+
'@id': 'http://purl.org/dc/terms/created',
|
|
21
|
+
'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
|
|
22
|
+
},
|
|
23
|
+
domain: 'https://w3id.org/security#domain',
|
|
24
|
+
expires: {
|
|
25
|
+
'@id': 'https://w3id.org/security#expiration',
|
|
26
|
+
'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
|
|
27
|
+
},
|
|
28
|
+
nonce: 'https://w3id.org/security#nonce',
|
|
29
|
+
proofPurpose: {
|
|
30
|
+
'@id': 'https://w3id.org/security#proofPurpose',
|
|
31
|
+
'@type': '@vocab',
|
|
32
|
+
},
|
|
33
|
+
assertionMethod: {
|
|
34
|
+
'@id': 'https://w3id.org/security#assertionMethod',
|
|
35
|
+
'@type': '@id',
|
|
36
|
+
},
|
|
37
|
+
authentication: {
|
|
38
|
+
'@id': 'https://w3id.org/security#authenticationMethod',
|
|
39
|
+
'@type': '@id',
|
|
40
|
+
},
|
|
41
|
+
cryptosuite: {
|
|
42
|
+
'@id': 'https://w3id.org/security#cryptosuite',
|
|
43
|
+
'@type': 'https://w3id.org/security#cryptosuiteString',
|
|
44
|
+
},
|
|
45
|
+
proofValue: {
|
|
46
|
+
'@id': 'https://w3id.org/security#proofValue',
|
|
47
|
+
'@type': 'https://w3id.org/security#multibase',
|
|
48
|
+
},
|
|
49
|
+
verificationMethod: {
|
|
50
|
+
'@id': 'https://w3id.org/security#verificationMethod',
|
|
51
|
+
'@type': '@id',
|
|
52
|
+
},
|
|
53
|
+
previousProof: {
|
|
54
|
+
'@id': 'https://w3id.org/security#previousProof',
|
|
55
|
+
'@type': '@id',
|
|
56
|
+
},
|
|
57
|
+
// Multikey terms
|
|
58
|
+
Multikey: 'https://w3id.org/security#Multikey',
|
|
59
|
+
controller: {
|
|
60
|
+
'@id': 'https://w3id.org/security#controller',
|
|
61
|
+
'@type': '@id',
|
|
62
|
+
},
|
|
63
|
+
revoked: {
|
|
64
|
+
'@id': 'https://w3id.org/security#revoked',
|
|
65
|
+
'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
|
|
66
|
+
},
|
|
67
|
+
publicKeyMultibase: {
|
|
68
|
+
'@id': 'https://w3id.org/security#publicKeyMultibase',
|
|
69
|
+
'@type': 'https://w3id.org/security#multibase',
|
|
70
|
+
},
|
|
71
|
+
secretKeyMultibase: {
|
|
72
|
+
'@id': 'https://w3id.org/security#secretKeyMultibase',
|
|
73
|
+
'@type': 'https://w3id.org/security#multibase',
|
|
74
|
+
},
|
|
75
|
+
// Common terms
|
|
76
|
+
proof: {
|
|
77
|
+
'@id': 'https://w3id.org/security#proof',
|
|
78
|
+
'@type': '@id',
|
|
79
|
+
'@container': '@graph',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const dataIntegrityContextMap = new Map();
|
|
84
|
+
exports.dataIntegrityContextMap = dataIntegrityContextMap;
|
|
85
|
+
dataIntegrityContextMap.set(constants_1.DATA_INTEGRITY_V2_CONTEXT_URL, exports.dataIntegrityV2Context);
|
|
86
|
+
//# sourceMappingURL=dataIntegrityV2Context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataIntegrityV2Context.js","sourceRoot":"","sources":["../../src/cryptosuites/dataIntegrityV2Context.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,2CAA2D;AAE9C,QAAA,sBAAsB,GAAG;IACpC,UAAU,EAAE;QACV,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,OAAO;QAEb,6BAA6B;QAC7B,kBAAkB,EAAE,8CAA8C;QAClE,SAAS,EAAE,qCAAqC;QAChD,OAAO,EAAE;YACP,KAAK,EAAE,kCAAkC;YACzC,OAAO,EAAE,2CAA2C;SACrD;QACD,MAAM,EAAE,kCAAkC;QAC1C,OAAO,EAAE;YACP,KAAK,EAAE,sCAAsC;YAC7C,OAAO,EAAE,2CAA2C;SACrD;QACD,KAAK,EAAE,iCAAiC;QACxC,YAAY,EAAE;YACZ,KAAK,EAAE,wCAAwC;YAC/C,OAAO,EAAE,QAAQ;SAClB;QACD,eAAe,EAAE;YACf,KAAK,EAAE,2CAA2C;YAClD,OAAO,EAAE,KAAK;SACf;QACD,cAAc,EAAE;YACd,KAAK,EAAE,gDAAgD;YACvD,OAAO,EAAE,KAAK;SACf;QACD,WAAW,EAAE;YACX,KAAK,EAAE,uCAAuC;YAC9C,OAAO,EAAE,6CAA6C;SACvD;QACD,UAAU,EAAE;YACV,KAAK,EAAE,sCAAsC;YAC7C,OAAO,EAAE,qCAAqC;SAC/C;QACD,kBAAkB,EAAE;YAClB,KAAK,EAAE,8CAA8C;YACrD,OAAO,EAAE,KAAK;SACf;QACD,aAAa,EAAE;YACb,KAAK,EAAE,yCAAyC;YAChD,OAAO,EAAE,KAAK;SACf;QAED,iBAAiB;QACjB,QAAQ,EAAE,oCAAoC;QAC9C,UAAU,EAAE;YACV,KAAK,EAAE,sCAAsC;YAC7C,OAAO,EAAE,KAAK;SACf;QACD,OAAO,EAAE;YACP,KAAK,EAAE,mCAAmC;YAC1C,OAAO,EAAE,2CAA2C;SACrD;QACD,kBAAkB,EAAE;YAClB,KAAK,EAAE,8CAA8C;YACrD,OAAO,EAAE,qCAAqC;SAC/C;QACD,kBAAkB,EAAE;YAClB,KAAK,EAAE,8CAA8C;YACrD,OAAO,EAAE,qCAAqC;SAC/C;QAED,eAAe;QACf,KAAK,EAAE;YACL,KAAK,EAAE,iCAAiC;YACxC,OAAO,EAAE,KAAK;YACd,YAAY,EAAE,QAAQ;SACvB;KACF;CACF,CAAA;AAED,MAAM,uBAAuB,GAAG,IAAI,GAAG,EAAyC,CAAA;AAGvE,0DAAuB;AAFhC,uBAAuB,CAAC,GAAG,CAAC,yCAA6B,EAAE,8BAAsB,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenBadges 3.0 Cryptosuites
|
|
3
|
+
*
|
|
4
|
+
* This module exports the cryptosuites required for OBv3 certification:
|
|
5
|
+
* - eddsa-rdfc-2022: Ed25519 with RDFC-1.0 canonicalization
|
|
6
|
+
* - ecdsa-sd-2023: ECDSA P-256 with selective disclosure support
|
|
7
|
+
*/
|
|
8
|
+
export * from './constants';
|
|
9
|
+
export * from './dataIntegrityV2Context';
|
|
10
|
+
export { EddsaRdfc2022Cryptosuite, type EddsaRdfc2022KeyPair, type EddsaRdfc2022Proof, type SignOptions as EddsaRdfc2022SignOptions, type VerifyOptions as EddsaRdfc2022VerifyOptions, } from './EddsaRdfc2022';
|
|
11
|
+
export { EcdsaSd2023Cryptosuite, type EcdsaSd2023KeyPair, type EcdsaSd2023Proof, type SignOptions as EcdsaSd2023SignOptions, type DeriveOptions as EcdsaSd2023DeriveOptions, type VerifyOptions as EcdsaSd2023VerifyOptions, } from './EcdsaSd2023';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenBadges 3.0 Cryptosuites
|
|
4
|
+
*
|
|
5
|
+
* This module exports the cryptosuites required for OBv3 certification:
|
|
6
|
+
* - eddsa-rdfc-2022: Ed25519 with RDFC-1.0 canonicalization
|
|
7
|
+
* - ecdsa-sd-2023: ECDSA P-256 with selective disclosure support
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.EcdsaSd2023Cryptosuite = exports.EddsaRdfc2022Cryptosuite = void 0;
|
|
25
|
+
__exportStar(require("./constants"), exports);
|
|
26
|
+
__exportStar(require("./dataIntegrityV2Context"), exports);
|
|
27
|
+
// Export EddsaRdfc2022 with namespaced types
|
|
28
|
+
var EddsaRdfc2022_1 = require("./EddsaRdfc2022");
|
|
29
|
+
Object.defineProperty(exports, "EddsaRdfc2022Cryptosuite", { enumerable: true, get: function () { return EddsaRdfc2022_1.EddsaRdfc2022Cryptosuite; } });
|
|
30
|
+
// Export EcdsaSd2023 with namespaced types
|
|
31
|
+
var EcdsaSd2023_1 = require("./EcdsaSd2023");
|
|
32
|
+
Object.defineProperty(exports, "EcdsaSd2023Cryptosuite", { enumerable: true, get: function () { return EcdsaSd2023_1.EcdsaSd2023Cryptosuite; } });
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cryptosuites/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;AAEH,8CAA2B;AAC3B,2DAAwC;AAExC,6CAA6C;AAC7C,iDAMwB;AALtB,yHAAA,wBAAwB,OAAA;AAO1B,2CAA2C;AAC3C,6CAOsB;AANpB,qHAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentContext, DependencyManager, Module } from '@credo-ts/core';
|
|
2
|
+
import { OpenBadgesHttpModuleConfig, type OpenBadgesHttpModuleConfigOptions } from './OpenBadgesHttpModuleConfig';
|
|
3
|
+
export declare class OpenBadgesHttpModule implements Module {
|
|
4
|
+
readonly config: OpenBadgesHttpModuleConfig;
|
|
5
|
+
constructor(options: OpenBadgesHttpModuleConfigOptions);
|
|
6
|
+
register(dependencyManager: DependencyManager): void;
|
|
7
|
+
initialize(agentContext: AgentContext): Promise<void>;
|
|
8
|
+
private configureRouter;
|
|
9
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.OpenBadgesHttpModule = void 0;
|
|
27
|
+
const core_1 = require("@credo-ts/core");
|
|
28
|
+
const router_1 = require("./router");
|
|
29
|
+
const OpenBadgesHttpModuleConfig_1 = require("./OpenBadgesHttpModuleConfig");
|
|
30
|
+
const serviceDescription_1 = require("./endpoints/serviceDescription");
|
|
31
|
+
const jwks_1 = require("./endpoints/jwks");
|
|
32
|
+
const registration_1 = require("./endpoints/registration");
|
|
33
|
+
const authorize_1 = require("./endpoints/authorize");
|
|
34
|
+
const token_1 = require("./endpoints/token");
|
|
35
|
+
const revoke_1 = require("./endpoints/revoke");
|
|
36
|
+
const introspect_1 = require("./endpoints/introspect");
|
|
37
|
+
const did_1 = require("./endpoints/did");
|
|
38
|
+
const profile_1 = require("./endpoints/profile");
|
|
39
|
+
const credentials_1 = require("./endpoints/credentials");
|
|
40
|
+
const statusList_1 = require("./endpoints/statusList");
|
|
41
|
+
const refresh_1 = require("./endpoints/refresh");
|
|
42
|
+
class OpenBadgesHttpModule {
|
|
43
|
+
constructor(options) {
|
|
44
|
+
this.config = new OpenBadgesHttpModuleConfig_1.OpenBadgesHttpModuleConfig(options);
|
|
45
|
+
}
|
|
46
|
+
register(dependencyManager) {
|
|
47
|
+
dependencyManager.resolve(core_1.AgentConfig).logger.info('[OB][HTTP] Registering OpenBadgesHttpModule');
|
|
48
|
+
// Expose the module instance via DI if needed in the future
|
|
49
|
+
dependencyManager.registerInstance(OpenBadgesHttpModule, this);
|
|
50
|
+
}
|
|
51
|
+
async initialize(agentContext) {
|
|
52
|
+
this.configureRouter(agentContext);
|
|
53
|
+
}
|
|
54
|
+
configureRouter(rootAgentContext) {
|
|
55
|
+
const { json, urlencoded, Router } = (0, router_1.importExpress)();
|
|
56
|
+
const contextRouter = this.config.router;
|
|
57
|
+
const endpointRouter = this.config.useTenantRouting ? Router() : contextRouter;
|
|
58
|
+
// parse application/x-www-form-urlencoded & json
|
|
59
|
+
contextRouter.use(urlencoded({ extended: false }));
|
|
60
|
+
contextRouter.use(json());
|
|
61
|
+
if (this.config.useTenantRouting) {
|
|
62
|
+
contextRouter.param(this.config.actorParamName, async (req, res, next, actorId) => {
|
|
63
|
+
if (!actorId)
|
|
64
|
+
return res.status(404).send('Not found');
|
|
65
|
+
try {
|
|
66
|
+
const { getAgentContextForActorId } = await Promise.resolve().then(() => __importStar(require('./tenants')));
|
|
67
|
+
const agentContext = await getAgentContextForActorId(rootAgentContext, actorId);
|
|
68
|
+
req.requestContext = { agentContext };
|
|
69
|
+
next();
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
await rootAgentContext.endSession();
|
|
73
|
+
return res.status(404).send('Not found');
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
contextRouter.use(`/:${this.config.actorParamName}`, endpointRouter);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Attach request context for single-tenant
|
|
80
|
+
contextRouter.use((0, router_1.setRequestContext)(rootAgentContext));
|
|
81
|
+
}
|
|
82
|
+
// Endpoints
|
|
83
|
+
(0, serviceDescription_1.configureServiceDescriptionEndpoint)(endpointRouter, this.config);
|
|
84
|
+
(0, jwks_1.configureJwksEndpoint)(endpointRouter, this.config);
|
|
85
|
+
(0, did_1.configureDidDocumentEndpoint)(endpointRouter, this.config);
|
|
86
|
+
(0, registration_1.configureRegistrationEndpoint)(endpointRouter, this.config);
|
|
87
|
+
(0, authorize_1.configureAuthorizeEndpoint)(endpointRouter, this);
|
|
88
|
+
(0, token_1.configureTokenEndpoint)(endpointRouter, this);
|
|
89
|
+
(0, revoke_1.configureRevokeEndpoint)(endpointRouter, this);
|
|
90
|
+
(0, introspect_1.configureIntrospectEndpoint)(endpointRouter, this);
|
|
91
|
+
// Consent endpoint for dev/simple flows
|
|
92
|
+
const { configureConsentEndpoint } = require('./endpoints/consent');
|
|
93
|
+
configureConsentEndpoint(endpointRouter, this);
|
|
94
|
+
(0, profile_1.configureProfileEndpoints)(endpointRouter, this.config, this);
|
|
95
|
+
(0, credentials_1.configureCredentialsEndpoints)(endpointRouter, this.config, this);
|
|
96
|
+
(0, statusList_1.configureStatusListEndpoint)(endpointRouter, this.config, this);
|
|
97
|
+
(0, refresh_1.configureRefreshEndpoint)(endpointRouter, this.config, this);
|
|
98
|
+
// End session middleware for tenant contexts
|
|
99
|
+
contextRouter.use(async (req, _res, next) => {
|
|
100
|
+
const agentContext = req.requestContext?.agentContext;
|
|
101
|
+
if (agentContext && agentContext !== rootAgentContext) {
|
|
102
|
+
await agentContext.endSession().catch(() => { });
|
|
103
|
+
}
|
|
104
|
+
next();
|
|
105
|
+
});
|
|
106
|
+
// Error fallthrough safeguard
|
|
107
|
+
contextRouter.use(async (err, req, res, next) => {
|
|
108
|
+
if (!res.headersSent) {
|
|
109
|
+
res.status(500).json({ error: 'server_error', error_description: 'Unexpected error' });
|
|
110
|
+
}
|
|
111
|
+
const agentContext = req.requestContext?.agentContext;
|
|
112
|
+
if (agentContext && agentContext !== rootAgentContext) {
|
|
113
|
+
await agentContext.endSession().catch(() => { });
|
|
114
|
+
}
|
|
115
|
+
next(err);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.OpenBadgesHttpModule = OpenBadgesHttpModule;
|
|
120
|
+
//# sourceMappingURL=OpenBadgesHttpModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenBadg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AE,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC,CAAA;YACxF,CAAC;YACD,MAAM,YAAY,GAAI,GAAW,CAAC,cAAc,EAAE,YAAY,CAAA;YAC9D,IAAI,YAAY,IAAI,YAAY,KAAK,gBAAgB,EAAE,CAAC;gBACtD,MAAM,YAAY,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YACjD,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,CAAA;QACX,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAnFD,oDAmFC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Router } from 'express';
|
|
2
|
+
export type OpenBadgesHttpModuleConfigOptions = {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
router?: Router;
|
|
5
|
+
defaultSubjectId?: string;
|
|
6
|
+
providerName?: string;
|
|
7
|
+
privacyPolicyUrl?: string;
|
|
8
|
+
termsOfServiceUrl?: string;
|
|
9
|
+
requireConsent?: boolean;
|
|
10
|
+
useTenantRouting?: boolean;
|
|
11
|
+
actorParamName?: string;
|
|
12
|
+
didWebId?: string;
|
|
13
|
+
endpoints?: {
|
|
14
|
+
discovery?: string;
|
|
15
|
+
jwks?: string;
|
|
16
|
+
didDocument?: string;
|
|
17
|
+
registration?: string;
|
|
18
|
+
authorize?: string;
|
|
19
|
+
token?: string;
|
|
20
|
+
revoke?: string;
|
|
21
|
+
introspect?: string;
|
|
22
|
+
consent?: string;
|
|
23
|
+
profile?: string;
|
|
24
|
+
credentials?: string;
|
|
25
|
+
statusList?: string;
|
|
26
|
+
refresh?: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare class OpenBadgesHttpModuleConfig {
|
|
30
|
+
private readonly options;
|
|
31
|
+
readonly router: Router;
|
|
32
|
+
constructor(options: OpenBadgesHttpModuleConfigOptions);
|
|
33
|
+
get baseUrl(): string;
|
|
34
|
+
get defaultSubjectId(): string | undefined;
|
|
35
|
+
get discoveryPath(): string;
|
|
36
|
+
get jwksPath(): string;
|
|
37
|
+
get didDocumentPath(): string;
|
|
38
|
+
get registrationPath(): string;
|
|
39
|
+
get authorizePath(): string;
|
|
40
|
+
get tokenPath(): string;
|
|
41
|
+
get revokePath(): string;
|
|
42
|
+
get introspectPath(): string;
|
|
43
|
+
get profilePath(): string;
|
|
44
|
+
get credentialsPath(): string;
|
|
45
|
+
get providerName(): string | undefined;
|
|
46
|
+
get privacyPolicyUrl(): string | undefined;
|
|
47
|
+
get termsOfServiceUrl(): string | undefined;
|
|
48
|
+
get requireConsent(): boolean;
|
|
49
|
+
get useTenantRouting(): boolean;
|
|
50
|
+
get actorParamName(): string;
|
|
51
|
+
get didWebId(): string | undefined;
|
|
52
|
+
get consentPath(): string;
|
|
53
|
+
get statusListPath(): string;
|
|
54
|
+
get refreshPath(): string;
|
|
55
|
+
}
|