@bluestep-systems/b6p-core 0.9.0 → 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/README.md +264 -25
- package/dist/B6PCore.d.ts +7 -0
- package/dist/B6PCore.js +54 -1
- package/dist/B6PCore.js.map +1 -1
- package/dist/B6PUri.d.ts +6 -8
- package/dist/B6PUri.js +6 -8
- package/dist/B6PUri.js.map +1 -1
- package/dist/Err.d.ts +415 -0
- package/dist/Err.js +552 -0
- package/dist/Err.js.map +1 -1
- package/dist/auth/BearerAuthProvider.d.ts +32 -0
- package/dist/auth/BearerAuthProvider.js +49 -0
- package/dist/auth/BearerAuthProvider.js.map +1 -1
- package/dist/cache/OrgCache.js.map +1 -1
- package/dist/cache/ScriptMetaDataStore.js.map +1 -1
- package/dist/constants/ApiEndpoints.d.ts +1 -0
- package/dist/constants/ApiEndpoints.js +1 -0
- package/dist/constants/ApiEndpoints.js.map +1 -1
- package/dist/constants/AuthTypes.js.map +1 -1
- package/dist/constants/BlueHQ.js.map +1 -1
- package/dist/constants/CryptoAlgorithms.js.map +1 -1
- package/dist/constants/ExtensionConfig.js.map +1 -1
- package/dist/constants/FileExtensions.js.map +1 -1
- package/dist/constants/FolderNames.js.map +1 -1
- package/dist/constants/Gateway.d.ts +71 -0
- package/dist/constants/Gateway.js +79 -0
- package/dist/constants/Gateway.js.map +1 -0
- package/dist/constants/GitHubUrls.js.map +1 -1
- package/dist/constants/Http.js.map +1 -1
- package/dist/constants/MimeTypes.js.map +1 -1
- package/dist/constants/Numerical.js.map +1 -1
- package/dist/constants/OutputChannels.js.map +1 -1
- package/dist/constants/SettingsKeys.d.ts +5 -0
- package/dist/constants/SettingsKeys.js +5 -0
- package/dist/constants/SettingsKeys.js.map +1 -1
- package/dist/constants/SpecialFiles.js.map +1 -1
- package/dist/constants/WebDAVElements.js.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +3 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/data/DownstairsPathParser.js.map +1 -1
- package/dist/data/GlobMatcher.js.map +1 -1
- package/dist/data/IdUtility.js.map +1 -1
- package/dist/data/OrgWorker.js.map +1 -1
- package/dist/data/ScriptKey.js.map +1 -1
- package/dist/data/ScriptUrlParser.js.map +1 -1
- package/dist/data/ServerVersion.d.ts +76 -0
- package/dist/data/ServerVersion.js +111 -0
- package/dist/data/ServerVersion.js.map +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.js +7 -1
- package/dist/data/index.js.map +1 -1
- package/dist/gateway/GatewayClient.d.ts +147 -0
- package/dist/gateway/GatewayClient.js +395 -0
- package/dist/gateway/GatewayClient.js.map +1 -0
- package/dist/gateway/GatewayContext.d.ts +43 -0
- package/dist/gateway/GatewayContext.js +3 -0
- package/dist/gateway/GatewayContext.js.map +1 -0
- package/dist/gateway/GatewayGit.d.ts +291 -0
- package/dist/gateway/GatewayGit.js +731 -0
- package/dist/gateway/GatewayGit.js.map +1 -0
- package/dist/gateway/GatewayKb.d.ts +173 -0
- package/dist/gateway/GatewayKb.js +354 -0
- package/dist/gateway/GatewayKb.js.map +1 -0
- package/dist/gateway/GatewayMarketplace.d.ts +116 -0
- package/dist/gateway/GatewayMarketplace.js +278 -0
- package/dist/gateway/GatewayMarketplace.js.map +1 -0
- package/dist/gateway/GatewayService.d.ts +47 -0
- package/dist/gateway/GatewayService.js +54 -0
- package/dist/gateway/GatewayService.js.map +1 -0
- package/dist/gateway/GatewayToken.d.ts +18 -0
- package/dist/gateway/GatewayToken.js +43 -0
- package/dist/gateway/GatewayToken.js.map +1 -0
- package/dist/gateway/GatewayTokenService.d.ts +101 -0
- package/dist/gateway/GatewayTokenService.js +465 -0
- package/dist/gateway/GatewayTokenService.js.map +1 -0
- package/dist/index.d.ts +24 -9
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/dist/network/HttpClient.js.map +1 -1
- package/dist/network/HttpClientProvider.js.map +1 -1
- package/dist/network/StatusCodes.js.map +1 -1
- package/dist/persistence/PersistablePseudoMap.js.map +1 -1
- package/dist/persistence/PersistenceKeys.js.map +1 -1
- package/dist/persistence/PrivatePersistanceMap.js.map +1 -1
- package/dist/persistence/PseudoMap.js.map +1 -1
- package/dist/persistence/PublicPersistanceMap.js.map +1 -1
- package/dist/persistence/Serializable.js.map +1 -1
- package/dist/persistence/SharedFilePersistence.d.ts +22 -0
- package/dist/persistence/SharedFilePersistence.js +65 -14
- package/dist/persistence/SharedFilePersistence.js.map +1 -1
- package/dist/persistence/TypedMap.js.map +1 -1
- package/dist/persistence/TypedPersistable.js.map +1 -1
- package/dist/persistence/TypedPrivatePersistable.js.map +1 -1
- package/dist/persistence/dirLockdown.js.map +1 -1
- package/dist/providers.d.ts +36 -19
- package/dist/script/GitIdentity.js.map +1 -1
- package/dist/script/GitSync.d.ts +78 -11
- package/dist/script/GitSync.js +84 -17
- package/dist/script/GitSync.js.map +1 -1
- package/dist/script/ScriptContext.d.ts +1 -8
- package/dist/script/ScriptFactory.d.ts +1 -2
- package/dist/script/ScriptFactory.js +1 -2
- package/dist/script/ScriptFactory.js.map +1 -1
- package/dist/script/ScriptFile.js.map +1 -1
- package/dist/script/ScriptFolder.js.map +1 -1
- package/dist/script/ScriptNode.js.map +1 -1
- package/dist/script/ScriptRoot.d.ts +0 -63
- package/dist/script/ScriptRoot.js +0 -178
- package/dist/script/ScriptRoot.js.map +1 -1
- package/dist/script/ScriptService.d.ts +45 -11
- package/dist/script/ScriptService.js +44 -6
- package/dist/script/ScriptService.js.map +1 -1
- package/dist/script/ServerCompile.d.ts +35 -0
- package/dist/script/ServerCompile.js +40 -0
- package/dist/script/ServerCompile.js.map +1 -0
- package/dist/script/TsConfig.d.ts +2 -2
- package/dist/script/TsConfig.js +3 -3
- package/dist/script/TsConfig.js.map +1 -1
- package/dist/script/push.d.ts +117 -77
- package/dist/script/push.js +151 -170
- package/dist/script/push.js.map +1 -1
- package/dist/session/SessionManager.js.map +1 -1
- package/dist/testing/FakeGateway.d.ts +280 -0
- package/dist/testing/FakeGateway.js +627 -0
- package/dist/testing/FakeGateway.js.map +1 -0
- package/dist/testing/MockFileSystem.js.map +1 -1
- package/dist/types.d.ts +332 -0
- package/dist/update/UpdateService.js.map +1 -1
- package/package.json +8 -7
- package/dist/script/ScriptTranspiler.d.ts +0 -183
- package/dist/script/ScriptTranspiler.js +0 -425
- package/dist/script/ScriptTranspiler.js.map +0 -1
- package/dist/script/TsLibResolver.d.ts +0 -60
- package/dist/script/TsLibResolver.js +0 -134
- package/dist/script/TsLibResolver.js.map +0 -1
|
@@ -0,0 +1,627 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FakeGateway = void 0;
|
|
37
|
+
const node_crypto_1 = require("node:crypto");
|
|
38
|
+
const http = __importStar(require("node:http"));
|
|
39
|
+
const Gateway_1 = require("../constants/Gateway");
|
|
40
|
+
/**
|
|
41
|
+
* The gateway's default lifetime for a minted token with no `expiresAt`.
|
|
42
|
+
* @lastreviewed null
|
|
43
|
+
*/
|
|
44
|
+
const DEFAULT_TOKEN_LIFETIME_MS = 90 * 24 * 60 * 60 * 1_000;
|
|
45
|
+
/**
|
|
46
|
+
* Live (unexpired) tokens one user may hold; a mint past it is `409 token-limit`.
|
|
47
|
+
* @lastreviewed null
|
|
48
|
+
*/
|
|
49
|
+
const LIVE_TOKEN_LIMIT = 50;
|
|
50
|
+
/**
|
|
51
|
+
* How long the gateway remembers a rotation's `Idempotency-Key` for replay.
|
|
52
|
+
* @lastreviewed null
|
|
53
|
+
*/
|
|
54
|
+
const IDEMPOTENCY_WINDOW_MS = 10 * 60 * 1_000;
|
|
55
|
+
/**
|
|
56
|
+
* A valid `Idempotency-Key`: 16–128 visible ASCII characters.
|
|
57
|
+
* @lastreviewed null
|
|
58
|
+
*/
|
|
59
|
+
const IDEMPOTENCY_KEY = /^[\x21-\x7e]{16,128}$/;
|
|
60
|
+
/**
|
|
61
|
+
* Whether `expiresAt` has passed.
|
|
62
|
+
* @lastreviewed null
|
|
63
|
+
*/
|
|
64
|
+
function isExpired(expiresAt) {
|
|
65
|
+
return expiresAt !== null && Date.parse(expiresAt) <= Date.now();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* An in-process gateway on `127.0.0.1` (an ephemeral port) answering the b6p gateway contract's
|
|
69
|
+
* REST shapes and error codes, for specs in this package and its consumers. It is a real HTTP
|
|
70
|
+
* server rather than an injected fetch so that the same instance can also serve git smart HTTP
|
|
71
|
+
* (via {@link route}) to a git client that brings its own HTTP stack.
|
|
72
|
+
*
|
|
73
|
+
* Built in: `GET /api/v1/knowledge-bases` (scope `kb:read`, `?scope=` and `?tenant=` filters),
|
|
74
|
+
* `GET /api/v1/registry/repos` (scope `registry:read`), the self-service token routes
|
|
75
|
+
* (`GET`/`POST /api/v1/tokens`, `DELETE /api/v1/tokens/{id}`, `POST /api/v1/tokens/{id}/rotate`,
|
|
76
|
+
* scope `tokens:self`, with `scope-escalation` and `alias-taken`), and `404 not-found` for anything else.
|
|
77
|
+
* A rotation honours `Idempotency-Key`: a retry with the same presenting token and key within 10
|
|
78
|
+
* minutes gets the first attempt's answer and rotates nothing (see {@link loseNextRotateAnswer}).
|
|
79
|
+
* Tokens are granted explicitly with their scopes; a request without one is `401 token-missing`,
|
|
80
|
+
* an unknown or expired one `401 token-invalid`, a missing scope `403 scope-missing` with `scope`.
|
|
81
|
+
* @lastreviewed null
|
|
82
|
+
*/
|
|
83
|
+
class FakeGateway {
|
|
84
|
+
server;
|
|
85
|
+
url;
|
|
86
|
+
/**
|
|
87
|
+
* When `true`, a mint or rotate of a token with any scope but `mcp` is refused `403 not-permitted`
|
|
88
|
+
* with reason `restricted-mints-disabled` (the gateway's rollout switch).
|
|
89
|
+
* @lastreviewed null
|
|
90
|
+
*/
|
|
91
|
+
restrictedMintsDisabled = false;
|
|
92
|
+
/**
|
|
93
|
+
* When `true`, a mint or rotate of a token holding `kb:rewrite` is refused `403 not-permitted` with
|
|
94
|
+
* reason `rewrite-not-permitted` and `scope: "kb:rewrite"` (this account may not rewrite knowledge bases).
|
|
95
|
+
* @lastreviewed null
|
|
96
|
+
*/
|
|
97
|
+
rewriteNotPermitted = false;
|
|
98
|
+
/**
|
|
99
|
+
* When `true`, simulates the gateway before web-global #81's fix: a rotation retry that presents
|
|
100
|
+
* the token the first attempt rotated away is `401 token-invalid` instead of a replay. When
|
|
101
|
+
* `false` (the contract), the replay is served even though the presenting token is now revoked.
|
|
102
|
+
* @lastreviewed null
|
|
103
|
+
*/
|
|
104
|
+
selfRotationRetryRefused = false;
|
|
105
|
+
/**
|
|
106
|
+
* How many rotations actually happened (a replay does not count).
|
|
107
|
+
* @lastreviewed null
|
|
108
|
+
*/
|
|
109
|
+
rotations = 0;
|
|
110
|
+
/**
|
|
111
|
+
* Every request received, in arrival order.
|
|
112
|
+
* @lastreviewed null
|
|
113
|
+
*/
|
|
114
|
+
requests = [];
|
|
115
|
+
/**
|
|
116
|
+
* Knowledge bases the list route returns (to every token with `kb:read`).
|
|
117
|
+
* @lastreviewed null
|
|
118
|
+
*/
|
|
119
|
+
knowledgeBases = [];
|
|
120
|
+
/**
|
|
121
|
+
* Marketplace repos the registry route returns.
|
|
122
|
+
* @lastreviewed null
|
|
123
|
+
*/
|
|
124
|
+
repos = [];
|
|
125
|
+
/**
|
|
126
|
+
* Milliseconds each built-in route waits before answering (to observe concurrency).
|
|
127
|
+
* @lastreviewed null
|
|
128
|
+
*/
|
|
129
|
+
delayMs = 0;
|
|
130
|
+
/**
|
|
131
|
+
* The most requests that were ever being handled at once.
|
|
132
|
+
* @lastreviewed null
|
|
133
|
+
*/
|
|
134
|
+
maxInFlight = 0;
|
|
135
|
+
/**
|
|
136
|
+
* Every secret this fake has ever accepted, granted or minted, revoked ones included, in issue
|
|
137
|
+
* order. For leak checks: a spec can assert none of them reached a log line or an error.
|
|
138
|
+
* @lastreviewed null
|
|
139
|
+
*/
|
|
140
|
+
issuedSecrets = [];
|
|
141
|
+
inFlight = 0;
|
|
142
|
+
tokens = new Map();
|
|
143
|
+
tokenSerial = 0;
|
|
144
|
+
failures = [];
|
|
145
|
+
routes = [];
|
|
146
|
+
replays = new Map();
|
|
147
|
+
lostAnswers = [];
|
|
148
|
+
constructor(server,
|
|
149
|
+
/**
|
|
150
|
+
* The gateway origin, e.g. `http://127.0.0.1:41234`, to use as `gatewayUrl`.
|
|
151
|
+
* @lastreviewed null
|
|
152
|
+
*/
|
|
153
|
+
url) {
|
|
154
|
+
this.server = server;
|
|
155
|
+
this.url = url;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Start a fake gateway on `127.0.0.1` and an ephemeral port.
|
|
159
|
+
* @lastreviewed null
|
|
160
|
+
*/
|
|
161
|
+
static async start() {
|
|
162
|
+
let fake;
|
|
163
|
+
const server = http.createServer((req, res) => {
|
|
164
|
+
if (!fake) {
|
|
165
|
+
res.writeHead(503).end();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
fake.handle(req, res).catch(() => {
|
|
169
|
+
if (!res.headersSent) {
|
|
170
|
+
res.writeHead(500);
|
|
171
|
+
}
|
|
172
|
+
res.end();
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
await new Promise((resolve, reject) => {
|
|
176
|
+
server.once("error", reject);
|
|
177
|
+
server.listen(0, "127.0.0.1", () => resolve());
|
|
178
|
+
});
|
|
179
|
+
const { port } = server.address();
|
|
180
|
+
fake = new FakeGateway(server, `http://127.0.0.1:${port}`);
|
|
181
|
+
return fake;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Accept `token` with these scopes (replacing any earlier grant).
|
|
185
|
+
* @lastreviewed null
|
|
186
|
+
*/
|
|
187
|
+
grantToken(token, scopes, options = {}) {
|
|
188
|
+
const n = ++this.tokenSerial;
|
|
189
|
+
const createdAt = options.createdAt === undefined ? new Date().toISOString() : options.createdAt;
|
|
190
|
+
const expiresAt = options.expiresAt === undefined
|
|
191
|
+
? new Date(Date.parse(createdAt ?? new Date().toISOString()) + DEFAULT_TOKEN_LIFETIME_MS).toISOString()
|
|
192
|
+
: options.expiresAt;
|
|
193
|
+
this.issuedSecrets.push(token);
|
|
194
|
+
this.tokens.set(token, {
|
|
195
|
+
secret: token,
|
|
196
|
+
id: options.id ?? `tok_${n}`,
|
|
197
|
+
alias: options.alias ?? `token-${n}`,
|
|
198
|
+
owner: options.owner ?? "user",
|
|
199
|
+
scopes: [...new Set(scopes)],
|
|
200
|
+
createdAt,
|
|
201
|
+
expiresAt,
|
|
202
|
+
lastUsedAt: null,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Every token this fake currently accepts, secrets included (granted or minted through the
|
|
207
|
+
* token routes).
|
|
208
|
+
* @lastreviewed null
|
|
209
|
+
*/
|
|
210
|
+
issuedTokens() {
|
|
211
|
+
return [...this.tokens.values()].map((t) => ({ ...t, scopes: [...t.scopes] }));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Stop accepting `token`; it then answers `401 token-invalid`.
|
|
215
|
+
* @lastreviewed null
|
|
216
|
+
*/
|
|
217
|
+
revokeToken(token) {
|
|
218
|
+
this.tokens.delete(token);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Serve `failure` for the next request, before any auth check. Queued failures are served in order.
|
|
222
|
+
* @lastreviewed null
|
|
223
|
+
*/
|
|
224
|
+
failNext(failure) {
|
|
225
|
+
this.failures.push(failure);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Act on the next rotation (or replay of one) as usual, then answer `lost` instead of its result:
|
|
229
|
+
* the lost `503` (or dropped connection) after which a client cannot tell whether it rotated.
|
|
230
|
+
* Defaults to `{ status: 503 }`. Queued losses are used in order.
|
|
231
|
+
* @lastreviewed null
|
|
232
|
+
*/
|
|
233
|
+
loseNextRotateAnswer(lost = { status: 503 }) {
|
|
234
|
+
this.lostAnswers.push(lost);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Mount an extra route; see {@link FakeGatewayRoute}.
|
|
238
|
+
* @lastreviewed null
|
|
239
|
+
*/
|
|
240
|
+
route(route) {
|
|
241
|
+
this.routes.push(route);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The git URL the real gateway would give `org`/`repo`, on this fake's origin.
|
|
245
|
+
* @lastreviewed null
|
|
246
|
+
*/
|
|
247
|
+
gitUrl(org, repo) {
|
|
248
|
+
return `${this.url}${Gateway_1.Gateway.Paths.GIT}/${org}/${repo}.git`;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Stop the server and drop its open connections.
|
|
252
|
+
* @lastreviewed null
|
|
253
|
+
*/
|
|
254
|
+
async stop() {
|
|
255
|
+
this.server.closeAllConnections();
|
|
256
|
+
await new Promise((resolve) => this.server.close(() => resolve()));
|
|
257
|
+
}
|
|
258
|
+
async handle(req, res) {
|
|
259
|
+
this.inFlight++;
|
|
260
|
+
this.maxInFlight = Math.max(this.maxInFlight, this.inFlight);
|
|
261
|
+
try {
|
|
262
|
+
const url = new URL(req.url ?? "/", this.url);
|
|
263
|
+
const method = req.method ?? "GET";
|
|
264
|
+
const custom = this.routes.find((r) => r.method === method && url.pathname.startsWith(r.prefix));
|
|
265
|
+
const body = custom ? "" : await readBody(req);
|
|
266
|
+
this.requests.push({
|
|
267
|
+
method,
|
|
268
|
+
path: url.pathname,
|
|
269
|
+
query: Object.fromEntries(url.searchParams),
|
|
270
|
+
authorization: req.headers.authorization,
|
|
271
|
+
body,
|
|
272
|
+
idempotencyKey: headerOf(req, "idempotency-key"),
|
|
273
|
+
});
|
|
274
|
+
const at = this.failures.findIndex((f) => f.method === undefined || f.method === req.method);
|
|
275
|
+
const failure = at < 0 ? undefined : this.failures.splice(at, 1)[0];
|
|
276
|
+
if (failure) {
|
|
277
|
+
sendFailure(res, failure);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (custom) {
|
|
281
|
+
if (this.authorize(req, res, custom.scope)) {
|
|
282
|
+
await custom.handler(req, res);
|
|
283
|
+
}
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (this.delayMs > 0) {
|
|
287
|
+
await new Promise((resolve) => setTimeout(resolve, this.delayMs));
|
|
288
|
+
}
|
|
289
|
+
if (method === "GET" && url.pathname === Gateway_1.Gateway.Paths.KNOWLEDGE_BASES) {
|
|
290
|
+
if (!this.authorize(req, res, Gateway_1.Gateway.Scopes.KB_READ)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const scope = url.searchParams.get("scope");
|
|
294
|
+
const tenant = url.searchParams.get("tenant");
|
|
295
|
+
const list = {
|
|
296
|
+
knowledgeBases: this.knowledgeBases.filter((kb) => (!scope || kb.scope === scope) && (!tenant || kb.tenant === tenant)),
|
|
297
|
+
};
|
|
298
|
+
sendJson(res, 200, list);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (method === "GET" && url.pathname === Gateway_1.Gateway.Paths.REGISTRY_REPOS) {
|
|
302
|
+
if (!this.authorize(req, res, Gateway_1.Gateway.Scopes.REGISTRY_READ)) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const list = { repos: this.repos };
|
|
306
|
+
sendJson(res, 200, list);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (url.pathname === Gateway_1.Gateway.Paths.TOKENS || url.pathname.startsWith(`${Gateway_1.Gateway.Paths.TOKENS}/`)) {
|
|
310
|
+
if (this.replayRotation(method, url.pathname, req, res)) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (this.authorize(req, res, Gateway_1.Gateway.Scopes.TOKENS_SELF)) {
|
|
314
|
+
this.handleTokens(method, url.pathname, body, req, res);
|
|
315
|
+
}
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (!this.authorize(req, res)) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
sendJson(res, 404, { error: "not-found", message: "Not found." });
|
|
322
|
+
}
|
|
323
|
+
finally {
|
|
324
|
+
this.inFlight--;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* The contract's §Tokens routes, for a request already authorised with `tokens:self`.
|
|
329
|
+
* @lastreviewed null
|
|
330
|
+
*/
|
|
331
|
+
handleTokens(method, path, body, req, res) {
|
|
332
|
+
const caller = this.tokens.get(tokenFrom(req.headers.authorization) ?? "");
|
|
333
|
+
if (!caller) {
|
|
334
|
+
sendJson(res, 401, { error: "token-invalid", message: "The access token is not valid." });
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const own = [...this.tokens.values()].filter((t) => t.owner === caller.owner);
|
|
338
|
+
const notFound = () => sendJson(res, 404, { error: "not-found", message: "Not found." });
|
|
339
|
+
if (path === Gateway_1.Gateway.Paths.TOKENS) {
|
|
340
|
+
if (method === "GET") {
|
|
341
|
+
const list = {
|
|
342
|
+
tokens: own.map((t) => ({
|
|
343
|
+
id: t.id,
|
|
344
|
+
alias: t.alias,
|
|
345
|
+
scopes: [...t.scopes],
|
|
346
|
+
createdAt: t.createdAt,
|
|
347
|
+
expiresAt: t.expiresAt,
|
|
348
|
+
lastUsedAt: t.lastUsedAt,
|
|
349
|
+
current: t === caller,
|
|
350
|
+
})),
|
|
351
|
+
};
|
|
352
|
+
sendJson(res, 200, list);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (method === "POST") {
|
|
356
|
+
let parsed;
|
|
357
|
+
try {
|
|
358
|
+
parsed = JSON.parse(body);
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
parsed = undefined;
|
|
362
|
+
}
|
|
363
|
+
const request = typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
364
|
+
const { alias, scopes } = request;
|
|
365
|
+
if (typeof alias !== "string" ||
|
|
366
|
+
alias.length === 0 ||
|
|
367
|
+
!Array.isArray(scopes) ||
|
|
368
|
+
!scopes.every((s) => typeof s === "string")) {
|
|
369
|
+
sendJson(res, 400, { error: "invalid-request", message: "alias and scopes are required." });
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (scopes.some((s) => !caller.scopes.includes(s))) {
|
|
373
|
+
sendJson(res, 403, {
|
|
374
|
+
error: "scope-escalation",
|
|
375
|
+
message: "The new token's scopes exceed the presenting token's.",
|
|
376
|
+
});
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
if (own.some((t) => t.alias === alias)) {
|
|
380
|
+
sendJson(res, 409, { error: "alias-taken", message: `The alias ${alias} is taken.` });
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const createdAt = new Date().toISOString();
|
|
384
|
+
let expiresAt;
|
|
385
|
+
if (!("expiresAt" in request) || request.expiresAt === undefined) {
|
|
386
|
+
// No expiry asked for: the sooner of 90 days and the presenting token's expiry.
|
|
387
|
+
const full = Date.now() + DEFAULT_TOKEN_LIFETIME_MS;
|
|
388
|
+
expiresAt = new Date(caller.expiresAt === null ? full : Math.min(full, Date.parse(caller.expiresAt))).toISOString();
|
|
389
|
+
}
|
|
390
|
+
else if (request.expiresAt === null) {
|
|
391
|
+
expiresAt = null;
|
|
392
|
+
}
|
|
393
|
+
else if (typeof request.expiresAt === "string") {
|
|
394
|
+
expiresAt = request.expiresAt;
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
sendJson(res, 400, { error: "invalid-request", message: "expiresAt is not a date." });
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (caller.expiresAt !== null && (expiresAt === null || Date.parse(expiresAt) > Date.parse(caller.expiresAt))) {
|
|
401
|
+
sendJson(res, 403, {
|
|
402
|
+
error: "not-permitted",
|
|
403
|
+
reason: "expiry-exceeds-presenting",
|
|
404
|
+
presentingExpiresAt: caller.expiresAt,
|
|
405
|
+
message: "A new token may not outlive the token that makes the request.",
|
|
406
|
+
});
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (this.rewriteNotPermitted && scopes.includes("kb:rewrite")) {
|
|
410
|
+
sendJson(res, 403, {
|
|
411
|
+
error: "not-permitted",
|
|
412
|
+
reason: "rewrite-not-permitted",
|
|
413
|
+
scope: "kb:rewrite",
|
|
414
|
+
message: "This account may not hold kb:rewrite.",
|
|
415
|
+
});
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (this.restrictedMintsDisabled && scopes.some((s) => s !== "mcp")) {
|
|
419
|
+
sendJson(res, 403, {
|
|
420
|
+
error: "not-permitted",
|
|
421
|
+
reason: "restricted-mints-disabled",
|
|
422
|
+
message: "Minting tokens beyond mcp is not enabled yet.",
|
|
423
|
+
});
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (own.filter((t) => !isExpired(t.expiresAt)).length >= LIVE_TOKEN_LIMIT) {
|
|
427
|
+
sendJson(res, 409, {
|
|
428
|
+
error: "token-limit",
|
|
429
|
+
message: `A user may hold at most ${LIVE_TOKEN_LIMIT} live tokens.`,
|
|
430
|
+
limit: LIVE_TOKEN_LIMIT,
|
|
431
|
+
});
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
sendJson(res, 201, this.mint(caller.owner, alias, scopes, createdAt, expiresAt));
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
notFound();
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const rest = path.slice(Gateway_1.Gateway.Paths.TOKENS.length + 1).split("/");
|
|
441
|
+
const target = own.find((t) => t.id === decodeURIComponent(rest[0]));
|
|
442
|
+
if (!target) {
|
|
443
|
+
notFound();
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (rest.length === 1 && method === "DELETE") {
|
|
447
|
+
this.tokens.delete(target.secret);
|
|
448
|
+
res.writeHead(204).end();
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (rest.length === 2 && rest[1] === "rotate" && method === "POST") {
|
|
452
|
+
const key = headerOf(req, "idempotency-key");
|
|
453
|
+
if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
|
|
454
|
+
sendJson(res, 400, { error: "invalid-request", message: "The Idempotency-Key is malformed." });
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const remembered = key === undefined ? undefined : this.freshReplay(caller.secret, key);
|
|
458
|
+
if (remembered && remembered.targetId !== target.id) {
|
|
459
|
+
sendJson(res, 400, { error: "invalid-request", message: "The Idempotency-Key was used for another token." });
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (remembered) {
|
|
463
|
+
this.answerRotation(res, remembered.body);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
if (isExpired(target.expiresAt)) {
|
|
467
|
+
sendJson(res, 400, { error: "invalid-request", message: "An expired token cannot be rotated." });
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if (this.rewriteNotPermitted && target.scopes.includes("kb:rewrite")) {
|
|
471
|
+
sendJson(res, 403, {
|
|
472
|
+
error: "not-permitted",
|
|
473
|
+
reason: "rewrite-not-permitted",
|
|
474
|
+
scope: "kb:rewrite",
|
|
475
|
+
message: "This account may not hold kb:rewrite.",
|
|
476
|
+
});
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (this.restrictedMintsDisabled && target.scopes.some((s) => s !== "mcp")) {
|
|
480
|
+
sendJson(res, 403, {
|
|
481
|
+
error: "not-permitted",
|
|
482
|
+
reason: "restricted-mints-disabled",
|
|
483
|
+
message: "Minting tokens beyond mcp is not enabled yet.",
|
|
484
|
+
});
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
// The replacement keeps the target's absolute end date.
|
|
488
|
+
this.tokens.delete(target.secret);
|
|
489
|
+
this.rotations++;
|
|
490
|
+
const minted = this.mint(target.owner, target.alias, target.scopes, new Date().toISOString(), target.expiresAt);
|
|
491
|
+
if (key !== undefined) {
|
|
492
|
+
this.replays.set(replayKey(caller.secret, key), { targetId: target.id, at: Date.now(), body: minted });
|
|
493
|
+
}
|
|
494
|
+
this.answerRotation(res, minted);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
notFound();
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Serve a remembered rotation to a retry before the usual auth check, so a retry presenting the
|
|
501
|
+
* token that rotation revoked still gets its answer (unless {@link selfRotationRetryRefused}).
|
|
502
|
+
* Returns `false`, having sent nothing, when the request is not such a retry.
|
|
503
|
+
* @lastreviewed null
|
|
504
|
+
*/
|
|
505
|
+
replayRotation(method, path, req, res) {
|
|
506
|
+
const rest = path.slice(Gateway_1.Gateway.Paths.TOKENS.length + 1).split("/");
|
|
507
|
+
const presenter = tokenFrom(req.headers.authorization);
|
|
508
|
+
const key = headerOf(req, "idempotency-key");
|
|
509
|
+
if (method !== "POST" || rest.length !== 2 || rest[1] !== "rotate" || !presenter || key === undefined) {
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
const remembered = this.freshReplay(presenter, key);
|
|
513
|
+
if (!remembered || remembered.targetId !== decodeURIComponent(rest[0])) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
if (!this.tokens.has(presenter) && this.selfRotationRetryRefused) {
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
this.answerRotation(res, remembered.body);
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
freshReplay(presenter, key) {
|
|
523
|
+
const remembered = this.replays.get(replayKey(presenter, key));
|
|
524
|
+
return remembered && Date.now() - remembered.at < IDEMPOTENCY_WINDOW_MS ? remembered : undefined;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Send a rotation's answer, or the next {@link loseNextRotateAnswer} loss in its place.
|
|
528
|
+
* @lastreviewed null
|
|
529
|
+
*/
|
|
530
|
+
answerRotation(res, body) {
|
|
531
|
+
const lost = this.lostAnswers.shift();
|
|
532
|
+
if (lost === "drop") {
|
|
533
|
+
res.socket?.destroy();
|
|
534
|
+
}
|
|
535
|
+
else if (lost) {
|
|
536
|
+
sendJson(res, lost.status, { error: "unavailable", message: "The answer was lost on the way back." });
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
sendJson(res, 201, body);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
mint(owner, alias, scopes, createdAt, expiresAt) {
|
|
543
|
+
const n = ++this.tokenSerial;
|
|
544
|
+
const secret = `${Gateway_1.Gateway.TOKEN_PREFIX}fake_${n}_${(0, node_crypto_1.randomBytes)(12).toString("hex")}`;
|
|
545
|
+
const record = {
|
|
546
|
+
secret,
|
|
547
|
+
id: `tok_${n}`,
|
|
548
|
+
alias,
|
|
549
|
+
owner,
|
|
550
|
+
scopes: [...new Set(scopes)],
|
|
551
|
+
createdAt,
|
|
552
|
+
expiresAt,
|
|
553
|
+
lastUsedAt: null,
|
|
554
|
+
};
|
|
555
|
+
this.issuedSecrets.push(secret);
|
|
556
|
+
this.tokens.set(secret, record);
|
|
557
|
+
return { id: record.id, token: secret, alias, scopes: [...record.scopes], expiresAt };
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Check the token (and scope); answer the contract's error and return `false` when it fails.
|
|
561
|
+
* @lastreviewed null
|
|
562
|
+
*/
|
|
563
|
+
authorize(req, res, scope) {
|
|
564
|
+
const token = tokenFrom(req.headers.authorization);
|
|
565
|
+
if (!token) {
|
|
566
|
+
sendJson(res, 401, { error: "token-missing", message: "No access token was sent." });
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
const granted = this.tokens.get(token);
|
|
570
|
+
if (!granted || (granted.expiresAt !== null && Date.parse(granted.expiresAt) <= Date.now())) {
|
|
571
|
+
sendJson(res, 401, { error: "token-invalid", message: "The access token is not valid." });
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
if (scope && !granted.scopes.includes(scope)) {
|
|
575
|
+
sendJson(res, 403, { error: "scope-missing", message: `The token lacks ${scope}.`, scope });
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
granted.lastUsedAt = new Date().toISOString();
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
exports.FakeGateway = FakeGateway;
|
|
583
|
+
function tokenFrom(header) {
|
|
584
|
+
if (!header) {
|
|
585
|
+
return undefined;
|
|
586
|
+
}
|
|
587
|
+
if (header.startsWith("Bearer ")) {
|
|
588
|
+
return header.slice("Bearer ".length) || undefined;
|
|
589
|
+
}
|
|
590
|
+
if (header.startsWith("Basic ")) {
|
|
591
|
+
const decoded = Buffer.from(header.slice("Basic ".length), "base64").toString("utf8");
|
|
592
|
+
const colon = decoded.indexOf(":");
|
|
593
|
+
return colon >= 0 ? decoded.slice(colon + 1) || undefined : undefined;
|
|
594
|
+
}
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
function headerOf(req, name) {
|
|
598
|
+
const value = req.headers[name];
|
|
599
|
+
return Array.isArray(value) ? value.join(", ") : value;
|
|
600
|
+
}
|
|
601
|
+
function replayKey(presenter, key) {
|
|
602
|
+
return `${presenter}\n${key}`;
|
|
603
|
+
}
|
|
604
|
+
function readBody(req) {
|
|
605
|
+
return new Promise((resolve, reject) => {
|
|
606
|
+
const chunks = [];
|
|
607
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
608
|
+
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
609
|
+
req.on("error", reject);
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
function sendJson(res, status, body) {
|
|
613
|
+
res.writeHead(status, { "Content-Type": "application/json" });
|
|
614
|
+
res.end(JSON.stringify(body));
|
|
615
|
+
}
|
|
616
|
+
function sendFailure(res, failure) {
|
|
617
|
+
if (failure.body === undefined) {
|
|
618
|
+
res.writeHead(failure.status).end();
|
|
619
|
+
}
|
|
620
|
+
else if (typeof failure.body === "string") {
|
|
621
|
+
res.writeHead(failure.status, { "Content-Type": "text/plain" }).end(failure.body);
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
sendJson(res, failure.status, failure.body);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
//# sourceMappingURL=FakeGateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeGateway.js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