@sentropic/cluster-mesh 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hono/session-router.d.ts +3 -1
- package/dist/hono/session-router.d.ts.map +1 -1
- package/dist/hono/session-router.js +111 -31
- package/dist/hono/session-router.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/messaging/ack-operation.d.ts +16 -0
- package/dist/messaging/ack-operation.d.ts.map +1 -0
- package/dist/messaging/ack-operation.js +119 -0
- package/dist/messaging/ack-operation.js.map +1 -0
- package/dist/messaging/bounded-local-messaging-store.d.ts +27 -0
- package/dist/messaging/bounded-local-messaging-store.d.ts.map +1 -0
- package/dist/messaging/bounded-local-messaging-store.js +49 -0
- package/dist/messaging/bounded-local-messaging-store.js.map +1 -0
- package/dist/messaging/bounded-local-options.d.ts +14 -0
- package/dist/messaging/bounded-local-options.d.ts.map +1 -0
- package/dist/messaging/bounded-local-options.js +2 -0
- package/dist/messaging/bounded-local-options.js.map +1 -0
- package/dist/messaging/canonical-json.d.ts +9 -0
- package/dist/messaging/canonical-json.d.ts.map +1 -0
- package/dist/messaging/canonical-json.js +31 -0
- package/dist/messaging/canonical-json.js.map +1 -0
- package/dist/messaging/delivery-actuation-handoff.d.ts +20 -0
- package/dist/messaging/delivery-actuation-handoff.d.ts.map +1 -0
- package/dist/messaging/delivery-actuation-handoff.js +107 -0
- package/dist/messaging/delivery-actuation-handoff.js.map +1 -0
- package/dist/messaging/delivery-contracts.d.ts +89 -0
- package/dist/messaging/delivery-contracts.d.ts.map +1 -0
- package/dist/messaging/delivery-contracts.js +2 -0
- package/dist/messaging/delivery-contracts.js.map +1 -0
- package/dist/messaging/delivery-operation.d.ts +29 -0
- package/dist/messaging/delivery-operation.d.ts.map +1 -0
- package/dist/messaging/delivery-operation.js +111 -0
- package/dist/messaging/delivery-operation.js.map +1 -0
- package/dist/messaging/drain-fence-operation.d.ts +12 -0
- package/dist/messaging/drain-fence-operation.d.ts.map +1 -0
- package/dist/messaging/drain-fence-operation.js +79 -0
- package/dist/messaging/drain-fence-operation.js.map +1 -0
- package/dist/messaging/handoff-contracts.d.ts +39 -0
- package/dist/messaging/handoff-contracts.d.ts.map +1 -0
- package/dist/messaging/handoff-contracts.js +2 -0
- package/dist/messaging/handoff-contracts.js.map +1 -0
- package/dist/messaging/index.d.ts +10 -0
- package/dist/messaging/index.d.ts.map +1 -0
- package/dist/messaging/index.js +10 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/messaging/local-model.d.ts +60 -0
- package/dist/messaging/local-model.d.ts.map +1 -0
- package/dist/messaging/local-model.js +4 -0
- package/dist/messaging/local-model.js.map +1 -0
- package/dist/messaging/local-state.d.ts +27 -0
- package/dist/messaging/local-state.d.ts.map +1 -0
- package/dist/messaging/local-state.js +130 -0
- package/dist/messaging/local-state.js.map +1 -0
- package/dist/messaging/local-support.d.ts +16 -0
- package/dist/messaging/local-support.d.ts.map +1 -0
- package/dist/messaging/local-support.js +54 -0
- package/dist/messaging/local-support.js.map +1 -0
- package/dist/messaging/message-client.d.ts +63 -0
- package/dist/messaging/message-client.d.ts.map +1 -0
- package/dist/messaging/message-client.js +112 -0
- package/dist/messaging/message-client.js.map +1 -0
- package/dist/messaging/message-contracts.d.ts +68 -0
- package/dist/messaging/message-contracts.d.ts.map +1 -0
- package/dist/messaging/message-contracts.js +2 -0
- package/dist/messaging/message-contracts.js.map +1 -0
- package/dist/messaging/native-batch-validation.d.ts +7 -0
- package/dist/messaging/native-batch-validation.d.ts.map +1 -0
- package/dist/messaging/native-batch-validation.js +45 -0
- package/dist/messaging/native-batch-validation.js.map +1 -0
- package/dist/messaging/native-drain-contracts.d.ts +78 -0
- package/dist/messaging/native-drain-contracts.d.ts.map +1 -0
- package/dist/messaging/native-drain-contracts.js +2 -0
- package/dist/messaging/native-drain-contracts.js.map +1 -0
- package/dist/messaging/native-import-mutation.d.ts +11 -0
- package/dist/messaging/native-import-mutation.d.ts.map +1 -0
- package/dist/messaging/native-import-mutation.js +84 -0
- package/dist/messaging/native-import-mutation.js.map +1 -0
- package/dist/messaging/native-import-operation.d.ts +12 -0
- package/dist/messaging/native-import-operation.d.ts.map +1 -0
- package/dist/messaging/native-import-operation.js +68 -0
- package/dist/messaging/native-import-operation.js.map +1 -0
- package/dist/messaging/product-authorization.d.ts +36 -0
- package/dist/messaging/product-authorization.d.ts.map +1 -0
- package/dist/messaging/product-authorization.js +2 -0
- package/dist/messaging/product-authorization.js.map +1 -0
- package/dist/messaging/put-operation.d.ts +26 -0
- package/dist/messaging/put-operation.d.ts.map +1 -0
- package/dist/messaging/put-operation.js +133 -0
- package/dist/messaging/put-operation.js.map +1 -0
- package/dist/messaging/subscription-operation.d.ts +13 -0
- package/dist/messaging/subscription-operation.d.ts.map +1 -0
- package/dist/messaging/subscription-operation.js +96 -0
- package/dist/messaging/subscription-operation.js.map +1 -0
- package/dist/messaging/validation.d.ts +14 -0
- package/dist/messaging/validation.d.ts.map +1 -0
- package/dist/messaging/validation.js +104 -0
- package/dist/messaging/validation.js.map +1 -0
- package/dist/runtime/bounded-local-custody-source.d.ts +28 -0
- package/dist/runtime/bounded-local-custody-source.d.ts.map +1 -0
- package/dist/runtime/bounded-local-custody-source.js +93 -0
- package/dist/runtime/bounded-local-custody-source.js.map +1 -0
- package/dist/runtime/custody-crypto.d.ts +13 -0
- package/dist/runtime/custody-crypto.d.ts.map +1 -0
- package/dist/runtime/custody-crypto.js +49 -0
- package/dist/runtime/custody-crypto.js.map +1 -0
- package/dist/runtime/custody-invocation-verifier.d.ts +11 -0
- package/dist/runtime/custody-invocation-verifier.d.ts.map +1 -0
- package/dist/runtime/custody-invocation-verifier.js +53 -0
- package/dist/runtime/custody-invocation-verifier.js.map +1 -0
- package/dist/runtime/custody-issuance.d.ts +14 -0
- package/dist/runtime/custody-issuance.d.ts.map +1 -0
- package/dist/runtime/custody-issuance.js +65 -0
- package/dist/runtime/custody-issuance.js.map +1 -0
- package/dist/runtime/custody-state.d.ts +26 -0
- package/dist/runtime/custody-state.d.ts.map +1 -0
- package/dist/runtime/custody-state.js +44 -0
- package/dist/runtime/custody-state.js.map +1 -0
- package/dist/runtime/custody-token-validation.d.ts +17 -0
- package/dist/runtime/custody-token-validation.d.ts.map +1 -0
- package/dist/runtime/custody-token-validation.js +52 -0
- package/dist/runtime/custody-token-validation.js.map +1 -0
- package/dist/runtime/custody-types.d.ts +110 -0
- package/dist/runtime/custody-types.d.ts.map +1 -0
- package/dist/runtime/custody-types.js +2 -0
- package/dist/runtime/custody-types.js.map +1 -0
- package/dist/runtime/custody-validation.d.ts +16 -0
- package/dist/runtime/custody-validation.d.ts.map +1 -0
- package/dist/runtime/custody-validation.js +66 -0
- package/dist/runtime/custody-validation.js.map +1 -0
- package/dist/runtime/custody-wire.d.ts +7 -0
- package/dist/runtime/custody-wire.d.ts.map +1 -0
- package/dist/runtime/custody-wire.js +104 -0
- package/dist/runtime/custody-wire.js.map +1 -0
- package/dist/runtime/registration.d.ts +48 -6
- package/dist/runtime/registration.d.ts.map +1 -1
- package/dist/runtime/registration.js +61 -2
- package/dist/runtime/registration.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CustodyRevocationSelector } from './custody-types.js';
|
|
2
|
+
export type CustodyStateStatus = 'available' | 'revoked' | 'replayed';
|
|
3
|
+
export interface CustodyStateInspection {
|
|
4
|
+
readonly selectors: readonly CustodyRevocationSelector[];
|
|
5
|
+
readonly tokenId?: string;
|
|
6
|
+
readonly invocationKey?: string;
|
|
7
|
+
readonly now: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CustodyStateConsumption extends CustodyStateInspection {
|
|
10
|
+
readonly tokenId: string;
|
|
11
|
+
readonly invocationKey: string;
|
|
12
|
+
readonly expiresAt: number;
|
|
13
|
+
readonly clockSkewMs: number;
|
|
14
|
+
}
|
|
15
|
+
export interface CustodyStateStorePort {
|
|
16
|
+
revoke(selector: CustodyRevocationSelector): Promise<void>;
|
|
17
|
+
inspect(input: CustodyStateInspection): Promise<CustodyStateStatus>;
|
|
18
|
+
consume(input: CustodyStateConsumption): Promise<CustodyStateStatus>;
|
|
19
|
+
}
|
|
20
|
+
export declare class InMemoryCustodyStateStore implements CustodyStateStorePort {
|
|
21
|
+
#private;
|
|
22
|
+
revoke(selector: CustodyRevocationSelector): Promise<void>;
|
|
23
|
+
inspect(input: CustodyStateInspection): Promise<CustodyStateStatus>;
|
|
24
|
+
consume(input: CustodyStateConsumption): Promise<CustodyStateStatus>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=custody-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-state.d.ts","sourceRoot":"","sources":["../../src/runtime/custody-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAGpE,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AAEtE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACzD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpE,OAAO,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACtE;AAKD,qBAAa,yBAA0B,YAAW,qBAAqB;;IAK/D,MAAM,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D,OAAO,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAYnE,OAAO,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAsB3E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { canonicalCustodyJson } from './custody-wire.js';
|
|
2
|
+
const selectorKey = (selector) => canonicalCustodyJson(selector);
|
|
3
|
+
export class InMemoryCustodyStateStore {
|
|
4
|
+
#revoked = new Set();
|
|
5
|
+
#tokens = new Map();
|
|
6
|
+
#invocations = new Map();
|
|
7
|
+
async revoke(selector) {
|
|
8
|
+
this.#revoked.add(selectorKey(selector));
|
|
9
|
+
}
|
|
10
|
+
async inspect(input) {
|
|
11
|
+
this.#prune(input.now);
|
|
12
|
+
if (input.selectors.some((selector) => this.#revoked.has(selectorKey(selector)))) {
|
|
13
|
+
return 'revoked';
|
|
14
|
+
}
|
|
15
|
+
if ((input.tokenId !== undefined && this.#tokens.has(input.tokenId))
|
|
16
|
+
|| (input.invocationKey !== undefined && this.#invocations.has(input.invocationKey)))
|
|
17
|
+
return 'replayed';
|
|
18
|
+
return 'available';
|
|
19
|
+
}
|
|
20
|
+
async consume(input) {
|
|
21
|
+
this.#prune(input.now);
|
|
22
|
+
if (input.selectors.some((selector) => this.#revoked.has(selectorKey(selector)))) {
|
|
23
|
+
return 'revoked';
|
|
24
|
+
}
|
|
25
|
+
if (this.#tokens.has(input.tokenId) || this.#invocations.has(input.invocationKey)) {
|
|
26
|
+
return 'replayed';
|
|
27
|
+
}
|
|
28
|
+
const replayFenceExpiresAt = input.expiresAt + input.clockSkewMs;
|
|
29
|
+
this.#tokens.set(input.tokenId, replayFenceExpiresAt);
|
|
30
|
+
this.#invocations.set(input.invocationKey, replayFenceExpiresAt);
|
|
31
|
+
return 'available';
|
|
32
|
+
}
|
|
33
|
+
#prune(now) {
|
|
34
|
+
for (const [key, replayFenceExpiresAt] of this.#tokens) {
|
|
35
|
+
if (replayFenceExpiresAt < now)
|
|
36
|
+
this.#tokens.delete(key);
|
|
37
|
+
}
|
|
38
|
+
for (const [key, replayFenceExpiresAt] of this.#invocations) {
|
|
39
|
+
if (replayFenceExpiresAt < now)
|
|
40
|
+
this.#invocations.delete(key);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=custody-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-state.js","sourceRoot":"","sources":["../../src/runtime/custody-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAwBzD,MAAM,WAAW,GAAG,CAAC,QAAmC,EAAU,EAAE,CAClE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;AAEjC,MAAM,OAAO,yBAAyB;IAC3B,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAC7B,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IACpC,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;IAElD,KAAK,CAAC,MAAM,CAAC,QAAmC;QAC9C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAA6B;QACzC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,C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AAW;QAChB,KAAK,MAAM,CAAC,GAAG,EAAE,oBAAoB,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvD,IAAI,oBAAoB,GAAG,GAAG;gBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3D,CAAC;QACD,KAAK,MAAM,CAAC,GAAG,EAAE,oBAAoB,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC5D,IAAI,oBAAoB,GAAG,GAAG;gBAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EphemeralCustodyKey } from './custody-crypto.js';
|
|
2
|
+
import type { CustodyStateStorePort } from './custody-state.js';
|
|
3
|
+
import type { CustodyBinding, CustodyTokenDecision, CustodyTokenExpectation, SignedCustodyToken } from './custody-types.js';
|
|
4
|
+
import type { RegistrationLookupPort } from './registration.js';
|
|
5
|
+
export declare function validateCustodyToken(input: {
|
|
6
|
+
readonly token: SignedCustodyToken;
|
|
7
|
+
readonly expected: CustodyTokenExpectation;
|
|
8
|
+
readonly registrations: RegistrationLookupPort;
|
|
9
|
+
readonly bindings: ReadonlyMap<string, CustodyBinding>;
|
|
10
|
+
readonly state: CustodyStateStorePort;
|
|
11
|
+
readonly key: EphemeralCustodyKey;
|
|
12
|
+
readonly maximumTtlMs: number;
|
|
13
|
+
readonly clockSkewMs: number;
|
|
14
|
+
readonly now: number;
|
|
15
|
+
readonly inspectState: boolean;
|
|
16
|
+
}): Promise<CustodyTokenDecision>;
|
|
17
|
+
//# sourceMappingURL=custody-token-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-token-validation.d.ts","sourceRoot":"","sources":["../../src/runtime/custody-token-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;IAC3C,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC;IAC/C,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvD,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IACtC,QAAQ,CAAC,GAAG,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAyChC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { verifyCustodySignature } from './custody-crypto.js';
|
|
2
|
+
import { custodyInvocationKey, custodySelectors, validateCurrentBinding, validateExpectedClaims, } from './custody-validation.js';
|
|
3
|
+
import { custodySignaturePayload, isSignedCustodyToken } from './custody-wire.js';
|
|
4
|
+
export async function validateCustodyToken(input) {
|
|
5
|
+
const { token } = input;
|
|
6
|
+
if (!isSignedCustodyToken(token))
|
|
7
|
+
return { ok: false, reason: 'untrusted' };
|
|
8
|
+
let trust;
|
|
9
|
+
try {
|
|
10
|
+
trust = await input.key.trustRoot.resolve(token.issuer);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return { ok: false, reason: 'unavailable' };
|
|
14
|
+
}
|
|
15
|
+
if (!trust || !verifyCustodySignature({
|
|
16
|
+
publicKeyBase64Url: trust.publicKeyBase64Url,
|
|
17
|
+
payload: custodySignaturePayload(token),
|
|
18
|
+
signatureBase64Url: token.evidence.signatureBase64Url,
|
|
19
|
+
}))
|
|
20
|
+
return { ok: false, reason: 'untrusted' };
|
|
21
|
+
const claimFailure = validateExpectedClaims(token, input.expected, {
|
|
22
|
+
now: input.now, maximumTtlMs: input.maximumTtlMs, clockSkewMs: input.clockSkewMs,
|
|
23
|
+
});
|
|
24
|
+
if (claimFailure)
|
|
25
|
+
return { ok: false, reason: claimFailure };
|
|
26
|
+
let registration;
|
|
27
|
+
try {
|
|
28
|
+
registration = await input.registrations.find(token.registrationId);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return { ok: false, reason: 'unavailable' };
|
|
32
|
+
}
|
|
33
|
+
const bindingFailure = validateCurrentBinding(token, registration, input.bindings.get(token.registrationId), input.now);
|
|
34
|
+
if (bindingFailure)
|
|
35
|
+
return { ok: false, reason: bindingFailure };
|
|
36
|
+
if (input.inspectState) {
|
|
37
|
+
try {
|
|
38
|
+
const status = await input.state.inspect({
|
|
39
|
+
selectors: custodySelectors(token), tokenId: token.tokenId,
|
|
40
|
+
invocationKey: custodyInvocationKey(token.registrationId, token.invocationId),
|
|
41
|
+
now: input.now,
|
|
42
|
+
});
|
|
43
|
+
if (status !== 'available')
|
|
44
|
+
return { ok: false, reason: status };
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return { ok: false, reason: 'unavailable' };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return { ok: true, token };
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=custody-token-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-token-validation.js","sourceRoot":"","sources":["../../src/runtime/custody-token-validation.ts"],"names":[],"mappings":"AACA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ationContext, VerifiedInvocationContextRequest } from '@sentropic/contracts';
|
|
2
|
+
export type CustodyAction = 'drive' | 'wake' | 'relaunch';
|
|
3
|
+
export interface CustodyIssueRequest {
|
|
4
|
+
readonly registrationId: string;
|
|
5
|
+
readonly action: CustodyAction;
|
|
6
|
+
readonly holderPrincipalId: string;
|
|
7
|
+
readonly invocationId: string;
|
|
8
|
+
readonly requestedTtlSeconds?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface CustodyTokenIssuer {
|
|
11
|
+
readonly issuerId: string;
|
|
12
|
+
readonly keyId: string;
|
|
13
|
+
readonly algorithm: 'EdDSA';
|
|
14
|
+
readonly curve: 'Ed25519';
|
|
15
|
+
}
|
|
16
|
+
export interface SignedCustodyToken {
|
|
17
|
+
readonly kind: 'signed-custody-token';
|
|
18
|
+
readonly version: 'sentropic.cluster-mesh.custody/v1';
|
|
19
|
+
readonly tokenId: string;
|
|
20
|
+
readonly issuer: CustodyTokenIssuer;
|
|
21
|
+
readonly audience: string;
|
|
22
|
+
readonly registrationId: string;
|
|
23
|
+
readonly action: CustodyAction;
|
|
24
|
+
readonly holderPrincipalId: string;
|
|
25
|
+
readonly epoch: number;
|
|
26
|
+
readonly custodyId: string;
|
|
27
|
+
readonly invocationId: string;
|
|
28
|
+
readonly issuedAt: string;
|
|
29
|
+
readonly expiresAt: string;
|
|
30
|
+
readonly evidence: {
|
|
31
|
+
readonly kind: 'detached-signature';
|
|
32
|
+
readonly canonicalization: 'sentropic-json-v1';
|
|
33
|
+
readonly signatureBase64Url: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export type CustodyRevocationSelector = {
|
|
37
|
+
readonly kind: 'token';
|
|
38
|
+
readonly tokenId: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: 'binding';
|
|
41
|
+
readonly registrationId: string;
|
|
42
|
+
readonly custodyId: string;
|
|
43
|
+
readonly holderPrincipalId: string;
|
|
44
|
+
readonly epoch: number;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: 'holder';
|
|
47
|
+
readonly holderPrincipalId: string;
|
|
48
|
+
};
|
|
49
|
+
export interface CustodyRevocationReceipt {
|
|
50
|
+
readonly issuerId: string;
|
|
51
|
+
readonly selector: CustodyRevocationSelector;
|
|
52
|
+
readonly reason: string;
|
|
53
|
+
readonly revokedAt: string;
|
|
54
|
+
}
|
|
55
|
+
export interface CustodySource {
|
|
56
|
+
readonly issuerId: string;
|
|
57
|
+
issue(input: CustodyIssueRequest): Promise<SignedCustodyToken | null>;
|
|
58
|
+
revoke(input: {
|
|
59
|
+
readonly selector: CustodyRevocationSelector;
|
|
60
|
+
readonly reason: string;
|
|
61
|
+
}): Promise<CustodyRevocationReceipt>;
|
|
62
|
+
}
|
|
63
|
+
export interface CustodyTokenExpectation {
|
|
64
|
+
readonly audience: string;
|
|
65
|
+
readonly registrationId: string;
|
|
66
|
+
readonly action: CustodyAction;
|
|
67
|
+
readonly holderPrincipalId: string;
|
|
68
|
+
readonly epoch: number;
|
|
69
|
+
readonly custodyId: string;
|
|
70
|
+
readonly invocationId: string;
|
|
71
|
+
}
|
|
72
|
+
export type CustodyTokenDecision = {
|
|
73
|
+
readonly ok: true;
|
|
74
|
+
readonly token: SignedCustodyToken;
|
|
75
|
+
} | {
|
|
76
|
+
readonly ok: false;
|
|
77
|
+
readonly reason: 'untrusted' | 'unbound' | 'stale' | 'revoked' | 'replayed' | 'unavailable';
|
|
78
|
+
};
|
|
79
|
+
export interface CustodyTokenVerifierPort {
|
|
80
|
+
verify(token: SignedCustodyToken, expected: CustodyTokenExpectation): Promise<CustodyTokenDecision>;
|
|
81
|
+
consume(token: SignedCustodyToken, expected: CustodyTokenExpectation): Promise<CustodyTokenDecision>;
|
|
82
|
+
}
|
|
83
|
+
export interface SourceVerifiedCustodyRef extends VerifiedCustodyRef {
|
|
84
|
+
readonly sourceToken: SignedCustodyToken;
|
|
85
|
+
}
|
|
86
|
+
export type CustodyVerifiedInvocationContext = VerifiedInvocationContext & {
|
|
87
|
+
readonly custody: SourceVerifiedCustodyRef;
|
|
88
|
+
};
|
|
89
|
+
export interface CustodyInvocationContextRequest extends VerifiedInvocationContextRequest {
|
|
90
|
+
readonly custodyToken?: string;
|
|
91
|
+
readonly custodyAction?: CustodyAction;
|
|
92
|
+
}
|
|
93
|
+
export interface CustodyBinding {
|
|
94
|
+
readonly registrationId: string;
|
|
95
|
+
readonly custodyId: string;
|
|
96
|
+
readonly holderPrincipalId: string;
|
|
97
|
+
readonly epoch: number;
|
|
98
|
+
readonly meshDomain: string;
|
|
99
|
+
readonly status: 'active' | 'revoked';
|
|
100
|
+
readonly expiresAt: string;
|
|
101
|
+
}
|
|
102
|
+
export interface CustodyTrustRoot {
|
|
103
|
+
resolve(issuer: CustodyTokenIssuer): Promise<{
|
|
104
|
+
readonly publicKeyBase64Url: string;
|
|
105
|
+
} | null>;
|
|
106
|
+
}
|
|
107
|
+
export interface CustodySigningPort {
|
|
108
|
+
signCanonical(payload: Uint8Array): Promise<string>;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=custody-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-types.d.ts","sourceRoot":"","sources":["../../src/runtime/custody-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,gCAAgC,EACjC,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACvC;AAED,MAAM,WAAW,kBAAkB;IACjC,QA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,IAAI,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-types.js","sourceRoot":"","sources":["../../src/runtime/custody-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ClusterMeshRegistration } from './registration.js';
|
|
2
|
+
import type { CustodyBinding, CustodyRevocationSelector, CustodyTokenDecision, CustodyTokenExpectation, SignedCustodyToken } from './custody-types.js';
|
|
3
|
+
export type CustodyFailureReason = Extract<CustodyTokenDecision, {
|
|
4
|
+
ok: false;
|
|
5
|
+
}>['reason'];
|
|
6
|
+
export declare function strictTimestamp(value: string): number | null;
|
|
7
|
+
export declare function custodyHorizon(registration: ClusterMeshRegistration, binding: CustodyBinding): number | null;
|
|
8
|
+
export declare function validateExpectedClaims(token: SignedCustodyToken, expected: CustodyTokenExpectation, input: {
|
|
9
|
+
readonly now: number;
|
|
10
|
+
readonly maximumTtlMs: number;
|
|
11
|
+
readonly clockSkewMs: number;
|
|
12
|
+
}): CustodyFailureReason | null;
|
|
13
|
+
export declare function validateCurrentBinding(token: SignedCustodyToken, registration: ClusterMeshRegistration | null, binding: CustodyBinding | undefined, now: number): CustodyFailureReason | null;
|
|
14
|
+
export declare function custodySelectors(token: SignedCustodyToken): readonly CustodyRevocationSelector[];
|
|
15
|
+
export declare function custodyInvocationKey(registrationId: string, invocationId: string): string;
|
|
16
|
+
//# sourceMappingURL=custody-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-validation.d.ts","sourceRoot":"","sources":["../../src/runtime/custody-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,EAAE;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AAE1F,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG5D;AAED,wBAAgB,cAAc,CAC5B,YAAY,EAAE,uBAAuB,EACrC,OAAO,EAAE,cAAc,GACtB,MAAM,GAAG,IAAI,CAMf;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,kBAAkB,EACzB,QAAQ,EAAE,uBAAuB,EACjC,KAAK,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC3F,oBAAoB,GAAG,IAAI,CAoB7B;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,kBAAkB,EACzB,YAAY,EAAE,uBAAuB,GAAG,IAAI,EAC5C,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,GAAG,EAAE,MAAM,GACV,oBAAoB,GAAG,IAAI,CAiB7B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,yBAAyB,EAAE,CAShG;AAED,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAEzF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { canonicalCustodyJson } from './custody-wire.js';
|
|
2
|
+
export function strictTimestamp(value) {
|
|
3
|
+
const timestamp = Date.parse(value);
|
|
4
|
+
return Number.isFinite(timestamp) && new Date(timestamp).toISOString() === value ? timestamp : null;
|
|
5
|
+
}
|
|
6
|
+
export function custodyHorizon(registration, binding) {
|
|
7
|
+
const registrationExpiry = strictTimestamp(registration.expiresAt);
|
|
8
|
+
const leaseExpiry = strictTimestamp(registration.leaseExpiresAt);
|
|
9
|
+
const bindingExpiry = strictTimestamp(binding.expiresAt);
|
|
10
|
+
if (registrationExpiry === null || leaseExpiry === null || bindingExpiry === null)
|
|
11
|
+
return null;
|
|
12
|
+
return Math.min(registrationExpiry, leaseExpiry, bindingExpiry);
|
|
13
|
+
}
|
|
14
|
+
export function validateExpectedClaims(token, expected, input) {
|
|
15
|
+
if (token.audience !== expected.audience
|
|
16
|
+
|| token.registrationId !== expected.registrationId
|
|
17
|
+
|| token.action !== expected.action
|
|
18
|
+
|| token.holderPrincipalId !== expected.holderPrincipalId
|
|
19
|
+
|| token.epoch !== expected.epoch
|
|
20
|
+
|| token.custodyId !== expected.custodyId
|
|
21
|
+
|| token.invocationId !== expected.invocationId)
|
|
22
|
+
return 'unbound';
|
|
23
|
+
const issuedAt = strictTimestamp(token.issuedAt);
|
|
24
|
+
const expiresAt = strictTimestamp(token.expiresAt);
|
|
25
|
+
if (issuedAt === null || expiresAt === null
|
|
26
|
+
|| expiresAt <= issuedAt
|
|
27
|
+
|| expiresAt - issuedAt > input.maximumTtlMs
|
|
28
|
+
|| issuedAt > input.now + input.clockSkewMs
|
|
29
|
+
|| expiresAt < input.now - input.clockSkewMs)
|
|
30
|
+
return 'stale';
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
export function validateCurrentBinding(token, registration, binding, now) {
|
|
34
|
+
if (!registration || !binding)
|
|
35
|
+
return 'unbound';
|
|
36
|
+
if (registration.status === 'revoked' || binding.status === 'revoked')
|
|
37
|
+
return 'revoked';
|
|
38
|
+
const horizon = custodyHorizon(registration, binding);
|
|
39
|
+
if (registration.status !== 'active' || horizon === null || horizon <= now)
|
|
40
|
+
return 'stale';
|
|
41
|
+
if (binding.registrationId !== registration.registrationId
|
|
42
|
+
|| token.registrationId !== registration.registrationId
|
|
43
|
+
|| token.audience !== binding.meshDomain
|
|
44
|
+
|| token.custodyId !== binding.custodyId
|
|
45
|
+
|| token.holderPrincipalId !== binding.holderPrincipalId
|
|
46
|
+
|| token.holderPrincipalId !== registration.custodyHolderPrincipalId
|
|
47
|
+
|| token.epoch !== binding.epoch
|
|
48
|
+
|| token.epoch !== registration.custodyEpoch)
|
|
49
|
+
return 'unbound';
|
|
50
|
+
const expiresAt = strictTimestamp(token.expiresAt);
|
|
51
|
+
return expiresAt === null || expiresAt > horizon ? 'unbound' : null;
|
|
52
|
+
}
|
|
53
|
+
export function custodySelectors(token) {
|
|
54
|
+
return [
|
|
55
|
+
{ kind: 'token', tokenId: token.tokenId },
|
|
56
|
+
{
|
|
57
|
+
kind: 'binding', registrationId: token.registrationId, custodyId: token.custodyId,
|
|
58
|
+
holderPrincipalId: token.holderPrincipalId, epoch: token.epoch,
|
|
59
|
+
},
|
|
60
|
+
{ kind: 'holder', holderPrincipalId: token.holderPrincipalId },
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
export function custodyInvocationKey(registrationId, invocationId) {
|
|
64
|
+
return canonicalCustodyJson([registrationId, invocationId]);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=custody-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-validation.js","sourceRoot":"","sources":["../../src/runtime/custody-validation.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAIzD,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AACtG,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,YAAqC,EACrC,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AE;QACzC;YACE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;YACjF,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK;SAC/D;QACD,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE;KAC/D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,cAAsB,EAAE,YAAoB;IAC/E,OAAO,oBAAoB,CAAC,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SignedCustodyToken } from './custody-types.js';
|
|
2
|
+
export declare function canonicalCustodyJson(value: unknown): string;
|
|
3
|
+
export declare function isSignedCustodyToken(value: unknown): value is SignedCustodyToken;
|
|
4
|
+
export declare function custodySignaturePayload(token: SignedCustodyToken): Uint8Array;
|
|
5
|
+
export declare function encodeCustodyToken(token: SignedCustodyToken): string;
|
|
6
|
+
export declare function decodeCustodyToken(value: string): SignedCustodyToken;
|
|
7
|
+
//# sourceMappingURL=custody-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-wire.d.ts","sourceRoot":"","sources":["../../src/runtime/custody-wire.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAwB7D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAiB3D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CA0BhF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,UAAU,CAG7E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAGpE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,CAsBpE"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
const TOKEN_KEYS = [
|
|
3
|
+
'action', 'audience', 'custodyId', 'epoch', 'evidence', 'expiresAt',
|
|
4
|
+
'holderPrincipalId', 'invocationId', 'issuedAt', 'issuer', 'kind',
|
|
5
|
+
'registrationId', 'tokenId', 'version',
|
|
6
|
+
];
|
|
7
|
+
const ISSUER_KEYS = ['algorithm', 'curve', 'issuerId', 'keyId'];
|
|
8
|
+
const EVIDENCE_KEYS = ['canonicalization', 'kind', 'signatureBase64Url'];
|
|
9
|
+
const actions = new Set(['drive', 'wake', 'relaunch']);
|
|
10
|
+
const base64Url = /^[A-Za-z0-9_-]+$/;
|
|
11
|
+
const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
12
|
+
&& (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
13
|
+
const hasExactKeys = (value, expected) => {
|
|
14
|
+
const actual = Object.keys(value).sort();
|
|
15
|
+
return actual.length === expected.length && expected.every((key, index) => actual[index] === key);
|
|
16
|
+
};
|
|
17
|
+
const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
|
|
18
|
+
export function canonicalCustodyJson(value) {
|
|
19
|
+
if (value === null || typeof value === 'boolean' || typeof value === 'string') {
|
|
20
|
+
return JSON.stringify(value);
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === 'number') {
|
|
23
|
+
if (!Number.isFinite(value))
|
|
24
|
+
throw new TypeError('custody canonical JSON requires finite numbers');
|
|
25
|
+
return JSON.stringify(value);
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
return `[${value.map((entry) => canonicalCustodyJson(entry)).join(',')}]`;
|
|
29
|
+
}
|
|
30
|
+
if (!isRecord(value))
|
|
31
|
+
throw new TypeError('custody canonical JSON requires plain JSON values');
|
|
32
|
+
const fields = Object.keys(value).sort().map((key) => {
|
|
33
|
+
if (value[key] === undefined)
|
|
34
|
+
throw new TypeError('custody canonical JSON rejects undefined');
|
|
35
|
+
return `${JSON.stringify(key)}:${canonicalCustodyJson(value[key])}`;
|
|
36
|
+
});
|
|
37
|
+
return `{${fields.join(',')}}`;
|
|
38
|
+
}
|
|
39
|
+
export function isSignedCustodyToken(value) {
|
|
40
|
+
if (!isRecord(value) || !hasExactKeys(value, TOKEN_KEYS))
|
|
41
|
+
return false;
|
|
42
|
+
if (!isRecord(value.issuer) || !hasExactKeys(value.issuer, ISSUER_KEYS))
|
|
43
|
+
return false;
|
|
44
|
+
if (!isRecord(value.evidence) || !hasExactKeys(value.evidence, EVIDENCE_KEYS))
|
|
45
|
+
return false;
|
|
46
|
+
const issuer = value.issuer;
|
|
47
|
+
const evidence = value.evidence;
|
|
48
|
+
return value.kind === 'signed-custody-token'
|
|
49
|
+
&& value.version === 'sentropic.cluster-mesh.custody/v1'
|
|
50
|
+
&& isNonEmptyString(value.tokenId)
|
|
51
|
+
&& isNonEmptyString(issuer.issuerId)
|
|
52
|
+
&& isNonEmptyString(issuer.keyId)
|
|
53
|
+
&& issuer.algorithm === 'EdDSA'
|
|
54
|
+
&& issuer.curve === 'Ed25519'
|
|
55
|
+
&& isNonEmptyString(value.audience)
|
|
56
|
+
&& isNonEmptyString(value.registrationId)
|
|
57
|
+
&& typeof value.action === 'string' && actions.has(value.action)
|
|
58
|
+
&& isNonEmptyString(value.holderPrincipalId)
|
|
59
|
+
&& typeof value.epoch === 'number' && Number.isInteger(value.epoch) && value.epoch >= 0
|
|
60
|
+
&& isNonEmptyString(value.custodyId)
|
|
61
|
+
&& isNonEmptyString(value.invocationId)
|
|
62
|
+
&& isNonEmptyString(value.issuedAt)
|
|
63
|
+
&& isNonEmptyString(value.expiresAt)
|
|
64
|
+
&& evidence.kind === 'detached-signature'
|
|
65
|
+
&& evidence.canonicalization === 'sentropic-json-v1'
|
|
66
|
+
&& isNonEmptyString(evidence.signatureBase64Url)
|
|
67
|
+
&& base64Url.test(evidence.signatureBase64Url);
|
|
68
|
+
}
|
|
69
|
+
export function custodySignaturePayload(token) {
|
|
70
|
+
const { signatureBase64Url: _signature, ...evidence } = token.evidence;
|
|
71
|
+
return new TextEncoder().encode(canonicalCustodyJson({ ...token, evidence }));
|
|
72
|
+
}
|
|
73
|
+
export function encodeCustodyToken(token) {
|
|
74
|
+
if (!isSignedCustodyToken(token))
|
|
75
|
+
throw new TypeError('invalid signed custody token');
|
|
76
|
+
return Buffer.from(canonicalCustodyJson(token), 'utf8').toString('base64url');
|
|
77
|
+
}
|
|
78
|
+
export function decodeCustodyToken(value) {
|
|
79
|
+
if (!value || !base64Url.test(value) || value.length % 4 === 1) {
|
|
80
|
+
throw new TypeError('invalid custody token base64url');
|
|
81
|
+
}
|
|
82
|
+
const bytes = Buffer.from(value, 'base64url');
|
|
83
|
+
if (bytes.toString('base64url') !== value)
|
|
84
|
+
throw new TypeError('non-canonical custody token base64url');
|
|
85
|
+
let json;
|
|
86
|
+
try {
|
|
87
|
+
json = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
throw new TypeError('invalid custody token UTF-8');
|
|
91
|
+
}
|
|
92
|
+
let parsed;
|
|
93
|
+
try {
|
|
94
|
+
parsed = JSON.parse(json);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw new TypeError('invalid custody token JSON');
|
|
98
|
+
}
|
|
99
|
+
if (!isSignedCustodyToken(parsed) || canonicalCustodyJson(parsed) !== json) {
|
|
100
|
+
throw new TypeError('non-canonical custody token shape');
|
|
101
|
+
}
|
|
102
|
+
return parsed;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=custody-wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custody-wire.js","sourceRoot":"","sources":["../../src/runtime/custody-wire.ts"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AAW,CAAC,CAAC;IAC9C,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,KAAK;QAAE,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;IACxG,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,SAAS,CAAC,6BAA6B,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;QAC3E,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import type { VerifiedInvocationContext } from '@sentropic/contracts';
|
|
2
|
-
|
|
2
|
+
import type { CustodyTokenVerifierPort } from './custody-types.js';
|
|
3
|
+
export declare const GATEWAY_RELAUNCH_SCOPE: "session:relaunch:gateway";
|
|
4
|
+
export interface RelaunchLaunchContext {
|
|
5
|
+
readonly gateway: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type GatewayNamespace = 'gw' | 'no-gw';
|
|
8
|
+
type SessionControlAction = 'drive' | 'wake' | 'relaunch';
|
|
9
|
+
export interface SessionControlIntent {
|
|
10
|
+
readonly commandRef: string;
|
|
11
|
+
readonly targetRegistrationId: string;
|
|
12
|
+
readonly idempotencyKey: string;
|
|
13
|
+
readonly launchContext?: RelaunchLaunchContext;
|
|
14
|
+
}
|
|
15
|
+
export interface RelaunchAuthorizationAttributes {
|
|
16
|
+
readonly launchContext: RelaunchLaunchContext;
|
|
17
|
+
}
|
|
18
|
+
export type RegistrationFailureReason = 'missing_registration' | 'stale_registration' | 'revoked_registration' | 'generation_mismatch' | 'principal_mismatch' | 'workspace_mismatch' | 'custody_required' | 'custody_mismatch' | 'invalid_launch_context' | 'gateway_forbidden' | 'actuator_unavailable' | 'command_unresolved';
|
|
3
19
|
export type ActuationOutcome = 'acted' | 'deferred' | 'failed';
|
|
4
20
|
export type TargetLiveness = 'alive' | 'dead' | 'parked' | 'unknown';
|
|
5
21
|
/**
|
|
@@ -14,7 +30,7 @@ export interface CommandInstructionPort {
|
|
|
14
30
|
resolve(input: {
|
|
15
31
|
readonly commandRef: string;
|
|
16
32
|
readonly registrationId: string;
|
|
17
|
-
readonly action:
|
|
33
|
+
readonly action: SessionControlAction;
|
|
18
34
|
}): Promise<SignedInstruction | null>;
|
|
19
35
|
}
|
|
20
36
|
export interface ClusterMeshRegistration {
|
|
@@ -34,13 +50,22 @@ export interface ClusterMeshRegistration {
|
|
|
34
50
|
export interface RegistrationLookupPort {
|
|
35
51
|
find(registrationId: string): Promise<ClusterMeshRegistration | null>;
|
|
36
52
|
}
|
|
37
|
-
|
|
53
|
+
interface ActuationRequestBase {
|
|
38
54
|
readonly registration: ClusterMeshRegistration;
|
|
39
|
-
readonly action: 'drive' | 'wake' | 'relaunch';
|
|
40
55
|
/** Opaque, non-executable identifier. Actuators MUST NOT interpret it as an instruction. */
|
|
41
56
|
readonly commandRef: string;
|
|
42
57
|
readonly resolvedInstruction: SignedInstruction;
|
|
43
58
|
}
|
|
59
|
+
export type ActuationRequest = ActuationRequestBase & ({
|
|
60
|
+
readonly action: 'drive';
|
|
61
|
+
readonly launchContext?: never;
|
|
62
|
+
} | {
|
|
63
|
+
readonly action: 'wake';
|
|
64
|
+
readonly launchContext?: never;
|
|
65
|
+
} | {
|
|
66
|
+
readonly action: 'relaunch';
|
|
67
|
+
readonly launchContext: RelaunchLaunchContext;
|
|
68
|
+
});
|
|
44
69
|
export interface ActuationResult {
|
|
45
70
|
readonly effectRef: string;
|
|
46
71
|
readonly outcome: ActuationOutcome;
|
|
@@ -61,26 +86,43 @@ export interface SecondaryActuatorPort {
|
|
|
61
86
|
export type SessionActuatorPort = PtyActuatorPort | SecondaryActuatorPort;
|
|
62
87
|
export declare function selectPreferredActuator(input: {
|
|
63
88
|
readonly actuatorRef: string;
|
|
64
|
-
readonly action:
|
|
89
|
+
readonly action: SessionControlAction;
|
|
65
90
|
readonly pty: PtyActuatorPort;
|
|
66
91
|
readonly secondary?: SecondaryActuatorPort;
|
|
67
92
|
}): Promise<SessionActuatorPort | null>;
|
|
68
93
|
export type RegistrationDecision = {
|
|
69
94
|
readonly ok: true;
|
|
95
|
+
readonly action: 'drive';
|
|
96
|
+
readonly registration: ClusterMeshRegistration;
|
|
97
|
+
readonly actuator: SessionActuatorPort;
|
|
98
|
+
readonly launchContext?: never;
|
|
99
|
+
} | {
|
|
100
|
+
readonly ok: true;
|
|
101
|
+
readonly action: 'wake';
|
|
102
|
+
readonly registration: ClusterMeshRegistration;
|
|
103
|
+
readonly actuator: SessionActuatorPort;
|
|
104
|
+
readonly launchContext?: never;
|
|
105
|
+
} | {
|
|
106
|
+
readonly ok: true;
|
|
107
|
+
readonly action: 'relaunch';
|
|
70
108
|
readonly registration: ClusterMeshRegistration;
|
|
71
109
|
readonly actuator: SessionActuatorPort;
|
|
110
|
+
readonly launchContext: RelaunchLaunchContext;
|
|
72
111
|
} | {
|
|
73
112
|
readonly ok: false;
|
|
74
113
|
readonly reason: RegistrationFailureReason;
|
|
75
114
|
};
|
|
76
115
|
export interface RegistrationGate {
|
|
77
|
-
|
|
116
|
+
readonly custodyControlled?: true;
|
|
117
|
+
authorize(context: VerifiedInvocationContext, action: SessionControlAction, attributes?: RelaunchAuthorizationAttributes): Promise<RegistrationDecision>;
|
|
78
118
|
}
|
|
79
119
|
export declare function createRegistrationGate(input: {
|
|
80
120
|
readonly generationId: string;
|
|
81
121
|
readonly registrations: RegistrationLookupPort;
|
|
82
122
|
readonly pty: PtyActuatorPort;
|
|
83
123
|
readonly secondary?: SecondaryActuatorPort;
|
|
124
|
+
readonly custodyTokens?: CustodyTokenVerifierPort;
|
|
84
125
|
readonly now?: () => Date;
|
|
85
126
|
}): RegistrationGate;
|
|
127
|
+
export {};
|
|
86
128
|
//# sourceMappingURL=registration.d.ts.map
|