@fabrika/control-contract 0.9.0-dev.32 → 0.9.0-dev.34
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/package.json +5 -4
- package/src/cli-access.ts +70 -0
- package/src/index.ts +6 -0
- package/src/rpc.ts +7 -0
- package/types/src/cli-access.d.ts +35 -0
- package/types/src/index.d.ts +6 -0
- package/types/src/rpc.d.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/control-contract",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"zod": "^3.25.76",
|
|
29
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
30
|
-
"@fabrika/app": "0.9.0-dev.
|
|
31
|
-
"@fabrika/
|
|
29
|
+
"@fabrika/auth-core": "0.9.0-dev.34",
|
|
30
|
+
"@fabrika/app": "0.9.0-dev.34",
|
|
31
|
+
"@fabrika/operations-contract": "0.9.0-dev.34",
|
|
32
|
+
"@fabrika/provider-contract": "0.9.0-dev.34"
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// What the `fabrika` command-line client may ask IAM for on an installation's console: one OAuth resource per RPC
|
|
2
|
+
// path, and the presets a person approves it under (RFC 8628 device grant). A preset other than `create` names the
|
|
3
|
+
// one application it holds its actions at (`deploy:<app>`); IAM narrows every action to that app, whatever wider
|
|
4
|
+
// grant the person holds.
|
|
5
|
+
|
|
6
|
+
import { OPERATIONS_ACTIONS } from '@fabrika/operations-contract/access'
|
|
7
|
+
import { CONTROL_ACTIONS, CONTROL_SCOPES } from './access.js'
|
|
8
|
+
|
|
9
|
+
/** The console's RPC paths, each its own OAuth resource: the proxy binds a resource to exactly one row's path. */
|
|
10
|
+
export const CONTROL_RPC_PATH = '/api/rpc'
|
|
11
|
+
export const CONTROL_OPERATIONS_RPC_PATH = '/operations/api/rpc'
|
|
12
|
+
|
|
13
|
+
export const CONTROL_CLI_PRESETS = ['read', 'deploy', 'operate', 'create'] as const
|
|
14
|
+
export type ControlCliPreset = (typeof CONTROL_CLI_PRESETS)[number]
|
|
15
|
+
|
|
16
|
+
/** The scope dimension every preset but `create` is narrowed by. */
|
|
17
|
+
export const CONTROL_CLI_PRESET_PARAMETER = CONTROL_SCOPES.APP
|
|
18
|
+
|
|
19
|
+
/** One preset on one resource: the actions it may carry. */
|
|
20
|
+
export interface ControlCliScopeGrant {
|
|
21
|
+
readonly scope: ControlCliPreset
|
|
22
|
+
/** Absent only on `create`, which holds its action everywhere the person does. */
|
|
23
|
+
readonly parameter?: typeof CONTROL_CLI_PRESET_PARAMETER
|
|
24
|
+
readonly actions: readonly string[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const READ = [CONTROL_ACTIONS.DEPLOY_READ, CONTROL_ACTIONS.DATA_READ]
|
|
28
|
+
const DEPLOY = [...READ, CONTROL_ACTIONS.DEPLOY_TRIGGER]
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The presets on the console's own RPC. None carries access approval, namespaces, source connections, mail or data
|
|
32
|
+
* content: those stay with a person in the console.
|
|
33
|
+
*/
|
|
34
|
+
export const CONTROL_CLI_RPC_GRANTS: readonly ControlCliScopeGrant[] = [
|
|
35
|
+
{ scope: 'read', parameter: CONTROL_CLI_PRESET_PARAMETER, actions: READ },
|
|
36
|
+
{ scope: 'deploy', parameter: CONTROL_CLI_PRESET_PARAMETER, actions: DEPLOY },
|
|
37
|
+
{ scope: 'operate', parameter: CONTROL_CLI_PRESET_PARAMETER, actions: [...DEPLOY, CONTROL_ACTIONS.SECRET_MANAGE, CONTROL_ACTIONS.APP_MANAGE] },
|
|
38
|
+
// Registering an application needs `app.manage` held globally, which also changes and deletes every app and its
|
|
39
|
+
// environments the person may; IAM's consent page warns about a scope bound to no value.
|
|
40
|
+
{ scope: 'create', actions: [CONTROL_ACTIONS.APP_MANAGE] },
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Operations through the console, under the same presets: reading on `read` and `deploy`, triage on `operate`, nothing
|
|
45
|
+
* on `create`. Managing sources, alerts and retention stays with a person in the console.
|
|
46
|
+
*/
|
|
47
|
+
export const CONTROL_CLI_OPERATIONS_GRANTS: readonly ControlCliScopeGrant[] = [
|
|
48
|
+
{ scope: 'read', parameter: CONTROL_CLI_PRESET_PARAMETER, actions: [OPERATIONS_ACTIONS.READ] },
|
|
49
|
+
{ scope: 'deploy', parameter: CONTROL_CLI_PRESET_PARAMETER, actions: [OPERATIONS_ACTIONS.READ] },
|
|
50
|
+
{ scope: 'operate', parameter: CONTROL_CLI_PRESET_PARAMETER, actions: [OPERATIONS_ACTIONS.READ, OPERATIONS_ACTIONS.TRIAGE] },
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
/** One OAuth resource of the console the command-line client is served, by its path on the console's origin. */
|
|
54
|
+
export interface ControlCliResource {
|
|
55
|
+
readonly path: string
|
|
56
|
+
readonly grants: readonly ControlCliScopeGrant[]
|
|
57
|
+
/** The service that verifies the resource's tokens itself: Control's gateway forwards Operations' path unchanged. */
|
|
58
|
+
readonly verifiedBy?: 'operations'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Every installation that serves the device grant registers exactly these, whichever provider composes it. */
|
|
62
|
+
export const CONTROL_CLI_RESOURCES: readonly ControlCliResource[] = [
|
|
63
|
+
{ path: CONTROL_RPC_PATH, grants: CONTROL_CLI_RPC_GRANTS },
|
|
64
|
+
{ path: CONTROL_OPERATIONS_RPC_PATH, grants: CONTROL_CLI_OPERATIONS_GRANTS, verifiedBy: 'operations' },
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
/** The resources a preset's grant covers: those with a grant for it, so `create` concerns the console's RPC alone. */
|
|
68
|
+
export function controlCliPresetPaths(preset: ControlCliPreset): readonly string[] {
|
|
69
|
+
return CONTROL_CLI_RESOURCES.filter((resource) => resource.grants.some((grant) => grant.scope === preset)).map((resource) => resource.path)
|
|
70
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './access.js'
|
|
|
6
6
|
export * from './builder-bootstrap.js'
|
|
7
7
|
export * from './builder-connections.js'
|
|
8
8
|
export * from './builder-pairing.js'
|
|
9
|
+
export * from './cli-access.js'
|
|
9
10
|
export * from './mail.js'
|
|
10
11
|
|
|
11
12
|
export type { JsonValue }
|
|
@@ -276,6 +277,11 @@ export interface AppEnvDto {
|
|
|
276
277
|
* a Control released before it.
|
|
277
278
|
*/
|
|
278
279
|
accessMap?: AccessMapDto
|
|
280
|
+
/**
|
|
281
|
+
* When Control took the environment offline (`apps.environments.suspend`), in Unix seconds; absent while it serves,
|
|
282
|
+
* and from a Control released before it.
|
|
283
|
+
*/
|
|
284
|
+
suspendedAt?: number
|
|
279
285
|
namespaceId: string | null
|
|
280
286
|
provider: string
|
|
281
287
|
target: ProviderEnvelopeDto
|
package/src/rpc.ts
CHANGED
|
@@ -194,6 +194,13 @@ export interface ControlRpcContract {
|
|
|
194
194
|
protect: RpcProcedure<SetEnvironmentProtectionRequest, AppEnvDto>
|
|
195
195
|
/** The environment's next deploy retires the key its signed tokens are signed with and signs with a new one. */
|
|
196
196
|
rotateTokenKey: RpcProcedure<AppEnvironmentInput, RotateTokenKeyResponse>
|
|
197
|
+
/**
|
|
198
|
+
* Take the environment offline in an incident: on a namespace proxy every request to it answers 503 once the
|
|
199
|
+
* republished proxy is live; on Cloudflare its object goes into maintenance `closed`. Repeating it is a retry.
|
|
200
|
+
*/
|
|
201
|
+
suspend: RpcProcedure<AppEnvironmentInput, AppEnvDto>
|
|
202
|
+
/** Undo `suspend`: the proxy routes the environment again, or the object returns to the mode it was in. */
|
|
203
|
+
resume: RpcProcedure<AppEnvironmentInput, AppEnvDto>
|
|
197
204
|
}
|
|
198
205
|
secrets: {
|
|
199
206
|
list: RpcProcedure<AppIdInput, ListResponse<AppSecretDto>>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The console's RPC paths, each its own OAuth resource: the proxy binds a resource to exactly one row's path. */
|
|
2
|
+
export declare const CONTROL_RPC_PATH = "/api/rpc";
|
|
3
|
+
export declare const CONTROL_OPERATIONS_RPC_PATH = "/operations/api/rpc";
|
|
4
|
+
export declare const CONTROL_CLI_PRESETS: readonly ["read", "deploy", "operate", "create"];
|
|
5
|
+
export type ControlCliPreset = (typeof CONTROL_CLI_PRESETS)[number];
|
|
6
|
+
/** The scope dimension every preset but `create` is narrowed by. */
|
|
7
|
+
export declare const CONTROL_CLI_PRESET_PARAMETER: "app";
|
|
8
|
+
/** One preset on one resource: the actions it may carry. */
|
|
9
|
+
export interface ControlCliScopeGrant {
|
|
10
|
+
readonly scope: ControlCliPreset;
|
|
11
|
+
/** Absent only on `create`, which holds its action everywhere the person does. */
|
|
12
|
+
readonly parameter?: typeof CONTROL_CLI_PRESET_PARAMETER;
|
|
13
|
+
readonly actions: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The presets on the console's own RPC. None carries access approval, namespaces, source connections, mail or data
|
|
17
|
+
* content: those stay with a person in the console.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CONTROL_CLI_RPC_GRANTS: readonly ControlCliScopeGrant[];
|
|
20
|
+
/**
|
|
21
|
+
* Operations through the console, under the same presets: reading on `read` and `deploy`, triage on `operate`, nothing
|
|
22
|
+
* on `create`. Managing sources, alerts and retention stays with a person in the console.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CONTROL_CLI_OPERATIONS_GRANTS: readonly ControlCliScopeGrant[];
|
|
25
|
+
/** One OAuth resource of the console the command-line client is served, by its path on the console's origin. */
|
|
26
|
+
export interface ControlCliResource {
|
|
27
|
+
readonly path: string;
|
|
28
|
+
readonly grants: readonly ControlCliScopeGrant[];
|
|
29
|
+
/** The service that verifies the resource's tokens itself: Control's gateway forwards Operations' path unchanged. */
|
|
30
|
+
readonly verifiedBy?: 'operations';
|
|
31
|
+
}
|
|
32
|
+
/** Every installation that serves the device grant registers exactly these, whichever provider composes it. */
|
|
33
|
+
export declare const CONTROL_CLI_RESOURCES: readonly ControlCliResource[];
|
|
34
|
+
/** The resources a preset's grant covers: those with a grant for it, so `create` concerns the console's RPC alone. */
|
|
35
|
+
export declare function controlCliPresetPaths(preset: ControlCliPreset): readonly string[];
|
package/types/src/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './access.js';
|
|
|
5
5
|
export * from './builder-bootstrap.js';
|
|
6
6
|
export * from './builder-connections.js';
|
|
7
7
|
export * from './builder-pairing.js';
|
|
8
|
+
export * from './cli-access.js';
|
|
8
9
|
export * from './mail.js';
|
|
9
10
|
export type { JsonValue };
|
|
10
11
|
/** A plain list response. */
|
|
@@ -242,6 +243,11 @@ export interface AppEnvDto {
|
|
|
242
243
|
* a Control released before it.
|
|
243
244
|
*/
|
|
244
245
|
accessMap?: AccessMapDto;
|
|
246
|
+
/**
|
|
247
|
+
* When Control took the environment offline (`apps.environments.suspend`), in Unix seconds; absent while it serves,
|
|
248
|
+
* and from a Control released before it.
|
|
249
|
+
*/
|
|
250
|
+
suspendedAt?: number;
|
|
245
251
|
namespaceId: string | null;
|
|
246
252
|
provider: string;
|
|
247
253
|
target: ProviderEnvelopeDto;
|
package/types/src/rpc.d.ts
CHANGED
|
@@ -116,6 +116,13 @@ export interface ControlRpcContract {
|
|
|
116
116
|
protect: RpcProcedure<SetEnvironmentProtectionRequest, AppEnvDto>;
|
|
117
117
|
/** The environment's next deploy retires the key its signed tokens are signed with and signs with a new one. */
|
|
118
118
|
rotateTokenKey: RpcProcedure<AppEnvironmentInput, RotateTokenKeyResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Take the environment offline in an incident: on a namespace proxy every request to it answers 503 once the
|
|
121
|
+
* republished proxy is live; on Cloudflare its object goes into maintenance `closed`. Repeating it is a retry.
|
|
122
|
+
*/
|
|
123
|
+
suspend: RpcProcedure<AppEnvironmentInput, AppEnvDto>;
|
|
124
|
+
/** Undo `suspend`: the proxy routes the environment again, or the object returns to the mode it was in. */
|
|
125
|
+
resume: RpcProcedure<AppEnvironmentInput, AppEnvDto>;
|
|
119
126
|
};
|
|
120
127
|
secrets: {
|
|
121
128
|
list: RpcProcedure<AppIdInput, ListResponse<AppSecretDto>>;
|