@cotal-ai/core 0.16.0 → 0.18.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 (145) hide show
  1. package/dist/acls.d.ts +21 -0
  2. package/dist/acls.d.ts.map +1 -1
  3. package/dist/acls.js +44 -1
  4. package/dist/acls.js.map +1 -1
  5. package/dist/artifact.d.ts +45 -0
  6. package/dist/artifact.d.ts.map +1 -0
  7. package/dist/artifact.js +82 -0
  8. package/dist/artifact.js.map +1 -0
  9. package/dist/backup-config.d.ts +9 -2
  10. package/dist/backup-config.d.ts.map +1 -1
  11. package/dist/backup-config.js +6 -2
  12. package/dist/backup-config.js.map +1 -1
  13. package/dist/broker-tls.d.ts +70 -0
  14. package/dist/broker-tls.d.ts.map +1 -0
  15. package/dist/broker-tls.js +195 -0
  16. package/dist/broker-tls.js.map +1 -0
  17. package/dist/canonical.d.ts +14 -1
  18. package/dist/canonical.d.ts.map +1 -1
  19. package/dist/canonical.js +21 -1
  20. package/dist/canonical.js.map +1 -1
  21. package/dist/channels.js +4 -4
  22. package/dist/channels.js.map +1 -1
  23. package/dist/endpoint-action.d.ts +108 -3
  24. package/dist/endpoint-action.d.ts.map +1 -1
  25. package/dist/endpoint-action.js +209 -20
  26. package/dist/endpoint-action.js.map +1 -1
  27. package/dist/endpoint-binding.d.ts +138 -8
  28. package/dist/endpoint-binding.d.ts.map +1 -1
  29. package/dist/endpoint-binding.js +233 -26
  30. package/dist/endpoint-binding.js.map +1 -1
  31. package/dist/endpoint-contract-store.d.ts +30 -1
  32. package/dist/endpoint-contract-store.d.ts.map +1 -1
  33. package/dist/endpoint-contract-store.js +100 -29
  34. package/dist/endpoint-contract-store.js.map +1 -1
  35. package/dist/endpoint-envelope.d.ts +15 -37
  36. package/dist/endpoint-envelope.d.ts.map +1 -1
  37. package/dist/endpoint-envelope.js +93 -44
  38. package/dist/endpoint-envelope.js.map +1 -1
  39. package/dist/endpoint-error.d.ts +33 -0
  40. package/dist/endpoint-error.d.ts.map +1 -0
  41. package/dist/endpoint-error.js +34 -0
  42. package/dist/endpoint-error.js.map +1 -0
  43. package/dist/endpoint-grants.d.ts +63 -7
  44. package/dist/endpoint-grants.d.ts.map +1 -1
  45. package/dist/endpoint-grants.js +118 -9
  46. package/dist/endpoint-grants.js.map +1 -1
  47. package/dist/endpoint-invoke.d.ts +138 -0
  48. package/dist/endpoint-invoke.d.ts.map +1 -0
  49. package/dist/endpoint-invoke.js +393 -0
  50. package/dist/endpoint-invoke.js.map +1 -0
  51. package/dist/endpoint-records.d.ts.map +1 -1
  52. package/dist/endpoint-records.js +17 -0
  53. package/dist/endpoint-records.js.map +1 -1
  54. package/dist/endpoint-serve-kv.d.ts +97 -0
  55. package/dist/endpoint-serve-kv.d.ts.map +1 -0
  56. package/dist/endpoint-serve-kv.js +336 -0
  57. package/dist/endpoint-serve-kv.js.map +1 -0
  58. package/dist/endpoint-serve.d.ts.map +1 -1
  59. package/dist/endpoint-serve.js +21 -1
  60. package/dist/endpoint-serve.js.map +1 -1
  61. package/dist/endpoint-service.d.ts +1 -1
  62. package/dist/endpoint-service.d.ts.map +1 -1
  63. package/dist/endpoint-service.js +34 -10
  64. package/dist/endpoint-service.js.map +1 -1
  65. package/dist/endpoint-session-rail.d.ts +127 -0
  66. package/dist/endpoint-session-rail.d.ts.map +1 -0
  67. package/dist/endpoint-session-rail.js +325 -0
  68. package/dist/endpoint-session-rail.js.map +1 -0
  69. package/dist/endpoint-session.d.ts +1 -115
  70. package/dist/endpoint-session.d.ts.map +1 -1
  71. package/dist/endpoint-session.js +4 -316
  72. package/dist/endpoint-session.js.map +1 -1
  73. package/dist/endpoint-subjects.d.ts +20 -1
  74. package/dist/endpoint-subjects.d.ts.map +1 -1
  75. package/dist/endpoint-subjects.js +20 -1
  76. package/dist/endpoint-subjects.js.map +1 -1
  77. package/dist/endpoint-verbs.d.ts +1 -2
  78. package/dist/endpoint-verbs.d.ts.map +1 -1
  79. package/dist/endpoint-verbs.js +6 -6
  80. package/dist/endpoint-verbs.js.map +1 -1
  81. package/dist/endpoint.d.ts +157 -11
  82. package/dist/endpoint.d.ts.map +1 -1
  83. package/dist/endpoint.js +471 -47
  84. package/dist/endpoint.js.map +1 -1
  85. package/dist/evict.d.ts +47 -0
  86. package/dist/evict.d.ts.map +1 -1
  87. package/dist/evict.js +191 -59
  88. package/dist/evict.js.map +1 -1
  89. package/dist/identity.d.ts +34 -0
  90. package/dist/identity.d.ts.map +1 -1
  91. package/dist/identity.js +46 -0
  92. package/dist/identity.js.map +1 -1
  93. package/dist/index.d.ts +8 -0
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +8 -0
  96. package/dist/index.js.map +1 -1
  97. package/dist/kv-scan.d.ts +8 -0
  98. package/dist/kv-scan.d.ts.map +1 -1
  99. package/dist/kv-scan.js +8 -0
  100. package/dist/kv-scan.js.map +1 -1
  101. package/dist/lease.d.ts +12 -5
  102. package/dist/lease.d.ts.map +1 -1
  103. package/dist/lease.js.map +1 -1
  104. package/dist/lifecycle-saga.d.ts +174 -0
  105. package/dist/lifecycle-saga.d.ts.map +1 -0
  106. package/dist/lifecycle-saga.js +418 -0
  107. package/dist/lifecycle-saga.js.map +1 -0
  108. package/dist/lifecycle-state.d.ts +202 -0
  109. package/dist/lifecycle-state.d.ts.map +1 -0
  110. package/dist/lifecycle-state.js +347 -0
  111. package/dist/lifecycle-state.js.map +1 -0
  112. package/dist/parts.d.ts +13 -0
  113. package/dist/parts.d.ts.map +1 -0
  114. package/dist/parts.js +17 -0
  115. package/dist/parts.js.map +1 -0
  116. package/dist/provision.d.ts +124 -15
  117. package/dist/provision.d.ts.map +1 -1
  118. package/dist/provision.js +578 -121
  119. package/dist/provision.js.map +1 -1
  120. package/dist/schema-profile.d.ts +3 -2
  121. package/dist/schema-profile.d.ts.map +1 -1
  122. package/dist/schema-profile.js +242 -18
  123. package/dist/schema-profile.js.map +1 -1
  124. package/dist/session-browser.d.ts +15 -0
  125. package/dist/session-browser.d.ts.map +1 -0
  126. package/dist/session-browser.js +14 -0
  127. package/dist/session-browser.js.map +1 -0
  128. package/dist/session-terminal-frames.d.ts +36 -0
  129. package/dist/session-terminal-frames.d.ts.map +1 -0
  130. package/dist/session-terminal-frames.js +149 -0
  131. package/dist/session-terminal-frames.js.map +1 -0
  132. package/dist/spaces.d.ts.map +1 -1
  133. package/dist/spaces.js +6 -1
  134. package/dist/spaces.js.map +1 -1
  135. package/dist/streams.d.ts +168 -1
  136. package/dist/streams.d.ts.map +1 -1
  137. package/dist/streams.js +299 -21
  138. package/dist/streams.js.map +1 -1
  139. package/dist/subjects.d.ts +34 -36
  140. package/dist/subjects.d.ts.map +1 -1
  141. package/dist/subjects.js +46 -35
  142. package/dist/subjects.js.map +1 -1
  143. package/dist/types.d.ts +27 -1
  144. package/dist/types.d.ts.map +1 -1
  145. package/package.json +6 -1
package/dist/evict.d.ts CHANGED
@@ -134,6 +134,53 @@ export declare function observePlaneLivenessWithCreds(opts: {
134
134
  query: PlaneLivenessQuery;
135
135
  options?: EvictOptions;
136
136
  }): Promise<PlaneLivenessResult>;
137
+ /** A principal's liveness verdict. `live` = a connection attributed to it exists NOW; `gone` = a
138
+ * COMPLETE, single-server-proven sweep proves none does; `unknown` = the observation cannot decide.
139
+ * A caller MUST treat `unknown` as "may still be live" — never as gone. */
140
+ export type PrincipalLiveness = "live" | "gone" | "unknown";
141
+ /** The probe's bound reply: the principal ECHOED back with its verdict (a reply that does not echo
142
+ * the exact principal asked about never authorizes), plus `sweepComplete` — CONNZ observation
143
+ * completeness, kept as its own field and NEVER folded into the verdict. */
144
+ export interface PrincipalLivenessResult {
145
+ principal: string;
146
+ state: PrincipalLiveness;
147
+ sweepComplete: boolean;
148
+ note?: string;
149
+ }
150
+ /** Closed, ECHO-BOUND parse of a wire-crossing {@link PrincipalLivenessResult} — the caller
151
+ * validates the delivery-admin rail's reply BEFORE reasoning over it. Exactly the v1 keys, the
152
+ * state in the enum, and the echoed principal EQUAL to the one queried. Undefined on ANY
153
+ * violation; the caller maps that to `unknown` (a garbled or foreign oracle must block the repair,
154
+ * never authorize it). `expected` is required precisely so the echo cannot be forgotten. */
155
+ export declare function parsePrincipalLivenessResult(v: unknown, expected: string): PrincipalLivenessResult | undefined;
156
+ /**
157
+ * Answer whether ONE principal holds any live connection — the read-only half of principal
158
+ * eviction, drawn from the SAME {@link livenessSweep} the plane oracle uses, so an observation good
159
+ * enough to authorize a repair is validated identically wherever it is read.
160
+ *
161
+ * - `live`: a complete sweep attributed at least one connection to the principal.
162
+ * - `gone`: the sweep is COMPLETE, the single-server mode is PROVEN (SPEC 13.13), and no connection
163
+ * attributes to the principal. The single-server proof is required for the same reason the plane
164
+ * reclaim requires it: in a clustered account, CONNZ absence cannot distinguish a genuinely dead
165
+ * holder from a live one behind a partition, and reading the second as "gone" is exactly the
166
+ * unsafe direction for a repair that revokes and evicts a credential family.
167
+ * - `unknown`: the sweep under-reported, or the single-server mode is unproven.
168
+ *
169
+ * Refuses a non-principal loudly: CONNZ attribution only ever surfaces `local`/`u_…` owners, so a
170
+ * syntactically-valid non-principal would sweep clean and return a HEALTHY `gone` — false
171
+ * confidence for a typo'd target. Same boundary `executeEviction` applies to its filter.
172
+ */
173
+ export declare function observePrincipalLiveness(observerConn: NatsConnection, accountId: string, principal: string, options?: EvictOptions): Promise<PrincipalLivenessResult>;
174
+ /** Creds-level wrapper for the delivery daemon's admin-rail principal-liveness verb: open the $SYS
175
+ * observer PER CALL (the eviction seam's rule — never a standing $SYS connection), run
176
+ * {@link observePrincipalLiveness}, drain. Read-only: no evictor cred enters this path. */
177
+ export declare function observePrincipalLivenessWithCreds(opts: {
178
+ servers: string;
179
+ observerCreds: string;
180
+ accountId: string;
181
+ principal: string;
182
+ options?: EvictOptions;
183
+ }): Promise<PrincipalLivenessResult>;
137
184
  /** Creds-level wrapper for composition roots that hold the two $SYS creds as FILES/strings (the
138
185
  * delivery daemon's admin-rail executor): open the observer (under its granted inbox prefix) and
139
186
  * the kick-only evictor PER CALL, run {@link evictDeniedPrincipal}, and drain both — eviction is a
@@ -1 +1 @@
1
- {"version":3,"file":"evict.d.ts","sourceRoot":"","sources":["../src/evict.ts"],"names":[],"mappings":"AAiCA,OAAO,EAA+B,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAgC3F;;sDAEsD;AACtD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,qGAAqG;IACrG,SAAS,EAAE,MAAM,CAAC;IAClB;0FACsF;IACtF,YAAY,EAAE,OAAO,CAAC;IACtB;sDACkD;IAClD,YAAY,EAAE,OAAO,CAAC;IACtB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;6CAC6C;AAC7C,MAAM,WAAW,YAAY;IAC3B,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAiHD;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,cAAc,EAC5B,WAAW,EAAE,cAAc,EAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,cAAc,CAAC,CA4CzB;AAID;;;mEAGmE;AACnE,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;0FAE0F;AAC1F,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,cAAc,CAAC;CACzB;AAED;;;gCAGgC;AAChC,MAAM,MAAM,iBAAiB,GAAG,MAAM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IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;6FAI6F;AAC7F,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS,CAS9G;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,uBAAuB,CAAC,CAclC;AAED;;4FAE4F;AAC5F,wBAAsB,iCAAiC,CAAC,IAAI,EAAE;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAYnC;AAED;;;;qGAIqG;AACrG,wBAAsB,6BAA6B,CAAC,IAAI,EAAE;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,GAAG,OAAO,CAAC,cAAc,CAAC,CAsB1B"}
package/dist/evict.js CHANGED
@@ -32,7 +32,7 @@
32
32
  */
33
33
  import { randomUUID } from "node:crypto";
34
34
  import { connect, credsAuthenticator } from "@nats-io/transport-node";
35
- import { connzRequestSubject, principalFromConnz, serverKickSubject, MEMBERSHIP_INBOX_PREFIX } from "./subjects.js";
35
+ import { connzRequestSubject, isPrincipalOwnerToken, parsePrincipalKey, principalFromConnz, serverKickSubject, MEMBERSHIP_INBOX_PREFIX } from "./subjects.js";
36
36
  const enc = (s) => new TextEncoder().encode(s);
37
37
  const MAX_PAGES = 64; // fan-out pagination guard (mirrors the membership feed's under-report ceiling)
38
38
  /** Scan this account's live connections, projected to `{cid, serverId, principal}`. Returns
@@ -47,12 +47,17 @@ async function scanLive(observerConn, accountId, opts) {
47
47
  let unroutable = false; // a reply named no server id → its conns can't be KICKed → scan is not complete
48
48
  const sweep = randomUUID(); // per-sweep reply-inbox nonce: concurrent sweeps must never cross-talk
49
49
  let seq = 0;
50
+ // See the lost-page check below: servers that owe a page after the previous round.
51
+ let owed = new Set();
52
+ let lostPage = false;
50
53
  for (let page = 0; page < MAX_PAGES; page++) {
51
54
  const offset = page * opts.pageLimit;
52
55
  const replies = await connzRound(observerConn, accountId, offset, opts, sweep, seq++);
53
56
  if (replies.length)
54
57
  gotAnyReply = true;
55
58
  let fullPageSomewhere = false;
59
+ const deliveredThisRound = new Set();
60
+ const owesAfterThisRound = new Set();
56
61
  for (const r of replies) {
57
62
  const serverId = r.data?.server_id ?? r.server?.id;
58
63
  if (!serverId) {
@@ -79,15 +84,28 @@ async function scanLive(observerConn, accountId, opts) {
79
84
  conns.push({ cid: c.cid, serverId, principal });
80
85
  }
81
86
  const total = r.data?.total ?? 0;
82
- if (cs.length >= opts.pageLimit && offset + cs.length < total)
87
+ // Same progress rule as `livenessSweep`: answering is not delivering (see there).
88
+ if (cs.length > 0 || offset >= total)
89
+ deliveredThisRound.add(serverId);
90
+ if (cs.length >= opts.pageLimit && offset + cs.length < total) {
83
91
  fullPageSomewhere = true;
92
+ owesAfterThisRound.add(serverId);
93
+ }
84
94
  }
95
+ // THE LOST-PAGE CHECK (same defect, same fix, as `livenessSweep`): a server that reported more
96
+ // data and then failed to deliver a page has gone silent mid-pagination, not ended. Reading
97
+ // that as an ending makes a scan that MISSED live connections report itself complete — and here
98
+ // that is `verifiedGone:true` for a principal still holding a connection past the first page.
99
+ for (const s of owed)
100
+ if (!deliveredThisRound.has(s))
101
+ lostPage = true;
102
+ owed = owesAfterThisRound;
85
103
  if (!fullPageSomewhere)
86
104
  break; // no server still has a full page → done
87
105
  if (page === MAX_PAGES - 1)
88
106
  truncated = true;
89
107
  }
90
- return { conns, complete: gotAnyReply && !truncated && !unroutable };
108
+ return { conns, complete: gotAnyReply && !truncated && !unroutable && !lostPage };
91
109
  }
92
110
  /** One CONNZ round: fan out the account request, collect every server's reply within the window. */
93
111
  function connzRound(observerConn, accountId, offset, opts, sweep, seq) {
@@ -252,44 +270,15 @@ export function parsePlaneLivenessResult(v) {
252
270
  return { ledger, records, sweepComplete: r.sweepComplete, ...(r.note !== undefined ? { note: r.note } : {}) };
253
271
  }
254
272
  /**
255
- * Answer a plane-liveness query over the account's live connections (the delivery daemon's
256
- * read-only half of the #29 HIGH 3 reclaim protocol; observer cred only, no KICK). Verdict rules,
257
- * fail-safe by construction:
258
- *
259
- * - `live`: a connection carrying the claimed `userNkey` exists ANYWHERE (any server, any cid —
260
- * wider than the exact tuple on purpose: an identity that still holds ANY connection must block
261
- * takeover), or the exact `(serverId, cid)` pair is present.
262
- * - `gone`: the sweep is COMPLETE, the observation PROVES the single-server mode, and the claimed
263
- * `userNkey` appears nowhere. This includes the claimed `serverId` being absent from the
264
- * repliers entirely: `server_id` is per-broker-RUN, so after a broker restart the claimed
265
- * incarnation can never reply again while every connection it held is gone by definition —
266
- * requiring its reply forever would turn every whole-stack crash into a permanent reclaim
267
- * wedge (the inverted-lockout class).
268
- *
269
- * THE SINGLE-SERVER PROOF (SPEC 13.13): CONNZ absence alone cannot distinguish a RESTARTED
270
- * claimed server (genuinely gone) from a PARTITIONED one (live, unreachable) — both present as
271
- * "the claimed serverId did not reply". The discriminator is the responding server's OWN
272
- * topology declaration, never an inference from who replied: `gone` additionally requires that
273
- * EVERY reply carried a server envelope declaring NO cluster membership (`server.cluster`
274
- * absent — nats-server sets it, config-named or dynamically generated, whenever clustering is
275
- * configured) and that exactly ONE distinct server replied. A standalone process cannot have a
276
- * silent same-cluster peer holding the claimed connection, so its complete reply is the whole
277
- * truth; a partitioned cluster member still DECLARES its cluster and reads `unknown`. NAMED
278
- * RESIDUALS: a leafnode/gateway-extended account is outside the cluster self-report (such
279
- * topologies are out of contract for the auth account until a multi-server incarnation
280
- * authority exists), and a backup-restore onto a fresh broker can present a still-running
281
- * foreign predecessor's `serverId` as dead.
282
- * - `unknown`: the sweep under-reported (no replies, truncation, an unroutable row) OR the
283
- * single-server mode is unproven (a cluster self-report, multiple repliers, or a reply without
284
- * the server envelope) — the caller refuses takeover.
273
+ * The read-only CONNZ sweep both liveness verdicts are drawn from ONE fail-closed observation,
274
+ * shared so a probe and the repair it authorizes can never disagree about what "gone" means.
285
275
  *
286
- * Closed surface: the CONNZ request carries no caller-selected filter (account-wide sweep only)
287
- * and the reply exposes ONLY the two bound verdicts + sweep completeness never a connection
288
- * listing. A row matching the claimed nkey under ANY connection name counts live (fail safe);
289
- * the residual "is this nkey connected" bit the verb leaks is strictly weaker than the kick
290
- * authority the same rail already carries.
276
+ * FAIL-CLOSED reply validation: only a SUCCESSFUL, well-formed CONNZ page may count toward an
277
+ * authorizing sweep. An API error, a missing/empty server envelope, a present but non-string (or
278
+ * empty-string) cluster declaration, an envelope/data server-id mismatch, or a structurally
279
+ * incomplete data page each mark the sweep malformed (⇒ every verdict `unknown`).
291
280
  */
292
- export async function observePlaneLiveness(observerConn, accountId, query, options = {}) {
281
+ async function livenessSweep(observerConn, accountId, options = {}) {
293
282
  const opts = {
294
283
  settleMs: options.settleMs ?? 250,
295
284
  maxWaitMs: options.maxWaitMs ?? 2000,
@@ -303,17 +292,20 @@ export async function observePlaneLiveness(observerConn, accountId, query, optio
303
292
  const repliers = new Set();
304
293
  const sweep = randomUUID(); // per-sweep reply-inbox nonce: concurrent sweeps must never cross-talk
305
294
  let seq = 0;
295
+ // Servers that reported MORE data after the previous round, and therefore OWE a page on this one.
296
+ // A server that owes a page and does not deliver a well-formed one has UNDER-REPORTED — the sweep
297
+ // must not read that silence as the end of the data (see `lostPage`).
298
+ let owed = new Set();
299
+ let lostPage = false;
306
300
  for (let page = 0; page < MAX_PAGES; page++) {
307
301
  const offset = page * opts.pageLimit;
308
302
  const replies = await connzRound(observerConn, accountId, offset, opts, sweep, seq++);
309
303
  if (replies.length)
310
304
  gotAnyReply = true;
311
305
  let fullPageSomewhere = false;
306
+ const deliveredThisRound = new Set();
307
+ const owesAfterThisRound = new Set();
312
308
  for (const r of replies) {
313
- // FAIL-CLOSED reply validation: only a SUCCESSFUL, well-formed CONNZ page may count toward a
314
- // reclaim-authorizing sweep. An API error, a missing/empty server envelope, a present but
315
- // non-string (or empty-string) cluster declaration, an envelope/data server-id mismatch, or a
316
- // structurally incomplete data page each mark the sweep malformed (=> every verdict unknown).
317
309
  const envId = r.server?.id;
318
310
  const cluster = r.server?.cluster;
319
311
  if (r.error !== undefined ||
@@ -336,38 +328,107 @@ export async function observePlaneLiveness(observerConn, accountId, query, optio
336
328
  malformed = true; // an id-less row could BE the claimed connection — fail safe
337
329
  continue;
338
330
  }
339
- conns.push({ serverId, cid: c.cid, ...(typeof c.authorized_user === "string" ? { userNkey: c.authorized_user } : {}) });
331
+ const principal = principalFromConnz(c);
332
+ conns.push({
333
+ serverId, cid: c.cid,
334
+ ...(typeof c.authorized_user === "string" ? { userNkey: c.authorized_user } : {}),
335
+ ...(principal === null ? {} : { principal }),
336
+ });
340
337
  }
341
338
  const total = r.data.total;
342
- if (cs.length >= opts.pageLimit && offset + cs.length < total)
339
+ // PROGRESS, not merely a reply: a server that owes the rest of its data discharges that debt
340
+ // only by handing some over (`cs.length > 0`) or by showing there is none left to hand
341
+ // (`offset >= total`). An empty page at an offset still short of `total` answers without
342
+ // delivering, and accepting it as an ending clears the debt exactly as silence used to.
343
+ if (cs.length > 0 || offset >= total)
344
+ deliveredThisRound.add(serverId);
345
+ if (cs.length >= opts.pageLimit && offset + cs.length < total) {
343
346
  fullPageSomewhere = true;
347
+ owesAfterThisRound.add(serverId);
348
+ }
344
349
  }
350
+ // THE LOST-PAGE CHECK. A server that said "there is more" and then failed to deliver the rest
351
+ // has not ended its data — it has stopped mid-pagination, and its remaining connections were
352
+ // never seen. Reading that as the end is how a sweep that MISSED a live connection reports
353
+ // itself COMPLETE, and a complete-and-absent sweep is exactly what authorizes `gone`. Fail
354
+ // closed: the observation is an under-report, not an ending.
355
+ for (const s of owed)
356
+ if (!deliveredThisRound.has(s))
357
+ lostPage = true;
358
+ owed = owesAfterThisRound;
345
359
  if (!fullPageSomewhere)
346
360
  break;
347
361
  if (page === MAX_PAGES - 1)
348
362
  truncated = true;
349
363
  }
350
- const sweepComplete = gotAnyReply && !truncated && !malformed;
351
- // The single-server proof (see the doc): `gone` is sound ONLY when every responder declared
352
- // standalone topology and exactly one server replied — a declaration, never a reply-count guess.
353
- const singleServerProven = sweepComplete && !clusterDeclared && repliers.size === 1;
364
+ const sweepComplete = gotAnyReply && !truncated && !malformed && !lostPage;
365
+ return {
366
+ conns, sweepComplete, clusterDeclared, repliers: repliers.size,
367
+ singleServerProven: sweepComplete && !clusterDeclared && repliers.size === 1,
368
+ };
369
+ }
370
+ /** The one-line reason a sweep cannot yield `gone`, or undefined when it can. `decision` names what
371
+ * the verdict was going to authorize, so the operator reads why THIS answer is withheld. */
372
+ function sweepShortfallNote(s, decision) {
373
+ if (!s.sweepComplete)
374
+ return "CONNZ sweep under-reported (no responder, truncation, an API error, or a malformed reply) - liveness UNKNOWN";
375
+ if (s.singleServerProven)
376
+ return undefined;
377
+ return s.clusterDeclared
378
+ ? `the broker DECLARES cluster membership - a partitioned member could still hold the connection, so CONNZ liveness cannot adjudicate ${decision} outside the single-server mode (SPEC 13.13) - liveness UNKNOWN`
379
+ : `${s.repliers} distinct servers replied - the single-server mode the verdict requires is unproven (SPEC 13.13) - liveness UNKNOWN`;
380
+ }
381
+ /**
382
+ * Answer a plane-liveness query over the account's live connections (the delivery daemon's
383
+ * read-only half of the #29 HIGH 3 reclaim protocol; observer cred only, no KICK). Verdict rules,
384
+ * fail-safe by construction:
385
+ *
386
+ * - `live`: a connection carrying the claimed `userNkey` exists ANYWHERE (any server, any cid —
387
+ * wider than the exact tuple on purpose: an identity that still holds ANY connection must block
388
+ * takeover), or the exact `(serverId, cid)` pair is present.
389
+ * - `gone`: the sweep is COMPLETE, the observation PROVES the single-server mode, and the claimed
390
+ * `userNkey` appears nowhere. This includes the claimed `serverId` being absent from the
391
+ * repliers entirely: `server_id` is per-broker-RUN, so after a broker restart the claimed
392
+ * incarnation can never reply again while every connection it held is gone by definition —
393
+ * requiring its reply forever would turn every whole-stack crash into a permanent reclaim
394
+ * wedge (the inverted-lockout class).
395
+ *
396
+ * THE SINGLE-SERVER PROOF (SPEC 13.13): CONNZ absence alone cannot distinguish a RESTARTED
397
+ * claimed server (genuinely gone) from a PARTITIONED one (live, unreachable) — both present as
398
+ * "the claimed serverId did not reply". The discriminator is the responding server's OWN
399
+ * topology declaration, never an inference from who replied: `gone` additionally requires that
400
+ * EVERY reply carried a server envelope declaring NO cluster membership (`server.cluster`
401
+ * absent — nats-server sets it, config-named or dynamically generated, whenever clustering is
402
+ * configured) and that exactly ONE distinct server replied. A standalone process cannot have a
403
+ * silent same-cluster peer holding the claimed connection, so its complete reply is the whole
404
+ * truth; a partitioned cluster member still DECLARES its cluster and reads `unknown`. NAMED
405
+ * RESIDUALS: a leafnode/gateway-extended account is outside the cluster self-report (such
406
+ * topologies are out of contract for the auth account until a multi-server incarnation
407
+ * authority exists), and a backup-restore onto a fresh broker can present a still-running
408
+ * foreign predecessor's `serverId` as dead.
409
+ * - `unknown`: the sweep under-reported (no replies, truncation, an unroutable row) OR the
410
+ * single-server mode is unproven (a cluster self-report, multiple repliers, or a reply without
411
+ * the server envelope) — the caller refuses takeover.
412
+ *
413
+ * Closed surface: the CONNZ request carries no caller-selected filter (account-wide sweep only)
414
+ * and the reply exposes ONLY the two bound verdicts + sweep completeness — never a connection
415
+ * listing. A row matching the claimed nkey under ANY connection name counts live (fail safe);
416
+ * the residual "is this nkey connected" bit the verb leaks is strictly weaker than the kick
417
+ * authority the same rail already carries.
418
+ */
419
+ export async function observePlaneLiveness(observerConn, accountId, query, options = {}) {
420
+ const s = await livenessSweep(observerConn, accountId, options);
354
421
  const verdict = (tuple) => {
355
- const live = conns.some((c) => c.userNkey === tuple.userNkey || (c.serverId === tuple.serverId && c.cid === tuple.cid));
422
+ const live = s.conns.some((c) => c.userNkey === tuple.userNkey || (c.serverId === tuple.serverId && c.cid === tuple.cid));
356
423
  if (live)
357
424
  return "live";
358
- return singleServerProven ? "gone" : "unknown";
425
+ return s.singleServerProven ? "gone" : "unknown";
359
426
  };
360
- const note = !sweepComplete
361
- ? "CONNZ sweep under-reported (no responder, truncation, an API error, or a malformed reply) - liveness UNKNOWN"
362
- : !singleServerProven
363
- ? clusterDeclared
364
- ? "the broker DECLARES cluster membership - a partitioned member could still hold the claimed connections, so CONNZ liveness cannot adjudicate a plane reclaim outside the single-server mode (SPEC 13.13) - liveness UNKNOWN"
365
- : `${repliers.size} distinct servers replied - the single-server mode the reclaim verdict requires is unproven (SPEC 13.13) - liveness UNKNOWN`
366
- : undefined;
427
+ const note = sweepShortfallNote(s, "a plane reclaim");
367
428
  return {
368
429
  ledger: { tuple: query.ledger, state: verdict(query.ledger) },
369
430
  records: { tuple: query.records, state: verdict(query.records) },
370
- sweepComplete,
431
+ sweepComplete: s.sweepComplete,
371
432
  ...(note === undefined ? {} : { note }),
372
433
  };
373
434
  }
@@ -388,6 +449,77 @@ export async function observePlaneLivenessWithCreds(opts) {
388
449
  await observer.drain().catch(() => { });
389
450
  }
390
451
  }
452
+ /** Closed, ECHO-BOUND parse of a wire-crossing {@link PrincipalLivenessResult} — the caller
453
+ * validates the delivery-admin rail's reply BEFORE reasoning over it. Exactly the v1 keys, the
454
+ * state in the enum, and the echoed principal EQUAL to the one queried. Undefined on ANY
455
+ * violation; the caller maps that to `unknown` (a garbled or foreign oracle must block the repair,
456
+ * never authorize it). `expected` is required precisely so the echo cannot be forgotten. */
457
+ export function parsePrincipalLivenessResult(v, expected) {
458
+ if (v === null || typeof v !== "object")
459
+ return undefined;
460
+ for (const k of Object.keys(v))
461
+ if (!["principal", "state", "sweepComplete", "note"].includes(k))
462
+ return undefined;
463
+ const r = v;
464
+ if (typeof r.principal !== "string" || r.principal !== expected)
465
+ return undefined;
466
+ if (r.state !== "live" && r.state !== "gone" && r.state !== "unknown")
467
+ return undefined;
468
+ if (typeof r.sweepComplete !== "boolean")
469
+ return undefined;
470
+ if (r.note !== undefined && (typeof r.note !== "string" || r.note.length === 0 || r.note.length > 2048))
471
+ return undefined;
472
+ return { principal: r.principal, state: r.state, sweepComplete: r.sweepComplete, ...(r.note !== undefined ? { note: r.note } : {}) };
473
+ }
474
+ /**
475
+ * Answer whether ONE principal holds any live connection — the read-only half of principal
476
+ * eviction, drawn from the SAME {@link livenessSweep} the plane oracle uses, so an observation good
477
+ * enough to authorize a repair is validated identically wherever it is read.
478
+ *
479
+ * - `live`: a complete sweep attributed at least one connection to the principal.
480
+ * - `gone`: the sweep is COMPLETE, the single-server mode is PROVEN (SPEC 13.13), and no connection
481
+ * attributes to the principal. The single-server proof is required for the same reason the plane
482
+ * reclaim requires it: in a clustered account, CONNZ absence cannot distinguish a genuinely dead
483
+ * holder from a live one behind a partition, and reading the second as "gone" is exactly the
484
+ * unsafe direction for a repair that revokes and evicts a credential family.
485
+ * - `unknown`: the sweep under-reported, or the single-server mode is unproven.
486
+ *
487
+ * Refuses a non-principal loudly: CONNZ attribution only ever surfaces `local`/`u_…` owners, so a
488
+ * syntactically-valid non-principal would sweep clean and return a HEALTHY `gone` — false
489
+ * confidence for a typo'd target. Same boundary `executeEviction` applies to its filter.
490
+ */
491
+ export async function observePrincipalLiveness(observerConn, accountId, principal, options = {}) {
492
+ const parsed = parsePrincipalKey(principal);
493
+ if (!parsed || !isPrincipalOwnerToken(parsed.owner))
494
+ throw new Error(`principalLiveness: "${principal}" is not a real owner.actor principal (owner must be \`local\` or a derived \`u_…\` token — the only shapes CONNZ attribution can surface); a clean sweep for it would be false confidence, not a verdict`);
495
+ const s = await livenessSweep(observerConn, accountId, options);
496
+ const live = s.conns.some((c) => c.principal === principal);
497
+ const note = sweepShortfallNote(s, "a freeze-holder repair");
498
+ return {
499
+ principal,
500
+ state: live ? "live" : s.singleServerProven ? "gone" : "unknown",
501
+ sweepComplete: s.sweepComplete,
502
+ // A `live` verdict is conclusive on its own — the shortfall note explains a WITHHELD `gone`.
503
+ ...(!live && note !== undefined ? { note } : {}),
504
+ };
505
+ }
506
+ /** Creds-level wrapper for the delivery daemon's admin-rail principal-liveness verb: open the $SYS
507
+ * observer PER CALL (the eviction seam's rule — never a standing $SYS connection), run
508
+ * {@link observePrincipalLiveness}, drain. Read-only: no evictor cred enters this path. */
509
+ export async function observePrincipalLivenessWithCreds(opts) {
510
+ const observer = await connect({
511
+ servers: opts.servers,
512
+ authenticator: credsAuthenticator(enc(opts.observerCreds)),
513
+ inboxPrefix: MEMBERSHIP_INBOX_PREFIX,
514
+ maxReconnectAttempts: 0,
515
+ });
516
+ try {
517
+ return await observePrincipalLiveness(observer, opts.accountId, opts.principal, opts.options ?? {});
518
+ }
519
+ finally {
520
+ await observer.drain().catch(() => { });
521
+ }
522
+ }
391
523
  /** Creds-level wrapper for composition roots that hold the two $SYS creds as FILES/strings (the
392
524
  * delivery daemon's admin-rail executor): open the observer (under its granted inbox prefix) and
393
525
  * the kick-only evictor PER CALL, run {@link evictDeniedPrincipal}, and drain both — eviction is a
package/dist/evict.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"evict.js","sourceRoot":"","sources":["../src/evict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAuB,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAEpH,MAAM,GAAG,GAAG,C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AC,CAAC;IACzC,CAAC;AACH,CAAC;AAED;;;;qGAIqG;AACrG,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,IAOnD;IACC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC;QAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,aAAa,EAAE,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1D,WAAW,EAAE,uBAAuB;QACpC,oBAAoB,EAAE,CAAC;KACxB,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC;YAC5B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,aAAa,EAAE,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACzD,oBAAoB,EAAE,CAAC;SACxB,CAAC,CAAC;QACH,IAAI,CAAC;YACH,OAAO,MAAM,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QAC3G,CAAC;gBAAS,CAAC;YACT,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
@@ -16,6 +16,25 @@ export interface Identity {
16
16
  /** Generate a fresh user nkey identity locally. The seed is derived here and never
17
17
  * leaves the generating process except as a creds file handed to its own agent. */
18
18
  export declare function newIdentity(): Identity;
19
+ /** The signing half an authority-bearing artifact needs: `signArtifact` / `mintSessionGrant`
20
+ * take exactly `{ sign(input): Uint8Array }`, and the matching `publicKey` is what the
21
+ * verifying anchor pins. An nkey KeyPair already satisfies both; this narrows it to the
22
+ * artifact surface so a consumer that must not depend on `@nats-io/nkeys` directly (an
23
+ * `implementations/*` package) can still sign — core owns the signing primitive. */
24
+ export interface ArtifactSigner {
25
+ /** The signer's nkey public key (`U…`) — the `SignerAnchor.publicKey` a verifier resolves. */
26
+ publicKey: string;
27
+ /** Ed25519 signature over an artifact's canonical signature input. */
28
+ sign(input: Uint8Array): Uint8Array;
29
+ }
30
+ /** Build an artifact signer from an existing nkey seed (e.g. an endpoint's own key material).
31
+ * The seed never leaves the process; only signatures + the public key do. */
32
+ export declare function artifactSignerFromSeed(seed: string): ArtifactSigner;
33
+ /** A fresh artifact signer (its own keypair + seed): for a self-signing endpoint that mints its
34
+ * own session grants and registers the matching public key as its `sessions` trust anchor. */
35
+ export declare function newArtifactSigner(): ArtifactSigner & {
36
+ seed: string;
37
+ };
19
38
  /** The stable id carried by a creds file: the agent's nkey public key. Derived from the
20
39
  * seed block (format-independent) and cross-checked against the JWT subject — a mismatch
21
40
  * means a corrupt or spliced creds file (a seed paired with someone else's JWT), which
@@ -27,6 +46,21 @@ export declare function idFromCreds(creds: string): string;
27
46
  * needs the token rather than the whole envelope. Returns undefined when there is no JWT block;
28
47
  * callers decide whether that is fatal. */
29
48
  export declare function jwtFromCreds(creds: string): string | undefined;
49
+ /** The ACCOUNT a creds file authenticates as.
50
+ *
51
+ * `iss` is NOT the answer, and assuming it was is a live-verified mistake: when a user JWT is
52
+ * signed by an account SIGNING key (which every credential this repo mints is), `iss` carries the
53
+ * SIGNING key and the account identity lives in `nats.issuer_account`. Comparing `iss` to an
54
+ * account public key rejects every correctly-configured mesh. So: `nats.issuer_account` when
55
+ * present, falling back to `iss` for a JWT signed directly by the account identity key.
56
+ *
57
+ * This exists so a process can cross-check its own tenancy against material it read off DISK.
58
+ * A daemon that resolves its scan target from a file (`membership.json`) has no way, without
59
+ * this, to notice it is reading a DIFFERENT tenant's file than the one it authenticates as — and
60
+ * a complete, well-formed sweep of the wrong account is indistinguishable from "the principal is
61
+ * gone". Fail-closed: no JWT block, or no usable `iss`, throws rather than returning a value a
62
+ * caller might compare loosely. */
63
+ export declare function accountFromCreds(creds: string): string;
30
64
  /** A non-secret GENERATION token for a credential: SHA-256 of its compact USER JWT.
31
65
  *
32
66
  * The JWT, not the whole creds envelope, on purpose. The JWT is exactly what the broker is
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;CACd;AAED;oFACoF;AACpF,wBAAgB,WAAW,IAAI,QAAQ,CAItC;AAED;;;;;kBAKkB;AAClB,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;4CAE4C;AAC5C,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED;;;;;;;;;;6FAU6F;AAC7F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAItD;AAED;;;6FAG6F;AAC7F,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAQpH;AAED;;;;;uFAKuF;AACvF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOzD;AAED;;;yEAGyE;AACzE,wBAAgB,iBAAiB,CAAC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,MAAM,CAAA;CAAE,CAQpH;AAED;;;;;uFAKuF;AACvF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOzD;AAED;;;yEAGyE;AACzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAWzD"}
package/dist/identity.js CHANGED
@@ -7,6 +7,18 @@ export function newIdentity() {
7
7
  const seed = new TextDecoder().decode(kp.getSeed());
8
8
  return { id: kp.getPublicKey(), seed };
9
9
  }
10
+ /** Build an artifact signer from an existing nkey seed (e.g. an endpoint's own key material).
11
+ * The seed never leaves the process; only signatures + the public key do. */
12
+ export function artifactSignerFromSeed(seed) {
13
+ const kp = fromSeed(new TextEncoder().encode(seed));
14
+ return { publicKey: kp.getPublicKey(), sign: (input) => kp.sign(input) };
15
+ }
16
+ /** A fresh artifact signer (its own keypair + seed): for a self-signing endpoint that mints its
17
+ * own session grants and registers the matching public key as its `sessions` trust anchor. */
18
+ export function newArtifactSigner() {
19
+ const { seed } = newIdentity();
20
+ return { ...artifactSignerFromSeed(seed), seed };
21
+ }
10
22
  /** The stable id carried by a creds file: the agent's nkey public key. Derived from the
11
23
  * seed block (format-independent) and cross-checked against the JWT subject — a mismatch
12
24
  * means a corrupt or spliced creds file (a seed paired with someone else's JWT), which
@@ -22,6 +34,40 @@ export function idFromCreds(creds) {
22
34
  export function jwtFromCreds(creds) {
23
35
  return creds.match(/BEGIN NATS USER JWT-----\s*([\s\S]*?)\s*------END NATS USER JWT/)?.[1].trim();
24
36
  }
37
+ /** The ACCOUNT a creds file authenticates as.
38
+ *
39
+ * `iss` is NOT the answer, and assuming it was is a live-verified mistake: when a user JWT is
40
+ * signed by an account SIGNING key (which every credential this repo mints is), `iss` carries the
41
+ * SIGNING key and the account identity lives in `nats.issuer_account`. Comparing `iss` to an
42
+ * account public key rejects every correctly-configured mesh. So: `nats.issuer_account` when
43
+ * present, falling back to `iss` for a JWT signed directly by the account identity key.
44
+ *
45
+ * This exists so a process can cross-check its own tenancy against material it read off DISK.
46
+ * A daemon that resolves its scan target from a file (`membership.json`) has no way, without
47
+ * this, to notice it is reading a DIFFERENT tenant's file than the one it authenticates as — and
48
+ * a complete, well-formed sweep of the wrong account is indistinguishable from "the principal is
49
+ * gone". Fail-closed: no JWT block, or no usable `iss`, throws rather than returning a value a
50
+ * caller might compare loosely. */
51
+ export function accountFromCreds(creds) {
52
+ const jwt = jwtFromCreds(creds);
53
+ if (!jwt)
54
+ throw new Error("creds: no NATS user JWT block found - cannot determine the issuing account");
55
+ const payload = jwt.split(".")[1];
56
+ if (!payload)
57
+ throw new Error("creds: the NATS user JWT is not a three-part token - cannot determine the issuing account");
58
+ let claims;
59
+ try {
60
+ claims = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
61
+ }
62
+ catch (e) {
63
+ throw new Error(`creds: the NATS user JWT payload does not decode (${e.message}) - cannot determine the issuing account`);
64
+ }
65
+ const c = claims;
66
+ const account = typeof c?.nats?.issuer_account === "string" ? c.nats.issuer_account : c?.iss;
67
+ if (typeof account !== "string" || !/^A[A-Z2-7]{55}$/.test(account))
68
+ throw new Error("creds: the NATS user JWT names no issuing account in account-nkey form (neither `nats.issuer_account` nor `iss`) - cannot determine the issuing account");
69
+ return account;
70
+ }
25
71
  /** A non-secret GENERATION token for a credential: SHA-256 of its compact USER JWT.
26
72
  *
27
73
  * The JWT, not the whole creds envelope, on purpose. The JWT is exactly what the broker is
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAkBtD;oFACoF;AACpF,MAAM,UAAU,WAAW;IACzB,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CA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