@bluestep-systems/b6p-core 0.8.1 → 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.
Files changed (149) hide show
  1. package/README.md +310 -32
  2. package/dist/B6PCore.d.ts +7 -0
  3. package/dist/B6PCore.js +96 -1
  4. package/dist/B6PCore.js.map +1 -1
  5. package/dist/B6PUri.d.ts +6 -8
  6. package/dist/B6PUri.js +6 -8
  7. package/dist/B6PUri.js.map +1 -1
  8. package/dist/Err.d.ts +421 -0
  9. package/dist/Err.js +558 -0
  10. package/dist/Err.js.map +1 -1
  11. package/dist/auth/BearerAuthProvider.d.ts +32 -0
  12. package/dist/auth/BearerAuthProvider.js +49 -0
  13. package/dist/auth/BearerAuthProvider.js.map +1 -1
  14. package/dist/cache/OrgCache.js.map +1 -1
  15. package/dist/cache/ScriptMetaDataStore.js.map +1 -1
  16. package/dist/constants/ApiEndpoints.d.ts +1 -0
  17. package/dist/constants/ApiEndpoints.js +1 -0
  18. package/dist/constants/ApiEndpoints.js.map +1 -1
  19. package/dist/constants/AuthTypes.js.map +1 -1
  20. package/dist/constants/BlueHQ.js.map +1 -1
  21. package/dist/constants/CryptoAlgorithms.js.map +1 -1
  22. package/dist/constants/ExtensionConfig.js.map +1 -1
  23. package/dist/constants/FileExtensions.js.map +1 -1
  24. package/dist/constants/FolderNames.js.map +1 -1
  25. package/dist/constants/Gateway.d.ts +71 -0
  26. package/dist/constants/Gateway.js +79 -0
  27. package/dist/constants/Gateway.js.map +1 -0
  28. package/dist/constants/GitHubUrls.js.map +1 -1
  29. package/dist/constants/Http.js.map +1 -1
  30. package/dist/constants/MimeTypes.js.map +1 -1
  31. package/dist/constants/Numerical.js.map +1 -1
  32. package/dist/constants/OutputChannels.js.map +1 -1
  33. package/dist/constants/SettingsKeys.d.ts +5 -0
  34. package/dist/constants/SettingsKeys.js +5 -0
  35. package/dist/constants/SettingsKeys.js.map +1 -1
  36. package/dist/constants/SpecialFiles.js.map +1 -1
  37. package/dist/constants/WebDAVElements.js.map +1 -1
  38. package/dist/constants/index.d.ts +1 -0
  39. package/dist/constants/index.js +3 -1
  40. package/dist/constants/index.js.map +1 -1
  41. package/dist/data/DownstairsPathParser.js.map +1 -1
  42. package/dist/data/GlobMatcher.js.map +1 -1
  43. package/dist/data/IdUtility.js.map +1 -1
  44. package/dist/data/OrgWorker.js.map +1 -1
  45. package/dist/data/ScriptKey.d.ts +3 -27
  46. package/dist/data/ScriptKey.js +12 -24
  47. package/dist/data/ScriptKey.js.map +1 -1
  48. package/dist/data/ScriptUrlParser.js +3 -1
  49. package/dist/data/ScriptUrlParser.js.map +1 -1
  50. package/dist/data/ServerVersion.d.ts +76 -0
  51. package/dist/data/ServerVersion.js +111 -0
  52. package/dist/data/ServerVersion.js.map +1 -0
  53. package/dist/data/index.d.ts +2 -0
  54. package/dist/data/index.js +7 -1
  55. package/dist/data/index.js.map +1 -1
  56. package/dist/gateway/GatewayClient.d.ts +147 -0
  57. package/dist/gateway/GatewayClient.js +395 -0
  58. package/dist/gateway/GatewayClient.js.map +1 -0
  59. package/dist/gateway/GatewayContext.d.ts +43 -0
  60. package/dist/gateway/GatewayContext.js +3 -0
  61. package/dist/gateway/GatewayContext.js.map +1 -0
  62. package/dist/gateway/GatewayGit.d.ts +291 -0
  63. package/dist/gateway/GatewayGit.js +731 -0
  64. package/dist/gateway/GatewayGit.js.map +1 -0
  65. package/dist/gateway/GatewayKb.d.ts +173 -0
  66. package/dist/gateway/GatewayKb.js +354 -0
  67. package/dist/gateway/GatewayKb.js.map +1 -0
  68. package/dist/gateway/GatewayMarketplace.d.ts +116 -0
  69. package/dist/gateway/GatewayMarketplace.js +278 -0
  70. package/dist/gateway/GatewayMarketplace.js.map +1 -0
  71. package/dist/gateway/GatewayService.d.ts +47 -0
  72. package/dist/gateway/GatewayService.js +54 -0
  73. package/dist/gateway/GatewayService.js.map +1 -0
  74. package/dist/gateway/GatewayToken.d.ts +18 -0
  75. package/dist/gateway/GatewayToken.js +43 -0
  76. package/dist/gateway/GatewayToken.js.map +1 -0
  77. package/dist/gateway/GatewayTokenService.d.ts +101 -0
  78. package/dist/gateway/GatewayTokenService.js +465 -0
  79. package/dist/gateway/GatewayTokenService.js.map +1 -0
  80. package/dist/index.d.ts +29 -8
  81. package/dist/index.js +81 -9
  82. package/dist/index.js.map +1 -1
  83. package/dist/network/HttpClient.js.map +1 -1
  84. package/dist/network/HttpClientProvider.js.map +1 -1
  85. package/dist/network/StatusCodes.js.map +1 -1
  86. package/dist/persistence/PersistablePseudoMap.js.map +1 -1
  87. package/dist/persistence/PersistenceKeys.js.map +1 -1
  88. package/dist/persistence/PrivatePersistanceMap.js.map +1 -1
  89. package/dist/persistence/PseudoMap.js.map +1 -1
  90. package/dist/persistence/PublicPersistanceMap.js.map +1 -1
  91. package/dist/persistence/Serializable.js.map +1 -1
  92. package/dist/persistence/SharedFilePersistence.d.ts +22 -0
  93. package/dist/persistence/SharedFilePersistence.js +65 -14
  94. package/dist/persistence/SharedFilePersistence.js.map +1 -1
  95. package/dist/persistence/TypedMap.js.map +1 -1
  96. package/dist/persistence/TypedPersistable.js.map +1 -1
  97. package/dist/persistence/TypedPrivatePersistable.js.map +1 -1
  98. package/dist/persistence/dirLockdown.js.map +1 -1
  99. package/dist/providers.d.ts +46 -16
  100. package/dist/script/GitIdentity.d.ts +48 -0
  101. package/dist/script/GitIdentity.js +52 -0
  102. package/dist/script/GitIdentity.js.map +1 -0
  103. package/dist/script/GitSync.d.ts +388 -0
  104. package/dist/script/GitSync.js +1068 -0
  105. package/dist/script/GitSync.js.map +1 -0
  106. package/dist/script/ScriptContext.d.ts +20 -5
  107. package/dist/script/ScriptFactory.d.ts +1 -2
  108. package/dist/script/ScriptFactory.js +1 -2
  109. package/dist/script/ScriptFactory.js.map +1 -1
  110. package/dist/script/ScriptFile.d.ts +0 -94
  111. package/dist/script/ScriptFile.js +0 -245
  112. package/dist/script/ScriptFile.js.map +1 -1
  113. package/dist/script/ScriptFolder.d.ts +0 -9
  114. package/dist/script/ScriptFolder.js +4 -7
  115. package/dist/script/ScriptFolder.js.map +1 -1
  116. package/dist/script/ScriptNode.d.ts +0 -9
  117. package/dist/script/ScriptNode.js.map +1 -1
  118. package/dist/script/ScriptRoot.d.ts +0 -65
  119. package/dist/script/ScriptRoot.js +0 -199
  120. package/dist/script/ScriptRoot.js.map +1 -1
  121. package/dist/script/ScriptService.d.ts +113 -9
  122. package/dist/script/ScriptService.js +164 -52
  123. package/dist/script/ScriptService.js.map +1 -1
  124. package/dist/script/ServerCompile.d.ts +35 -0
  125. package/dist/script/ServerCompile.js +40 -0
  126. package/dist/script/ServerCompile.js.map +1 -0
  127. package/dist/script/TsConfig.d.ts +2 -2
  128. package/dist/script/TsConfig.js +3 -3
  129. package/dist/script/TsConfig.js.map +1 -1
  130. package/dist/script/push.d.ts +162 -188
  131. package/dist/script/push.js +216 -474
  132. package/dist/script/push.js.map +1 -1
  133. package/dist/session/SessionManager.js.map +1 -1
  134. package/dist/testing/FakeGateway.d.ts +280 -0
  135. package/dist/testing/FakeGateway.js +627 -0
  136. package/dist/testing/FakeGateway.js.map +1 -0
  137. package/dist/testing/MockFileSystem.js.map +1 -1
  138. package/dist/types.d.ts +332 -0
  139. package/dist/update/UpdateService.js.map +1 -1
  140. package/package.json +17 -12
  141. package/dist/script/ScriptTranspiler.d.ts +0 -121
  142. package/dist/script/ScriptTranspiler.js +0 -333
  143. package/dist/script/ScriptTranspiler.js.map +0 -1
  144. package/dist/script/SnapshotHistoryRecorder.d.ts +0 -47
  145. package/dist/script/SnapshotHistoryRecorder.js +0 -231
  146. package/dist/script/SnapshotHistoryRecorder.js.map +0 -1
  147. package/dist/script/TsLibResolver.d.ts +0 -60
  148. package/dist/script/TsLibResolver.js +0 -134
  149. package/dist/script/TsLibResolver.js.map +0 -1
@@ -0,0 +1,101 @@
1
+ import type { GatewayCreatedToken, GatewayTokenCreateRequest, GatewayTokenRevokeResult, GatewayTokenRotateResult, GatewayTokenSummary } from "../types";
2
+ import type { GatewayClient } from "./GatewayClient";
3
+ import type { GatewayContext } from "./GatewayContext";
4
+ /**
5
+ * Self-service management of the caller's own gateway access tokens (`core.gateway.tokens`), per
6
+ * the contract's §Tokens. Every route needs the `tokens:self` scope on the presenting token, which
7
+ * is the one b6p has stored; nothing here addresses another user.
8
+ *
9
+ * Secrets: a minted secret is returned once, in the result, and never logged or put in an error
10
+ * message. Every request goes through the gateway's one {@link GatewayClient}, so they stay
11
+ * sequential with the rest of the gateway's traffic.
12
+ *
13
+ * There is still ONE stored token. {@link rotate} replaces it when the rotated token is the stored
14
+ * one; {@link revoke} of the stored token leaves it in place (dead) and says so, and the consumer
15
+ * decides what to do. Warning about and confirming a never-expiring token is the consumer's job;
16
+ * results carry `neverExpires` so it can tell.
17
+ * @lastreviewed null
18
+ */
19
+ export declare class GatewayTokenService {
20
+ private readonly client;
21
+ private readonly ctx;
22
+ constructor(client: GatewayClient, ctx: GatewayContext);
23
+ /**
24
+ * The caller's tokens. `current` marks the one that made the request (the stored one).
25
+ * @throws {Err.GatewayError} a subclass; `GatewayScopeError` with `scope: "tokens:self"` when the
26
+ * stored token may not manage tokens
27
+ * @lastreviewed null
28
+ */
29
+ list(): Promise<GatewayTokenSummary[]>;
30
+ /**
31
+ * Mint a new token for the caller. The result holds the secret, which the gateway shows only
32
+ * this once.
33
+ *
34
+ * - `expiresAt` left out: none is sent. The gateway mints for the sooner of 90 days and the
35
+ * presenting token's expiry; when that cut more than 24 hours off the 90 days, the result's
36
+ * `expiryCapped` says so and gives the date the gateway returned.
37
+ * - `expiresAt` a date, or `null` (never): sent as given, and `expiryCapped` is `null`. A `403
38
+ * not-permitted` with reason `expiry-exceeds-presenting` is
39
+ * {@link Err.GatewayTokenExpiryRefusedError}.
40
+ *
41
+ * @throws {Err.GatewayInvalidArgumentError} before sending, for an empty or malformed alias or scope
42
+ * list, or an expiry that is not a date
43
+ * @throws {Err.GatewayInvalidRequestError} the gateway rejected the request (`400 invalid-request`)
44
+ * @throws {Err.GatewayScopeEscalationError} a scope the presenting token lacks was asked for
45
+ * @throws {Err.GatewayAliasTakenError} another of the caller's tokens has the alias
46
+ * @throws {Err.GatewayTokenLimitError} the caller already holds the maximum number of live tokens
47
+ * @throws {Err.GatewayTokenExpiryRefusedError} the requested expiry outlives the presenting token
48
+ * @throws {Err.GatewayRestrictedMintsDisabledError} the gateway is not yet minting tokens beyond `mcp`
49
+ * @throws {Err.GatewayRewriteNotPermittedError} the account may not hold `kb:rewrite`
50
+ * @throws {Err.GatewayOffContractTokenError} the token was minted but the answer was malformed;
51
+ * the error carries the secret
52
+ * @lastreviewed null
53
+ */
54
+ create(request: GatewayTokenCreateRequest): Promise<GatewayCreatedToken>;
55
+ /**
56
+ * Revoke one of the caller's tokens, by id or alias (resolved through the list first, in the
57
+ * same queue entry and with the same token as the revoke).
58
+ * Revoking the stored token is allowed: the result says `revokedCurrent: true`, and the stored
59
+ * token is left in place for the consumer to deal with.
60
+ *
61
+ * @throws {Err.GatewayInvalidArgumentError} before sending, for an empty id-or-alias or one containing `b6pt_`
62
+ * @throws {Err.GatewayNotFoundError} no token of the caller's has that id or alias
63
+ * @throws {Err.GatewayTokenAmbiguousError} it matches one token's id and another's alias
64
+ * @lastreviewed null
65
+ */
66
+ revoke(idOrAlias: string): Promise<GatewayTokenRevokeResult>;
67
+ /**
68
+ * Rotate one of the caller's tokens, by id or alias: the gateway atomically mints a replacement
69
+ * with the same alias, scopes and absolute end date and revokes the old one. When the rotated
70
+ * token is the stored one, the replacement is stored in its place.
71
+ *
72
+ * The list, the rotate request and the store run as one entry in the client's queue and present
73
+ * one read of the stored token, so nothing queued behind can present the revoked token, and the
74
+ * store replaces exactly the token that was rotated. A secret the gateway returns is never
75
+ * dropped, whatever fails after it arrives.
76
+ *
77
+ * **Idempotency.** Each call generates one `Idempotency-Key` (a UUID) and sends it on the rotate
78
+ * request. When that request goes unanswered ({@link Err.GatewayUnavailableError}: a dropped
79
+ * connection, a timeout, `502`/`503`/`504`), it is retried once, at once, in the same queue
80
+ * entry, with the same key and the same presenting token; the gateway answers such a retry with
81
+ * the first attempt's result and never rotates twice. A successful retry is the normal path (a
82
+ * stored token's replacement is stored). An unanswered retry is
83
+ * {@link Err.GatewayOutcomeUnknownError} (`retried: true`), and so is a retry refused `401` or
84
+ * `404` when the target is the stored token: the first attempt most likely rotated, and so
85
+ * revoked, the very token the retry presents. The store is then left untouched. Any other error on
86
+ * the retry passes through. The key is not a secret, but it is never logged or put in a message.
87
+ *
88
+ * @throws {Err.GatewayNotFoundError} no token of the caller's has that id or alias
89
+ * @throws {Err.GatewayInvalidRequestError} the gateway refused the rotation (`400 invalid-request`),
90
+ * e.g. the target has expired
91
+ * @throws {Err.GatewayOutcomeUnknownError} the rotation may have happened and its answer never arrived
92
+ * @throws {Err.GatewayTokenAmbiguousError} it matches one token's id and another's alias
93
+ * @throws {Err.GatewayRewriteNotPermittedError} the token holds `kb:rewrite` and the account may not
94
+ * @throws {Err.GatewayTokenStoreError} the stored token was rotated (so it is already revoked) but
95
+ * its replacement could not be stored; the error carries the replacement, secret included
96
+ * @throws {Err.GatewayOffContractTokenError} the token was rotated but the answer was malformed; the
97
+ * error carries the secret, and says whether it was stored (only tried for the stored token)
98
+ * @lastreviewed null
99
+ */
100
+ rotate(idOrAlias: string): Promise<GatewayTokenRotateResult>;
101
+ }
@@ -0,0 +1,465 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GatewayTokenService = void 0;
4
+ const node_crypto_1 = require("node:crypto");
5
+ const Gateway_1 = require("../constants/Gateway");
6
+ const Http_1 = require("../constants/Http");
7
+ const Err_1 = require("../Err");
8
+ const GatewayToken_1 = require("./GatewayToken");
9
+ /**
10
+ * Whitespace or control characters; refused in an alias or a scope.
11
+ * @lastreviewed null
12
+ */
13
+ const BAD_CHARS = /[\s\u0000-\u001f\u007f]/;
14
+ /**
15
+ * The default lifetime of a token minted with no expiry (ruling 48's cap applies against it).
16
+ * @lastreviewed null
17
+ */
18
+ const DEFAULT_LIFETIME_MS = 90 * 24 * 60 * 60 * 1_000;
19
+ /**
20
+ * A cap that cuts no more than this off the 90 days is applied but not reported (`expiryCapped` stays null).
21
+ * @lastreviewed null
22
+ */
23
+ const REPORTABLE_CUT_MS = 24 * 60 * 60 * 1_000;
24
+ /**
25
+ * Self-service management of the caller's own gateway access tokens (`core.gateway.tokens`), per
26
+ * the contract's §Tokens. Every route needs the `tokens:self` scope on the presenting token, which
27
+ * is the one b6p has stored; nothing here addresses another user.
28
+ *
29
+ * Secrets: a minted secret is returned once, in the result, and never logged or put in an error
30
+ * message. Every request goes through the gateway's one {@link GatewayClient}, so they stay
31
+ * sequential with the rest of the gateway's traffic.
32
+ *
33
+ * There is still ONE stored token. {@link rotate} replaces it when the rotated token is the stored
34
+ * one; {@link revoke} of the stored token leaves it in place (dead) and says so, and the consumer
35
+ * decides what to do. Warning about and confirming a never-expiring token is the consumer's job;
36
+ * results carry `neverExpires` so it can tell.
37
+ * @lastreviewed null
38
+ */
39
+ class GatewayTokenService {
40
+ client;
41
+ ctx;
42
+ constructor(client, ctx) {
43
+ this.client = client;
44
+ this.ctx = ctx;
45
+ }
46
+ /**
47
+ * The caller's tokens. `current` marks the one that made the request (the stored one).
48
+ * @throws {Err.GatewayError} a subclass; `GatewayScopeError` with `scope: "tokens:self"` when the
49
+ * stored token may not manage tokens
50
+ * @lastreviewed null
51
+ */
52
+ async list() {
53
+ return listVia((method, path) => this.client.request(method, path));
54
+ }
55
+ /**
56
+ * Mint a new token for the caller. The result holds the secret, which the gateway shows only
57
+ * this once.
58
+ *
59
+ * - `expiresAt` left out: none is sent. The gateway mints for the sooner of 90 days and the
60
+ * presenting token's expiry; when that cut more than 24 hours off the 90 days, the result's
61
+ * `expiryCapped` says so and gives the date the gateway returned.
62
+ * - `expiresAt` a date, or `null` (never): sent as given, and `expiryCapped` is `null`. A `403
63
+ * not-permitted` with reason `expiry-exceeds-presenting` is
64
+ * {@link Err.GatewayTokenExpiryRefusedError}.
65
+ *
66
+ * @throws {Err.GatewayInvalidArgumentError} before sending, for an empty or malformed alias or scope
67
+ * list, or an expiry that is not a date
68
+ * @throws {Err.GatewayInvalidRequestError} the gateway rejected the request (`400 invalid-request`)
69
+ * @throws {Err.GatewayScopeEscalationError} a scope the presenting token lacks was asked for
70
+ * @throws {Err.GatewayAliasTakenError} another of the caller's tokens has the alias
71
+ * @throws {Err.GatewayTokenLimitError} the caller already holds the maximum number of live tokens
72
+ * @throws {Err.GatewayTokenExpiryRefusedError} the requested expiry outlives the presenting token
73
+ * @throws {Err.GatewayRestrictedMintsDisabledError} the gateway is not yet minting tokens beyond `mcp`
74
+ * @throws {Err.GatewayRewriteNotPermittedError} the account may not hold `kb:rewrite`
75
+ * @throws {Err.GatewayOffContractTokenError} the token was minted but the answer was malformed;
76
+ * the error carries the secret
77
+ * @lastreviewed null
78
+ */
79
+ async create(request) {
80
+ checkAlias(request.alias);
81
+ const scopes = checkScopes(request.scopes);
82
+ const body = { alias: request.alias, scopes };
83
+ if (request.expiresAt === null) {
84
+ body.expiresAt = null;
85
+ }
86
+ else if (request.expiresAt !== undefined) {
87
+ if (!isIsoDateTime(request.expiresAt)) {
88
+ throw new Err_1.Err.GatewayInvalidArgumentError("The token's expiry is not an ISO 8601 date-time with a time zone (Z or an offset).");
89
+ }
90
+ body.expiresAt = request.expiresAt;
91
+ }
92
+ const what = `${Http_1.Http.Methods.POST} ${Gateway_1.Gateway.Paths.TOKENS}`;
93
+ const answer = await outcomeUnknownOnUnavailable(() => this.client
94
+ .request(Http_1.Http.Methods.POST, Gateway_1.Gateway.Paths.TOKENS, { body })
95
+ .catch(explainMintRefusal(request.expiresAt)), "create", "a token may have been minted, and its secret was never received");
96
+ const mintedAt = Date.now();
97
+ const parsed = parseMinted(answer, what, "the token may have been minted");
98
+ if (parsed.minted) {
99
+ let expiryCapped = null;
100
+ // Derived from the answer: the gateway minted for min(90 days, the presenting token's expiry).
101
+ if (request.expiresAt === undefined && parsed.minted.expiresAt !== null) {
102
+ const cut = mintedAt + DEFAULT_LIFETIME_MS - Date.parse(parsed.minted.expiresAt);
103
+ // A cut of a day or less is not worth reporting.
104
+ if (cut > REPORTABLE_CUT_MS) {
105
+ expiryCapped = { cappedTo: parsed.minted.expiresAt, requested: "90d" };
106
+ }
107
+ }
108
+ return { ...parsed.minted, expiryCapped };
109
+ }
110
+ throw new Err_1.Err.GatewayOffContractTokenError(`${what}: a token was minted, but the gateway's answer describing it was malformed.`, "create", parsed.secret, false);
111
+ }
112
+ /**
113
+ * Revoke one of the caller's tokens, by id or alias (resolved through the list first, in the
114
+ * same queue entry and with the same token as the revoke).
115
+ * Revoking the stored token is allowed: the result says `revokedCurrent: true`, and the stored
116
+ * token is left in place for the consumer to deal with.
117
+ *
118
+ * @throws {Err.GatewayInvalidArgumentError} before sending, for an empty id-or-alias or one containing `b6pt_`
119
+ * @throws {Err.GatewayNotFoundError} no token of the caller's has that id or alias
120
+ * @throws {Err.GatewayTokenAmbiguousError} it matches one token's id and another's alias
121
+ * @lastreviewed null
122
+ */
123
+ async revoke(idOrAlias) {
124
+ const wanted = checkIdOrAlias(idOrAlias);
125
+ // One queue entry and one token read: `current` describes the token the DELETE presents.
126
+ return this.client.sequence(async (seq) => {
127
+ const target = pick(await listVia(seq.request), wanted);
128
+ await seq.request(Http_1.Http.Methods.DELETE, `${Gateway_1.Gateway.Paths.TOKENS}/${encodeURIComponent(target.id)}`);
129
+ return { id: target.id, alias: target.alias, revokedCurrent: target.current };
130
+ });
131
+ }
132
+ /**
133
+ * Rotate one of the caller's tokens, by id or alias: the gateway atomically mints a replacement
134
+ * with the same alias, scopes and absolute end date and revokes the old one. When the rotated
135
+ * token is the stored one, the replacement is stored in its place.
136
+ *
137
+ * The list, the rotate request and the store run as one entry in the client's queue and present
138
+ * one read of the stored token, so nothing queued behind can present the revoked token, and the
139
+ * store replaces exactly the token that was rotated. A secret the gateway returns is never
140
+ * dropped, whatever fails after it arrives.
141
+ *
142
+ * **Idempotency.** Each call generates one `Idempotency-Key` (a UUID) and sends it on the rotate
143
+ * request. When that request goes unanswered ({@link Err.GatewayUnavailableError}: a dropped
144
+ * connection, a timeout, `502`/`503`/`504`), it is retried once, at once, in the same queue
145
+ * entry, with the same key and the same presenting token; the gateway answers such a retry with
146
+ * the first attempt's result and never rotates twice. A successful retry is the normal path (a
147
+ * stored token's replacement is stored). An unanswered retry is
148
+ * {@link Err.GatewayOutcomeUnknownError} (`retried: true`), and so is a retry refused `401` or
149
+ * `404` when the target is the stored token: the first attempt most likely rotated, and so
150
+ * revoked, the very token the retry presents. The store is then left untouched. Any other error on
151
+ * the retry passes through. The key is not a secret, but it is never logged or put in a message.
152
+ *
153
+ * @throws {Err.GatewayNotFoundError} no token of the caller's has that id or alias
154
+ * @throws {Err.GatewayInvalidRequestError} the gateway refused the rotation (`400 invalid-request`),
155
+ * e.g. the target has expired
156
+ * @throws {Err.GatewayOutcomeUnknownError} the rotation may have happened and its answer never arrived
157
+ * @throws {Err.GatewayTokenAmbiguousError} it matches one token's id and another's alias
158
+ * @throws {Err.GatewayRewriteNotPermittedError} the token holds `kb:rewrite` and the account may not
159
+ * @throws {Err.GatewayTokenStoreError} the stored token was rotated (so it is already revoked) but
160
+ * its replacement could not be stored; the error carries the replacement, secret included
161
+ * @throws {Err.GatewayOffContractTokenError} the token was rotated but the answer was malformed; the
162
+ * error carries the secret, and says whether it was stored (only tried for the stored token)
163
+ * @lastreviewed null
164
+ */
165
+ async rotate(idOrAlias) {
166
+ const wanted = checkIdOrAlias(idOrAlias);
167
+ // ONE queue entry for list + rotate + store, so no queued request runs between the gateway
168
+ // revoking the old token and the replacement landing in the store; and ONE token read
169
+ // (`seq.token()`), so `current`, the token the rotate presents and the store's `expected` agree.
170
+ return this.client.sequence(async (seq) => {
171
+ const target = pick(await listVia(seq.request), wanted);
172
+ const path = `${Gateway_1.Gateway.Paths.TOKENS}/${encodeURIComponent(target.id)}/rotate`;
173
+ const what = `${Http_1.Http.Methods.POST} ${path}`;
174
+ // One key per call, reused only by this call's one retry. Not a secret, but never logged or quoted.
175
+ const idempotencyKey = (0, node_crypto_1.randomUUID)();
176
+ const answer = await sendRotate(() => seq
177
+ .request(Http_1.Http.Methods.POST, path, { headers: { [Gateway_1.Gateway.Headers.IDEMPOTENCY_KEY]: idempotencyKey } })
178
+ .catch(explainMintRefusal(undefined)), what, target, this.ctx.logger);
179
+ const parsed = parseMinted(answer, what, "the token may have been rotated");
180
+ const secret = parsed.minted ? parsed.minted.token : parsed.secret;
181
+ const replaced = { id: target.id, alias: target.alias };
182
+ if (!target.current) {
183
+ if (!parsed.minted) {
184
+ throw new Err_1.Err.GatewayOffContractTokenError(`${what}: the token "${target.alias}" was rotated and the old one is revoked, but the gateway's answer describing the replacement was malformed. It is not the stored token, so nothing was stored.`, "rotate", secret, false);
185
+ }
186
+ return { replaced, token: parsed.minted, rotatedCurrent: false };
187
+ }
188
+ // The stored token is already revoked at the gateway: offer the secret to the store even
189
+ // when the rest of the answer is off-contract, and never drop it.
190
+ let storeFailure;
191
+ try {
192
+ const problem = (0, GatewayToken_1.gatewayTokenProblem)(secret);
193
+ if (problem) {
194
+ throw new Error(`the replacement is not usable as a gateway token: ${problem}`);
195
+ }
196
+ await this.ctx.gatewayTokenStore.replace(await seq.token(), secret);
197
+ }
198
+ catch (error) {
199
+ storeFailure = (0, GatewayToken_1.redactToken)((0, GatewayToken_1.redactToken)(error instanceof Error ? error.message : String(error), secret), await seq.token());
200
+ }
201
+ if (!parsed.minted) {
202
+ const outcome = storeFailure === undefined
203
+ ? "The replacement was stored in its place."
204
+ : `The replacement could not be stored: ${storeFailure}`;
205
+ throw new Err_1.Err.GatewayOffContractTokenError(`${what}: the stored token "${target.alias}" was rotated and the old one is revoked, but the gateway's answer describing the replacement was malformed. ${outcome}`, "rotate", secret, storeFailure === undefined);
206
+ }
207
+ if (storeFailure !== undefined) {
208
+ throw new Err_1.Err.GatewayTokenStoreError(`The stored token "${target.alias}" was rotated and the old one is revoked, but the replacement could not be stored: ${storeFailure}`, parsed.minted);
209
+ }
210
+ this.ctx.logger.info(`Rotated the stored gateway token "${target.alias}" and stored its replacement.`);
211
+ return { replaced, token: parsed.minted, rotatedCurrent: true };
212
+ });
213
+ }
214
+ }
215
+ exports.GatewayTokenService = GatewayTokenService;
216
+ /**
217
+ * `GET /api/v1/tokens`, parsed.
218
+ * @lastreviewed null
219
+ */
220
+ async function listVia(send) {
221
+ const what = `${Http_1.Http.Methods.GET} ${Gateway_1.Gateway.Paths.TOKENS}`;
222
+ const body = await send(Http_1.Http.Methods.GET, Gateway_1.Gateway.Paths.TOKENS);
223
+ const tokens = isObject(body) ? body.tokens : undefined;
224
+ if (!Array.isArray(tokens)) {
225
+ throw unexpected(what, "is not the token list the contract describes");
226
+ }
227
+ return tokens.map((entry) => {
228
+ const summary = toSummary(entry);
229
+ if (!summary) {
230
+ throw unexpected(what, "lists a token that is not shaped as the contract describes");
231
+ }
232
+ return summary;
233
+ });
234
+ }
235
+ /**
236
+ * Check an id-or-alias argument before anything is sent, and return it trimmed. A value that
237
+ * contains `b6pt_` anywhere is taken for a pasted secret: refused, never sent, never quoted.
238
+ * @lastreviewed null
239
+ */
240
+ function checkIdOrAlias(idOrAlias) {
241
+ const wanted = typeof idOrAlias === "string" ? idOrAlias.trim() : "";
242
+ if (wanted.length === 0) {
243
+ throw new Err_1.Err.GatewayInvalidArgumentError("No token id or alias was given.");
244
+ }
245
+ if (wanted.includes(Gateway_1.Gateway.TOKEN_PREFIX)) {
246
+ throw new Err_1.Err.GatewayInvalidArgumentError(`The given id or alias contains ${Gateway_1.Gateway.TOKEN_PREFIX}, so it looks like a token secret; it was not sent.`);
247
+ }
248
+ return wanted;
249
+ }
250
+ /**
251
+ * The one token whose id or alias is `wanted`. Messages never quote `wanted`: it is user input,
252
+ * and may be a secret the guard above did not recognise.
253
+ * @lastreviewed null
254
+ */
255
+ function pick(tokens, wanted) {
256
+ const matches = tokens.filter((t) => t.id === wanted || t.alias === wanted);
257
+ if (matches.length === 0) {
258
+ throw new Err_1.Err.GatewayNotFoundError("No token of this user has the given id or alias.", "not-found");
259
+ }
260
+ if (matches.length > 1) {
261
+ const ids = matches.map((t) => t.id);
262
+ throw new Err_1.Err.GatewayTokenAmbiguousError(`The given id or alias is the id of one of this user's tokens and the alias of another (ids ${ids.join(", ")}).`, ids);
263
+ }
264
+ return matches[0];
265
+ }
266
+ /**
267
+ * For a mint or rotate request's `.catch`: turn a `403 not-permitted` whose body gave a known reason
268
+ * into its typed error. Any other reason, or none, stays the plain {@link Err.GatewayNotPermittedError}
269
+ * (the gateway may add reasons). Nothing is inferred client-side.
270
+ * @param requested the expiry the request asked for (`undefined` when it named none)
271
+ * @lastreviewed null
272
+ */
273
+ function explainMintRefusal(requested) {
274
+ return (error) => {
275
+ if (error instanceof Err_1.Err.GatewayNotPermittedError && error.code === "not-permitted") {
276
+ if (error.reason === "expiry-exceeds-presenting" && error.presentingExpiresAt !== null) {
277
+ throw new Err_1.Err.GatewayTokenExpiryRefusedError(`${error.message.split(": ")[0]}: the new token would outlive the token making the request, which expires at ${error.presentingExpiresAt} (403 not-permitted)`, requested, error.presentingExpiresAt);
278
+ }
279
+ if (error.reason === "restricted-mints-disabled") {
280
+ throw new Err_1.Err.GatewayRestrictedMintsDisabledError(`${error.message.split(": ")[0]}: the gateway is not yet issuing tokens beyond the mcp scope (403 not-permitted)`);
281
+ }
282
+ if (error.reason === "rewrite-not-permitted") {
283
+ throw new Err_1.Err.GatewayRewriteNotPermittedError(`${error.message.split(": ")[0]}: this account may not hold the ${error.scope ?? "kb:rewrite"} scope (403 not-permitted)`, error.scope ?? "kb:rewrite");
284
+ }
285
+ }
286
+ throw error;
287
+ };
288
+ }
289
+ /**
290
+ * Send a mint request, never retried (a mint has no idempotency key). A
291
+ * {@link Err.GatewayUnavailableError} there (a dropped connection, a timeout, or `502`/`503`/`504`)
292
+ * does not say whether the gateway acted, so it becomes {@link Err.GatewayOutcomeUnknownError};
293
+ * every other error passes through. A rotation goes through {@link sendRotate} instead.
294
+ * @lastreviewed null
295
+ */
296
+ async function outcomeUnknownOnUnavailable(send, operation, consequence) {
297
+ try {
298
+ return await send();
299
+ }
300
+ catch (error) {
301
+ if (error instanceof Err_1.Err.GatewayUnavailableError) {
302
+ throw new Err_1.Err.GatewayOutcomeUnknownError(`${error.message} The outcome is unknown: ${consequence}.`, operation, error.status);
303
+ }
304
+ throw error;
305
+ }
306
+ }
307
+ /**
308
+ * Send a rotate request and, when it goes unanswered, retry it once (`send` carries the same
309
+ * idempotency key and presents the same token both times); see {@link GatewayTokenService.rotate}
310
+ * for what each outcome of the retry becomes.
311
+ * @lastreviewed null
312
+ */
313
+ async function sendRotate(send, what, target, logger) {
314
+ const lost = `the token "${target.alias}" may have been rotated, in which case the old one is revoked and its replacement was never received`;
315
+ let first;
316
+ try {
317
+ return await send();
318
+ }
319
+ catch (error) {
320
+ if (!(error instanceof Err_1.Err.GatewayUnavailableError)) {
321
+ throw error;
322
+ }
323
+ first = error;
324
+ }
325
+ logger.debug(`${what}: no answer (${first.status ?? "no status"}); retrying once with the same idempotency key`);
326
+ try {
327
+ return await send();
328
+ }
329
+ catch (error) {
330
+ if (error instanceof Err_1.Err.GatewayUnavailableError) {
331
+ throw new Err_1.Err.GatewayOutcomeUnknownError(`${error.message} The first attempt went unanswered too, and so did its one retry. The outcome is unknown: ${lost}.`, "rotate", error.status, true);
332
+ }
333
+ const refusedAsRevoked = (error instanceof Err_1.Err.GatewayAuthError && error.status === 401) || error instanceof Err_1.Err.GatewayNotFoundError;
334
+ if (target.current && refusedAsRevoked) {
335
+ // The retry presents the stored token, which the first attempt, if it went through, revoked.
336
+ // That is not the stored token being invalid, and the store must not be cleared over it.
337
+ // Only the status: the code (`token-invalid`, `not-found`) would misreport what happened.
338
+ throw new Err_1.Err.GatewayOutcomeUnknownError(`${what}: the first attempt went unanswered, and its one retry was refused (${error.status}) as if the stored token "${target.alias}" were already revoked. The first attempt most likely rotated it, which revokes the old token, and its replacement was never received. The stored token was left as it was.`, "rotate", first.status, true);
339
+ }
340
+ throw error;
341
+ }
342
+ }
343
+ /**
344
+ * Strict ISO 8601 date-time with a time zone: `YYYY-MM-DDTHH:MM[:SS[.fff]]` then `Z` or `±HH:MM`.
345
+ * The calendar fields must exist (no month 13, no 30 February). A plain date is refused: the
346
+ * contract types `expiresAt` as an instant, and a date alone would leave its time zone to guesswork.
347
+ * @lastreviewed null
348
+ */
349
+ const ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,9})?)?(Z|[+-](\d{2}):(\d{2}))$/;
350
+ function isIsoDateTime(value) {
351
+ if (typeof value !== "string") {
352
+ return false;
353
+ }
354
+ const m = ISO_DATE_TIME.exec(value);
355
+ if (!m) {
356
+ return false;
357
+ }
358
+ const [year, month, day, hour, minute] = [m[1], m[2], m[3], m[4], m[5]].map(Number);
359
+ const second = m[6] === undefined ? 0 : Number(m[6]);
360
+ if (month < 1 || month > 12 || hour > 23 || minute > 59 || second > 59) {
361
+ return false;
362
+ }
363
+ const daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate();
364
+ if (day < 1 || day > daysInMonth) {
365
+ return false;
366
+ }
367
+ if (m[7] !== "Z" && (Number(m[8]) > 14 || Number(m[9]) > 59)) {
368
+ return false;
369
+ }
370
+ return !Number.isNaN(Date.parse(value));
371
+ }
372
+ function isObject(value) {
373
+ return typeof value === "object" && value !== null && !Array.isArray(value);
374
+ }
375
+ function isStringArray(value) {
376
+ return Array.isArray(value) && value.every((v) => typeof v === "string");
377
+ }
378
+ function isNullableString(value) {
379
+ return value === null || typeof value === "string";
380
+ }
381
+ /**
382
+ * The contract does not fix the id's JSON type; accept a string or a number and keep it as a string.
383
+ * @lastreviewed null
384
+ */
385
+ function idOf(value) {
386
+ if (typeof value === "string" && value.length > 0) {
387
+ return value;
388
+ }
389
+ if (typeof value === "number" && Number.isFinite(value)) {
390
+ return String(value);
391
+ }
392
+ return undefined;
393
+ }
394
+ function toSummary(entry) {
395
+ if (!isObject(entry)) {
396
+ return undefined;
397
+ }
398
+ const id = idOf(entry.id);
399
+ const { alias, scopes, expiresAt, current } = entry;
400
+ const created = entry.createdAt ?? null;
401
+ const lastUsedAt = entry.lastUsedAt ?? null;
402
+ if (id === undefined ||
403
+ typeof alias !== "string" ||
404
+ !isStringArray(scopes) ||
405
+ !isNullableString(created) ||
406
+ !isNullableString(expiresAt) ||
407
+ !isNullableString(lastUsedAt) ||
408
+ typeof current !== "boolean") {
409
+ return undefined;
410
+ }
411
+ return {
412
+ id,
413
+ alias,
414
+ scopes,
415
+ createdAt: created,
416
+ expiresAt,
417
+ lastUsedAt,
418
+ current,
419
+ neverExpires: expiresAt === null,
420
+ expired: expiresAt !== null && Date.parse(expiresAt) <= Date.now(),
421
+ };
422
+ }
423
+ /**
424
+ * Parse a mint/rotate answer. The body holds a secret, so a failure never quotes it. Throws
425
+ * {@link Err.GatewayUnexpectedResponseError} only when the answer carries no secret at all.
426
+ * @lastreviewed null
427
+ */
428
+ function parseMinted(answer, what, consequence) {
429
+ if (isObject(answer) && typeof answer.token === "string" && answer.token.length > 0) {
430
+ const token = answer.token;
431
+ const id = idOf(answer.id);
432
+ const { alias, scopes, expiresAt } = answer;
433
+ if (id !== undefined && typeof alias === "string" && isStringArray(scopes) && isNullableString(expiresAt)) {
434
+ return { minted: { id, token, alias, scopes, expiresAt, neverExpires: expiresAt === null } };
435
+ }
436
+ return { secret: token };
437
+ }
438
+ throw unexpected(what, `is not the minted token the contract describes, and carries no token; ${consequence}`);
439
+ }
440
+ function unexpected(what, problem) {
441
+ return new Err_1.Err.GatewayUnexpectedResponseError(`${what}: the gateway's answer ${problem}.`, null, null);
442
+ }
443
+ function checkAlias(alias) {
444
+ if (typeof alias !== "string" || alias.length === 0) {
445
+ throw new Err_1.Err.GatewayInvalidArgumentError("The token's alias is empty.");
446
+ }
447
+ if (BAD_CHARS.test(alias)) {
448
+ throw new Err_1.Err.GatewayInvalidArgumentError("The token's alias contains whitespace or control characters.");
449
+ }
450
+ if (alias.includes(Gateway_1.Gateway.TOKEN_PREFIX)) {
451
+ throw new Err_1.Err.GatewayInvalidArgumentError(`The token's alias contains ${Gateway_1.Gateway.TOKEN_PREFIX}, which is reserved for token secrets; it was not sent.`);
452
+ }
453
+ }
454
+ function checkScopes(scopes) {
455
+ if (!Array.isArray(scopes) || scopes.length === 0) {
456
+ throw new Err_1.Err.GatewayInvalidArgumentError("The token's scope list is empty.");
457
+ }
458
+ for (const scope of scopes) {
459
+ if (typeof scope !== "string" || scope.length === 0 || BAD_CHARS.test(scope)) {
460
+ throw new Err_1.Err.GatewayInvalidArgumentError("A scope in the token's scope list is empty or contains whitespace.");
461
+ }
462
+ }
463
+ return [...new Set(scopes)];
464
+ }
465
+ //# sourceMappingURL=GatewayTokenService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GatewayTokenService.js","sourceRoot":"","sources":["../../src/gateway/GatewayTokenService.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,kDAA+C;AAC/C,4CAAyC;AACzC,gCAA6B;AAa7B,iDAAkE;AAElE;;;GAGG;AACH,MAAM,SAAS,GAAG,yBAAyB,CAAC;AAE5C;;;GAGG;AACH,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AAEtD;;;GAGG;AACH,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH;IAEqB,MAAM;IACN,GAAG;IAFtB,YACmB,MAAqB,EACrB,GAAmB;sBADnB,MAAM;mBACN,GAAG;IACnB,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM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