@fabrika/auth-core 0.9.0-dev.4 → 0.9.0-dev.40

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/canonical-path.ts +18 -0
  3. package/src/client-address.ts +74 -0
  4. package/src/contract-canonical.ts +168 -2
  5. package/src/contract-encoding.ts +181 -0
  6. package/src/contract.ts +212 -12
  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 +72 -0
  11. package/src/framework-variables.ts +23 -0
  12. package/src/iam-mail.ts +354 -0
  13. package/src/index.ts +10 -0
  14. package/src/locale.ts +13 -1
  15. package/src/managed-environment.ts +147 -0
  16. package/src/membership.ts +12 -4
  17. package/src/oauth.ts +11 -0
  18. package/src/ops.ts +1933 -0
  19. package/src/permissions.ts +42 -0
  20. package/src/public-egress.ts +168 -0
  21. package/src/requirement.ts +5 -2
  22. package/src/rpc.ts +8 -8
  23. package/src/scope-values.ts +123 -0
  24. package/src/sha256.ts +52 -14
  25. package/src/terminal.ts +105 -0
  26. package/src/token.ts +170 -19
  27. package/src/types.ts +68 -2
  28. package/src/wire.ts +7 -0
  29. package/types/src/canonical-path.d.ts +6 -0
  30. package/types/src/client-address.d.ts +7 -0
  31. package/types/src/contract-canonical.d.ts +11 -1
  32. package/types/src/contract-encoding.d.ts +18 -0
  33. package/types/src/contract.d.ts +197 -11
  34. package/types/src/dev-environment.d.ts +5 -0
  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 +25 -0
  38. package/types/src/framework-variables.d.ts +12 -1
  39. package/types/src/iam-mail.d.ts +92 -0
  40. package/types/src/index.d.ts +10 -0
  41. package/types/src/locale.d.ts +11 -1
  42. package/types/src/managed-environment.d.ts +32 -0
  43. package/types/src/membership.d.ts +8 -3
  44. package/types/src/oauth.d.ts +7 -0
  45. package/types/src/ops.d.ts +657 -0
  46. package/types/src/permissions.d.ts +12 -0
  47. package/types/src/public-egress.d.ts +31 -0
  48. package/types/src/requirement.d.ts +2 -2
  49. package/types/src/rpc.d.ts +5 -5
  50. package/types/src/scope-values.d.ts +61 -0
  51. package/types/src/sha256.d.ts +10 -0
  52. package/types/src/terminal.d.ts +72 -0
  53. package/types/src/token.d.ts +69 -12
  54. package/types/src/types.d.ts +47 -2
  55. package/types/src/wire.d.ts +6 -0
@@ -1,5 +1,8 @@
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';
5
+ import type { TerminalArtifact } from './terminal';
3
6
  /**
4
7
  * The artifact format this release writes. A release that changes the artifact raises it, and Control upcasts every
5
8
  * older format of its window to this one (ADR-0062). The 0.4, 0.5 and 0.6 artifacts carry no `format`.
@@ -18,10 +21,15 @@ export interface ContractArtifact extends EndpointTable {
18
21
  /** Action → description. Exact actions only; the artifact holds no wildcard. */
19
22
  readonly actions: Readonly<Record<string, string>>;
20
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>>;
21
29
  readonly mounts: Readonly<Record<string, MountArtifact>>;
22
30
  readonly files: Readonly<Record<string, FileCollectionArtifact>>;
23
31
  /**
24
- * 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
25
33
  * has no owner and no endpoint; the table that holds a file is its authority. Absent unless declared, so the digest stays.
26
34
  */
27
35
  readonly fileKinds?: Readonly<Record<string, FileKindArtifact>>;
@@ -62,6 +70,11 @@ export interface ContractArtifact extends EndpointTable {
62
70
  };
63
71
  /** `labels`: the application's directory shows labels to `members.list` holders. Absent unless declared, so digests stay. */
64
72
  readonly directory?: 'labels';
73
+ /**
74
+ * The page on the application's own origin that identifies a person at an enrolled terminal (ADR-0067): IAM sends a
75
+ * terminal's browser there, and only an application that declares it may assert a person. Absent unless declared.
76
+ */
77
+ readonly terminal?: TerminalArtifact;
65
78
  /**
66
79
  * What each procedure of the staged kit admits and how long it runs, by endpoint id, with every default applied: the
67
80
  * rules the application applies itself, beside the row the proxy applies. Absent for a contract with no such
@@ -168,7 +181,8 @@ interface EndpointRowBase {
168
181
  readonly crossOrigin?: CrossOriginForm;
169
182
  /**
170
183
  * `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.
184
+ * answer of it, a denial included, ADR-0022's file treatment. `inline-file`: the same, for a kind declared `inline:
185
+ * true`, whose XML documents are shown too. Absent otherwise, so every other row keeps its digest.
172
186
  */
173
187
  readonly response?: EndpointResponse;
174
188
  /**
@@ -186,8 +200,8 @@ interface EndpointRowBase {
186
200
  }
187
201
  /** What the proxy does with an anonymous request's `Authorization` on a row that names it: forward it to the application. */
188
202
  export type EndpointAuthorization = 'forward';
189
- /** The answer profile of a row that answers a stored file. */
190
- export type EndpointResponse = 'file';
203
+ /** The answer profile of a row that answers a stored file: `inline-file` also shows the XML documents a machine reads. */
204
+ export type EndpointResponse = 'file' | 'inline-file';
191
205
  /** A cacheable row's lifetime: `maxAgeSeconds`, or `immutable`, a year, for an input that names an immutable value. */
192
206
  export type EndpointCache = {
193
207
  readonly maxAgeSeconds: number;
@@ -226,7 +240,7 @@ export interface BodyAdmission {
226
240
  * `action` is that action in some scope, global included, and only globally under the `app` form. The access form is
227
241
  * what the framework then resolves.
228
242
  */
229
- export type EndpointRequirement = MemberRequirement | ActionRequirement | CapabilitiesRequirement;
243
+ export type EndpointRequirement = MemberRequirement | ActionRequirement | AnyOfRequirement | CapabilitiesRequirement;
230
244
  export interface MemberRequirement {
231
245
  readonly kind: 'member';
232
246
  }
@@ -235,6 +249,21 @@ export interface ActionRequirement {
235
249
  readonly action: string;
236
250
  readonly access: AccessForm;
237
251
  }
252
+ /**
253
+ * Any one of several actions (`access: { anyOf, app: true }`), each held as a global grant, the `app` form's rule: two to
254
+ * `MAX_ANY_OF` distinct actions, sorted, so the order in the source does not change the digest.
255
+ */
256
+ export interface AnyOfRequirement {
257
+ readonly kind: 'anyOf';
258
+ readonly actions: readonly [string, string, ...string[]];
259
+ readonly access: {
260
+ readonly form: 'app';
261
+ };
262
+ }
263
+ /** The most actions an `anyOf` requirement lists. */
264
+ export declare const MAX_ANY_OF = 16;
265
+ /** Whether `actions` is an `anyOf` list as a row carries it: two to `MAX_ANY_OF` actions, strictly ascending. */
266
+ export declare function isAnyOfList(actions: readonly string[]): boolean;
238
267
  /**
239
268
  * Several capabilities (`access: { capabilities }`), by the name the handler reads each under (`ctx.capabilities.<name>`):
240
269
  * 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 +355,8 @@ export interface FileShape {
326
355
  readonly kind: string;
327
356
  }
328
357
  export declare function isFileShape(shape: OutputShape): shape is FileShape;
358
+ /** The kinds of the files a schema holds, anywhere in it, each once per place it appears. */
359
+ export declare function fileKindsIn(shape: SchemaShape): readonly string[];
329
360
  /**
330
361
  * What a procedure answers: a JSON value of a schema, a file of rows (`attachment()` of `@fabrika/app/contract`), or a
331
362
  * redirect (`redirect()`).
@@ -414,6 +445,13 @@ export interface DimensionArtifact {
414
445
  } | null;
415
446
  /** `labels`: the member directory shows labels to `members.list` holders. Absent unless declared, so digests stay. */
416
447
  readonly directory?: 'labels';
448
+ /** The values the console offers for a grant in this dimension (ADR-0085). Absent unless declared, so digests stay. */
449
+ readonly values?: readonly DimensionValue[];
450
+ /**
451
+ * The id of the query procedure IAM asks, as the administrator, for this dimension's values (ADR-0085 §4). Absent
452
+ * unless declared, so digests stay.
453
+ */
454
+ readonly valuesFrom?: string;
417
455
  }
418
456
  export interface RoleArtifact {
419
457
  readonly grants: readonly string[];
@@ -427,6 +465,15 @@ export interface RoleArtifact {
427
465
  } | null;
428
466
  /** An external principal may hold this membership role (ADR-0051). Absent unless declared, so digests stay. */
429
467
  readonly external?: true;
468
+ /**
469
+ * Relation → actions the holder of a global grant of this role holds at each node a relation row names them at.
470
+ * Absent unless declared, so digests stay.
471
+ */
472
+ readonly via?: Readonly<Record<string, readonly string[]>>;
473
+ }
474
+ /** A relation of the vocabulary: the dimension whose nodes its rows name. */
475
+ export interface RelationArtifact {
476
+ readonly dimension: string;
430
477
  }
431
478
  export type MountArtifact = RpcMountArtifact | LinkMountArtifact | SpaMountArtifact | HealthMountArtifact | FormMountArtifact | WebhookMountArtifact;
432
479
  export interface RpcMountArtifact {
@@ -615,6 +662,11 @@ export interface FileKindArtifact {
615
662
  readonly maxBytes: number;
616
663
  /** Present when every file of the kind waits `quarantined` for a clean malware verdict before it is served. */
617
664
  readonly scan?: true;
665
+ /**
666
+ * Present when its files are shown rather than downloaded: every type is an inert image or an XML document a machine
667
+ * reads, and a row answering it is `response: 'inline-file'`. Absent otherwise, so every other kind keeps its digest.
668
+ */
669
+ readonly inline?: true;
618
670
  }
619
671
  export interface JobArtifact {
620
672
  readonly schedule: string;
@@ -688,10 +740,12 @@ export interface DeclaredReach {
688
740
  */
689
741
  readonly signs?: readonly string[];
690
742
  /**
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.
743
+ * The HTTPS origins this site's code calls (`fetch`), sorted, each an exact origin or a one-label pattern
744
+ * (`parseEgressEntry`): a credentialed procedure, a webhook or a job. Or `'public'` (a cron job only): every public
745
+ * host over HTTPS or HTTP, never the installation or a private network (ADR-0075). Absent unless declared, so the
746
+ * digest stays.
693
747
  */
694
- readonly egress?: readonly string[];
748
+ readonly egress?: DeclaredEgress;
695
749
  /**
696
750
  * A public procedure's workload actions, sorted: all its handler holds, through the key Control issues for the
697
751
  * endpoint (`contractWorkloads`). Present only on a public procedure's entry, so every other digest stays.
@@ -728,6 +782,11 @@ export interface CspSource {
728
782
  * two. A single action stays text, so the artifact of a policy that names one keeps its shape and digest.
729
783
  */
730
784
  export type TableActionArtifact = string | readonly string[];
785
+ /**
786
+ * An application table's `actions.read` that every `app` endpoint, job and webhook reads with, whatever its action; never
787
+ * a public procedure, a scoped site, a link or an export. No vocabulary may declare an action of this name.
788
+ */
789
+ export declare const READ_ANY = "any";
731
790
  export interface TablePolicyArtifact {
732
791
  readonly scope: TableScope;
733
792
  /** An inbox's read action is `read`; it has no write action, because only its form appends. */
@@ -758,11 +817,138 @@ export interface TablePolicyArtifact {
758
817
  * actions are the file's authority. Absent unless declared, so the digest stays.
759
818
  */
760
819
  readonly files?: Readonly<Record<string, string>>;
820
+ /**
821
+ * A view (ADR-0072): read like its scope's tables, written by nothing, its containment stated by its SQL alone.
822
+ * Absent for a table, so the digest stays.
823
+ */
824
+ readonly view?: true;
825
+ /** Relation → how a row of this table confers it. Absent unless declared, so the digest stays. */
826
+ readonly confers?: Readonly<Record<string, ConfersArtifact>>;
827
+ /** Action → the condition a row must meet for it, narrowing what any grant of it reaches. Absent unless declared. */
828
+ readonly when?: Readonly<Record<string, ConditionArtifact>>;
829
+ /**
830
+ * Relation → action → the condition a row the relation reaches must meet for it; it narrows that relation's reach only.
831
+ * Absent unless declared, so the digest stays. A reader that ignores it reaches more: Control refuses to publish it to
832
+ * an application pinned below the release that enforces it.
833
+ */
834
+ readonly relationWhen?: Readonly<Record<string, Readonly<Record<string, ConditionArtifact>>>>;
835
+ /**
836
+ * Relation of the table's own dimension → the ancestor its rows reveal. Absent unless declared, so the digest stays.
837
+ * A reader that ignores it reaches less, never more.
838
+ */
839
+ readonly reveals?: Readonly<Record<string, RevealsArtifact>>;
840
+ /**
841
+ * Dimension outside the chain → the column a `Within`'s read reaches a row through. Absent unless declared, so the
842
+ * digest stays. A reader that ignores it reaches less, never more.
843
+ */
844
+ readonly readThrough?: Readonly<Record<string, string>>;
845
+ /**
846
+ * Dimension of `readThrough` → the actions a `Ref` held through that path holds, writes included; whoever inserts the
847
+ * path's column must hold each at the node it names. Absent unless declared, so the digest stays. A reader that
848
+ * ignores it reaches less, never more.
849
+ */
850
+ readonly writeThrough?: Readonly<Record<string, readonly string[]>>;
851
+ /**
852
+ * The table's own dimension → the ancestor its rows reveal to a grant at their node, for a `Within`'s reads. Absent
853
+ * unless declared, so the digest stays. A reader that ignores it reaches less, never more.
854
+ */
855
+ readonly memberReveals?: Readonly<Record<string, MemberRevealsArtifact>>;
856
+ /**
857
+ * Relation → the access view that lists the rows it reaches (ADR-0076). Absent unless declared, so the digest stays.
858
+ * A reader that ignores it reaches less, never more.
859
+ */
860
+ readonly access?: Readonly<Record<string, AccessArtifact>>;
861
+ }
862
+ /** An access view: its `row` column names the table's key; `principal` is compared to the caller, `member` to its nodes. */
863
+ export interface AccessArtifact {
864
+ readonly view: string;
865
+ readonly row: string;
866
+ readonly principal: string | null;
867
+ readonly member: string | null;
868
+ }
869
+ /**
870
+ * 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
871
+ * key's dimension names, while `when` admits the row.
872
+ */
873
+ export interface MemberRevealsArtifact {
874
+ readonly to: string;
875
+ readonly actions: readonly string[];
876
+ readonly when?: ConditionArtifact;
877
+ /**
878
+ * Through a path, on a table with an insert: the writer picks the node, and `self` lets it pick one where it holds a
879
+ * grant the reveal counts. Absent otherwise; only a reader that refuses a path's key reads it.
880
+ */
881
+ readonly assign?: {
882
+ readonly self: boolean;
883
+ };
884
+ }
885
+ /** A row the relation reaches reveals its node in `to` for `actions`, while `when` admits the row. */
886
+ export interface RevealsArtifact {
887
+ readonly to: string;
888
+ readonly actions: readonly string[];
889
+ readonly when?: ConditionArtifact;
890
+ /** On a reveal matched through `readThrough`: an insert delegates, and `self` lets it name a node its writer holds. */
891
+ readonly assign?: {
892
+ readonly self: boolean;
893
+ };
894
+ }
895
+ /** A row names `principal` at the node in `node`, until `expires`, while `when` admits it; `assign` bounds its writer. */
896
+ export interface ConfersArtifact {
897
+ /** The column that holds the principal, or `<column>.<principal column>` through one foreign key of the table. */
898
+ readonly principal: string;
899
+ readonly node: string;
900
+ readonly expires: string | null;
901
+ readonly when?: ConditionArtifact;
902
+ readonly assign: {
903
+ readonly maxDays: number | null;
904
+ readonly self: boolean;
905
+ } | null;
906
+ }
907
+ /**
908
+ * A structured row condition: connectives, `{ '<column or fk_column.column>': test }` with every test holding, or
909
+ * `some` / `none` of the rows of one table whose foreign key names the row, also at the end of a path
910
+ * (`{ '<fk_column>': { some: … } }`). Each form is absent from a condition that does not use it, so its digest stays.
911
+ */
912
+ export type ConditionArtifact = {
913
+ readonly allOf: readonly ConditionArtifact[];
914
+ } | {
915
+ readonly anyOf: readonly ConditionArtifact[];
916
+ } | {
917
+ readonly not: ConditionArtifact;
918
+ } | RowsTestArtifact | {
919
+ readonly [path: string]: ColumnTestArtifact | RowsTestArtifact;
920
+ };
921
+ /** `some` or `none` of the rows of one table whose foreign key names the row. */
922
+ export type RowsTestArtifact = {
923
+ readonly some: Readonly<Record<string, ConditionArtifact>>;
924
+ } | {
925
+ readonly none: Readonly<Record<string, ConditionArtifact>>;
926
+ };
927
+ export type ConditionLiteralArtifact = string | number | boolean;
928
+ /** One operator of a column test; `{ now: true }` compares a timestamp with the statement's clock. */
929
+ export interface ColumnTestArtifact {
930
+ readonly eq?: ConditionLiteralArtifact;
931
+ readonly notEq?: ConditionLiteralArtifact;
932
+ readonly in?: readonly ConditionLiteralArtifact[];
933
+ readonly notIn?: readonly ConditionLiteralArtifact[];
934
+ readonly isNull?: boolean;
935
+ readonly lt?: ConditionLiteralArtifact | {
936
+ readonly now: true;
937
+ };
938
+ readonly lte?: ConditionLiteralArtifact | {
939
+ readonly now: true;
940
+ };
941
+ readonly gt?: ConditionLiteralArtifact | {
942
+ readonly now: true;
943
+ };
944
+ readonly gte?: ConditionLiteralArtifact | {
945
+ readonly now: true;
946
+ };
761
947
  }
762
- /** A column's own read action, its own write action, or both; an absent one is left out. */
948
+ /** 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. */
763
949
  export interface ColumnPolicyArtifact {
764
- readonly read?: string;
765
- readonly write?: string;
950
+ readonly read?: TableActionArtifact;
951
+ readonly write?: TableActionArtifact;
766
952
  }
767
953
  export type TableScope = {
768
954
  readonly mode: 'dimension';
@@ -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,25 @@
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;
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;
@@ -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_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"];
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
@@ -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,23 +1,33 @@
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';
15
+ export * from './iam-mail';
11
16
  export * from './installation-endpoint';
12
17
  export { parseJsonStringArray } from './json';
13
18
  export * from './locale';
14
19
  export * from './mail';
20
+ export * from './managed-environment';
15
21
  export * from './membership';
16
22
  export * from './oauth';
23
+ export * from './ops';
17
24
  export * from './permissions';
25
+ export * from './public-egress';
18
26
  export * from './requirement';
19
27
  export * from './rpc';
28
+ export * from './scope-values';
20
29
  export { sha256Hex } from './sha256';
30
+ export * from './terminal';
21
31
  export * from './token';
22
32
  export * from './types';
23
33
  export * from './wire';
@@ -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
  /**
@@ -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[];
@@ -1,4 +1,5 @@
1
1
  import type { ContractArtifact, EndpointRow } from './contract';
2
+ import { type Locale } from './locale';
2
3
  import type { PrincipalAffiliation, Scope } from './types';
3
4
  /**
4
5
  * What an endpoint may ask IAM about the members of its own target (`ctx.members`): `manage` where its action is the
@@ -98,14 +99,18 @@ export declare const MAX_INVITATION_MESSAGE_LENGTH = 1000;
98
99
  * What an invitation by address carries besides its role. `label` is the invited person's company as the application
99
100
  * names it, `message` the inviter's personal note; both are plain text IAM escapes wherever it inserts them. `resend`
100
101
  * rotates the open invitation's link, restarts its lifetime and sends it again; without it, repeating an invitation
101
- * answers the open one and sends nothing.
102
+ * answers the open one and sends nothing. `locale` is the invited person's language, when the application knows it: IAM
103
+ * writes the invitation and the pages its link opens in it, and its acceptance keeps it as the person's, so IAM's later
104
+ * e-mails (a password reset) and pages speak it too. Without one, IAM speaks the language the person already has, else the
105
+ * application's. A resend that names one replaces the stored one.
102
106
  */
103
107
  export interface InvitationOptions {
104
108
  readonly label?: string;
105
109
  readonly message?: string;
106
110
  readonly resend?: boolean;
111
+ readonly locale?: Locale;
107
112
  }
108
- /** Why IAM refuses an invitation's label or message, or `null`. A message may break lines; nothing else is a control character. */
113
+ /** Why IAM refuses an invitation's label, message or locale, or `null`. A message may break lines; nothing else is a control character. */
109
114
  export declare function invitationOptionsProblem(options: InvitationOptions): string | null;
110
115
  /** How long a delegation grant may be held before it is spent. One request, so seconds. */
111
116
  export declare const DELEGATION_GRANT_TTL_SECONDS = 120;
@@ -152,7 +157,7 @@ export interface AssignMemberInput extends MembershipCaller {
152
157
  scope: Scope;
153
158
  role: string;
154
159
  member: MemberTarget;
155
- /** Only with an address: the invitation's label, message and resend (`InvitationOptions`). */
160
+ /** Only with an address: the invitation's label, message, resend and locale (`InvitationOptions`). */
156
161
  invitation?: InvitationOptions;
157
162
  }
158
163
  export type AssignMemberResult = {
@@ -3,5 +3,12 @@
3
3
  export declare function isOAuthResourceUri(value: unknown): value is string;
4
4
  /** Client ID Metadata Document identifier: HTTPS, explicit path, no userinfo, fragment or dot segments. */
5
5
  export declare function isCimdClientId(value: unknown): value is string;
6
+ /**
7
+ * The client id of every installation's own command-line client: a public client IAM knows without a metadata document.
8
+ * It is the one client id that is not a CIMD URL.
9
+ */
10
+ export declare const OAUTH_CLI_CLIENT_ID = "fabrika-cli";
11
+ /** A client id a token or revocation request may name: a CIMD document's URL, or the command-line client. */
12
+ export declare function isOAuthClientId(value: unknown): value is string;
6
13
  /** RFC 6749 scope-token syntax; duplicates and empty sets are refused. */
7
14
  export declare function parseOAuthScopes(value: unknown): string[] | null;