@fabrika/auth-core 0.9.0-dev.3 → 0.9.0-dev.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/canonical-path.ts +18 -0
- package/src/client-address.ts +74 -0
- package/src/contract-canonical.ts +159 -1
- package/src/contract-encoding.ts +181 -0
- package/src/contract.ts +203 -11
- package/src/dev-environment.ts +6 -0
- package/src/egress.ts +97 -0
- package/src/endpoint-digest.ts +22 -2
- package/src/framework-release.ts +72 -0
- package/src/framework-variables.ts +15 -0
- package/src/iam-mail.ts +354 -0
- package/src/index.ts +9 -0
- package/src/locale.ts +13 -1
- package/src/managed-environment.ts +140 -0
- package/src/membership.ts +12 -4
- package/src/ops.ts +1933 -0
- package/src/permissions.ts +42 -0
- package/src/public-egress.ts +168 -0
- package/src/requirement.ts +5 -2
- package/src/rpc.ts +8 -8
- package/src/sha256.ts +52 -14
- package/src/terminal.ts +105 -0
- package/src/token.ts +73 -13
- package/src/types.ts +63 -2
- package/src/wire.ts +7 -0
- package/types/src/canonical-path.d.ts +6 -0
- package/types/src/client-address.d.ts +7 -0
- package/types/src/contract-canonical.d.ts +11 -1
- package/types/src/contract-encoding.d.ts +18 -0
- package/types/src/contract.d.ts +188 -10
- package/types/src/dev-environment.d.ts +5 -0
- package/types/src/egress.d.ts +27 -0
- package/types/src/endpoint-digest.d.ts +5 -0
- package/types/src/framework-release.d.ts +25 -0
- package/types/src/framework-variables.d.ts +12 -1
- package/types/src/iam-mail.d.ts +92 -0
- package/types/src/index.d.ts +9 -0
- package/types/src/locale.d.ts +11 -1
- package/types/src/managed-environment.d.ts +32 -0
- package/types/src/membership.d.ts +8 -3
- package/types/src/ops.d.ts +657 -0
- package/types/src/permissions.d.ts +12 -0
- package/types/src/public-egress.d.ts +31 -0
- package/types/src/requirement.d.ts +2 -2
- package/types/src/rpc.d.ts +5 -5
- package/types/src/sha256.d.ts +10 -0
- package/types/src/terminal.d.ts +72 -0
- package/types/src/token.d.ts +36 -11
- package/types/src/types.d.ts +42 -2
- package/types/src/wire.d.ts +6 -0
package/types/src/contract.d.ts
CHANGED
|
@@ -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.
|
|
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
|
|
692
|
-
*
|
|
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?:
|
|
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,10 +809,137 @@ 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
|
-
/** A column's own read
|
|
940
|
+
/** A column's own read actions (one as its text, several as a list), its own write action, or both; an absent one is left out. */
|
|
763
941
|
export interface ColumnPolicyArtifact {
|
|
764
|
-
readonly read?:
|
|
942
|
+
readonly read?: TableActionArtifact;
|
|
765
943
|
readonly write?: string;
|
|
766
944
|
}
|
|
767
945
|
export type TableScope = {
|
|
@@ -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_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
|
|
@@ -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;
|
package/types/src/index.d.ts
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
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';
|
|
20
28
|
export { sha256Hex } from './sha256';
|
|
29
|
+
export * from './terminal';
|
|
21
30
|
export * from './token';
|
|
22
31
|
export * from './types';
|
|
23
32
|
export * from './wire';
|
package/types/src/locale.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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 = {
|