@cotal-ai/core 0.11.6 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acls.d.ts +31 -7
- package/dist/acls.d.ts.map +1 -1
- package/dist/acls.js +105 -17
- package/dist/acls.js.map +1 -1
- package/dist/agent-file.js +1 -1
- package/dist/agent-file.js.map +1 -1
- package/dist/auth-provider.d.ts +90 -10
- package/dist/auth-provider.d.ts.map +1 -1
- package/dist/auth-provider.js.map +1 -1
- package/dist/backup-config.d.ts +55 -0
- package/dist/backup-config.d.ts.map +1 -0
- package/dist/backup-config.js +243 -0
- package/dist/backup-config.js.map +1 -0
- package/dist/backup.d.ts +86 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +497 -0
- package/dist/backup.js.map +1 -0
- package/dist/broker-floor.d.ts +34 -0
- package/dist/broker-floor.d.ts.map +1 -0
- package/dist/broker-floor.js +39 -0
- package/dist/broker-floor.js.map +1 -0
- package/dist/canonical.d.ts +24 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +159 -0
- package/dist/canonical.js.map +1 -0
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js +8 -1
- package/dist/channels.js.map +1 -1
- package/dist/connector.d.ts +4 -0
- package/dist/connector.d.ts.map +1 -1
- package/dist/endpoint-action.d.ts +424 -0
- package/dist/endpoint-action.d.ts.map +1 -0
- package/dist/endpoint-action.js +910 -0
- package/dist/endpoint-action.js.map +1 -0
- package/dist/endpoint-binding.d.ts +344 -0
- package/dist/endpoint-binding.d.ts.map +1 -0
- package/dist/endpoint-binding.js +753 -0
- package/dist/endpoint-binding.js.map +1 -0
- package/dist/endpoint-checkpoint.d.ts +292 -0
- package/dist/endpoint-checkpoint.d.ts.map +1 -0
- package/dist/endpoint-checkpoint.js +818 -0
- package/dist/endpoint-checkpoint.js.map +1 -0
- package/dist/endpoint-cluster.d.ts +95 -0
- package/dist/endpoint-cluster.d.ts.map +1 -0
- package/dist/endpoint-cluster.js +194 -0
- package/dist/endpoint-cluster.js.map +1 -0
- package/dist/endpoint-contract-store.d.ts +90 -0
- package/dist/endpoint-contract-store.d.ts.map +1 -0
- package/dist/endpoint-contract-store.js +348 -0
- package/dist/endpoint-contract-store.js.map +1 -0
- package/dist/endpoint-envelope.d.ts +165 -0
- package/dist/endpoint-envelope.d.ts.map +1 -0
- package/dist/endpoint-envelope.js +346 -0
- package/dist/endpoint-envelope.js.map +1 -0
- package/dist/endpoint-grants.d.ts +123 -0
- package/dist/endpoint-grants.d.ts.map +1 -0
- package/dist/endpoint-grants.js +215 -0
- package/dist/endpoint-grants.js.map +1 -0
- package/dist/endpoint-guard.d.ts +222 -0
- package/dist/endpoint-guard.d.ts.map +1 -0
- package/dist/endpoint-guard.js +468 -0
- package/dist/endpoint-guard.js.map +1 -0
- package/dist/endpoint-handle.d.ts +176 -0
- package/dist/endpoint-handle.d.ts.map +1 -0
- package/dist/endpoint-handle.js +608 -0
- package/dist/endpoint-handle.js.map +1 -0
- package/dist/endpoint-journal.d.ts +225 -0
- package/dist/endpoint-journal.d.ts.map +1 -0
- package/dist/endpoint-journal.js +431 -0
- package/dist/endpoint-journal.js.map +1 -0
- package/dist/endpoint-receipt.d.ts +225 -0
- package/dist/endpoint-receipt.d.ts.map +1 -0
- package/dist/endpoint-receipt.js +417 -0
- package/dist/endpoint-receipt.js.map +1 -0
- package/dist/endpoint-records.d.ts +243 -0
- package/dist/endpoint-records.d.ts.map +1 -0
- package/dist/endpoint-records.js +591 -0
- package/dist/endpoint-records.js.map +1 -0
- package/dist/endpoint-serve.d.ts +176 -0
- package/dist/endpoint-serve.d.ts.map +1 -0
- package/dist/endpoint-serve.js +446 -0
- package/dist/endpoint-serve.js.map +1 -0
- package/dist/endpoint-service.d.ts +518 -0
- package/dist/endpoint-service.d.ts.map +1 -0
- package/dist/endpoint-service.js +973 -0
- package/dist/endpoint-service.js.map +1 -0
- package/dist/endpoint-session.d.ts +398 -0
- package/dist/endpoint-session.d.ts.map +1 -0
- package/dist/endpoint-session.js +834 -0
- package/dist/endpoint-session.js.map +1 -0
- package/dist/endpoint-signing.d.ts +105 -0
- package/dist/endpoint-signing.d.ts.map +1 -0
- package/dist/endpoint-signing.js +190 -0
- package/dist/endpoint-signing.js.map +1 -0
- package/dist/endpoint-subjects.d.ts +222 -0
- package/dist/endpoint-subjects.d.ts.map +1 -0
- package/dist/endpoint-subjects.js +381 -0
- package/dist/endpoint-subjects.js.map +1 -0
- package/dist/endpoint-supervisor.d.ts +19 -0
- package/dist/endpoint-supervisor.d.ts.map +1 -0
- package/dist/endpoint-supervisor.js +12 -0
- package/dist/endpoint-supervisor.js.map +1 -0
- package/dist/endpoint-traits.d.ts +225 -0
- package/dist/endpoint-traits.d.ts.map +1 -0
- package/dist/endpoint-traits.js +469 -0
- package/dist/endpoint-traits.js.map +1 -0
- package/dist/endpoint-verbs.d.ts +277 -0
- package/dist/endpoint-verbs.d.ts.map +1 -0
- package/dist/endpoint-verbs.js +576 -0
- package/dist/endpoint-verbs.js.map +1 -0
- package/dist/endpoint-virtual.d.ts +308 -0
- package/dist/endpoint-virtual.d.ts.map +1 -0
- package/dist/endpoint-virtual.js +440 -0
- package/dist/endpoint-virtual.js.map +1 -0
- package/dist/endpoint-work.d.ts +304 -0
- package/dist/endpoint-work.d.ts.map +1 -0
- package/dist/endpoint-work.js +728 -0
- package/dist/endpoint-work.js.map +1 -0
- package/dist/endpoint.d.ts +66 -22
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/endpoint.js +289 -89
- package/dist/endpoint.js.map +1 -1
- package/dist/evict.d.ts +95 -32
- package/dist/evict.d.ts.map +1 -1
- package/dist/evict.js +193 -3
- package/dist/evict.js.map +1 -1
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/lease.d.ts +4 -0
- package/dist/lease.d.ts.map +1 -1
- package/dist/lease.js.map +1 -1
- package/dist/members.d.ts +4 -4
- package/dist/members.d.ts.map +1 -1
- package/dist/members.js +12 -12
- package/dist/members.js.map +1 -1
- package/dist/provision.d.ts +78 -20
- package/dist/provision.d.ts.map +1 -1
- package/dist/provision.js +214 -37
- package/dist/provision.js.map +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/safe-pattern.d.ts +33 -0
- package/dist/safe-pattern.d.ts.map +1 -0
- package/dist/safe-pattern.js +486 -0
- package/dist/safe-pattern.js.map +1 -0
- package/dist/schema-profile.d.ts +93 -0
- package/dist/schema-profile.d.ts.map +1 -0
- package/dist/schema-profile.js +284 -0
- package/dist/schema-profile.js.map +1 -0
- package/dist/secret-store.d.ts +46 -0
- package/dist/secret-store.d.ts.map +1 -0
- package/dist/secret-store.js +2 -0
- package/dist/secret-store.js.map +1 -0
- package/dist/space-auth.d.ts +9 -0
- package/dist/space-auth.d.ts.map +1 -0
- package/dist/space-auth.js +126 -0
- package/dist/space-auth.js.map +1 -0
- package/dist/streams.d.ts +14 -10
- package/dist/streams.d.ts.map +1 -1
- package/dist/streams.js +47 -76
- package/dist/streams.js.map +1 -1
- package/dist/subjects.d.ts +100 -40
- package/dist/subjects.d.ts.map +1 -1
- package/dist/subjects.js +136 -60
- package/dist/subjects.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -2
package/dist/acls.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Durable read-ACL registry — read/write helpers over the per-space ACL KV bucket
|
|
3
|
-
* (`cotal_acl_<space>`). One {@link AclRecord} per
|
|
3
|
+
* (`cotal_acl_<space>`). One {@link AclRecord} per LIFECYCLE under {@link aclKey}
|
|
4
|
+
* (`<owner>.<actor>.<lifecycleUid>`, SPEC §13.1), holding that incarnation's
|
|
4
5
|
* current read ACL (`allowSubscribe`). This is the **keystone** that lets the Plane-3 trusted reader
|
|
5
6
|
* run in a stateless, server-side **delivery daemon**: the reader re-authorizes every durable entry
|
|
6
7
|
* against the owner's ACL read FRESH from here (not the manager's in-memory ledger), so a daemon
|
|
@@ -26,10 +27,31 @@ export declare function openAclRegistry(nc: import("@nats-io/transport-node").Na
|
|
|
26
27
|
* `allowSubscribe` as-is, **including `[]`** (a known no-read policy → DROP). The CAS revision is
|
|
27
28
|
* returned alongside for a read-modify-write.
|
|
28
29
|
*/
|
|
29
|
-
export declare function readAcl(kv: KV, owner: string): Promise<{
|
|
30
|
+
export declare function readAcl(kv: KV, owner: string, lifecycleUid: string): Promise<{
|
|
30
31
|
record: AclRecord;
|
|
31
32
|
revision: number;
|
|
32
33
|
} | undefined>;
|
|
34
|
+
/** Error for an alias with MORE than one live ACL row: §13.1's invariant is at most one live
|
|
35
|
+
* lifecycle per alias, so two rows are split-brain evidence (a reservation breach or an unfinished
|
|
36
|
+
* teardown), and an alias-level authorizer MUST refuse loudly rather than pick one. */
|
|
37
|
+
export declare class AmbiguousAclAlias extends Error {
|
|
38
|
+
readonly principal: string;
|
|
39
|
+
readonly lifecycleUids: string[];
|
|
40
|
+
constructor(principal: string, lifecycleUids: string[]);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolve an ALIAS (`<owner>.<actor>` dot-form) to its single live lifecycle-keyed ACL row — the
|
|
44
|
+
* bounded prefix enumeration for callers that hold no lifecycle UID (a runtime durable-join authz).
|
|
45
|
+
* Returns `undefined` when NO live row exists (unknown alias — the caller DEFERS/refuses), the row +
|
|
46
|
+
* its uid when exactly ONE does, and THROWS {@link AmbiguousAclAlias} on two or more: taking
|
|
47
|
+
* first-match would let a stale row authorize (or de-authorize) the successor. Keys that do not parse
|
|
48
|
+
* as `<owner>.<actor>.<uid>` are ignored (foreign shapes never authorize).
|
|
49
|
+
*/
|
|
50
|
+
export declare function readAclForAlias(kv: KV, principal: string): Promise<{
|
|
51
|
+
record: AclRecord;
|
|
52
|
+
revision: number;
|
|
53
|
+
lifecycleUid: string;
|
|
54
|
+
} | undefined>;
|
|
33
55
|
/**
|
|
34
56
|
* Record (set) an owner's read ACL — a single ATOMIC CAS put of the full value, never
|
|
35
57
|
* create-then-populate, so a present record is always complete and `[]` always means "no-read", never
|
|
@@ -37,9 +59,11 @@ export declare function readAcl(kv: KV, owner: string): Promise<{
|
|
|
37
59
|
* effect: writing the same `allowSubscribe` is harmless. Use `allowSubscribe: []` to revoke all reads
|
|
38
60
|
* (the reader then DROPS the owner's entries) — distinct from {@link deleteAcl}, which removes the row.
|
|
39
61
|
*/
|
|
40
|
-
export declare function commitAcl(kv: KV, owner: string, allowSubscribe: string[]): Promise<AclRecord>;
|
|
41
|
-
/** Permanently remove
|
|
42
|
-
* AFTER invalidating creds).
|
|
43
|
-
*
|
|
44
|
-
|
|
62
|
+
export declare function commitAcl(kv: KV, owner: string, lifecycleUid: string, allowSubscribe: string[]): Promise<AclRecord>;
|
|
63
|
+
/** Permanently remove one LIFECYCLE's ACL row (GC / footprint deletion — revocation deletes the
|
|
64
|
+
* footprint AFTER invalidating creds). Lifecycle-exact by construction: a replayed delete for a
|
|
65
|
+
* retired lifecycle names a key the successor's row does not share. Distinct from a
|
|
66
|
+
* `commitAcl(kv, owner, uid, [])` write, which keeps a present "no-read" record so the reader DROPS
|
|
67
|
+
* (vs. DEFER for an absent owner). */
|
|
68
|
+
export declare function deleteAcl(kv: KV, owner: string, lifecycleUid: string): Promise<void>;
|
|
45
69
|
//# sourceMappingURL=acls.d.ts.map
|
package/dist/acls.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acls.d.ts","sourceRoot":"","sources":["../src/acls.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"acls.d.ts","sourceRoot":"","sources":["../src/acls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAO,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,SA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 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Durable read-ACL registry — read/write helpers over the per-space ACL KV bucket
|
|
3
|
-
* (`cotal_acl_<space>`). One {@link AclRecord} per
|
|
3
|
+
* (`cotal_acl_<space>`). One {@link AclRecord} per LIFECYCLE under {@link aclKey}
|
|
4
|
+
* (`<owner>.<actor>.<lifecycleUid>`, SPEC §13.1), holding that incarnation's
|
|
4
5
|
* current read ACL (`allowSubscribe`). This is the **keystone** that lets the Plane-3 trusted reader
|
|
5
6
|
* run in a stateless, server-side **delivery daemon**: the reader re-authorizes every durable entry
|
|
6
7
|
* against the owner's ACL read FRESH from here (not the manager's in-memory ledger), so a daemon
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
* record (a genuinely-unknown owner — the reader DEFERS, never drops).
|
|
14
15
|
*/
|
|
15
16
|
import { Kvm } from "@nats-io/kv";
|
|
16
|
-
import { aclBucket, aclKey } from "./subjects.js";
|
|
17
|
+
import { aclBucket, aclKey, aclAliasFilter, parseLifecycleSubjectKey } from "./subjects.js";
|
|
17
18
|
/** Open the ACL registry bucket. Auth mode OPENs the bucket pre-created at `cotal up`; a privileged
|
|
18
19
|
* caller may pass `{ create: true }` to lazily CREATE it. Mirrors {@link openMembersRegistry}. */
|
|
19
20
|
export async function openAclRegistry(nc, space, opts = {}) {
|
|
@@ -27,8 +28,8 @@ export async function openAclRegistry(nc, space, opts = {}) {
|
|
|
27
28
|
* `allowSubscribe` as-is, **including `[]`** (a known no-read policy → DROP). The CAS revision is
|
|
28
29
|
* returned alongside for a read-modify-write.
|
|
29
30
|
*/
|
|
30
|
-
export async function readAcl(kv, owner) {
|
|
31
|
-
const e = await kv.get(aclKey(owner));
|
|
31
|
+
export async function readAcl(kv, owner, lifecycleUid) {
|
|
32
|
+
const e = await kv.get(aclKey(owner, lifecycleUid));
|
|
32
33
|
if (!e || e.operation === "DEL" || e.operation === "PURGE")
|
|
33
34
|
return undefined;
|
|
34
35
|
try {
|
|
@@ -41,6 +42,72 @@ export async function readAcl(kv, owner) {
|
|
|
41
42
|
return undefined;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
/** Error for an alias with MORE than one live ACL row: §13.1's invariant is at most one live
|
|
46
|
+
* lifecycle per alias, so two rows are split-brain evidence (a reservation breach or an unfinished
|
|
47
|
+
* teardown), and an alias-level authorizer MUST refuse loudly rather than pick one. */
|
|
48
|
+
export class AmbiguousAclAlias extends Error {
|
|
49
|
+
principal;
|
|
50
|
+
lifecycleUids;
|
|
51
|
+
constructor(principal, lifecycleUids) {
|
|
52
|
+
super(`read-ACL alias "${principal}" resolves to ${lifecycleUids.length} live lifecycle rows (${lifecycleUids.join(", ")}); ` +
|
|
53
|
+
`at most one lifecycle may be live per alias (SPEC 13.1) - refusing to authorize on a first-match guess`);
|
|
54
|
+
this.principal = principal;
|
|
55
|
+
this.lifecycleUids = lifecycleUids;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve an ALIAS (`<owner>.<actor>` dot-form) to its single live lifecycle-keyed ACL row — the
|
|
60
|
+
* bounded prefix enumeration for callers that hold no lifecycle UID (a runtime durable-join authz).
|
|
61
|
+
* Returns `undefined` when NO live row exists (unknown alias — the caller DEFERS/refuses), the row +
|
|
62
|
+
* its uid when exactly ONE does, and THROWS {@link AmbiguousAclAlias} on two or more: taking
|
|
63
|
+
* first-match would let a stale row authorize (or de-authorize) the successor. Keys that do not parse
|
|
64
|
+
* as `<owner>.<actor>.<uid>` are ignored (foreign shapes never authorize).
|
|
65
|
+
*/
|
|
66
|
+
export async function readAclForAlias(kv, principal) {
|
|
67
|
+
// HONESTY (SPEC 13.1 residual, panel-locked): "at most one live lifecycle per alias" is
|
|
68
|
+
// fail-loud + exact-name teardown, NOT a broker occupancy CAS (reservation lands with P2).
|
|
69
|
+
// A FAILED detached teardown leaves the predecessor's row live; a same-alias successor then
|
|
70
|
+
// hits AmbiguousAclAlias on every durable-join and stays LIVE-ONLY until an operator re-runs
|
|
71
|
+
// the exact-uid deprovision (or a future D30/D33 reconciler, which does not exist yet). The
|
|
72
|
+
// fail direction is deliberate: refuse beats silently inheriting a predecessor's ACL.
|
|
73
|
+
const first = await enumerateLiveAclRows(kv, principal);
|
|
74
|
+
if (first.length > 1)
|
|
75
|
+
throw new AmbiguousAclAlias(principal, first.map((l) => l.lifecycleUid).sort());
|
|
76
|
+
// POST-SCAN RE-VERIFY (panel bar, TOCTOU close): `kv.keys()` is a point-in-time snapshot
|
|
77
|
+
// bounded by the stream sequence at consumer-create, so a successor row COMMITTED AFTER that
|
|
78
|
+
// snapshot is invisible to the first pass — a genuinely dual-live alias would resolve as the
|
|
79
|
+
// lone (possibly predecessor) row instead of refusing. Enumerate a SECOND time and act on the
|
|
80
|
+
// fresh pass: a row that appeared makes the alias ambiguous (refuse), a row that vanished
|
|
81
|
+
// makes it absent (defer). Two live rows in EITHER pass refuse. Bounded at two passes — an
|
|
82
|
+
// alias replaced BETWEEN the passes (disjoint singles) also refuses, and the caller's retry
|
|
83
|
+
// resolves against the settled state; anything stronger is the P2 occupancy reservation.
|
|
84
|
+
const second = await enumerateLiveAclRows(kv, principal);
|
|
85
|
+
if (second.length > 1)
|
|
86
|
+
throw new AmbiguousAclAlias(principal, second.map((l) => l.lifecycleUid).sort());
|
|
87
|
+
if (second.length === 0)
|
|
88
|
+
return undefined;
|
|
89
|
+
if (first.length === 1 && first[0].lifecycleUid !== second[0].lifecycleUid)
|
|
90
|
+
throw new AmbiguousAclAlias(principal, [first[0].lifecycleUid, second[0].lifecycleUid].sort());
|
|
91
|
+
return { record: second[0].record, revision: second[0].revision, lifecycleUid: second[0].lifecycleUid };
|
|
92
|
+
}
|
|
93
|
+
/** One live-row enumeration pass for {@link readAclForAlias}: LIVE rows, not keys — each candidate
|
|
94
|
+
* key is resolved through {@link readAcl} (which filters DEL/PURGE markers and garbled values)
|
|
95
|
+
* BEFORE it counts toward ambiguity. The pinned @nats-io/kv keys() already skips DEL/PURGE
|
|
96
|
+
* markers, so the re-read is belt-and-suspenders — but the refusal invariant is ">=2 LIVE rows",
|
|
97
|
+
* and counting raw iterator keys would let a client-version drift (a keys() that surfaces
|
|
98
|
+
* markers) fail-closed the NORMAL deprovision-then-respawn path. */
|
|
99
|
+
async function enumerateLiveAclRows(kv, principal) {
|
|
100
|
+
const live = [];
|
|
101
|
+
for await (const key of await kv.keys(aclAliasFilter(principal))) {
|
|
102
|
+
const parsed = parseLifecycleSubjectKey(key);
|
|
103
|
+
if (!parsed || `${parsed.owner}.${parsed.actor}` !== principal)
|
|
104
|
+
continue;
|
|
105
|
+
const row = await readAcl(kv, principal, parsed.lifecycleUid);
|
|
106
|
+
if (row !== undefined)
|
|
107
|
+
live.push({ lifecycleUid: parsed.lifecycleUid, ...row });
|
|
108
|
+
}
|
|
109
|
+
return live;
|
|
110
|
+
}
|
|
44
111
|
/**
|
|
45
112
|
* Record (set) an owner's read ACL — a single ATOMIC CAS put of the full value, never
|
|
46
113
|
* create-then-populate, so a present record is always complete and `[]` always means "no-read", never
|
|
@@ -48,10 +115,11 @@ export async function readAcl(kv, owner) {
|
|
|
48
115
|
* effect: writing the same `allowSubscribe` is harmless. Use `allowSubscribe: []` to revoke all reads
|
|
49
116
|
* (the reader then DROPS the owner's entries) — distinct from {@link deleteAcl}, which removes the row.
|
|
50
117
|
*/
|
|
51
|
-
export async function commitAcl(kv, owner, allowSubscribe) {
|
|
52
|
-
const key = aclKey(owner);
|
|
118
|
+
export async function commitAcl(kv, owner, lifecycleUid, allowSubscribe) {
|
|
119
|
+
const key = aclKey(owner, lifecycleUid);
|
|
120
|
+
let lastErr;
|
|
53
121
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
54
|
-
const cur = await readAcl(kv, owner);
|
|
122
|
+
const cur = await readAcl(kv, owner, lifecycleUid);
|
|
55
123
|
const next = {
|
|
56
124
|
allowSubscribe: [...allowSubscribe],
|
|
57
125
|
revision: (cur?.record.revision ?? 0) + 1,
|
|
@@ -63,24 +131,44 @@ export async function commitAcl(kv, owner, allowSubscribe) {
|
|
|
63
131
|
await kv.create(key, data);
|
|
64
132
|
return next;
|
|
65
133
|
}
|
|
66
|
-
catch {
|
|
67
|
-
|
|
134
|
+
catch (e) {
|
|
135
|
+
lastErr = e;
|
|
136
|
+
// Either we lost a create race, or the row is PRESENT but garbled — readAcl reports both
|
|
137
|
+
// as `undefined` (DEFER), and a garbled row would make this create conflict on every
|
|
138
|
+
// attempt (the owner stays wedged until purge). CAS-overwrite at the raw revision: the
|
|
139
|
+
// atomic full-value put restores the "present record is always complete" invariant.
|
|
140
|
+
try {
|
|
141
|
+
const raw = await kv.get(key);
|
|
142
|
+
if (raw) {
|
|
143
|
+
await kv.update(key, data, raw.revision);
|
|
144
|
+
return next;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (e2) {
|
|
148
|
+
lastErr = e2;
|
|
149
|
+
}
|
|
150
|
+
continue; // raced a concurrent writer — re-read and retry
|
|
68
151
|
}
|
|
69
152
|
}
|
|
70
153
|
try {
|
|
71
154
|
await kv.update(key, data, cur.revision);
|
|
72
155
|
return next;
|
|
73
156
|
}
|
|
74
|
-
catch {
|
|
75
|
-
|
|
157
|
+
catch (e) {
|
|
158
|
+
lastErr = e; // revision moved under us — re-read and retry
|
|
159
|
+
continue;
|
|
76
160
|
}
|
|
77
161
|
}
|
|
78
|
-
|
|
162
|
+
// Carry the last underlying KV failure: without it the operator sees only this wrapper and the
|
|
163
|
+
// actual cause (timeout, permission, sequence conflict) is permanently lost.
|
|
164
|
+
throw new Error(`acl CAS exhausted retries for ${owner}${lastErr ? ` - last error: ${lastErr instanceof Error ? lastErr.message : String(lastErr)}` : ""}`, lastErr instanceof Error ? { cause: lastErr } : undefined);
|
|
79
165
|
}
|
|
80
|
-
/** Permanently remove
|
|
81
|
-
* AFTER invalidating creds).
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
|
|
166
|
+
/** Permanently remove one LIFECYCLE's ACL row (GC / footprint deletion — revocation deletes the
|
|
167
|
+
* footprint AFTER invalidating creds). Lifecycle-exact by construction: a replayed delete for a
|
|
168
|
+
* retired lifecycle names a key the successor's row does not share. Distinct from a
|
|
169
|
+
* `commitAcl(kv, owner, uid, [])` write, which keeps a present "no-read" record so the reader DROPS
|
|
170
|
+
* (vs. DEFER for an absent owner). */
|
|
171
|
+
export async function deleteAcl(kv, owner, lifecycleUid) {
|
|
172
|
+
await kv.purge(aclKey(owner, lifecycleUid));
|
|
85
173
|
}
|
|
86
174
|
//# sourceMappingURL=acls.js.map
|
package/dist/acls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acls.js","sourceRoot":"","sources":["../src/acls.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"acls.js","sourceRoot":"","sources":["../src/acls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,GAAG,EAAW,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAG5F;mGACmG;AACnG,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,EAAoD,EACpD,KAAa,EACb,OAA6B,EAAE;IAE/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC;IACxB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACjF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,EAAM,EACN,KAAa,EACb,YAAoB;IAEpB,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;IACpD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EAAE,YAAY,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/agent-file.js
CHANGED
|
@@ -38,7 +38,7 @@ function parseFrontmatter(src, path) {
|
|
|
38
38
|
doc = parseYaml(src);
|
|
39
39
|
}
|
|
40
40
|
catch (e) {
|
|
41
|
-
throw new Error(`agent file ${path}: invalid YAML frontmatter
|
|
41
|
+
throw new Error(`agent file ${path}: invalid YAML frontmatter; ${e.message}`);
|
|
42
42
|
}
|
|
43
43
|
if (doc === null || doc === undefined)
|
|
44
44
|
return {};
|
package/dist/agent-file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-file.js","sourceRoot":"","sources":["../src/agent-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA2DtF;;;2FAG2F;AAC3F,SAAS,gBAAgB,CAAC,GAAW,EAAE,IAAY;IACjD,IAAI,GAAY,CAAC;IACjB,IAAI,CAAC;QACH,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,
|
|
1
|
+
{"version":3,"file":"agent-file.js","sourceRoot":"","sources":["../src/agent-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,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AAC,EAAE,CAAC;IAC1D,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,QAAQ,WAAW,YAAY,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED;;mDAEmD;AACnD,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,UAAkB;IAC5D,IAAI,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IAC9C,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrF,OAAO,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,UAAU,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED;;;kGAGkG;AAClG,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,KAAgC;IAC1E,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,GAAI,CAAC,EAAE,EAAE,CAAC;QACtB,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IAC1C,CAAC;AACH,CAAC"}
|
package/dist/auth-provider.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Extension } from "./registry.js";
|
|
2
|
+
import type { SecretStore } from "./secret-store.js";
|
|
2
3
|
/**
|
|
3
4
|
* The one extension kind an identity/auth implementation registers so a composition root can turn
|
|
4
5
|
* on USER-MODE auth (the human-owner identity plane over per-agent NATS identity) WITHOUT importing
|
|
@@ -14,21 +15,29 @@ import { type Extension } from "./registry.js";
|
|
|
14
15
|
* No provider registered ⇒ user-mode auth is unavailable and requesting it MUST fail loud (no
|
|
15
16
|
* static fallback) — a library root that never imports the auth package simply cannot serve a
|
|
16
17
|
* user-auth space.
|
|
18
|
+
*
|
|
19
|
+
* TWO state surfaces, split by the {@link SecretStore} seam: the provider's SECRET material
|
|
20
|
+
* (callout account, issuer keys, owner secret, service key projection) rides the `store` each
|
|
21
|
+
* method receives — the CALLER composes it (locally the workspace's `.cotal`-rooted filesystem
|
|
22
|
+
* store; a hosted composition injects KMS/Vault), the provider never discovers one ambiently.
|
|
23
|
+
* The provider's NON-SEAM state (the actor ledger, the IdP pin, service runtime discovery)
|
|
24
|
+
* stays under `dir`, the local state directory.
|
|
17
25
|
*/
|
|
18
26
|
export interface AuthProvider extends Extension {
|
|
19
27
|
readonly kind: "auth-provider";
|
|
20
28
|
/**
|
|
21
|
-
* Ensure this space's user-auth material exists
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
29
|
+
* Ensure this space's user-auth material exists (generated + persisted on the first call, reused
|
|
30
|
+
* verbatim after — account identities and signing keys MUST be stable across restarts or
|
|
31
|
+
* previously-issued credentials break) and describe what the composition root must wire up.
|
|
32
|
+
* Secret material persists through `input.store`; non-seam state under `input.dir`. Idempotent. This call may hold the provisioning seeds BRIEFLY; the long-lived service
|
|
25
33
|
* process must load only provider-owned projected files written here, never the space's full
|
|
26
34
|
* trust bundle.
|
|
27
35
|
*/
|
|
28
36
|
prepareServer(input: AuthPrepareInput): Promise<AuthPrepared>;
|
|
29
37
|
/**
|
|
30
38
|
* CLIENT side: produce the connect material for a user-mode space from THIS machine's session
|
|
31
|
-
* state (the login cache + the provider's space-scoped state
|
|
39
|
+
* state (the login cache + the provider's space-scoped state — secrets in `store`, the rest
|
|
40
|
+
* under `dir`). `actor` is the
|
|
32
41
|
* ledger-granted agent-instance the caller connects as. Returns what {@link EndpointOptions}'
|
|
33
42
|
* user mode consumes (`bearer` + `sentinelCreds`). MUST fail loud with the EXACT operator
|
|
34
43
|
* action when anything is missing — not logged in (`cotal login --idp …`), the auth service
|
|
@@ -41,6 +50,7 @@ export interface AuthProvider extends Extension {
|
|
|
41
50
|
* `spawn -f`) ride. An under-scoped or unknown view MUST fail loud with the exact re-grant.
|
|
42
51
|
*/
|
|
43
52
|
userCredentials(opts: {
|
|
53
|
+
store: SecretStore;
|
|
44
54
|
dir: string;
|
|
45
55
|
space: string;
|
|
46
56
|
actor: string;
|
|
@@ -54,9 +64,10 @@ export interface AuthProvider extends Extension {
|
|
|
54
64
|
* offline from the login session + the space's local user-auth material (no IdP round trip).
|
|
55
65
|
* The spawn paths use it to answer "whose agents are these": a foreground/manifest spawn runs
|
|
56
66
|
* the agents under the OPERATOR's owner. MUST fail loud when not logged in (naming the exact
|
|
57
|
-
* `cotal login --idp …` line) or when the space has no user-auth material
|
|
67
|
+
* `cotal login --idp …` line) or when the space has no user-auth material (in `store`/`dir`).
|
|
58
68
|
*/
|
|
59
69
|
ownerForLogin(opts: {
|
|
70
|
+
store: SecretStore;
|
|
60
71
|
dir: string;
|
|
61
72
|
space: string;
|
|
62
73
|
}): Promise<string>;
|
|
@@ -64,10 +75,11 @@ export interface AuthProvider extends Extension {
|
|
|
64
75
|
* Read-only OFFLINE introspection for status surfaces (`cotal status`): this machine's cached
|
|
65
76
|
* login for the space and — where the space's ledger is locally readable — whether that login's
|
|
66
77
|
* `actor` is granted. Never network-bound and never a mint; "not signed in" is a REPORTED state
|
|
67
|
-
* here, not a thrown one. Throws only when the space has no user-auth material
|
|
78
|
+
* here, not a thrown one. Throws only when the space has no user-auth material in `store`/`dir`
|
|
68
79
|
* (there is nothing to report status about).
|
|
69
80
|
*/
|
|
70
81
|
userStatus(opts: {
|
|
82
|
+
store: SecretStore;
|
|
71
83
|
dir: string;
|
|
72
84
|
space: string;
|
|
73
85
|
actor: string;
|
|
@@ -78,9 +90,10 @@ export interface AuthProvider extends Extension {
|
|
|
78
90
|
* connect payloads". Returns the ONE-TIME plaintext agent secret (persisted only as a hash;
|
|
79
91
|
* the caller delivers it to the agent process via a 0600 file and never sees it again) plus
|
|
80
92
|
* the sentinel creds the agent presents alongside its bearers. Upsert — re-granting an actor
|
|
81
|
-
* rotates its secret. MUST fail loud when the space has no user-auth material
|
|
93
|
+
* rotates its secret. MUST fail loud when the space has no user-auth material in `store`/`dir`.
|
|
82
94
|
*/
|
|
83
95
|
grantAgent(opts: {
|
|
96
|
+
store: SecretStore;
|
|
84
97
|
dir: string;
|
|
85
98
|
space: string;
|
|
86
99
|
owner: string;
|
|
@@ -92,6 +105,10 @@ export interface AuthProvider extends Extension {
|
|
|
92
105
|
/** The spawning principal (`<owner>.<actor>` dot-form) — the grant's audit link. */
|
|
93
106
|
parent?: string;
|
|
94
107
|
label?: string;
|
|
108
|
+
/** The incarnation's lifecycle UID (SPEC §13.1). Recorded on the ledger row so the auth
|
|
109
|
+
* callout mints this agent's lifecycle-keyed grants (`dm_…-<uid>`/`dlv_…-<uid>`/
|
|
110
|
+
* `chathist_…-<uid>`) from the SAME value its provisioned broker footprint carries. */
|
|
111
|
+
lifecycleUid: string;
|
|
95
112
|
}): Promise<{
|
|
96
113
|
actorToken: string;
|
|
97
114
|
sentinelCreds: string;
|
|
@@ -116,6 +133,45 @@ export interface AuthProvider extends Extension {
|
|
|
116
133
|
owner: string;
|
|
117
134
|
actor: string;
|
|
118
135
|
}): Promise<string[] | undefined>;
|
|
136
|
+
/**
|
|
137
|
+
* Remove this provider's SECRET material for a space from the given store — the DELETE half of
|
|
138
|
+
* the seam pair (every kind that reads and writes through a {@link SecretStore} must be
|
|
139
|
+
* deletable through it, or a reset wipes local identity while an injected backend keeps the old
|
|
140
|
+
* secrets authoritative: split authority, and the next provision mixes a fresh trust bundle
|
|
141
|
+
* with stale stable identities). Attempts EVERY owned key even when one fails (each delete is
|
|
142
|
+
* idempotent by the store contract, so a failed pass is retryable as-is), then throws with the
|
|
143
|
+
* collected failures. Touches ONLY the store — non-seam state (ledger, IdP pin, discovery) is
|
|
144
|
+
* the caller's local-reset concern, swept only AFTER this succeeds.
|
|
145
|
+
*/
|
|
146
|
+
deprovisionSecrets(opts: {
|
|
147
|
+
store: SecretStore;
|
|
148
|
+
space: string;
|
|
149
|
+
}): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Read-only OFFLINE continuity commitment for this space's existing user-auth trust state. The
|
|
152
|
+
* provider defines `scheme`; `value` is safe to place in a backup manifest and MUST commit to the
|
|
153
|
+
* account identity, owner derivation, IdP/issuer pins, and every interactive + managed authority
|
|
154
|
+
* row. Missing or malformed state throws. This method must never create, repair, rotate, or mint.
|
|
155
|
+
*/
|
|
156
|
+
trustFingerprint(opts: {
|
|
157
|
+
store: SecretStore;
|
|
158
|
+
dir: string;
|
|
159
|
+
space: string;
|
|
160
|
+
}): Promise<AuthTrustFingerprint>;
|
|
161
|
+
/**
|
|
162
|
+
* Validate that retained managed-agent material still names the SAME live principal and authority
|
|
163
|
+
* row. This is the resume path: it must reuse the supplied token/sentinel, never call
|
|
164
|
+
* {@link grantAgent}, rotate a token, create a row, or provision a replacement identity.
|
|
165
|
+
*/
|
|
166
|
+
validateRetainedAgent(opts: {
|
|
167
|
+
store: SecretStore;
|
|
168
|
+
dir: string;
|
|
169
|
+
space: string;
|
|
170
|
+
owner: string;
|
|
171
|
+
actor: string;
|
|
172
|
+
actorToken: string;
|
|
173
|
+
sentinelCreds: string;
|
|
174
|
+
}): Promise<RetainedAgentAuthority>;
|
|
119
175
|
/**
|
|
120
176
|
* Registry name of the provider's self-registered {@link Command} that prints ONE fresh agent
|
|
121
177
|
* bearer to stdout and exits (flags: `--dir <state-dir> --space <space> --owner <o> --actor <a>
|
|
@@ -124,6 +180,25 @@ export interface AuthProvider extends Extension {
|
|
|
124
180
|
* runtime only runs an argv and reads a line. */
|
|
125
181
|
readonly agentBearerCommand: string;
|
|
126
182
|
}
|
|
183
|
+
/** Provider-defined, versioned manifest-safe commitment. Callers compare both fields exactly. */
|
|
184
|
+
export interface AuthTrustFingerprint {
|
|
185
|
+
scheme: string;
|
|
186
|
+
value: string;
|
|
187
|
+
}
|
|
188
|
+
/** Existing managed row returned after retained secret + sentinel validation. */
|
|
189
|
+
export interface RetainedAgentAuthority {
|
|
190
|
+
owner: string;
|
|
191
|
+
actor: string;
|
|
192
|
+
/** The incarnation UID the CURRENT ledger row carries. The manager binds it against the inventory
|
|
193
|
+
* identity's uid before any spawn, so a retained record aimed at a different incarnation fails at
|
|
194
|
+
* pre-effect validation rather than at the broker after the child is already running (SPEC §13.1). */
|
|
195
|
+
lifecycleUid: string;
|
|
196
|
+
scope: string[];
|
|
197
|
+
allowSubscribe: string[];
|
|
198
|
+
allowPublish: string[];
|
|
199
|
+
role?: string;
|
|
200
|
+
parent?: string;
|
|
201
|
+
}
|
|
127
202
|
/** The ONE registered auth provider, or a thrown sentence naming the fix. More than one registered
|
|
128
203
|
* is ambiguous and refuses just as loudly — there is no pick-the-first fallback. Lives in core so
|
|
129
204
|
* every surface that resolves the provider generically (CLI, manager) shares one resolution. */
|
|
@@ -165,8 +240,13 @@ export interface AuthPrepareInput {
|
|
|
165
240
|
pub: string;
|
|
166
241
|
signingSeed: string;
|
|
167
242
|
};
|
|
168
|
-
/**
|
|
169
|
-
*
|
|
243
|
+
/** Where the provider's SECRET material persists (callout account, issuer keys, owner secret,
|
|
244
|
+
* service key projection) — caller-composed, keys are the provider's own. Locally the
|
|
245
|
+
* workspace's `.cotal`-rooted filesystem store; a hosted composition injects its backend. */
|
|
246
|
+
store: SecretStore;
|
|
247
|
+
/** The provider's OWN state dir for NON-SEAM state (actor ledger, IdP pin, service runtime
|
|
248
|
+
* discovery). The caller keys it — today `<root>/.cotal/auth/<space>`; a future
|
|
249
|
+
* (broker, space) key is a caller change, never an on-disk format break. */
|
|
170
250
|
dir: string;
|
|
171
251
|
/** The operator's external identity-provider base URL (`up --user-auth --idp <url>`), OPAQUE to
|
|
172
252
|
* core — the provider pins/persists it (first call requires one; a later call must match the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B;;;;;;;OAOG;IACH,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9D;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,WAAW,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5J;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,WAAW,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzF;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,WAAW,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;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ources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-provider.js","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,eAAe,CAAC;AAyKzD;;iGAEiG;AACjG,MAAM,UAAU,mBAAmB;IACjC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAe,eAAe,CAAC,CAAC;IAC9D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,yKAAyK,CAC1K,CAAC;IACJ,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,uCAAuC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAClI,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { StoreCompression, type StreamConfig } from "@nats-io/jetstream";
|
|
2
|
+
export type SpaceBackupSelection = "full" | "registry";
|
|
3
|
+
export type SpaceBackupStreamClass = "messages" | "registry" | "authorization";
|
|
4
|
+
export type SpaceBackupExcludedClass = "transient" | "derived" | "lease";
|
|
5
|
+
export interface SpaceBackupStream {
|
|
6
|
+
name: string;
|
|
7
|
+
class: SpaceBackupStreamClass;
|
|
8
|
+
}
|
|
9
|
+
export interface SpaceBackupExcludedStream {
|
|
10
|
+
name: string;
|
|
11
|
+
class: SpaceBackupExcludedClass;
|
|
12
|
+
}
|
|
13
|
+
export interface SpaceBackupInventory {
|
|
14
|
+
backedUp: readonly SpaceBackupStream[];
|
|
15
|
+
excluded: readonly SpaceBackupExcludedStream[];
|
|
16
|
+
full: readonly string[];
|
|
17
|
+
registry: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/** The complete Cotal stream inventory at a stable backup cut. Only the eight `backedUp` streams
|
|
20
|
+
* enter a full artifact; the four excluded streams are transient, derived, or leases. */
|
|
21
|
+
export declare function spaceBackupInventory(space: string): SpaceBackupInventory;
|
|
22
|
+
/** Reject a missing, foreign, or additional stream before selecting artifact components. */
|
|
23
|
+
export declare function validateSpaceBackupInventory(space: string, actualNames: readonly string[]): SpaceBackupInventory;
|
|
24
|
+
export interface BackupStreamState {
|
|
25
|
+
messages: number;
|
|
26
|
+
bytes: number;
|
|
27
|
+
first_seq: number;
|
|
28
|
+
last_seq: number;
|
|
29
|
+
consumer_count: number;
|
|
30
|
+
first_ts?: string;
|
|
31
|
+
last_ts?: string;
|
|
32
|
+
deleted?: number[];
|
|
33
|
+
num_deleted?: number;
|
|
34
|
+
num_subjects?: number;
|
|
35
|
+
subjects?: Record<string, number>;
|
|
36
|
+
lost?: {
|
|
37
|
+
msgs?: number[] | null;
|
|
38
|
+
bytes?: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** The NATS 2.10 stream-config surface Cotal permits in an artifact or restore request. */
|
|
42
|
+
export type CanonicalBackupStreamConfig = Pick<StreamConfig, "name" | "subjects" | "retention" | "storage" | "max_consumers" | "max_msgs" | "max_bytes" | "max_age" | "max_msgs_per_subject" | "max_msg_size" | "discard" | "num_replicas" | "duplicate_window" | "allow_direct" | "mirror_direct" | "discard_new_per_subject" | "allow_rollup_hdrs" | "deny_delete" | "deny_purge" | "sealed" | "consumer_limits"> & {
|
|
43
|
+
no_ack: boolean;
|
|
44
|
+
compression: typeof StoreCompression.None;
|
|
45
|
+
};
|
|
46
|
+
export declare const BACKUP_MAX_MSGS_PER_SUBJECT = 1000;
|
|
47
|
+
export declare const BACKUP_PLANE3_DEDUP_WINDOW_MS: number;
|
|
48
|
+
/** Current canonical config for one of the eight backed-up streams. Restore callers must use this
|
|
49
|
+
* config, not the config embedded in untrusted snapshot bytes. */
|
|
50
|
+
export declare function canonicalBackupStreamConfig(space: string, stream: string): CanonicalBackupStreamConfig;
|
|
51
|
+
/** Validate every active and security-sensitive stream setting, including explicit rejection of
|
|
52
|
+
* mirrors, sources, transforms, republish, placement, sealing, metadata, and future active features. */
|
|
53
|
+
export declare function validateCanonicalBackupStreamConfig(space: string, stream: string, actual: Readonly<Record<string, unknown>>): CanonicalBackupStreamConfig;
|
|
54
|
+
export declare function validateBackupStreamState(state: Readonly<Record<string, unknown>>): BackupStreamState;
|
|
55
|
+
//# sourceMappingURL=backup-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup-config.d.ts","sourceRoot":"","sources":["../src/backup-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,gBAAgB,EAChB,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAkB5B,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,UAAU,CAAC;AACvD,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,UAAU,GAAG,eAAe,CAAC;AAC/E,MAAM,MAAM,wBAAwB,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAEzE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,sBAAsB,CAAC;CAC/B;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,wBAAwB,CAAC;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACvC,QAAQ,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAC/C,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED;yFACyF;AACzF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAwBxE;AAED,4FAA4F;AAC5F,wBA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