@fabrika/auth-core 0.9.0-dev.33 → 0.9.0-dev.34
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 +6 -2
- package/src/contract.ts +2 -2
- package/src/framework-variables.ts +8 -0
- package/src/managed-environment.ts +7 -0
- package/src/oauth.ts +11 -0
- package/src/token.ts +2 -2
- package/types/src/contract.d.ts +2 -2
- package/types/src/framework-variables.d.ts +1 -1
- package/types/src/oauth.d.ts +7 -0
package/package.json
CHANGED
|
@@ -172,9 +172,13 @@ function canonicalTable(table: TablePolicyArtifact): TablePolicyArtifact {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
/** A column's
|
|
175
|
+
/** A column's lists of read and write actions sorted; one action, and an absent one, as they are. */
|
|
176
176
|
function canonicalColumn(column: ColumnPolicyArtifact): ColumnPolicyArtifact {
|
|
177
|
-
return
|
|
177
|
+
return {
|
|
178
|
+
...column,
|
|
179
|
+
...(column.read === undefined || typeof column.read === 'string' ? {} : { read: sorted(column.read) }),
|
|
180
|
+
...(column.write === undefined || typeof column.write === 'string' ? {} : { write: sorted(column.write) }),
|
|
181
|
+
}
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
function canonicalConfers(confers: ConfersArtifact): ConfersArtifact {
|
package/src/contract.ts
CHANGED
|
@@ -1020,10 +1020,10 @@ export interface ColumnTestArtifact {
|
|
|
1020
1020
|
readonly gte?: ConditionLiteralArtifact | { readonly now: true }
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
|
-
/** A column's own read actions (one as its text, several as a list),
|
|
1023
|
+
/** 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. */
|
|
1024
1024
|
export interface ColumnPolicyArtifact {
|
|
1025
1025
|
readonly read?: TableActionArtifact
|
|
1026
|
-
readonly write?:
|
|
1026
|
+
readonly write?: TableActionArtifact
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
1029
|
export type TableScope =
|
|
@@ -50,7 +50,15 @@ export const FRAMEWORK_VARIABLE_NAMES = [
|
|
|
50
50
|
'FABRIKA_APP_STORAGE_BUCKET',
|
|
51
51
|
'FABRIKA_APP_STORAGE_ACCESS_KEY_ID',
|
|
52
52
|
'FABRIKA_APP_STORAGE_SECRET_ACCESS_KEY',
|
|
53
|
+
'FABRIKA_APP_STORAGE_REGION',
|
|
54
|
+
// `path` or `virtual`, and `static` or `container`: how a container cloud's storage is addressed and signed for.
|
|
55
|
+
'FABRIKA_APP_STORAGE_ADDRESSING',
|
|
56
|
+
'FABRIKA_APP_STORAGE_CREDENTIALS',
|
|
53
57
|
'FABRIKA_STORAGE_PROVENANCE',
|
|
58
|
+
// Who schedules the jobs, and the deploy that keeps the schedule (ADR-0080). Not `FABRIKA_JOB_*`: that family is the
|
|
59
|
+
// jobs' keys, and a deploy removes a member of it that Control no longer hands it.
|
|
60
|
+
'FABRIKA_JOBS_SCHEDULE',
|
|
61
|
+
'FABRIKA_JOBS_SCHEDULE_GENERATION',
|
|
54
62
|
FABRIKA_PROXY_SECRET,
|
|
55
63
|
'FABRIKA_IAM_RPC_URL',
|
|
56
64
|
'FABRIKA_IAM_RPC_KEY',
|
|
@@ -57,6 +57,13 @@ const PUBLIC_VARIABLES: ReadonlySet<string> = new Set<FrameworkVariableName>([
|
|
|
57
57
|
FABRIKA_OPS_KEY_DIGESTS,
|
|
58
58
|
// Host names anyone can look up in DNS.
|
|
59
59
|
FABRIKA_EGRESS_REFUSED_HOSTS,
|
|
60
|
+
// The storage's region, a public name like `eu-central-1`, and two mode words.
|
|
61
|
+
'FABRIKA_APP_STORAGE_REGION',
|
|
62
|
+
'FABRIKA_APP_STORAGE_ADDRESSING',
|
|
63
|
+
'FABRIKA_APP_STORAGE_CREDENTIALS',
|
|
64
|
+
// A mode word and a deploy's generation: neither opens anything.
|
|
65
|
+
'FABRIKA_JOBS_SCHEDULE',
|
|
66
|
+
'FABRIKA_JOBS_SCHEDULE_GENERATION',
|
|
60
67
|
])
|
|
61
68
|
|
|
62
69
|
const PLATFORM_URL_VARIABLES: ReadonlySet<string> = new Set(PLATFORM_RECEIVERS.map((receiver) => platformTransportVariables(receiver).url))
|
package/src/oauth.ts
CHANGED
|
@@ -27,6 +27,17 @@ export function isCimdClientId(value: unknown): value is string {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The client id of every installation's own command-line client: a public client IAM knows without a metadata document.
|
|
32
|
+
* It is the one client id that is not a CIMD URL.
|
|
33
|
+
*/
|
|
34
|
+
export const OAUTH_CLI_CLIENT_ID = 'fabrika-cli'
|
|
35
|
+
|
|
36
|
+
/** A client id a token or revocation request may name: a CIMD document's URL, or the command-line client. */
|
|
37
|
+
export function isOAuthClientId(value: unknown): value is string {
|
|
38
|
+
return value === OAUTH_CLI_CLIENT_ID || isCimdClientId(value)
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
/** RFC 6749 scope-token syntax; duplicates and empty sets are refused. */
|
|
31
42
|
export function parseOAuthScopes(value: unknown): string[] | null {
|
|
32
43
|
if (!Array.isArray(value) || value.length === 0 || value.length > 64) return null
|
package/src/token.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import { numberField, prop, stringField } from './json'
|
|
26
26
|
import { isNormalizedMailbox } from './membership'
|
|
27
|
-
import {
|
|
27
|
+
import { isOAuthClientId, isOAuthResourceUri, parseOAuthScopes } from './oauth'
|
|
28
28
|
import type { ResolvedPrincipal } from './rpc'
|
|
29
29
|
import { isWorkloadKind, type PermissionEntry, type PermissionSource, type Scope, type TokenPrincipalType, type WorkloadKind } from './types'
|
|
30
30
|
import { isOwnWorkloadName } from './workloads'
|
|
@@ -518,7 +518,7 @@ function parseOAuthClaims(payload: unknown): OAuthTokenClaims | null | undefined
|
|
|
518
518
|
}
|
|
519
519
|
const scopes = typeof scope === 'string' ? parseOAuthScopes(scope.split(' ')) : null
|
|
520
520
|
if (
|
|
521
|
-
typeof app !== 'string' || app === '' || !
|
|
521
|
+
typeof app !== 'string' || app === '' || !isOAuthClientId(clientId) || scopes === null || typeof grantId !== 'string' || grantId === ''
|
|
522
522
|
|| typeof tokenId !== 'string' || tokenId === ''
|
|
523
523
|
) {
|
|
524
524
|
return undefined
|
package/types/src/contract.d.ts
CHANGED
|
@@ -937,10 +937,10 @@ export interface ColumnTestArtifact {
|
|
|
937
937
|
readonly now: true;
|
|
938
938
|
};
|
|
939
939
|
}
|
|
940
|
-
/** A column's own read actions (one as its text, several as a list),
|
|
940
|
+
/** 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. */
|
|
941
941
|
export interface ColumnPolicyArtifact {
|
|
942
942
|
readonly read?: TableActionArtifact;
|
|
943
|
-
readonly write?:
|
|
943
|
+
readonly write?: TableActionArtifact;
|
|
944
944
|
}
|
|
945
945
|
export type TableScope = {
|
|
946
946
|
readonly mode: 'dimension';
|
|
@@ -27,7 +27,7 @@ export declare const FABRIKA_APPLICATION_OBJECTS = "FABRIKA_APPLICATION_OBJECTS"
|
|
|
27
27
|
* application variable or secret under one of them, and so does every provider, for every surface that writes one.
|
|
28
28
|
* A work unit that gives an application a new credential adds its name here.
|
|
29
29
|
*/
|
|
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"];
|
|
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"];
|
|
31
31
|
export type FrameworkVariableName = (typeof FRAMEWORK_VARIABLE_NAMES)[number];
|
|
32
32
|
/**
|
|
33
33
|
* The name families only the platform writes: one variable per job, webhook or public procedure, named after it
|
package/types/src/oauth.d.ts
CHANGED
|
@@ -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;
|