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

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 (49) hide show
  1. package/package.json +2 -2
  2. package/src/canonical-path.ts +18 -0
  3. package/src/client-address.ts +74 -0
  4. package/src/contract-canonical.ts +152 -1
  5. package/src/contract-encoding.ts +181 -0
  6. package/src/contract.ts +201 -9
  7. package/src/dev-environment.ts +6 -0
  8. package/src/egress.ts +97 -0
  9. package/src/endpoint-digest.ts +22 -2
  10. package/src/framework-release.ts +2 -0
  11. package/src/framework-variables.ts +15 -0
  12. package/src/iam-mail.ts +354 -0
  13. package/src/index.ts +9 -0
  14. package/src/locale.ts +13 -1
  15. package/src/managed-environment.ts +140 -0
  16. package/src/membership.ts +12 -4
  17. package/src/ops.ts +1933 -0
  18. package/src/public-egress.ts +168 -0
  19. package/src/requirement.ts +5 -2
  20. package/src/rpc.ts +8 -8
  21. package/src/sha256.ts +52 -14
  22. package/src/terminal.ts +105 -0
  23. package/src/token.ts +73 -13
  24. package/src/types.ts +63 -2
  25. package/src/wire.ts +7 -0
  26. package/types/src/canonical-path.d.ts +6 -0
  27. package/types/src/client-address.d.ts +7 -0
  28. package/types/src/contract-canonical.d.ts +11 -1
  29. package/types/src/contract-encoding.d.ts +18 -0
  30. package/types/src/contract.d.ts +186 -8
  31. package/types/src/dev-environment.d.ts +5 -0
  32. package/types/src/egress.d.ts +27 -0
  33. package/types/src/endpoint-digest.d.ts +5 -0
  34. package/types/src/framework-release.d.ts +2 -0
  35. package/types/src/framework-variables.d.ts +12 -1
  36. package/types/src/iam-mail.d.ts +92 -0
  37. package/types/src/index.d.ts +9 -0
  38. package/types/src/locale.d.ts +11 -1
  39. package/types/src/managed-environment.d.ts +32 -0
  40. package/types/src/membership.d.ts +8 -3
  41. package/types/src/ops.d.ts +657 -0
  42. package/types/src/public-egress.d.ts +31 -0
  43. package/types/src/requirement.d.ts +2 -2
  44. package/types/src/rpc.d.ts +5 -5
  45. package/types/src/sha256.d.ts +10 -0
  46. package/types/src/terminal.d.ts +72 -0
  47. package/types/src/token.d.ts +36 -11
  48. package/types/src/types.d.ts +42 -2
  49. package/types/src/wire.d.ts +6 -0
@@ -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';
@@ -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 = {