@serve.zone/interfaces 30.6.0 → 30.8.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 +18 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/index.d.ts +4 -0
- package/dist_ts/data/index.js +5 -1
- package/dist_ts/data/networkauthority.d.ts +92 -0
- package/dist_ts/data/networkauthority.js +244 -0
- package/dist_ts/data/networkdelivery.d.ts +25 -0
- package/dist_ts/data/networkdelivery.js +38 -0
- package/dist_ts/data/networkprojection.d.ts +140 -0
- package/dist_ts/data/networkprojection.js +371 -0
- package/dist_ts/data/networksigning.d.ts +46 -0
- package/dist_ts/data/networksigning.js +52 -0
- package/dist_ts/private/networkcontract.d.ts +31 -0
- package/dist_ts/private/networkcontract.js +134 -0
- package/dist_ts/requests/runtimesession.d.ts +13 -0
- package/dist_ts/runtime.d.ts +1 -0
- package/dist_ts/runtime.js +2 -1
- package/dist_ts/runtime.networkprojection.d.ts +15 -0
- package/dist_ts/runtime.networkprojection.js +58 -0
- package/package.json +1 -1
- package/readme.md +103 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/index.ts +4 -0
- package/ts/data/networkauthority.ts +293 -0
- package/ts/data/networkdelivery.ts +58 -0
- package/ts/data/networkprojection.ts +448 -0
- package/ts/data/networksigning.ts +84 -0
- package/ts/private/networkcontract.ts +117 -0
- package/ts/requests/runtimesession.ts +19 -0
- package/ts/runtime.networkprojection.ts +64 -0
- package/ts/runtime.ts +1 -0
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import * as plugins from '../plugins.js';
|
|
2
2
|
import type * as data from '../data/runtimesession.js';
|
|
3
3
|
import type * as terminal from '../data/runtimeterminalreceipt.js';
|
|
4
|
+
import type * as network from '../data/networkdelivery.js';
|
|
5
|
+
|
|
6
|
+
/** Dedicated signing trust installed only through the current authenticated physical peer. */
|
|
7
|
+
export interface IReq_Controller_Pallet_ApplyRuntimeNetworkSigningAuthorityV1 extends plugins.typedrequestInterfaces.implementsTR<
|
|
8
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Controller_Pallet_ApplyRuntimeNetworkSigningAuthorityV1
|
|
9
|
+
> {
|
|
10
|
+
method: 'applyRuntimeNetworkSigningAuthorityV1';
|
|
11
|
+
request: network.IApplyRuntimeNetworkSigningAuthorityRequestV1;
|
|
12
|
+
response: network.IApplyRuntimeNetworkAuthorityResponseV1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Complete signed node state; an ACK asserts admission only. */
|
|
16
|
+
export interface IReq_Controller_Pallet_ApplyRuntimeNetworkProjectionV1 extends plugins.typedrequestInterfaces.implementsTR<
|
|
17
|
+
plugins.typedrequestInterfaces.ITypedRequest, IReq_Controller_Pallet_ApplyRuntimeNetworkProjectionV1
|
|
18
|
+
> {
|
|
19
|
+
method: 'applyRuntimeNetworkProjectionV1';
|
|
20
|
+
request: network.IApplyRuntimeNetworkProjectionRequestV1;
|
|
21
|
+
response: network.IApplyRuntimeNetworkAuthorityResponseV1;
|
|
22
|
+
}
|
|
4
23
|
|
|
5
24
|
/** WSS-only Pallet bootstrap. Derive physical peer/process/idempotency server-side. */
|
|
6
25
|
export interface IReq_Pallet_Cloudly_RegisterPalletRuntimeSessionV1 extends plugins.typedrequestInterfaces.implementsTR<
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as plugins from './plugins.runtime.js';
|
|
2
|
+
import type { IRuntimeAuthorityReferenceV1 } from './data/runtimeassignment.js';
|
|
3
|
+
import type { IRuntimeNetworkProjectionV1 } from './data/networkprojection.js';
|
|
4
|
+
import { snapshotRuntimeNetworkNodeScopeV1, snapshotRuntimeNetworkProjectionV1, validateRuntimeNetworkProjectionV1 } from './data/networkprojection.js';
|
|
5
|
+
import type { IRuntimeNetworkSigningAuthorityV1, ISignedRuntimeNetworkProjectionV1 } from './data/networksigning.js';
|
|
6
|
+
import { computeRuntimeNetworkSigningAuthorityV1Digest, runtimeNetworkSigningV1Contract,
|
|
7
|
+
snapshotRuntimeNetworkSigningAuthorityV1, snapshotSignedRuntimeNetworkProjectionV1 } from './data/networksigning.js';
|
|
8
|
+
import { failNetwork, networkCanonical, networkEqual, networkReferenceOf, requireNetwork } from './private/networkcontract.js';
|
|
9
|
+
|
|
10
|
+
/** The private KeyObject is process-local. Persist only through the controller's encrypted secret store. */
|
|
11
|
+
export const createRuntimeNetworkSigningKeyV1 = (): { publicKey: string; privateKey: plugins.crypto.KeyObject } => {
|
|
12
|
+
const pair = plugins.crypto.generateKeyPairSync('ed25519');
|
|
13
|
+
const jwk = pair.publicKey.export({ format: 'jwk' });
|
|
14
|
+
requireNetwork(jwk.kty === 'OKP' && jwk.crv === 'Ed25519' && typeof jwk.x === 'string');
|
|
15
|
+
return { publicKey: Buffer.from(jwk.x, 'base64url').toString('hex'), privateKey: pair.privateKey };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const signatureBytes = (authority: IRuntimeAuthorityReferenceV1, projection: IRuntimeNetworkProjectionV1): Uint8Array =>
|
|
19
|
+
new TextEncoder().encode(networkCanonical({ domain: runtimeNetworkSigningV1Contract.signatureDomain, schemaVersion: 1, authority, projection }));
|
|
20
|
+
const validateAuthority = async (authority: IRuntimeNetworkSigningAuthorityV1, projection: IRuntimeNetworkProjectionV1): Promise<void> => {
|
|
21
|
+
requireNetwork(authority.publicKey !== null && networkEqual(authority.controller, projection.controller)
|
|
22
|
+
&& authority.digest === await computeRuntimeNetworkSigningAuthorityV1Digest(authority));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** Sign only validated complete state and a matching dedicated private key. */
|
|
26
|
+
export const signRuntimeNetworkProjectionV1 = async (
|
|
27
|
+
projectionValue: unknown, authorityValue: unknown, privateKey: plugins.crypto.KeyObject,
|
|
28
|
+
): Promise<ISignedRuntimeNetworkProjectionV1> => {
|
|
29
|
+
try {
|
|
30
|
+
const input = snapshotRuntimeNetworkProjectionV1(projectionValue), authority = snapshotRuntimeNetworkSigningAuthorityV1(authorityValue);
|
|
31
|
+
requireNetwork(privateKey instanceof plugins.crypto.KeyObject && privateKey.type === 'private' && privateKey.asymmetricKeyType === 'ed25519');
|
|
32
|
+
const publicKey = plugins.crypto.createPublicKey(privateKey).export({ format: 'jwk' });
|
|
33
|
+
requireNetwork(typeof publicKey.x === 'string' && Buffer.from(publicKey.x, 'base64url').toString('hex') === authority.publicKey);
|
|
34
|
+
const projection = await validateRuntimeNetworkProjectionV1(input);
|
|
35
|
+
await validateAuthority(authority, projection);
|
|
36
|
+
const reference = networkReferenceOf(authority);
|
|
37
|
+
const signature = plugins.crypto.sign(null, signatureBytes(reference, projection), privateKey).toString('hex');
|
|
38
|
+
return { schemaVersion: 1, authority: reference, projection, signature };
|
|
39
|
+
} catch { return failNetwork(); }
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* trustedAuthorityValue is receiver-owned persisted trust, NEVER envelope material.
|
|
44
|
+
* This verifies content/scope/signature only. The owner still performs atomic revision
|
|
45
|
+
* admission, live-session fencing, allocation barriers and conservative DNS time checks.
|
|
46
|
+
*/
|
|
47
|
+
export const verifyRuntimeNetworkProjectionV1 = async (
|
|
48
|
+
value: unknown, trustedAuthorityValue: unknown, trustedScopeValue: unknown,
|
|
49
|
+
): Promise<ISignedRuntimeNetworkProjectionV1> => {
|
|
50
|
+
try {
|
|
51
|
+
const signed = snapshotSignedRuntimeNetworkProjectionV1(value);
|
|
52
|
+
const authority = snapshotRuntimeNetworkSigningAuthorityV1(trustedAuthorityValue);
|
|
53
|
+
const trusted = snapshotRuntimeNetworkNodeScopeV1(trustedScopeValue);
|
|
54
|
+
requireNetwork(networkEqual(signed.authority, networkReferenceOf(authority))
|
|
55
|
+
&& signed.projection.nodeId === trusted.nodeId && signed.projection.runtimeNamespace === trusted.runtimeNamespace
|
|
56
|
+
&& networkEqual(signed.projection.controller, trusted.controller));
|
|
57
|
+
await validateAuthority(authority, signed.projection);
|
|
58
|
+
const key = plugins.crypto.createPublicKey({ format: 'jwk', key: { kty: 'OKP', crv: 'Ed25519',
|
|
59
|
+
x: Buffer.from(authority.publicKey!, 'hex').toString('base64url') } });
|
|
60
|
+
requireNetwork(plugins.crypto.verify(null, signatureBytes(signed.authority, signed.projection), key, Buffer.from(signed.signature, 'hex')));
|
|
61
|
+
await validateRuntimeNetworkProjectionV1(signed.projection);
|
|
62
|
+
return signed;
|
|
63
|
+
} catch { return failNetwork(); }
|
|
64
|
+
};
|
package/ts/runtime.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
} from './runtime.workloadinit.js';
|
|
40
40
|
|
|
41
41
|
export * from './runtime.workloadinit.js';
|
|
42
|
+
export * from './runtime.networkprojection.js';
|
|
42
43
|
export * from './runtime.corestore.js';
|
|
43
44
|
export * from './runtime.corestore.databaseexportpackage.js';
|
|
44
45
|
export * from './runtime.cloudlylegacydeploymentsettlement.js';
|