@fabrika/auth-core 0.9.0-dev.5 → 0.9.0-dev.50

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 (55) hide show
  1. package/package.json +3 -2
  2. package/src/agent.ts +89 -0
  3. package/src/canonical-path.ts +18 -0
  4. package/src/client-address.ts +74 -0
  5. package/src/contract-canonical.ts +168 -2
  6. package/src/contract-encoding.ts +181 -0
  7. package/src/contract.ts +220 -17
  8. package/src/egress.ts +97 -0
  9. package/src/endpoint-digest.ts +22 -2
  10. package/src/framework-release.ts +70 -0
  11. package/src/framework-variables.ts +14 -0
  12. package/src/iam-mail.ts +354 -0
  13. package/src/index.ts +7 -0
  14. package/src/installation-endpoint.ts +3 -2
  15. package/src/locale.ts +13 -1
  16. package/src/managed-environment.ts +11 -0
  17. package/src/membership.ts +12 -4
  18. package/src/oauth.ts +19 -0
  19. package/src/ops.ts +487 -16
  20. package/src/permissions.ts +42 -0
  21. package/src/public-egress.ts +168 -0
  22. package/src/requirement.ts +12 -4
  23. package/src/rpc.ts +137 -9
  24. package/src/scope-values.ts +123 -0
  25. package/src/sha256.ts +52 -14
  26. package/src/token.ts +195 -14
  27. package/src/types.ts +72 -1
  28. package/src/wire.ts +2 -1
  29. package/types/src/agent.d.ts +37 -0
  30. package/types/src/canonical-path.d.ts +6 -0
  31. package/types/src/client-address.d.ts +7 -0
  32. package/types/src/contract-canonical.d.ts +11 -1
  33. package/types/src/contract-encoding.d.ts +18 -0
  34. package/types/src/contract.d.ts +205 -16
  35. package/types/src/egress.d.ts +27 -0
  36. package/types/src/endpoint-digest.d.ts +5 -0
  37. package/types/src/framework-release.d.ts +23 -0
  38. package/types/src/framework-variables.d.ts +6 -1
  39. package/types/src/iam-mail.d.ts +92 -0
  40. package/types/src/index.d.ts +7 -0
  41. package/types/src/installation-endpoint.d.ts +3 -2
  42. package/types/src/locale.d.ts +11 -1
  43. package/types/src/managed-environment.d.ts +1 -1
  44. package/types/src/membership.d.ts +8 -3
  45. package/types/src/oauth.d.ts +11 -0
  46. package/types/src/ops.d.ts +133 -8
  47. package/types/src/permissions.d.ts +12 -0
  48. package/types/src/public-egress.d.ts +31 -0
  49. package/types/src/requirement.d.ts +5 -4
  50. package/types/src/rpc.d.ts +113 -6
  51. package/types/src/scope-values.d.ts +61 -0
  52. package/types/src/sha256.d.ts +10 -0
  53. package/types/src/token.d.ts +70 -8
  54. package/types/src/types.d.ts +48 -1
  55. package/types/src/wire.d.ts +2 -1
@@ -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 { DimensionValue } from './scope-values';
3
5
  import type { TerminalArtifact } from './terminal';
4
6
  /**
5
7
  * The artifact format this release writes. A release that changes the artifact raises it, and Control upcasts every
@@ -19,10 +21,15 @@ export interface ContractArtifact extends EndpointTable {
19
21
  /** Action → description. Exact actions only; the artifact holds no wildcard. */
20
22
  readonly actions: Readonly<Record<string, string>>;
21
23
  readonly roles: Readonly<Record<string, RoleArtifact>>;
24
+ /**
25
+ * The relations a table's rows confer (`relations: { owner: { dimension: 'project' } }`): a role's `via` holds its
26
+ * actions where a row names the caller. Absent unless declared, so the digest stays.
27
+ */
28
+ readonly relations?: Readonly<Record<string, RelationArtifact>>;
22
29
  readonly mounts: Readonly<Record<string, MountArtifact>>;
23
30
  readonly files: Readonly<Record<string, FileCollectionArtifact>>;
24
31
  /**
25
- * The file kinds (`c.files({ types, maxBytes, scan? })`): classes of stored files a table's file column holds. A kind
32
+ * The file kinds (`c.files({ types, maxBytes, scan?, inline? })`): classes of stored files a table's file column holds. A kind
26
33
  * has no owner and no endpoint; the table that holds a file is its authority. Absent unless declared, so the digest stays.
27
34
  */
28
35
  readonly fileKinds?: Readonly<Record<string, FileKindArtifact>>;
@@ -68,6 +75,11 @@ export interface ContractArtifact extends EndpointTable {
68
75
  * terminal's browser there, and only an application that declares it may assert a person. Absent unless declared.
69
76
  */
70
77
  readonly terminal?: TerminalArtifact;
78
+ /**
79
+ * The application notifies people through Web Push (ADR-0088), so the table holds the framework's push rows under
80
+ * `/__fabrika/push`. Absent unless declared, so the digest stays.
81
+ */
82
+ readonly notifications?: true;
71
83
  /**
72
84
  * What each procedure of the staged kit admits and how long it runs, by endpoint id, with every default applied: the
73
85
  * rules the application applies itself, beside the row the proxy applies. Absent for a contract with no such
@@ -125,14 +137,17 @@ export interface EndpointTable {
125
137
  */
126
138
  readonly reservedPrefixes: readonly string[];
127
139
  }
128
- /** Who may call a credentialed endpoint. There is no public caller: anonymous traffic is a fixed endpoint kind. */
129
- export type Caller = 'human' | 'machine' | 'link' | `app:${string}`;
140
+ /**
141
+ * Who may call a credentialed endpoint. There is no public caller: anonymous traffic is a fixed endpoint kind. `agent` is a
142
+ * person's agent holding a device grant for the environment (ADR-0090).
143
+ */
144
+ export type Caller = 'human' | 'machine' | 'agent' | 'link' | `app:${string}`;
130
145
  /** `app:<id>`: the connector of the consuming application `<id>`. */
131
146
  export declare const APP_CALLER_PREFIX = "app:";
132
147
  /** Every export procedure and description is served under this prefix; an `app:<id>` caller reaches nothing else. */
133
148
  export declare const CONNECT_PREFIX = "/__fabrika/connect";
134
149
  /** An RPC mount's callers: a link holder reaches only its own link mount, and an `app:<id>` only an export. */
135
- export type RpcCaller = 'human' | 'machine';
150
+ export type RpcCaller = 'human' | 'machine' | 'agent';
136
151
  export type EndpointMethod = 'GET' | 'POST';
137
152
  /** Kinds that verify a credential, check the caller kind and the requirement. */
138
153
  export type CredentialedEndpointKind = 'query' | 'mutation' | 'spa' | 'upload' | 'download';
@@ -146,10 +161,11 @@ export type AnonymousEndpointKind = 'health' | 'form' | 'webhook' | 'link-spa' |
146
161
  export type EndpointKind = CredentialedEndpointKind | AnonymousEndpointKind;
147
162
  /**
148
163
  * The contract entry that declared an endpoint. A `challenge` row is the framework's own: the endpoint that issues the
149
- * ALTCHA challenge of the public procedure `name`.
164
+ * ALTCHA challenge of the public procedure `name`. A `push` row is the framework's own too: one of the rows a contract
165
+ * that declares `notifications` gets under `/__fabrika/push` (ADR-0088), named by its part (`worker`).
150
166
  */
151
167
  export interface EndpointSource {
152
- readonly kind: 'mount' | 'export' | 'files' | 'challenge';
168
+ readonly kind: 'mount' | 'export' | 'files' | 'challenge' | 'push';
153
169
  readonly name: string;
154
170
  }
155
171
  interface EndpointRowBase {
@@ -174,7 +190,8 @@ interface EndpointRowBase {
174
190
  readonly crossOrigin?: CrossOriginForm;
175
191
  /**
176
192
  * `file`: the procedure answers a stored file (an output `file('<kind>')`), so the proxy and the application give every
177
- * answer of it, a denial included, ADR-0022's file treatment. Absent otherwise, so every other row keeps its digest.
193
+ * answer of it, a denial included, ADR-0022's file treatment. `inline-file`: the same, for a kind declared `inline:
194
+ * true`, whose XML documents are shown too. Absent otherwise, so every other row keeps its digest.
178
195
  */
179
196
  readonly response?: EndpointResponse;
180
197
  /**
@@ -192,8 +209,8 @@ interface EndpointRowBase {
192
209
  }
193
210
  /** What the proxy does with an anonymous request's `Authorization` on a row that names it: forward it to the application. */
194
211
  export type EndpointAuthorization = 'forward';
195
- /** The answer profile of a row that answers a stored file. */
196
- export type EndpointResponse = 'file';
212
+ /** The answer profile of a row that answers a stored file: `inline-file` also shows the XML documents a machine reads. */
213
+ export type EndpointResponse = 'file' | 'inline-file';
197
214
  /** A cacheable row's lifetime: `maxAgeSeconds`, or `immutable`, a year, for an input that names an immutable value. */
198
215
  export type EndpointCache = {
199
216
  readonly maxAgeSeconds: number;
@@ -232,7 +249,7 @@ export interface BodyAdmission {
232
249
  * `action` is that action in some scope, global included, and only globally under the `app` form. The access form is
233
250
  * what the framework then resolves.
234
251
  */
235
- export type EndpointRequirement = MemberRequirement | ActionRequirement | CapabilitiesRequirement;
252
+ export type EndpointRequirement = MemberRequirement | ActionRequirement | AnyOfRequirement | CapabilitiesRequirement;
236
253
  export interface MemberRequirement {
237
254
  readonly kind: 'member';
238
255
  }
@@ -241,6 +258,21 @@ export interface ActionRequirement {
241
258
  readonly action: string;
242
259
  readonly access: AccessForm;
243
260
  }
261
+ /**
262
+ * Any one of several actions (`access: { anyOf, app: true }`), each held as a global grant, the `app` form's rule: two to
263
+ * `MAX_ANY_OF` distinct actions, sorted, so the order in the source does not change the digest.
264
+ */
265
+ export interface AnyOfRequirement {
266
+ readonly kind: 'anyOf';
267
+ readonly actions: readonly [string, string, ...string[]];
268
+ readonly access: {
269
+ readonly form: 'app';
270
+ };
271
+ }
272
+ /** The most actions an `anyOf` requirement lists. */
273
+ export declare const MAX_ANY_OF = 16;
274
+ /** Whether `actions` is an `anyOf` list as a row carries it: two to `MAX_ANY_OF` actions, strictly ascending. */
275
+ export declare function isAnyOfList(actions: readonly string[]): boolean;
244
276
  /**
245
277
  * Several capabilities (`access: { capabilities }`), by the name the handler reads each under (`ctx.capabilities.<name>`):
246
278
  * the token must carry every action, and the access form of each narrows it as it narrows a single one. At least two.
@@ -332,6 +364,8 @@ export interface FileShape {
332
364
  readonly kind: string;
333
365
  }
334
366
  export declare function isFileShape(shape: OutputShape): shape is FileShape;
367
+ /** The kinds of the files a schema holds, anywhere in it, each once per place it appears. */
368
+ export declare function fileKindsIn(shape: SchemaShape): readonly string[];
335
369
  /**
336
370
  * What a procedure answers: a JSON value of a schema, a file of rows (`attachment()` of `@fabrika/app/contract`), or a
337
371
  * redirect (`redirect()`).
@@ -420,6 +454,13 @@ export interface DimensionArtifact {
420
454
  } | null;
421
455
  /** `labels`: the member directory shows labels to `members.list` holders. Absent unless declared, so digests stay. */
422
456
  readonly directory?: 'labels';
457
+ /** The values the console offers for a grant in this dimension (ADR-0085). Absent unless declared, so digests stay. */
458
+ readonly values?: readonly DimensionValue[];
459
+ /**
460
+ * The id of the query procedure IAM asks, as the administrator, for this dimension's values (ADR-0085 §4). Absent
461
+ * unless declared, so digests stay.
462
+ */
463
+ readonly valuesFrom?: string;
423
464
  }
424
465
  export interface RoleArtifact {
425
466
  readonly grants: readonly string[];
@@ -433,6 +474,15 @@ export interface RoleArtifact {
433
474
  } | null;
434
475
  /** An external principal may hold this membership role (ADR-0051). Absent unless declared, so digests stay. */
435
476
  readonly external?: true;
477
+ /**
478
+ * Relation → actions the holder of a global grant of this role holds at each node a relation row names them at.
479
+ * Absent unless declared, so digests stay.
480
+ */
481
+ readonly via?: Readonly<Record<string, readonly string[]>>;
482
+ }
483
+ /** A relation of the vocabulary: the dimension whose nodes its rows name. */
484
+ export interface RelationArtifact {
485
+ readonly dimension: string;
436
486
  }
437
487
  export type MountArtifact = RpcMountArtifact | LinkMountArtifact | SpaMountArtifact | HealthMountArtifact | FormMountArtifact | WebhookMountArtifact;
438
488
  export interface RpcMountArtifact {
@@ -621,6 +671,11 @@ export interface FileKindArtifact {
621
671
  readonly maxBytes: number;
622
672
  /** Present when every file of the kind waits `quarantined` for a clean malware verdict before it is served. */
623
673
  readonly scan?: true;
674
+ /**
675
+ * Present when its files are shown rather than downloaded: every type is an inert image or an XML document a machine
676
+ * reads, and a row answering it is `response: 'inline-file'`. Absent otherwise, so every other kind keeps its digest.
677
+ */
678
+ readonly inline?: true;
624
679
  }
625
680
  export interface JobArtifact {
626
681
  readonly schedule: string;
@@ -694,10 +749,12 @@ export interface DeclaredReach {
694
749
  */
695
750
  readonly signs?: readonly string[];
696
751
  /**
697
- * The HTTPS origins this site's code calls (`fetch`), sorted: a credentialed procedure, a webhook or a job. Absent
698
- * unless declared, so the digest stays.
752
+ * The HTTPS origins this site's code calls (`fetch`), sorted, each an exact origin or a one-label pattern
753
+ * (`parseEgressEntry`): a credentialed procedure, a webhook or a job. Or `'public'` (a cron job only): every public
754
+ * host over HTTPS or HTTP, never the installation or a private network (ADR-0075). Absent unless declared, so the
755
+ * digest stays.
699
756
  */
700
- readonly egress?: readonly string[];
757
+ readonly egress?: DeclaredEgress;
701
758
  /**
702
759
  * A public procedure's workload actions, sorted: all its handler holds, through the key Control issues for the
703
760
  * endpoint (`contractWorkloads`). Present only on a public procedure's entry, so every other digest stays.
@@ -734,6 +791,11 @@ export interface CspSource {
734
791
  * two. A single action stays text, so the artifact of a policy that names one keeps its shape and digest.
735
792
  */
736
793
  export type TableActionArtifact = string | readonly string[];
794
+ /**
795
+ * An application table's `actions.read` that every `app` endpoint, job and webhook reads with, whatever its action; never
796
+ * a public procedure, a scoped site, a link or an export. No vocabulary may declare an action of this name.
797
+ */
798
+ export declare const READ_ANY = "any";
737
799
  export interface TablePolicyArtifact {
738
800
  readonly scope: TableScope;
739
801
  /** An inbox's read action is `read`; it has no write action, because only its form appends. */
@@ -764,11 +826,138 @@ export interface TablePolicyArtifact {
764
826
  * actions are the file's authority. Absent unless declared, so the digest stays.
765
827
  */
766
828
  readonly files?: Readonly<Record<string, string>>;
829
+ /**
830
+ * A view (ADR-0072): read like its scope's tables, written by nothing, its containment stated by its SQL alone.
831
+ * Absent for a table, so the digest stays.
832
+ */
833
+ readonly view?: true;
834
+ /** Relation → how a row of this table confers it. Absent unless declared, so the digest stays. */
835
+ readonly confers?: Readonly<Record<string, ConfersArtifact>>;
836
+ /** Action → the condition a row must meet for it, narrowing what any grant of it reaches. Absent unless declared. */
837
+ readonly when?: Readonly<Record<string, ConditionArtifact>>;
838
+ /**
839
+ * Relation → action → the condition a row the relation reaches must meet for it; it narrows that relation's reach only.
840
+ * Absent unless declared, so the digest stays. A reader that ignores it reaches more: Control refuses to publish it to
841
+ * an application pinned below the release that enforces it.
842
+ */
843
+ readonly relationWhen?: Readonly<Record<string, Readonly<Record<string, ConditionArtifact>>>>;
844
+ /**
845
+ * Relation of the table's own dimension → the ancestor its rows reveal. Absent unless declared, so the digest stays.
846
+ * A reader that ignores it reaches less, never more.
847
+ */
848
+ readonly reveals?: Readonly<Record<string, RevealsArtifact>>;
849
+ /**
850
+ * Dimension outside the chain → the column a `Within`'s read reaches a row through. Absent unless declared, so the
851
+ * digest stays. A reader that ignores it reaches less, never more.
852
+ */
853
+ readonly readThrough?: Readonly<Record<string, string>>;
854
+ /**
855
+ * Dimension of `readThrough` → the actions a `Ref` held through that path holds, writes included; whoever inserts the
856
+ * path's column must hold each at the node it names. Absent unless declared, so the digest stays. A reader that
857
+ * ignores it reaches less, never more.
858
+ */
859
+ readonly writeThrough?: Readonly<Record<string, readonly string[]>>;
860
+ /**
861
+ * The table's own dimension → the ancestor its rows reveal to a grant at their node, for a `Within`'s reads. Absent
862
+ * unless declared, so the digest stays. A reader that ignores it reaches less, never more.
863
+ */
864
+ readonly memberReveals?: Readonly<Record<string, MemberRevealsArtifact>>;
865
+ /**
866
+ * Relation → the access view that lists the rows it reaches (ADR-0076). Absent unless declared, so the digest stays.
867
+ * A reader that ignores it reaches less, never more.
868
+ */
869
+ readonly access?: Readonly<Record<string, AccessArtifact>>;
870
+ }
871
+ /** An access view: its `row` column names the table's key; `principal` is compared to the caller, `member` to its nodes. */
872
+ export interface AccessArtifact {
873
+ readonly view: string;
874
+ readonly row: string;
875
+ readonly principal: string | null;
876
+ readonly member: string | null;
877
+ }
878
+ /**
879
+ * 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
880
+ * key's dimension names, while `when` admits the row.
881
+ */
882
+ export interface MemberRevealsArtifact {
883
+ readonly to: string;
884
+ readonly actions: readonly string[];
885
+ readonly when?: ConditionArtifact;
886
+ /**
887
+ * Through a path, on a table with an insert: the writer picks the node, and `self` lets it pick one where it holds a
888
+ * grant the reveal counts. Absent otherwise; only a reader that refuses a path's key reads it.
889
+ */
890
+ readonly assign?: {
891
+ readonly self: boolean;
892
+ };
893
+ }
894
+ /** A row the relation reaches reveals its node in `to` for `actions`, while `when` admits the row. */
895
+ export interface RevealsArtifact {
896
+ readonly to: string;
897
+ readonly actions: readonly string[];
898
+ readonly when?: ConditionArtifact;
899
+ /** On a reveal matched through `readThrough`: an insert delegates, and `self` lets it name a node its writer holds. */
900
+ readonly assign?: {
901
+ readonly self: boolean;
902
+ };
903
+ }
904
+ /** A row names `principal` at the node in `node`, until `expires`, while `when` admits it; `assign` bounds its writer. */
905
+ export interface ConfersArtifact {
906
+ /** The column that holds the principal, or `<column>.<principal column>` through one foreign key of the table. */
907
+ readonly principal: string;
908
+ readonly node: string;
909
+ readonly expires: string | null;
910
+ readonly when?: ConditionArtifact;
911
+ readonly assign: {
912
+ readonly maxDays: number | null;
913
+ readonly self: boolean;
914
+ } | null;
915
+ }
916
+ /**
917
+ * A structured row condition: connectives, `{ '<column or fk_column.column>': test }` with every test holding, or
918
+ * `some` / `none` of the rows of one table whose foreign key names the row, also at the end of a path
919
+ * (`{ '<fk_column>': { some: … } }`). Each form is absent from a condition that does not use it, so its digest stays.
920
+ */
921
+ export type ConditionArtifact = {
922
+ readonly allOf: readonly ConditionArtifact[];
923
+ } | {
924
+ readonly anyOf: readonly ConditionArtifact[];
925
+ } | {
926
+ readonly not: ConditionArtifact;
927
+ } | RowsTestArtifact | {
928
+ readonly [path: string]: ColumnTestArtifact | RowsTestArtifact;
929
+ };
930
+ /** `some` or `none` of the rows of one table whose foreign key names the row. */
931
+ export type RowsTestArtifact = {
932
+ readonly some: Readonly<Record<string, ConditionArtifact>>;
933
+ } | {
934
+ readonly none: Readonly<Record<string, ConditionArtifact>>;
935
+ };
936
+ export type ConditionLiteralArtifact = string | number | boolean;
937
+ /** One operator of a column test; `{ now: true }` compares a timestamp with the statement's clock. */
938
+ export interface ColumnTestArtifact {
939
+ readonly eq?: ConditionLiteralArtifact;
940
+ readonly notEq?: ConditionLiteralArtifact;
941
+ readonly in?: readonly ConditionLiteralArtifact[];
942
+ readonly notIn?: readonly ConditionLiteralArtifact[];
943
+ readonly isNull?: boolean;
944
+ readonly lt?: ConditionLiteralArtifact | {
945
+ readonly now: true;
946
+ };
947
+ readonly lte?: ConditionLiteralArtifact | {
948
+ readonly now: true;
949
+ };
950
+ readonly gt?: ConditionLiteralArtifact | {
951
+ readonly now: true;
952
+ };
953
+ readonly gte?: ConditionLiteralArtifact | {
954
+ readonly now: true;
955
+ };
767
956
  }
768
- /** A column's own read action, its own write action, or both; an absent one is left out. */
957
+ /** A column's own read actions, its own write actions (each one as its text, several as a list), or both; an absent one is left out. */
769
958
  export interface ColumnPolicyArtifact {
770
- readonly read?: string;
771
- readonly write?: string;
959
+ readonly read?: TableActionArtifact;
960
+ readonly write?: TableActionArtifact;
772
961
  }
773
962
  export type TableScope = {
774
963
  readonly mode: 'dimension';
@@ -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
@@ -1,2 +1,25 @@
1
1
  /** A framework release as npm publishes it; the only form one may take before it reaches a generated build command. */
2
2
  export declare const FRAMEWORK_RELEASE_PATTERN: RegExp;
3
+ /**
4
+ * Whether framework release `release` is at least `since`. A prerelease counts as its `major.minor`; a release that
5
+ * does not start with `<major>.<minor>.` is never at least anything (ADR-0062).
6
+ */
7
+ export declare const releaseAtLeast: (release: string, since: {
8
+ readonly major: number;
9
+ readonly minor: number;
10
+ }) => boolean;
11
+ /**
12
+ * Whether framework release `release` is at or above the exact version `since` in semver's precedence, prerelease
13
+ * included; a release that is not a semver version never is (ADR-0062).
14
+ */
15
+ export declare const releaseFrom: (release: string, since: string) => boolean;
16
+ /**
17
+ * The release a gate reads for an approved access: the application's pin, never the reader's `checker`, which is this
18
+ * platform's patch of the pin's minor and so passes a `releaseFrom` gate a prerelease pin does not. An access approved before Control recorded the pin is read as the oldest release of its
19
+ * reader's minor (`<major>.<minor>.0-0`): every `releaseAtLeast` gate answers as for that minor, and every `releaseFrom`
20
+ * gate of a prerelease or a patch fails closed, as for an older application, until a deploy reads its pin.
21
+ */
22
+ export declare const applicationRelease: (access: {
23
+ readonly checker: string;
24
+ readonly framework?: string;
25
+ }) => string;
@@ -12,6 +12,11 @@ export declare const FABRIKA_TOKEN_KEYS = "FABRIKA_TOKEN_KEYS";
12
12
  export declare const FABRIKA_APP_ORIGIN = "FABRIKA_APP_ORIGIN";
13
13
  /** The digests of the environment's ops keys, which the object checks Control's key against (`parseOpsKeyDigests`, ADR-0069). */
14
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";
15
20
  /** The name of the object that serves an environment's ordinary traffic on Cloudflare; `application` without it. */
16
21
  export declare const FABRIKA_APPLICATION_OBJECT = "FABRIKA_APPLICATION_OBJECT";
17
22
  /** The object names an ops request may target, all in the environment's own namespace (`parseApplicationObjects`). */
@@ -22,7 +27,7 @@ export declare const FABRIKA_APPLICATION_OBJECTS = "FABRIKA_APPLICATION_OBJECTS"
22
27
  * application variable or secret under one of them, and so does every provider, for every surface that writes one.
23
28
  * A work unit that gives an application a new credential adds its name here.
24
29
  */
25
- 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_APPLICATION_OBJECT", "FABRIKA_APPLICATION_OBJECTS"];
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_APP_STORAGE_REGION", "FABRIKA_APP_STORAGE_ADDRESSING", "FABRIKA_APP_STORAGE_CREDENTIALS", "FABRIKA_STORAGE_PROVENANCE", "FABRIKA_JOBS_SCHEDULE", "FABRIKA_JOBS_SCHEDULE_GENERATION", "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"];
26
31
  export type FrameworkVariableName = (typeof FRAMEWORK_VARIABLE_NAMES)[number];
27
32
  /**
28
33
  * The name families only the platform writes: one variable per job, webhook or public procedure, named after it
@@ -0,0 +1,92 @@
1
+ import { type Locale } from './locale';
2
+ import { type MailTemplate, type MessageKind } from './mail';
3
+ /** A rendered e-mail: the subject and both bodies, from the same values. */
4
+ export interface RenderedMessage {
5
+ readonly subject: string;
6
+ readonly text: string;
7
+ readonly html: string;
8
+ }
9
+ /**
10
+ * How the owner of an invitation's mailbox accepts it. `create`: no principal holds the mailbox and accepting creates
11
+ * one with the password its owner chooses (ADR-0051). `sign_in`: a principal holds it, or single sign-on would admit
12
+ * it, so its owner signs in and accepts. `no_account`: neither, so the owner cannot accept until someone gives the
13
+ * mailbox an account.
14
+ */
15
+ export type InvitationAcceptance = 'create' | 'sign_in' | 'no_account';
16
+ export interface PasswordActionValues {
17
+ /** The application the action returns to; `null` for an action on the installation itself. */
18
+ readonly appName: string | null;
19
+ readonly recipient: string;
20
+ readonly actionUrl: string;
21
+ readonly expiresAt: number;
22
+ }
23
+ /**
24
+ * The closed set of values each IAM message is rendered from. Every value is plain text; a template escapes it. IAM
25
+ * builds the action URL itself, and a template places it. `expiresAt` is the link's expiry in seconds since the epoch.
26
+ */
27
+ export interface MessageValues {
28
+ readonly invitation: {
29
+ readonly appName: string;
30
+ readonly role: string;
31
+ readonly scope: string;
32
+ readonly recipient: string;
33
+ readonly inviterLabel: string;
34
+ /** The invited person's company, as the inviting application names it; empty when the invitation names none. */
35
+ readonly companyLabel: string;
36
+ /** The inviter's personal message; empty when the invitation carries none. */
37
+ readonly message: string;
38
+ readonly actionUrl: string;
39
+ readonly expiresAt: number;
40
+ /** How the mailbox's owner accepts, as IAM can tell when it sends; it picks IAM's words, and is no placeholder. */
41
+ readonly acceptance: InvitationAcceptance;
42
+ };
43
+ readonly enrollment: PasswordActionValues;
44
+ readonly reset: PasswordActionValues;
45
+ }
46
+ /** One template per message. IAM's catalog supplies a default set per language. */
47
+ export type MessageTemplates = {
48
+ readonly [K in MessageKind]: (values: MessageValues[K]) => RenderedMessage;
49
+ };
50
+ /** IAM's words around an application's own wording of a message: the HTML part's button and the expiry. */
51
+ export interface ApplicationMailText {
52
+ readonly button: {
53
+ readonly [K in MessageKind]: string;
54
+ };
55
+ /** `expiresAt` in seconds since the epoch, as the `{{expiry}}` placeholder shows it. */
56
+ readonly expiry: (expiresAt: number) => string;
57
+ }
58
+ /** IAM's wording of its e-mails in one language. */
59
+ export interface IamMailCatalog {
60
+ readonly messages: MessageTemplates;
61
+ readonly applicationMail: ApplicationMailText;
62
+ }
63
+ /** IAM's wording of its e-mails in `locale`. */
64
+ export declare function iamMailCatalog(locale: Locale): IamMailCatalog;
65
+ /**
66
+ * The language IAM writes an e-mail in: the person's own (the language an invitation names, else the one the mailbox's
67
+ * principal keeps, ADR-0077), else the application's, else the default. An e-mail has no request to ask, so IAM's
68
+ * `chooseLocale` without one comes to the same language; IAM's tests hold the two equal.
69
+ */
70
+ export declare function mailLocale(sources: {
71
+ readonly person?: Locale | null;
72
+ readonly app?: Locale | null;
73
+ }): Locale;
74
+ /** What an IAM e-mail of one application is rendered with, beside its message's values. */
75
+ export interface MailRendering {
76
+ /** The e-mail's language (`mailLocale`). */
77
+ readonly locale: Locale;
78
+ /** The application's own template of the message in that language; `null` when it declares none. */
79
+ readonly template: MailTemplate | null;
80
+ /** `{{displayName}}`: the application's display name, else its id. */
81
+ readonly displayName: string;
82
+ /** `{{appUrl}}`: the application's address with a trailing slash; `null` while no return origin is registered. */
83
+ readonly appUrl: string | null;
84
+ /** The longest subject the sender accepts: a filled template's subject gives way at its end. */
85
+ readonly maxSubjectLength: number;
86
+ }
87
+ /**
88
+ * The template IAM renders a `kind` e-mail with: the application's own wording when it declares one in the e-mail's
89
+ * language, else the catalog's. A template the rule no longer admits is the catalog's, and so is one that names
90
+ * `{{appUrl}}` while the application has no registered return origin to build it from.
91
+ */
92
+ export declare function iamMessageTemplate<K extends MessageKind>(kind: K, rendering: MailRendering): (values: MessageValues[K]) => RenderedMessage;
@@ -1,14 +1,19 @@
1
+ export * from './agent';
1
2
  export * from './app-environment';
2
3
  export * from './canonical-path';
4
+ export * from './client-address';
3
5
  export * from './contract';
4
6
  export * from './contract-canonical';
7
+ export * from './contract-encoding';
5
8
  export * from './dev-environment';
6
9
  export * from './device';
10
+ export * from './egress';
7
11
  export * from './endpoint-digest';
8
12
  export * from './endpoints';
9
13
  export * from './environment';
10
14
  export * from './framework-release';
11
15
  export * from './framework-variables';
16
+ export * from './iam-mail';
12
17
  export * from './installation-endpoint';
13
18
  export { parseJsonStringArray } from './json';
14
19
  export * from './locale';
@@ -18,8 +23,10 @@ export * from './membership';
18
23
  export * from './oauth';
19
24
  export * from './ops';
20
25
  export * from './permissions';
26
+ export * from './public-egress';
21
27
  export * from './requirement';
22
28
  export * from './rpc';
29
+ export * from './scope-values';
23
30
  export { sha256Hex } from './sha256';
24
31
  export * from './terminal';
25
32
  export * from './token';
@@ -1,11 +1,12 @@
1
+ import type { AGENT_CALLER } from './agent';
1
2
  import type { BodyAdmission, Caller, EndpointMethod } from './contract';
2
3
  /** Any method. The ambiguity check treats it as overlapping every method of the same path shape. */
3
4
  export declare const ANY_METHOD = "*";
4
5
  export type InstallationEndpointMethod = EndpointMethod | typeof ANY_METHOD;
5
6
  /** The caller an OAuth resource token presents. Only an installation row may admit it. */
6
7
  export declare const OAUTH_CALLER = "oauth";
7
- /** Every caller a verified token can present: an application caller, or `oauth`. */
8
- export type TokenCaller = Caller | typeof OAUTH_CALLER;
8
+ /** Every caller a verified token can present: an application caller, `oauth`, or an agent's exchanged grant. */
9
+ export type TokenCaller = Caller | typeof OAUTH_CALLER | typeof AGENT_CALLER;
9
10
  export type InstallationCaller = 'human' | 'machine' | typeof OAUTH_CALLER;
10
11
  /** `service` verifies a credential; `protocol` and `health` are anonymous, and `protocol` keeps `Authorization`. */
11
12
  export type InstallationEndpointKind = 'service' | 'protocol' | 'health';
@@ -1,9 +1,19 @@
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;
6
6
  export declare function isLocale(value: unknown): value is Locale;
7
+ /**
8
+ * The cookie that names the language a browser reads fabrika's pages in, host-only on whichever host wrote it: IAM's
9
+ * on IAM's host, an application's on its own. An application's proxy passes the value on its host to IAM's sign-in as
10
+ * `LOCALE_PARAM`. It picks words and nothing else: no credential, landing or authority depends on it, and a value
11
+ * that is not a `Locale` counts as none. Its name does not start with `FABRIKA_COOKIE_PREFIX`, so the proxy leaves it
12
+ * on the request it sends an application.
13
+ */
14
+ export declare const LOCALE_COOKIE = "__Host-fabrika_locale";
15
+ /** The query parameter IAM's pages read the reader's language from: IAM's own links and the proxy's sign-in bounce. */
16
+ export declare const LOCALE_PARAM = "locale";
7
17
  /** The longest display name, in code points: it is a page heading and part of an e-mail subject. */
8
18
  export declare const MAX_DISPLAY_NAME_LENGTH = 80;
9
19
  /**
@@ -2,7 +2,7 @@
2
2
  * The framework names Control hands every deploy, each with a value or `null` (the deploy removes it). Beside them, a
3
3
  * deploy carries the families of `FRAMEWORK_VARIABLE_PREFIXES`, one variable per workload, import or receiver.
4
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"];
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
6
  export type ManagedVariableName = (typeof MANAGED_VARIABLE_NAMES)[number];
7
7
  /**
8
8
  * Whether a managed variable carries a credential, so a provider writes it as a secret and never reads it back. Fail