@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,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_KEY_EXPIRY_TOLERANCE_SECONDS = exports.API_KEY_SECONDS_PER_DAY = void 0;
|
|
4
|
+
exports.apiKeyLimitMessages = apiKeyLimitMessages;
|
|
5
|
+
exports.validateApiKeyName = validateApiKeyName;
|
|
6
|
+
exports.resolveApiKeyExpiresIn = resolveApiKeyExpiresIn;
|
|
7
|
+
exports.betterAuthApiKeyInputErrorMessage = betterAuthApiKeyInputErrorMessage;
|
|
8
|
+
exports.betterAuthApiKeyLimitOptions = betterAuthApiKeyLimitOptions;
|
|
9
|
+
/** Seconds in one day; the plugin compares `expiresIn / 86400` to its limits. */
|
|
10
|
+
exports.API_KEY_SECONDS_PER_DAY = 86_400;
|
|
11
|
+
/**
|
|
12
|
+
* Default slack for a custom expiry chosen right at a limit. The browser
|
|
13
|
+
* converts the chosen date before the request reaches the server, and clocks
|
|
14
|
+
* drift, so "one day from now" arrives a little under one day away. Values
|
|
15
|
+
* within this slack are clamped onto the limit instead of being rejected.
|
|
16
|
+
*/
|
|
17
|
+
exports.API_KEY_EXPIRY_TOLERANCE_SECONDS = 300;
|
|
18
|
+
const NAME_REQUIRED_MESSAGE = "Enter a name for this key.";
|
|
19
|
+
const EXPIRY_IN_FUTURE_MESSAGE = "Choose a future expiry date.";
|
|
20
|
+
function formatDays(days) {
|
|
21
|
+
return days === 1 ? "1 day" : `${days} days`;
|
|
22
|
+
}
|
|
23
|
+
function formatCharacters(count) {
|
|
24
|
+
return count === 1 ? "1 character" : `${count} characters`;
|
|
25
|
+
}
|
|
26
|
+
function assertDays(field, value) {
|
|
27
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
28
|
+
throw new Error(`Invalid API-key limits: ${field} must be a finite number of days >= 0.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function assertNameLength(field, value) {
|
|
32
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1) {
|
|
33
|
+
throw new Error(`Invalid API-key limits: ${field} must be a safe integer >= 1.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Rejects malformed limits so a misconfiguration fails loudly rather than
|
|
38
|
+
* silently validating nothing. Omitted fields are allowed here; the public
|
|
39
|
+
* Better Auth helpers require every field through their types.
|
|
40
|
+
*/
|
|
41
|
+
function assertLimits(limits) {
|
|
42
|
+
if (!limits || typeof limits !== "object") {
|
|
43
|
+
throw new Error("Invalid API-key limits: expected an object.");
|
|
44
|
+
}
|
|
45
|
+
const { maxExpiresInDays, maxNameLength, minExpiresInDays, minNameLength } = limits;
|
|
46
|
+
if (minExpiresInDays !== undefined) {
|
|
47
|
+
assertDays("minExpiresInDays", minExpiresInDays);
|
|
48
|
+
}
|
|
49
|
+
if (maxExpiresInDays !== undefined) {
|
|
50
|
+
assertDays("maxExpiresInDays", maxExpiresInDays);
|
|
51
|
+
}
|
|
52
|
+
if (minNameLength !== undefined) {
|
|
53
|
+
assertNameLength("minNameLength", minNameLength);
|
|
54
|
+
}
|
|
55
|
+
if (maxNameLength !== undefined) {
|
|
56
|
+
assertNameLength("maxNameLength", maxNameLength);
|
|
57
|
+
}
|
|
58
|
+
if (minExpiresInDays !== undefined && maxExpiresInDays !== undefined &&
|
|
59
|
+
minExpiresInDays > maxExpiresInDays) {
|
|
60
|
+
throw new Error("Invalid API-key limits: minExpiresInDays exceeds maxExpiresInDays.");
|
|
61
|
+
}
|
|
62
|
+
if (minNameLength !== undefined && maxNameLength !== undefined &&
|
|
63
|
+
minNameLength > maxNameLength) {
|
|
64
|
+
throw new Error("Invalid API-key limits: minNameLength exceeds maxNameLength.");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function assertCompleteLimits(limits) {
|
|
68
|
+
assertLimits(limits);
|
|
69
|
+
for (const field of [
|
|
70
|
+
"maxExpiresInDays",
|
|
71
|
+
"maxNameLength",
|
|
72
|
+
"minExpiresInDays",
|
|
73
|
+
"minNameLength",
|
|
74
|
+
]) {
|
|
75
|
+
if (limits[field] === undefined) {
|
|
76
|
+
throw new Error(`Invalid API-key limits: ${field} is required.`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Builds the user-facing messages for one set of limits.
|
|
82
|
+
*
|
|
83
|
+
* Server validation, the MUI dialogs, and `betterAuthApiKeyInputErrorMessage`
|
|
84
|
+
* all use these, so the same input produces the same text everywhere. Bounds
|
|
85
|
+
* omitted from `limits` fall back to the generic messages Loom's dialogs used
|
|
86
|
+
* before limits existed.
|
|
87
|
+
*/
|
|
88
|
+
function apiKeyLimitMessages(limits) {
|
|
89
|
+
assertLimits(limits);
|
|
90
|
+
const { maxExpiresInDays, maxNameLength, minExpiresInDays, minNameLength } = limits;
|
|
91
|
+
let nameLength = NAME_REQUIRED_MESSAGE;
|
|
92
|
+
if (minNameLength !== undefined && maxNameLength !== undefined) {
|
|
93
|
+
nameLength =
|
|
94
|
+
`Key names must be between ${minNameLength} and ${maxNameLength} characters.`;
|
|
95
|
+
}
|
|
96
|
+
else if (maxNameLength !== undefined) {
|
|
97
|
+
nameLength = `Key names must be at most ${formatCharacters(maxNameLength)}.`;
|
|
98
|
+
}
|
|
99
|
+
else if (minNameLength !== undefined) {
|
|
100
|
+
nameLength = `Key names must be at least ${formatCharacters(minNameLength)}.`;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
expiryInvalid: "Expiry must be a valid date.",
|
|
104
|
+
expiryRequired: "Choose an expiry date.",
|
|
105
|
+
expiryTooLate: maxExpiresInDays === undefined
|
|
106
|
+
? "Expiry is too far in the future."
|
|
107
|
+
: `Expiry must be no more than ${formatDays(maxExpiresInDays)} from now.`,
|
|
108
|
+
expiryTooSoon: minExpiresInDays === undefined || minExpiresInDays === 0
|
|
109
|
+
? EXPIRY_IN_FUTURE_MESSAGE
|
|
110
|
+
: `Expiry must be at least ${formatDays(minExpiresInDays)} from now.`,
|
|
111
|
+
nameLength,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Validates and trims an untrusted key name.
|
|
116
|
+
*
|
|
117
|
+
* Accepts `unknown` because server-action arguments are untrusted. A blank
|
|
118
|
+
* name is always rejected. Omitted bounds are not enforced here, so pass the
|
|
119
|
+
* same complete `ApiKeyLimits` given to the plugin.
|
|
120
|
+
*/
|
|
121
|
+
function validateApiKeyName(name, limits) {
|
|
122
|
+
const messages = apiKeyLimitMessages(limits);
|
|
123
|
+
const trimmed = typeof name === "string" ? name.trim() : "";
|
|
124
|
+
if (trimmed.length === 0 ||
|
|
125
|
+
(limits.minNameLength !== undefined &&
|
|
126
|
+
trimmed.length < limits.minNameLength) ||
|
|
127
|
+
(limits.maxNameLength !== undefined &&
|
|
128
|
+
trimmed.length > limits.maxNameLength)) {
|
|
129
|
+
return { message: messages.nameLength, ok: false };
|
|
130
|
+
}
|
|
131
|
+
return { ok: true, value: trimmed };
|
|
132
|
+
}
|
|
133
|
+
function referenceTime(now) {
|
|
134
|
+
const value = now === undefined
|
|
135
|
+
? Date.now()
|
|
136
|
+
: typeof now === "number"
|
|
137
|
+
? now
|
|
138
|
+
: now.valueOf();
|
|
139
|
+
if (!Number.isFinite(value)) {
|
|
140
|
+
throw new Error("resolveApiKeyExpiresIn: `now` must be a valid time.");
|
|
141
|
+
}
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Converts an untrusted absolute expiry into the plugin's relative
|
|
146
|
+
* `expiresIn` seconds, or `null` when no expiry was chosen.
|
|
147
|
+
*
|
|
148
|
+
* Only strings are accepted (parsed with `Date`; send ISO timestamps), and
|
|
149
|
+
* `null`/`undefined` mean no expiry unless `allowNoExpiry` is `false`. Values
|
|
150
|
+
* beyond the tolerance past a limit are rejected with a readable message;
|
|
151
|
+
* values within it are clamped onto the limit, so a returned number always
|
|
152
|
+
* lies inside the plugin's inclusive bounds. The result is never below 1,
|
|
153
|
+
* because the plugin treats a falsy `expiresIn` as "not given". Pass
|
|
154
|
+
* `value ?? undefined` to `createApiKey`.
|
|
155
|
+
*
|
|
156
|
+
* For a key without `expiresIn` the plugin applies
|
|
157
|
+
* `keyExpiration.defaultExpiresIn`, so `null` only means "never expires"
|
|
158
|
+
* while that option is `null` (the plugin default).
|
|
159
|
+
*/
|
|
160
|
+
function resolveApiKeyExpiresIn(expiresAt, limits, options = {}) {
|
|
161
|
+
const messages = apiKeyLimitMessages(limits);
|
|
162
|
+
const tolerance = options.toleranceSeconds ??
|
|
163
|
+
exports.API_KEY_EXPIRY_TOLERANCE_SECONDS;
|
|
164
|
+
if (!Number.isFinite(tolerance) || tolerance < 0) {
|
|
165
|
+
throw new Error("resolveApiKeyExpiresIn: toleranceSeconds must be a finite number >= 0.");
|
|
166
|
+
}
|
|
167
|
+
if (expiresAt === null || expiresAt === undefined) {
|
|
168
|
+
return options.allowNoExpiry === false
|
|
169
|
+
? { message: messages.expiryRequired, ok: false }
|
|
170
|
+
: { ok: true, value: null };
|
|
171
|
+
}
|
|
172
|
+
const target = typeof expiresAt === "string"
|
|
173
|
+
? new Date(expiresAt).valueOf()
|
|
174
|
+
: Number.NaN;
|
|
175
|
+
if (!Number.isFinite(target)) {
|
|
176
|
+
return { message: messages.expiryInvalid, ok: false };
|
|
177
|
+
}
|
|
178
|
+
const seconds = Math.floor((target - referenceTime(options.now)) / 1000);
|
|
179
|
+
// The slack only ever applies above "in the future": a past expiry is never
|
|
180
|
+
// clamped into a valid one, whatever the configured minimum.
|
|
181
|
+
const minSeconds = (limits.minExpiresInDays ?? 0) * exports.API_KEY_SECONDS_PER_DAY;
|
|
182
|
+
if (seconds < Math.max(1, minSeconds - tolerance)) {
|
|
183
|
+
return { message: messages.expiryTooSoon, ok: false };
|
|
184
|
+
}
|
|
185
|
+
if (limits.maxExpiresInDays !== undefined) {
|
|
186
|
+
const maxSeconds = limits.maxExpiresInDays * exports.API_KEY_SECONDS_PER_DAY;
|
|
187
|
+
if (seconds > maxSeconds + tolerance) {
|
|
188
|
+
return { message: messages.expiryTooLate, ok: false };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const lower = Math.max(1, Math.ceil(minSeconds));
|
|
192
|
+
const upper = limits.maxExpiresInDays === undefined
|
|
193
|
+
? Number.POSITIVE_INFINITY
|
|
194
|
+
: Math.floor(limits.maxExpiresInDays * exports.API_KEY_SECONDS_PER_DAY);
|
|
195
|
+
if (upper < lower) {
|
|
196
|
+
// A sub-second maximum cannot express any expiry the plugin accepts.
|
|
197
|
+
return { message: messages.expiryTooLate, ok: false };
|
|
198
|
+
}
|
|
199
|
+
return { ok: true, value: Math.min(Math.max(seconds, lower), upper) };
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Plugin rejection codes a user can correct, mapped to message keys. Local
|
|
203
|
+
* validation with the same limits should make these unreachable; mapping them
|
|
204
|
+
* keeps configuration drift from showing a raw library message.
|
|
205
|
+
*/
|
|
206
|
+
const BETTER_AUTH_INPUT_ERROR_MESSAGE_KEYS = new Map([
|
|
207
|
+
["EXPIRES_IN_IS_TOO_SMALL", "expiryTooSoon"],
|
|
208
|
+
["EXPIRES_IN_IS_TOO_LARGE", "expiryTooLate"],
|
|
209
|
+
["INVALID_NAME_LENGTH", "nameLength"],
|
|
210
|
+
["NAME_REQUIRED", "nameLength"],
|
|
211
|
+
]);
|
|
212
|
+
/**
|
|
213
|
+
* Maps a correctable Better Auth api-key plugin rejection to the same message
|
|
214
|
+
* local validation would show, or returns `null` for anything else.
|
|
215
|
+
*
|
|
216
|
+
* Structural, like Better Auth's own `isAPIError`: it reads `error.body.code`
|
|
217
|
+
* from an error named `APIError` without importing Better Auth. Every other
|
|
218
|
+
* error, including other plugin codes, returns `null` and should be rethrown
|
|
219
|
+
* unchanged.
|
|
220
|
+
*/
|
|
221
|
+
function betterAuthApiKeyInputErrorMessage(error, limits) {
|
|
222
|
+
assertCompleteLimits(limits);
|
|
223
|
+
if (!error || typeof error !== "object" ||
|
|
224
|
+
error.name !== "APIError") {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const body = error.body;
|
|
228
|
+
if (!body || typeof body !== "object")
|
|
229
|
+
return null;
|
|
230
|
+
const code = body.code;
|
|
231
|
+
if (typeof code !== "string")
|
|
232
|
+
return null;
|
|
233
|
+
const key = BETTER_AUTH_INPUT_ERROR_MESSAGE_KEYS.get(code);
|
|
234
|
+
return key ? apiKeyLimitMessages(limits)[key] : null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Returns the Better Auth api-key plugin options that enforce `limits`.
|
|
238
|
+
*
|
|
239
|
+
* Merge `keyExpiration` with any other expiration options the app sets, for
|
|
240
|
+
* example `keyExpiration: { ...options.keyExpiration, defaultExpiresIn: null }`.
|
|
241
|
+
* It deliberately leaves `defaultExpiresIn` alone: keep it `null` (the plugin
|
|
242
|
+
* default) when "Never" should mean a key that never expires.
|
|
243
|
+
*/
|
|
244
|
+
function betterAuthApiKeyLimitOptions(limits) {
|
|
245
|
+
assertCompleteLimits(limits);
|
|
246
|
+
return {
|
|
247
|
+
keyExpiration: {
|
|
248
|
+
maxExpiresIn: limits.maxExpiresInDays,
|
|
249
|
+
minExpiresIn: limits.minExpiresInDays,
|
|
250
|
+
},
|
|
251
|
+
maximumNameLength: limits.maxNameLength,
|
|
252
|
+
minimumNameLength: limits.minNameLength,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import "../../_dnt.polyfills.js";
|
|
2
2
|
export * from "./authorize.js";
|
|
3
|
+
export * from "./betterAuth.js";
|
|
3
4
|
export * from "./country.js";
|
|
4
5
|
export * from "./credentials.js";
|
|
5
6
|
export * from "./fingerprint.js";
|
|
7
|
+
export * from "./lifecycle.js";
|
|
8
|
+
export * from "./limits.js";
|
|
9
|
+
export * from "./permissions.js";
|
|
6
10
|
export * from "./policy.js";
|
|
7
11
|
export * from "./retention.js";
|
|
8
12
|
export * from "./types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/mod.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/mod.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
|
@@ -16,9 +16,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
require("../../_dnt.polyfills.js");
|
|
18
18
|
__exportStar(require("./authorize.js"), exports);
|
|
19
|
+
__exportStar(require("./betterAuth.js"), exports);
|
|
19
20
|
__exportStar(require("./country.js"), exports);
|
|
20
21
|
__exportStar(require("./credentials.js"), exports);
|
|
21
22
|
__exportStar(require("./fingerprint.js"), exports);
|
|
23
|
+
__exportStar(require("./lifecycle.js"), exports);
|
|
24
|
+
__exportStar(require("./limits.js"), exports);
|
|
25
|
+
__exportStar(require("./permissions.js"), exports);
|
|
22
26
|
__exportStar(require("./policy.js"), exports);
|
|
23
27
|
__exportStar(require("./retention.js"), exports);
|
|
24
28
|
__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ApiKeyScopeDefinitions, DefinedApiKeyScopes } from "./policy.js";
|
|
2
|
+
import type { ApiKeyPermission } from "./types.js";
|
|
3
|
+
/** Native Better Auth api-key permissions: resource name to action list. */
|
|
4
|
+
export type ApiKeyPermissionRecord = Record<string, string[]>;
|
|
5
|
+
type ScopeId<TDefinitions extends ApiKeyScopeDefinitions> = Extract<keyof TDefinitions, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Reports whether decoded api-key permissions grant exactly `permission`.
|
|
8
|
+
*
|
|
9
|
+
* `decoded` must already be decoded: Better Auth's `verifyApiKey` result, or a
|
|
10
|
+
* raw column passed through `decodeStoredApiKeyPermissions`. Strings are never
|
|
11
|
+
* decoded here, because Better Auth has already decoded the column once; a
|
|
12
|
+
* string at this point means double-encoded storage, which Better Auth's own
|
|
13
|
+
* check denies too.
|
|
14
|
+
*
|
|
15
|
+
* Fails closed: anything but a plain or null-prototype object, inherited
|
|
16
|
+
* properties, non-array action lists, and non-identical action strings never
|
|
17
|
+
* match. This is stricter than Better Auth's check, which reads inherited
|
|
18
|
+
* properties and would substring-match an action list stored as a string.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasApiKeyPermission(decoded: unknown, permission: ApiKeyPermission): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Decodes a raw stored `apikey.permissions` value exactly once.
|
|
23
|
+
*
|
|
24
|
+
* Better Auth stores permissions as JSON text. A string is parsed once, and
|
|
25
|
+
* malformed JSON yields `null`; any other value is returned unchanged so a
|
|
26
|
+
* database driver that already decoded the column still works. JSON that
|
|
27
|
+
* decodes to another string, i.e. double-encoded storage, is returned as that
|
|
28
|
+
* string and therefore grants nothing.
|
|
29
|
+
*/
|
|
30
|
+
export declare function decodeStoredApiKeyPermissions(stored: unknown): unknown;
|
|
31
|
+
/**
|
|
32
|
+
* Converts scope IDs into the native permissions to store on a new key.
|
|
33
|
+
*
|
|
34
|
+
* Actions for scopes that share a resource are merged rather than replaced,
|
|
35
|
+
* and duplicates are removed. An ID that is not an own registry entry throws:
|
|
36
|
+
* validate untrusted input against the registry first.
|
|
37
|
+
*/
|
|
38
|
+
export declare function apiKeyPermissionsFromScopeIds<TDefinitions extends ApiKeyScopeDefinitions>(registry: DefinedApiKeyScopes<TDefinitions>, scopeIds: readonly string[]): ApiKeyPermissionRecord;
|
|
39
|
+
/**
|
|
40
|
+
* Lists the registry scope IDs that decoded permissions grant exactly, in
|
|
41
|
+
* registry order. Grants outside the registry are ignored.
|
|
42
|
+
*/
|
|
43
|
+
export declare function apiKeyScopeIdsFromPermissions<TDefinitions extends ApiKeyScopeDefinitions>(registry: DefinedApiKeyScopes<TDefinitions>, decoded: unknown): ScopeId<TDefinitions>[];
|
|
44
|
+
/**
|
|
45
|
+
* Builds the explicit principal permissions for a verified key: the registry
|
|
46
|
+
* permissions that decoded permissions grant exactly, in registry order.
|
|
47
|
+
*/
|
|
48
|
+
export declare function apiKeyPrincipalPermissions<TDefinitions extends ApiKeyScopeDefinitions>(registry: DefinedApiKeyScopes<TDefinitions>, decoded: unknown): ApiKeyPermission[];
|
|
49
|
+
/**
|
|
50
|
+
* Flattens every exact grant in decoded permissions, for verifiers without a
|
|
51
|
+
* registry. Non-plain objects, inherited properties, non-array action lists,
|
|
52
|
+
* and non-string or empty actions are skipped.
|
|
53
|
+
*/
|
|
54
|
+
export declare function apiKeyGrantedPermissions(decoded: unknown): ApiKeyPermission[];
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/src/apiKeys/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,4EAA4E;AAC5E,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAE9D,KAAK,OAAO,CAAC,YAAY,SAAS,sBAAsB,IAAI,OAAO,CACjE,MAAM,YAAY,EAClB,MAAM,CACP,CAAC;AAaF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,gBAAgB,GAC3B,OAAO,CAST;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOtE;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,SAAS,sBAAsB,EAE3C,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAC3C,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,sBAAsB,CAiBxB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,SAAS,sBAAsB,EAE3C,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAC3C,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,YAAY,CAAC,EAAE,CAIzB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,SAAS,sBAAsB,EAE3C,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,EAC3C,OAAO,EAAE,OAAO,GACf,gBAAgB,EAAE,CAOpB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAe7E"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasApiKeyPermission = hasApiKeyPermission;
|
|
4
|
+
exports.decodeStoredApiKeyPermissions = decodeStoredApiKeyPermissions;
|
|
5
|
+
exports.apiKeyPermissionsFromScopeIds = apiKeyPermissionsFromScopeIds;
|
|
6
|
+
exports.apiKeyScopeIdsFromPermissions = apiKeyScopeIdsFromPermissions;
|
|
7
|
+
exports.apiKeyPrincipalPermissions = apiKeyPrincipalPermissions;
|
|
8
|
+
exports.apiKeyGrantedPermissions = apiKeyGrantedPermissions;
|
|
9
|
+
const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
10
|
+
/** Returns `value` only when it is a plain (JSON-shaped) object. */
|
|
11
|
+
function asPermissionRecord(value) {
|
|
12
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
13
|
+
return null;
|
|
14
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
16
|
+
return null;
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reports whether decoded api-key permissions grant exactly `permission`.
|
|
21
|
+
*
|
|
22
|
+
* `decoded` must already be decoded: Better Auth's `verifyApiKey` result, or a
|
|
23
|
+
* raw column passed through `decodeStoredApiKeyPermissions`. Strings are never
|
|
24
|
+
* decoded here, because Better Auth has already decoded the column once; a
|
|
25
|
+
* string at this point means double-encoded storage, which Better Auth's own
|
|
26
|
+
* check denies too.
|
|
27
|
+
*
|
|
28
|
+
* Fails closed: anything but a plain or null-prototype object, inherited
|
|
29
|
+
* properties, non-array action lists, and non-identical action strings never
|
|
30
|
+
* match. This is stricter than Better Auth's check, which reads inherited
|
|
31
|
+
* properties and would substring-match an action list stored as a string.
|
|
32
|
+
*/
|
|
33
|
+
function hasApiKeyPermission(decoded, permission) {
|
|
34
|
+
if (!permission || typeof permission !== "object")
|
|
35
|
+
return false;
|
|
36
|
+
const { action, resource } = permission;
|
|
37
|
+
if (typeof resource !== "string" || typeof action !== "string")
|
|
38
|
+
return false;
|
|
39
|
+
if (!resource || !action)
|
|
40
|
+
return false;
|
|
41
|
+
const record = asPermissionRecord(decoded);
|
|
42
|
+
if (!record || !hasOwn(record, resource))
|
|
43
|
+
return false;
|
|
44
|
+
const actions = record[resource];
|
|
45
|
+
return Array.isArray(actions) && actions.includes(action);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Decodes a raw stored `apikey.permissions` value exactly once.
|
|
49
|
+
*
|
|
50
|
+
* Better Auth stores permissions as JSON text. A string is parsed once, and
|
|
51
|
+
* malformed JSON yields `null`; any other value is returned unchanged so a
|
|
52
|
+
* database driver that already decoded the column still works. JSON that
|
|
53
|
+
* decodes to another string, i.e. double-encoded storage, is returned as that
|
|
54
|
+
* string and therefore grants nothing.
|
|
55
|
+
*/
|
|
56
|
+
function decodeStoredApiKeyPermissions(stored) {
|
|
57
|
+
if (typeof stored !== "string")
|
|
58
|
+
return stored;
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(stored);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Converts scope IDs into the native permissions to store on a new key.
|
|
68
|
+
*
|
|
69
|
+
* Actions for scopes that share a resource are merged rather than replaced,
|
|
70
|
+
* and duplicates are removed. An ID that is not an own registry entry throws:
|
|
71
|
+
* validate untrusted input against the registry first.
|
|
72
|
+
*/
|
|
73
|
+
function apiKeyPermissionsFromScopeIds(registry, scopeIds) {
|
|
74
|
+
if (!Array.isArray(scopeIds)) {
|
|
75
|
+
throw new Error("API-key scope IDs must be an array.");
|
|
76
|
+
}
|
|
77
|
+
const actionsByResource = new Map();
|
|
78
|
+
for (const scopeId of scopeIds) {
|
|
79
|
+
if (typeof scopeId !== "string" || !hasOwn(registry.byId, scopeId)) {
|
|
80
|
+
throw new Error(`Unknown API-key scope "${String(scopeId)}".`);
|
|
81
|
+
}
|
|
82
|
+
const { action, resource } = registry.byId[scopeId].permission;
|
|
83
|
+
const actions = actionsByResource.get(resource) ?? [];
|
|
84
|
+
if (!actions.includes(action))
|
|
85
|
+
actions.push(action);
|
|
86
|
+
actionsByResource.set(resource, actions);
|
|
87
|
+
}
|
|
88
|
+
// `Object.fromEntries` defines own data properties, so a resource such as
|
|
89
|
+
// "__proto__" cannot change the result's prototype.
|
|
90
|
+
return Object.fromEntries(actionsByResource);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Lists the registry scope IDs that decoded permissions grant exactly, in
|
|
94
|
+
* registry order. Grants outside the registry are ignored.
|
|
95
|
+
*/
|
|
96
|
+
function apiKeyScopeIdsFromPermissions(registry, decoded) {
|
|
97
|
+
return registry.list
|
|
98
|
+
.filter((scope) => hasApiKeyPermission(decoded, scope.permission))
|
|
99
|
+
.map((scope) => scope.id);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Builds the explicit principal permissions for a verified key: the registry
|
|
103
|
+
* permissions that decoded permissions grant exactly, in registry order.
|
|
104
|
+
*/
|
|
105
|
+
function apiKeyPrincipalPermissions(registry, decoded) {
|
|
106
|
+
return registry.list
|
|
107
|
+
.filter((scope) => hasApiKeyPermission(decoded, scope.permission))
|
|
108
|
+
.map((scope) => ({
|
|
109
|
+
action: scope.permission.action,
|
|
110
|
+
resource: scope.permission.resource,
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Flattens every exact grant in decoded permissions, for verifiers without a
|
|
115
|
+
* registry. Non-plain objects, inherited properties, non-array action lists,
|
|
116
|
+
* and non-string or empty actions are skipped.
|
|
117
|
+
*/
|
|
118
|
+
function apiKeyGrantedPermissions(decoded) {
|
|
119
|
+
const record = asPermissionRecord(decoded);
|
|
120
|
+
if (!record)
|
|
121
|
+
return [];
|
|
122
|
+
const permissions = [];
|
|
123
|
+
for (const resource of Object.keys(record)) {
|
|
124
|
+
const actions = record[resource];
|
|
125
|
+
if (!resource || !Array.isArray(actions))
|
|
126
|
+
continue;
|
|
127
|
+
const seen = new Set();
|
|
128
|
+
for (const action of actions) {
|
|
129
|
+
if (typeof action !== "string" || !action || seen.has(action))
|
|
130
|
+
continue;
|
|
131
|
+
seen.add(action);
|
|
132
|
+
permissions.push({ action, resource });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return permissions;
|
|
136
|
+
}
|
|
@@ -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;AAC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,gBAAgB,GACxB,OAAO,GACP,MAAM,GACN,CAAC,CACD,OAAO,EAAE,uBAAuB,KAC7B,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAEzD,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,CAC3B,YAAY,SAAS,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"}
|
|
@@ -69,7 +69,9 @@ function assertPolicyRules(registry, rules) {
|
|
|
69
69
|
* Creates an exact-match, default-deny policy from a typed scope registry.
|
|
70
70
|
*
|
|
71
71
|
* The verifier remains responsible for proving that the key owns the requested
|
|
72
|
-
* native permission
|
|
72
|
+
* native permission; for Better Auth, `createBetterAuthApiKeyVerifier` checks
|
|
73
|
+
* the decoded grants itself, because the plugin reports a missing permission
|
|
74
|
+
* as an unknown key. Dynamic rules are for fresh app-owned checks such as
|
|
73
75
|
* current role membership; thrown errors intentionally reach Loom's existing
|
|
74
76
|
* `policy_error` handling.
|
|
75
77
|
*/
|
|
@@ -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,M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