@lunora/auth 1.0.0-alpha.2 → 1.0.0-alpha.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/LICENSE.md +38 -0
  2. package/README.md +99 -10
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/adapter.d.mts +4 -43
  5. package/dist/adapter.d.ts +4 -43
  6. package/dist/adapter.mjs +1 -47
  7. package/dist/audit.d.mts +142 -0
  8. package/dist/audit.d.ts +142 -0
  9. package/dist/audit.mjs +12 -0
  10. package/dist/cimd-node.d.mts +1 -0
  11. package/dist/cimd-node.d.ts +1 -0
  12. package/dist/cimd-node.mjs +1 -0
  13. package/dist/cimd-workers.d.mts +32 -0
  14. package/dist/cimd-workers.d.ts +32 -0
  15. package/dist/cimd-workers.mjs +1 -0
  16. package/dist/email-guard.d.mts +127 -0
  17. package/dist/email-guard.d.ts +127 -0
  18. package/dist/email-guard.mjs +1 -0
  19. package/dist/index.d.mts +935 -147
  20. package/dist/index.d.ts +935 -147
  21. package/dist/index.mjs +1 -12
  22. package/dist/middleware.d.mts +167 -156
  23. package/dist/middleware.d.ts +167 -156
  24. package/dist/middleware.mjs +1 -53
  25. package/dist/packem_shared/AUTH_DO_AUDIT_PATH-CptaQ6ZX.mjs +1 -0
  26. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DneiLGpv.mjs +1 -0
  27. package/dist/packem_shared/LunoraAuthAdminError-uhKG1MgQ.mjs +1 -0
  28. package/dist/packem_shared/adapter-CG0Yv85f.mjs +2 -0
  29. package/dist/packem_shared/adapter.d-CElAPJ1U.d.ts +88 -0
  30. package/dist/packem_shared/adapter.d-CaPwF2v3.d.mts +88 -0
  31. package/dist/packem_shared/auth-do-B2X2lboC.mjs +1 -0
  32. package/dist/packem_shared/authAuditHook-DPTKdjBe.mjs +1 -0
  33. package/dist/packem_shared/authDiscoveryPaths-B14lM14u.mjs +1 -0
  34. package/dist/packem_shared/authDoColumnAdditions-UwF3Rl41.mjs +1 -0
  35. package/dist/packem_shared/compileMigrationsSql-BiYsLz91.mjs +1 -0
  36. package/dist/packem_shared/create-auth.d-D1CKOFWc.d.mts +142 -0
  37. package/dist/packem_shared/create-auth.d-D1CKOFWc.d.ts +142 -0
  38. package/dist/packem_shared/createAuth-BdVltKyf.mjs +1 -0
  39. package/dist/packem_shared/createDoAuthWiring-cqHnqjyh.mjs +1 -0
  40. package/dist/packem_shared/createLunoraAuthClient-DRcFNwp9.mjs +1 -0
  41. package/dist/packem_shared/createSignUpInvitation-DHZL9fNl.mjs +1 -0
  42. package/dist/packem_shared/emailGateDatabaseHooks-CAygR3iq.mjs +1 -0
  43. package/dist/packem_shared/invite-only.d-CsPJWAwM.d.ts +126 -0
  44. package/dist/packem_shared/invite-only.d-DKyHHkkQ.d.mts +126 -0
  45. package/dist/packem_shared/legacyIssuerCleanupStatements-D9Kf8OD1.mjs +1 -0
  46. package/dist/packem_shared/mcp-CgX1hTOv.mjs +1 -0
  47. package/dist/packem_shared/on-cloudflare-edge-Dx6gFjBO.mjs +1 -0
  48. package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +1 -0
  49. package/dist/packem_shared/sessionPresets-C867Mlo4.mjs +1 -0
  50. package/dist/packem_shared/sql-store-CYa4HJsO.mjs +1 -0
  51. package/dist/packem_shared/uiConfig-B8pN6pks.mjs +1 -0
  52. package/dist/plugins-client.d.mts +250 -1
  53. package/dist/plugins-client.d.ts +250 -1
  54. package/dist/plugins-client.mjs +1 -2
  55. package/dist/plugins-enterprise-client.d.mts +13 -0
  56. package/dist/plugins-enterprise-client.d.ts +13 -0
  57. package/dist/plugins-enterprise-client.mjs +1 -0
  58. package/dist/plugins-enterprise.d.mts +1668 -0
  59. package/dist/plugins-enterprise.d.ts +1668 -0
  60. package/dist/plugins-enterprise.mjs +1 -0
  61. package/dist/plugins.d.mts +167 -2
  62. package/dist/plugins.d.ts +167 -2
  63. package/dist/plugins.mjs +1 -22
  64. package/dist/schema.d.mts +39 -39
  65. package/dist/schema.d.ts +39 -39
  66. package/dist/schema.mjs +1 -62
  67. package/dist/sql-store.d.mts +28 -28
  68. package/dist/sql-store.d.ts +28 -28
  69. package/dist/sql-store.mjs +1 -162
  70. package/dist/store.d.mts +67 -31
  71. package/dist/store.d.ts +67 -31
  72. package/dist/store.mjs +1 -170
  73. package/dist/turnstile-middleware.d.mts +73 -55
  74. package/dist/turnstile-middleware.d.ts +73 -55
  75. package/dist/turnstile-middleware.mjs +1 -45
  76. package/dist/turnstile.d.mts +42 -59
  77. package/dist/turnstile.d.ts +42 -59
  78. package/dist/turnstile.mjs +1 -61
  79. package/package.json +49 -6
  80. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DjcUWEQl.mjs +0 -11
  81. package/dist/packem_shared/LunoraAuthAdminError-BxrfEeA_.mjs +0 -249
  82. package/dist/packem_shared/compileMigrationsSql-wZH3oXDu.mjs +0 -28
  83. package/dist/packem_shared/create-auth.d-M36jwG_Y.d.mts +0 -58
  84. package/dist/packem_shared/create-auth.d-M36jwG_Y.d.ts +0 -58
  85. package/dist/packem_shared/createAuth-B-tvsvQU.mjs +0 -56
  86. package/dist/packem_shared/sessionPresets-B95rXrd8.mjs +0 -35
@@ -1,43 +1,4 @@
1
- import { createAdapterFactory } from 'better-auth/adapters';
2
- import { d1Executor } from "./sql-store.mjs";
3
- import { AuthStore } from "./store.mjs";
4
- /**
5
- * A better-auth database adapter backed by an {@link AuthStore} — the bridge
6
- * that routes better-auth's reads and writes through Lunora's data layer
7
- * instead of better-auth's built-in D1/Kysely adapter. Pass the result as
8
- * `createAuth({ database: lunoraAuthAdapter(store) })`; better-auth's
9
- * `createAdapterFactory` handles id generation, default values, field-name
10
- * mapping and output shaping, so this only translates the cleaned CRUD calls
11
- * onto the store.
12
- *
13
- * ```ts
14
- * const auth = createAuth({
15
- * secret: env.AUTH_SECRET,
16
- * emailAndPassword: { enabled: true },
17
- * database: lunoraAuthAdapter(lunoraStore), // lunoraStore writes via ctx.db
18
- * });
19
- * ```
20
- *
21
- * Scope: the {@link AuthStore} interface is single-table CRUD. better-auth's
22
- * relational `join` reads (an advanced opt-in) are not handled — pair the
23
- * adapter with `disableJoins` or let better-auth fall back to per-table reads.
24
- */
25
- declare const lunoraAuthAdapter: (store: AuthStore) => ReturnType<typeof createAdapterFactory>;
26
- /**
27
- * One-liner for the common case: a better-auth `database` backed by a Cloudflare
28
- * D1 binding, via Lunora's SQL store — equivalent to
29
- * `lunoraAuthAdapter(createSqlAuthStore(d1Executor(d1)))`.
30
- *
31
- * Prefer this over passing the raw `env.DB` as `database`. With raw D1,
32
- * better-auth resolves its Kysely adapter through a runtime `await import(...)`
33
- * inside `auth.$context`, and that dynamic import never settles under
34
- * `@cloudflare/vite-plugin`'s worker runner — so it hangs *every* auth request
35
- * in `pnpm dev` (a standalone `wrangler dev` or a deployed worker bundle it
36
- * up-front, so they're unaffected — which makes the hang baffling to debug).
37
- * This explicit adapter skips that import entirely, so dev and prod behave the
38
- * same. The migration instance is the one exception — it wants raw `env.DB` so
39
- * `ensureMigrated`'s Kysely migrator can create the tables (its `$context` is
40
- * never resolved, so the hang doesn't apply there).
41
- */
42
- declare const lunoraD1Adapter: (d1: Parameters<typeof d1Executor>[0]) => ReturnType<typeof lunoraAuthAdapter>;
43
- export { lunoraAuthAdapter, lunoraD1Adapter };
1
+ import 'better-auth/adapters';
2
+ export { l as lunoraAuthAdapter, a as lunoraD1Adapter, b as lunoraDoAdapter } from "./packem_shared/adapter.d-CaPwF2v3.mjs";
3
+ import "./sql-store.mjs";
4
+ import "./store.mjs";
package/dist/adapter.d.ts CHANGED
@@ -1,43 +1,4 @@
1
- import { createAdapterFactory } from 'better-auth/adapters';
2
- import { d1Executor } from "./sql-store.js";
3
- import { AuthStore } from "./store.js";
4
- /**
5
- * A better-auth database adapter backed by an {@link AuthStore} — the bridge
6
- * that routes better-auth's reads and writes through Lunora's data layer
7
- * instead of better-auth's built-in D1/Kysely adapter. Pass the result as
8
- * `createAuth({ database: lunoraAuthAdapter(store) })`; better-auth's
9
- * `createAdapterFactory` handles id generation, default values, field-name
10
- * mapping and output shaping, so this only translates the cleaned CRUD calls
11
- * onto the store.
12
- *
13
- * ```ts
14
- * const auth = createAuth({
15
- * secret: env.AUTH_SECRET,
16
- * emailAndPassword: { enabled: true },
17
- * database: lunoraAuthAdapter(lunoraStore), // lunoraStore writes via ctx.db
18
- * });
19
- * ```
20
- *
21
- * Scope: the {@link AuthStore} interface is single-table CRUD. better-auth's
22
- * relational `join` reads (an advanced opt-in) are not handled — pair the
23
- * adapter with `disableJoins` or let better-auth fall back to per-table reads.
24
- */
25
- declare const lunoraAuthAdapter: (store: AuthStore) => ReturnType<typeof createAdapterFactory>;
26
- /**
27
- * One-liner for the common case: a better-auth `database` backed by a Cloudflare
28
- * D1 binding, via Lunora's SQL store — equivalent to
29
- * `lunoraAuthAdapter(createSqlAuthStore(d1Executor(d1)))`.
30
- *
31
- * Prefer this over passing the raw `env.DB` as `database`. With raw D1,
32
- * better-auth resolves its Kysely adapter through a runtime `await import(...)`
33
- * inside `auth.$context`, and that dynamic import never settles under
34
- * `@cloudflare/vite-plugin`'s worker runner — so it hangs *every* auth request
35
- * in `pnpm dev` (a standalone `wrangler dev` or a deployed worker bundle it
36
- * up-front, so they're unaffected — which makes the hang baffling to debug).
37
- * This explicit adapter skips that import entirely, so dev and prod behave the
38
- * same. The migration instance is the one exception — it wants raw `env.DB` so
39
- * `ensureMigrated`'s Kysely migrator can create the tables (its `$context` is
40
- * never resolved, so the hang doesn't apply there).
41
- */
42
- declare const lunoraD1Adapter: (d1: Parameters<typeof d1Executor>[0]) => ReturnType<typeof lunoraAuthAdapter>;
43
- export { lunoraAuthAdapter, lunoraD1Adapter };
1
+ import 'better-auth/adapters';
2
+ export { l as lunoraAuthAdapter, a as lunoraD1Adapter, b as lunoraDoAdapter } from "./packem_shared/adapter.d-CElAPJ1U.js";
3
+ import "./sql-store.js";
4
+ import "./store.js";
package/dist/adapter.mjs CHANGED
@@ -1,47 +1 @@
1
- import { createAdapterFactory } from 'better-auth/adapters';
2
- import { createSqlAuthStore, d1Executor } from './sql-store.mjs';
3
-
4
- const asRow = (row) => row;
5
- const asRowOrNull = (row) => row ?? null;
6
- const asRows = (rows) => rows;
7
- const lunoraAuthAdapter = (store) => createAdapterFactory({
8
- adapter: () => {
9
- return {
10
- consumeOne: async ({ model, where }) => asRowOrNull(await store.consumeOne(model, where)),
11
- count: async ({ model, where }) => store.count(model, where ?? []),
12
- create: async ({ data, model }) => asRow(await store.create(model, data)),
13
- delete: async ({ model, where }) => {
14
- await store.remove(model, where);
15
- },
16
- deleteMany: async ({ model, where }) => store.remove(model, where),
17
- findMany: async ({ limit, model, offset, sortBy, where }) => asRows(await store.read(model, { limit, offset, sortBy, where: where ?? [] })),
18
- findOne: async ({ model, where }) => {
19
- const [row] = await store.read(model, { limit: 1, where });
20
- return asRowOrNull(row);
21
- },
22
- update: async ({ model, update, where }) => {
23
- const [row] = await store.update(model, where, update);
24
- return asRowOrNull(row);
25
- },
26
- updateMany: async ({ model, update, where }) => {
27
- const updated = await store.update(model, where, update);
28
- return updated.length;
29
- }
30
- };
31
- },
32
- config: {
33
- adapterId: "lunora",
34
- adapterName: "Lunora Adapter",
35
- // Conservative flags so the adapter is store-agnostic: better-auth
36
- // serializes dates/booleans/json to primitives (string/number) before a
37
- // write and parses them back after a read, so a store — in-memory or
38
- // SQL — only ever handles primitives, never schema-aware codecs.
39
- supportsBooleans: false,
40
- supportsDates: false,
41
- supportsJSON: false,
42
- supportsNumericIds: false
43
- }
44
- });
45
- const lunoraD1Adapter = (d1) => lunoraAuthAdapter(createSqlAuthStore(d1Executor(d1)));
46
-
47
- export { lunoraAuthAdapter, lunoraD1Adapter };
1
+ import{l as t,a as p,b as e}from"./packem_shared/adapter-CG0Yv85f.mjs";import"./packem_shared/sql-store-CYa4HJsO.mjs";export{t as lunoraAuthAdapter,p as lunoraD1Adapter,e as lunoraDoAdapter};
@@ -0,0 +1,142 @@
1
+ import { SqlExecutor } from "./sql-store.mjs";
2
+ import "./store.mjs";
3
+ import 'better-auth/adapters';
4
+ /** Reserved append-only table backing the Studio "Security / audit" page. Auto-hidden from the data browser by the `__lunora` prefix. */
5
+ declare const AUTH_AUDIT_TABLE = "__lunora_auth_audit__";
6
+ /**
7
+ * Well-known auth/security event types. A plain `string` is also accepted so
8
+ * plugins can record their own events without a union change — the union just
9
+ * gives autocomplete for the common ones.
10
+ */
11
+ type AuthAuditEvent = "account-link" | "account-unlink" | "email-verification" | "mfa-disable" | "mfa-enable" | "password-change" | "password-reset" | "session-revoke" | "sign-in" | "sign-in-initiated" | "sign-out" | "sign-up" | "token-refresh" | (string & {});
12
+ /** Whether the recorded operation succeeded or failed (e.g. a rejected sign-in). */
13
+ type AuthAuditOutcome = "failure" | "success";
14
+ /** One recorded auth/security event, in monotonic `seq` order. */
15
+ interface AuthAuditEntry {
16
+ /** Redaction is applied to `detail`, not this — the actor's email is intentional forensic data. Absent for anonymous/pre-auth events. */
17
+ actorEmail?: string;
18
+ /** The acting user's id, when known. */
19
+ actorId?: string;
20
+ /** JSON-decoded extra context, with secrets/PII redacted at write time; absent when none was recorded. */
21
+ detail?: Record<string, unknown>;
22
+ /** Auth event type, e.g. `sign-in` / `password-change`. */
23
+ event: string;
24
+ /** Client IP the event originated from, when resolvable. */
25
+ ip?: string;
26
+ /** Whether the operation succeeded or failed. */
27
+ outcome: AuthAuditOutcome;
28
+ /** Monotonic per-database cursor — strictly increasing, never reused. */
29
+ seq: number;
30
+ /**
31
+ * The identifier (email or username) a sign-in-family request ATTEMPTED,
32
+ * read from the request body. Present for both successful and failed
33
+ * attempts — unlike `actorEmail` (which requires an authenticated
34
+ * session), this is what lets a FAILED credential-stuffing attempt be
35
+ * grouped by target. Same redaction exemption as `actorEmail`: a
36
+ * top-level column, not a `detail` key, because `AUDIT_REDACT_RULES`
37
+ * scrubs email-shaped values inside `detail` regardless of key name —
38
+ * putting it there would erase exactly this datum. Length-capped to 320
39
+ * chars (RFC 5321) since it carries attacker-controlled request-body text.
40
+ */
41
+ targetEmail?: string;
42
+ /** Wall-clock millis when the event was recorded. */
43
+ ts: number;
44
+ /** Client User-Agent, when present on the request. */
45
+ userAgent?: string;
46
+ }
47
+ /** Fields accepted when appending one event; `seq` is assigned by the table. */
48
+ interface AppendAuthAuditEntry {
49
+ actorEmail?: string;
50
+ actorId?: string;
51
+ detail?: Record<string, unknown>;
52
+ event: string;
53
+ ip?: string;
54
+ outcome: AuthAuditOutcome;
55
+ /** See {@link AuthAuditEntry.targetEmail}. */
56
+ targetEmail?: string;
57
+ ts: number;
58
+ userAgent?: string;
59
+ }
60
+ /** Options for {@link appendAuthAuditEntry}. */
61
+ interface AppendAuthAuditOptions {
62
+ /**
63
+ * Redact secrets/PII in the `detail` payload before persisting. Defaults to
64
+ * `true`. Set `false` only for a trusted, pre-scrubbed payload.
65
+ */
66
+ redactDetail?: boolean;
67
+ /**
68
+ * Keep only the most recent `retention` rows (trimmed after each append),
69
+ * mirroring the admin audit log's bounded retention. Omit for an unbounded
70
+ * trail (the compliance default) — deliberately NOT capped at 1000.
71
+ */
72
+ retention?: number;
73
+ }
74
+ /** Options for {@link readAuthAuditLog}. */
75
+ interface ReadAuthAuditOptions {
76
+ /** Return only events for this actor id. */
77
+ actorId?: string;
78
+ /** Return only events of this type. */
79
+ event?: string;
80
+ /** Max rows to return, clamped to [1, 10000]. Defaults to 1000. */
81
+ limit?: number;
82
+ /**
83
+ * Return only events with `seq` strictly greater than this. Supplying it
84
+ * switches the page to oldest-first so the cursor walks forward; omit it for
85
+ * the newest-first feed.
86
+ */
87
+ sinceSeq?: number;
88
+ }
89
+ declare const ensureAuthAuditTable: (executor: SqlExecutor) => Promise<void>;
90
+ /**
91
+ * Append one auth event, redacting its `detail` payload (unless disabled) and —
92
+ * when `retention` is set — trimming the log back to the most recent rows.
93
+ * Creates the table first so callers needn't. Returns the redacted, persisted
94
+ * entry (sans `seq`) so an export tap can forward exactly what was stored.
95
+ */
96
+ declare const appendAuthAuditEntry: (executor: SqlExecutor, entry: AppendAuthAuditEntry, options?: AppendAuthAuditOptions) => Promise<AppendAuthAuditEntry>;
97
+ /**
98
+ * Read audit events, optionally filtered by `actorId` / `event` and paged past
99
+ * `sinceSeq`, up to `limit` (clamped to [1, 10000]). Parses each row's `detail`
100
+ * JSON back into an object. Creates the table first so reads on a never-audited
101
+ * database return `[]` instead of throwing.
102
+ *
103
+ * Ordering follows the cursor: **without** `sinceSeq` the page is newest-first
104
+ * (`seq DESC`) — the feed the studio's Security panel renders. **With**
105
+ * `sinceSeq` it is oldest-first (`seq ASC`), because a lower bound is a forward
106
+ * walk: a descending page above the bound would hand back the newest rows and
107
+ * leave everything between the cursor and them unreachable once the caller
108
+ * advanced past it.
109
+ *
110
+ * `limit` is NaN-safe: a non-finite/non-number value (e.g. a caller passing
111
+ * `Number.NaN`, or an upstream boundary that failed to reject one) falls back
112
+ * to {@link DEFAULT_READ_LIMIT} rather than reaching `Math.min`/`Math.max`,
113
+ * which both propagate `NaN` and would otherwise bind it as the SQL `LIMIT`
114
+ * parameter. This is the library-level fix; `#readAudit` (`./auth-do`) also
115
+ * rejects a non-numeric `limit` at the boundary with a 400 — this clamp is the
116
+ * safety net for every OTHER caller of this function too.
117
+ */
118
+ declare const readAuthAuditLog: (executor: SqlExecutor, options?: ReadAuthAuditOptions) => Promise<AuthAuditEntry[]>;
119
+ /**
120
+ * The auth/security audit read plane the runtime's `authAuditReader` option
121
+ * accepts — a structurally-compatible `{ read }` object the worker calls behind
122
+ * its admin gate to back the studio's "Security / audit" page
123
+ * (`__lunora_admin__:getAuthAuditLog`).
124
+ */
125
+ interface AuthAuditReader {
126
+ read: (options: ReadAuthAuditOptions) => Promise<AuthAuditEntry[]>;
127
+ }
128
+ /**
129
+ * Build the reader the runtime's `authAuditReader` option accepts, closing over
130
+ * the auth D1 `executor` (`d1Executor(env.DB)`) so an admin caller reads the same
131
+ * `__lunora_auth_audit__` table the hook writes. Filters/paging pass straight
132
+ * through to {@link readAuthAuditLog} (which clamps `limit`).
133
+ *
134
+ * ```ts
135
+ * export default createWorker({
136
+ * authAuditReader: createAuthAuditReader(d1Executor(env.DB)),
137
+ * // …
138
+ * });
139
+ * ```
140
+ */
141
+ declare const createAuthAuditReader: (executor: SqlExecutor) => AuthAuditReader;
142
+ export { AUTH_AUDIT_TABLE, type AppendAuthAuditEntry, type AppendAuthAuditOptions, type AuthAuditEntry, type AuthAuditEvent, type AuthAuditOutcome, type AuthAuditReader, type ReadAuthAuditOptions, appendAuthAuditEntry, createAuthAuditReader, ensureAuthAuditTable, readAuthAuditLog };
@@ -0,0 +1,142 @@
1
+ import { SqlExecutor } from "./sql-store.js";
2
+ import "./store.js";
3
+ import 'better-auth/adapters';
4
+ /** Reserved append-only table backing the Studio "Security / audit" page. Auto-hidden from the data browser by the `__lunora` prefix. */
5
+ declare const AUTH_AUDIT_TABLE = "__lunora_auth_audit__";
6
+ /**
7
+ * Well-known auth/security event types. A plain `string` is also accepted so
8
+ * plugins can record their own events without a union change — the union just
9
+ * gives autocomplete for the common ones.
10
+ */
11
+ type AuthAuditEvent = "account-link" | "account-unlink" | "email-verification" | "mfa-disable" | "mfa-enable" | "password-change" | "password-reset" | "session-revoke" | "sign-in" | "sign-in-initiated" | "sign-out" | "sign-up" | "token-refresh" | (string & {});
12
+ /** Whether the recorded operation succeeded or failed (e.g. a rejected sign-in). */
13
+ type AuthAuditOutcome = "failure" | "success";
14
+ /** One recorded auth/security event, in monotonic `seq` order. */
15
+ interface AuthAuditEntry {
16
+ /** Redaction is applied to `detail`, not this — the actor's email is intentional forensic data. Absent for anonymous/pre-auth events. */
17
+ actorEmail?: string;
18
+ /** The acting user's id, when known. */
19
+ actorId?: string;
20
+ /** JSON-decoded extra context, with secrets/PII redacted at write time; absent when none was recorded. */
21
+ detail?: Record<string, unknown>;
22
+ /** Auth event type, e.g. `sign-in` / `password-change`. */
23
+ event: string;
24
+ /** Client IP the event originated from, when resolvable. */
25
+ ip?: string;
26
+ /** Whether the operation succeeded or failed. */
27
+ outcome: AuthAuditOutcome;
28
+ /** Monotonic per-database cursor — strictly increasing, never reused. */
29
+ seq: number;
30
+ /**
31
+ * The identifier (email or username) a sign-in-family request ATTEMPTED,
32
+ * read from the request body. Present for both successful and failed
33
+ * attempts — unlike `actorEmail` (which requires an authenticated
34
+ * session), this is what lets a FAILED credential-stuffing attempt be
35
+ * grouped by target. Same redaction exemption as `actorEmail`: a
36
+ * top-level column, not a `detail` key, because `AUDIT_REDACT_RULES`
37
+ * scrubs email-shaped values inside `detail` regardless of key name —
38
+ * putting it there would erase exactly this datum. Length-capped to 320
39
+ * chars (RFC 5321) since it carries attacker-controlled request-body text.
40
+ */
41
+ targetEmail?: string;
42
+ /** Wall-clock millis when the event was recorded. */
43
+ ts: number;
44
+ /** Client User-Agent, when present on the request. */
45
+ userAgent?: string;
46
+ }
47
+ /** Fields accepted when appending one event; `seq` is assigned by the table. */
48
+ interface AppendAuthAuditEntry {
49
+ actorEmail?: string;
50
+ actorId?: string;
51
+ detail?: Record<string, unknown>;
52
+ event: string;
53
+ ip?: string;
54
+ outcome: AuthAuditOutcome;
55
+ /** See {@link AuthAuditEntry.targetEmail}. */
56
+ targetEmail?: string;
57
+ ts: number;
58
+ userAgent?: string;
59
+ }
60
+ /** Options for {@link appendAuthAuditEntry}. */
61
+ interface AppendAuthAuditOptions {
62
+ /**
63
+ * Redact secrets/PII in the `detail` payload before persisting. Defaults to
64
+ * `true`. Set `false` only for a trusted, pre-scrubbed payload.
65
+ */
66
+ redactDetail?: boolean;
67
+ /**
68
+ * Keep only the most recent `retention` rows (trimmed after each append),
69
+ * mirroring the admin audit log's bounded retention. Omit for an unbounded
70
+ * trail (the compliance default) — deliberately NOT capped at 1000.
71
+ */
72
+ retention?: number;
73
+ }
74
+ /** Options for {@link readAuthAuditLog}. */
75
+ interface ReadAuthAuditOptions {
76
+ /** Return only events for this actor id. */
77
+ actorId?: string;
78
+ /** Return only events of this type. */
79
+ event?: string;
80
+ /** Max rows to return, clamped to [1, 10000]. Defaults to 1000. */
81
+ limit?: number;
82
+ /**
83
+ * Return only events with `seq` strictly greater than this. Supplying it
84
+ * switches the page to oldest-first so the cursor walks forward; omit it for
85
+ * the newest-first feed.
86
+ */
87
+ sinceSeq?: number;
88
+ }
89
+ declare const ensureAuthAuditTable: (executor: SqlExecutor) => Promise<void>;
90
+ /**
91
+ * Append one auth event, redacting its `detail` payload (unless disabled) and —
92
+ * when `retention` is set — trimming the log back to the most recent rows.
93
+ * Creates the table first so callers needn't. Returns the redacted, persisted
94
+ * entry (sans `seq`) so an export tap can forward exactly what was stored.
95
+ */
96
+ declare const appendAuthAuditEntry: (executor: SqlExecutor, entry: AppendAuthAuditEntry, options?: AppendAuthAuditOptions) => Promise<AppendAuthAuditEntry>;
97
+ /**
98
+ * Read audit events, optionally filtered by `actorId` / `event` and paged past
99
+ * `sinceSeq`, up to `limit` (clamped to [1, 10000]). Parses each row's `detail`
100
+ * JSON back into an object. Creates the table first so reads on a never-audited
101
+ * database return `[]` instead of throwing.
102
+ *
103
+ * Ordering follows the cursor: **without** `sinceSeq` the page is newest-first
104
+ * (`seq DESC`) — the feed the studio's Security panel renders. **With**
105
+ * `sinceSeq` it is oldest-first (`seq ASC`), because a lower bound is a forward
106
+ * walk: a descending page above the bound would hand back the newest rows and
107
+ * leave everything between the cursor and them unreachable once the caller
108
+ * advanced past it.
109
+ *
110
+ * `limit` is NaN-safe: a non-finite/non-number value (e.g. a caller passing
111
+ * `Number.NaN`, or an upstream boundary that failed to reject one) falls back
112
+ * to {@link DEFAULT_READ_LIMIT} rather than reaching `Math.min`/`Math.max`,
113
+ * which both propagate `NaN` and would otherwise bind it as the SQL `LIMIT`
114
+ * parameter. This is the library-level fix; `#readAudit` (`./auth-do`) also
115
+ * rejects a non-numeric `limit` at the boundary with a 400 — this clamp is the
116
+ * safety net for every OTHER caller of this function too.
117
+ */
118
+ declare const readAuthAuditLog: (executor: SqlExecutor, options?: ReadAuthAuditOptions) => Promise<AuthAuditEntry[]>;
119
+ /**
120
+ * The auth/security audit read plane the runtime's `authAuditReader` option
121
+ * accepts — a structurally-compatible `{ read }` object the worker calls behind
122
+ * its admin gate to back the studio's "Security / audit" page
123
+ * (`__lunora_admin__:getAuthAuditLog`).
124
+ */
125
+ interface AuthAuditReader {
126
+ read: (options: ReadAuthAuditOptions) => Promise<AuthAuditEntry[]>;
127
+ }
128
+ /**
129
+ * Build the reader the runtime's `authAuditReader` option accepts, closing over
130
+ * the auth D1 `executor` (`d1Executor(env.DB)`) so an admin caller reads the same
131
+ * `__lunora_auth_audit__` table the hook writes. Filters/paging pass straight
132
+ * through to {@link readAuthAuditLog} (which clamps `limit`).
133
+ *
134
+ * ```ts
135
+ * export default createWorker({
136
+ * authAuditReader: createAuthAuditReader(d1Executor(env.DB)),
137
+ * // …
138
+ * });
139
+ * ```
140
+ */
141
+ declare const createAuthAuditReader: (executor: SqlExecutor) => AuthAuditReader;
142
+ export { AUTH_AUDIT_TABLE, type AppendAuthAuditEntry, type AppendAuthAuditOptions, type AuthAuditEntry, type AuthAuditEvent, type AuthAuditOutcome, type AuthAuditReader, type ReadAuthAuditOptions, appendAuthAuditEntry, createAuthAuditReader, ensureAuthAuditTable, readAuthAuditLog };
package/dist/audit.mjs ADDED
@@ -0,0 +1,12 @@
1
+ import{standardRules as N,piiRules as D,redact as $}from"@visulima/redact";const C=new Set(["auth","authorization","bearer","card","cc","cookie","credential","cvc","cvv","dsn","hmac","hotp","iban","jwt","kek","mnemonic","otp","pass","passcode","passphrase","passwd","password","pem","pin","pwd","salt","secret","session","sid","sig","signature","ssn","token","totp","verifier"]),x=new Set(["card","pass","pin","session"]),U=new Set(["access","api","client","encryption","master","priv","private","secret","signing"]),M=new Set(["2fa","auth","authorization","backup","factor","hotp","mfa","otp","pin","recovery","reset","security","totp","verification","verify"]),z=new Set(["card no","connection string","database url","one time"]),W=["accesskey","apikey","authorization","cookie","credential","mfacode","otpcode","passcode","passphrase","passwd","password","privatekey","secret","secretkey","sessionid","signature","token"],F=new Set(["again","b64","base","base64","bytes","confirm","confirmation","data","digest","encrypted","hash","hashed","header","hex","id","input","key","no","num","number","plain","plaintext","raw","repeat","str","string","text","value"]),G=new Set(["count","counts","length","limit","limits","size","tokens","total","usage"]),X=new Set(["max","min","num","total"]),S=4096,Z=128,j=16384,l="<REDACTED>",P="[redaction budget exceeded]",v=e=>e.replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/[^a-z\d]+/).filter(t=>t.length>0),y=e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,H=(e,t)=>{const n=y(e[t]),s=t>0?y(e[t-1]):void 0;if(C.has(n))return n;if(s!==void 0){if(n==="key"&&U.has(s))return"key";if(n==="code"&&M.has(s))return"code";if(z.has(`${s} ${n}`))return`${s} ${n}`}return W.some(a=>n.endsWith(a))?n:void 0},k=e=>{const t=v(e);if(t.length===0)return"none";const n=G.has(t.at(-1))||X.has(t[0]);for(let s=t.length-1;s>=0;s-=1){const a=H(t,s);if(a!==void 0)return n?"count-secret":t.slice(s+1).every(i=>F.has(i))?x.has(a)&&s===t.length-1?"scalar-secret":"secret":"none"}return"none"},V=e=>typeof e=="boolean"||e===null||e===void 0?e:l,q=e=>{const t=e.indexOf("://")+3,n=e.slice(t),s=n.split(/[?#]/,1)[0],a=s.lastIndexOf("@"),i=s.indexOf(":"),c=s.indexOf("/"),r=i!==-1&&/^\d+$/.test(s.slice(i+1,c===-1?void 0:c)),o=i!==-1&&!r&&(c===-1||i<c);if(a===-1&&o&&n.includes("@",s.length))return e.slice(0,t);const d=a!==-1&&(c===-1||a<c||i!==-1&&i<a&&!r);return`${e.slice(0,t)}${d?s.slice(a+1):s}`},B=/\b[a-z][\d+.a-z-]{1,15}:\/\/[^\s"'<>()[\]{}]+/gi,Y=/-----BEGIN ([A-Z ]{0,32}PRIVATE KEY)-----[\s\S]*?(?:-----END [A-Z ]{0,32}PRIVATE KEY-----|$)/g,K=/\b(Basic|Bearer|Digest)\s+[\w+/=.~-]{4,}/g,R=String.raw`%[\dA-Fa-f]{2}|\\(?:[bfnrt]|u[\dA-Fa-f]{4})`,I=[{body:String.raw`[\dA-Za-z]{10,}`,name:"Stripe secret or restricted key",prefix:String.raw`[rs]k_(?:live|test)_`},{body:String.raw`[\d+/=A-Za-z]{20,}`,name:"Stripe webhook secret",prefix:"whsec_"},{body:String.raw`[\dA-Za-z]{30,}`,name:"GitHub classic token (personal, OAuth, user/server-to-server, refresh)",prefix:"gh[oprsu]_"},{body:String.raw`\w{20,}`,name:"GitHub fine-grained token",prefix:"github_pat_"},{body:String.raw`[\w-]{20,}`,name:"GitLab personal, pipeline-trigger and deploy tokens",prefix:"gl(?:pat|ptt|dt)-"},{body:String.raw`[\dA-Za-z-]{10,}`,name:"Slack token",prefix:"xox[a-eprs]-"},{body:String.raw`\d-[\dA-Za-z-]{10,}`,name:"Slack app-level token",prefix:"xapp-"},{body:String.raw`[\dA-Z]{16}\b`,name:"AWS access-key id, long-lived and temporary",prefix:"(?:AKIA|ASIA)"},{body:String.raw`[\w-]{35}(?![\w-])`,name:"Google API key",prefix:"AIza"},{body:String.raw`[\w-]{24,}`,name:"Google OAuth client secret",prefix:"GOCSPX-"},{body:String.raw`[\w-]{20,}`,name:"Google OAuth access token",prefix:String.raw`ya29\.`},{body:String.raw`[\dA-Za-z]{36}\b`,name:"npm token",prefix:"npm_"},{body:String.raw`[\dA-Za-z]{30,}`,name:"Hugging Face token",prefix:"hf_"},{body:String.raw`[\dA-Fa-f]{32}\b`,name:"Shopify token",prefix:"shp(?:at|ca|pa|ss)_"},{body:String.raw`[\da-f]{64}\b`,name:"DigitalOcean token",prefix:"do[opr]_v1_"},{body:String.raw`[\w-]{20,}`,name:"OpenAI project/service/admin key, Anthropic key",prefix:"sk-(?:admin|ant|proj|svcacct)-"},{body:String.raw`[\dA-Za-z]{20}T3BlbkFJ[\dA-Za-z]{20}\b`,name:"OpenAI legacy key",prefix:"sk-"},{body:String.raw`[\w-]{22}\.[\w-]{43}(?![\w-])`,name:"SendGrid key",prefix:String.raw`SG\.`}],J=String.raw`(?<=^|[^\w-]|${R})eyJ[\w-]{2,}\.[\w-]{2,}\.[\w-]*`,Q=new RegExp([...I.map(({body:e,prefix:t})=>String.raw`(?<=^|[^\dA-Za-z]|${R})${t}${e}`),J].join("|"),"g"),ee=new RegExp([...I.map(({prefix:e})=>e),"eyJ"].join("|")),te=/(\s|^)(-u|--user|--password|--pass|--token|--api-key)(\s+|=)[^\s"']+/g,f=/(?<![\w.-])(\\?["']?)([A-Za-z_][\w.-]{0,63})\1[ \t]{0,4}([:=])[ \t]{0,4}/g,w=/(?:basic|bearer|digest|token)\s+[^\s"&'),;\]}]+|\\"(?:[^"\\\n]|\\[^"])*(?:\\")?|"[^\n"]*"?|'[^\n']*'?|[^\s"&'),;\]}]+/iy,b=/(?:[ \t]+(?![A-Za-z_][\w.-]{0,63}[:=])[^\s,;)\]}]+)*/y,ne=e=>{let t="",n=0;f.lastIndex=0;for(let s=f.exec(e);s!==null;s=f.exec(e)){const a=k(s[2]),i=s.index+s[0].length;w.lastIndex=i;const c=a==="none"?null:w.exec(e);if(c===null||a==="count-secret"&&/^["']?[\d.]+["']?$/.test(c[0])){f.lastIndex=Math.max(i,s.index+1);continue}const r=c[0],o=r.startsWith('\\"')?'\\"':r.startsWith('"')||r.startsWith("'")?r[0]:"";let d=i+r.length;o===""&&s[3]===":"&&(b.lastIndex=d,d+=b.exec(e)?.[0].length??0),t+=`${e.slice(n,i)}${o}${l}${r.length>o.length&&r.endsWith(o)?o:""}`,n=d,f.lastIndex=n}return t+e.slice(n)},se=/[:=@]|basic|bearer|digest|-u\b|--/i,re=e=>{const t=ee.test(e);if(!t&&!se.test(e))return e;const n=e.replaceAll(Y,`-----BEGIN $1-----${l}`).replaceAll(B,q).replaceAll(K,`$1 ${l}`);return ne((t?n.replaceAll(Q,l):n).replaceAll(te,`$1$2$3${l}`))},ae=(e,t)=>{if(t.remaining<=0)return P;const n=e.slice(0,S+Z);t.remaining-=n.length;const s=re(n);return s.length>S||e.length>n.length?`${s.slice(0,S)}…[truncated]`:s},ie=e=>e instanceof Error||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof Promise||e instanceof ArrayBuffer||ArrayBuffer.isView(e),g=Symbol("no-json"),oe=e=>{const{toJSON:t}=e;if(typeof t!="function")return g;try{const n=t.call(e);return n===e?g:n}catch{return g}},ce=32,u=(e,t,n,s,a)=>{if(typeof e=="string")return s?l:ae(e,a);if(typeof e!="object"||e===null||!Array.isArray(e)&&ie(e))return e;if(t.has(e)||n>=ce)return l;const i=Array.isArray(e)?g:oe(e);if(i!==g){t.add(e);const r=u(i,t,n+1,s,a);return t.delete(e),r}t.add(e);const c=Array.isArray(e)?e.map(r=>u(r,t,n+1,s,a)):Object.fromEntries(Object.entries(e).map(([r,o])=>{const d=k(r);return d==="secret"||d==="scalar-secret"&&(typeof o!="object"||o===null)?[r,V(o)]:[r,u(o,t,n+1,d==="count-secret"&&(typeof o=="string"||Array.isArray(o)),a)]}));return t.delete(e),c},de=e=>u(e,new WeakSet,0,!1,{remaining:j}),E="__lunora_auth_audit__",le=[...N,...D],pe=1e3,Ae=1e4,A=null,m=e=>{if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="bigint"||typeof e=="boolean")return String(e)},Ee=async e=>{await e.run(`CREATE TABLE IF NOT EXISTS "${E}" (
2
+ seq INTEGER PRIMARY KEY AUTOINCREMENT,
3
+ ts REAL NOT NULL,
4
+ event TEXT NOT NULL,
5
+ outcome TEXT NOT NULL,
6
+ actor_id TEXT,
7
+ actor_email TEXT,
8
+ target_email TEXT,
9
+ ip TEXT,
10
+ user_agent TEXT,
11
+ detail TEXT
12
+ )`,[]);try{await e.run(`ALTER TABLE "${E}" ADD COLUMN target_email TEXT`,[])}catch(t){if(!(t instanceof Error?t.message.toLowerCase():String(t).toLowerCase()).includes("duplicate column"))throw t}},_=new WeakMap,L=e=>{const t=_.get(e);if(t)return t;const n=Ee(e);return _.set(e,n),n.catch(()=>_.delete(e)),n},ue=async(e,t,n={})=>{await L(e);let s;return t.detail!==void 0&&(s=n.redactDetail===!1?t.detail:$(de(t.detail),le)),await e.run(`INSERT INTO "${E}" (ts, event, outcome, actor_id, actor_email, target_email, ip, user_agent, detail) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,[t.ts,t.event,t.outcome,t.actorId??A,t.actorEmail??A,t.targetEmail??A,t.ip??A,t.userAgent??A,s===void 0?A:JSON.stringify(s)]),typeof n.retention=="number"&&n.retention>0&&await e.run(`DELETE FROM "${E}" WHERE seq <= (SELECT MAX(seq) - ? FROM "${E}")`,[n.retention]),{...t,detail:s}},fe=async(e,t={})=>{await L(e);const n=Number.isFinite(t.limit)?Math.max(1,Math.min(t.limit,Ae)):pe,s=["seq > ?"],a=[t.sinceSeq??0],i=t.sinceSeq===void 0?"DESC":"ASC";return t.actorId!==void 0&&(s.push("actor_id = ?"),a.push(t.actorId)),t.event!==void 0&&(s.push("event = ?"),a.push(t.event)),a.push(n),(await e.all(`SELECT seq, ts, event, outcome, actor_id, actor_email, target_email, ip, user_agent, detail FROM "${E}" WHERE ${s.join(" AND ")} ORDER BY seq ${i} LIMIT ?`,a)).map(r=>{const o={event:m(r.event)??"",outcome:r.outcome==="failure"?"failure":"success",seq:Number(r.seq),ts:Number(r.ts)},d=[["actorId","actor_id"],["actorEmail","actor_email"],["targetEmail","target_email"],["ip","ip"],["userAgent","user_agent"]];for(const[p,O]of d){const T=m(r[O]);T!==void 0&&(o[p]=T)}const h=m(r.detail);if(h!==void 0)try{const p=JSON.parse(h);typeof p=="object"&&p!==null&&!Array.isArray(p)&&(o.detail=p)}catch{}return o})},Se=e=>({read:t=>fe(e,t)});export{E as AUTH_AUDIT_TABLE,ue as appendAuthAuditEntry,Se as createAuthAuditReader,L as ensureAuthAuditTable,fe as readAuthAuditLog};
@@ -0,0 +1 @@
1
+ export { fetchClientMetadataResource as default } from '@better-auth/cimd/node';
@@ -0,0 +1 @@
1
+ export { fetchClientMetadataResource as default } from '@better-auth/cimd/node';
@@ -0,0 +1 @@
1
+ import{fetchClientMetadataResource as a}from"@better-auth/cimd/node";export{a as default};
@@ -0,0 +1,32 @@
1
+ import { ClientMetadataResourceFetch } from '@better-auth/oauth-provider';
2
+ /**
3
+ * Build the `fetchClientMetadataResource` transport for `cimd()` on Cloudflare
4
+ * Workers.
5
+ *
6
+ * ```ts
7
+ * import { cimd, jwt, mcp } from "@lunora/auth/plugins";
8
+ * import workersCimdFetch from "@lunora/auth/cimd/workers";
9
+ *
10
+ * plugins: [
11
+ * jwt(),
12
+ * mcp({ … }),
13
+ * cimd({
14
+ * fetchClientMetadataResource: workersCimdFetch(),
15
+ * metadataProfile: "mcp-2026-07-28",
16
+ * isMetadataDocumentUrlAllowed: (url) => new URL(url).origin === "https://claude.ai",
17
+ * // The allowlist gates only the `client_id` fetch; bind `jwks_uri` to it too.
18
+ * originBoundFields: ["post_logout_redirect_uris", "client_uri", "jwks_uri"],
19
+ * }),
20
+ * ];
21
+ * ```
22
+ *
23
+ * The returned transport only issues `GET` / `HEAD` to `https:` URLs without
24
+ * credentials, and never follows a redirect: it fetches with `redirect: "manual"`
25
+ * (workerd does not implement `"error"`) and throws on any redirect status, which
26
+ * cimd reports as `invalid_client`. A `304` from a conditional revalidation passes
27
+ * through.
28
+ * @throws LunoraError `AUTH_CIMD_FETCH_NOT_PUBLIC` when the Worker runs without the
29
+ * `global_fetch_strictly_public` compatibility flag.
30
+ */
31
+ declare const workersCimdFetch: () => ClientMetadataResourceFetch;
32
+ export { workersCimdFetch as default };
@@ -0,0 +1,32 @@
1
+ import { ClientMetadataResourceFetch } from '@better-auth/oauth-provider';
2
+ /**
3
+ * Build the `fetchClientMetadataResource` transport for `cimd()` on Cloudflare
4
+ * Workers.
5
+ *
6
+ * ```ts
7
+ * import { cimd, jwt, mcp } from "@lunora/auth/plugins";
8
+ * import workersCimdFetch from "@lunora/auth/cimd/workers";
9
+ *
10
+ * plugins: [
11
+ * jwt(),
12
+ * mcp({ … }),
13
+ * cimd({
14
+ * fetchClientMetadataResource: workersCimdFetch(),
15
+ * metadataProfile: "mcp-2026-07-28",
16
+ * isMetadataDocumentUrlAllowed: (url) => new URL(url).origin === "https://claude.ai",
17
+ * // The allowlist gates only the `client_id` fetch; bind `jwks_uri` to it too.
18
+ * originBoundFields: ["post_logout_redirect_uris", "client_uri", "jwks_uri"],
19
+ * }),
20
+ * ];
21
+ * ```
22
+ *
23
+ * The returned transport only issues `GET` / `HEAD` to `https:` URLs without
24
+ * credentials, and never follows a redirect: it fetches with `redirect: "manual"`
25
+ * (workerd does not implement `"error"`) and throws on any redirect status, which
26
+ * cimd reports as `invalid_client`. A `304` from a conditional revalidation passes
27
+ * through.
28
+ * @throws LunoraError `AUTH_CIMD_FETCH_NOT_PUBLIC` when the Worker runs without the
29
+ * `global_fetch_strictly_public` compatibility flag.
30
+ */
31
+ declare const workersCimdFetch: () => ClientMetadataResourceFetch;
32
+ export { workersCimdFetch as default };
@@ -0,0 +1 @@
1
+ import{LunoraError as c}from"@lunora/errors";const a="global_fetch_strictly_public",i=()=>{const{Cloudflare:t}=globalThis;return t?.compatibilityFlags?.[a]===!0},n=new Set([301,302,303,307,308]),l=t=>n.has(t.status)||t.type==="opaqueredirect",d=()=>{if(!i())throw new c("AUTH_CIMD_FETCH_NOT_PUBLIC",`CIMD needs the "${a}" compatibility flag, so metadata fetches cannot reach private addresses. Add it to "compatibility_flags" in wrangler.jsonc.`);return async(t,s)=>{const e=new Request(t,{...s,redirect:"manual"}),r=new URL(e.url);if(r.protocol!=="https:")throw new TypeError(`refusing to fetch a client metadata resource over ${r.protocol}`);if(r.username!==""||r.password!=="")throw new TypeError("refusing to fetch a client metadata resource URL that carries credentials");if(e.method!=="GET"&&e.method!=="HEAD")throw new TypeError(`refusing to ${e.method} a client metadata resource`);const o=await fetch(e);if(l(o))throw new TypeError("client metadata resource fetches must not follow redirects");return o}};export{d as default};