@substrat-run/control-plane-api 0.158.0 → 0.160.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/dist/api.d.ts +25 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +570 -55
- package/dist/api.js.map +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -1
- package/dist/browser.js.map +1 -1
- package/dist/cf-observability.d.ts +30 -5
- package/dist/cf-observability.d.ts.map +1 -1
- package/dist/cf-observability.js +277 -92
- package/dist/cf-observability.js.map +1 -1
- package/dist/custom-hostnames.d.ts +30 -0
- package/dist/custom-hostnames.d.ts.map +1 -1
- package/dist/custom-hostnames.js +25 -2
- package/dist/custom-hostnames.js.map +1 -1
- package/dist/deploy.d.ts +3 -0
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/observability.d.ts +26 -2
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +6 -13
- package/dist/observability.js.map +1 -1
- package/dist/platform-drain.d.ts.map +1 -1
- package/dist/platform-drain.js +103 -40
- package/dist/platform-drain.js.map +1 -1
- package/dist/platform-entry.generated.d.ts +2 -2
- package/dist/platform-entry.generated.d.ts.map +1 -1
- package/dist/platform-entry.generated.js +5 -5
- package/dist/platform-entry.generated.js.map +1 -1
- package/dist/platform-wire.d.ts +51 -0
- package/dist/platform-wire.d.ts.map +1 -0
- package/dist/platform-wire.js +163 -0
- package/dist/platform-wire.js.map +1 -0
- package/dist/scope-copy-backfill.d.ts.map +1 -1
- package/dist/scope-copy-backfill.js +22 -9
- package/dist/scope-copy-backfill.js.map +1 -1
- package/dist/staff-client.d.ts +38 -2
- package/dist/staff-client.d.ts.map +1 -1
- package/dist/staff-client.js +24 -1
- package/dist/staff-client.js.map +1 -1
- package/dist/vertical-client.d.ts +59 -3
- package/dist/vertical-client.d.ts.map +1 -1
- package/dist/vertical-client.js +144 -6
- package/dist/vertical-client.js.map +1 -1
- package/dist/wire-upload.d.ts +74 -0
- package/dist/wire-upload.d.ts.map +1 -0
- package/dist/wire-upload.js +114 -0
- package/dist/wire-upload.js.map +1 -0
- package/package.json +10 -10
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The uploader's half of RFC wire-signing step 2 (follow-on 3): what one upload gives the deployment
|
|
3
|
+
* it goes to, and the capability record of it (§5, §6, §7, Q8).
|
|
4
|
+
*
|
|
5
|
+
* A deployment is given both issuers' public key lists, its own dispatch name for the audience
|
|
6
|
+
* check and the state `dual`, all plain configuration, rewritten on every upload. Nothing is given
|
|
7
|
+
* until the control plane's `WIRE_KEYS_ROLLOUT` says so: unset or `off` gives no deployment lists,
|
|
8
|
+
* `canary:<vertical>` gives them to that one vertical's deployments only (the single canary the RFC
|
|
9
|
+
* puts first in each environment), and `fleet` to every deployment. A setting that cannot be read
|
|
10
|
+
* gives nothing. So with the setting unset, every upload is what it was before this existed.
|
|
11
|
+
*
|
|
12
|
+
* The lists are judged before they are given, by the function the platform's entry loads them with
|
|
13
|
+
* (`wireUploadSettings`), so a deployment is never given lists its verifier would refuse: the upload
|
|
14
|
+
* gives nothing instead, and says why. No code here can give a state other than `dual`: moving a
|
|
15
|
+
* deployment to `signed-only` is the flip, a later and separate step.
|
|
16
|
+
*
|
|
17
|
+
* Every upload has a record, given lists or not, written from what the uploader built: whether the
|
|
18
|
+
* bundle carries the platform's entry (which holds the verifier), the state, the audience and the key
|
|
19
|
+
* ids, or why nothing was given. The vertical never declares any of it.
|
|
20
|
+
*/
|
|
21
|
+
import { verticalSlug } from '@substrat-run/contracts';
|
|
22
|
+
import { wireUploadSettings, wireVerificationKeys, WIRE_ENVELOPE_VERSION, WIRE_UPLOAD_STATE } from '@substrat-run/contracts/wire-signing';
|
|
23
|
+
import { platformEntrySkipReason } from './platform-entry.js';
|
|
24
|
+
const CANARY = 'canary:';
|
|
25
|
+
/**
|
|
26
|
+
* The rollout setting's one reading. Unset, empty or `off` is off; `fleet` is every deployment;
|
|
27
|
+
* `canary:<vertical>` is one vertical, named as the registry names it. Anything else is refused
|
|
28
|
+
* with the reason, a second vertical in a canary included: the RFC's canary is one, before the rest.
|
|
29
|
+
*/
|
|
30
|
+
export function wireKeysRolloutOf(value) {
|
|
31
|
+
if (value === undefined || value === null)
|
|
32
|
+
return { kind: 'off' };
|
|
33
|
+
if (typeof value !== 'string')
|
|
34
|
+
return { refused: 'the rollout setting is not text' };
|
|
35
|
+
const text = value.trim();
|
|
36
|
+
if (text === '' || text === 'off')
|
|
37
|
+
return { kind: 'off' };
|
|
38
|
+
if (text === 'fleet')
|
|
39
|
+
return { kind: 'fleet' };
|
|
40
|
+
if (!text.startsWith(CANARY))
|
|
41
|
+
return { refused: 'the rollout setting is `off`, `canary:<vertical>` or `fleet`' };
|
|
42
|
+
const vertical = text.slice(CANARY.length).trim();
|
|
43
|
+
if (/[,\s]/.test(vertical))
|
|
44
|
+
return { refused: 'a canary names one vertical' };
|
|
45
|
+
if (!verticalSlug.safeParse(vertical).success)
|
|
46
|
+
return { refused: 'a canary names a vertical by its registry slug' };
|
|
47
|
+
return { kind: 'canary', vertical };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What the upload of `bundle` to the script `deploymentRef`, a deployment of `vertical`, gives it
|
|
51
|
+
* under `settings`, and the record of it. Gives nothing while the rollout is off or leaves the
|
|
52
|
+
* vertical out, while the setting cannot be read, or while the lists would not load.
|
|
53
|
+
*/
|
|
54
|
+
export async function wireUploadFor(settings, upload) {
|
|
55
|
+
const { vertical, deploymentRef } = upload;
|
|
56
|
+
const skipped = platformEntrySkipReason(upload.bundle) ?? null;
|
|
57
|
+
const entry = { envelope: skipped === null ? WIRE_ENVELOPE_VERSION : null, entrySkipped: skipped };
|
|
58
|
+
const nothing = (withheld, refusal = null) => ({
|
|
59
|
+
vertical,
|
|
60
|
+
deploymentRef,
|
|
61
|
+
bindings: [],
|
|
62
|
+
record: { ...entry, state: 'legacy-only', audience: null, routerKids: [], platformKids: [], withheld },
|
|
63
|
+
refusal,
|
|
64
|
+
});
|
|
65
|
+
const rollout = wireKeysRolloutOf(settings?.rollout);
|
|
66
|
+
if ('refused' in rollout)
|
|
67
|
+
return nothing('rollout-refused', rollout.refused);
|
|
68
|
+
if (rollout.kind === 'off')
|
|
69
|
+
return nothing('unconfigured');
|
|
70
|
+
if (rollout.kind === 'canary' && rollout.vertical !== vertical)
|
|
71
|
+
return nothing('not-in-rollout');
|
|
72
|
+
try {
|
|
73
|
+
const given = await wireUploadSettings({
|
|
74
|
+
routerKeys: settings?.routerKeys ?? '',
|
|
75
|
+
platformKeys: settings?.platformKeys ?? '',
|
|
76
|
+
audience: deploymentRef,
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
vertical,
|
|
80
|
+
deploymentRef,
|
|
81
|
+
bindings: given.settings.map((setting) => ({ type: 'plain_text', ...setting })),
|
|
82
|
+
record: { ...entry, state: WIRE_UPLOAD_STATE, audience: deploymentRef, routerKids: given.routerKids, platformKids: given.platformKids, withheld: null },
|
|
83
|
+
refusal: null,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return nothing('lists-refused', await refusedList(settings, error));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Why the lists were refused, naming the setting to fix: each list is loaded alone, and the first
|
|
92
|
+
* that fails is named with its problem. When each loads alone (a key in both, or an audience the
|
|
93
|
+
* encoder would not carry), the refusal is the one given. The parser's messages are fixed text
|
|
94
|
+
* naming a problem, never a key.
|
|
95
|
+
*/
|
|
96
|
+
async function refusedList(settings, error) {
|
|
97
|
+
const problem = (e) => (e instanceof Error ? e.message : 'the list did not load').replace(/^a store public key/, 'a public key');
|
|
98
|
+
for (const [name, router, platform] of [
|
|
99
|
+
['WIRE_ROUTER_PUBLIC_KEYS', settings?.routerKeys, undefined],
|
|
100
|
+
['WIRE_PLATFORM_PUBLIC_KEYS', undefined, settings?.platformKeys],
|
|
101
|
+
]) {
|
|
102
|
+
const list = router ?? platform;
|
|
103
|
+
if (!list?.trim())
|
|
104
|
+
return `${name} lists no key`;
|
|
105
|
+
try {
|
|
106
|
+
await wireVerificationKeys({ router, platform });
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
return `${name}: ${problem(e)}`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return problem(error);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=wire-upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire-upload.js","sourceRoot":"","sources":["../src/wire-upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAuB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC1I,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAmB9D,MAAM,MAAM,GAAG,SAAS,CAAC;AAEzB;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAClE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;IACrF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,KAAK;QAAE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AED;;;;;GAKG;AACH,KAAK,UAAU,WAAW,CAAC,QAAwC,EAAE,KAAc;IACjF,MAAM,OAAO,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;IAC1I,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI;QACrC,CAAC,yBAAyB,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC;QAC5D,CAAC,2BAA2B,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAC;KACxD,EAAE,CAAC;QACX,MAAM,IAAI,GAAG,MAAM,IAAI,QAAQ,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE;YAAE,OAAO,GAAG,IAAI,eAAe,CAAC;QACjD,IAAI,CAAC;YACH,MAAM,oBAAoB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/control-plane-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.160.0",
|
|
4
4
|
"description": "HTTP surface over HostAdmin — the audited control-plane transport (control-plane.md §4.5)",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"hono": "^4.13.13",
|
|
30
|
-
"@substrat-run/contracts": "^0.
|
|
31
|
-
"@substrat-run/
|
|
32
|
-
"@substrat-run/
|
|
33
|
-
"@substrat-run/
|
|
30
|
+
"@substrat-run/contracts": "^0.160.0",
|
|
31
|
+
"@substrat-run/control-plane-client": "^0.3.11",
|
|
32
|
+
"@substrat-run/psl": "^0.2.5",
|
|
33
|
+
"@substrat-run/kernel": "^0.160.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hono/node-server": "^1.13.0",
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
"tsx": "^4.19.0",
|
|
44
44
|
"typescript": "^7.0.0",
|
|
45
45
|
"vitest": "^5.0.5",
|
|
46
|
-
"@substrat-run/adapter-sqlite": "^0.
|
|
47
|
-
"@substrat-run/connector-fortnox": "^0.4.
|
|
48
|
-
"@substrat-run/
|
|
49
|
-
"@substrat-run/
|
|
46
|
+
"@substrat-run/adapter-sqlite": "^0.160.0",
|
|
47
|
+
"@substrat-run/connector-fortnox": "^0.4.62",
|
|
48
|
+
"@substrat-run/vertical-host": "^0.160.0",
|
|
49
|
+
"@substrat-run/connector-planima": "^0.2.57"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsc -p tsconfig.json",
|
|
56
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.platform-entry.json",
|
|
57
57
|
"test": "vitest run",
|
|
58
58
|
"dev": "tsx dev/server.mts"
|
|
59
59
|
}
|