@serve.zone/interfaces 32.80.0 → 32.81.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/changelog.md +6 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/index.d.ts +1 -0
- package/dist_ts/data/index.js +2 -1
- package/dist_ts/data/witness.d.ts +217 -0
- package/dist_ts/data/witness.js +407 -0
- package/dist_ts/requests/index.d.ts +2 -1
- package/dist_ts/requests/index.js +3 -2
- package/dist_ts/requests/witness.d.ts +83 -0
- package/dist_ts/requests/witness.js +2 -0
- package/package.json +1 -1
- package/readme.md +80 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/index.ts +1 -0
- package/ts/data/witness.ts +606 -0
- package/ts/requests/index.ts +2 -0
- package/ts/requests/witness.ts +121 -0
package/changelog.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-11-12 - 32.81.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Witness contract (AGL-1195, Linus rulings 69 Q5, Q6 and 73): one compare-and-set record per controller, `data.IWitnessRecord` (`controllerId`, `epoch`, `activeOrigin`, `inSyncStandbyOrigin`, `revision`, `memberOrigins`, each site named by its site origin), the decision a change sets `data.IWitnessState` and the member credential `data.IWitnessMemberCredential`, whose bearer each site creates for itself (base64url of `data.witnessContract.bearerRandomBytes` random bytes, 43 characters, checked by an exact pattern) and keeps in its own config or secret store, never in the replicated controller database; the requests `requests.witness` `pairWitnessController` (redeems a one-time code the witness's operator made for the controller id, with the caller's `bearerSha256`), `enrollWitnessMember` (the active enrolls another site by its `bearerSha256`, never the recorded in-sync standby), both answering only `{ record }`, `getWitnessRecord`, `compareAndSetWitnessRecord` (stored only at `expectedRevision`, raising it by one) and the unauthenticated `getWitnessHealth`; the shared rules `data.judgeWitnessChange` (within an epoch only the active changes its in-sync standby; an epoch rises by one and records no standby; a promotion names the recorded in-sync standby and is stated by it; the active raises its own epoch after a restore) and `data.judgeWitnessMemberEnrollment`, each documenting the order of its refusals; the 15-code refusal vocabulary `data.witnessRefusals`, with one `credential-invalid` for an unknown controller, a non-member site and a bad bearer, and `data.isWitnessRefusal`, the momentary `data.witnessMomentaryRefusals` (`witness-unavailable`, `outcome-unknown`), `data.IWitnessRefusalErrorData` (`{ code, retryable }`), `data.createWitnessRefusalErrorData` and `data.readWitnessRefusalErrorData`; exact validators for every body and answer, none of whose refusals carries a bearer or a pairing code; bounds in `data.witnessContract`. Spec: `test.witness`.
|
|
8
|
+
|
|
3
9
|
## 2026-11-12 - 32.80.0
|
|
4
10
|
|
|
5
11
|
### Features
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@serve.zone/interfaces',
|
|
6
|
-
version: '32.
|
|
6
|
+
version: '32.81.0',
|
|
7
7
|
description: 'Shared TypeScript interfaces and TypedRequest contracts for the serve.zone ecosystem.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFNBQVM7SUFDbEIsV0FBVyxFQUFFLHVGQUF1RjtDQUNyRyxDQUFBIn0=
|
package/dist_ts/data/index.d.ts
CHANGED
package/dist_ts/data/index.js
CHANGED
|
@@ -94,5 +94,6 @@ export * from './traffic.js';
|
|
|
94
94
|
export * from './user.js';
|
|
95
95
|
export * from './version.js';
|
|
96
96
|
export * from './webpush.js';
|
|
97
|
+
export * from './witness.js';
|
|
97
98
|
export * from './workloadreplicaidentity.js';
|
|
98
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
99
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9kYXRhL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxnQ0FBZ0MsQ0FBQztBQUMvQyxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsaUJBQWlCLENBQUM7QUFDaEMsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLDRCQUE0QixDQUFDO0FBQzNDLGNBQWMsOEJBQThCLENBQUM7QUFDN0MsY0FBYywwQkFBMEIsQ0FBQztBQUN6QyxjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMsaUJBQWlCLENBQUM7QUFDaEMsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMsNEJBQTRCLENBQUM7QUFDM0MsY0FBYywwQkFBMEIsQ0FBQztBQUN6QyxjQUFjLDBCQUEwQixDQUFDO0FBQ3pDLGNBQWMsZ0NBQWdDLENBQUM7QUFDL0MsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLFVBQVUsQ0FBQztBQUN6QixjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGFBQWEsQ0FBQztB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FBQztBQUNuQyxjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLFdBQVcsQ0FBQztBQUMxQixjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLDhCQUE4QixDQUFDIn0=
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export declare const witnessContract: Readonly<{
|
|
2
|
+
/** The path of the witness's TypedRequest endpoint below its `https` origin. */
|
|
3
|
+
readonly typedRequestPath: '/typedrequest';
|
|
4
|
+
/** The longest site origin: the bound of every `IControllerPeerSet` origin. */
|
|
5
|
+
readonly maximumOriginLength: 2048;
|
|
6
|
+
/** The active site and at most `controllerPeerSetContract.maximumShadowOrigins` shadows. */
|
|
7
|
+
readonly maximumMemberOrigins: number;
|
|
8
|
+
/** A member bearer is base64url, unpadded, of this many random bytes: 43 characters. */
|
|
9
|
+
readonly bearerRandomBytes: 32;
|
|
10
|
+
/** The longest pairing code: base64url characters. */
|
|
11
|
+
readonly maximumPairingCodeLength: 64;
|
|
12
|
+
}>;
|
|
13
|
+
/** What a change of a witness record decides: the epoch, its active site and that site's in-sync standby. */
|
|
14
|
+
export interface IWitnessState {
|
|
15
|
+
/** A positive safe integer: the controller epoch, the value `IControllerPeerSet.epoch` carries. */
|
|
16
|
+
epoch: number;
|
|
17
|
+
/** The site origin of the controller that is active in `epoch`. */
|
|
18
|
+
activeOrigin: string;
|
|
19
|
+
/**
|
|
20
|
+
* The member site the active records as a standby in sync with it, and so the only site a
|
|
21
|
+
* promotion may name; `null` once the active continues without a standby, and after every epoch
|
|
22
|
+
* raise.
|
|
23
|
+
*/
|
|
24
|
+
inSyncStandbyOrigin: string | null;
|
|
25
|
+
}
|
|
26
|
+
/** The witness record of one controller (`validateWitnessRecord`). */
|
|
27
|
+
export interface IWitnessRecord extends IWitnessState {
|
|
28
|
+
controllerId: string;
|
|
29
|
+
/**
|
|
30
|
+
* A positive safe integer, 1 when the record is paired and raised by one with every accepted
|
|
31
|
+
* change, an enrollment included. A change names the revision it read (`expectedRevision`).
|
|
32
|
+
*/
|
|
33
|
+
revision: number;
|
|
34
|
+
/**
|
|
35
|
+
* Every member site, as a canonical list: strictly increasing (`compareWireTokens`, so each once),
|
|
36
|
+
* 1 to `witnessContract.maximumMemberOrigins` origins. The active and the in-sync standby are
|
|
37
|
+
* members. Only a member authenticates, and only `enrollWitnessMember` adds one.
|
|
38
|
+
*/
|
|
39
|
+
memberOrigins: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A member site's credential: the member the caller is and the bearer that site created for itself.
|
|
43
|
+
* Enrolling a member again replaces its bearer hash; the previous bearer stops authenticating.
|
|
44
|
+
*/
|
|
45
|
+
export interface IWitnessMemberCredential {
|
|
46
|
+
/** The member's site origin. */
|
|
47
|
+
origin: string;
|
|
48
|
+
/**
|
|
49
|
+
* Base64url, unpadded, of `witnessContract.bearerRandomBytes` random bytes: exactly 43 characters,
|
|
50
|
+
* the canonical encoding. Kept in the site's own config or secret store, never in the replicated
|
|
51
|
+
* controller database; never logged, never part of a refusal.
|
|
52
|
+
*/
|
|
53
|
+
bearer: string;
|
|
54
|
+
}
|
|
55
|
+
/** The body of `pairWitnessController` (`validatePairWitnessControllerRequest`). */
|
|
56
|
+
export interface IPairWitnessControllerRequest {
|
|
57
|
+
/**
|
|
58
|
+
* The one-time code the witness's operator made on the witness host for `controllerId`:
|
|
59
|
+
* 1 to `witnessContract.maximumPairingCodeLength` base64url characters.
|
|
60
|
+
*/
|
|
61
|
+
pairingCode: string;
|
|
62
|
+
controllerId: string;
|
|
63
|
+
/** The controller's current epoch. */
|
|
64
|
+
epoch: number;
|
|
65
|
+
/** The caller's own site origin; it becomes the active site and the only member. */
|
|
66
|
+
origin: string;
|
|
67
|
+
/**
|
|
68
|
+
* The SHA-256 of the UTF-8 of the bearer the caller created for itself: 64 lowercase hex
|
|
69
|
+
* characters. The bearer itself never leaves the caller's site.
|
|
70
|
+
*/
|
|
71
|
+
bearerSha256: string;
|
|
72
|
+
}
|
|
73
|
+
/** The body of `enrollWitnessMember` (`validateEnrollWitnessMemberRequest`). */
|
|
74
|
+
export interface IEnrollWitnessMemberRequest {
|
|
75
|
+
controllerId: string;
|
|
76
|
+
/** The active's own credential. */
|
|
77
|
+
member: IWitnessMemberCredential;
|
|
78
|
+
/** The record revision the active read; the enrollment is a compare-and-set on it. */
|
|
79
|
+
expectedRevision: number;
|
|
80
|
+
/**
|
|
81
|
+
* The site to enroll: a new member, or an existing one whose bearer hash is replaced. Never the
|
|
82
|
+
* caller, never the recorded in-sync standby (`judgeWitnessMemberEnrollment`).
|
|
83
|
+
*/
|
|
84
|
+
origin: string;
|
|
85
|
+
/**
|
|
86
|
+
* The SHA-256 of the UTF-8 of the bearer that site created for itself: 64 lowercase hex
|
|
87
|
+
* characters. The site hands the active only this hash, never the bearer.
|
|
88
|
+
*/
|
|
89
|
+
bearerSha256: string;
|
|
90
|
+
}
|
|
91
|
+
/** The body of `getWitnessRecord` (`validateGetWitnessRecordRequest`). */
|
|
92
|
+
export interface IGetWitnessRecordRequest {
|
|
93
|
+
controllerId: string;
|
|
94
|
+
member: IWitnessMemberCredential;
|
|
95
|
+
}
|
|
96
|
+
/** The body of `compareAndSetWitnessRecord` (`validateCompareAndSetWitnessRecordRequest`). */
|
|
97
|
+
export interface ICompareAndSetWitnessRecordRequest {
|
|
98
|
+
controllerId: string;
|
|
99
|
+
member: IWitnessMemberCredential;
|
|
100
|
+
/** The record revision the caller read; any other stored revision refuses the change. */
|
|
101
|
+
expectedRevision: number;
|
|
102
|
+
/** The state the record holds after the change (`judgeWitnessChange`). */
|
|
103
|
+
next: IWitnessState;
|
|
104
|
+
}
|
|
105
|
+
/** What the witness answers `getWitnessHealth` (`validateWitnessHealth`); it names no controller. */
|
|
106
|
+
export interface IWitnessHealth {
|
|
107
|
+
/** True while the witness can read and write its records. */
|
|
108
|
+
ready: boolean;
|
|
109
|
+
/** The witness release the site runs (`data.isReleaseVersion`). */
|
|
110
|
+
witnessVersion: string;
|
|
111
|
+
/** The release of this package the witness speaks (`data.isReleaseVersion`). */
|
|
112
|
+
interfacesVersion: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Every reason the witness answers instead of a request, as a `TypedResponseError` whose `errorData`
|
|
116
|
+
* is `IWitnessRefusalErrorData` and whose text carries the detail, never a bearer or a pairing code.
|
|
117
|
+
*
|
|
118
|
+
* This list is the closed vocabulary; its order is not the order the witness checks a request in.
|
|
119
|
+
* That order is the gate order this module's header states, then the judge's own.
|
|
120
|
+
*
|
|
121
|
+
* Only `witnessMomentaryRefusals` are momentary. A change whose answer does not arrive at all, like
|
|
122
|
+
* one refused `outcome-unknown`, may have been stored: the caller reads the record before it acts on
|
|
123
|
+
* the change or sends another.
|
|
124
|
+
*/
|
|
125
|
+
export declare const witnessRefusals: readonly ["request-invalid", "pairing-code-unknown", "pairing-code-expired", "pairing-code-used", "controller-mismatch", "controller-paired", "credential-invalid", "revision-stale", "site-not-active", "epoch-invalid", "standby-not-in-sync", "transition-invalid", "member-limit", "witness-unavailable", "outcome-unknown"];
|
|
126
|
+
/** One of the reasons the witness answers instead of a request. */
|
|
127
|
+
export type TWitnessRefusal = typeof witnessRefusals[number];
|
|
128
|
+
/** The refusals that describe the witness's own state rather than a judgement of the request. */
|
|
129
|
+
export declare const witnessMomentaryRefusals: readonly ["witness-unavailable", "outcome-unknown"];
|
|
130
|
+
/** One of the momentary witness refusals. */
|
|
131
|
+
export type TWitnessMomentaryRefusal = typeof witnessMomentaryRefusals[number];
|
|
132
|
+
/** A witness refusal as `TypedResponseError.errorData`; the error text carries its detail. */
|
|
133
|
+
export interface IWitnessRefusalErrorData {
|
|
134
|
+
code: TWitnessRefusal;
|
|
135
|
+
/**
|
|
136
|
+
* True exactly for `witnessMomentaryRefusals`: the same request may be sent again later. Every
|
|
137
|
+
* other refusal answers the same request again until the state the code names has changed.
|
|
138
|
+
*/
|
|
139
|
+
retryable: boolean;
|
|
140
|
+
}
|
|
141
|
+
/** True for one of `witnessRefusals`. */
|
|
142
|
+
export declare const isWitnessRefusal: (valueArg: unknown) => valueArg is TWitnessRefusal;
|
|
143
|
+
/** True for one of `witnessMomentaryRefusals`. */
|
|
144
|
+
export declare const isWitnessMomentaryRefusal: (valueArg: unknown) => valueArg is TWitnessMomentaryRefusal;
|
|
145
|
+
/** The `errorData` the witness answers a refusal with. */
|
|
146
|
+
export declare const createWitnessRefusalErrorData: (codeArg: TWitnessRefusal) => IWitnessRefusalErrorData;
|
|
147
|
+
/**
|
|
148
|
+
* The witness refusal an error payload states, or `null` when it is not exactly one: a payload with
|
|
149
|
+
* another member, an unknown code or a `retryable` that disagrees with the code reads as no answer
|
|
150
|
+
* from the witness, never as a verdict.
|
|
151
|
+
*/
|
|
152
|
+
export declare const readWitnessRefusalErrorData: (valueArg: unknown) => IWitnessRefusalErrorData | null;
|
|
153
|
+
/**
|
|
154
|
+
* Whether a member may change a witness record to `nextArg`: `null` when the change is admissible,
|
|
155
|
+
* otherwise the refusal the witness answers. The witness applies it to the stored record before its
|
|
156
|
+
* compare-and-set, and a controller asks it before it sends one.
|
|
157
|
+
*
|
|
158
|
+
* It judges the decision only, on values that passed `validateWitnessRecord` and
|
|
159
|
+
* `validateWitnessState`. That the caller authenticated as `callerOriginArg` is the witness's to
|
|
160
|
+
* check, and whether `recordArg` is still the stored revision is the compare-and-set's
|
|
161
|
+
* (`revision-stale`); a caller that is no member is refused `credential-invalid`, as the
|
|
162
|
+
* authentication would have.
|
|
163
|
+
*
|
|
164
|
+
* - Within an epoch only the active changes the record, and only its in-sync standby.
|
|
165
|
+
* - An epoch rises by exactly one, and every epoch raise records no in-sync standby: no site has
|
|
166
|
+
* followed an epoch nobody has written in yet.
|
|
167
|
+
* - An epoch raise that keeps the active (a database restore, ruling 30) is the active's own.
|
|
168
|
+
* - A promotion names as active the site the record holds as its in-sync standby, and is stated by
|
|
169
|
+
* that site.
|
|
170
|
+
*
|
|
171
|
+
* An admissible change that leaves the state as it was is still a change: it raises the revision.
|
|
172
|
+
*
|
|
173
|
+
* It answers the first of these that applies, in this order: `credential-invalid` for a caller that
|
|
174
|
+
* is no member; `transition-invalid` for a next state naming a site that is no member, or the active
|
|
175
|
+
* as its own standby; within the epoch `site-not-active` for another caller, then
|
|
176
|
+
* `transition-invalid` for a changed active; `epoch-invalid` for any epoch but this one or the next;
|
|
177
|
+
* `transition-invalid` for a raise that records a standby; for a raise keeping the active
|
|
178
|
+
* `site-not-active` for another caller; `standby-not-in-sync` for a promotion of another site than
|
|
179
|
+
* the recorded in-sync standby; `transition-invalid` for a promotion stated by another site.
|
|
180
|
+
*/
|
|
181
|
+
export declare const judgeWitnessChange: (recordArg: Readonly<IWitnessRecord>, callerOriginArg: string, nextArg: Readonly<IWitnessState>) => TWitnessRefusal | null;
|
|
182
|
+
/**
|
|
183
|
+
* Whether a member may enroll `originArg` on a witness record: `null` when it may, otherwise the
|
|
184
|
+
* refusal the witness answers. Only the active enrolls, never itself (the request validator refuses
|
|
185
|
+
* that), never the recorded in-sync standby, and a new member only while the record has room for
|
|
186
|
+
* one. Enrolling an existing member replaces its bearer hash and leaves the state as it is; either
|
|
187
|
+
* way the revision rises.
|
|
188
|
+
*
|
|
189
|
+
* The in-sync standby is refused `transition-invalid`: replacing its bearer hash would let the
|
|
190
|
+
* active lock the one site that may promote itself out of the promotion. The active drops that
|
|
191
|
+
* standby by compare-and-set first (`judgeWitnessChange`), then enrolls it again.
|
|
192
|
+
*
|
|
193
|
+
* It answers the first of these that applies, in this order: `credential-invalid` for a caller that
|
|
194
|
+
* is no member, `site-not-active` for a caller that is not the active, `request-invalid` for the
|
|
195
|
+
* caller's own origin, `transition-invalid` for the in-sync standby, `member-limit` for a new member
|
|
196
|
+
* of a full record.
|
|
197
|
+
*/
|
|
198
|
+
export declare const judgeWitnessMemberEnrollment: (recordArg: Readonly<IWitnessRecord>, callerOriginArg: string, originArg: string) => TWitnessRefusal | null;
|
|
199
|
+
/**
|
|
200
|
+
* Validates one witness state, the decision a change sets, and names every reason it is refused.
|
|
201
|
+
* Shape only: whether the record admits the change is `judgeWitnessChange`'s to decide.
|
|
202
|
+
*/
|
|
203
|
+
export declare const validateWitnessState: (valueArg: unknown, pathArg?: string) => string[];
|
|
204
|
+
/** Validates one witness record and names every reason it is refused. */
|
|
205
|
+
export declare const validateWitnessRecord: (valueArg: unknown, pathArg?: string) => string[];
|
|
206
|
+
/** Validates one member credential; no refusal carries the bearer. */
|
|
207
|
+
export declare const validateWitnessMemberCredential: (valueArg: unknown, pathArg?: string) => string[];
|
|
208
|
+
/** Validates a `pairWitnessController` body; no refusal carries the pairing code. */
|
|
209
|
+
export declare const validatePairWitnessControllerRequest: (valueArg: unknown, pathArg?: string) => string[];
|
|
210
|
+
/** Validates an `enrollWitnessMember` body; no refusal carries the bearer. */
|
|
211
|
+
export declare const validateEnrollWitnessMemberRequest: (valueArg: unknown, pathArg?: string) => string[];
|
|
212
|
+
/** Validates a `getWitnessRecord` body; no refusal carries the bearer. */
|
|
213
|
+
export declare const validateGetWitnessRecordRequest: (valueArg: unknown, pathArg?: string) => string[];
|
|
214
|
+
/** Validates a `compareAndSetWitnessRecord` body; no refusal carries the bearer. */
|
|
215
|
+
export declare const validateCompareAndSetWitnessRecordRequest: (valueArg: unknown, pathArg?: string) => string[];
|
|
216
|
+
/** Validates the witness's `getWitnessHealth` answer. */
|
|
217
|
+
export declare const validateWitnessHealth: (valueArg: unknown, pathArg?: string) => string[];
|