@serve.zone/interfaces 31.9.0 → 32.0.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/changelog.md +476 -0
- package/dist_ts/00_commitinfo_data.js +3 -3
- package/dist_ts/appstore/types.d.ts +4 -6
- package/dist_ts/appstore/types.js +5 -5
- package/dist_ts/data/backup.d.ts +3 -26
- package/dist_ts/data/cluster.d.ts +36 -11
- package/dist_ts/data/cluster.js +33 -22
- package/dist_ts/data/clusteringress.d.ts +8 -0
- package/dist_ts/data/clusteringress.js +13 -8
- package/dist_ts/data/clusternode.d.ts +121 -74
- package/dist_ts/data/clusternode.js +109 -132
- package/dist_ts/data/coremail.d.ts +3 -7
- package/dist_ts/data/coremail.js +2 -2
- package/dist_ts/data/coremail.runtime.d.ts +0 -1
- package/dist_ts/data/coremail.runtime.js +5 -22
- package/dist_ts/data/deploymentadoption.d.ts +0 -2
- package/dist_ts/data/deploymentadoption.js +40 -6
- package/dist_ts/data/deploymentoperation.js +16 -3
- package/dist_ts/data/deploymentpreflight.d.ts +0 -2
- package/dist_ts/data/deploymentpreflight.js +1 -1
- package/dist_ts/data/immutableimage.d.ts +38 -21
- package/dist_ts/data/immutableimage.js +45 -5
- package/dist_ts/data/index.d.ts +1 -1
- package/dist_ts/data/isolatedrestore.d.ts +139 -21
- package/dist_ts/data/isolatedrestore.golden.d.ts +0 -1
- package/dist_ts/data/isolatedrestore.golden.js +6 -9
- package/dist_ts/data/isolatedrestore.js +176 -40
- package/dist_ts/data/mail.d.ts +1 -1
- package/dist_ts/data/networkaddressplan.d.ts +8 -8
- package/dist_ts/data/networkaddressplan.js +4 -4
- package/dist_ts/data/networkauthority.d.ts +20 -22
- package/dist_ts/data/networkauthority.js +26 -28
- package/dist_ts/data/networkcredential.d.ts +10 -10
- package/dist_ts/data/networkcredential.js +16 -16
- package/dist_ts/data/networkdelivery.d.ts +18 -18
- package/dist_ts/data/networkdelivery.js +16 -16
- package/dist_ts/data/networklease.d.ts +18 -7
- package/dist_ts/data/networklease.js +29 -7
- package/dist_ts/data/networknode.d.ts +2 -2
- package/dist_ts/data/networkprojection.d.ts +59 -60
- package/dist_ts/data/networkprojection.js +53 -57
- package/dist_ts/data/networkprotection.d.ts +27 -28
- package/dist_ts/data/networkprotection.js +36 -36
- package/dist_ts/data/networkrouter.d.ts +11 -11
- package/dist_ts/data/networkrouter.js +1 -1
- package/dist_ts/data/networksigning.d.ts +16 -18
- package/dist_ts/data/networksigning.js +20 -21
- package/dist_ts/data/nodecredential.d.ts +4 -6
- package/dist_ts/data/nodeenrollment.d.ts +35 -40
- package/dist_ts/data/nodeenrollment.js +57 -72
- package/dist_ts/data/privatenetwork.d.ts +21 -24
- package/dist_ts/data/privatenetwork.js +39 -54
- package/dist_ts/data/runtimeassignment.d.ts +50 -34
- package/dist_ts/data/runtimeassignment.js +79 -45
- package/dist_ts/data/runtimeconfig.d.ts +21 -22
- package/dist_ts/data/runtimeconfig.js +24 -24
- package/dist_ts/data/runtimesession.d.ts +100 -62
- package/dist_ts/data/runtimesession.js +98 -79
- package/dist_ts/data/runtimeterminalreceipt.d.ts +28 -29
- package/dist_ts/data/runtimeterminalreceipt.js +42 -42
- package/dist_ts/data/secret.d.ts +18 -25
- package/dist_ts/data/secret.js +12 -52
- package/dist_ts/data/servicecredential.d.ts +14 -16
- package/dist_ts/data/servicecredential.js +17 -28
- package/dist_ts/data/serviceruntime.d.ts +7 -7
- package/dist_ts/data/serviceruntime.js +4 -4
- package/dist_ts/data/sparknodereport.d.ts +27 -14
- package/dist_ts/data/sparknodereport.js +35 -28
- package/dist_ts/data/webpush.d.ts +0 -1
- package/dist_ts/index.d.ts +2 -1
- package/dist_ts/index.js +3 -2
- package/dist_ts/platform/objectstorageretention.d.ts +21 -24
- package/dist_ts/platform/objectstorageretention.js +10 -17
- package/dist_ts/platform/storage.d.ts +1 -3
- package/dist_ts/platform/storagemigration.d.ts +0 -7
- package/dist_ts/platform/storagemigration.golden.d.ts +0 -1
- package/dist_ts/platform/storagemigration.golden.js +8 -12
- package/dist_ts/platform/storagemigration.js +6 -51
- package/dist_ts/platform/types.d.ts +2 -2
- package/dist_ts/private/canonicaljson.d.ts +9 -1
- package/dist_ts/private/canonicaljson.js +14 -2
- package/dist_ts/private/dataproperties.d.ts +62 -0
- package/dist_ts/private/dataproperties.js +117 -0
- package/dist_ts/private/networkcontract.d.ts +10 -10
- package/dist_ts/private/networkcontract.js +1 -1
- package/dist_ts/private/releaseversion.d.ts +37 -0
- package/dist_ts/private/releaseversion.js +48 -0
- package/dist_ts/private/runtimepolicy.d.ts +2 -2
- package/dist_ts/private/runtimepolicy.js +1 -1
- package/dist_ts/private/tokenlist.d.ts +9 -0
- package/dist_ts/private/tokenlist.js +23 -0
- package/dist_ts/protocol.d.ts +137 -0
- package/dist_ts/protocol.js +255 -0
- package/dist_ts/requests/admin.d.ts +8 -8
- package/dist_ts/requests/backup.d.ts +102 -112
- package/dist_ts/requests/cluster.d.ts +10 -10
- package/dist_ts/requests/clusteringress.d.ts +9 -0
- package/dist_ts/requests/clusteringress.js +1 -1
- package/dist_ts/requests/config.d.ts +3 -3
- package/dist_ts/requests/corestore.d.ts +0 -3
- package/dist_ts/requests/corestore.js +5 -9
- package/dist_ts/requests/network.d.ts +30 -30
- package/dist_ts/requests/node.d.ts +15 -28
- package/dist_ts/requests/pallet.d.ts +13 -13
- package/dist_ts/requests/runtimesession.d.ts +53 -41
- package/dist_ts/requests/secret.d.ts +4 -5
- package/dist_ts/requests/secret.js +1 -5
- package/dist_ts/runtime.corestore.d.ts +56 -74
- package/dist_ts/runtime.corestore.databaseexportpackage.d.ts +30 -36
- package/dist_ts/runtime.corestore.databaseexportpackage.golden.d.ts +11 -12
- package/dist_ts/runtime.corestore.databaseexportpackage.golden.js +54 -71
- package/dist_ts/runtime.corestore.databaseexportpackage.js +9 -25
- package/dist_ts/runtime.corestore.js +35 -135
- package/dist_ts/runtime.corestore.relay.js +2 -7
- package/dist_ts/runtime.d.ts +38 -48
- package/dist_ts/runtime.js +20 -77
- package/dist_ts/runtime.networkprojection.d.ts +4 -4
- package/dist_ts/runtime.networkprojection.js +18 -18
- package/dist_ts/runtime.workloadinit.d.ts +23 -24
- package/dist_ts/runtime.workloadinit.js +6 -13
- package/package.json +2 -2
- package/readme.md +421 -270
- package/ts/00_commitinfo_data.ts +3 -3
- package/ts/appstore/types.ts +4 -6
- package/ts/data/backup.ts +3 -38
- package/ts/data/cluster.ts +51 -34
- package/ts/data/clusteringress.ts +12 -12
- package/ts/data/clusternode.ts +204 -232
- package/ts/data/coremail.runtime.ts +4 -21
- package/ts/data/coremail.ts +3 -7
- package/ts/data/deploymentadoption.ts +46 -4
- package/ts/data/deploymentoperation.ts +16 -1
- package/ts/data/deploymentpreflight.ts +0 -2
- package/ts/data/immutableimage.ts +71 -24
- package/ts/data/index.ts +1 -1
- package/ts/data/isolatedrestore.golden.ts +5 -9
- package/ts/data/isolatedrestore.ts +339 -54
- package/ts/data/mail.ts +1 -1
- package/ts/data/networkaddressplan.ts +13 -13
- package/ts/data/networkauthority.ts +42 -46
- package/ts/data/networkcredential.ts +24 -24
- package/ts/data/networkdelivery.ts +27 -27
- package/ts/data/networklease.ts +40 -13
- package/ts/data/networknode.ts +2 -2
- package/ts/data/networkprojection.ts +119 -124
- package/ts/data/networkprotection.ts +54 -55
- package/ts/data/networkrouter.ts +14 -14
- package/ts/data/networksigning.ts +29 -32
- package/ts/data/nodecredential.ts +4 -6
- package/ts/data/nodeenrollment.ts +96 -114
- package/ts/data/privatenetwork.ts +58 -74
- package/ts/data/runtimeassignment.ts +143 -94
- package/ts/data/runtimeconfig.ts +45 -46
- package/ts/data/runtimesession.ts +185 -138
- package/ts/data/runtimeterminalreceipt.ts +72 -73
- package/ts/data/secret.ts +28 -76
- package/ts/data/servicecredential.ts +33 -43
- package/ts/data/serviceruntime.ts +11 -11
- package/ts/data/sparknodereport.ts +48 -36
- package/ts/data/webpush.ts +0 -1
- package/ts/index.ts +2 -0
- package/ts/platform/objectstorageretention.ts +40 -54
- package/ts/platform/storage.ts +1 -3
- package/ts/platform/storagemigration.golden.ts +7 -11
- package/ts/platform/storagemigration.ts +5 -55
- package/ts/platform/types.ts +2 -2
- package/ts/private/canonicaljson.ts +13 -1
- package/ts/private/dataproperties.ts +139 -0
- package/ts/private/networkcontract.ts +9 -9
- package/ts/private/releaseversion.ts +70 -0
- package/ts/private/runtimepolicy.ts +2 -2
- package/ts/private/tokenlist.ts +30 -0
- package/ts/protocol.ts +364 -0
- package/ts/requests/admin.ts +11 -11
- package/ts/requests/backup.ts +112 -117
- package/ts/requests/cluster.ts +13 -13
- package/ts/requests/clusteringress.ts +9 -0
- package/ts/requests/config.ts +3 -3
- package/ts/requests/corestore.ts +4 -16
- package/ts/requests/network.ts +40 -40
- package/ts/requests/node.ts +21 -38
- package/ts/requests/pallet.ts +17 -17
- package/ts/requests/runtimesession.ts +63 -51
- package/ts/requests/secret.ts +5 -10
- package/ts/runtime.corestore.databaseexportpackage.golden.ts +77 -95
- package/ts/runtime.corestore.databaseexportpackage.ts +51 -73
- package/ts/runtime.corestore.relay.ts +1 -10
- package/ts/runtime.corestore.ts +118 -268
- package/ts/runtime.networkprojection.ts +30 -30
- package/ts/runtime.ts +83 -158
- package/ts/runtime.workloadinit.ts +36 -48
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.d.ts +0 -902
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.golden.d.ts +0 -35
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.golden.js +0 -315
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.js +0 -3315
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.d.ts +0 -291
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.golden.d.ts +0 -30
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.golden.js +0 -408
- package/dist_ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.js +0 -1126
- package/ts/runtime.cloudlylegacydeploymentsettlement.golden.ts +0 -421
- package/ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.golden.ts +0 -510
- package/ts/runtime.cloudlylegacydeploymentsettlement.offlineexport.ts +0 -2470
- package/ts/runtime.cloudlylegacydeploymentsettlement.ts +0 -6630
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isPlausibleUnicastIpv4 } from '../private/ipv4.js';
|
|
2
2
|
import type { TSha256Digest } from './immutableimage.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
9
|
-
import {
|
|
3
|
+
import type { IRuntimeAuthorityReference } from './runtimeassignment.js';
|
|
4
|
+
import type { IRuntimeNetworkNodeScope } from './networkprojection.js';
|
|
5
|
+
import { snapshotRuntimeNetworkNodeScope } from './networkprojection.js';
|
|
6
|
+
import type { IRuntimeNetworkProtectedAuthority } from './networkauthority.js';
|
|
7
|
+
import { computeRuntimeNetworkProtectedAuthorityDigest, snapshotRuntimeNetworkProtectedAuthority } from './networkauthority.js';
|
|
8
|
+
import type { IRuntimeSessionBinding } from './runtimesession.js';
|
|
9
|
+
import { snapshotRuntimeSessionBinding } from './runtimesession.js';
|
|
10
10
|
import { captureNetwork, failNetwork, networkCanonical, networkDigest, networkEqual, networkHash,
|
|
11
11
|
networkId, networkList, networkRecord, networkReference, networkReferenceOf, networkRevision,
|
|
12
12
|
networkSafe, networkSorted, requireNetwork } from '../private/networkcontract.js';
|
|
@@ -18,21 +18,20 @@ import { captureNetwork, failNetwork, networkCanonical, networkDigest, networkEq
|
|
|
18
18
|
* a single table inspection, a boot event or a caller-selected success flag.
|
|
19
19
|
* A null nativeBarrier explicitly withdraws this node's allocation eligibility.
|
|
20
20
|
*/
|
|
21
|
-
export interface
|
|
22
|
-
schemaVersion: 1;
|
|
21
|
+
export interface IRuntimeNetworkProtectionReceipt extends IRuntimeNetworkNodeScope {
|
|
23
22
|
id: string;
|
|
24
23
|
generation: number;
|
|
25
|
-
previous:
|
|
26
|
-
protectedAuthority:
|
|
24
|
+
previous: IRuntimeAuthorityReference | null;
|
|
25
|
+
protectedAuthority: IRuntimeAuthorityReference;
|
|
27
26
|
reporterSessionId: string;
|
|
28
27
|
bootId: string;
|
|
29
|
-
nativeBarrier:
|
|
28
|
+
nativeBarrier: IRuntimeAuthorityReference | null;
|
|
30
29
|
digest: TSha256Digest;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
export interface
|
|
34
|
-
session:
|
|
35
|
-
receipt:
|
|
32
|
+
export interface IReportRuntimeNetworkProtectionRequest {
|
|
33
|
+
session: IRuntimeSessionBinding;
|
|
34
|
+
receipt: IRuntimeNetworkProtectionReceipt;
|
|
36
35
|
/**
|
|
37
36
|
* The address this node answers on, as the node itself observed it.
|
|
38
37
|
*
|
|
@@ -44,14 +43,14 @@ export interface IReportRuntimeNetworkProtectionRequestV1 {
|
|
|
44
43
|
*/
|
|
45
44
|
uplinkAddress?: string;
|
|
46
45
|
}
|
|
47
|
-
export interface
|
|
46
|
+
export interface IReportRuntimeNetworkProtectionResponse {
|
|
48
47
|
status: 'accepted' | 'replay';
|
|
49
|
-
receipt:
|
|
48
|
+
receipt: IRuntimeAuthorityReference;
|
|
50
49
|
authorityUse: 'current' | 'historical';
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
export const
|
|
54
|
-
digestDomain: 'serve.zone/runtime-network-protection-receipt
|
|
52
|
+
export const runtimeNetworkProtectionContract = Object.freeze({
|
|
53
|
+
digestDomain: 'serve.zone/runtime-network-protection-receipt',
|
|
55
54
|
maximumAuthorities: 256,
|
|
56
55
|
allocation: 'all-current-affected-egress-receipts-before-reserving-any-lease',
|
|
57
56
|
receiptSource: 'joined-complete-native-protection-journal',
|
|
@@ -60,45 +59,45 @@ export const runtimeNetworkProtectionV1Contract = Object.freeze({
|
|
|
60
59
|
quarantine: 'no-release-authority',
|
|
61
60
|
} as const);
|
|
62
61
|
|
|
63
|
-
const scopeOf = (value:
|
|
62
|
+
const scopeOf = (value: IRuntimeNetworkNodeScope): IRuntimeNetworkNodeScope =>
|
|
64
63
|
({ controller: value.controller, nodeId: value.nodeId, runtimeNamespace: value.runtimeNamespace });
|
|
65
64
|
const scopeKey = (value: { nodeId: string; runtimeNamespace: string }): string =>
|
|
66
65
|
networkCanonical([value.nodeId, value.runtimeNamespace]);
|
|
67
66
|
|
|
68
|
-
export const
|
|
69
|
-
const item = networkRecord(captureNetwork(value), ['
|
|
67
|
+
export const snapshotRuntimeNetworkProtectionReceipt = (value: unknown): IRuntimeNetworkProtectionReceipt => networkSafe(() => {
|
|
68
|
+
const item = networkRecord(captureNetwork(value), ['id', 'generation', 'previous',
|
|
70
69
|
'controller', 'nodeId', 'runtimeNamespace', 'protectedAuthority', 'reporterSessionId', 'bootId', 'nativeBarrier', 'digest']);
|
|
71
|
-
requireNetwork(
|
|
70
|
+
requireNetwork(typeof item.bootId === 'string'
|
|
72
71
|
&& /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(item.bootId)
|
|
73
72
|
&& item.bootId !== '00000000-0000-0000-0000-000000000000');
|
|
74
|
-
const scope =
|
|
75
|
-
return {
|
|
73
|
+
const scope = snapshotRuntimeNetworkNodeScope({ controller: item.controller, nodeId: item.nodeId, runtimeNamespace: item.runtimeNamespace });
|
|
74
|
+
return { ...networkRevision(item), ...scope,
|
|
76
75
|
protectedAuthority: networkReference(item.protectedAuthority), reporterSessionId: networkId(item.reporterSessionId),
|
|
77
76
|
bootId: item.bootId, nativeBarrier: item.nativeBarrier === null ? null : networkReference(item.nativeBarrier),
|
|
78
77
|
digest: networkDigest(item.digest) };
|
|
79
78
|
});
|
|
80
79
|
|
|
81
|
-
export const
|
|
82
|
-
networkHash(
|
|
80
|
+
export const computeRuntimeNetworkProtectionReceiptDigest = (value: IRuntimeNetworkProtectionReceipt): Promise<TSha256Digest> =>
|
|
81
|
+
networkHash(runtimeNetworkProtectionContract.digestDomain, snapshotRuntimeNetworkProtectionReceipt(value));
|
|
83
82
|
|
|
84
83
|
/** Pure revision binding. The owner must authenticate the reporter and fence all DB writes. */
|
|
85
|
-
export const
|
|
84
|
+
export const admitRuntimeNetworkProtectionReceipt = async (
|
|
86
85
|
value: unknown, previousValue: unknown | null, trustedScopeValue: unknown, knownProtectionValue: unknown,
|
|
87
|
-
): Promise<{ status: 'accepted' | 'replay'; receipt:
|
|
86
|
+
): Promise<{ status: 'accepted' | 'replay'; receipt: IRuntimeNetworkProtectionReceipt }> => {
|
|
88
87
|
try {
|
|
89
|
-
const receipt =
|
|
90
|
-
const previous = previousValue === null ? null :
|
|
91
|
-
const scope =
|
|
92
|
-
const protection =
|
|
88
|
+
const receipt = snapshotRuntimeNetworkProtectionReceipt(value);
|
|
89
|
+
const previous = previousValue === null ? null : snapshotRuntimeNetworkProtectionReceipt(previousValue);
|
|
90
|
+
const scope = snapshotRuntimeNetworkNodeScope(captureNetwork(trustedScopeValue));
|
|
91
|
+
const protection = snapshotRuntimeNetworkProtectedAuthority(captureNetwork(knownProtectionValue));
|
|
93
92
|
requireNetwork(networkEqual(scopeOf(receipt), scope) && networkEqual(receipt.controller, protection.controller)
|
|
94
93
|
&& networkEqual(receipt.protectedAuthority, networkReferenceOf(protection))
|
|
95
94
|
&& protection.egressAuthorities.some(owner => scopeKey(owner) === scopeKey(receipt)));
|
|
96
|
-
requireNetwork(receipt.digest === await
|
|
97
|
-
&& protection.digest === await
|
|
95
|
+
requireNetwork(receipt.digest === await computeRuntimeNetworkProtectionReceiptDigest(receipt)
|
|
96
|
+
&& protection.digest === await computeRuntimeNetworkProtectedAuthorityDigest(protection));
|
|
98
97
|
if (!previous) requireNetwork(receipt.generation === 1 && receipt.previous === null);
|
|
99
98
|
else {
|
|
100
99
|
requireNetwork(networkEqual(scopeOf(previous), scope)
|
|
101
|
-
&& previous.digest === await
|
|
100
|
+
&& previous.digest === await computeRuntimeNetworkProtectionReceiptDigest(previous));
|
|
102
101
|
if (networkEqual(receipt, previous)) return { status: 'replay', receipt };
|
|
103
102
|
requireNetwork(receipt.id === previous.id && receipt.generation === previous.generation + 1
|
|
104
103
|
&& networkEqual(receipt.previous, networkReferenceOf(previous))
|
|
@@ -123,11 +122,11 @@ export const admitRuntimeNetworkProtectionReceiptV1 = async (
|
|
|
123
122
|
} catch { return failNetwork(); }
|
|
124
123
|
};
|
|
125
124
|
|
|
126
|
-
export const
|
|
125
|
+
export const snapshotReportRuntimeNetworkProtectionRequest = (value: unknown): IReportRuntimeNetworkProtectionRequest => networkSafe(() => {
|
|
127
126
|
const item = networkRecord(captureNetwork(value), ['session', 'receipt'], ['uplinkAddress']);
|
|
128
|
-
const request:
|
|
129
|
-
session:
|
|
130
|
-
receipt:
|
|
127
|
+
const request: IReportRuntimeNetworkProtectionRequest = {
|
|
128
|
+
session: snapshotRuntimeSessionBinding(item.session),
|
|
129
|
+
receipt: snapshotRuntimeNetworkProtectionReceipt(item.receipt),
|
|
131
130
|
};
|
|
132
131
|
if (Object.hasOwn(item, 'uplinkAddress')) {
|
|
133
132
|
request.uplinkAddress = runtimeNodeUplinkAddress(item.uplinkAddress);
|
|
@@ -150,12 +149,12 @@ export const runtimeNodeUplinkAddress = (value: unknown): string => {
|
|
|
150
149
|
};
|
|
151
150
|
|
|
152
151
|
/** Both trusted bindings come from the receiver's fenced physical-session/history owner. */
|
|
153
|
-
export const
|
|
152
|
+
export const bindReportRuntimeNetworkProtectionRequest = (
|
|
154
153
|
value: unknown, trustedCurrentSessionValue: unknown, trustedReporterSessionValue: unknown,
|
|
155
|
-
): { request:
|
|
156
|
-
const request =
|
|
157
|
-
const current =
|
|
158
|
-
const reporter =
|
|
154
|
+
): { request: IReportRuntimeNetworkProtectionRequest; authorityUse: 'current' | 'historical' } => networkSafe(() => {
|
|
155
|
+
const request = snapshotReportRuntimeNetworkProtectionRequest(value);
|
|
156
|
+
const current = snapshotRuntimeSessionBinding(captureNetwork(trustedCurrentSessionValue));
|
|
157
|
+
const reporter = snapshotRuntimeSessionBinding(captureNetwork(trustedReporterSessionValue));
|
|
159
158
|
requireNetwork(networkEqual(request.session, current) && networkEqual(scopeOf(request.receipt), scopeOf(current))
|
|
160
159
|
&& networkEqual(scopeOf(reporter), scopeOf(current)) && reporter.reporterSessionId === request.receipt.reporterSessionId);
|
|
161
160
|
const authorityUse = reporter.reporterSessionId === current.reporterSessionId ? 'current' : 'historical';
|
|
@@ -164,15 +163,15 @@ export const bindReportRuntimeNetworkProtectionRequestV1 = (
|
|
|
164
163
|
return { request, authorityUse };
|
|
165
164
|
});
|
|
166
165
|
|
|
167
|
-
export const
|
|
166
|
+
export const snapshotReportRuntimeNetworkProtectionResponse = (value: unknown): IReportRuntimeNetworkProtectionResponse => networkSafe(() => {
|
|
168
167
|
const item = networkRecord(captureNetwork(value), ['status', 'receipt', 'authorityUse']);
|
|
169
168
|
requireNetwork((item.status === 'accepted' || item.status === 'replay')
|
|
170
169
|
&& (item.authorityUse === 'current' || item.authorityUse === 'historical'));
|
|
171
170
|
return { status: item.status, receipt: networkReference(item.receipt), authorityUse: item.authorityUse };
|
|
172
171
|
});
|
|
173
172
|
|
|
174
|
-
export const
|
|
175
|
-
const response =
|
|
173
|
+
export const bindReportRuntimeNetworkProtectionResponse = (value: unknown, sentReceiptValue: unknown): IReportRuntimeNetworkProtectionResponse => networkSafe(() => {
|
|
174
|
+
const response = snapshotReportRuntimeNetworkProtectionResponse(value);
|
|
176
175
|
requireNetwork(networkEqual(response.receipt, networkReference(captureNetwork(sentReceiptValue))));
|
|
177
176
|
return response;
|
|
178
177
|
});
|
|
@@ -185,14 +184,14 @@ export const bindReportRuntimeNetworkProtectionResponseV1 = (value: unknown, sen
|
|
|
185
184
|
* cannot be omitted. Independent fences need their own verified owning contract;
|
|
186
185
|
* this helper supplies no generic override, expiry or quorum escape hatch.
|
|
187
186
|
*/
|
|
188
|
-
export const
|
|
187
|
+
export const bindRuntimeNetworkAllocationProtection = async (
|
|
189
188
|
protectionValue: unknown, receiptsValue: unknown, currentSessionsValue: unknown,
|
|
190
|
-
): Promise<{ protection:
|
|
189
|
+
): Promise<{ protection: IRuntimeNetworkProtectedAuthority; receipts: IRuntimeNetworkProtectionReceipt[] }> => {
|
|
191
190
|
try {
|
|
192
|
-
const protection =
|
|
193
|
-
const receipts = networkSorted(networkList(captureNetwork(receiptsValue), 256,
|
|
194
|
-
const sessions = networkSorted(networkList(captureNetwork(currentSessionsValue), 256,
|
|
195
|
-
requireNetwork(protection.digest === await
|
|
191
|
+
const protection = snapshotRuntimeNetworkProtectedAuthority(captureNetwork(protectionValue));
|
|
192
|
+
const receipts = networkSorted(networkList(captureNetwork(receiptsValue), 256, snapshotRuntimeNetworkProtectionReceipt), scopeKey);
|
|
193
|
+
const sessions = networkSorted(networkList(captureNetwork(currentSessionsValue), 256, snapshotRuntimeSessionBinding), scopeKey);
|
|
194
|
+
requireNetwork(protection.digest === await computeRuntimeNetworkProtectedAuthorityDigest(protection)
|
|
196
195
|
&& receipts.length === protection.egressAuthorities.length && sessions.length === receipts.length);
|
|
197
196
|
for (const [index, owner] of protection.egressAuthorities.entries()) {
|
|
198
197
|
const receipt = receipts[index], session = sessions[index];
|
|
@@ -200,7 +199,7 @@ export const bindRuntimeNetworkAllocationProtectionV1 = async (
|
|
|
200
199
|
&& networkEqual(receipt.controller, protection.controller) && networkEqual(session.controller, protection.controller)
|
|
201
200
|
&& receipt.reporterSessionId === session.reporterSessionId && receipt.nativeBarrier !== null
|
|
202
201
|
&& networkEqual(receipt.protectedAuthority, networkReferenceOf(protection))
|
|
203
|
-
&& receipt.digest === await
|
|
202
|
+
&& receipt.digest === await computeRuntimeNetworkProtectionReceiptDigest(receipt));
|
|
204
203
|
}
|
|
205
204
|
return { protection, receipts };
|
|
206
205
|
} catch { return failNetwork(); }
|
package/ts/data/networkrouter.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { IRuntimeAuthorityReference } from './runtimeassignment.js';
|
|
2
|
+
import type { IRuntimeNetworkHandoffLease, IRuntimeNetworkProtectedAuthority } from './networkauthority.js';
|
|
3
3
|
import { networkCanonical, networkCounter, networkId, networkIpv4, networkList,
|
|
4
4
|
networkRecord, networkReference, networkReferenceOf, networkSorted, requireNetwork } from '../private/networkcontract.js';
|
|
5
5
|
|
|
6
6
|
/** Exact router-origin flow authority; unrelated to workload connectivity or DNS names. */
|
|
7
|
-
export interface
|
|
8
|
-
source: { handoff:
|
|
7
|
+
export interface IRuntimeNetworkRouterPacketGrant {
|
|
8
|
+
source: { handoff: IRuntimeAuthorityReference; address: string };
|
|
9
9
|
destination: { kind: 'resolver' | 'platform'; id: string; address: string; protocol: 'tcp' | 'udp'; port: number };
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/** Explicit selections from the current protected inventory plus retained denials. */
|
|
13
|
-
export interface
|
|
13
|
+
export interface IRuntimeNetworkRouterProjection {
|
|
14
14
|
/** Each selected resolver authorizes its exact TCP and UDP endpoint. */
|
|
15
15
|
resolverIds: string[];
|
|
16
16
|
platformEndpointIds: string[];
|
|
17
|
-
withdrawals:
|
|
17
|
+
withdrawals: IRuntimeNetworkRouterPacketGrant[];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const grant = (value: unknown):
|
|
20
|
+
const grant = (value: unknown): IRuntimeNetworkRouterPacketGrant => {
|
|
21
21
|
const item = networkRecord(value, ['source', 'destination']);
|
|
22
22
|
const source = networkRecord(item.source, ['handoff', 'address']);
|
|
23
23
|
const destination = networkRecord(item.destination, ['kind', 'id', 'address', 'protocol', 'port']);
|
|
@@ -29,7 +29,7 @@ const grant = (value: unknown): IRuntimeNetworkRouterPacketGrantV1 => {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
/** Internal parser: the enclosing projection has already captured caller input. */
|
|
32
|
-
export const snapshotRouterProjection = (value: unknown):
|
|
32
|
+
export const snapshotRouterProjection = (value: unknown): IRuntimeNetworkRouterProjection => {
|
|
33
33
|
const item = networkRecord(value, ['resolverIds', 'platformEndpointIds', 'withdrawals']);
|
|
34
34
|
return {
|
|
35
35
|
resolverIds: networkSorted(networkList(item.resolverIds, 16, networkId), value => value),
|
|
@@ -40,16 +40,16 @@ export const snapshotRouterProjection = (value: unknown): IRuntimeNetworkRouterP
|
|
|
40
40
|
|
|
41
41
|
/** Internal composition after capture. The public helper validates the whole projection. */
|
|
42
42
|
export const routerPacketGrantsOf = (projection: {
|
|
43
|
-
router?:
|
|
44
|
-
handoff:
|
|
45
|
-
protectedAuthority:
|
|
46
|
-
}):
|
|
43
|
+
router?: IRuntimeNetworkRouterProjection;
|
|
44
|
+
handoff: IRuntimeNetworkHandoffLease | null;
|
|
45
|
+
protectedAuthority: IRuntimeNetworkProtectedAuthority;
|
|
46
|
+
}): IRuntimeNetworkRouterPacketGrant[] => {
|
|
47
47
|
const selected = projection.router;
|
|
48
48
|
if (!selected || selected.resolverIds.length + selected.platformEndpointIds.length === 0) return [];
|
|
49
49
|
const handoff = projection.handoff; requireNetwork(handoff);
|
|
50
50
|
const source = { handoff: networkReferenceOf(handoff), address: handoff.transit.routerAddress };
|
|
51
|
-
const result:
|
|
52
|
-
const append = (destination:
|
|
51
|
+
const result: IRuntimeNetworkRouterPacketGrant[] = [];
|
|
52
|
+
const append = (destination: IRuntimeNetworkRouterPacketGrant['destination']) => {
|
|
53
53
|
requireNetwork(handoff.sourcePortRanges.some(range => range.protocol === destination.protocol));
|
|
54
54
|
result.push({ source: { handoff: { ...source.handoff }, address: source.address }, destination });
|
|
55
55
|
};
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import type { TSha256Digest } from './immutableimage.js';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { IRuntimeAuthorityReference, IRuntimeController } from './runtimeassignment.js';
|
|
3
|
+
import type { IRuntimeNetworkProjection } from './networkprojection.js';
|
|
4
|
+
import { snapshotRuntimeNetworkProjection } from './networkprojection.js';
|
|
5
|
+
import { snapshotRuntimeSessionBinding } from './runtimesession.js';
|
|
6
6
|
import { captureNetwork, failNetwork, networkController, networkDigest, networkEqual, networkHash, networkRecord,
|
|
7
7
|
networkReference, networkReferenceOf, networkRevision, networkSafe, networkSignature, requireNetwork } from '../private/networkcontract.js';
|
|
8
8
|
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
projection: IRuntimeNetworkProjectionV1;
|
|
9
|
+
export interface ISignedRuntimeNetworkProjection {
|
|
10
|
+
authority: IRuntimeAuthorityReference;
|
|
11
|
+
projection: IRuntimeNetworkProjection;
|
|
13
12
|
/** Ed25519 signature of the complete domain-separated envelope, lowercase hex. */
|
|
14
13
|
signature: string;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
export const
|
|
18
|
-
const item = networkRecord(captureNetwork(value), ['
|
|
19
|
-
|
|
20
|
-
return { schemaVersion: 1, authority: networkReference(item.authority), projection: snapshotRuntimeNetworkProjectionV1(item.projection),
|
|
16
|
+
export const snapshotSignedRuntimeNetworkProjection = (value: unknown): ISignedRuntimeNetworkProjection => networkSafe(() => {
|
|
17
|
+
const item = networkRecord(captureNetwork(value), ['authority', 'projection', 'signature']);
|
|
18
|
+
return { authority: networkReference(item.authority), projection: snapshotRuntimeNetworkProjection(item.projection),
|
|
21
19
|
signature: networkSignature(item.signature) };
|
|
22
20
|
});
|
|
23
21
|
|
|
@@ -27,54 +25,53 @@ export const snapshotSignedRuntimeNetworkProjectionV1 = (value: unknown): ISigne
|
|
|
27
25
|
* null revokes signing; rotation requires a new complete signed projection for DNS.
|
|
28
26
|
* Existing packet grants still require applied denial or independent fencing.
|
|
29
27
|
*/
|
|
30
|
-
export interface
|
|
31
|
-
schemaVersion: 1;
|
|
28
|
+
export interface IRuntimeNetworkSigningAuthority {
|
|
32
29
|
id: string;
|
|
33
30
|
generation: number;
|
|
34
|
-
previous:
|
|
35
|
-
controller:
|
|
31
|
+
previous: IRuntimeAuthorityReference | null;
|
|
32
|
+
controller: IRuntimeController;
|
|
36
33
|
algorithm: 'Ed25519';
|
|
37
34
|
/** Canonical 32-byte raw public key, lowercase hex. No private material. */
|
|
38
35
|
publicKey: string | null;
|
|
39
36
|
digest: TSha256Digest;
|
|
40
37
|
}
|
|
41
38
|
|
|
42
|
-
export const
|
|
43
|
-
authorityDigestDomain: 'serve.zone/runtime-network-signing-authority
|
|
44
|
-
signatureDomain: 'serve.zone/runtime-network-projection-signature
|
|
39
|
+
export const runtimeNetworkSigningContract = Object.freeze({
|
|
40
|
+
authorityDigestDomain: 'serve.zone/runtime-network-signing-authority',
|
|
41
|
+
signatureDomain: 'serve.zone/runtime-network-projection-signature',
|
|
45
42
|
trust: 'current-authenticated-physical-session-and-durable-revision-fence',
|
|
46
43
|
rotation: 'replace-dns-authority-with-new-signed-projection',
|
|
47
44
|
revocation: 'no-implicit-packet-denial-or-allocation-reuse',
|
|
48
45
|
} as const);
|
|
49
46
|
|
|
50
|
-
export const
|
|
51
|
-
const item = networkRecord(captureNetwork(value), ['
|
|
52
|
-
requireNetwork(item.
|
|
47
|
+
export const snapshotRuntimeNetworkSigningAuthority = (value: unknown): IRuntimeNetworkSigningAuthority => networkSafe(() => {
|
|
48
|
+
const item = networkRecord(captureNetwork(value), ['id', 'generation', 'previous', 'controller', 'algorithm', 'publicKey', 'digest']);
|
|
49
|
+
requireNetwork(item.algorithm === 'Ed25519');
|
|
53
50
|
requireNetwork(item.publicKey === null || (typeof item.publicKey === 'string'
|
|
54
51
|
&& /^[a-f0-9]{64}$/.test(item.publicKey) && item.publicKey !== '0'.repeat(64)));
|
|
55
|
-
return {
|
|
52
|
+
return { ...networkRevision(item), controller: networkController(item.controller),
|
|
56
53
|
algorithm: 'Ed25519', publicKey: item.publicKey, digest: networkDigest(item.digest) };
|
|
57
54
|
});
|
|
58
55
|
|
|
59
|
-
export const
|
|
60
|
-
networkHash(
|
|
56
|
+
export const computeRuntimeNetworkSigningAuthorityDigest = (value: IRuntimeNetworkSigningAuthority): Promise<TSha256Digest> =>
|
|
57
|
+
networkHash(runtimeNetworkSigningContract.authorityDigestDomain, snapshotRuntimeNetworkSigningAuthority(value));
|
|
61
58
|
|
|
62
59
|
/**
|
|
63
60
|
* Detached content/CAS check. Caller must fence the live peer and commit atomically.
|
|
64
61
|
* A newly enrolled node bootstraps the controller's CURRENT authority at any generation;
|
|
65
62
|
* it must not fabricate local history or use this bootstrap path to erase existing trust.
|
|
66
63
|
*/
|
|
67
|
-
export const
|
|
64
|
+
export const admitRuntimeNetworkSigningAuthority = async (
|
|
68
65
|
value: unknown, previousValue: unknown | null, trustedSessionValue: unknown,
|
|
69
|
-
): Promise<{ status: 'accepted' | 'replay'; authority:
|
|
66
|
+
): Promise<{ status: 'accepted' | 'replay'; authority: IRuntimeNetworkSigningAuthority }> => {
|
|
70
67
|
try {
|
|
71
|
-
const authority =
|
|
72
|
-
const previous = previousValue === null ? null :
|
|
73
|
-
const session =
|
|
68
|
+
const authority = snapshotRuntimeNetworkSigningAuthority(value);
|
|
69
|
+
const previous = previousValue === null ? null : snapshotRuntimeNetworkSigningAuthority(previousValue);
|
|
70
|
+
const session = snapshotRuntimeSessionBinding(trustedSessionValue);
|
|
74
71
|
requireNetwork(networkEqual(authority.controller, session.controller));
|
|
75
|
-
requireNetwork(authority.digest === await
|
|
72
|
+
requireNetwork(authority.digest === await computeRuntimeNetworkSigningAuthorityDigest(authority));
|
|
76
73
|
if (previous === null) return { status: 'accepted', authority };
|
|
77
|
-
requireNetwork(previous.digest === await
|
|
74
|
+
requireNetwork(previous.digest === await computeRuntimeNetworkSigningAuthorityDigest(previous)
|
|
78
75
|
&& authority.id === previous.id && networkEqual(previous.controller, authority.controller));
|
|
79
76
|
if (authority.generation === previous.generation) {
|
|
80
77
|
requireNetwork(networkEqual(authority, previous)); return { status: 'replay', authority };
|
|
@@ -6,8 +6,7 @@ export type TNodeCredentialPurpose = 'spark' | 'pallet';
|
|
|
6
6
|
* hashes, socket peer IDs or controller process IDs. On replay this is historical
|
|
7
7
|
* evidence, not an assertion that a credential or reporter session is still live.
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
10
|
-
schemaVersion: 1;
|
|
9
|
+
export interface INodeCredentialMetadata {
|
|
11
10
|
nodeId: string;
|
|
12
11
|
purpose: TNodeCredentialPurpose;
|
|
13
12
|
state: 'active' | 'revoked';
|
|
@@ -25,8 +24,7 @@ export interface INodeCredentialMetadataV1 {
|
|
|
25
24
|
* preconditions, not minimums. Retrying must retain this complete input and the
|
|
26
25
|
* original mutationId; a changed request with the same ID must fail closed.
|
|
27
26
|
*/
|
|
28
|
-
export interface
|
|
29
|
-
schemaVersion: 1;
|
|
27
|
+
export interface INodeCredentialMutationPreconditions {
|
|
30
28
|
nodeId: string;
|
|
31
29
|
purpose: TNodeCredentialPurpose;
|
|
32
30
|
mutationId: string;
|
|
@@ -34,8 +32,8 @@ export interface INodeCredentialMutationPreconditionsV1 {
|
|
|
34
32
|
expectedSessionEpoch: number;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
export interface
|
|
38
|
-
metadata:
|
|
35
|
+
export interface INodeCredentialMutationResult {
|
|
36
|
+
metadata: INodeCredentialMetadata;
|
|
39
37
|
/** A replay returns the original result without restoring its authority. */
|
|
40
38
|
replayed: boolean;
|
|
41
39
|
}
|