@fabrika/control-contract 0.9.0-dev.34 → 0.9.0-dev.36
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 -5
- package/src/approval-view.ts +42 -6
- package/src/cli-access.ts +4 -2
- package/src/index.ts +23 -2
- package/types/src/approval-view.d.ts +12 -5
- package/types/src/cli-access.d.ts +2 -0
- package/types/src/index.d.ts +20 -2
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.36",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,9 +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/operations-contract": "0.9.0-dev.
|
|
32
|
-
"@fabrika/provider-contract": "0.9.0-dev.
|
|
29
|
+
"@fabrika/auth-core": "0.9.0-dev.36",
|
|
30
|
+
"@fabrika/app": "0.9.0-dev.36",
|
|
31
|
+
"@fabrika/operations-contract": "0.9.0-dev.36",
|
|
32
|
+
"@fabrika/provider-contract": "0.9.0-dev.36"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/approval-view.ts
CHANGED
|
@@ -1,25 +1,61 @@
|
|
|
1
1
|
// How the approval page shows one access change (ADR-0050 §7): the classification's facts grouped by who reaches an
|
|
2
2
|
// endpoint and by what else they are about, one row per subject with all its lines, ranked by effect, review and
|
|
3
3
|
// reach, and quiet subjects that changed alike folded into one row. Pure, and it decides nothing: whether a run waits is
|
|
4
|
-
// `waitsForApproval` of its lines
|
|
4
|
+
// `waitsForApproval` of its lines, its environment's protection and the categories it chose alone.
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
type AccessChangeDto,
|
|
8
|
+
type ApprovalCategory,
|
|
8
9
|
CHANGE_SUBJECT_KINDS,
|
|
9
10
|
type ChangeAudienceDto,
|
|
10
11
|
type ChangeSubjectDto,
|
|
11
12
|
type ChangeSubjectKind,
|
|
13
|
+
REVIEW_REASONS,
|
|
12
14
|
SURFACE_REACHES,
|
|
13
15
|
type SurfaceReach,
|
|
14
16
|
} from './index.js'
|
|
15
17
|
|
|
18
|
+
/** The fields of a line that place it in a category. */
|
|
19
|
+
export type CategorizedChange = Pick<AccessChangeDto, 'effect' | 'review' | 'reason' | 'rule' | 'audience'>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The approval categories a line belongs to (ADR-0083 §1). A closer-review line belongs to its reason; one stored before
|
|
23
|
+
* lines carried a reason belongs to every reason, so it waits whenever any of them is chosen. The permission, public and
|
|
24
|
+
* CSP categories take a line by its rule, and only when it widens, except a new role. `grants` holds no deploy line.
|
|
25
|
+
*/
|
|
26
|
+
export function changeCategories(change: CategorizedChange): ApprovalCategory[] {
|
|
27
|
+
const categories: ApprovalCategory[] = []
|
|
28
|
+
if (change.review === 'closer') categories.push(...(change.reason === undefined ? REVIEW_REASONS : [change.reason]))
|
|
29
|
+
if (change.rule === 'role.added') categories.push('role-added')
|
|
30
|
+
if (change.effect !== 'widens') return categories
|
|
31
|
+
switch (change.rule) {
|
|
32
|
+
case 'role.grants':
|
|
33
|
+
case 'role.via':
|
|
34
|
+
categories.push('role-actions')
|
|
35
|
+
break
|
|
36
|
+
case 'role.external':
|
|
37
|
+
categories.push('role-external')
|
|
38
|
+
break
|
|
39
|
+
case 'endpoint.public':
|
|
40
|
+
categories.push('public')
|
|
41
|
+
break
|
|
42
|
+
case 'endpoint.added':
|
|
43
|
+
if (change.audience?.reach === 'anyone') categories.push('public')
|
|
44
|
+
break
|
|
45
|
+
case 'csp.source':
|
|
46
|
+
categories.push('csp')
|
|
47
|
+
break
|
|
48
|
+
}
|
|
49
|
+
return categories
|
|
50
|
+
}
|
|
51
|
+
|
|
16
52
|
/**
|
|
17
|
-
* Whether a change waits for a person on a protected environment (ADR-0050 §3):
|
|
18
|
-
* a
|
|
19
|
-
* data. Any other change publishes at once, its lines recorded.
|
|
53
|
+
* Whether a change waits for a person on a protected environment (ADR-0050 §3, ADR-0083 §3): one of its lines belongs to
|
|
54
|
+
* a category the environment chose. Any other change publishes at once, its lines recorded.
|
|
20
55
|
*/
|
|
21
|
-
export function waitsForApproval(changes: readonly
|
|
22
|
-
|
|
56
|
+
export function waitsForApproval(changes: readonly CategorizedChange[], categories: readonly ApprovalCategory[]): boolean {
|
|
57
|
+
const chosen = new Set(categories)
|
|
58
|
+
return changes.some((change) => changeCategories(change).some((category) => chosen.has(category)))
|
|
23
59
|
}
|
|
24
60
|
|
|
25
61
|
/**
|
package/src/cli-access.ts
CHANGED
|
@@ -53,6 +53,8 @@ export const CONTROL_CLI_OPERATIONS_GRANTS: readonly ControlCliScopeGrant[] = [
|
|
|
53
53
|
/** One OAuth resource of the console the command-line client is served, by its path on the console's origin. */
|
|
54
54
|
export interface ControlCliResource {
|
|
55
55
|
readonly path: string
|
|
56
|
+
/** What IAM's device-consent page names the resource, above its URL. */
|
|
57
|
+
readonly label: string
|
|
56
58
|
readonly grants: readonly ControlCliScopeGrant[]
|
|
57
59
|
/** The service that verifies the resource's tokens itself: Control's gateway forwards Operations' path unchanged. */
|
|
58
60
|
readonly verifiedBy?: 'operations'
|
|
@@ -60,8 +62,8 @@ export interface ControlCliResource {
|
|
|
60
62
|
|
|
61
63
|
/** Every installation that serves the device grant registers exactly these, whichever provider composes it. */
|
|
62
64
|
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
|
+
{ 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' },
|
|
65
67
|
]
|
|
66
68
|
|
|
67
69
|
/** The resources a preset's grant covers: those with a grant for it, so `create` concerns the console's RPC alone. */
|
package/src/index.ts
CHANGED
|
@@ -263,6 +263,11 @@ export interface AppEnvDto {
|
|
|
263
263
|
authoring: boolean
|
|
264
264
|
/** A widening of access waits for a human's approval here (ADR-0050); `prod` is protected by default. */
|
|
265
265
|
protected: boolean
|
|
266
|
+
/**
|
|
267
|
+
* The kinds of change that wait for a person while the environment is protected (ADR-0083), in `APPROVAL_CATEGORIES`
|
|
268
|
+
* order; `DEFAULT_APPROVAL_CATEGORIES` unless someone chose otherwise.
|
|
269
|
+
*/
|
|
270
|
+
approvalCategories: ApprovalCategory[]
|
|
266
271
|
/** The run whose snapshot is this environment's active access; null until a run publishes one. */
|
|
267
272
|
publishedRunId: string | null
|
|
268
273
|
/**
|
|
@@ -702,6 +707,18 @@ export const REVIEW_REASONS = ['off-road', 'anyone-calls', 'get-mutation', 'peop
|
|
|
702
707
|
|
|
703
708
|
export type ReviewReason = (typeof REVIEW_REASONS)[number]
|
|
704
709
|
|
|
710
|
+
/**
|
|
711
|
+
* The kinds of change an environment may make wait for a person (ADR-0083): each closer-review reason, the permission
|
|
712
|
+
* changes in the contract (`role-actions`, `role-external`, `role-added`), an endpoint anyone opens (`public`), a CSP
|
|
713
|
+
* origin (`csp`), and a console grant, grant edit or revocation in IAM (`grants`). `changeCategories` places a line.
|
|
714
|
+
*/
|
|
715
|
+
export const APPROVAL_CATEGORIES = [...REVIEW_REASONS, 'role-actions', 'role-external', 'role-added', 'public', 'csp', 'grants'] as const
|
|
716
|
+
|
|
717
|
+
export type ApprovalCategory = (typeof APPROVAL_CATEGORIES)[number]
|
|
718
|
+
|
|
719
|
+
/** What a protected environment waits for when nobody chose otherwise: ADR-0050's closer-review reasons, nothing more. */
|
|
720
|
+
export const DEFAULT_APPROVAL_CATEGORIES: readonly ApprovalCategory[] = REVIEW_REASONS
|
|
721
|
+
|
|
705
722
|
/** What a call sets off, when the line says so. */
|
|
706
723
|
export interface ChangeConsequenceDto {
|
|
707
724
|
kind: 'starts-job'
|
|
@@ -741,7 +758,7 @@ export interface ApprovalDto {
|
|
|
741
758
|
run: RunDto
|
|
742
759
|
/**
|
|
743
760
|
* `none`: no line. `no-widening`: lines that narrow or leave access unchanged. `widening`: a line widens. On a
|
|
744
|
-
* protected environment only a change with a
|
|
761
|
+
* protected environment only a change with a line of a chosen category waits (`waitsForApproval`); any other publishes at once.
|
|
745
762
|
*/
|
|
746
763
|
outcome: 'none' | 'no-widening' | 'widening'
|
|
747
764
|
changes: AccessChangeDto[]
|
|
@@ -751,6 +768,8 @@ export interface ApprovalDto {
|
|
|
751
768
|
/** The published run the change was compared with; null when nothing was published. */
|
|
752
769
|
baselineRunId: string | null
|
|
753
770
|
protected: boolean
|
|
771
|
+
/** The categories the run was classified under (ADR-0083); the defaults for a run classified before they existed. */
|
|
772
|
+
categories: ApprovalCategory[]
|
|
754
773
|
/**
|
|
755
774
|
* The environment's cross-origin list as it stands now: the pages an endpoint the contract opens to the environment's
|
|
756
775
|
* list answers. It is set on the environment, takes effect at once, and no approval covers it (ADR-0050). Only on one
|
|
@@ -791,11 +810,13 @@ export interface CompleteApprovalRequest {
|
|
|
791
810
|
baselineDigest: string
|
|
792
811
|
}
|
|
793
812
|
|
|
794
|
-
/** Change whether a
|
|
813
|
+
/** Change whether, and for which kinds of change, a deploy or a grant waits for approval on one environment (ADR-0050 §4, ADR-0083). */
|
|
795
814
|
export interface SetEnvironmentProtectionRequest {
|
|
796
815
|
appId: string
|
|
797
816
|
env: string
|
|
798
817
|
protected: boolean
|
|
818
|
+
/** The categories that wait while protected; omitted keeps the stored choice. */
|
|
819
|
+
categories?: ApprovalCategory[]
|
|
799
820
|
}
|
|
800
821
|
|
|
801
822
|
export interface TriggerDeployRequest {
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { type AccessChangeDto, type ChangeAudienceDto, type ChangeSubjectDto, type ChangeSubjectKind, type SurfaceReach } from './index.js';
|
|
1
|
+
import { type AccessChangeDto, type ApprovalCategory, type ChangeAudienceDto, type ChangeSubjectDto, type ChangeSubjectKind, type SurfaceReach } from './index.js';
|
|
2
|
+
/** The fields of a line that place it in a category. */
|
|
3
|
+
export type CategorizedChange = Pick<AccessChangeDto, 'effect' | 'review' | 'reason' | 'rule' | 'audience'>;
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
* a
|
|
5
|
-
*
|
|
5
|
+
* The approval categories a line belongs to (ADR-0083 §1). A closer-review line belongs to its reason; one stored before
|
|
6
|
+
* lines carried a reason belongs to every reason, so it waits whenever any of them is chosen. The permission, public and
|
|
7
|
+
* CSP categories take a line by its rule, and only when it widens, except a new role. `grants` holds no deploy line.
|
|
6
8
|
*/
|
|
7
|
-
export declare function
|
|
9
|
+
export declare function changeCategories(change: CategorizedChange): ApprovalCategory[];
|
|
10
|
+
/**
|
|
11
|
+
* Whether a change waits for a person on a protected environment (ADR-0050 §3, ADR-0083 §3): one of its lines belongs to
|
|
12
|
+
* a category the environment chose. Any other change publishes at once, its lines recorded.
|
|
13
|
+
*/
|
|
14
|
+
export declare function waitsForApproval(changes: readonly CategorizedChange[], categories: readonly ApprovalCategory[]): boolean;
|
|
8
15
|
/**
|
|
9
16
|
* The endpoints of one caller group: everyone a reach admits, or the holders of one link mount's share links. `people`
|
|
10
17
|
* marks the machine endpoints that signed-in people reach too, a group of their own, so its title names both.
|
|
@@ -25,6 +25,8 @@ export declare const CONTROL_CLI_OPERATIONS_GRANTS: readonly ControlCliScopeGran
|
|
|
25
25
|
/** One OAuth resource of the console the command-line client is served, by its path on the console's origin. */
|
|
26
26
|
export interface ControlCliResource {
|
|
27
27
|
readonly path: string;
|
|
28
|
+
/** What IAM's device-consent page names the resource, above its URL. */
|
|
29
|
+
readonly label: string;
|
|
28
30
|
readonly grants: readonly ControlCliScopeGrant[];
|
|
29
31
|
/** The service that verifies the resource's tokens itself: Control's gateway forwards Operations' path unchanged. */
|
|
30
32
|
readonly verifiedBy?: 'operations';
|
package/types/src/index.d.ts
CHANGED
|
@@ -229,6 +229,11 @@ export interface AppEnvDto {
|
|
|
229
229
|
authoring: boolean;
|
|
230
230
|
/** A widening of access waits for a human's approval here (ADR-0050); `prod` is protected by default. */
|
|
231
231
|
protected: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* The kinds of change that wait for a person while the environment is protected (ADR-0083), in `APPROVAL_CATEGORIES`
|
|
234
|
+
* order; `DEFAULT_APPROVAL_CATEGORIES` unless someone chose otherwise.
|
|
235
|
+
*/
|
|
236
|
+
approvalCategories: ApprovalCategory[];
|
|
232
237
|
/** The run whose snapshot is this environment's active access; null until a run publishes one. */
|
|
233
238
|
publishedRunId: string | null;
|
|
234
239
|
/**
|
|
@@ -606,6 +611,15 @@ export interface ChangeAudienceDto {
|
|
|
606
611
|
*/
|
|
607
612
|
export declare const REVIEW_REASONS: readonly ["off-road", "anyone-calls", "get-mutation", "people", "adoption", "terminal", "deletes-data"];
|
|
608
613
|
export type ReviewReason = (typeof REVIEW_REASONS)[number];
|
|
614
|
+
/**
|
|
615
|
+
* The kinds of change an environment may make wait for a person (ADR-0083): each closer-review reason, the permission
|
|
616
|
+
* changes in the contract (`role-actions`, `role-external`, `role-added`), an endpoint anyone opens (`public`), a CSP
|
|
617
|
+
* origin (`csp`), and a console grant, grant edit or revocation in IAM (`grants`). `changeCategories` places a line.
|
|
618
|
+
*/
|
|
619
|
+
export declare const APPROVAL_CATEGORIES: readonly ["off-road", "anyone-calls", "get-mutation", "people", "adoption", "terminal", "deletes-data", "role-actions", "role-external", "role-added", "public", "csp", "grants"];
|
|
620
|
+
export type ApprovalCategory = (typeof APPROVAL_CATEGORIES)[number];
|
|
621
|
+
/** What a protected environment waits for when nobody chose otherwise: ADR-0050's closer-review reasons, nothing more. */
|
|
622
|
+
export declare const DEFAULT_APPROVAL_CATEGORIES: readonly ApprovalCategory[];
|
|
609
623
|
/** What a call sets off, when the line says so. */
|
|
610
624
|
export interface ChangeConsequenceDto {
|
|
611
625
|
kind: 'starts-job';
|
|
@@ -643,7 +657,7 @@ export interface ApprovalDto {
|
|
|
643
657
|
run: RunDto;
|
|
644
658
|
/**
|
|
645
659
|
* `none`: no line. `no-widening`: lines that narrow or leave access unchanged. `widening`: a line widens. On a
|
|
646
|
-
* protected environment only a change with a
|
|
660
|
+
* protected environment only a change with a line of a chosen category waits (`waitsForApproval`); any other publishes at once.
|
|
647
661
|
*/
|
|
648
662
|
outcome: 'none' | 'no-widening' | 'widening';
|
|
649
663
|
changes: AccessChangeDto[];
|
|
@@ -653,6 +667,8 @@ export interface ApprovalDto {
|
|
|
653
667
|
/** The published run the change was compared with; null when nothing was published. */
|
|
654
668
|
baselineRunId: string | null;
|
|
655
669
|
protected: boolean;
|
|
670
|
+
/** The categories the run was classified under (ADR-0083); the defaults for a run classified before they existed. */
|
|
671
|
+
categories: ApprovalCategory[];
|
|
656
672
|
/**
|
|
657
673
|
* The environment's cross-origin list as it stands now: the pages an endpoint the contract opens to the environment's
|
|
658
674
|
* list answers. It is set on the environment, takes effect at once, and no approval covers it (ADR-0050). Only on one
|
|
@@ -696,11 +712,13 @@ export interface CompleteApprovalRequest {
|
|
|
696
712
|
candidateDigest: string;
|
|
697
713
|
baselineDigest: string;
|
|
698
714
|
}
|
|
699
|
-
/** Change whether a
|
|
715
|
+
/** Change whether, and for which kinds of change, a deploy or a grant waits for approval on one environment (ADR-0050 §4, ADR-0083). */
|
|
700
716
|
export interface SetEnvironmentProtectionRequest {
|
|
701
717
|
appId: string;
|
|
702
718
|
env: string;
|
|
703
719
|
protected: boolean;
|
|
720
|
+
/** The categories that wait while protected; omitted keeps the stored choice. */
|
|
721
|
+
categories?: ApprovalCategory[];
|
|
704
722
|
}
|
|
705
723
|
export interface TriggerDeployRequest {
|
|
706
724
|
appId: string;
|