@fabrika/auth-core 0.9.0-dev.3 → 0.9.0-dev.5
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 +1 -1
- package/src/contract-canonical.ts +1 -0
- package/src/contract.ts +6 -0
- package/src/dev-environment.ts +6 -0
- package/src/framework-release.ts +2 -0
- package/src/framework-variables.ts +9 -0
- package/src/index.ts +4 -0
- package/src/managed-environment.ts +136 -0
- package/src/ops.ts +1634 -0
- package/src/terminal.ts +105 -0
- package/src/token.ts +65 -5
- package/src/types.ts +4 -1
- package/src/wire.ts +6 -0
- package/types/src/contract.d.ts +6 -0
- package/types/src/dev-environment.d.ts +5 -0
- package/types/src/framework-release.d.ts +2 -0
- package/types/src/framework-variables.d.ts +7 -1
- package/types/src/index.d.ts +4 -0
- package/types/src/managed-environment.d.ts +32 -0
- package/types/src/ops.d.ts +610 -0
- package/types/src/terminal.d.ts +72 -0
- package/types/src/token.d.ts +29 -4
- package/types/src/types.d.ts +6 -1
- package/types/src/wire.d.ts +5 -0
package/src/terminal.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// What an application declares and calls to sign a person in on an enrolled terminal (ADR-0067): its identification
|
|
2
|
+
// page, and the identification operations a handler asks IAM for. IAM takes the asserting application from the
|
|
3
|
+
// verified transport, never from the input: over `/membership/*` the application's membership transport key pins it, and
|
|
4
|
+
// over a Workers binding the `props` the deployer wrote on the application's `IAM` binding pin it. The credential must
|
|
5
|
+
// also verify for that application, but its audience alone proves nothing.
|
|
6
|
+
|
|
7
|
+
import { isCanonicalPath } from './canonical-path'
|
|
8
|
+
import type { MembershipCaller } from './membership'
|
|
9
|
+
|
|
10
|
+
/** The terminal declaration of a contract: the page on the application's own origin that identifies a person. */
|
|
11
|
+
export interface TerminalArtifact {
|
|
12
|
+
readonly identify: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The longest identification path a contract declares. */
|
|
16
|
+
export const MAX_TERMINAL_IDENTIFY_PATH_LENGTH = 200
|
|
17
|
+
|
|
18
|
+
/** The query parameter IAM appends to the identification page: the identification's id. */
|
|
19
|
+
export const IDENTIFICATION_QUERY_PARAMETER = 'identification'
|
|
20
|
+
|
|
21
|
+
/** The path prefix the platform owns on every application host. */
|
|
22
|
+
const PLATFORM_PATH = '/__fabrika'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Why `path` is not an identification page, or `null`: an absolute, canonical path on the application's own origin,
|
|
26
|
+
* with no query or fragment (IAM appends its own) and outside the platform's `/__fabrika`.
|
|
27
|
+
*/
|
|
28
|
+
export function terminalIdentifyProblem(path: string): string | null {
|
|
29
|
+
if (path.length === 0 || path.length > MAX_TERMINAL_IDENTIFY_PATH_LENGTH) {
|
|
30
|
+
return `is 1 to ${MAX_TERMINAL_IDENTIFY_PATH_LENGTH} characters`
|
|
31
|
+
}
|
|
32
|
+
if (!path.startsWith('/') || path.startsWith('//')) {
|
|
33
|
+
return "is not an absolute path on the application's own origin (write it as '/identify')"
|
|
34
|
+
}
|
|
35
|
+
if (/[?#\s\p{Cc}]/u.test(path)) {
|
|
36
|
+
return 'carries a query, a fragment, whitespace or a control character; IAM appends the query itself'
|
|
37
|
+
}
|
|
38
|
+
if (!isCanonicalPath(path)) {
|
|
39
|
+
return 'is not a canonical path: no empty, `.` or `..` segment, no `\\` and no encoded separator'
|
|
40
|
+
}
|
|
41
|
+
if (path === PLATFORM_PATH || path.startsWith(`${PLATFORM_PATH}/`)) {
|
|
42
|
+
return `lies under ${PLATFORM_PATH}, which the platform owns`
|
|
43
|
+
}
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Every identification operation carries the caller's verified credential: a public procedure's workload token. */
|
|
48
|
+
export type TerminalCaller = MembershipCaller
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Why IAM refused. `not_found` is an identification that is unknown, expired, consumed, cancelled, of another
|
|
52
|
+
* application, or whose terminal no longer lists the application: alike, so an id reveals nothing. `invalid_principal`
|
|
53
|
+
* is a principal that cannot sign in on a terminal: unknown, disabled, not a person, or external (ADR-0051).
|
|
54
|
+
*/
|
|
55
|
+
export type TerminalFailure = {
|
|
56
|
+
ok: false
|
|
57
|
+
reason: 'missing_token' | 'invalid_token' | 'not_allowed' | 'not_found' | 'invalid_principal'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type TerminalFailureReason = TerminalFailure['reason']
|
|
61
|
+
|
|
62
|
+
/** The terminal an identification was opened on, as the token's `terminal` claim names it. */
|
|
63
|
+
export interface IdentificationTerminal {
|
|
64
|
+
id: string
|
|
65
|
+
label: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Read an open identification: the id is the `identification` query parameter of the identification page. */
|
|
69
|
+
export interface InspectIdentificationInput extends TerminalCaller {
|
|
70
|
+
id: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** `expiresAt` is unix seconds. The application keys its throttle of guesses on `terminal.id`. */
|
|
74
|
+
export type InspectIdentificationResult = { ok: true; terminal: IdentificationTerminal; expiresAt: number } | TerminalFailure
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The application's word that `principalId` stands at the identification's terminal. IAM consumes the identification
|
|
78
|
+
* (single use), signs the person in under the terminal's ceiling, and answers the URL the browser goes to next: IAM's
|
|
79
|
+
* completion of the identification, which issues the handoff code only to the terminal's own browser. The application
|
|
80
|
+
* never holds a code.
|
|
81
|
+
*/
|
|
82
|
+
export interface AssertIdentityInput extends TerminalCaller {
|
|
83
|
+
id: string
|
|
84
|
+
principalId: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type AssertIdentityResult = { ok: true; completionUrl: string } | TerminalFailure
|
|
88
|
+
|
|
89
|
+
/** End an identification the person abandoned. Repeating it, or cancelling a consumed one, answers `not_found`. */
|
|
90
|
+
export interface CancelIdentificationInput extends TerminalCaller {
|
|
91
|
+
id: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type CancelIdentificationResult = { ok: true } | TerminalFailure
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The identification operations IAM serves an application: on the membership transport (`/membership/<method>`) and
|
|
98
|
+
* on its application entrypoint. A SEPARATE interface from `IamMembershipRpc`, so a transport that predates terminals
|
|
99
|
+
* still satisfies that one.
|
|
100
|
+
*/
|
|
101
|
+
export interface IamTerminalRpc {
|
|
102
|
+
inspectIdentification(input: InspectIdentificationInput): Promise<InspectIdentificationResult>
|
|
103
|
+
assertIdentity(input: AssertIdentityInput): Promise<AssertIdentityResult>
|
|
104
|
+
cancelIdentification(input: CancelIdentificationInput): Promise<CancelIdentificationResult>
|
|
105
|
+
}
|
package/src/token.ts
CHANGED
|
@@ -70,13 +70,23 @@ export const DEFAULT_TOKEN_TTL_SECONDS = 300
|
|
|
70
70
|
export const TOKEN_REFRESH_SKEW_SECONDS = 30
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* The largest access token IAM signs, in bytes (a JWT is ASCII)
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
73
|
+
* The largest access token IAM signs, in bytes (a JWT is ASCII), except an application token below. A client sends
|
|
74
|
+
* such a token itself (an OAuth access token, a console bearer), so it crosses Caddy's `forward_auth` into the proxy's
|
|
75
|
+
* auth service and reaches installation services, which run on Bun with its default: a request's headers at most
|
|
76
|
+
* 16 KiB in total. 8 KiB leaves the rest for the request's own headers and cookies.
|
|
77
77
|
*/
|
|
78
78
|
export const MAX_ACCESS_TOKEN_BYTES = 8192
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* The largest token IAM mints for the proxy to inject toward a contract application, in bytes. No client sends it; on
|
|
82
|
+
* that hop it travels twice (`X-Fabrika-Token`, and `Authorization` on a bearer request), so two copies and 16 KiB of
|
|
83
|
+
* the request's own headers fit the header limit the platform starts the application's Bun with.
|
|
84
|
+
*/
|
|
85
|
+
export const MAX_APPLICATION_TOKEN_BYTES = 24576
|
|
86
|
+
|
|
87
|
+
/** The request-header limit the platform starts an application's Bun server with (`--max-http-header-size`). */
|
|
88
|
+
export const APPLICATION_SERVER_MAX_HEADER_BYTES = 65536
|
|
89
|
+
|
|
80
90
|
// ── Claim shape (one, no discriminator) ────────────────────────────────────────
|
|
81
91
|
|
|
82
92
|
/**
|
|
@@ -117,12 +127,29 @@ export interface AccessTokenClaims {
|
|
|
117
127
|
* key carries what the key's own grants narrow, so a check that resolves the person's permissions requires this.
|
|
118
128
|
*/
|
|
119
129
|
session?: true
|
|
130
|
+
/**
|
|
131
|
+
* Present only on a session token of a person an application asserted at an enrolled terminal (ADR-0067), and
|
|
132
|
+
* always together with `terminal`.
|
|
133
|
+
*/
|
|
134
|
+
amr?: TerminalAuthenticationMethod
|
|
135
|
+
/** The terminal the person is signed in on; present exactly when `amr` is. */
|
|
136
|
+
terminal?: TerminalTokenClaims
|
|
120
137
|
/** Present only on an OAuth resource token (`aud` is then a resource URI, not an app id). */
|
|
121
138
|
oauth?: OAuthTokenClaims
|
|
122
139
|
/** Present only on a share-link token, which has no `ptype`: `sub` is then the link key's id. */
|
|
123
140
|
link?: LinkTokenClaims
|
|
124
141
|
}
|
|
125
142
|
|
|
143
|
+
/** The `amr` value of a session an application asserted at a terminal. */
|
|
144
|
+
export const TERMINAL_AUTHENTICATION_METHOD = 'terminal_assertion'
|
|
145
|
+
export type TerminalAuthenticationMethod = typeof TERMINAL_AUTHENTICATION_METHOD
|
|
146
|
+
|
|
147
|
+
/** The terminal a person's session was asserted on: its principal id and the label an administrator gave it. */
|
|
148
|
+
export interface TerminalTokenClaims {
|
|
149
|
+
id: string
|
|
150
|
+
label: string
|
|
151
|
+
}
|
|
152
|
+
|
|
126
153
|
/** What a share-link token adds: the link mount that issued the key and the chain the key is bound to. */
|
|
127
154
|
export interface LinkTokenClaims {
|
|
128
155
|
mount: string
|
|
@@ -200,6 +227,8 @@ export interface AccessTokenParams {
|
|
|
200
227
|
email?: string
|
|
201
228
|
/** Minted from a signed-in session; refused on a token without `type` or of a workload. */
|
|
202
229
|
session?: true
|
|
230
|
+
/** The terminal of a person's session asserted on one; sets `amr` too, and requires a user `type` and `session`. */
|
|
231
|
+
terminal?: TerminalTokenClaims
|
|
203
232
|
permissions: PermissionEntry[]
|
|
204
233
|
issuedAt: number
|
|
205
234
|
expiresAt: number
|
|
@@ -284,6 +313,13 @@ export function buildAccessClaims(params: AccessTokenParams): AccessTokenClaims
|
|
|
284
313
|
if (params.type === undefined || isWorkloadKind(params.type)) throw new Error("Only a person's or a service's token is minted from a session")
|
|
285
314
|
claims.session = params.session
|
|
286
315
|
}
|
|
316
|
+
if (params.terminal !== undefined) {
|
|
317
|
+
if (params.type !== 'user' || params.session !== true || !isTerminalClaims(params.terminal)) {
|
|
318
|
+
throw new Error("Only a person's session token names a terminal, and only by a non-empty id and label")
|
|
319
|
+
}
|
|
320
|
+
claims.amr = TERMINAL_AUTHENTICATION_METHOD
|
|
321
|
+
claims.terminal = { id: params.terminal.id, label: params.terminal.label }
|
|
322
|
+
}
|
|
287
323
|
if (params.link !== undefined) {
|
|
288
324
|
if (params.type !== undefined) throw new Error('A share-link token has no principal type')
|
|
289
325
|
claims.link = { mount: params.link.mount, chain: params.link.chain.map((scope) => ({ type: scope.type, value: scope.value })) }
|
|
@@ -333,6 +369,10 @@ export function parseAccessClaims(payload: unknown): AccessTokenClaims | null {
|
|
|
333
369
|
if (session !== undefined && (session !== true || ptype === null || isWorkloadKind(ptype) || oauth !== null)) {
|
|
334
370
|
return null
|
|
335
371
|
}
|
|
372
|
+
const terminal = parseTerminalClaims(prop(payload, 'amr'), prop(payload, 'terminal'))
|
|
373
|
+
if (terminal === undefined || (terminal !== null && (ptype !== 'user' || session !== true || oauth !== null))) {
|
|
374
|
+
return null
|
|
375
|
+
}
|
|
336
376
|
const claims: AccessTokenClaims = { iss, aud, sub, iat, exp, perms, label }
|
|
337
377
|
if (ptype !== null) {
|
|
338
378
|
claims.ptype = ptype
|
|
@@ -346,6 +386,10 @@ export function parseAccessClaims(payload: unknown): AccessTokenClaims | null {
|
|
|
346
386
|
if (session === true) {
|
|
347
387
|
claims.session = true
|
|
348
388
|
}
|
|
389
|
+
if (terminal !== null) {
|
|
390
|
+
claims.amr = TERMINAL_AUTHENTICATION_METHOD
|
|
391
|
+
claims.terminal = terminal
|
|
392
|
+
}
|
|
349
393
|
if (oauth !== null) {
|
|
350
394
|
claims.oauth = oauth
|
|
351
395
|
}
|
|
@@ -379,6 +423,22 @@ function parseEmail(value: unknown, ptype: TokenPrincipalType | null): string |
|
|
|
379
423
|
return ptype === 'user' && typeof value === 'string' && isNormalizedMailbox(value) ? value : undefined
|
|
380
424
|
}
|
|
381
425
|
|
|
426
|
+
/** Both absent → null; `amr` naming the terminal method beside a well-formed `terminal` → it; anything else → undefined. */
|
|
427
|
+
function parseTerminalClaims(amr: unknown, value: unknown): TerminalTokenClaims | null | undefined {
|
|
428
|
+
if (amr === undefined && value === undefined) {
|
|
429
|
+
return null
|
|
430
|
+
}
|
|
431
|
+
if (amr !== TERMINAL_AUTHENTICATION_METHOD) {
|
|
432
|
+
return undefined
|
|
433
|
+
}
|
|
434
|
+
const terminal = { id: stringField(value, 'id'), label: stringField(value, 'label') }
|
|
435
|
+
return isTerminalClaims(terminal) ? { id: terminal.id, label: terminal.label } : undefined
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function isTerminalClaims(value: { id: string | undefined; label: string | undefined }): value is TerminalTokenClaims {
|
|
439
|
+
return value.id !== undefined && value.id !== '' && value.label !== undefined && value.label !== ''
|
|
440
|
+
}
|
|
441
|
+
|
|
382
442
|
/** Absent → null; a mount and a non-empty chain → the claims; anything else → undefined. */
|
|
383
443
|
function parseLinkClaims(value: unknown): LinkTokenClaims | null | undefined {
|
|
384
444
|
if (value === undefined) {
|
|
@@ -470,7 +530,7 @@ function parseScope(value: unknown): Scope | null | undefined {
|
|
|
470
530
|
|
|
471
531
|
/** Validate `source` against the union — our own token, but read without `as`. */
|
|
472
532
|
function parseSource(value: unknown): PermissionSource | null {
|
|
473
|
-
if (value === 'grant' || value === 'bootstrap') {
|
|
533
|
+
if (value === 'grant' || value === 'bootstrap' || value === 'terminal') {
|
|
474
534
|
return value
|
|
475
535
|
}
|
|
476
536
|
if (typeof value === 'string' && value.startsWith('group:')) {
|
package/src/types.ts
CHANGED
|
@@ -31,8 +31,9 @@ export function isWorkloadKind(value: unknown): value is WorkloadKind {
|
|
|
31
31
|
* - 'grant' — explicit `grants` row
|
|
32
32
|
* - 'bootstrap' — IAM_BOOTSTRAP_ADMINS env match (resolution-time only)
|
|
33
33
|
* - `group:${groupRef}` — IdP group → role mapping (the `<org>/<team>` ref)
|
|
34
|
+
* - 'terminal' — a grant of the terminal a person is signed in on (ADR-0067)
|
|
34
35
|
*/
|
|
35
|
-
export type PermissionSource = 'grant' | 'bootstrap' | `group:${string}`
|
|
36
|
+
export type PermissionSource = 'grant' | 'bootstrap' | 'terminal' | `group:${string}`
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* A flat, app-owned scope coordinate — one dimension (`type`) and an opaque value.
|
|
@@ -177,6 +178,8 @@ export interface AppSchema {
|
|
|
177
178
|
members?: { manage: string; list: string }
|
|
178
179
|
/** `labels`: a holder of the app's `members.list` also sees each member's label. Absent, labels stay with `members.manage`. */
|
|
179
180
|
directory?: 'labels'
|
|
181
|
+
/** The app's identification page for a person at an enrolled terminal (ADR-0067); absent, no terminal lists it. */
|
|
182
|
+
terminal?: { identify: string }
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
/**
|
package/src/wire.ts
CHANGED
|
@@ -63,6 +63,12 @@ export function proxySecretVariable(id: string): string {
|
|
|
63
63
|
return `${FABRIKA_PROXY_SECRET}_${sha256Hex(id).slice(0, 32).toUpperCase()}`
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The variable holding the secret the platform proxy sends IAM's installation entry in `PROXY_SECRET_HEADER`. The proxy
|
|
68
|
+
* and IAM hold it under this one name. It proves only who wrote IAM's client-address and request-id headers.
|
|
69
|
+
*/
|
|
70
|
+
export const IAM_PROXY_SECRET_VARIABLE = 'FABRIKA_INSTALLATION_PROXY_SECRET_IAM'
|
|
71
|
+
|
|
66
72
|
/**
|
|
67
73
|
* Every `X-Fabrika-*` name a proxy hop carries to an application. Caddy's first step and the Cloudflare proxy Worker
|
|
68
74
|
* delete each of them from the client's request before anything else, then set only what the decision asserts. A new
|
package/types/src/contract.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Locale } from './locale';
|
|
2
2
|
import type { MailTemplates } from './mail';
|
|
3
|
+
import type { TerminalArtifact } from './terminal';
|
|
3
4
|
/**
|
|
4
5
|
* The artifact format this release writes. A release that changes the artifact raises it, and Control upcasts every
|
|
5
6
|
* older format of its window to this one (ADR-0062). The 0.4, 0.5 and 0.6 artifacts carry no `format`.
|
|
@@ -62,6 +63,11 @@ export interface ContractArtifact extends EndpointTable {
|
|
|
62
63
|
};
|
|
63
64
|
/** `labels`: the application's directory shows labels to `members.list` holders. Absent unless declared, so digests stay. */
|
|
64
65
|
readonly directory?: 'labels';
|
|
66
|
+
/**
|
|
67
|
+
* The page on the application's own origin that identifies a person at an enrolled terminal (ADR-0067): IAM sends a
|
|
68
|
+
* terminal's browser there, and only an application that declares it may assert a person. Absent unless declared.
|
|
69
|
+
*/
|
|
70
|
+
readonly terminal?: TerminalArtifact;
|
|
65
71
|
/**
|
|
66
72
|
* What each procedure of the staged kit admits and how long it runs, by endpoint id, with every default applied: the
|
|
67
73
|
* rules the application applies itself, beside the row the proxy applies. Absent for a contract with no such
|
|
@@ -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;
|
|
@@ -10,13 +10,19 @@ 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
|
+
/** The name of the object that serves an environment's ordinary traffic on Cloudflare; `application` without it. */
|
|
16
|
+
export declare const FABRIKA_APPLICATION_OBJECT = "FABRIKA_APPLICATION_OBJECT";
|
|
17
|
+
/** The object names an ops request may target, all in the environment's own namespace (`parseApplicationObjects`). */
|
|
18
|
+
export declare const FABRIKA_APPLICATION_OBJECTS = "FABRIKA_APPLICATION_OBJECTS";
|
|
13
19
|
/**
|
|
14
20
|
* The environment names only the platform writes into an application
|
|
15
21
|
* ([ADR-0043](../../../docs/decisions/0043-validate-and-render-one-zerops-descriptor-meaning.md)). Control refuses an
|
|
16
22
|
* application variable or secret under one of them, and so does every provider, for every surface that writes one.
|
|
17
23
|
* A work unit that gives an application a new credential adds its name here.
|
|
18
24
|
*/
|
|
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"];
|
|
25
|
+
export declare const FRAMEWORK_VARIABLE_NAMES: readonly ["FABRIKA_RELEASE", "FABRIKA_CONTRACT_DIGEST", "FABRIKA_IAM_ISSUER", "FABRIKA_IAM_APP_ID", "FABRIKA_OPERATIONS_DSN", "FABRIKA_APP_ID", "FABRIKA_ENVIRONMENT", "FABRIKA_SERVICE_KEY", "FABRIKA_APP_DATABASE_URL", "FABRIKA_APP_RUNTIME_DATABASE_URL", "FABRIKA_APP_DATABASE_CONNECTIONS", "FABRIKA_APP_STORAGE_ENDPOINT", "FABRIKA_APP_STORAGE_BUCKET", "FABRIKA_APP_STORAGE_ACCESS_KEY_ID", "FABRIKA_APP_STORAGE_SECRET_ACCESS_KEY", "FABRIKA_STORAGE_PROVENANCE", "FABRIKA_PROXY_SECRET", "FABRIKA_IAM_RPC_URL", "FABRIKA_IAM_RPC_KEY", "FABRIKA_SOURCE_MAP_UPLOAD", "FABRIKA_SOURCE_MAP_UPLOAD_KEY", "FABRIKA_TOKEN_KEYS", "FABRIKA_APP_ORIGIN", "FABRIKA_OPS_KEY_DIGESTS", "FABRIKA_APPLICATION_OBJECT", "FABRIKA_APPLICATION_OBJECTS"];
|
|
20
26
|
export type FrameworkVariableName = (typeof FRAMEWORK_VARIABLE_NAMES)[number];
|
|
21
27
|
/**
|
|
22
28
|
* The name families only the platform writes: one variable per job, webhook or public procedure, named after it
|
package/types/src/index.d.ts
CHANGED
|
@@ -7,17 +7,21 @@ export * from './device';
|
|
|
7
7
|
export * from './endpoint-digest';
|
|
8
8
|
export * from './endpoints';
|
|
9
9
|
export * from './environment';
|
|
10
|
+
export * from './framework-release';
|
|
10
11
|
export * from './framework-variables';
|
|
11
12
|
export * from './installation-endpoint';
|
|
12
13
|
export { parseJsonStringArray } from './json';
|
|
13
14
|
export * from './locale';
|
|
14
15
|
export * from './mail';
|
|
16
|
+
export * from './managed-environment';
|
|
15
17
|
export * from './membership';
|
|
16
18
|
export * from './oauth';
|
|
19
|
+
export * from './ops';
|
|
17
20
|
export * from './permissions';
|
|
18
21
|
export * from './requirement';
|
|
19
22
|
export * from './rpc';
|
|
20
23
|
export { sha256Hex } from './sha256';
|
|
24
|
+
export * from './terminal';
|
|
21
25
|
export * from './token';
|
|
22
26
|
export * from './types';
|
|
23
27
|
export * from './wire';
|
|
@@ -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"];
|
|
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[];
|