@fabrika/control-contract 0.9.0-dev.33 → 0.9.0-dev.35

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabrika/control-contract",
3
- "version": "0.9.0-dev.33",
3
+ "version": "0.9.0-dev.35",
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.33",
30
- "@fabrika/app": "0.9.0-dev.33",
31
- "@fabrika/provider-contract": "0.9.0-dev.33"
29
+ "@fabrika/auth-core": "0.9.0-dev.35",
30
+ "@fabrika/app": "0.9.0-dev.35",
31
+ "@fabrika/operations-contract": "0.9.0-dev.35",
32
+ "@fabrika/provider-contract": "0.9.0-dev.35"
32
33
  }
33
34
  }
@@ -0,0 +1,72 @@
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
+ /** What IAM's device-consent page names the resource, above its URL. */
57
+ readonly label: string
58
+ readonly grants: readonly ControlCliScopeGrant[]
59
+ /** The service that verifies the resource's tokens itself: Control's gateway forwards Operations' path unchanged. */
60
+ readonly verifiedBy?: 'operations'
61
+ }
62
+
63
+ /** Every installation that serves the device grant registers exactly these, whichever provider composes it. */
64
+ export const CONTROL_CLI_RESOURCES: readonly ControlCliResource[] = [
65
+ { path: CONTROL_RPC_PATH, label: 'Console', grants: CONTROL_CLI_RPC_GRANTS },
66
+ { path: CONTROL_OPERATIONS_RPC_PATH, label: 'Operations', grants: CONTROL_CLI_OPERATIONS_GRANTS, verifiedBy: 'operations' },
67
+ ]
68
+
69
+ /** The resources a preset's grant covers: those with a grant for it, so `create` concerns the console's RPC alone. */
70
+ export function controlCliPresetPaths(preset: ControlCliPreset): readonly string[] {
71
+ return CONTROL_CLI_RESOURCES.filter((resource) => resource.grants.some((grant) => grant.scope === preset)).map((resource) => resource.path)
72
+ }
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 }
@@ -0,0 +1,37 @@
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
+ /** What IAM's device-consent page names the resource, above its URL. */
29
+ readonly label: string;
30
+ readonly grants: readonly ControlCliScopeGrant[];
31
+ /** The service that verifies the resource's tokens itself: Control's gateway forwards Operations' path unchanged. */
32
+ readonly verifiedBy?: 'operations';
33
+ }
34
+ /** Every installation that serves the device grant registers exactly these, whichever provider composes it. */
35
+ export declare const CONTROL_CLI_RESOURCES: readonly ControlCliResource[];
36
+ /** The resources a preset's grant covers: those with a grant for it, so `create` concerns the console's RPC alone. */
37
+ export declare function controlCliPresetPaths(preset: ControlCliPreset): readonly string[];
@@ -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. */