@bluestep-systems/b6p-core 1.8.1 → 1.9.1
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 +105 -10
- package/dist/B6PCore.js +48 -1
- package/dist/B6PCore.js.map +1 -1
- package/dist/Err.d.ts +56 -3
- package/dist/Err.js +65 -1
- package/dist/Err.js.map +1 -1
- package/dist/auth/BearerAuthProvider.d.ts +43 -13
- package/dist/auth/BearerAuthProvider.js +151 -22
- package/dist/auth/BearerAuthProvider.js.map +1 -1
- package/dist/constants/Gateway.d.ts +84 -1
- package/dist/constants/Gateway.js +94 -1
- package/dist/constants/Gateway.js.map +1 -1
- package/dist/gateway/GatewayClient.d.ts +88 -0
- package/dist/gateway/GatewayClient.js +157 -15
- package/dist/gateway/GatewayClient.js.map +1 -1
- package/dist/gateway/GatewayContext.d.ts +16 -3
- package/dist/gateway/GatewayKb.d.ts +2 -2
- package/dist/gateway/GatewayKb.js +6 -6
- package/dist/gateway/GatewayKb.js.map +1 -1
- package/dist/gateway/GatewaySecretRecovery.d.ts +35 -0
- package/dist/gateway/GatewaySecretRecovery.js +169 -0
- package/dist/gateway/GatewaySecretRecovery.js.map +1 -0
- package/dist/gateway/GatewayService.d.ts +8 -1
- package/dist/gateway/GatewayService.js +8 -0
- package/dist/gateway/GatewayService.js.map +1 -1
- package/dist/gateway/GatewaySignIn.d.ts +389 -0
- package/dist/gateway/GatewaySignIn.js +877 -0
- package/dist/gateway/GatewaySignIn.js.map +1 -0
- package/dist/gateway/GatewayToken.d.ts +19 -4
- package/dist/gateway/GatewayToken.js +51 -10
- package/dist/gateway/GatewayToken.js.map +1 -1
- package/dist/gateway/GatewayTokenService.d.ts +2 -2
- package/dist/gateway/GatewayTokenService.js +67 -51
- package/dist/gateway/GatewayTokenService.js.map +1 -1
- package/dist/gitCredential/GitCredentialContext.d.ts +7 -1
- package/dist/gitCredential/GitCredentialService.d.ts +8 -0
- package/dist/gitCredential/GitCredentialService.js +31 -0
- package/dist/gitCredential/GitCredentialService.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/persistence/PersistenceKeys.d.ts +6 -1
- package/dist/persistence/PersistenceKeys.js +5 -0
- package/dist/persistence/PersistenceKeys.js.map +1 -1
- package/dist/persistence/SharedFilePersistence.d.ts +5 -0
- package/dist/persistence/SharedFilePersistence.js +7 -0
- package/dist/persistence/SharedFilePersistence.js.map +1 -1
- package/dist/providers.d.ts +73 -3
- package/dist/testing/FakeGateway.d.ts +135 -1
- package/dist/testing/FakeGateway.js +197 -1
- package/dist/testing/FakeGateway.js.map +1 -1
- package/dist/types.d.ts +78 -0
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BearerAuthParams } from "../types";
|
|
2
|
-
import type { AuthProvider, Logger, Persistence, Prompt } from "../providers";
|
|
1
|
+
import type { BearerAuthParams, GatewayMintedToken, GatewaySignInRecord } from "../types";
|
|
2
|
+
import type { AuthProvider, GatewayStoredToken, Logger, Persistence, Prompt } from "../providers";
|
|
3
3
|
/**
|
|
4
4
|
* Core-layer bearer auth provider.
|
|
5
5
|
*
|
|
@@ -14,7 +14,9 @@ export declare class BearerAuthProvider implements AuthProvider<BearerAuthParams
|
|
|
14
14
|
constructor(persistence: Persistence, prompt: Prompt, logger: Logger);
|
|
15
15
|
/**
|
|
16
16
|
* Returns the bearer auth header value (`"Bearer <token>"`).
|
|
17
|
-
* Prompts for a token if none is stored.
|
|
17
|
+
* Prompts for a token if none is stored. A stored value that is not a platform token (a reserved `b6p_o_` one,
|
|
18
|
+
* say, stored before 1.9.0 refused it) is never put in a header: it throws, the value unquoted.
|
|
19
|
+
* @lastreviewed null
|
|
18
20
|
*/
|
|
19
21
|
authHeaderValue(): Promise<string>;
|
|
20
22
|
getOrCreate(): Promise<BearerAuthParams>;
|
|
@@ -39,6 +41,9 @@ export declare class BearerAuthProvider implements AuthProvider<BearerAuthParams
|
|
|
39
41
|
* false right after a "Token stored" log line, and the next `authHeaderValue()`
|
|
40
42
|
* re-prompted, giving a user who keeps pressing Enter an unbounded prompt loop.
|
|
41
43
|
*
|
|
44
|
+
* A value that is not a platform token (`b6p_g_`, `b6p_t_`, `b6pt_`; the reserved `b6p_o_` is not one) is refused
|
|
45
|
+
* unstored, as is a new value given to {@link update}.
|
|
46
|
+
*
|
|
42
47
|
* Note {@link update} deliberately reads empty as "keep the current token"; there
|
|
43
48
|
* is no current token to keep here.
|
|
44
49
|
* @lastreviewed null
|
|
@@ -77,20 +82,45 @@ export declare class BearerAuthProvider implements AuthProvider<BearerAuthParams
|
|
|
77
82
|
* Never prompts, and neither value is logged or put in an error message.
|
|
78
83
|
*
|
|
79
84
|
* This is the write behind rotating the stored token through the gateway: the gateway has
|
|
80
|
-
* already revoked `expected`, so `next` must take its place. It
|
|
81
|
-
*
|
|
82
|
-
*
|
|
85
|
+
* already revoked `expected`, so `next` must take its place. It does not touch the web session,
|
|
86
|
+
* which still bootstraps through {@link authHeaderValue}. A device sign-in's record follows the
|
|
87
|
+
* token: `minted` (the gateway's answer) gives its new id, expiry and scopes; without it the id
|
|
88
|
+
* becomes unknown (`null`).
|
|
83
89
|
*
|
|
84
|
-
* The
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* reported (thrown) rather than reported as stored.
|
|
90
|
+
* The compare-then-write runs under the store's lock ({@link storeSignIn} and {@link forget} take
|
|
91
|
+
* the same one; across processes only when the persistence can lock). `auth set` / `auth update`
|
|
92
|
+
* do not take it, so a write by them, or by a persistence that cannot lock, that lands between this
|
|
93
|
+
* read and this write is overwritten. The value is read back after the write, so an overwrite that
|
|
94
|
+
* lands before that read-back is reported (thrown) rather than reported as stored.
|
|
90
95
|
*
|
|
91
96
|
* @throws {Error} when `next` is empty, the stored token is no longer `expected`, the write fails,
|
|
92
97
|
* or the read-back finds something other than `next`
|
|
93
98
|
* @lastreviewed null
|
|
94
99
|
*/
|
|
95
|
-
replaceStoredToken(expected: string, next: string): Promise<void>;
|
|
100
|
+
replaceStoredToken(expected: string, next: string, minted?: GatewayMintedToken): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* The stored token and its sign-in record (`null` for a pasted token), or `undefined` when none is stored. Never
|
|
103
|
+
* prompts and never logs the value.
|
|
104
|
+
* @lastreviewed null
|
|
105
|
+
*/
|
|
106
|
+
storedSignIn(): Promise<GatewayStoredToken | undefined>;
|
|
107
|
+
/**
|
|
108
|
+
* Store `token`, made by a device sign-in, with its record, in place of whatever is stored, and read it back.
|
|
109
|
+
* Runs under the store's lock (across processes when the persistence can lock), and reads what it replaces
|
|
110
|
+
* inside it. Never prompts; neither value reaches a log line or a message.
|
|
111
|
+
*
|
|
112
|
+
* @returns what it replaced, `undefined` when nothing was stored
|
|
113
|
+
* @throws {Error} the token or record is not usable, the write failed, or the read-back found something else
|
|
114
|
+
* @lastreviewed null
|
|
115
|
+
*/
|
|
116
|
+
storeSignIn(token: string, signIn: GatewaySignInRecord): Promise<GatewayStoredToken | undefined>;
|
|
117
|
+
/**
|
|
118
|
+
* Forget the stored token when it is still `expected` (under the store's lock), along with any credentials left
|
|
119
|
+
* behind by the removed basic-auth provider. Never prompts.
|
|
120
|
+
*
|
|
121
|
+
* @returns `true` when it was forgotten (or nothing was stored), `false` when another token is stored now; that
|
|
122
|
+
* one is left as it is
|
|
123
|
+
* @lastreviewed null
|
|
124
|
+
*/
|
|
125
|
+
forget(expected: string): Promise<boolean>;
|
|
96
126
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BearerAuthProvider = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
|
+
const lockedMutation_1 = require("../persistence/lockedMutation");
|
|
6
|
+
const GatewayToken_1 = require("../gateway/GatewayToken");
|
|
5
7
|
const PERSISTENCE_KEY = "bearerAuth";
|
|
6
8
|
/**
|
|
7
9
|
* Secret-storage key written by the removed `BasicAuthProvider`. Purged by
|
|
@@ -29,10 +31,16 @@ class BearerAuthProvider {
|
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
33
|
* Returns the bearer auth header value (`"Bearer <token>"`).
|
|
32
|
-
* Prompts for a token if none is stored.
|
|
34
|
+
* Prompts for a token if none is stored. A stored value that is not a platform token (a reserved `b6p_o_` one,
|
|
35
|
+
* say, stored before 1.9.0 refused it) is never put in a header: it throws, the value unquoted.
|
|
36
|
+
* @lastreviewed null
|
|
33
37
|
*/
|
|
34
38
|
async authHeaderValue() {
|
|
35
39
|
const { token } = await this.getOrCreate();
|
|
40
|
+
const problem = (0, GatewayToken_1.gatewayTokenProblem)(token);
|
|
41
|
+
if (problem !== null) {
|
|
42
|
+
throw new Error(`The stored access token is not a platform token (${problem}); it was not sent.`);
|
|
43
|
+
}
|
|
36
44
|
return `${constants_1.AuthTypes.BEARER_PREFIX}${token}`;
|
|
37
45
|
}
|
|
38
46
|
async getOrCreate() {
|
|
@@ -77,7 +85,16 @@ class BearerAuthProvider {
|
|
|
77
85
|
return false;
|
|
78
86
|
}
|
|
79
87
|
const candidate = value;
|
|
80
|
-
|
|
88
|
+
if (!(candidate.scheme === BEARER_SCHEME && typeof candidate.token === "string" && candidate.token.length > 0)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
// A sign-in record that is not well formed is dropped, never the token: the token still works, and b6p then
|
|
92
|
+
// treats it as pasted (it does not revoke or renew what it cannot describe).
|
|
93
|
+
if (candidate.signIn !== undefined && !isSignInRecord(candidate.signIn)) {
|
|
94
|
+
this.logger.warn("The stored sign-in record is malformed; the token is kept and treated as pasted.");
|
|
95
|
+
delete candidate.signIn;
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
81
98
|
}
|
|
82
99
|
/**
|
|
83
100
|
* Prompt for a new token and store it.
|
|
@@ -88,6 +105,9 @@ class BearerAuthProvider {
|
|
|
88
105
|
* false right after a "Token stored" log line, and the next `authHeaderValue()`
|
|
89
106
|
* re-prompted, giving a user who keeps pressing Enter an unbounded prompt loop.
|
|
90
107
|
*
|
|
108
|
+
* A value that is not a platform token (`b6p_g_`, `b6p_t_`, `b6pt_`; the reserved `b6p_o_` is not one) is refused
|
|
109
|
+
* unstored, as is a new value given to {@link update}.
|
|
110
|
+
*
|
|
91
111
|
* Note {@link update} deliberately reads empty as "keep the current token"; there
|
|
92
112
|
* is no current token to keep here.
|
|
93
113
|
* @lastreviewed null
|
|
@@ -97,6 +117,7 @@ class BearerAuthProvider {
|
|
|
97
117
|
if (token === undefined || token.length === 0) {
|
|
98
118
|
throw new Error("Token entry cancelled");
|
|
99
119
|
}
|
|
120
|
+
refuseNonPlatform(token);
|
|
100
121
|
const creds = { scheme: BEARER_SCHEME, token };
|
|
101
122
|
await this.persistence.setSecret(PERSISTENCE_KEY, JSON.stringify(creds));
|
|
102
123
|
this.logger.info("Token stored");
|
|
@@ -115,7 +136,11 @@ class BearerAuthProvider {
|
|
|
115
136
|
this.prompt.info("Cancelled");
|
|
116
137
|
return existing;
|
|
117
138
|
}
|
|
118
|
-
|
|
139
|
+
if (newToken) {
|
|
140
|
+
refuseNonPlatform(newToken);
|
|
141
|
+
}
|
|
142
|
+
// Keeping the current token keeps what is known about it (a device sign-in's record); a new one is pasted.
|
|
143
|
+
const creds = newToken ? { scheme: BEARER_SCHEME, token: newToken } : existing;
|
|
119
144
|
await this.persistence.setSecret(PERSISTENCE_KEY, JSON.stringify(creds));
|
|
120
145
|
if (creds.token === existing.token) {
|
|
121
146
|
this.prompt.info("No changes made to the token.");
|
|
@@ -161,37 +186,141 @@ class BearerAuthProvider {
|
|
|
161
186
|
* Never prompts, and neither value is logged or put in an error message.
|
|
162
187
|
*
|
|
163
188
|
* This is the write behind rotating the stored token through the gateway: the gateway has
|
|
164
|
-
* already revoked `expected`, so `next` must take its place. It
|
|
165
|
-
*
|
|
166
|
-
*
|
|
189
|
+
* already revoked `expected`, so `next` must take its place. It does not touch the web session,
|
|
190
|
+
* which still bootstraps through {@link authHeaderValue}. A device sign-in's record follows the
|
|
191
|
+
* token: `minted` (the gateway's answer) gives its new id, expiry and scopes; without it the id
|
|
192
|
+
* becomes unknown (`null`).
|
|
167
193
|
*
|
|
168
|
-
* The
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* reported (thrown) rather than reported as stored.
|
|
194
|
+
* The compare-then-write runs under the store's lock ({@link storeSignIn} and {@link forget} take
|
|
195
|
+
* the same one; across processes only when the persistence can lock). `auth set` / `auth update`
|
|
196
|
+
* do not take it, so a write by them, or by a persistence that cannot lock, that lands between this
|
|
197
|
+
* read and this write is overwritten. The value is read back after the write, so an overwrite that
|
|
198
|
+
* lands before that read-back is reported (thrown) rather than reported as stored.
|
|
174
199
|
*
|
|
175
200
|
* @throws {Error} when `next` is empty, the stored token is no longer `expected`, the write fails,
|
|
176
201
|
* or the read-back finds something other than `next`
|
|
177
202
|
* @lastreviewed null
|
|
178
203
|
*/
|
|
179
|
-
async replaceStoredToken(expected, next) {
|
|
204
|
+
async replaceStoredToken(expected, next, minted) {
|
|
180
205
|
if (next.length === 0) {
|
|
181
206
|
throw new Error("The replacement token is empty; the stored token was left as it was.");
|
|
182
207
|
}
|
|
208
|
+
await (0, lockedMutation_1.exclusive)(this.persistence, PERSISTENCE_KEY, async () => {
|
|
209
|
+
const stored = await this.readStored();
|
|
210
|
+
if (stored?.token !== expected) {
|
|
211
|
+
throw new Error("The stored token is no longer the one that was rotated; it was left as it was.");
|
|
212
|
+
}
|
|
213
|
+
const creds = { scheme: BEARER_SCHEME, token: next };
|
|
214
|
+
if (stored.signIn) {
|
|
215
|
+
// A rotation keeps the alias; the id, expiry and scopes are the replacement's when the gateway said them.
|
|
216
|
+
creds.signIn = minted
|
|
217
|
+
? {
|
|
218
|
+
...stored.signIn,
|
|
219
|
+
tokenId: minted.id,
|
|
220
|
+
scopes: [...minted.scopes],
|
|
221
|
+
expiresAt: minted.expiresAt,
|
|
222
|
+
refreshable: minted.refreshable,
|
|
223
|
+
storedAt: new Date().toISOString(),
|
|
224
|
+
}
|
|
225
|
+
: { ...stored.signIn, tokenId: null, storedAt: new Date().toISOString() };
|
|
226
|
+
}
|
|
227
|
+
await this.persistence.setSecret(PERSISTENCE_KEY, JSON.stringify(creds));
|
|
228
|
+
// Read it back: another process sharing the store can write its stale copy over this one.
|
|
229
|
+
if ((await this.readStored())?.token !== next) {
|
|
230
|
+
throw new Error("The stored token was overwritten right after the replacement was written; it is not stored.");
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
this.logger.info("Token replaced");
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The stored token and its sign-in record (`null` for a pasted token), or `undefined` when none is stored. Never
|
|
237
|
+
* prompts and never logs the value.
|
|
238
|
+
* @lastreviewed null
|
|
239
|
+
*/
|
|
240
|
+
async storedSignIn() {
|
|
183
241
|
const stored = await this.readStored();
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
242
|
+
return stored === undefined ? undefined : { token: stored.token, signIn: stored.signIn ?? null };
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Store `token`, made by a device sign-in, with its record, in place of whatever is stored, and read it back.
|
|
246
|
+
* Runs under the store's lock (across processes when the persistence can lock), and reads what it replaces
|
|
247
|
+
* inside it. Never prompts; neither value reaches a log line or a message.
|
|
248
|
+
*
|
|
249
|
+
* @returns what it replaced, `undefined` when nothing was stored
|
|
250
|
+
* @throws {Error} the token or record is not usable, the write failed, or the read-back found something else
|
|
251
|
+
* @lastreviewed null
|
|
252
|
+
*/
|
|
253
|
+
async storeSignIn(token, signIn) {
|
|
254
|
+
if (token.length === 0 || !isSignInRecord(signIn)) {
|
|
255
|
+
throw new Error("The signed-in token or its record is not usable; nothing was stored.");
|
|
192
256
|
}
|
|
193
|
-
this.
|
|
257
|
+
return (0, lockedMutation_1.exclusive)(this.persistence, PERSISTENCE_KEY, async () => {
|
|
258
|
+
const previous = await this.storedSignIn();
|
|
259
|
+
const creds = { scheme: BEARER_SCHEME, token, signIn };
|
|
260
|
+
await this.persistence.setSecret(PERSISTENCE_KEY, JSON.stringify(creds));
|
|
261
|
+
if ((await this.readStored())?.token !== token) {
|
|
262
|
+
throw new Error("The stored token was overwritten right after the new one was written; it is not stored.");
|
|
263
|
+
}
|
|
264
|
+
this.logger.info("Token stored");
|
|
265
|
+
return previous;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Forget the stored token when it is still `expected` (under the store's lock), along with any credentials left
|
|
270
|
+
* behind by the removed basic-auth provider. Never prompts.
|
|
271
|
+
*
|
|
272
|
+
* @returns `true` when it was forgotten (or nothing was stored), `false` when another token is stored now; that
|
|
273
|
+
* one is left as it is
|
|
274
|
+
* @lastreviewed null
|
|
275
|
+
*/
|
|
276
|
+
async forget(expected) {
|
|
277
|
+
return (0, lockedMutation_1.exclusive)(this.persistence, PERSISTENCE_KEY, async () => {
|
|
278
|
+
const stored = await this.readStored();
|
|
279
|
+
if (stored !== undefined && stored.token !== expected) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
await this.clear();
|
|
283
|
+
return true;
|
|
284
|
+
});
|
|
194
285
|
}
|
|
195
286
|
}
|
|
196
287
|
exports.BearerAuthProvider = BearerAuthProvider;
|
|
288
|
+
/**
|
|
289
|
+
* Refuse, before anything is stored, a value that is not a platform token (`b6p_g_`, `b6p_t_`, `b6pt_`): the
|
|
290
|
+
* reserved `b6p_o_`, a value with no prefix, or one with whitespace. The value is never quoted.
|
|
291
|
+
* @lastreviewed null
|
|
292
|
+
*/
|
|
293
|
+
function refuseNonPlatform(token) {
|
|
294
|
+
const problem = (0, GatewayToken_1.gatewayTokenProblem)(token);
|
|
295
|
+
if (problem !== null) {
|
|
296
|
+
throw new Error(`That is not a platform access token (${problem}); nothing was stored.`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Whether `value` is a well-formed {@link GatewaySignInRecord}.
|
|
301
|
+
* @lastreviewed null
|
|
302
|
+
*/
|
|
303
|
+
function isSignInRecord(value) {
|
|
304
|
+
if (typeof value !== "object" || value === null) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
const r = value;
|
|
308
|
+
return (typeof r.gateway === "string" &&
|
|
309
|
+
r.gateway.length > 0 &&
|
|
310
|
+
(r.tokenId === null || (typeof r.tokenId === "string" && r.tokenId.length > 0)) &&
|
|
311
|
+
typeof r.alias === "string" &&
|
|
312
|
+
(r.account === null || isAccount(r.account)) &&
|
|
313
|
+
Array.isArray(r.scopes) &&
|
|
314
|
+
r.scopes.every((scope) => typeof scope === "string") &&
|
|
315
|
+
(r.expiresAt === null || (typeof r.expiresAt === "string" && !Number.isNaN(Date.parse(r.expiresAt)))) &&
|
|
316
|
+
typeof r.refreshable === "boolean" &&
|
|
317
|
+
typeof r.storedAt === "string");
|
|
318
|
+
}
|
|
319
|
+
function isAccount(value) {
|
|
320
|
+
if (typeof value !== "object" || value === null) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
const a = value;
|
|
324
|
+
return typeof a.name === "string" && typeof a.login === "string";
|
|
325
|
+
}
|
|
197
326
|
//# sourceMappingURL=BearerAuthProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BearerAuthProvider.js","sourceRoot":"","sources":["../../src/auth/BearerAuthProvider.ts"],"names":[],"mappings":";;;AACA,4CAAyC;
|
|
1
|
+
{"version":3,"file":"BearerAuthProvider.js","sourceRoot":"","sources":["../../src/auth/BearerAuthProvider.ts"],"names":[],"mappings":";;;AACA,4CAAyC;AAEzC,kEAA0D;AAC1D,0DAA8D;AAE9D,MAAM,eAAe,GAAG,YAAY,CAAC;AAErC;;;;GAIG;AACH,MAAM,4BAA4B,GAAG,W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AM,CAAC,GAAG,KAA6D,CAAC;IACxE,OAAO,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC;AACnE,CAAC"}
|
|
@@ -11,7 +11,31 @@ export declare namespace Gateway {
|
|
|
11
11
|
*/
|
|
12
12
|
const DEFAULT_URL = "https://gateway.bluestep.net";
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* The prefixes of the platform tokens b6p accepts, stores and sends (web-shared `TokenPrefix`):
|
|
15
|
+
* - `b6p_g_`: a global user's token, as minted since web-global's strict mints;
|
|
16
|
+
* - `b6p_t_`: a tenant's own user's token;
|
|
17
|
+
* - `b6pt_`: the legacy global token, still accepted everywhere (deprecated by the platform, never minted again).
|
|
18
|
+
*
|
|
19
|
+
* Minted tokens are the prefix and 48 lower-case hex characters; b6p checks only the prefix and that the rest is
|
|
20
|
+
* printable ASCII (the alphabet is the platform's business). No prefix is a prefix of another.
|
|
21
|
+
* @lastreviewed null
|
|
22
|
+
*/
|
|
23
|
+
const TOKEN_PREFIXES: readonly ["b6p_g_", "b6p_t_", "b6pt_"];
|
|
24
|
+
/**
|
|
25
|
+
* Prefixes the platform reserves and b6p never accepts as a platform token: `b6p_o_` is for OAuth access tokens.
|
|
26
|
+
* A value with one is still a secret, so it is redacted like the others ({@link SECRET_PREFIXES}).
|
|
27
|
+
* @lastreviewed null
|
|
28
|
+
*/
|
|
29
|
+
const RESERVED_TOKEN_PREFIXES: readonly ["b6p_o_"];
|
|
30
|
+
/**
|
|
31
|
+
* Every prefix that marks a secret: {@link TOKEN_PREFIXES} and {@link RESERVED_TOKEN_PREFIXES}. Anything starting
|
|
32
|
+
* with one (in any letter case) is redacted from messages and refused where an id, alias, page or name belongs.
|
|
33
|
+
* @lastreviewed null
|
|
34
|
+
*/
|
|
35
|
+
const SECRET_PREFIXES: readonly ["b6p_g_", "b6p_t_", "b6pt_", "b6p_o_"];
|
|
36
|
+
/**
|
|
37
|
+
* The legacy prefix alone. Kept for consumers that imported it; core no longer reads it.
|
|
38
|
+
* @deprecated Use {@link TOKEN_PREFIXES} to accept tokens and {@link SECRET_PREFIXES} to recognise secrets.
|
|
15
39
|
* @lastreviewed null
|
|
16
40
|
*/
|
|
17
41
|
const TOKEN_PREFIX = "b6pt_";
|
|
@@ -46,6 +70,44 @@ export declare namespace Gateway {
|
|
|
46
70
|
* @lastreviewed null
|
|
47
71
|
*/
|
|
48
72
|
const REFRESH_DAYS: readonly [30, 60, 90, 180, 365];
|
|
73
|
+
/**
|
|
74
|
+
* Device sign-in (`b6p auth login`) and the renewal of the token it makes. The token's scopes, lifetime and name
|
|
75
|
+
* are the gateway's (`mcp, kb:read, kb:push, registry:read, tokens:self`; 90 days; refreshable;
|
|
76
|
+
* `b6p on <host> <yyyy-MM-dd HH:mm>`): b6p asks for none of them.
|
|
77
|
+
* @lastreviewed null
|
|
78
|
+
*/
|
|
79
|
+
namespace SignIn {
|
|
80
|
+
/**
|
|
81
|
+
* The `client` b6p names itself as when it starts a sign-in.
|
|
82
|
+
* @lastreviewed null
|
|
83
|
+
*/
|
|
84
|
+
const CLIENT = "b6p";
|
|
85
|
+
/**
|
|
86
|
+
* The most code points of the computer's name sent as `host` (the gateway cuts to this too).
|
|
87
|
+
* @lastreviewed null
|
|
88
|
+
*/
|
|
89
|
+
const MAX_HOST = 40;
|
|
90
|
+
/**
|
|
91
|
+
* The most code points of `client`, `clientVersion` and `platform`.
|
|
92
|
+
* @lastreviewed null
|
|
93
|
+
*/
|
|
94
|
+
const MAX_LABEL = 32;
|
|
95
|
+
/**
|
|
96
|
+
* A renewal is due when this many days or fewer are left.
|
|
97
|
+
* @lastreviewed null
|
|
98
|
+
*/
|
|
99
|
+
const RENEW_WITHIN_DAYS = 30;
|
|
100
|
+
/**
|
|
101
|
+
* A renewal gives the token this many days from the moment of renewal (the sign-in's own lifetime).
|
|
102
|
+
* @lastreviewed null
|
|
103
|
+
*/
|
|
104
|
+
const RENEW_DAYS = 90;
|
|
105
|
+
/**
|
|
106
|
+
* A due renewal is tried at most once in this long on one computer (unless forced).
|
|
107
|
+
* @lastreviewed null
|
|
108
|
+
*/
|
|
109
|
+
const RENEW_ATTEMPT_INTERVAL_MS: number;
|
|
110
|
+
}
|
|
49
111
|
/**
|
|
50
112
|
* Request headers specific to the gateway contract.
|
|
51
113
|
* @lastreviewed null
|
|
@@ -80,6 +142,21 @@ export declare namespace Gateway {
|
|
|
80
142
|
const REGISTRY_TOMBSTONES = "/api/v1/registry/tombstones";
|
|
81
143
|
const GIT = "/api/v1/git";
|
|
82
144
|
const TOKENS = "/api/v1/tokens";
|
|
145
|
+
/**
|
|
146
|
+
* Device sign-in's start (`POST`, no token): b6p's `b6p auth login`.
|
|
147
|
+
* @lastreviewed null
|
|
148
|
+
*/
|
|
149
|
+
const DEVICE_LOGINS = "/api/v1/device-logins";
|
|
150
|
+
/**
|
|
151
|
+
* Device sign-in's poll (`POST {deviceCode}`, no token).
|
|
152
|
+
* @lastreviewed null
|
|
153
|
+
*/
|
|
154
|
+
const DEVICE_LOGIN_POLL = "/api/v1/device-logins/poll";
|
|
155
|
+
/**
|
|
156
|
+
* The gateway's sign-in options (`GET`, anonymous); `deviceLogin: true` when device sign-in is on.
|
|
157
|
+
* @lastreviewed null
|
|
158
|
+
*/
|
|
159
|
+
const AUTH_OPTIONS = "/api/v1/auth/options";
|
|
83
160
|
/**
|
|
84
161
|
* The gateway's MCP endpoint (streamable HTTP), which takes the same `b6pt_` token with the `mcp` scope.
|
|
85
162
|
* @lastreviewed null
|
|
@@ -109,5 +186,11 @@ export declare namespace Gateway {
|
|
|
109
186
|
const REGISTRY_PUSH = "registry:push";
|
|
110
187
|
const MCP = "mcp";
|
|
111
188
|
const TOKENS_SELF = "tokens:self";
|
|
189
|
+
const KB_REWRITE = "kb:rewrite";
|
|
190
|
+
/**
|
|
191
|
+
* Every scope name the gateway issues. A device sign-in's approval naming anything else is off-contract.
|
|
192
|
+
* @lastreviewed null
|
|
193
|
+
*/
|
|
194
|
+
const KNOWN: readonly string[];
|
|
112
195
|
}
|
|
113
196
|
}
|
|
@@ -15,7 +15,31 @@ var Gateway;
|
|
|
15
15
|
*/
|
|
16
16
|
Gateway.DEFAULT_URL = "https://gateway.bluestep.net";
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* The prefixes of the platform tokens b6p accepts, stores and sends (web-shared `TokenPrefix`):
|
|
19
|
+
* - `b6p_g_`: a global user's token, as minted since web-global's strict mints;
|
|
20
|
+
* - `b6p_t_`: a tenant's own user's token;
|
|
21
|
+
* - `b6pt_`: the legacy global token, still accepted everywhere (deprecated by the platform, never minted again).
|
|
22
|
+
*
|
|
23
|
+
* Minted tokens are the prefix and 48 lower-case hex characters; b6p checks only the prefix and that the rest is
|
|
24
|
+
* printable ASCII (the alphabet is the platform's business). No prefix is a prefix of another.
|
|
25
|
+
* @lastreviewed null
|
|
26
|
+
*/
|
|
27
|
+
Gateway.TOKEN_PREFIXES = ["b6p_g_", "b6p_t_", "b6pt_"];
|
|
28
|
+
/**
|
|
29
|
+
* Prefixes the platform reserves and b6p never accepts as a platform token: `b6p_o_` is for OAuth access tokens.
|
|
30
|
+
* A value with one is still a secret, so it is redacted like the others ({@link SECRET_PREFIXES}).
|
|
31
|
+
* @lastreviewed null
|
|
32
|
+
*/
|
|
33
|
+
Gateway.RESERVED_TOKEN_PREFIXES = ["b6p_o_"];
|
|
34
|
+
/**
|
|
35
|
+
* Every prefix that marks a secret: {@link TOKEN_PREFIXES} and {@link RESERVED_TOKEN_PREFIXES}. Anything starting
|
|
36
|
+
* with one (in any letter case) is redacted from messages and refused where an id, alias, page or name belongs.
|
|
37
|
+
* @lastreviewed null
|
|
38
|
+
*/
|
|
39
|
+
Gateway.SECRET_PREFIXES = [...Gateway.TOKEN_PREFIXES, ...Gateway.RESERVED_TOKEN_PREFIXES];
|
|
40
|
+
/**
|
|
41
|
+
* The legacy prefix alone. Kept for consumers that imported it; core no longer reads it.
|
|
42
|
+
* @deprecated Use {@link TOKEN_PREFIXES} to accept tokens and {@link SECRET_PREFIXES} to recognise secrets.
|
|
19
43
|
* @lastreviewed null
|
|
20
44
|
*/
|
|
21
45
|
Gateway.TOKEN_PREFIX = "b6pt_";
|
|
@@ -50,6 +74,45 @@ var Gateway;
|
|
|
50
74
|
* @lastreviewed null
|
|
51
75
|
*/
|
|
52
76
|
Gateway.REFRESH_DAYS = [30, 60, 90, 180, 365];
|
|
77
|
+
/**
|
|
78
|
+
* Device sign-in (`b6p auth login`) and the renewal of the token it makes. The token's scopes, lifetime and name
|
|
79
|
+
* are the gateway's (`mcp, kb:read, kb:push, registry:read, tokens:self`; 90 days; refreshable;
|
|
80
|
+
* `b6p on <host> <yyyy-MM-dd HH:mm>`): b6p asks for none of them.
|
|
81
|
+
* @lastreviewed null
|
|
82
|
+
*/
|
|
83
|
+
let SignIn;
|
|
84
|
+
(function (SignIn) {
|
|
85
|
+
/**
|
|
86
|
+
* The `client` b6p names itself as when it starts a sign-in.
|
|
87
|
+
* @lastreviewed null
|
|
88
|
+
*/
|
|
89
|
+
SignIn.CLIENT = "b6p";
|
|
90
|
+
/**
|
|
91
|
+
* The most code points of the computer's name sent as `host` (the gateway cuts to this too).
|
|
92
|
+
* @lastreviewed null
|
|
93
|
+
*/
|
|
94
|
+
SignIn.MAX_HOST = 40;
|
|
95
|
+
/**
|
|
96
|
+
* The most code points of `client`, `clientVersion` and `platform`.
|
|
97
|
+
* @lastreviewed null
|
|
98
|
+
*/
|
|
99
|
+
SignIn.MAX_LABEL = 32;
|
|
100
|
+
/**
|
|
101
|
+
* A renewal is due when this many days or fewer are left.
|
|
102
|
+
* @lastreviewed null
|
|
103
|
+
*/
|
|
104
|
+
SignIn.RENEW_WITHIN_DAYS = 30;
|
|
105
|
+
/**
|
|
106
|
+
* A renewal gives the token this many days from the moment of renewal (the sign-in's own lifetime).
|
|
107
|
+
* @lastreviewed null
|
|
108
|
+
*/
|
|
109
|
+
SignIn.RENEW_DAYS = 90;
|
|
110
|
+
/**
|
|
111
|
+
* A due renewal is tried at most once in this long on one computer (unless forced).
|
|
112
|
+
* @lastreviewed null
|
|
113
|
+
*/
|
|
114
|
+
SignIn.RENEW_ATTEMPT_INTERVAL_MS = 24 * 60 * 60 * 1_000;
|
|
115
|
+
})(SignIn = Gateway.SignIn || (Gateway.SignIn = {}));
|
|
53
116
|
/**
|
|
54
117
|
* Request headers specific to the gateway contract.
|
|
55
118
|
* @lastreviewed null
|
|
@@ -86,6 +149,21 @@ var Gateway;
|
|
|
86
149
|
Paths.REGISTRY_TOMBSTONES = "/api/v1/registry/tombstones";
|
|
87
150
|
Paths.GIT = "/api/v1/git";
|
|
88
151
|
Paths.TOKENS = "/api/v1/tokens";
|
|
152
|
+
/**
|
|
153
|
+
* Device sign-in's start (`POST`, no token): b6p's `b6p auth login`.
|
|
154
|
+
* @lastreviewed null
|
|
155
|
+
*/
|
|
156
|
+
Paths.DEVICE_LOGINS = "/api/v1/device-logins";
|
|
157
|
+
/**
|
|
158
|
+
* Device sign-in's poll (`POST {deviceCode}`, no token).
|
|
159
|
+
* @lastreviewed null
|
|
160
|
+
*/
|
|
161
|
+
Paths.DEVICE_LOGIN_POLL = "/api/v1/device-logins/poll";
|
|
162
|
+
/**
|
|
163
|
+
* The gateway's sign-in options (`GET`, anonymous); `deviceLogin: true` when device sign-in is on.
|
|
164
|
+
* @lastreviewed null
|
|
165
|
+
*/
|
|
166
|
+
Paths.AUTH_OPTIONS = "/api/v1/auth/options";
|
|
89
167
|
/**
|
|
90
168
|
* The gateway's MCP endpoint (streamable HTTP), which takes the same `b6pt_` token with the `mcp` scope.
|
|
91
169
|
* @lastreviewed null
|
|
@@ -116,6 +194,21 @@ var Gateway;
|
|
|
116
194
|
Scopes.REGISTRY_PUSH = "registry:push";
|
|
117
195
|
Scopes.MCP = "mcp";
|
|
118
196
|
Scopes.TOKENS_SELF = "tokens:self";
|
|
197
|
+
Scopes.KB_REWRITE = "kb:rewrite";
|
|
198
|
+
/**
|
|
199
|
+
* Every scope name the gateway issues. A device sign-in's approval naming anything else is off-contract.
|
|
200
|
+
* @lastreviewed null
|
|
201
|
+
*/
|
|
202
|
+
Scopes.KNOWN = [
|
|
203
|
+
Scopes.KB_READ,
|
|
204
|
+
Scopes.KB_PUSH,
|
|
205
|
+
Scopes.KB_MANAGE,
|
|
206
|
+
Scopes.KB_REWRITE,
|
|
207
|
+
Scopes.REGISTRY_READ,
|
|
208
|
+
Scopes.REGISTRY_PUSH,
|
|
209
|
+
Scopes.MCP,
|
|
210
|
+
Scopes.TOKENS_SELF,
|
|
211
|
+
];
|
|
119
212
|
})(Scopes = Gateway.Scopes || (Gateway.Scopes = {}));
|
|
120
213
|
})(Gateway || (exports.Gateway = Gateway = {}));
|
|
121
214
|
//# sourceMappingURL=Gateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../../src/constants/Gateway.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,IAAiB,OAAO,
|
|
1
|
+
{"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../../src/constants/Gateway.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,IAAiB,OAAO,CAqNvB;AArND,WAAiB,OAAO;IACtB;;;OAGG;IACU,mBAAW,GAAG,8BAA8B,CAAC;IAE1D;;;;;;;;;OASG;IACU,sBAAc,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;IAErE;;;;OAIG;IACU,+BAAuB,GAAG,CAAC,QAAQ,CAAU,CAAC;IAE3D;;;;OAIG;IACU,uBAAe,GAAG,CAAC,GAAG,sBAAc,EAAE,GAAG,+BAAuB,CAAU,CAAC;IAExF;;;;OAIG;IACU,oBAAY,GAAG,OAAO,CAAC;IAEpC;;;OAGG;IACU,0BAAkB,GAAG,MAAM,CAAC;IAEzC;;;;OAIG;IACU,iCAAyB,GAAG,MAAM,CAAC;IAEhD;;;;;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