@serve.zone/interfaces 27.5.0 → 28.1.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 +28 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/index.d.ts +2 -0
- package/dist_ts/data/index.js +3 -1
- package/dist_ts/data/nodecredential.d.ts +38 -0
- package/dist_ts/data/nodecredential.js +2 -0
- package/dist_ts/data/nodeenrollment.d.ts +95 -0
- package/dist_ts/data/nodeenrollment.js +186 -0
- package/dist_ts/requests/node.d.ts +58 -1
- package/package.json +1 -1
- package/readme.md +59 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/index.ts +2 -0
- package/ts/data/nodecredential.ts +41 -0
- package/ts/data/nodeenrollment.ts +270 -0
- package/ts/requests/node.ts +87 -1
package/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-09-06 - 28.1.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- add independent node enrollment contracts (node-enrollment)
|
|
8
|
+
- Export node enrollment data interfaces and helpers for strict snapshots, canonical digests, proof verification, acknowledgement binding, and state snapshots.
|
|
9
|
+
- Add node TypedRequest contracts for enrollment state checks and node enrollment transactions.
|
|
10
|
+
- Document node enrollment semantics and add tests for digest binding, proof validation, acknowledgement validation, and TypedRequest ownership.
|
|
11
|
+
|
|
12
|
+
### Fixes
|
|
13
|
+
|
|
14
|
+
- use qualified pnpm 11.25.0 for exact release packaging (package)
|
|
15
|
+
- Select the GitZone-qualified version permitted by the existing release-age policy.
|
|
16
|
+
- Remove the inactive pnpm 12 bootstrap lock document without changing application dependencies.
|
|
17
|
+
- clarify pnpm release packaging changelog entry (changelog)
|
|
18
|
+
- Consolidates duplicate pnpm pinning notes into a single package fix entry.
|
|
19
|
+
- Documents qualified pnpm 11.25.0 selection for release packaging.
|
|
20
|
+
|
|
21
|
+
## 2026-09-05 - 28.0.0
|
|
22
|
+
|
|
23
|
+
### Breaking Changes
|
|
24
|
+
|
|
25
|
+
- require identity for node config and add credential administration contracts (node-credentials)
|
|
26
|
+
- Add node credential metadata, mutation precondition, and mutation result interfaces for spark and pallet purposes.
|
|
27
|
+
- Add getNodeCredential, rotateNodeCredential, and revokeNodeCredential typed request contracts with infrastructure-admin identity requirements.
|
|
28
|
+
- Require identity on getNodeConfig requests, changing the existing request shape.
|
|
29
|
+
- Document node credential administration semantics and add type-level contract tests.
|
|
30
|
+
|
|
3
31
|
## 2026-09-05 - 27.5.0
|
|
4
32
|
|
|
5
33
|
### Features
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@serve.zone/interfaces',
|
|
6
|
-
version: '
|
|
6
|
+
version: '28.1.0',
|
|
7
7
|
description: 'Shared TypeScript interfaces and TypedRequest contracts for the serve.zone ecosystem.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLHVGQUF1RjtDQUNyRyxDQUFBIn0=
|
package/dist_ts/data/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export * from './immutableimage.js';
|
|
|
20
20
|
export * from './isolatedrestore.js';
|
|
21
21
|
export * from './isolatedrestore.golden.js';
|
|
22
22
|
export * from './mail.js';
|
|
23
|
+
export * from './nodecredential.js';
|
|
24
|
+
export * from './nodeenrollment.js';
|
|
23
25
|
export * from './registry.js';
|
|
24
26
|
export * from './runtimeassignment.js';
|
|
25
27
|
export * from './secret.js';
|
package/dist_ts/data/index.js
CHANGED
|
@@ -20,6 +20,8 @@ export * from './immutableimage.js';
|
|
|
20
20
|
export * from './isolatedrestore.js';
|
|
21
21
|
export * from './isolatedrestore.golden.js';
|
|
22
22
|
export * from './mail.js';
|
|
23
|
+
export * from './nodecredential.js';
|
|
24
|
+
export * from './nodeenrollment.js';
|
|
23
25
|
export * from './registry.js';
|
|
24
26
|
export * from './runtimeassignment.js';
|
|
25
27
|
export * from './secret.js';
|
|
@@ -36,4 +38,4 @@ export * from './traffic.js';
|
|
|
36
38
|
export * from './user.js';
|
|
37
39
|
export * from './version.js';
|
|
38
40
|
export * from './webpush.js';
|
|
39
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9kYXRhL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxlQUFlLENBQUM7QUFDOUIsY0FBYyx1QkFBdUIsQ0FBQztBQUN0QyxjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMseUJBQXlCLENBQUM7QUFDeEMsY0FBYywwQkFBMEIsQ0FBQztBQUN6QyxjQUFjLDBCQUEwQixDQUFDO0FBQ3pDLGNBQWMsZ0JBQWdCLENBQUM7QUFDL0IsY0FBYyxVQUFVLENBQUM7QUFDekIsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxZQUFZLENBQUM7QUFDM0IsY0FBYyx1QkFBdUIsQ0FBQztBQUN0QyxjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLGdCQUFnQixDQUFDO0FBQy9CLGNBQWMsWUFBWSxDQUFDO0FBQzNCLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxzQkFBc0IsQ0FBQztBQUNyQyxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMscUJBQXFCLENBQUM7QUFDcEMsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLHdCQUF3QixDQUFDO0FBQ3ZDLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsZ0JBQWdCLENBQUM7QUFDL0IsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxrQkFBa0IsQ0FBQztBQUNqQyxjQUFjLGVBQWUsQ0FBQztBQUM5QixjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsYUFBYSxDQUFDO0FBQzVCLGNBQWMsb0JBQW9CLENBQUM7QUFDbkMsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxXQUFXLENBQUM7QUFDMUIsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxjQUFjLENBQUMifQ==
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Independent infrastructure credentials; neither purpose grants workload RBAC. */
|
|
2
|
+
export type TNodeCredentialPurpose = 'spark' | 'pallet';
|
|
3
|
+
/**
|
|
4
|
+
* Public inspection and mutation-result metadata. Never includes bearer material,
|
|
5
|
+
* hashes, socket peer IDs or controller process IDs. On replay this is historical
|
|
6
|
+
* evidence, not an assertion that a credential or reporter session is still live.
|
|
7
|
+
*/
|
|
8
|
+
export interface INodeCredentialMetadataV1 {
|
|
9
|
+
schemaVersion: 1;
|
|
10
|
+
nodeId: string;
|
|
11
|
+
purpose: TNodeCredentialPurpose;
|
|
12
|
+
state: 'active' | 'revoked';
|
|
13
|
+
generation: number;
|
|
14
|
+
/** Migrated Spark credentials remain usable only until their staged rotation. */
|
|
15
|
+
requiresRotation: boolean;
|
|
16
|
+
sessionEpoch: number;
|
|
17
|
+
sessionId: string | null;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
updatedAt: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Infrastructure-admin mutation preconditions. Both counters are exact CAS
|
|
23
|
+
* preconditions, not minimums. Retrying must retain this complete input and the
|
|
24
|
+
* original mutationId; a changed request with the same ID must fail closed.
|
|
25
|
+
*/
|
|
26
|
+
export interface INodeCredentialMutationPreconditionsV1 {
|
|
27
|
+
schemaVersion: 1;
|
|
28
|
+
nodeId: string;
|
|
29
|
+
purpose: TNodeCredentialPurpose;
|
|
30
|
+
mutationId: string;
|
|
31
|
+
expectedGeneration: number;
|
|
32
|
+
expectedSessionEpoch: number;
|
|
33
|
+
}
|
|
34
|
+
export interface INodeCredentialMutationResultV1 {
|
|
35
|
+
metadata: INodeCredentialMetadataV1;
|
|
36
|
+
/** A replay returns the original result without restoring its authority. */
|
|
37
|
+
replayed: boolean;
|
|
38
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { TNodeCredentialPurpose } from './nodecredential.js';
|
|
2
|
+
export interface INodeEnrollmentCredentialProposalV1 {
|
|
3
|
+
purpose: TNodeCredentialPurpose;
|
|
4
|
+
installationId: string;
|
|
5
|
+
mutationId: string;
|
|
6
|
+
/** SHA-256 of the independently generated, durably prepared bearer UTF-8 bytes. */
|
|
7
|
+
tokenHash: string;
|
|
8
|
+
expectedGeneration: number;
|
|
9
|
+
expectedSessionEpoch: number;
|
|
10
|
+
}
|
|
11
|
+
/** Value-free, immutable proposal. Hashes are still sensitive transport fields. */
|
|
12
|
+
export interface INodeEnrollmentV1 {
|
|
13
|
+
schemaVersion: 1;
|
|
14
|
+
/** 32 CSPRNG bytes encoded as lowercase hexadecimal; retain across every retry. */
|
|
15
|
+
enrollmentId: string;
|
|
16
|
+
cloudlyOrigin: string;
|
|
17
|
+
hostname: string;
|
|
18
|
+
bootstrap: {
|
|
19
|
+
kind: 'jump';
|
|
20
|
+
proofHash: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'adopt-existing';
|
|
23
|
+
nodeId: string;
|
|
24
|
+
proofHash: string;
|
|
25
|
+
};
|
|
26
|
+
credentials: [
|
|
27
|
+
INodeEnrollmentCredentialProposalV1 & {
|
|
28
|
+
purpose: 'spark';
|
|
29
|
+
},
|
|
30
|
+
INodeEnrollmentCredentialProposalV1 & {
|
|
31
|
+
purpose: 'pallet';
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
export interface INodeEnrollmentRequestV1 {
|
|
36
|
+
enrollment: INodeEnrollmentV1;
|
|
37
|
+
/** Never persist on the server, log, put in URLs, or expose in transport hooks. */
|
|
38
|
+
proof: {
|
|
39
|
+
kind: 'bootstrap' | 'pending-spark';
|
|
40
|
+
bearer: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface INodeEnrollmentCredentialAcknowledgementV1 {
|
|
44
|
+
purpose: TNodeCredentialPurpose;
|
|
45
|
+
installationId: string;
|
|
46
|
+
mutationId: string;
|
|
47
|
+
tokenHash: string;
|
|
48
|
+
generation: number;
|
|
49
|
+
}
|
|
50
|
+
/** Immutable commit evidence, not authorization or workload readiness. */
|
|
51
|
+
export interface INodeEnrollmentAcknowledgementV1 {
|
|
52
|
+
schemaVersion: 1;
|
|
53
|
+
enrollmentId: string;
|
|
54
|
+
cloudlyOrigin: string;
|
|
55
|
+
nodeId: string;
|
|
56
|
+
requestDigest: string;
|
|
57
|
+
credentials: [
|
|
58
|
+
INodeEnrollmentCredentialAcknowledgementV1 & {
|
|
59
|
+
purpose: 'spark';
|
|
60
|
+
},
|
|
61
|
+
INodeEnrollmentCredentialAcknowledgementV1 & {
|
|
62
|
+
purpose: 'pallet';
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
/** Returned only after current Spark authentication and proof that Pallet is absent. */
|
|
67
|
+
export interface INodeEnrollmentStateV1 {
|
|
68
|
+
schemaVersion: 1;
|
|
69
|
+
nodeId: string;
|
|
70
|
+
spark: {
|
|
71
|
+
generation: number;
|
|
72
|
+
sessionEpoch: number;
|
|
73
|
+
};
|
|
74
|
+
pallet: 'absent';
|
|
75
|
+
}
|
|
76
|
+
export declare const nodeEnrollmentV1Contract: Readonly<{
|
|
77
|
+
readonly digestDomain: "serve.zone/node-enrollment-v1";
|
|
78
|
+
readonly localActivation: "independently-durable-convergence";
|
|
79
|
+
readonly bootstrapProof: "first-commit-only";
|
|
80
|
+
readonly pendingSparkProof: "committed-exact-receipt-only";
|
|
81
|
+
}>;
|
|
82
|
+
/** Detached frozen snapshot, captured synchronously before hashing or other awaits. */
|
|
83
|
+
export declare const snapshotNodeEnrollmentV1: (valueArg: unknown) => INodeEnrollmentV1;
|
|
84
|
+
export declare const computeNodeEnrollmentV1Digest: (valueArg: INodeEnrollmentV1) => Promise<string>;
|
|
85
|
+
export declare const snapshotNodeEnrollmentRequestV1: (valueArg: unknown) => INodeEnrollmentRequestV1;
|
|
86
|
+
/**
|
|
87
|
+
* Pure proof binding/mode check only, NOT authentication. The server must derive
|
|
88
|
+
* receiptState from its owned transaction, compare the complete stored proposal,
|
|
89
|
+
* and fence current Jump/Spark/Pallet authority before any commit or replay.
|
|
90
|
+
*/
|
|
91
|
+
export declare const verifyNodeEnrollmentProofV1: (valueArg: INodeEnrollmentRequestV1, receiptStateArg: "absent" | "committed") => Promise<boolean>;
|
|
92
|
+
export declare const snapshotNodeEnrollmentAcknowledgementV1: (valueArg: unknown) => INodeEnrollmentAcknowledgementV1;
|
|
93
|
+
/** Content binding only. Authenticate Cloudly first; persist only the returned snapshot. */
|
|
94
|
+
export declare const bindNodeEnrollmentAcknowledgementV1: (enrollmentArg: INodeEnrollmentV1, acknowledgementArg: INodeEnrollmentAcknowledgementV1) => Promise<INodeEnrollmentAcknowledgementV1>;
|
|
95
|
+
export declare const snapshotNodeEnrollmentStateV1: (valueArg: unknown) => INodeEnrollmentStateV1;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { canonicalizeStrictJson, createCanonicalJsonSha256Hex, createSha256Hex, deepFreezeValue, } from '../private/canonicaljson.js';
|
|
2
|
+
export const nodeEnrollmentV1Contract = Object.freeze({
|
|
3
|
+
digestDomain: 'serve.zone/node-enrollment-v1',
|
|
4
|
+
localActivation: 'independently-durable-convergence',
|
|
5
|
+
bootstrapProof: 'first-commit-only',
|
|
6
|
+
pendingSparkProof: 'committed-exact-receipt-only',
|
|
7
|
+
});
|
|
8
|
+
const fail = () => { throw new Error('Node enrollment contract rejected.'); };
|
|
9
|
+
function requireValue(valueArg) {
|
|
10
|
+
if (!valueArg)
|
|
11
|
+
fail();
|
|
12
|
+
}
|
|
13
|
+
/** Decoded JSON/data records only. No input accessor is executed or preserved. */
|
|
14
|
+
const record = (valueArg, keysArg) => {
|
|
15
|
+
requireValue(valueArg !== null && typeof valueArg === 'object' && !Array.isArray(valueArg));
|
|
16
|
+
const prototype = Object.getPrototypeOf(valueArg);
|
|
17
|
+
requireValue(prototype === Object.prototype || prototype === null);
|
|
18
|
+
const keys = Reflect.ownKeys(valueArg);
|
|
19
|
+
requireValue(keys.length === keysArg.length);
|
|
20
|
+
const snapshot = Object.create(null);
|
|
21
|
+
for (const key of keys) {
|
|
22
|
+
requireValue(typeof key === 'string' && keysArg.includes(key));
|
|
23
|
+
const descriptor = Object.getOwnPropertyDescriptor(valueArg, key);
|
|
24
|
+
requireValue(descriptor?.enumerable && Object.hasOwn(descriptor, 'value'));
|
|
25
|
+
snapshot[key] = descriptor.value;
|
|
26
|
+
}
|
|
27
|
+
return snapshot;
|
|
28
|
+
};
|
|
29
|
+
const pair = (valueArg) => {
|
|
30
|
+
requireValue(Array.isArray(valueArg) && Object.getPrototypeOf(valueArg) === Array.prototype);
|
|
31
|
+
requireValue(Reflect.ownKeys(valueArg).length === 3 && valueArg.length === 2);
|
|
32
|
+
const first = Object.getOwnPropertyDescriptor(valueArg, '0');
|
|
33
|
+
const second = Object.getOwnPropertyDescriptor(valueArg, '1');
|
|
34
|
+
requireValue(first?.enumerable && Object.hasOwn(first, 'value'));
|
|
35
|
+
requireValue(second?.enumerable && Object.hasOwn(second, 'value'));
|
|
36
|
+
return [first.value, second.value];
|
|
37
|
+
};
|
|
38
|
+
const id = (valueArg) => {
|
|
39
|
+
requireValue(typeof valueArg === 'string' && /^[A-Za-z0-9_-]{1,128}$/.test(valueArg));
|
|
40
|
+
return valueArg;
|
|
41
|
+
};
|
|
42
|
+
const hash = (valueArg) => {
|
|
43
|
+
requireValue(typeof valueArg === 'string' && /^[a-f0-9]{64}$/.test(valueArg));
|
|
44
|
+
return valueArg;
|
|
45
|
+
};
|
|
46
|
+
const counter = (valueArg, minimumArg = 0, incrementArg = false) => {
|
|
47
|
+
requireValue(typeof valueArg === 'number' && Number.isSafeInteger(valueArg)
|
|
48
|
+
&& !Object.is(valueArg, -0) && valueArg >= minimumArg
|
|
49
|
+
&& (!incrementArg || valueArg < Number.MAX_SAFE_INTEGER));
|
|
50
|
+
return valueArg;
|
|
51
|
+
};
|
|
52
|
+
const origin = (valueArg) => {
|
|
53
|
+
requireValue(typeof valueArg === 'string' && valueArg.length <= 2048);
|
|
54
|
+
let url;
|
|
55
|
+
try {
|
|
56
|
+
url = new URL(valueArg);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return fail();
|
|
60
|
+
}
|
|
61
|
+
requireValue(url.protocol === 'https:' && !url.username && !url.password && url.origin === valueArg);
|
|
62
|
+
return valueArg;
|
|
63
|
+
};
|
|
64
|
+
const hostname = (valueArg) => {
|
|
65
|
+
requireValue(typeof valueArg === 'string' && valueArg.length <= 253 && valueArg.length > 0);
|
|
66
|
+
requireValue(valueArg.split('.').every((labelArg) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(labelArg)));
|
|
67
|
+
return valueArg;
|
|
68
|
+
};
|
|
69
|
+
const proposal = (valueArg, purposeArg) => {
|
|
70
|
+
const value = record(valueArg, ['purpose', 'installationId', 'mutationId', 'tokenHash',
|
|
71
|
+
'expectedGeneration', 'expectedSessionEpoch']);
|
|
72
|
+
requireValue(value.purpose === purposeArg);
|
|
73
|
+
return { purpose: purposeArg, installationId: id(value.installationId), mutationId: id(value.mutationId),
|
|
74
|
+
tokenHash: hash(value.tokenHash), expectedGeneration: counter(value.expectedGeneration, 0, true),
|
|
75
|
+
expectedSessionEpoch: counter(value.expectedSessionEpoch, 0, true) };
|
|
76
|
+
};
|
|
77
|
+
const distinctOwners = (sparkArg, palletArg) => {
|
|
78
|
+
requireValue(sparkArg.installationId !== palletArg.installationId
|
|
79
|
+
&& sparkArg.mutationId !== palletArg.mutationId && sparkArg.tokenHash !== palletArg.tokenHash);
|
|
80
|
+
};
|
|
81
|
+
/** Detached frozen snapshot, captured synchronously before hashing or other awaits. */
|
|
82
|
+
export const snapshotNodeEnrollmentV1 = (valueArg) => {
|
|
83
|
+
const value = record(valueArg, ['schemaVersion', 'enrollmentId', 'cloudlyOrigin', 'hostname',
|
|
84
|
+
'bootstrap', 'credentials']);
|
|
85
|
+
requireValue(value.schemaVersion === 1);
|
|
86
|
+
// Read the discriminant from its data descriptor, never an input getter.
|
|
87
|
+
requireValue(value.bootstrap !== null && typeof value.bootstrap === 'object');
|
|
88
|
+
const kind = Object.getOwnPropertyDescriptor(value.bootstrap, 'kind');
|
|
89
|
+
requireValue(kind && Object.hasOwn(kind, 'value'));
|
|
90
|
+
const bootstrap = record(value.bootstrap, kind.value === 'jump'
|
|
91
|
+
? ['kind', 'proofHash'] : ['kind', 'nodeId', 'proofHash']);
|
|
92
|
+
requireValue(bootstrap.kind === 'jump' || bootstrap.kind === 'adopt-existing');
|
|
93
|
+
const [sparkInput, palletInput] = pair(value.credentials);
|
|
94
|
+
const spark = proposal(sparkInput, 'spark');
|
|
95
|
+
const pallet = proposal(palletInput, 'pallet');
|
|
96
|
+
distinctOwners(spark, pallet);
|
|
97
|
+
requireValue(pallet.expectedGeneration === 0 && pallet.expectedSessionEpoch === 0);
|
|
98
|
+
requireValue(bootstrap.kind === 'jump'
|
|
99
|
+
? spark.expectedGeneration === 0 && spark.expectedSessionEpoch === 0
|
|
100
|
+
: spark.expectedGeneration > 0);
|
|
101
|
+
return deepFreezeValue({ schemaVersion: 1, enrollmentId: hash(value.enrollmentId),
|
|
102
|
+
cloudlyOrigin: origin(value.cloudlyOrigin), hostname: hostname(value.hostname),
|
|
103
|
+
bootstrap: bootstrap.kind === 'jump'
|
|
104
|
+
? { kind: 'jump', proofHash: hash(bootstrap.proofHash) }
|
|
105
|
+
: { kind: 'adopt-existing', nodeId: id(bootstrap.nodeId), proofHash: hash(bootstrap.proofHash) },
|
|
106
|
+
credentials: [spark, pallet] });
|
|
107
|
+
};
|
|
108
|
+
export const computeNodeEnrollmentV1Digest = async (valueArg) => {
|
|
109
|
+
const payload = snapshotNodeEnrollmentV1(valueArg);
|
|
110
|
+
return createCanonicalJsonSha256Hex(canonicalizeStrictJson({
|
|
111
|
+
domain: nodeEnrollmentV1Contract.digestDomain, payload,
|
|
112
|
+
}, fail), fail);
|
|
113
|
+
};
|
|
114
|
+
export const snapshotNodeEnrollmentRequestV1 = (valueArg) => {
|
|
115
|
+
const value = record(valueArg, ['enrollment', 'proof']);
|
|
116
|
+
const enrollment = snapshotNodeEnrollmentV1(value.enrollment);
|
|
117
|
+
const proof = record(value.proof, ['kind', 'bearer']);
|
|
118
|
+
requireValue(proof.kind === 'bootstrap' || proof.kind === 'pending-spark');
|
|
119
|
+
requireValue(typeof proof.bearer === 'string');
|
|
120
|
+
requireValue(proof.kind === 'bootstrap' && enrollment.bootstrap.kind === 'jump'
|
|
121
|
+
? /^[A-Za-z0-9_-]{16}$/.test(proof.bearer) : /^secureToken[a-f0-9]{64}$/.test(proof.bearer));
|
|
122
|
+
return deepFreezeValue({ enrollment, proof: { kind: proof.kind, bearer: proof.bearer } });
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Pure proof binding/mode check only, NOT authentication. The server must derive
|
|
126
|
+
* receiptState from its owned transaction, compare the complete stored proposal,
|
|
127
|
+
* and fence current Jump/Spark/Pallet authority before any commit or replay.
|
|
128
|
+
*/
|
|
129
|
+
export const verifyNodeEnrollmentProofV1 = async (valueArg, receiptStateArg) => {
|
|
130
|
+
try {
|
|
131
|
+
const { enrollment, proof } = snapshotNodeEnrollmentRequestV1(valueArg);
|
|
132
|
+
if (!(proof.kind === 'bootstrap' && receiptStateArg === 'absent')
|
|
133
|
+
&& !(proof.kind === 'pending-spark' && receiptStateArg === 'committed'))
|
|
134
|
+
return false;
|
|
135
|
+
// This helper hashes exact UTF-8 text; no JSON quoting or normalization.
|
|
136
|
+
const actual = await createSha256Hex(new TextEncoder().encode(proof.bearer), fail);
|
|
137
|
+
return actual === (proof.kind === 'bootstrap'
|
|
138
|
+
? enrollment.bootstrap.proofHash : enrollment.credentials[0].tokenHash);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const credentialAcknowledgement = (valueArg, purposeArg) => {
|
|
145
|
+
const value = record(valueArg, ['purpose', 'installationId', 'mutationId', 'tokenHash', 'generation']);
|
|
146
|
+
requireValue(value.purpose === purposeArg);
|
|
147
|
+
return { purpose: purposeArg, installationId: id(value.installationId), mutationId: id(value.mutationId),
|
|
148
|
+
tokenHash: hash(value.tokenHash), generation: counter(value.generation, 1) };
|
|
149
|
+
};
|
|
150
|
+
export const snapshotNodeEnrollmentAcknowledgementV1 = (valueArg) => {
|
|
151
|
+
const value = record(valueArg, ['schemaVersion', 'enrollmentId', 'cloudlyOrigin', 'nodeId',
|
|
152
|
+
'requestDigest', 'credentials']);
|
|
153
|
+
requireValue(value.schemaVersion === 1);
|
|
154
|
+
const [sparkInput, palletInput] = pair(value.credentials);
|
|
155
|
+
const spark = credentialAcknowledgement(sparkInput, 'spark');
|
|
156
|
+
const pallet = credentialAcknowledgement(palletInput, 'pallet');
|
|
157
|
+
distinctOwners(spark, pallet);
|
|
158
|
+
requireValue(pallet.generation === 1);
|
|
159
|
+
return deepFreezeValue({ schemaVersion: 1, enrollmentId: hash(value.enrollmentId),
|
|
160
|
+
cloudlyOrigin: origin(value.cloudlyOrigin), nodeId: id(value.nodeId),
|
|
161
|
+
requestDigest: hash(value.requestDigest), credentials: [spark, pallet] });
|
|
162
|
+
};
|
|
163
|
+
/** Content binding only. Authenticate Cloudly first; persist only the returned snapshot. */
|
|
164
|
+
export const bindNodeEnrollmentAcknowledgementV1 = async (enrollmentArg, acknowledgementArg) => {
|
|
165
|
+
const enrollment = snapshotNodeEnrollmentV1(enrollmentArg);
|
|
166
|
+
const ack = snapshotNodeEnrollmentAcknowledgementV1(acknowledgementArg);
|
|
167
|
+
requireValue(ack.enrollmentId === enrollment.enrollmentId && ack.cloudlyOrigin === enrollment.cloudlyOrigin
|
|
168
|
+
&& (enrollment.bootstrap.kind === 'jump' || ack.nodeId === enrollment.bootstrap.nodeId));
|
|
169
|
+
for (const index of [0, 1]) {
|
|
170
|
+
const expected = enrollment.credentials[index];
|
|
171
|
+
const actual = ack.credentials[index];
|
|
172
|
+
requireValue(actual.purpose === expected.purpose && actual.installationId === expected.installationId
|
|
173
|
+
&& actual.mutationId === expected.mutationId && actual.tokenHash === expected.tokenHash
|
|
174
|
+
&& actual.generation === expected.expectedGeneration + 1);
|
|
175
|
+
}
|
|
176
|
+
requireValue(ack.requestDigest === await computeNodeEnrollmentV1Digest(enrollment));
|
|
177
|
+
return ack;
|
|
178
|
+
};
|
|
179
|
+
export const snapshotNodeEnrollmentStateV1 = (valueArg) => {
|
|
180
|
+
const value = record(valueArg, ['schemaVersion', 'nodeId', 'spark', 'pallet']);
|
|
181
|
+
requireValue(value.schemaVersion === 1 && value.pallet === 'absent');
|
|
182
|
+
const spark = record(value.spark, ['generation', 'sessionEpoch']);
|
|
183
|
+
return deepFreezeValue({ schemaVersion: 1, nodeId: id(value.nodeId), pallet: 'absent',
|
|
184
|
+
spark: { generation: counter(spark.generation, 1, true), sessionEpoch: counter(spark.sessionEpoch, 0, true) } });
|
|
185
|
+
};
|
|
186
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9kZWVucm9sbG1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9kYXRhL25vZGVlbnJvbGxtZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFDTCxzQkFBc0IsRUFDdEIsNEJBQTRCLEVBQzVCLGVBQWUsRUFDZixlQUFlLEdBQ2hCLE1BQU0sNkJBQTZCLENBQUM7QUErRHJDLE1BQU0sQ0FBQyxNQUFNLHdCQUF3QixHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUM7SUFDcEQsWUFBWSxFQUFFLCtCQUErQjtJQUM3QyxlQUFlLEVBQUUsbUNBQW1DO0lBQ3BELGNBQWMsRUFBRSxtQkFBbUI7SUFDbkMsaUJBQWlCLEVBQUUsOEJBQThCO0NBQ3pDLENBQUMsQ0FBQztBQUVaLE1BQU0sSUFBSSxHQUFHLEdBQVUsRUFBRSxHQUFHLE1BQU0sSUFBSSxLQUFLLENBQUMsb0NBQW9DLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUNyRixTQUFTLFlBQVksQ0FBQyxRQUFpQjtJQUNyQyxJQUFJLENBQUMsUUFBUTtRQUFFLElBQUksRUFBRSxDQUFDO0FBQ3hCLENBQUM7QUFFRCxrRkFBa0Y7QUFDbEYsTUFBTSxNQUFNLEdBQUcsQ0FBQyxRQUFpQixFQUFFLE9BQTBCLEVBQTJCLEVBQUU7SUFDeEYsWU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BQUMsYUFBYSxLQUFLLENBQUMsSUFBSSxLQUFLLENBQUMsTUFBTSxLQUFLLFFBQVEsQ0FBQyxDQUFDO0lBQ3JFLE1BQU0sS0FBSyxHQUFHLE1BQU0sQ0FBQyxLQUFLLENBQUMsS0FBSyxFQUFFLENBQUMsWUFBWSxFQUFFLGNBQWMsQ0FBQyxDQUFDLENBQUM7SUFDbEUsT0FBTyxlQUFlLENBQUMsRUFBRSxhQUFhLEVBQUUsQ0FBQyxFQUFFLE1BQU0sRUFBRSxFQUFFLENBQUMsS0FBSyxDQUFDLE1BQU0sQ0FBQyxFQUFFLE1BQU0sRUFBRSxRQUFRO1FBQ25GLEtBQUssRUFBRSxFQUFFLFVBQVUsRUFBRSxPQUFPLENBQUMsS0FBSyxDQUFDLFVBQVUsRUFBRSxDQUFDLEVBQUUsSUFBSSxDQUFDLEVBQUUsWUFBWSxFQUFFLE9BQU8sQ0FBQyxLQUFLLENBQUMsWUFBWSxFQUFFLENBQUMsRUFBRSxJQUFJLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQztBQUNySCxDQUFDLENBQUMifQ==
|
|
@@ -4,15 +4,72 @@ import type { ICluster } from '../data/cluster.js';
|
|
|
4
4
|
import type { IClusterNode, IClusterNodeMetrics, INodeAction, INodeMetricsSample, ISparkNodeRuntimeInfo, TNodeActionName } from '../data/clusternode.js';
|
|
5
5
|
import type { IDeployment } from '../data/deployment.js';
|
|
6
6
|
import type { IIdentity } from '../data/user.js';
|
|
7
|
-
|
|
7
|
+
import type { INodeCredentialMetadataV1, INodeCredentialMutationPreconditionsV1, INodeCredentialMutationResultV1, TNodeCredentialPurpose } from '../data/nodecredential.js';
|
|
8
|
+
import type { INodeEnrollmentRequestV1, INodeEnrollmentAcknowledgementV1, INodeEnrollmentStateV1 } from '../data/nodeenrollment.js';
|
|
9
|
+
/** Node-self adoption preconditions, not an admin or workload RBAC grant. */
|
|
10
|
+
export interface IReq_Spark_Cloudly_GetNodeEnrollmentStateV1 extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_Spark_Cloudly_GetNodeEnrollmentStateV1> {
|
|
11
|
+
method: 'getNodeEnrollmentStateV1';
|
|
12
|
+
request: {
|
|
13
|
+
nodeId: string;
|
|
14
|
+
nodeToken: string;
|
|
15
|
+
};
|
|
16
|
+
/** Reject unless Spark is currently authenticated and Pallet authority is absent. */
|
|
17
|
+
response: INodeEnrollmentStateV1;
|
|
18
|
+
}
|
|
19
|
+
/** One server transaction; each node-local owner durably activates independently. */
|
|
20
|
+
export interface IReq_Spark_Cloudly_EnrollNodeV1 extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_Spark_Cloudly_EnrollNodeV1> {
|
|
21
|
+
method: 'enrollNodeV1';
|
|
22
|
+
request: INodeEnrollmentRequestV1;
|
|
23
|
+
/** Replays require the exact receipt AND both current credential authorities. */
|
|
24
|
+
response: INodeEnrollmentAcknowledgementV1;
|
|
25
|
+
}
|
|
26
|
+
/** Requires verified platform-infrastructure admin authority; returns public data only. */
|
|
27
|
+
export interface IRequest_Any_Cloudly_GetNodeConfig extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IRequest_Any_Cloudly_GetNodeConfig> {
|
|
8
28
|
method: 'getNodeConfig';
|
|
9
29
|
request: {
|
|
30
|
+
identity: IIdentity;
|
|
10
31
|
nodeId: string;
|
|
11
32
|
};
|
|
12
33
|
response: {
|
|
13
34
|
configData: IClusterNode;
|
|
14
35
|
};
|
|
15
36
|
}
|
|
37
|
+
/** These credential methods require verified infrastructure-admin authority. */
|
|
38
|
+
export interface IReq_Any_Cloudly_GetNodeCredential extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_Any_Cloudly_GetNodeCredential> {
|
|
39
|
+
method: 'getNodeCredential';
|
|
40
|
+
request: {
|
|
41
|
+
identity: IIdentity;
|
|
42
|
+
nodeId: string;
|
|
43
|
+
purpose: TNodeCredentialPurpose;
|
|
44
|
+
};
|
|
45
|
+
response: {
|
|
46
|
+
metadata: INodeCredentialMetadataV1 | null;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface IReq_Any_Cloudly_RotateNodeCredential extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_Any_Cloudly_RotateNodeCredential> {
|
|
50
|
+
method: 'rotateNodeCredential';
|
|
51
|
+
request: {
|
|
52
|
+
identity: IIdentity;
|
|
53
|
+
mutation: INodeCredentialMutationPreconditionsV1 & {
|
|
54
|
+
/**
|
|
55
|
+
* SHA-256(token UTF-8 bytes), exactly 64 lowercase hexadecimal characters.
|
|
56
|
+
* The node must durably retain its pending CSPRNG credential and mutation
|
|
57
|
+
* identity before this request. A metadata-only retry never issues plaintext.
|
|
58
|
+
* Treat this request field as sensitive; never include it in hooks or logs.
|
|
59
|
+
*/
|
|
60
|
+
newTokenHash: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
response: INodeCredentialMutationResultV1;
|
|
64
|
+
}
|
|
65
|
+
export interface IReq_Any_Cloudly_RevokeNodeCredential extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_Any_Cloudly_RevokeNodeCredential> {
|
|
66
|
+
method: 'revokeNodeCredential';
|
|
67
|
+
request: {
|
|
68
|
+
identity: IIdentity;
|
|
69
|
+
mutation: INodeCredentialMutationPreconditionsV1;
|
|
70
|
+
};
|
|
71
|
+
response: INodeCredentialMutationResultV1;
|
|
72
|
+
}
|
|
16
73
|
export interface IRequest_Any_Cloudly_GetNodesByCluster {
|
|
17
74
|
method: 'getNodesByCluster';
|
|
18
75
|
request: {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -47,6 +47,65 @@ validator; unlike `@serve.zone/interfaces/runtime`, it does not load the general
|
|
|
47
47
|
runtime graph, `plugins.js`, SmartCrypto, TypedRequest, Corestore, or settlement
|
|
48
48
|
runtime modules.
|
|
49
49
|
|
|
50
|
+
### Node Credential Administration
|
|
51
|
+
|
|
52
|
+
`requests.node` defines `getNodeCredential`, `rotateNodeCredential` and
|
|
53
|
+
`revokeNodeCredential` for verified platform-infrastructure administrators.
|
|
54
|
+
`getNodeConfig` now also requires `identity`; callers using the previous
|
|
55
|
+
unauthenticated request shape must update. Its response remains the public
|
|
56
|
+
`IClusterNode`, never a persisted backend document.
|
|
57
|
+
|
|
58
|
+
`data.INodeCredentialMetadataV1` separates `spark` and `pallet` purposes and
|
|
59
|
+
exposes lifecycle state, generation, rotation-required status and session epoch,
|
|
60
|
+
but no bearer, hash, socket peer or controller process identity. Infrastructure
|
|
61
|
+
credentials do not grant organization or workload permissions.
|
|
62
|
+
|
|
63
|
+
Mutations require the exact generation and session epoch plus a stable mutation
|
|
64
|
+
ID. Rotation takes the SHA-256 hash of a node-generated CSPRNG credential that the
|
|
65
|
+
node has already durably retained with that mutation ID. Lost-response retries
|
|
66
|
+
repeat the complete request and receive the original metadata, never newly minted
|
|
67
|
+
plaintext. A replay result is historical and cannot authorize a current session.
|
|
68
|
+
Treat rotation request hashes as sensitive in transport hooks and logs.
|
|
69
|
+
|
|
70
|
+
These types do not implement authentication, storage, enrollment or endpoints.
|
|
71
|
+
Cloudly must verify current administrator authority, validate complete inputs,
|
|
72
|
+
atomically persist the credential transition and immutable actor-bound receipt,
|
|
73
|
+
and fence subsequent control effects against current durable credential/session
|
|
74
|
+
authority. Node identity storage and transport integration must be qualified
|
|
75
|
+
before enabling rotation or Pallet enrollment.
|
|
76
|
+
|
|
77
|
+
### Independent Node Enrollment
|
|
78
|
+
|
|
79
|
+
`requests.node` defines `getNodeEnrollmentStateV1` for current Spark-authenticated
|
|
80
|
+
adoption preconditions and `enrollNodeV1` for atomic Spark/Pallet enrollment. These
|
|
81
|
+
contracts do not implement endpoints, authentication, a database or a daemon.
|
|
82
|
+
|
|
83
|
+
The enrollment proposal binds the canonical HTTPS Cloudly origin, hostname,
|
|
84
|
+
enrollment identity, original bootstrap proof hash and an exact ordered pair of
|
|
85
|
+
independently prepared Spark/Pallet credential hashes and CAS counters. Fresh Jump
|
|
86
|
+
starts both at zero; existing-node adoption rotates current Spark and requires
|
|
87
|
+
Pallet authority to be absent. `snapshotNodeEnrollmentV1` returns a detached,
|
|
88
|
+
frozen snapshot; `computeNodeEnrollmentV1Digest` hashes domain-separated strict
|
|
89
|
+
canonical JSON. Neither helper generates or persists credential material.
|
|
90
|
+
|
|
91
|
+
Transport proof is excluded from the digest to permit exact lost-response
|
|
92
|
+
recovery. Bootstrap proof must hash to the original proof hash and is allowed only
|
|
93
|
+
before a receipt exists. Pending-Spark proof must hash to the prepared Spark hash
|
|
94
|
+
and is allowed only for an existing exact receipt. `verifyNodeEnrollmentProofV1`
|
|
95
|
+
checks this binding and mode only: Cloudly must derive receipt state itself and
|
|
96
|
+
fence live bootstrap/credential authority in the same owned transaction. Current
|
|
97
|
+
Jump codes are 12 random bytes encoded as 16 canonical base64url characters.
|
|
98
|
+
|
|
99
|
+
`bindNodeEnrollmentAcknowledgementV1` checks the complete digest, both owners,
|
|
100
|
+
exact next generations and unchanged adopted node ID, returning a detached frozen
|
|
101
|
+
acknowledgement. Authenticate Cloudly before accepting it. The acknowledgement is
|
|
102
|
+
immutable commit evidence, not ongoing authority or workload readiness. Server
|
|
103
|
+
replay must still verify both active credential generations and hashes; reporter
|
|
104
|
+
reconnect alone does not invalidate the credential. Spark and Pallet commit their
|
|
105
|
+
local activation independently and converge after restart; there is no shared
|
|
106
|
+
plaintext vault or cross-local-database ACID claim. Never log proof/request bodies
|
|
107
|
+
or hashes, put them in URLs, or expose them through transport hooks.
|
|
108
|
+
|
|
50
109
|
### Node-Bound Runtime Assignments
|
|
51
110
|
|
|
52
111
|
The `data` namespace exports `IRuntimeAssignmentV1`, canonical digest helpers,
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/data/index.ts
CHANGED
|
@@ -20,6 +20,8 @@ export * from './immutableimage.js';
|
|
|
20
20
|
export * from './isolatedrestore.js';
|
|
21
21
|
export * from './isolatedrestore.golden.js';
|
|
22
22
|
export * from './mail.js';
|
|
23
|
+
export * from './nodecredential.js';
|
|
24
|
+
export * from './nodeenrollment.js';
|
|
23
25
|
export * from './registry.js';
|
|
24
26
|
export * from './runtimeassignment.js';
|
|
25
27
|
export * from './secret.js';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Independent infrastructure credentials; neither purpose grants workload RBAC. */
|
|
2
|
+
export type TNodeCredentialPurpose = 'spark' | 'pallet';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Public inspection and mutation-result metadata. Never includes bearer material,
|
|
6
|
+
* hashes, socket peer IDs or controller process IDs. On replay this is historical
|
|
7
|
+
* evidence, not an assertion that a credential or reporter session is still live.
|
|
8
|
+
*/
|
|
9
|
+
export interface INodeCredentialMetadataV1 {
|
|
10
|
+
schemaVersion: 1;
|
|
11
|
+
nodeId: string;
|
|
12
|
+
purpose: TNodeCredentialPurpose;
|
|
13
|
+
state: 'active' | 'revoked';
|
|
14
|
+
generation: number;
|
|
15
|
+
/** Migrated Spark credentials remain usable only until their staged rotation. */
|
|
16
|
+
requiresRotation: boolean;
|
|
17
|
+
sessionEpoch: number;
|
|
18
|
+
sessionId: string | null;
|
|
19
|
+
createdAt: number;
|
|
20
|
+
updatedAt: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Infrastructure-admin mutation preconditions. Both counters are exact CAS
|
|
25
|
+
* preconditions, not minimums. Retrying must retain this complete input and the
|
|
26
|
+
* original mutationId; a changed request with the same ID must fail closed.
|
|
27
|
+
*/
|
|
28
|
+
export interface INodeCredentialMutationPreconditionsV1 {
|
|
29
|
+
schemaVersion: 1;
|
|
30
|
+
nodeId: string;
|
|
31
|
+
purpose: TNodeCredentialPurpose;
|
|
32
|
+
mutationId: string;
|
|
33
|
+
expectedGeneration: number;
|
|
34
|
+
expectedSessionEpoch: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface INodeCredentialMutationResultV1 {
|
|
38
|
+
metadata: INodeCredentialMetadataV1;
|
|
39
|
+
/** A replay returns the original result without restoring its authority. */
|
|
40
|
+
replayed: boolean;
|
|
41
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import type { TNodeCredentialPurpose } from './nodecredential.js';
|
|
2
|
+
import {
|
|
3
|
+
canonicalizeStrictJson,
|
|
4
|
+
createCanonicalJsonSha256Hex,
|
|
5
|
+
createSha256Hex,
|
|
6
|
+
deepFreezeValue,
|
|
7
|
+
} from '../private/canonicaljson.js';
|
|
8
|
+
|
|
9
|
+
export interface INodeEnrollmentCredentialProposalV1 {
|
|
10
|
+
purpose: TNodeCredentialPurpose;
|
|
11
|
+
installationId: string;
|
|
12
|
+
mutationId: string;
|
|
13
|
+
/** SHA-256 of the independently generated, durably prepared bearer UTF-8 bytes. */
|
|
14
|
+
tokenHash: string;
|
|
15
|
+
expectedGeneration: number;
|
|
16
|
+
expectedSessionEpoch: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Value-free, immutable proposal. Hashes are still sensitive transport fields. */
|
|
20
|
+
export interface INodeEnrollmentV1 {
|
|
21
|
+
schemaVersion: 1;
|
|
22
|
+
/** 32 CSPRNG bytes encoded as lowercase hexadecimal; retain across every retry. */
|
|
23
|
+
enrollmentId: string;
|
|
24
|
+
cloudlyOrigin: string;
|
|
25
|
+
hostname: string;
|
|
26
|
+
bootstrap:
|
|
27
|
+
| { kind: 'jump'; proofHash: string }
|
|
28
|
+
| { kind: 'adopt-existing'; nodeId: string; proofHash: string };
|
|
29
|
+
credentials: [
|
|
30
|
+
INodeEnrollmentCredentialProposalV1 & { purpose: 'spark' },
|
|
31
|
+
INodeEnrollmentCredentialProposalV1 & { purpose: 'pallet' },
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface INodeEnrollmentRequestV1 {
|
|
36
|
+
enrollment: INodeEnrollmentV1;
|
|
37
|
+
/** Never persist on the server, log, put in URLs, or expose in transport hooks. */
|
|
38
|
+
proof: { kind: 'bootstrap' | 'pending-spark'; bearer: string };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface INodeEnrollmentCredentialAcknowledgementV1 {
|
|
42
|
+
purpose: TNodeCredentialPurpose;
|
|
43
|
+
installationId: string;
|
|
44
|
+
mutationId: string;
|
|
45
|
+
tokenHash: string;
|
|
46
|
+
generation: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Immutable commit evidence, not authorization or workload readiness. */
|
|
50
|
+
export interface INodeEnrollmentAcknowledgementV1 {
|
|
51
|
+
schemaVersion: 1;
|
|
52
|
+
enrollmentId: string;
|
|
53
|
+
cloudlyOrigin: string;
|
|
54
|
+
nodeId: string;
|
|
55
|
+
requestDigest: string;
|
|
56
|
+
credentials: [
|
|
57
|
+
INodeEnrollmentCredentialAcknowledgementV1 & { purpose: 'spark' },
|
|
58
|
+
INodeEnrollmentCredentialAcknowledgementV1 & { purpose: 'pallet' },
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Returned only after current Spark authentication and proof that Pallet is absent. */
|
|
63
|
+
export interface INodeEnrollmentStateV1 {
|
|
64
|
+
schemaVersion: 1;
|
|
65
|
+
nodeId: string;
|
|
66
|
+
spark: { generation: number; sessionEpoch: number };
|
|
67
|
+
pallet: 'absent';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const nodeEnrollmentV1Contract = Object.freeze({
|
|
71
|
+
digestDomain: 'serve.zone/node-enrollment-v1',
|
|
72
|
+
localActivation: 'independently-durable-convergence',
|
|
73
|
+
bootstrapProof: 'first-commit-only',
|
|
74
|
+
pendingSparkProof: 'committed-exact-receipt-only',
|
|
75
|
+
} as const);
|
|
76
|
+
|
|
77
|
+
const fail = (): never => { throw new Error('Node enrollment contract rejected.'); };
|
|
78
|
+
function requireValue(valueArg: unknown): asserts valueArg {
|
|
79
|
+
if (!valueArg) fail();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Decoded JSON/data records only. No input accessor is executed or preserved. */
|
|
83
|
+
const record = (valueArg: unknown, keysArg: readonly string[]): Record<string, unknown> => {
|
|
84
|
+
requireValue(valueArg !== null && typeof valueArg === 'object' && !Array.isArray(valueArg));
|
|
85
|
+
const prototype = Object.getPrototypeOf(valueArg);
|
|
86
|
+
requireValue(prototype === Object.prototype || prototype === null);
|
|
87
|
+
const keys = Reflect.ownKeys(valueArg);
|
|
88
|
+
requireValue(keys.length === keysArg.length);
|
|
89
|
+
const snapshot: Record<string, unknown> = Object.create(null);
|
|
90
|
+
for (const key of keys) {
|
|
91
|
+
requireValue(typeof key === 'string' && keysArg.includes(key));
|
|
92
|
+
const descriptor = Object.getOwnPropertyDescriptor(valueArg, key);
|
|
93
|
+
requireValue(descriptor?.enumerable && Object.hasOwn(descriptor, 'value'));
|
|
94
|
+
snapshot[key] = descriptor.value;
|
|
95
|
+
}
|
|
96
|
+
return snapshot;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const pair = (valueArg: unknown): [unknown, unknown] => {
|
|
100
|
+
requireValue(Array.isArray(valueArg) && Object.getPrototypeOf(valueArg) === Array.prototype);
|
|
101
|
+
requireValue(Reflect.ownKeys(valueArg).length === 3 && valueArg.length === 2);
|
|
102
|
+
const first = Object.getOwnPropertyDescriptor(valueArg, '0');
|
|
103
|
+
const second = Object.getOwnPropertyDescriptor(valueArg, '1');
|
|
104
|
+
requireValue(first?.enumerable && Object.hasOwn(first, 'value'));
|
|
105
|
+
requireValue(second?.enumerable && Object.hasOwn(second, 'value'));
|
|
106
|
+
return [first.value, second.value];
|
|
107
|
+
};
|
|
108
|
+
const id = (valueArg: unknown): string => {
|
|
109
|
+
requireValue(typeof valueArg === 'string' && /^[A-Za-z0-9_-]{1,128}$/.test(valueArg));
|
|
110
|
+
return valueArg;
|
|
111
|
+
};
|
|
112
|
+
const hash = (valueArg: unknown): string => {
|
|
113
|
+
requireValue(typeof valueArg === 'string' && /^[a-f0-9]{64}$/.test(valueArg));
|
|
114
|
+
return valueArg;
|
|
115
|
+
};
|
|
116
|
+
const counter = (valueArg: unknown, minimumArg = 0, incrementArg = false): number => {
|
|
117
|
+
requireValue(typeof valueArg === 'number' && Number.isSafeInteger(valueArg)
|
|
118
|
+
&& !Object.is(valueArg, -0) && valueArg >= minimumArg
|
|
119
|
+
&& (!incrementArg || valueArg < Number.MAX_SAFE_INTEGER));
|
|
120
|
+
return valueArg;
|
|
121
|
+
};
|
|
122
|
+
const origin = (valueArg: unknown): string => {
|
|
123
|
+
requireValue(typeof valueArg === 'string' && valueArg.length <= 2048);
|
|
124
|
+
let url: URL;
|
|
125
|
+
try { url = new URL(valueArg); } catch { return fail(); }
|
|
126
|
+
requireValue(url.protocol === 'https:' && !url.username && !url.password && url.origin === valueArg);
|
|
127
|
+
return valueArg;
|
|
128
|
+
};
|
|
129
|
+
const hostname = (valueArg: unknown): string => {
|
|
130
|
+
requireValue(typeof valueArg === 'string' && valueArg.length <= 253 && valueArg.length > 0);
|
|
131
|
+
requireValue(valueArg.split('.').every((labelArg) =>
|
|
132
|
+
/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(labelArg)));
|
|
133
|
+
return valueArg;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const proposal = <TPurpose extends TNodeCredentialPurpose>(
|
|
137
|
+
valueArg: unknown, purposeArg: TPurpose,
|
|
138
|
+
): INodeEnrollmentCredentialProposalV1 & { purpose: TPurpose } => {
|
|
139
|
+
const value = record(valueArg, ['purpose', 'installationId', 'mutationId', 'tokenHash',
|
|
140
|
+
'expectedGeneration', 'expectedSessionEpoch']);
|
|
141
|
+
requireValue(value.purpose === purposeArg);
|
|
142
|
+
return { purpose: purposeArg, installationId: id(value.installationId), mutationId: id(value.mutationId),
|
|
143
|
+
tokenHash: hash(value.tokenHash), expectedGeneration: counter(value.expectedGeneration, 0, true),
|
|
144
|
+
expectedSessionEpoch: counter(value.expectedSessionEpoch, 0, true) };
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const distinctOwners = (
|
|
148
|
+
sparkArg: INodeEnrollmentCredentialAcknowledgementV1 | INodeEnrollmentCredentialProposalV1,
|
|
149
|
+
palletArg: INodeEnrollmentCredentialAcknowledgementV1 | INodeEnrollmentCredentialProposalV1,
|
|
150
|
+
): void => {
|
|
151
|
+
requireValue(sparkArg.installationId !== palletArg.installationId
|
|
152
|
+
&& sparkArg.mutationId !== palletArg.mutationId && sparkArg.tokenHash !== palletArg.tokenHash);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/** Detached frozen snapshot, captured synchronously before hashing or other awaits. */
|
|
156
|
+
export const snapshotNodeEnrollmentV1 = (valueArg: unknown): INodeEnrollmentV1 => {
|
|
157
|
+
const value = record(valueArg, ['schemaVersion', 'enrollmentId', 'cloudlyOrigin', 'hostname',
|
|
158
|
+
'bootstrap', 'credentials']);
|
|
159
|
+
requireValue(value.schemaVersion === 1);
|
|
160
|
+
// Read the discriminant from its data descriptor, never an input getter.
|
|
161
|
+
requireValue(value.bootstrap !== null && typeof value.bootstrap === 'object');
|
|
162
|
+
const kind = Object.getOwnPropertyDescriptor(value.bootstrap, 'kind');
|
|
163
|
+
requireValue(kind && Object.hasOwn(kind, 'value'));
|
|
164
|
+
const bootstrap = record(value.bootstrap, kind.value === 'jump'
|
|
165
|
+
? ['kind', 'proofHash'] : ['kind', 'nodeId', 'proofHash']);
|
|
166
|
+
requireValue(bootstrap.kind === 'jump' || bootstrap.kind === 'adopt-existing');
|
|
167
|
+
const [sparkInput, palletInput] = pair(value.credentials);
|
|
168
|
+
const spark = proposal(sparkInput, 'spark');
|
|
169
|
+
const pallet = proposal(palletInput, 'pallet');
|
|
170
|
+
distinctOwners(spark, pallet);
|
|
171
|
+
requireValue(pallet.expectedGeneration === 0 && pallet.expectedSessionEpoch === 0);
|
|
172
|
+
requireValue(bootstrap.kind === 'jump'
|
|
173
|
+
? spark.expectedGeneration === 0 && spark.expectedSessionEpoch === 0
|
|
174
|
+
: spark.expectedGeneration > 0);
|
|
175
|
+
return deepFreezeValue({ schemaVersion: 1, enrollmentId: hash(value.enrollmentId),
|
|
176
|
+
cloudlyOrigin: origin(value.cloudlyOrigin), hostname: hostname(value.hostname),
|
|
177
|
+
bootstrap: bootstrap.kind === 'jump'
|
|
178
|
+
? { kind: 'jump', proofHash: hash(bootstrap.proofHash) }
|
|
179
|
+
: { kind: 'adopt-existing', nodeId: id(bootstrap.nodeId), proofHash: hash(bootstrap.proofHash) },
|
|
180
|
+
credentials: [spark, pallet] });
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const computeNodeEnrollmentV1Digest = async (valueArg: INodeEnrollmentV1): Promise<string> => {
|
|
184
|
+
const payload = snapshotNodeEnrollmentV1(valueArg);
|
|
185
|
+
return createCanonicalJsonSha256Hex(canonicalizeStrictJson({
|
|
186
|
+
domain: nodeEnrollmentV1Contract.digestDomain, payload,
|
|
187
|
+
}, fail), fail);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const snapshotNodeEnrollmentRequestV1 = (valueArg: unknown): INodeEnrollmentRequestV1 => {
|
|
191
|
+
const value = record(valueArg, ['enrollment', 'proof']);
|
|
192
|
+
const enrollment = snapshotNodeEnrollmentV1(value.enrollment);
|
|
193
|
+
const proof = record(value.proof, ['kind', 'bearer']);
|
|
194
|
+
requireValue(proof.kind === 'bootstrap' || proof.kind === 'pending-spark');
|
|
195
|
+
requireValue(typeof proof.bearer === 'string');
|
|
196
|
+
requireValue(proof.kind === 'bootstrap' && enrollment.bootstrap.kind === 'jump'
|
|
197
|
+
? /^[A-Za-z0-9_-]{16}$/.test(proof.bearer) : /^secureToken[a-f0-9]{64}$/.test(proof.bearer));
|
|
198
|
+
return deepFreezeValue({ enrollment, proof: { kind: proof.kind, bearer: proof.bearer } });
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Pure proof binding/mode check only, NOT authentication. The server must derive
|
|
203
|
+
* receiptState from its owned transaction, compare the complete stored proposal,
|
|
204
|
+
* and fence current Jump/Spark/Pallet authority before any commit or replay.
|
|
205
|
+
*/
|
|
206
|
+
export const verifyNodeEnrollmentProofV1 = async (
|
|
207
|
+
valueArg: INodeEnrollmentRequestV1, receiptStateArg: 'absent' | 'committed',
|
|
208
|
+
): Promise<boolean> => {
|
|
209
|
+
try {
|
|
210
|
+
const { enrollment, proof } = snapshotNodeEnrollmentRequestV1(valueArg);
|
|
211
|
+
if (!(proof.kind === 'bootstrap' && receiptStateArg === 'absent')
|
|
212
|
+
&& !(proof.kind === 'pending-spark' && receiptStateArg === 'committed')) return false;
|
|
213
|
+
// This helper hashes exact UTF-8 text; no JSON quoting or normalization.
|
|
214
|
+
const actual = await createSha256Hex(new TextEncoder().encode(proof.bearer), fail);
|
|
215
|
+
return actual === (proof.kind === 'bootstrap'
|
|
216
|
+
? enrollment.bootstrap.proofHash : enrollment.credentials[0].tokenHash);
|
|
217
|
+
} catch { return false; }
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const credentialAcknowledgement = <TPurpose extends TNodeCredentialPurpose>(
|
|
221
|
+
valueArg: unknown, purposeArg: TPurpose,
|
|
222
|
+
): INodeEnrollmentCredentialAcknowledgementV1 & { purpose: TPurpose } => {
|
|
223
|
+
const value = record(valueArg, ['purpose', 'installationId', 'mutationId', 'tokenHash', 'generation']);
|
|
224
|
+
requireValue(value.purpose === purposeArg);
|
|
225
|
+
return { purpose: purposeArg, installationId: id(value.installationId), mutationId: id(value.mutationId),
|
|
226
|
+
tokenHash: hash(value.tokenHash), generation: counter(value.generation, 1) };
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const snapshotNodeEnrollmentAcknowledgementV1 = (
|
|
230
|
+
valueArg: unknown,
|
|
231
|
+
): INodeEnrollmentAcknowledgementV1 => {
|
|
232
|
+
const value = record(valueArg, ['schemaVersion', 'enrollmentId', 'cloudlyOrigin', 'nodeId',
|
|
233
|
+
'requestDigest', 'credentials']);
|
|
234
|
+
requireValue(value.schemaVersion === 1);
|
|
235
|
+
const [sparkInput, palletInput] = pair(value.credentials);
|
|
236
|
+
const spark = credentialAcknowledgement(sparkInput, 'spark');
|
|
237
|
+
const pallet = credentialAcknowledgement(palletInput, 'pallet');
|
|
238
|
+
distinctOwners(spark, pallet);
|
|
239
|
+
requireValue(pallet.generation === 1);
|
|
240
|
+
return deepFreezeValue({ schemaVersion: 1, enrollmentId: hash(value.enrollmentId),
|
|
241
|
+
cloudlyOrigin: origin(value.cloudlyOrigin), nodeId: id(value.nodeId),
|
|
242
|
+
requestDigest: hash(value.requestDigest), credentials: [spark, pallet] });
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/** Content binding only. Authenticate Cloudly first; persist only the returned snapshot. */
|
|
246
|
+
export const bindNodeEnrollmentAcknowledgementV1 = async (
|
|
247
|
+
enrollmentArg: INodeEnrollmentV1, acknowledgementArg: INodeEnrollmentAcknowledgementV1,
|
|
248
|
+
): Promise<INodeEnrollmentAcknowledgementV1> => {
|
|
249
|
+
const enrollment = snapshotNodeEnrollmentV1(enrollmentArg);
|
|
250
|
+
const ack = snapshotNodeEnrollmentAcknowledgementV1(acknowledgementArg);
|
|
251
|
+
requireValue(ack.enrollmentId === enrollment.enrollmentId && ack.cloudlyOrigin === enrollment.cloudlyOrigin
|
|
252
|
+
&& (enrollment.bootstrap.kind === 'jump' || ack.nodeId === enrollment.bootstrap.nodeId));
|
|
253
|
+
for (const index of [0, 1] as const) {
|
|
254
|
+
const expected = enrollment.credentials[index];
|
|
255
|
+
const actual = ack.credentials[index];
|
|
256
|
+
requireValue(actual.purpose === expected.purpose && actual.installationId === expected.installationId
|
|
257
|
+
&& actual.mutationId === expected.mutationId && actual.tokenHash === expected.tokenHash
|
|
258
|
+
&& actual.generation === expected.expectedGeneration + 1);
|
|
259
|
+
}
|
|
260
|
+
requireValue(ack.requestDigest === await computeNodeEnrollmentV1Digest(enrollment));
|
|
261
|
+
return ack;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export const snapshotNodeEnrollmentStateV1 = (valueArg: unknown): INodeEnrollmentStateV1 => {
|
|
265
|
+
const value = record(valueArg, ['schemaVersion', 'nodeId', 'spark', 'pallet']);
|
|
266
|
+
requireValue(value.schemaVersion === 1 && value.pallet === 'absent');
|
|
267
|
+
const spark = record(value.spark, ['generation', 'sessionEpoch']);
|
|
268
|
+
return deepFreezeValue({ schemaVersion: 1, nodeId: id(value.nodeId), pallet: 'absent',
|
|
269
|
+
spark: { generation: counter(spark.generation, 1, true), sessionEpoch: counter(spark.sessionEpoch, 0, true) } });
|
|
270
|
+
};
|
package/ts/requests/node.ts
CHANGED
|
@@ -4,10 +4,48 @@ import type { ICluster } from '../data/cluster.js';
|
|
|
4
4
|
import type { IClusterNode, IClusterNodeMetrics, INodeAction, INodeMetricsSample, ISparkNodeRuntimeInfo, TNodeActionName } from '../data/clusternode.js';
|
|
5
5
|
import type { IDeployment } from '../data/deployment.js';
|
|
6
6
|
import type { IIdentity } from '../data/user.js';
|
|
7
|
+
import type {
|
|
8
|
+
INodeCredentialMetadataV1,
|
|
9
|
+
INodeCredentialMutationPreconditionsV1,
|
|
10
|
+
INodeCredentialMutationResultV1,
|
|
11
|
+
TNodeCredentialPurpose,
|
|
12
|
+
} from '../data/nodecredential.js';
|
|
13
|
+
import type {
|
|
14
|
+
INodeEnrollmentRequestV1,
|
|
15
|
+
INodeEnrollmentAcknowledgementV1,
|
|
16
|
+
INodeEnrollmentStateV1,
|
|
17
|
+
} from '../data/nodeenrollment.js';
|
|
7
18
|
|
|
8
|
-
|
|
19
|
+
/** Node-self adoption preconditions, not an admin or workload RBAC grant. */
|
|
20
|
+
export interface IReq_Spark_Cloudly_GetNodeEnrollmentStateV1 extends plugins.typedrequestInterfaces.implementsTR<
|
|
21
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
22
|
+
IReq_Spark_Cloudly_GetNodeEnrollmentStateV1
|
|
23
|
+
> {
|
|
24
|
+
method: 'getNodeEnrollmentStateV1';
|
|
25
|
+
request: { nodeId: string; nodeToken: string };
|
|
26
|
+
/** Reject unless Spark is currently authenticated and Pallet authority is absent. */
|
|
27
|
+
response: INodeEnrollmentStateV1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** One server transaction; each node-local owner durably activates independently. */
|
|
31
|
+
export interface IReq_Spark_Cloudly_EnrollNodeV1 extends plugins.typedrequestInterfaces.implementsTR<
|
|
32
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
33
|
+
IReq_Spark_Cloudly_EnrollNodeV1
|
|
34
|
+
> {
|
|
35
|
+
method: 'enrollNodeV1';
|
|
36
|
+
request: INodeEnrollmentRequestV1;
|
|
37
|
+
/** Replays require the exact receipt AND both current credential authorities. */
|
|
38
|
+
response: INodeEnrollmentAcknowledgementV1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Requires verified platform-infrastructure admin authority; returns public data only. */
|
|
42
|
+
export interface IRequest_Any_Cloudly_GetNodeConfig extends plugins.typedrequestInterfaces.implementsTR<
|
|
43
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
44
|
+
IRequest_Any_Cloudly_GetNodeConfig
|
|
45
|
+
> {
|
|
9
46
|
method: 'getNodeConfig';
|
|
10
47
|
request: {
|
|
48
|
+
identity: IIdentity;
|
|
11
49
|
nodeId: string;
|
|
12
50
|
};
|
|
13
51
|
response: {
|
|
@@ -15,6 +53,54 @@ export interface IRequest_Any_Cloudly_GetNodeConfig {
|
|
|
15
53
|
};
|
|
16
54
|
}
|
|
17
55
|
|
|
56
|
+
/** These credential methods require verified infrastructure-admin authority. */
|
|
57
|
+
export interface IReq_Any_Cloudly_GetNodeCredential extends plugins.typedrequestInterfaces.implementsTR<
|
|
58
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
59
|
+
IReq_Any_Cloudly_GetNodeCredential
|
|
60
|
+
> {
|
|
61
|
+
method: 'getNodeCredential';
|
|
62
|
+
request: {
|
|
63
|
+
identity: IIdentity;
|
|
64
|
+
nodeId: string;
|
|
65
|
+
purpose: TNodeCredentialPurpose;
|
|
66
|
+
};
|
|
67
|
+
response: {
|
|
68
|
+
metadata: INodeCredentialMetadataV1 | null;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface IReq_Any_Cloudly_RotateNodeCredential extends plugins.typedrequestInterfaces.implementsTR<
|
|
73
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
74
|
+
IReq_Any_Cloudly_RotateNodeCredential
|
|
75
|
+
> {
|
|
76
|
+
method: 'rotateNodeCredential';
|
|
77
|
+
request: {
|
|
78
|
+
identity: IIdentity;
|
|
79
|
+
mutation: INodeCredentialMutationPreconditionsV1 & {
|
|
80
|
+
/**
|
|
81
|
+
* SHA-256(token UTF-8 bytes), exactly 64 lowercase hexadecimal characters.
|
|
82
|
+
* The node must durably retain its pending CSPRNG credential and mutation
|
|
83
|
+
* identity before this request. A metadata-only retry never issues plaintext.
|
|
84
|
+
* Treat this request field as sensitive; never include it in hooks or logs.
|
|
85
|
+
*/
|
|
86
|
+
newTokenHash: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
response: INodeCredentialMutationResultV1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface IReq_Any_Cloudly_RevokeNodeCredential extends plugins.typedrequestInterfaces.implementsTR<
|
|
93
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
94
|
+
IReq_Any_Cloudly_RevokeNodeCredential
|
|
95
|
+
> {
|
|
96
|
+
method: 'revokeNodeCredential';
|
|
97
|
+
request: {
|
|
98
|
+
identity: IIdentity;
|
|
99
|
+
mutation: INodeCredentialMutationPreconditionsV1;
|
|
100
|
+
};
|
|
101
|
+
response: INodeCredentialMutationResultV1;
|
|
102
|
+
}
|
|
103
|
+
|
|
18
104
|
export interface IRequest_Any_Cloudly_GetNodesByCluster {
|
|
19
105
|
method: 'getNodesByCluster';
|
|
20
106
|
request: {
|