@fabrika/auth-core 0.9.0-dev.2 → 0.9.0-dev.20

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.
Files changed (47) hide show
  1. package/package.json +2 -2
  2. package/src/canonical-path.ts +18 -0
  3. package/src/client-address.ts +74 -0
  4. package/src/contract-canonical.ts +152 -1
  5. package/src/contract-encoding.ts +181 -0
  6. package/src/contract.ts +201 -9
  7. package/src/dev-environment.ts +6 -0
  8. package/src/egress.ts +97 -0
  9. package/src/endpoint-digest.ts +22 -2
  10. package/src/framework-release.ts +2 -0
  11. package/src/framework-variables.ts +15 -0
  12. package/src/index.ts +8 -0
  13. package/src/locale.ts +1 -1
  14. package/src/managed-environment.ts +140 -0
  15. package/src/membership.ts +12 -4
  16. package/src/ops.ts +1933 -0
  17. package/src/public-egress.ts +168 -0
  18. package/src/requirement.ts +5 -2
  19. package/src/rpc.ts +8 -8
  20. package/src/sha256.ts +52 -14
  21. package/src/terminal.ts +105 -0
  22. package/src/token.ts +73 -13
  23. package/src/types.ts +63 -2
  24. package/src/wire.ts +7 -0
  25. package/types/src/canonical-path.d.ts +6 -0
  26. package/types/src/client-address.d.ts +7 -0
  27. package/types/src/contract-canonical.d.ts +11 -1
  28. package/types/src/contract-encoding.d.ts +18 -0
  29. package/types/src/contract.d.ts +186 -8
  30. package/types/src/dev-environment.d.ts +5 -0
  31. package/types/src/egress.d.ts +27 -0
  32. package/types/src/endpoint-digest.d.ts +5 -0
  33. package/types/src/framework-release.d.ts +2 -0
  34. package/types/src/framework-variables.d.ts +12 -1
  35. package/types/src/index.d.ts +8 -0
  36. package/types/src/locale.d.ts +1 -1
  37. package/types/src/managed-environment.d.ts +32 -0
  38. package/types/src/membership.d.ts +8 -3
  39. package/types/src/ops.d.ts +657 -0
  40. package/types/src/public-egress.d.ts +31 -0
  41. package/types/src/requirement.d.ts +2 -2
  42. package/types/src/rpc.d.ts +5 -5
  43. package/types/src/sha256.d.ts +10 -0
  44. package/types/src/terminal.d.ts +72 -0
  45. package/types/src/token.d.ts +36 -11
  46. package/types/src/types.d.ts +42 -2
  47. package/types/src/wire.d.ts +6 -0
package/src/types.ts CHANGED
@@ -31,8 +31,9 @@ export function isWorkloadKind(value: unknown): value is WorkloadKind {
31
31
  * - 'grant' — explicit `grants` row
32
32
  * - 'bootstrap' — IAM_BOOTSTRAP_ADMINS env match (resolution-time only)
33
33
  * - `group:${groupRef}` — IdP group → role mapping (the `<org>/<team>` ref)
34
+ * - 'terminal' — a grant of the terminal a person is signed in on (ADR-0067)
34
35
  */
35
- export type PermissionSource = 'grant' | 'bootstrap' | `group:${string}`
36
+ export type PermissionSource = 'grant' | 'bootstrap' | 'terminal' | `group:${string}`
36
37
 
37
38
  /**
38
39
  * A flat, app-owned scope coordinate — one dimension (`type`) and an opaque value.
@@ -44,6 +45,57 @@ export interface Scope {
44
45
  value: string
45
46
  }
46
47
 
48
+ /**
49
+ * The pseudo-scope of a relation entry: `{ type: '~rel', value: <relation> }` means the action is held where a row of
50
+ * the application names the principal in that relation. No dimension may start with `~`, so no reader that compares
51
+ * scopes by `(type, value)` mistakes one for a dimension value, and none resolves it but the framework.
52
+ */
53
+ export const RELATION_SCOPE_TYPE = '~rel'
54
+
55
+ /**
56
+ * The pseudo-scope of a relation entry held inside one node: `{ type: '~relin', value: '<relation>:<dimension>:<node>' }`
57
+ * means the action is held where a row names the principal in that relation, on rows that lie inside `node` of
58
+ * `dimension`. IAM gives it a grant at that node of a role with `via`. Its own type, never `~rel`: a release that reads
59
+ * `~rel` as "the relation anywhere" ignores this one and reaches less.
60
+ */
61
+ export const RELATION_INSIDE_SCOPE_TYPE = '~relin'
62
+
63
+ /** A relation held inside one node of a dimension, as a `~relin` entry names it. */
64
+ export interface RelationInside {
65
+ readonly relation: string
66
+ readonly dimension: string
67
+ readonly node: string
68
+ }
69
+
70
+ /**
71
+ * The `~relin` scope of `relation` inside `node` of `dimension`. A relation or dimension name never holds `:` (the
72
+ * contract's names do not), so the node, last, is read back verbatim, colons included; a name that holds one is refused.
73
+ */
74
+ export function relationInsideScope(inside: RelationInside): Scope {
75
+ if (inside.relation === '' || inside.dimension === '' || inside.relation.includes(':') || inside.dimension.includes(':')) {
76
+ throw new Error('a relation held inside a node names a relation and a dimension without ":"')
77
+ }
78
+ return { type: RELATION_INSIDE_SCOPE_TYPE, value: `${inside.relation}:${inside.dimension}:${inside.node}` }
79
+ }
80
+
81
+ /** The relation, dimension and node of a `~relin` scope, or null for any other scope or a malformed value. */
82
+ export function parseRelationInside(scope: Scope): RelationInside | null {
83
+ if (scope.type !== RELATION_INSIDE_SCOPE_TYPE) {
84
+ return null
85
+ }
86
+ const first = scope.value.indexOf(':')
87
+ const second = first === -1 ? -1 : scope.value.indexOf(':', first + 1)
88
+ if (first <= 0 || second <= first + 1 || second === scope.value.length - 1) {
89
+ return null
90
+ }
91
+ return { relation: scope.value.slice(0, first), dimension: scope.value.slice(first + 1, second), node: scope.value.slice(second + 1) }
92
+ }
93
+
94
+ /** A scope type no dimension, grant or key may name: IAM derives a `~` entry itself and never stores one. */
95
+ export function isReservedScopeType(type: string): boolean {
96
+ return type.startsWith('~')
97
+ }
98
+
47
99
  export interface PermissionEntry {
48
100
  action: string
49
101
  /** null = global / all scopes */
@@ -79,6 +131,13 @@ export interface RoleDef {
79
131
  member?: { scope: string; assignableBy?: string[] }
80
132
  /** An external principal may hold this membership role (ADR-0051). Only a membership role may declare it. */
81
133
  external?: true
134
+ /**
135
+ * Relation → exact actions. A GLOBAL grant of this role also carries `{ action, scope: { type: '~rel', value:
136
+ * relation } }`: the application holds the action where one of its rows names the principal in that relation. A
137
+ * grant at a node carries `~relin` instead (`relationInsideScope`): the relation holds only inside that node. Only an
138
+ * internal role declares it.
139
+ */
140
+ via?: Record<string, string[]>
82
141
  }
83
142
 
84
143
  /**
@@ -146,7 +205,7 @@ export interface AppDelegationDef {
146
205
  purpose: 'members' | 'creates'
147
206
  }
148
207
 
149
- /** An app's full authz vocabulary, declared in the app's code, reconciled into Propustka. */
208
+ /** An app's full authz vocabulary, declared in the app's code, reconciled into IAM. */
150
209
  export interface AppSchema {
151
210
  scopes: AppScopeDef[]
152
211
  actions: AppActionDef[]
@@ -177,6 +236,8 @@ export interface AppSchema {
177
236
  members?: { manage: string; list: string }
178
237
  /** `labels`: a holder of the app's `members.list` also sees each member's label. Absent, labels stay with `members.manage`. */
179
238
  directory?: 'labels'
239
+ /** The app's identification page for a person at an enrolled terminal (ADR-0067); absent, no terminal lists it. */
240
+ terminal?: { identify: string }
180
241
  }
181
242
 
182
243
  /**
package/src/wire.ts CHANGED
@@ -63,6 +63,13 @@ export function proxySecretVariable(id: string): string {
63
63
  return `${FABRIKA_PROXY_SECRET}_${sha256Hex(id).slice(0, 32).toUpperCase()}`
64
64
  }
65
65
 
66
+ /**
67
+ * The variable holding the secret the platform proxy sends IAM's installation entry in `PROXY_SECRET_HEADER`. The proxy
68
+ * and IAM hold it under this one name. It proves only who wrote IAM's request-id header; IAM keys every request without
69
+ * it on one shared client bucket.
70
+ */
71
+ export const IAM_PROXY_SECRET_VARIABLE = 'FABRIKA_INSTALLATION_PROXY_SECRET_IAM'
72
+
66
73
  /**
67
74
  * Every `X-Fabrika-*` name a proxy hop carries to an application. Caddy's first step and the Cloudflare proxy Worker
68
75
  * delete each of them from the client's request before anything else, then set only what the decision asserts. A new
@@ -18,3 +18,9 @@ export declare function splitRequestTarget(target: string): RequestTarget;
18
18
  * the string because `new URL()` resolves dot segments and so hides the very paths that must be refused.
19
19
  */
20
20
  export declare function rawRequestTarget(url: string): RequestTarget;
21
+ /**
22
+ * The absolute URL of `path` on `origin`, or `null` when `path` is not a path of that origin: the one rule for a
23
+ * redirect or return target that must stay on its own origin. A leading `//` or any `\` would make a browser read a
24
+ * host from it, and a browser strips a tab or newline before parsing, so no control character is admitted.
25
+ */
26
+ export declare function sameOriginTarget(origin: string, path: string): string | null;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The client a client-address header value counts as: an IPv4 address, or an IPv6 address's /64 (one subscriber's
3
+ * prefix, of which it may hold every address); an IPv4-mapped IPv6 address counts as its IPv4 address. Only the first
4
+ * value counts, so a caller that appends a second copy cannot change the key. `null` when the value is absent or no
5
+ * IP address.
6
+ */
7
+ export declare function clientAddressKey(header: string | null): string | null;
@@ -1,4 +1,4 @@
1
- import type { BodyAdmission, ContractArtifact, OutputShape, SchemaShape, TableActionArtifact } from './contract';
1
+ import type { BodyAdmission, ConditionArtifact, ContractArtifact, OutputShape, SchemaShape, TableActionArtifact } from './contract';
2
2
  /**
3
3
  * The artifact with every array whose order carries no meaning sorted: endpoints by id, and every list of names.
4
4
  * Tuple items and union options keep their order, because it changes what a schema admits. Object keys are left
@@ -11,9 +11,19 @@ export declare function canonicalArtifactJson(artifact: ContractArtifact): strin
11
11
  export declare function canonicalJson(value: unknown): string;
12
12
  /** Each action of one table operation, `[]` for none: how a reader of the artifact reads `actions.read` and the others. */
13
13
  export declare function tableActions(actions: TableActionArtifact | null): readonly string[];
14
+ /**
15
+ * A condition with its connectives' operands and its `in` / `notIn` lists sorted by their canonical JSON: AND and OR
16
+ * commute and a list is a set, so neither order changes which rows it admits.
17
+ */
18
+ export declare function canonicalCondition(condition: ConditionArtifact): ConditionArtifact;
14
19
  /** A body admission with its content types sorted. */
15
20
  export declare function canonicalAdmission(admission: BodyAdmission): BodyAdmission;
16
21
  /** An output shape: an attachment keeps its column order, which is the file's; each column's shape is canonical. */
17
22
  export declare function canonicalOutput(shape: OutputShape): OutputShape;
18
23
  /** A schema shape with its enum values sorted; tuple items and union options keep their order. */
19
24
  export declare function canonicalShape(shape: SchemaShape): SchemaShape;
25
+ /**
26
+ * `canonicalJson(value)` written in pieces to `write`, so a digest of a large value never holds its whole text. Each
27
+ * object is rebuilt as `sortKeys` rebuilds it, so integer-like keys come first exactly as `JSON.stringify` orders them.
28
+ */
29
+ export declare function writeCanonicalJson(value: unknown, write: (piece: string) => void): void;
@@ -0,0 +1,18 @@
1
+ import type { ContractArtifact } from './contract';
2
+ /** The `encoding` of an encoded artifact; a plain artifact has no such key. */
3
+ export declare const SHARED_SHAPES_ENCODING = "shared-shapes";
4
+ /** In place of a shape: `shapes[index]` of the encoded artifact, which is always written before it is referenced. */
5
+ export interface SharedShapeReference {
6
+ readonly type: 'shared';
7
+ readonly index: number;
8
+ }
9
+ /** An artifact in the shared encoding, as JSON. */
10
+ export interface EncodedArtifact {
11
+ readonly encoding: typeof SHARED_SHAPES_ENCODING;
12
+ readonly shapes: readonly object[];
13
+ readonly artifact: object;
14
+ }
15
+ /** The canonical artifact in the shared encoding. */
16
+ export declare function encodeArtifact(artifact: ContractArtifact): EncodedArtifact;
17
+ /** The encoded artifact as text, keys sorted: what a build bundles. */
18
+ export declare function encodedArtifactJson(artifact: ContractArtifact): string;
@@ -1,5 +1,7 @@
1
1
  import type { Locale } from './locale';
2
2
  import type { MailTemplates } from './mail';
3
+ import type { DeclaredEgress } from './public-egress';
4
+ import type { TerminalArtifact } from './terminal';
3
5
  /**
4
6
  * The artifact format this release writes. A release that changes the artifact raises it, and Control upcasts every
5
7
  * older format of its window to this one (ADR-0062). The 0.4, 0.5 and 0.6 artifacts carry no `format`.
@@ -18,10 +20,15 @@ export interface ContractArtifact extends EndpointTable {
18
20
  /** Action → description. Exact actions only; the artifact holds no wildcard. */
19
21
  readonly actions: Readonly<Record<string, string>>;
20
22
  readonly roles: Readonly<Record<string, RoleArtifact>>;
23
+ /**
24
+ * The relations a table's rows confer (`relations: { owner: { dimension: 'project' } }`): a role's `via` holds its
25
+ * actions where a row names the caller. Absent unless declared, so the digest stays.
26
+ */
27
+ readonly relations?: Readonly<Record<string, RelationArtifact>>;
21
28
  readonly mounts: Readonly<Record<string, MountArtifact>>;
22
29
  readonly files: Readonly<Record<string, FileCollectionArtifact>>;
23
30
  /**
24
- * The file kinds (`c.files({ types, maxBytes, scan? })`): classes of stored files a table's file column holds. A kind
31
+ * The file kinds (`c.files({ types, maxBytes, scan?, inline? })`): classes of stored files a table's file column holds. A kind
25
32
  * has no owner and no endpoint; the table that holds a file is its authority. Absent unless declared, so the digest stays.
26
33
  */
27
34
  readonly fileKinds?: Readonly<Record<string, FileKindArtifact>>;
@@ -62,6 +69,11 @@ export interface ContractArtifact extends EndpointTable {
62
69
  };
63
70
  /** `labels`: the application's directory shows labels to `members.list` holders. Absent unless declared, so digests stay. */
64
71
  readonly directory?: 'labels';
72
+ /**
73
+ * The page on the application's own origin that identifies a person at an enrolled terminal (ADR-0067): IAM sends a
74
+ * terminal's browser there, and only an application that declares it may assert a person. Absent unless declared.
75
+ */
76
+ readonly terminal?: TerminalArtifact;
65
77
  /**
66
78
  * What each procedure of the staged kit admits and how long it runs, by endpoint id, with every default applied: the
67
79
  * rules the application applies itself, beside the row the proxy applies. Absent for a contract with no such
@@ -168,7 +180,8 @@ interface EndpointRowBase {
168
180
  readonly crossOrigin?: CrossOriginForm;
169
181
  /**
170
182
  * `file`: the procedure answers a stored file (an output `file('<kind>')`), so the proxy and the application give every
171
- * answer of it, a denial included, ADR-0022's file treatment. Absent otherwise, so every other row keeps its digest.
183
+ * answer of it, a denial included, ADR-0022's file treatment. `inline-file`: the same, for a kind declared `inline:
184
+ * true`, whose XML documents are shown too. Absent otherwise, so every other row keeps its digest.
172
185
  */
173
186
  readonly response?: EndpointResponse;
174
187
  /**
@@ -186,8 +199,8 @@ interface EndpointRowBase {
186
199
  }
187
200
  /** What the proxy does with an anonymous request's `Authorization` on a row that names it: forward it to the application. */
188
201
  export type EndpointAuthorization = 'forward';
189
- /** The answer profile of a row that answers a stored file. */
190
- export type EndpointResponse = 'file';
202
+ /** The answer profile of a row that answers a stored file: `inline-file` also shows the XML documents a machine reads. */
203
+ export type EndpointResponse = 'file' | 'inline-file';
191
204
  /** A cacheable row's lifetime: `maxAgeSeconds`, or `immutable`, a year, for an input that names an immutable value. */
192
205
  export type EndpointCache = {
193
206
  readonly maxAgeSeconds: number;
@@ -226,7 +239,7 @@ export interface BodyAdmission {
226
239
  * `action` is that action in some scope, global included, and only globally under the `app` form. The access form is
227
240
  * what the framework then resolves.
228
241
  */
229
- export type EndpointRequirement = MemberRequirement | ActionRequirement | CapabilitiesRequirement;
242
+ export type EndpointRequirement = MemberRequirement | ActionRequirement | AnyOfRequirement | CapabilitiesRequirement;
230
243
  export interface MemberRequirement {
231
244
  readonly kind: 'member';
232
245
  }
@@ -235,6 +248,21 @@ export interface ActionRequirement {
235
248
  readonly action: string;
236
249
  readonly access: AccessForm;
237
250
  }
251
+ /**
252
+ * Any one of several actions (`access: { anyOf, app: true }`), each held as a global grant, the `app` form's rule: two to
253
+ * `MAX_ANY_OF` distinct actions, sorted, so the order in the source does not change the digest.
254
+ */
255
+ export interface AnyOfRequirement {
256
+ readonly kind: 'anyOf';
257
+ readonly actions: readonly [string, string, ...string[]];
258
+ readonly access: {
259
+ readonly form: 'app';
260
+ };
261
+ }
262
+ /** The most actions an `anyOf` requirement lists. */
263
+ export declare const MAX_ANY_OF = 16;
264
+ /** Whether `actions` is an `anyOf` list as a row carries it: two to `MAX_ANY_OF` actions, strictly ascending. */
265
+ export declare function isAnyOfList(actions: readonly string[]): boolean;
238
266
  /**
239
267
  * Several capabilities (`access: { capabilities }`), by the name the handler reads each under (`ctx.capabilities.<name>`):
240
268
  * the token must carry every action, and the access form of each narrows it as it narrows a single one. At least two.
@@ -326,6 +354,8 @@ export interface FileShape {
326
354
  readonly kind: string;
327
355
  }
328
356
  export declare function isFileShape(shape: OutputShape): shape is FileShape;
357
+ /** The kinds of the files a schema holds, anywhere in it, each once per place it appears. */
358
+ export declare function fileKindsIn(shape: SchemaShape): readonly string[];
329
359
  /**
330
360
  * What a procedure answers: a JSON value of a schema, a file of rows (`attachment()` of `@fabrika/app/contract`), or a
331
361
  * redirect (`redirect()`).
@@ -427,6 +457,15 @@ export interface RoleArtifact {
427
457
  } | null;
428
458
  /** An external principal may hold this membership role (ADR-0051). Absent unless declared, so digests stay. */
429
459
  readonly external?: true;
460
+ /**
461
+ * Relation → actions the holder of a global grant of this role holds at each node a relation row names them at.
462
+ * Absent unless declared, so digests stay.
463
+ */
464
+ readonly via?: Readonly<Record<string, readonly string[]>>;
465
+ }
466
+ /** A relation of the vocabulary: the dimension whose nodes its rows name. */
467
+ export interface RelationArtifact {
468
+ readonly dimension: string;
430
469
  }
431
470
  export type MountArtifact = RpcMountArtifact | LinkMountArtifact | SpaMountArtifact | HealthMountArtifact | FormMountArtifact | WebhookMountArtifact;
432
471
  export interface RpcMountArtifact {
@@ -615,6 +654,11 @@ export interface FileKindArtifact {
615
654
  readonly maxBytes: number;
616
655
  /** Present when every file of the kind waits `quarantined` for a clean malware verdict before it is served. */
617
656
  readonly scan?: true;
657
+ /**
658
+ * Present when its files are shown rather than downloaded: every type is an inert image or an XML document a machine
659
+ * reads, and a row answering it is `response: 'inline-file'`. Absent otherwise, so every other kind keeps its digest.
660
+ */
661
+ readonly inline?: true;
618
662
  }
619
663
  export interface JobArtifact {
620
664
  readonly schedule: string;
@@ -688,10 +732,12 @@ export interface DeclaredReach {
688
732
  */
689
733
  readonly signs?: readonly string[];
690
734
  /**
691
- * The HTTPS origins this site's code calls (`fetch`), sorted: a credentialed procedure, a webhook or a job. Absent
692
- * unless declared, so the digest stays.
735
+ * The HTTPS origins this site's code calls (`fetch`), sorted, each an exact origin or a one-label pattern
736
+ * (`parseEgressEntry`): a credentialed procedure, a webhook or a job. Or `'public'` (a cron job only): every public
737
+ * host over HTTPS or HTTP, never the installation or a private network (ADR-0075). Absent unless declared, so the
738
+ * digest stays.
693
739
  */
694
- readonly egress?: readonly string[];
740
+ readonly egress?: DeclaredEgress;
695
741
  /**
696
742
  * A public procedure's workload actions, sorted: all its handler holds, through the key Control issues for the
697
743
  * endpoint (`contractWorkloads`). Present only on a public procedure's entry, so every other digest stays.
@@ -728,6 +774,11 @@ export interface CspSource {
728
774
  * two. A single action stays text, so the artifact of a policy that names one keeps its shape and digest.
729
775
  */
730
776
  export type TableActionArtifact = string | readonly string[];
777
+ /**
778
+ * An application table's `actions.read` that every `app` endpoint, job and webhook reads with, whatever its action; never
779
+ * a public procedure, a scoped site, a link or an export. No vocabulary may declare an action of this name.
780
+ */
781
+ export declare const READ_ANY = "any";
731
782
  export interface TablePolicyArtifact {
732
783
  readonly scope: TableScope;
733
784
  /** An inbox's read action is `read`; it has no write action, because only its form appends. */
@@ -758,6 +809,133 @@ export interface TablePolicyArtifact {
758
809
  * actions are the file's authority. Absent unless declared, so the digest stays.
759
810
  */
760
811
  readonly files?: Readonly<Record<string, string>>;
812
+ /**
813
+ * A view (ADR-0072): read like its scope's tables, written by nothing, its containment stated by its SQL alone.
814
+ * Absent for a table, so the digest stays.
815
+ */
816
+ readonly view?: true;
817
+ /** Relation → how a row of this table confers it. Absent unless declared, so the digest stays. */
818
+ readonly confers?: Readonly<Record<string, ConfersArtifact>>;
819
+ /** Action → the condition a row must meet for it, narrowing what any grant of it reaches. Absent unless declared. */
820
+ readonly when?: Readonly<Record<string, ConditionArtifact>>;
821
+ /**
822
+ * Relation → action → the condition a row the relation reaches must meet for it; it narrows that relation's reach only.
823
+ * Absent unless declared, so the digest stays. A reader that ignores it reaches more: Control refuses to publish it to
824
+ * an application pinned below the release that enforces it.
825
+ */
826
+ readonly relationWhen?: Readonly<Record<string, Readonly<Record<string, ConditionArtifact>>>>;
827
+ /**
828
+ * Relation of the table's own dimension → the ancestor its rows reveal. Absent unless declared, so the digest stays.
829
+ * A reader that ignores it reaches less, never more.
830
+ */
831
+ readonly reveals?: Readonly<Record<string, RevealsArtifact>>;
832
+ /**
833
+ * Dimension outside the chain → the column a `Within`'s read reaches a row through. Absent unless declared, so the
834
+ * digest stays. A reader that ignores it reaches less, never more.
835
+ */
836
+ readonly readThrough?: Readonly<Record<string, string>>;
837
+ /**
838
+ * Dimension of `readThrough` → the actions a `Ref` held through that path holds, writes included; whoever inserts the
839
+ * path's column must hold each at the node it names. Absent unless declared, so the digest stays. A reader that
840
+ * ignores it reaches less, never more.
841
+ */
842
+ readonly writeThrough?: Readonly<Record<string, readonly string[]>>;
843
+ /**
844
+ * The table's own dimension → the ancestor its rows reveal to a grant at their node, for a `Within`'s reads. Absent
845
+ * unless declared, so the digest stays. A reader that ignores it reaches less, never more.
846
+ */
847
+ readonly memberReveals?: Readonly<Record<string, MemberRevealsArtifact>>;
848
+ /**
849
+ * Relation → the access view that lists the rows it reaches (ADR-0076). Absent unless declared, so the digest stays.
850
+ * A reader that ignores it reaches less, never more.
851
+ */
852
+ readonly access?: Readonly<Record<string, AccessArtifact>>;
853
+ }
854
+ /** An access view: its `row` column names the table's key; `principal` is compared to the caller, `member` to its nodes. */
855
+ export interface AccessArtifact {
856
+ readonly view: string;
857
+ readonly row: string;
858
+ readonly principal: string | null;
859
+ readonly member: string | null;
860
+ }
861
+ /**
862
+ * A row reveals its node in `to` for `actions` to a grant of them at the row's own node, or at the node its path to the
863
+ * key's dimension names, while `when` admits the row.
864
+ */
865
+ export interface MemberRevealsArtifact {
866
+ readonly to: string;
867
+ readonly actions: readonly string[];
868
+ readonly when?: ConditionArtifact;
869
+ /**
870
+ * Through a path, on a table with an insert: the writer picks the node, and `self` lets it pick one where it holds a
871
+ * grant the reveal counts. Absent otherwise; only a reader that refuses a path's key reads it.
872
+ */
873
+ readonly assign?: {
874
+ readonly self: boolean;
875
+ };
876
+ }
877
+ /** A row the relation reaches reveals its node in `to` for `actions`, while `when` admits the row. */
878
+ export interface RevealsArtifact {
879
+ readonly to: string;
880
+ readonly actions: readonly string[];
881
+ readonly when?: ConditionArtifact;
882
+ /** On a reveal matched through `readThrough`: an insert delegates, and `self` lets it name a node its writer holds. */
883
+ readonly assign?: {
884
+ readonly self: boolean;
885
+ };
886
+ }
887
+ /** A row names `principal` at the node in `node`, until `expires`, while `when` admits it; `assign` bounds its writer. */
888
+ export interface ConfersArtifact {
889
+ /** The column that holds the principal, or `<column>.<principal column>` through one foreign key of the table. */
890
+ readonly principal: string;
891
+ readonly node: string;
892
+ readonly expires: string | null;
893
+ readonly when?: ConditionArtifact;
894
+ readonly assign: {
895
+ readonly maxDays: number | null;
896
+ readonly self: boolean;
897
+ } | null;
898
+ }
899
+ /**
900
+ * A structured row condition: connectives, `{ '<column or fk_column.column>': test }` with every test holding, or
901
+ * `some` / `none` of the rows of one table whose foreign key names the row, also at the end of a path
902
+ * (`{ '<fk_column>': { some: … } }`). Each form is absent from a condition that does not use it, so its digest stays.
903
+ */
904
+ export type ConditionArtifact = {
905
+ readonly allOf: readonly ConditionArtifact[];
906
+ } | {
907
+ readonly anyOf: readonly ConditionArtifact[];
908
+ } | {
909
+ readonly not: ConditionArtifact;
910
+ } | RowsTestArtifact | {
911
+ readonly [path: string]: ColumnTestArtifact | RowsTestArtifact;
912
+ };
913
+ /** `some` or `none` of the rows of one table whose foreign key names the row. */
914
+ export type RowsTestArtifact = {
915
+ readonly some: Readonly<Record<string, ConditionArtifact>>;
916
+ } | {
917
+ readonly none: Readonly<Record<string, ConditionArtifact>>;
918
+ };
919
+ export type ConditionLiteralArtifact = string | number | boolean;
920
+ /** One operator of a column test; `{ now: true }` compares a timestamp with the statement's clock. */
921
+ export interface ColumnTestArtifact {
922
+ readonly eq?: ConditionLiteralArtifact;
923
+ readonly notEq?: ConditionLiteralArtifact;
924
+ readonly in?: readonly ConditionLiteralArtifact[];
925
+ readonly notIn?: readonly ConditionLiteralArtifact[];
926
+ readonly isNull?: boolean;
927
+ readonly lt?: ConditionLiteralArtifact | {
928
+ readonly now: true;
929
+ };
930
+ readonly lte?: ConditionLiteralArtifact | {
931
+ readonly now: true;
932
+ };
933
+ readonly gt?: ConditionLiteralArtifact | {
934
+ readonly now: true;
935
+ };
936
+ readonly gte?: ConditionLiteralArtifact | {
937
+ readonly now: true;
938
+ };
761
939
  }
762
940
  /** A column's own read action, its own write action, or both; an absent one is left out. */
763
941
  export interface ColumnPolicyArtifact {
@@ -7,6 +7,11 @@ export declare const DEV_LAUNCHER_CONFIG_FILE = "fabrika/dev.generated.json";
7
7
  export declare const DEV_LAUNCHER_MODULE = "@fabrika/app/dev";
8
8
  /** Where the launcher records what it holds, so a restart of the same container resumes it. A new container has none. */
9
9
  export declare const DEV_LAUNCHER_STATE_FILE = "fabrika/dev-state.json";
10
+ /**
11
+ * The launcher writes it once its boot reconcile reported, served or failed. A dev container's readiness check passes on
12
+ * it too, so a boot that failed still activates, and `reset_dev` can reach the launcher that reports the failure.
13
+ */
14
+ export declare const DEV_LAUNCHER_BOOTED_FILE = "fabrika/dev-booted";
10
15
  /** One command of the build's check chain, run by the shell in the application root. */
11
16
  export interface DevLauncherCheck {
12
17
  readonly name: string;
@@ -0,0 +1,27 @@
1
+ /** One parsed `egress` entry. `port` is `''` for the default port, as `URL.port` spells it. */
2
+ export type EgressEntry = {
3
+ readonly kind: 'origin';
4
+ readonly origin: string;
5
+ readonly host: string;
6
+ readonly port: string;
7
+ } | {
8
+ readonly kind: 'pattern';
9
+ readonly pattern: string;
10
+ readonly domain: string;
11
+ readonly port: string;
12
+ };
13
+ export type EgressEntryParse = {
14
+ readonly ok: true;
15
+ readonly entry: EgressEntry;
16
+ } | {
17
+ readonly ok: false;
18
+ readonly problem: string;
19
+ };
20
+ /**
21
+ * `value` as an `egress` entry, or why it is none. Each entry is written canonically (lower case, punycode, no default
22
+ * port, no trailing dot, no path), so an artifact names one entry one way; a problem names the canonical spelling when
23
+ * there is one.
24
+ */
25
+ export declare function parseEgressEntry(value: string): EgressEntryParse;
26
+ /** Whether `url` is a request an entry of `entries` admits: its host and port, a trailing dot of the host aside. */
27
+ export declare function egressAdmits(entries: readonly EgressEntry[], url: URL): boolean;
@@ -38,6 +38,11 @@ export declare function endpointDigest(artifact: Pick<ContractArtifact, 'dimensi
38
38
  export declare function requirementDigest(rules: EndpointRules): string;
39
39
  /** The digest of the whole artifact, over its one canonical serialization. */
40
40
  export declare function contractDigest(artifact: ContractArtifact): string;
41
+ /**
42
+ * `contractDigest` of an artifact that already is canonical (`canonicalizeArtifact`'s, as a decoded artifact is),
43
+ * hashed as it is serialized: neither a canonical copy nor its text is built. A shared shape is hashed at each place.
44
+ */
45
+ export declare function canonicalArtifactDigest(canonical: ContractArtifact): string;
41
46
  /**
42
47
  * The digest of an installation service's table: each row's id and `requirementDigest`, and the reserved prefixes. A
43
48
  * composition writes it beside the service from the table its proxy publishes, so the service refuses to start under
@@ -0,0 +1,2 @@
1
+ /** A framework release as npm publishes it; the only form one may take before it reaches a generated build command. */
2
+ export declare const FRAMEWORK_RELEASE_PATTERN: RegExp;
@@ -10,13 +10,24 @@ export declare const FABRIKA_SOURCE_MAP_UPLOAD_KEY = "FABRIKA_SOURCE_MAP_UPLOAD_
10
10
  export declare const FABRIKA_TOKEN_KEYS = "FABRIKA_TOKEN_KEYS";
11
11
  /** The environment's canonical origin (`https://crm.example`), which `ctx.url` builds absolute links on. */
12
12
  export declare const FABRIKA_APP_ORIGIN = "FABRIKA_APP_ORIGIN";
13
+ /** The digests of the environment's ops keys, which the object checks Control's key against (`parseOpsKeyDigests`, ADR-0069). */
14
+ export declare const FABRIKA_OPS_KEY_DIGESTS = "FABRIKA_OPS_KEY_DIGESTS";
15
+ /**
16
+ * The installation's own hosts, which a cron job's public egress refuses (ADR-0075): Control's, IAM's, Operations' and
17
+ * every application environment's domain, normalized and joined by `,`. Written only for a contract with such a job.
18
+ */
19
+ export declare const FABRIKA_EGRESS_REFUSED_HOSTS = "FABRIKA_EGRESS_REFUSED_HOSTS";
20
+ /** The name of the object that serves an environment's ordinary traffic on Cloudflare; `application` without it. */
21
+ export declare const FABRIKA_APPLICATION_OBJECT = "FABRIKA_APPLICATION_OBJECT";
22
+ /** The object names an ops request may target, all in the environment's own namespace (`parseApplicationObjects`). */
23
+ export declare const FABRIKA_APPLICATION_OBJECTS = "FABRIKA_APPLICATION_OBJECTS";
13
24
  /**
14
25
  * The environment names only the platform writes into an application
15
26
  * ([ADR-0043](../../../docs/decisions/0043-validate-and-render-one-zerops-descriptor-meaning.md)). Control refuses an
16
27
  * application variable or secret under one of them, and so does every provider, for every surface that writes one.
17
28
  * A work unit that gives an application a new credential adds its name here.
18
29
  */
19
- export declare const FRAMEWORK_VARIABLE_NAMES: readonly ["FABRIKA_RELEASE", "FABRIKA_CONTRACT_DIGEST", "FABRIKA_IAM_ISSUER", "FABRIKA_IAM_APP_ID", "FABRIKA_OPERATIONS_DSN", "FABRIKA_APP_ID", "FABRIKA_ENVIRONMENT", "FABRIKA_SERVICE_KEY", "FABRIKA_APP_DATABASE_URL", "FABRIKA_APP_RUNTIME_DATABASE_URL", "FABRIKA_APP_DATABASE_CONNECTIONS", "FABRIKA_APP_STORAGE_ENDPOINT", "FABRIKA_APP_STORAGE_BUCKET", "FABRIKA_APP_STORAGE_ACCESS_KEY_ID", "FABRIKA_APP_STORAGE_SECRET_ACCESS_KEY", "FABRIKA_STORAGE_PROVENANCE", "FABRIKA_PROXY_SECRET", "FABRIKA_IAM_RPC_URL", "FABRIKA_IAM_RPC_KEY", "FABRIKA_SOURCE_MAP_UPLOAD", "FABRIKA_SOURCE_MAP_UPLOAD_KEY", "FABRIKA_TOKEN_KEYS", "FABRIKA_APP_ORIGIN"];
30
+ export declare const FRAMEWORK_VARIABLE_NAMES: readonly ["FABRIKA_RELEASE", "FABRIKA_CONTRACT_DIGEST", "FABRIKA_IAM_ISSUER", "FABRIKA_IAM_APP_ID", "FABRIKA_OPERATIONS_DSN", "FABRIKA_APP_ID", "FABRIKA_ENVIRONMENT", "FABRIKA_SERVICE_KEY", "FABRIKA_APP_DATABASE_URL", "FABRIKA_APP_RUNTIME_DATABASE_URL", "FABRIKA_APP_DATABASE_CONNECTIONS", "FABRIKA_APP_STORAGE_ENDPOINT", "FABRIKA_APP_STORAGE_BUCKET", "FABRIKA_APP_STORAGE_ACCESS_KEY_ID", "FABRIKA_APP_STORAGE_SECRET_ACCESS_KEY", "FABRIKA_STORAGE_PROVENANCE", "FABRIKA_PROXY_SECRET", "FABRIKA_IAM_RPC_URL", "FABRIKA_IAM_RPC_KEY", "FABRIKA_SOURCE_MAP_UPLOAD", "FABRIKA_SOURCE_MAP_UPLOAD_KEY", "FABRIKA_TOKEN_KEYS", "FABRIKA_APP_ORIGIN", "FABRIKA_OPS_KEY_DIGESTS", "FABRIKA_EGRESS_REFUSED_HOSTS", "FABRIKA_APPLICATION_OBJECT", "FABRIKA_APPLICATION_OBJECTS"];
20
31
  export type FrameworkVariableName = (typeof FRAMEWORK_VARIABLE_NAMES)[number];
21
32
  /**
22
33
  * The name families only the platform writes: one variable per job, webhook or public procedure, named after it
@@ -1,23 +1,31 @@
1
1
  export * from './app-environment';
2
2
  export * from './canonical-path';
3
+ export * from './client-address';
3
4
  export * from './contract';
4
5
  export * from './contract-canonical';
6
+ export * from './contract-encoding';
5
7
  export * from './dev-environment';
6
8
  export * from './device';
9
+ export * from './egress';
7
10
  export * from './endpoint-digest';
8
11
  export * from './endpoints';
9
12
  export * from './environment';
13
+ export * from './framework-release';
10
14
  export * from './framework-variables';
11
15
  export * from './installation-endpoint';
12
16
  export { parseJsonStringArray } from './json';
13
17
  export * from './locale';
14
18
  export * from './mail';
19
+ export * from './managed-environment';
15
20
  export * from './membership';
16
21
  export * from './oauth';
22
+ export * from './ops';
17
23
  export * from './permissions';
24
+ export * from './public-egress';
18
25
  export * from './requirement';
19
26
  export * from './rpc';
20
27
  export { sha256Hex } from './sha256';
28
+ export * from './terminal';
21
29
  export * from './token';
22
30
  export * from './types';
23
31
  export * from './wire';
@@ -1,5 +1,5 @@
1
1
  /** The languages IAM renders its pages and its own e-mails in. */
2
- export declare const LOCALES: readonly ["en", "cs"];
2
+ export declare const LOCALES: readonly ["en", "cs", "uk"];
3
3
  export type Locale = (typeof LOCALES)[number];
4
4
  /** IAM's language for a request that names no application, or one that declares none. */
5
5
  export declare const DEFAULT_LOCALE: Locale;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The framework names Control hands every deploy, each with a value or `null` (the deploy removes it). Beside them, a
3
+ * deploy carries the families of `FRAMEWORK_VARIABLE_PREFIXES`, one variable per workload, import or receiver.
4
+ */
5
+ export declare const MANAGED_VARIABLE_NAMES: readonly ["FABRIKA_RELEASE", "FABRIKA_OPERATIONS_DSN", "FABRIKA_IAM_ISSUER", "FABRIKA_IAM_APP_ID", "FABRIKA_APP_ID", "FABRIKA_ENVIRONMENT", "FABRIKA_SERVICE_KEY", "FABRIKA_PROXY_SECRET", "FABRIKA_IAM_RPC_URL", "FABRIKA_IAM_RPC_KEY", "FABRIKA_APP_ORIGIN", "FABRIKA_TOKEN_KEYS", "FABRIKA_OPS_KEY_DIGESTS", "FABRIKA_EGRESS_REFUSED_HOSTS"];
6
+ export type ManagedVariableName = (typeof MANAGED_VARIABLE_NAMES)[number];
7
+ /**
8
+ * Whether a managed variable carries a credential, so a provider writes it as a secret and never reads it back. Fail
9
+ * closed: a name not known to be public is a credential.
10
+ */
11
+ export declare function isManagedCredential(name: string): boolean;
12
+ /** Whether a deploy writes `name` from what Control hands it, so a deploy that no longer hands it removes it. */
13
+ export declare function isManagedVariableName(name: string): boolean;
14
+ /** One managed variable: its value, or `null` when the deploy removes it, and whether it is a credential. */
15
+ export interface ManagedEntry {
16
+ readonly value: string | null;
17
+ readonly credential: boolean;
18
+ }
19
+ /** What Control hands a deploy, parsed once: every name is one Control writes, and every family value has its shape. */
20
+ export type ManagedEnvironment = Readonly<Record<string, ManagedEntry>>;
21
+ /**
22
+ * Parse what Control hands a deploy. Control parses it before any provider effect, and the Cloudflare executor parses
23
+ * what its job carries; a name or a value Control would not produce fails either.
24
+ */
25
+ export declare function parseManagedEnvironment(value: Readonly<Record<string, string | null>>): ManagedEnvironment;
26
+ /** The value a deploy writes under `name`, or `null` when it writes none. */
27
+ export declare function managedValue(environment: ManagedEnvironment, name: string): string | null;
28
+ /**
29
+ * The managed variables a service or Worker still holds that the deploy no longer writes: handed as `null`, or a
30
+ * family member no longer handed. `written` names what the deploy writes there.
31
+ */
32
+ export declare function staleManagedVariables(present: Iterable<string>, written: ReadonlySet<string>): string[];