@gadicc/loom 1.33.1 → 1.35.0
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/README.md +108 -41
- package/esm/src/apiKeys/authorize.d.ts.map +1 -1
- package/esm/src/apiKeys/authorize.js +71 -0
- package/esm/src/apiKeys/betterAuth.d.ts +123 -0
- package/esm/src/apiKeys/betterAuth.d.ts.map +1 -0
- package/esm/src/apiKeys/betterAuth.js +164 -0
- package/esm/src/apiKeys/credentials.d.ts +37 -2
- package/esm/src/apiKeys/credentials.d.ts.map +1 -1
- package/esm/src/apiKeys/credentials.js +69 -8
- package/esm/src/apiKeys/lifecycle.d.ts +41 -0
- package/esm/src/apiKeys/lifecycle.d.ts.map +1 -0
- package/esm/src/apiKeys/lifecycle.js +6 -0
- package/esm/src/apiKeys/limits.d.ts +132 -0
- package/esm/src/apiKeys/limits.d.ts.map +1 -0
- package/esm/src/apiKeys/limits.js +246 -0
- package/esm/src/apiKeys/mod.d.ts +4 -0
- package/esm/src/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/apiKeys/mod.js +4 -0
- package/esm/src/apiKeys/permissions.d.ts +56 -0
- package/esm/src/apiKeys/permissions.d.ts.map +1 -0
- package/esm/src/apiKeys/permissions.js +128 -0
- package/esm/src/apiKeys/policy.d.ts +3 -1
- package/esm/src/apiKeys/policy.d.ts.map +1 -1
- package/esm/src/apiKeys/policy.js +3 -1
- package/esm/src/apiKeys/types.d.ts +68 -1
- package/esm/src/apiKeys/types.d.ts.map +1 -1
- package/esm/src/cli/localDb.d.ts +28 -0
- package/esm/src/cli/localDb.d.ts.map +1 -0
- package/esm/src/cli/localDb.js +366 -0
- package/esm/src/cli/localDevLock.d.ts +97 -0
- package/esm/src/cli/localDevLock.d.ts.map +1 -0
- package/esm/src/cli/localDevLock.js +312 -0
- package/esm/src/cli/localDevPackage.d.ts +172 -0
- package/esm/src/cli/localDevPackage.d.ts.map +1 -0
- package/esm/src/cli/localDevPackage.js +617 -0
- package/esm/src/cli/migrationEnv.d.ts +19 -0
- package/esm/src/cli/migrationEnv.d.ts.map +1 -1
- package/esm/src/cli/migrationEnv.js +44 -1
- package/esm/src/cli/mod.d.ts +69 -4
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +2822 -419
- package/esm/src/cli/projectTooling.d.ts +19 -1
- package/esm/src/cli/projectTooling.d.ts.map +1 -1
- package/esm/src/cli/projectTooling.js +142 -12
- package/esm/src/mui/apiKeys.d.ts +123 -17
- package/esm/src/mui/apiKeys.d.ts.map +1 -1
- package/esm/src/mui/apiKeys.js +219 -78
- package/esm/src/mui/apiKeysView.d.ts +145 -0
- package/esm/src/mui/apiKeysView.d.ts.map +1 -1
- package/esm/src/mui/apiKeysView.js +278 -0
- package/esm/src/next/apiKeys/mod.d.ts +8 -1
- package/esm/src/next/apiKeys/mod.d.ts.map +1 -1
- package/esm/src/next/apiKeys/mod.js +5 -2
- package/package.json +2 -6
- package/script/src/apiKeys/authorize.d.ts.map +1 -1
- package/script/src/apiKeys/authorize.js +71 -0
- package/script/src/apiKeys/betterAuth.d.ts +123 -0
- package/script/src/apiKeys/betterAuth.d.ts.map +1 -0
- package/script/src/apiKeys/betterAuth.js +169 -0
- package/script/src/apiKeys/credentials.d.ts +37 -2
- package/script/src/apiKeys/credentials.d.ts.map +1 -1
- package/script/src/apiKeys/credentials.js +71 -8
- package/script/src/apiKeys/lifecycle.d.ts +41 -0
- package/script/src/apiKeys/lifecycle.d.ts.map +1 -0
- package/script/src/apiKeys/lifecycle.js +7 -0
- package/script/src/apiKeys/limits.d.ts +132 -0
- package/script/src/apiKeys/limits.d.ts.map +1 -0
- package/script/src/apiKeys/limits.js +254 -0
- package/script/src/apiKeys/mod.d.ts +4 -0
- package/script/src/apiKeys/mod.d.ts.map +1 -1
- package/script/src/apiKeys/mod.js +4 -0
- package/script/src/apiKeys/permissions.d.ts +56 -0
- package/script/src/apiKeys/permissions.d.ts.map +1 -0
- package/script/src/apiKeys/permissions.js +136 -0
- package/script/src/apiKeys/policy.d.ts +3 -1
- package/script/src/apiKeys/policy.d.ts.map +1 -1
- package/script/src/apiKeys/policy.js +3 -1
- package/script/src/apiKeys/types.d.ts +68 -1
- package/script/src/apiKeys/types.d.ts.map +1 -1
- package/script/src/cli/localDb.d.ts +28 -0
- package/script/src/cli/localDb.d.ts.map +1 -0
- package/script/src/cli/localDb.js +370 -0
- package/script/src/cli/localDevLock.d.ts +97 -0
- package/script/src/cli/localDevLock.d.ts.map +1 -0
- package/script/src/cli/localDevLock.js +320 -0
- package/script/src/cli/localDevPackage.d.ts +172 -0
- package/script/src/cli/localDevPackage.d.ts.map +1 -0
- package/script/src/cli/localDevPackage.js +635 -0
- package/script/src/cli/migrationEnv.d.ts +19 -0
- package/script/src/cli/migrationEnv.d.ts.map +1 -1
- package/script/src/cli/migrationEnv.js +48 -1
- package/script/src/cli/mod.d.ts +69 -4
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +2823 -419
- package/script/src/cli/projectTooling.d.ts +19 -1
- package/script/src/cli/projectTooling.d.ts.map +1 -1
- package/script/src/cli/projectTooling.js +176 -12
- package/script/src/mui/apiKeys.d.ts +123 -17
- package/script/src/mui/apiKeys.d.ts.map +1 -1
- package/script/src/mui/apiKeys.js +220 -77
- package/script/src/mui/apiKeysView.d.ts +145 -0
- package/script/src/mui/apiKeysView.d.ts.map +1 -1
- package/script/src/mui/apiKeysView.js +291 -0
- package/script/src/next/apiKeys/mod.d.ts +8 -1
- package/script/src/next/apiKeys/mod.d.ts.map +1 -1
- package/script/src/next/apiKeys/mod.js +5 -2
- package/skills/loom/SKILL.md +116 -18
- package/skills/loom-api-keys/SKILL.md +101 -7
- package/skills/loom-auth/SKILL.md +9 -0
- package/skills/loom-db/SKILL.md +33 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
2
|
+
/** Returns `value` only when it is a plain (JSON-shaped) object. */
|
|
3
|
+
function asPermissionRecord(value) {
|
|
4
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
5
|
+
return null;
|
|
6
|
+
const prototype = Object.getPrototypeOf(value);
|
|
7
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
8
|
+
return null;
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Reports whether decoded api-key permissions grant exactly `permission`.
|
|
13
|
+
*
|
|
14
|
+
* `decoded` must already be decoded: Better Auth's `verifyApiKey` result, or a
|
|
15
|
+
* raw column passed through `decodeStoredApiKeyPermissions`. Strings are never
|
|
16
|
+
* decoded here, because Better Auth has already decoded the column once; a
|
|
17
|
+
* string at this point means double-encoded storage, which Better Auth's own
|
|
18
|
+
* check denies too.
|
|
19
|
+
*
|
|
20
|
+
* Fails closed: anything but a plain or null-prototype object, inherited
|
|
21
|
+
* properties, non-array action lists, and non-identical action strings never
|
|
22
|
+
* match. This is stricter than Better Auth's check, which reads inherited
|
|
23
|
+
* properties and would substring-match an action list stored as a string.
|
|
24
|
+
*/
|
|
25
|
+
export function hasApiKeyPermission(decoded, permission) {
|
|
26
|
+
if (!permission || typeof permission !== "object")
|
|
27
|
+
return false;
|
|
28
|
+
const { action, resource } = permission;
|
|
29
|
+
if (typeof resource !== "string" || typeof action !== "string")
|
|
30
|
+
return false;
|
|
31
|
+
if (!resource || !action)
|
|
32
|
+
return false;
|
|
33
|
+
const record = asPermissionRecord(decoded);
|
|
34
|
+
if (!record || !hasOwn(record, resource))
|
|
35
|
+
return false;
|
|
36
|
+
const actions = record[resource];
|
|
37
|
+
return Array.isArray(actions) && actions.includes(action);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Decodes a raw stored `apikey.permissions` value exactly once.
|
|
41
|
+
*
|
|
42
|
+
* Better Auth stores permissions as JSON text. A string is parsed once, and
|
|
43
|
+
* malformed JSON yields `null`; any other value is returned unchanged so a
|
|
44
|
+
* database driver that already decoded the column still works. JSON that
|
|
45
|
+
* decodes to another string, i.e. double-encoded storage, is returned as that
|
|
46
|
+
* string and therefore grants nothing.
|
|
47
|
+
*/
|
|
48
|
+
export function decodeStoredApiKeyPermissions(stored) {
|
|
49
|
+
if (typeof stored !== "string")
|
|
50
|
+
return stored;
|
|
51
|
+
try {
|
|
52
|
+
return JSON.parse(stored);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Converts scope IDs into the native permissions to store on a new key.
|
|
60
|
+
*
|
|
61
|
+
* Actions for scopes that share a resource are merged rather than replaced,
|
|
62
|
+
* and duplicates are removed. An ID that is not an own registry entry throws:
|
|
63
|
+
* validate untrusted input against the registry first.
|
|
64
|
+
*/
|
|
65
|
+
export function apiKeyPermissionsFromScopeIds(registry, scopeIds) {
|
|
66
|
+
if (!Array.isArray(scopeIds)) {
|
|
67
|
+
throw new Error("API-key scope IDs must be an array.");
|
|
68
|
+
}
|
|
69
|
+
const actionsByResource = new Map();
|
|
70
|
+
for (const scopeId of scopeIds) {
|
|
71
|
+
if (typeof scopeId !== "string" || !hasOwn(registry.byId, scopeId)) {
|
|
72
|
+
throw new Error(`Unknown API-key scope "${String(scopeId)}".`);
|
|
73
|
+
}
|
|
74
|
+
const { action, resource } = registry.byId[scopeId].permission;
|
|
75
|
+
const actions = actionsByResource.get(resource) ?? [];
|
|
76
|
+
if (!actions.includes(action))
|
|
77
|
+
actions.push(action);
|
|
78
|
+
actionsByResource.set(resource, actions);
|
|
79
|
+
}
|
|
80
|
+
// `Object.fromEntries` defines own data properties, so a resource such as
|
|
81
|
+
// "__proto__" cannot change the result's prototype.
|
|
82
|
+
return Object.fromEntries(actionsByResource);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Lists the registry scope IDs that decoded permissions grant exactly, in
|
|
86
|
+
* registry order. Grants outside the registry are ignored.
|
|
87
|
+
*/
|
|
88
|
+
export function apiKeyScopeIdsFromPermissions(registry, decoded) {
|
|
89
|
+
return registry.list
|
|
90
|
+
.filter((scope) => hasApiKeyPermission(decoded, scope.permission))
|
|
91
|
+
.map((scope) => scope.id);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Builds the explicit principal permissions for a verified key: the registry
|
|
95
|
+
* permissions that decoded permissions grant exactly, in registry order.
|
|
96
|
+
*/
|
|
97
|
+
export function apiKeyPrincipalPermissions(registry, decoded) {
|
|
98
|
+
return registry.list
|
|
99
|
+
.filter((scope) => hasApiKeyPermission(decoded, scope.permission))
|
|
100
|
+
.map((scope) => ({
|
|
101
|
+
action: scope.permission.action,
|
|
102
|
+
resource: scope.permission.resource,
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Flattens every exact grant in decoded permissions, for verifiers without a
|
|
107
|
+
* registry. Non-plain objects, inherited properties, non-array action lists,
|
|
108
|
+
* and non-string or empty actions are skipped.
|
|
109
|
+
*/
|
|
110
|
+
export function apiKeyGrantedPermissions(decoded) {
|
|
111
|
+
const record = asPermissionRecord(decoded);
|
|
112
|
+
if (!record)
|
|
113
|
+
return [];
|
|
114
|
+
const permissions = [];
|
|
115
|
+
for (const resource of Object.keys(record)) {
|
|
116
|
+
const actions = record[resource];
|
|
117
|
+
if (!resource || !Array.isArray(actions))
|
|
118
|
+
continue;
|
|
119
|
+
const seen = new Set();
|
|
120
|
+
for (const action of actions) {
|
|
121
|
+
if (typeof action !== "string" || !action || seen.has(action))
|
|
122
|
+
continue;
|
|
123
|
+
seen.add(action);
|
|
124
|
+
permissions.push({ action, resource });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return permissions;
|
|
128
|
+
}
|
|
@@ -50,7 +50,9 @@ export declare function defineApiKeyScopes<const TDefinitions extends ApiKeyScop
|
|
|
50
50
|
* Creates an exact-match, default-deny policy from a typed scope registry.
|
|
51
51
|
*
|
|
52
52
|
* The verifier remains responsible for proving that the key owns the requested
|
|
53
|
-
* native permission
|
|
53
|
+
* native permission; for Better Auth, `createBetterAuthApiKeyVerifier` checks
|
|
54
|
+
* the decoded grants itself, because the plugin reports a missing permission
|
|
55
|
+
* as an unknown key. Dynamic rules are for fresh app-owned checks such as
|
|
54
56
|
* current role membership; thrown errors intentionally reach Loom's existing
|
|
55
57
|
* `policy_error` handling.
|
|
56
58
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CACtC,CAAC;AAEF,KAAK,aAAa,CAAC,YAAY,SAAS,sBAAsB,IAAI,OAAO,CACvE,MAAM,YAAY,EAClB,MAAM,CACP,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,CAC7B,YAAY,SAAS,sBAAsB,IACzC;KACD,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,GAAG,QAAQ,CAC5C;QAAE,EAAE,EAAE,GAAG,CAAA;KAAE,GAAG,YAAY,CAAC,GAAG,CAAC,CAChC;CACF,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;AAE/B,4EAA4E;AAC5E,MAAM,WAAW,mBAAmB,CAClC,YAAY,SAAS,sBAAsB;IAE3C,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,4CAA4C;IAC5C,QAAQ,CAAC,GAAG,EAAE,SAAS,aAAa,CAAC,YAAY,CAAC,E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,sBAAsB,IACzC;IACF,QAAQ,EAAE,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,GAAG,gBAAgB;CAChE,CAAC;AA+CF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,YAAY,SAAS,sBAAsB,EACjD,WAAW,EAAE,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAkB9D;AAsBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,CAAC,YAAY,SAAS,sBAAsB,EAEjD,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAC3C,KAAK,EAAE,iBAAiB,CAAC,YAAY,CAAC,GACrC,YAAY,CAiBd"}
|
|
@@ -65,7 +65,9 @@ function assertPolicyRules(registry, rules) {
|
|
|
65
65
|
* Creates an exact-match, default-deny policy from a typed scope registry.
|
|
66
66
|
*
|
|
67
67
|
* The verifier remains responsible for proving that the key owns the requested
|
|
68
|
-
* native permission
|
|
68
|
+
* native permission; for Better Auth, `createBetterAuthApiKeyVerifier` checks
|
|
69
|
+
* the decoded grants itself, because the plugin reports a missing permission
|
|
70
|
+
* as an unknown key. Dynamic rules are for fresh app-owned checks such as
|
|
69
71
|
* current role membership; thrown errors intentionally reach Loom's existing
|
|
70
72
|
* `policy_error` handling.
|
|
71
73
|
*/
|
|
@@ -19,17 +19,32 @@ export type ApiKeyCredentialExtractionResult = {
|
|
|
19
19
|
transport: ApiKeyCredentialTransport;
|
|
20
20
|
} | {
|
|
21
21
|
kind: "ambiguous";
|
|
22
|
+
/**
|
|
23
|
+
* The transports involved. A single element means one transport carried
|
|
24
|
+
* several values, for example `["x-api-key"]` for a repeated header or
|
|
25
|
+
* `["query"]` for a repeated query parameter.
|
|
26
|
+
*/
|
|
22
27
|
transports: ApiKeyCredentialTransport[];
|
|
23
28
|
} | {
|
|
24
29
|
credential: string;
|
|
25
30
|
kind: "present";
|
|
26
31
|
transport: ApiKeyCredentialTransport;
|
|
27
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Which credential transports an app accepts. Plain data, so the same object
|
|
35
|
+
* can configure the authorizer and, passed from a Server Component, the MUI
|
|
36
|
+
* transport guidance.
|
|
37
|
+
*/
|
|
28
38
|
export interface ApiKeyCredentialOptions {
|
|
39
|
+
/** Accept `Authorization: Bearer <key>`. Defaults to `true`. */
|
|
29
40
|
allowAuthorizationBearer?: boolean;
|
|
41
|
+
/** Accept a query parameter. Defaults to `false`; URLs leak keys. */
|
|
30
42
|
allowQuery?: boolean;
|
|
43
|
+
/** Accept the `xApiKeyHeaderName` header. Defaults to `true`. */
|
|
31
44
|
allowXApiKey?: boolean;
|
|
45
|
+
/** Query parameter name. Defaults to `"apiKey"`. */
|
|
32
46
|
queryName?: string;
|
|
47
|
+
/** Header name for the `x-api-key` transport. Defaults to `"x-api-key"`. */
|
|
33
48
|
xApiKeyHeaderName?: string;
|
|
34
49
|
}
|
|
35
50
|
export interface ApiKeyCredentialSource {
|
|
@@ -73,7 +88,7 @@ export interface ApiKeyAuthorizationAuditEvent {
|
|
|
73
88
|
operation: string;
|
|
74
89
|
ownerId?: string;
|
|
75
90
|
pageName?: string;
|
|
76
|
-
reasonCode?:
|
|
91
|
+
reasonCode?: ApiKeyAuditReasonCode;
|
|
77
92
|
requestId?: string;
|
|
78
93
|
routeTemplate?: string;
|
|
79
94
|
scopeAction: string;
|
|
@@ -98,6 +113,11 @@ export interface ApiKeyCompletionAuditEvent {
|
|
|
98
113
|
operationOutcome: ApiKeyOperationOutcome;
|
|
99
114
|
ownerId: string;
|
|
100
115
|
pageName?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Loom records an `ApiKeyCompletionReasonCode`. The type stays `string` for
|
|
118
|
+
* completion events an app appends itself; never record error messages or
|
|
119
|
+
* class names here, because owners can read their own audit history.
|
|
120
|
+
*/
|
|
101
121
|
reasonCode?: string;
|
|
102
122
|
requestId?: string;
|
|
103
123
|
scopeAction: string;
|
|
@@ -134,6 +154,19 @@ export type ApiKeyVerifierResult = {
|
|
|
134
154
|
} | {
|
|
135
155
|
code: "insufficient_permission" | "invalid_credential" | "rate_limited";
|
|
136
156
|
ok: false;
|
|
157
|
+
/**
|
|
158
|
+
* The valid key's identity, for an `insufficient_permission` denial
|
|
159
|
+
* only. Loom records it on the denial audit event so the key's owner can
|
|
160
|
+
* see it; it never reaches the caller or the response. Ignored for every
|
|
161
|
+
* other code, so invalid, revoked, expired, and rate-limited attempts stay
|
|
162
|
+
* unattributed.
|
|
163
|
+
*
|
|
164
|
+
* Return it only after the secret itself was verified (its hash matched)
|
|
165
|
+
* and the key was confirmed enabled and unexpired. Otherwise an
|
|
166
|
+
* attacker's attempts could be attributed to a victim's key and evict its
|
|
167
|
+
* history from the per-key retention cap.
|
|
168
|
+
*/
|
|
169
|
+
principal?: ApiKeyPrincipal;
|
|
137
170
|
status?: 401 | 403 | 429;
|
|
138
171
|
};
|
|
139
172
|
/** App adapter that performs exactly one verification call per authorization. */
|
|
@@ -163,11 +196,45 @@ export type ApiKeyAuthorizationResult = {
|
|
|
163
196
|
ok: false;
|
|
164
197
|
status: 400 | 401 | 403 | 429 | 500 | 503;
|
|
165
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* Reason recorded on an authorization audit event. Adds two audit-only codes
|
|
201
|
+
* for the `rejectCredential` hook: `credential_rejected` (it denied the
|
|
202
|
+
* credential; callers see `invalid_credential`) and
|
|
203
|
+
* `credential_rejection_error` (it threw; callers see `verification_error`).
|
|
204
|
+
*/
|
|
205
|
+
export type ApiKeyAuditReasonCode = ApiKeyDenialCode | "credential_rejected" | "credential_rejection_error";
|
|
206
|
+
/**
|
|
207
|
+
* Reason Loom records on a completion audit event: `handler_error` when the
|
|
208
|
+
* protected handler threw. The error's class and message are never recorded.
|
|
209
|
+
*/
|
|
210
|
+
export type ApiKeyCompletionReasonCode = "handler_error";
|
|
211
|
+
/** Context passed to a `rejectCredential` hook. */
|
|
212
|
+
export interface ApiKeyCredentialRejectionContext {
|
|
213
|
+
/** The protected operation being authorized. */
|
|
214
|
+
descriptor: ApiKeyAuthorizationDescriptor;
|
|
215
|
+
/** The transport the credential arrived in. */
|
|
216
|
+
transport: ApiKeyCredentialTransport;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* App-owned check that denies specific credential values, such as a
|
|
220
|
+
* scheduler's shared secret, before Loom fingerprints, verifies, or
|
|
221
|
+
* attributes them. Any result other than `false` denies; a thrown error
|
|
222
|
+
* fails closed as `verification_error` (audited as
|
|
223
|
+
* `credential_rejection_error`).
|
|
224
|
+
*/
|
|
225
|
+
export type ApiKeyCredentialRejector = (credential: string, context: ApiKeyCredentialRejectionContext) => boolean | Promise<boolean>;
|
|
166
226
|
export interface AuthorizeApiKeyOptions {
|
|
167
227
|
audit: ApiKeyAuditRepository;
|
|
168
228
|
credentialOptions?: ApiKeyCredentialOptions;
|
|
169
229
|
descriptor: ApiKeyAuthorizationDescriptor;
|
|
170
230
|
policy: ApiKeyPolicy;
|
|
231
|
+
/**
|
|
232
|
+
* Called once with the single extracted credential, before it is
|
|
233
|
+
* fingerprinted or verified. A rejection is answered exactly like an
|
|
234
|
+
* invalid key (401 `invalid_credential`) and audited without any
|
|
235
|
+
* credential-derived data under reason `credential_rejected`.
|
|
236
|
+
*/
|
|
237
|
+
rejectCredential?: ApiKeyCredentialRejector;
|
|
171
238
|
request?: ApiKeyRequestAuditContext;
|
|
172
239
|
source: ApiKeyCredentialSource;
|
|
173
240
|
verifier: ApiKeyVerifier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/types.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC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AC5C,UAAU,EAAE,6BAA6B,CAAC;IAC1C,MAAM,EAAE,YAAY,CAAC;IACrB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,EAAE,cAAc,CAAC;CAC1B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CommandRunner } from "./mod.js";
|
|
2
|
+
type LocalDbOptions = {
|
|
3
|
+
commandRunner: CommandRunner;
|
|
4
|
+
env?: Record<string, string | undefined>;
|
|
5
|
+
host?: string;
|
|
6
|
+
port?: string;
|
|
7
|
+
replaceLocalTarget?: boolean;
|
|
8
|
+
promptSecret?: (question: string) => Promise<string>;
|
|
9
|
+
resolveHost?: (host: string) => Promise<Array<{
|
|
10
|
+
address: string;
|
|
11
|
+
}>>;
|
|
12
|
+
};
|
|
13
|
+
/** Check all configured URL candidates and authenticate as the restricted project role. */
|
|
14
|
+
export declare function checkLocalDatabase(cwd: string, options: LocalDbOptions): Promise<{
|
|
15
|
+
database: string;
|
|
16
|
+
role: string;
|
|
17
|
+
host: string;
|
|
18
|
+
port: string;
|
|
19
|
+
}>;
|
|
20
|
+
/** Provision one project database and role on an existing local PostgreSQL server. */
|
|
21
|
+
export declare function setupLocalDatabase(cwd: string, options: LocalDbOptions): Promise<{
|
|
22
|
+
database: string;
|
|
23
|
+
role: string;
|
|
24
|
+
host: string;
|
|
25
|
+
port: string;
|
|
26
|
+
}>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=localDb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDb.d.ts","sourceRoot":"","sources":["../../../src/src/cli/localDb.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAqB9C,KAAK,cAAc,GAAG;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CACrE,CAAC;AAmPF,2FAA2F;AAC3F,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;;;;;GA4C5E;AAED,sFAAsF;AACtF,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;;;;;GA0L5E"}
|