@lunora/auth 1.0.0-alpha.28 → 1.0.0-alpha.280

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 (107) hide show
  1. package/LICENSE.md +233 -104
  2. package/README.md +109 -15
  3. package/dist/adapter.d.mts +4 -43
  4. package/dist/adapter.d.ts +4 -43
  5. package/dist/adapter.mjs +1 -48
  6. package/dist/audit.d.mts +173 -0
  7. package/dist/audit.d.ts +173 -0
  8. package/dist/audit.mjs +1 -0
  9. package/dist/cimd-node.d.mts +1 -0
  10. package/dist/cimd-node.d.ts +1 -0
  11. package/dist/cimd-node.mjs +1 -0
  12. package/dist/cimd-workers.d.mts +64 -0
  13. package/dist/cimd-workers.d.ts +64 -0
  14. package/dist/cimd-workers.mjs +1 -0
  15. package/dist/email-guard.d.mts +143 -0
  16. package/dist/email-guard.d.ts +143 -0
  17. package/dist/email-guard.mjs +1 -0
  18. package/dist/index.d.mts +620 -541
  19. package/dist/index.d.ts +620 -541
  20. package/dist/index.mjs +1 -12
  21. package/dist/middleware.d.mts +165 -155
  22. package/dist/middleware.d.ts +165 -155
  23. package/dist/middleware.mjs +1 -56
  24. package/dist/migrate.d.mts +62 -0
  25. package/dist/migrate.d.ts +62 -0
  26. package/dist/migrate.mjs +1 -0
  27. package/dist/packem_shared/AUTH_DO_AUDIT_PATH-jbpoDPJs.mjs +1 -0
  28. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-C3SqYG3N.mjs +1 -0
  29. package/dist/packem_shared/LunoraAuthAdminError-Cg94b5lr.mjs +1 -0
  30. package/dist/packem_shared/adapter-L3XvHnkW.mjs +2 -0
  31. package/dist/packem_shared/adapter.d-BEvPbvSs.d.ts +110 -0
  32. package/dist/packem_shared/adapter.d-RQVSeO5T.d.mts +110 -0
  33. package/dist/packem_shared/api-key-storage-D15k9_CF.mjs +1 -0
  34. package/dist/packem_shared/apiKey-B9uGt5Nc.mjs +1 -0
  35. package/dist/packem_shared/audit-daeExZWv.mjs +12 -0
  36. package/dist/packem_shared/auth-do-JzJM4sBK.mjs +1 -0
  37. package/dist/packem_shared/authAuditBeforeHook-DPRq6mbA.mjs +1 -0
  38. package/dist/packem_shared/authBackfillStatus-ZDUCk4U6.mjs +1 -0
  39. package/dist/packem_shared/authCanonicalEmailColumn-CfhnJ1Wp.mjs +1 -0
  40. package/dist/packem_shared/authCredentialColumns-CnsISHUl.mjs +1 -0
  41. package/dist/packem_shared/authDiscoveryPaths-BtKCs_3V.mjs +1 -0
  42. package/dist/packem_shared/authDoColumnAdditions-UwF3Rl41.mjs +1 -0
  43. package/dist/packem_shared/convertAuthDatesOnce-DE_O-bpx.mjs +1 -0
  44. package/dist/packem_shared/create-auth.d-B8S7aw9O.d.mts +153 -0
  45. package/dist/packem_shared/create-auth.d-B8S7aw9O.d.ts +153 -0
  46. package/dist/packem_shared/createAuth-DFkaeVge.mjs +1 -0
  47. package/dist/packem_shared/createDoAuthWiring-o3mfSSIf.mjs +1 -0
  48. package/dist/packem_shared/createLunoraAuthClient-wzZk9E0m.mjs +1 -0
  49. package/dist/packem_shared/createSignUpInvitation-miwkunlA.mjs +1 -0
  50. package/dist/packem_shared/effectiveCookieCache-JvL6i6YO.mjs +1 -0
  51. package/dist/packem_shared/emailGateDatabaseHooks-Dvyliwxx.mjs +1 -0
  52. package/dist/packem_shared/handleAuthRequest-Id9Vv_Tk.mjs +1 -0
  53. package/dist/packem_shared/identity-claims-hAvIl2wm.mjs +1 -0
  54. package/dist/packem_shared/invitation-email-backfill-DUwurNbV.mjs +1 -0
  55. package/dist/packem_shared/invite-only.d-CsBPLsY1.d.mts +126 -0
  56. package/dist/packem_shared/invite-only.d-JdPDmy_a.d.ts +126 -0
  57. package/dist/packem_shared/isDevEnvironment-yLbPngwn.mjs +1 -0
  58. package/dist/packem_shared/legacyIssuerCleanupStatements-DCL5uV55.mjs +1 -0
  59. package/dist/packem_shared/mcp-CK5XkDFp.mjs +1 -0
  60. package/dist/packem_shared/on-cloudflare-edge-Dx6gFjBO.mjs +1 -0
  61. package/dist/packem_shared/prepareAuthData-CP4M7zk1.mjs +1 -0
  62. package/dist/packem_shared/provision-DWGVCbQD.mjs +1 -0
  63. package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +1 -0
  64. package/dist/packem_shared/resolveSessionIdentity-EBhckRBW.mjs +1 -0
  65. package/dist/packem_shared/sessionPresets-DQQYAOER.mjs +1 -0
  66. package/dist/packem_shared/sql-store-CFeVqF0V.mjs +1 -0
  67. package/dist/packem_shared/uiConfig-B8pN6pks.mjs +1 -0
  68. package/dist/packem_shared/worker.d-CDnMrB5s.d.mts +912 -0
  69. package/dist/packem_shared/worker.d-CVuhZPM3.d.ts +912 -0
  70. package/dist/plugins-client.d.mts +251 -1
  71. package/dist/plugins-client.d.ts +251 -1
  72. package/dist/plugins-client.mjs +1 -2
  73. package/dist/plugins-enterprise-client.d.mts +13 -0
  74. package/dist/plugins-enterprise-client.d.ts +13 -0
  75. package/dist/plugins-enterprise-client.mjs +1 -0
  76. package/dist/plugins-enterprise.d.mts +1659 -0
  77. package/dist/plugins-enterprise.d.ts +1659 -0
  78. package/dist/plugins-enterprise.mjs +1 -0
  79. package/dist/plugins.d.mts +180 -2
  80. package/dist/plugins.d.ts +180 -2
  81. package/dist/plugins.mjs +1 -22
  82. package/dist/schema.d.mts +47 -39
  83. package/dist/schema.d.ts +47 -39
  84. package/dist/schema.mjs +1 -62
  85. package/dist/sql-store.d.mts +48 -29
  86. package/dist/sql-store.d.ts +48 -29
  87. package/dist/sql-store.mjs +1 -184
  88. package/dist/store.d.mts +65 -47
  89. package/dist/store.d.ts +65 -47
  90. package/dist/store.mjs +1 -183
  91. package/dist/turnstile-middleware.d.mts +73 -55
  92. package/dist/turnstile-middleware.d.ts +73 -55
  93. package/dist/turnstile-middleware.mjs +1 -34
  94. package/dist/turnstile.d.mts +42 -49
  95. package/dist/turnstile.d.ts +42 -49
  96. package/dist/turnstile.mjs +1 -54
  97. package/dist/worker.d.mts +9 -0
  98. package/dist/worker.d.ts +9 -0
  99. package/dist/worker.mjs +1 -0
  100. package/package.json +58 -7
  101. package/dist/packem_shared/DEFAULT_AUTH_BASE_PATH-DjcUWEQl.mjs +0 -11
  102. package/dist/packem_shared/LunoraAuthAdminError-D4L7n6gN.mjs +0 -510
  103. package/dist/packem_shared/compileMigrationsSql-B9bj-mJv.mjs +0 -29
  104. package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.mts +0 -128
  105. package/dist/packem_shared/create-auth.d-Mwhb4gSc.d.ts +0 -128
  106. package/dist/packem_shared/createAuth-BVMMllTm.mjs +0 -87
  107. package/dist/packem_shared/sessionPresets-Dwwd74_J.mjs +0 -38
@@ -1,34 +1 @@
1
- import { LunoraError } from '@lunora/errors';
2
- import { verifyTurnstile } from './turnstile.mjs';
3
-
4
- const verifyTurnstileMiddleware = (options) => async ({ ctx, next }) => {
5
- const token = options.token(ctx);
6
- if (token === void 0 || token === "") {
7
- throw new LunoraError("FORBIDDEN", options.message ?? "turnstile token missing");
8
- }
9
- let result;
10
- try {
11
- result = await verifyTurnstile({
12
- expectedAction: options.expectedAction,
13
- expectedHostname: options.expectedHostname,
14
- fetch: options.fetch,
15
- remoteip: options.remoteip?.(ctx),
16
- secret: options.secret,
17
- token
18
- });
19
- } catch (error) {
20
- console.error(`@lunora/auth: verifyTurnstileMiddleware siteverify threw; ${options.failOpen ? "failing open" : "failing closed"}`, error);
21
- if (options.failOpen) {
22
- return next();
23
- }
24
- throw new LunoraError("FORBIDDEN", options.message ?? "turnstile verification unavailable", { cause: error });
25
- }
26
- if (!result.success || options.validate !== void 0 && !options.validate(result)) {
27
- throw new LunoraError("FORBIDDEN", options.message ?? "turnstile verification failed", {
28
- data: result.errorCodes.length > 0 ? { errorCodes: result.errorCodes } : void 0
29
- });
30
- }
31
- return next();
32
- };
33
-
34
- export { verifyTurnstileMiddleware };
1
+ import{LunoraError as i}from"@lunora/errors";import{tagPerDispatchMiddleware as d}from"@lunora/server";import{verifyTurnstile as n}from"./turnstile.mjs";const u=e=>d(async({ctx:a,next:l})=>{const t=e.token(a);if(t===void 0||t==="")throw new i("FORBIDDEN",e.message??"turnstile token missing");let r;try{r=await n({expectedAction:e.expectedAction,expectedHostname:e.expectedHostname,fetch:e.fetch,remoteip:e.remoteip?.(a),secret:e.secret,token:t})}catch(c){if(console.error(`@lunora/auth: verifyTurnstileMiddleware siteverify threw; ${e.failOpen?"failing open":"failing closed"}`,c),e.failOpen)return l();throw new i("FORBIDDEN",e.message??"turnstile verification unavailable",{cause:c})}if(!r.success||e.validate!==void 0&&e.validate(r)!==!0)throw new i("FORBIDDEN",e.message??"turnstile verification failed",{data:r.errorCodes.length>0?{errorCodes:r.errorCodes}:void 0});return l()});export{u as verifyTurnstileMiddleware};
@@ -8,32 +8,32 @@ type FetchLike = (input: string, init?: {
8
8
  }) => Promise<Response>;
9
9
  interface VerifyTurnstileOptions {
10
10
  /**
11
- * Assert the widget `action` the token was solved for. Cloudflare echoes the
12
- * customer-supplied `action` back in the siteverify response; when this is
13
- * set and the returned `action` does not match, the verdict is downgraded to
14
- * `success: false` (with error code `action-mismatch`). Leave unset to skip
15
- * the check.
16
- */
11
+ * Assert the widget `action` the token was solved for. Cloudflare echoes the
12
+ * customer-supplied `action` back in the siteverify response; when this is
13
+ * set and the returned `action` does not match, the verdict is downgraded to
14
+ * `success: false` (with error code `action-mismatch`). Leave unset to skip
15
+ * the check.
16
+ */
17
17
  expectedAction?: string;
18
18
  /**
19
- * Assert the `hostname` the challenge was solved on. Cloudflare returns the
20
- * solving hostname in the siteverify response; when this is set and the
21
- * returned `hostname` does not match, the verdict is downgraded to
22
- * `success: false` (with error code `hostname-mismatch`). Set this when a
23
- * single secret/sitekey is shared across multiple domains to stop a token
24
- * harvested on one origin from being replayed against another. Leave unset
25
- * to skip the check.
26
- */
19
+ * Assert the `hostname` the challenge was solved on. Cloudflare returns the
20
+ * solving hostname in the siteverify response; when this is set and the
21
+ * returned `hostname` does not match, the verdict is downgraded to
22
+ * `success: false` (with error code `hostname-mismatch`). Set this when a
23
+ * single secret/sitekey is shared across multiple domains to stop a token
24
+ * harvested on one origin from being replayed against another. Leave unset
25
+ * to skip the check.
26
+ */
27
27
  expectedHostname?: string;
28
28
  /**
29
- * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. Primarily
30
- * for unit tests — production callers can omit it.
31
- */
29
+ * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. Primarily
30
+ * for unit tests — production callers can omit it.
31
+ */
32
32
  fetch?: FetchLike;
33
33
  /**
34
- * The visitor's IP address, if known. Optional; Cloudflare uses it as an
35
- * extra signal but verification works without it.
36
- */
34
+ * The visitor's IP address, if known. Optional; Cloudflare uses it as an
35
+ * extra signal but verification works without it.
36
+ */
37
37
  remoteip?: string;
38
38
  /** Your Turnstile secret key (the `TURNSTILE_SECRET_KEY` env var). */
39
39
  secret: string;
@@ -41,13 +41,13 @@ interface VerifyTurnstileOptions {
41
41
  token: string;
42
42
  }
43
43
  /**
44
- * The normalized result of a Turnstile verification. Snake-cased fields from
45
- * Cloudflare (`error-codes`, `challenge_ts`) are mapped to camelCase.
46
- *
47
- * A `success: false` verdict is a **bot/invalid-token** outcome, not an error —
48
- * it is returned, never thrown. `verifyTurnstile` only throws on transport
49
- * failure (network error, non-2xx response).
50
- */
44
+ * The normalized result of a Turnstile verification. Snake-cased fields from
45
+ * Cloudflare (`error-codes`, `challenge_ts`) are mapped to camelCase.
46
+ *
47
+ * A `success: false` verdict is a **bot/invalid-token** outcome, not an error —
48
+ * it is returned, never thrown. `verifyTurnstile` only throws on transport
49
+ * failure (network error, non-2xx response).
50
+ */
51
51
  interface TurnstileVerifyResult {
52
52
  /** The customer-supplied `action` the widget was rendered with, if any. */
53
53
  action?: string;
@@ -56,9 +56,9 @@ interface TurnstileVerifyResult {
56
56
  /** ISO timestamp of the challenge, if Cloudflare returned one. */
57
57
  challengeTs?: string;
58
58
  /**
59
- * Cloudflare error codes for a failed verification (e.g.
60
- * `"invalid-input-response"`, `"timeout-or-duplicate"`). Empty on success.
61
- */
59
+ * Cloudflare error codes for a failed verification (e.g.
60
+ * `"invalid-input-response"`, `"timeout-or-duplicate"`). Empty on success.
61
+ */
62
62
  errorCodes: string[];
63
63
  /** Hostname the challenge was solved on, if Cloudflare returned one. */
64
64
  hostname?: string;
@@ -66,23 +66,16 @@ interface TurnstileVerifyResult {
66
66
  success: boolean;
67
67
  }
68
68
  /**
69
- * Verify a Turnstile token against Cloudflare's `siteverify` endpoint.
70
- *
71
- * POSTs `application/x-www-form-urlencoded` (`secret`, `response`=token, and an
72
- * optional `remoteip`) and returns the parsed verdict. A `success: false`
73
- * outcome (bot / invalid / expired token) is **returned**, not thrown — callers
74
- * decide how to react. The function throws a structural `LunoraError`-shaped
75
- * error (`{ name: "LunoraError", code: "SERVICE_UNAVAILABLE", status: 503 }`)
76
- * only when the siteverify call itself fails (network error or non-2xx), so a
77
- * "siteverify is down" failure is distinguishable from a "this is a bot"
78
- * verdict.
79
- */
80
- declare const verifyTurnstile: ({
81
- expectedAction,
82
- expectedHostname,
83
- fetch,
84
- remoteip,
85
- secret,
86
- token
87
- }: VerifyTurnstileOptions) => Promise<TurnstileVerifyResult>;
69
+ * Verify a Turnstile token against Cloudflare's `siteverify` endpoint.
70
+ *
71
+ * POSTs `application/x-www-form-urlencoded` (`secret`, `response`=token, and an
72
+ * optional `remoteip`) and returns the parsed verdict. A `success: false`
73
+ * outcome (bot / invalid / expired token) is **returned**, not thrown — callers
74
+ * decide how to react. The function throws a structural `LunoraError`-shaped
75
+ * error (`{ name: "LunoraError", code: "SERVICE_UNAVAILABLE", status: 503 }`)
76
+ * only when the siteverify call itself fails (network error or non-2xx), so a
77
+ * "siteverify is down" failure is distinguishable from a "this is a bot"
78
+ * verdict.
79
+ */
80
+ declare const verifyTurnstile: ({ expectedAction, expectedHostname, fetch, remoteip, secret, token }: VerifyTurnstileOptions) => Promise<TurnstileVerifyResult>;
88
81
  export { type FetchLike, TURNSTILE_VERIFY_ENDPOINT, type TurnstileVerifyResult, type VerifyTurnstileOptions, verifyTurnstile };
@@ -8,32 +8,32 @@ type FetchLike = (input: string, init?: {
8
8
  }) => Promise<Response>;
9
9
  interface VerifyTurnstileOptions {
10
10
  /**
11
- * Assert the widget `action` the token was solved for. Cloudflare echoes the
12
- * customer-supplied `action` back in the siteverify response; when this is
13
- * set and the returned `action` does not match, the verdict is downgraded to
14
- * `success: false` (with error code `action-mismatch`). Leave unset to skip
15
- * the check.
16
- */
11
+ * Assert the widget `action` the token was solved for. Cloudflare echoes the
12
+ * customer-supplied `action` back in the siteverify response; when this is
13
+ * set and the returned `action` does not match, the verdict is downgraded to
14
+ * `success: false` (with error code `action-mismatch`). Leave unset to skip
15
+ * the check.
16
+ */
17
17
  expectedAction?: string;
18
18
  /**
19
- * Assert the `hostname` the challenge was solved on. Cloudflare returns the
20
- * solving hostname in the siteverify response; when this is set and the
21
- * returned `hostname` does not match, the verdict is downgraded to
22
- * `success: false` (with error code `hostname-mismatch`). Set this when a
23
- * single secret/sitekey is shared across multiple domains to stop a token
24
- * harvested on one origin from being replayed against another. Leave unset
25
- * to skip the check.
26
- */
19
+ * Assert the `hostname` the challenge was solved on. Cloudflare returns the
20
+ * solving hostname in the siteverify response; when this is set and the
21
+ * returned `hostname` does not match, the verdict is downgraded to
22
+ * `success: false` (with error code `hostname-mismatch`). Set this when a
23
+ * single secret/sitekey is shared across multiple domains to stop a token
24
+ * harvested on one origin from being replayed against another. Leave unset
25
+ * to skip the check.
26
+ */
27
27
  expectedHostname?: string;
28
28
  /**
29
- * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. Primarily
30
- * for unit tests — production callers can omit it.
31
- */
29
+ * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. Primarily
30
+ * for unit tests — production callers can omit it.
31
+ */
32
32
  fetch?: FetchLike;
33
33
  /**
34
- * The visitor's IP address, if known. Optional; Cloudflare uses it as an
35
- * extra signal but verification works without it.
36
- */
34
+ * The visitor's IP address, if known. Optional; Cloudflare uses it as an
35
+ * extra signal but verification works without it.
36
+ */
37
37
  remoteip?: string;
38
38
  /** Your Turnstile secret key (the `TURNSTILE_SECRET_KEY` env var). */
39
39
  secret: string;
@@ -41,13 +41,13 @@ interface VerifyTurnstileOptions {
41
41
  token: string;
42
42
  }
43
43
  /**
44
- * The normalized result of a Turnstile verification. Snake-cased fields from
45
- * Cloudflare (`error-codes`, `challenge_ts`) are mapped to camelCase.
46
- *
47
- * A `success: false` verdict is a **bot/invalid-token** outcome, not an error —
48
- * it is returned, never thrown. `verifyTurnstile` only throws on transport
49
- * failure (network error, non-2xx response).
50
- */
44
+ * The normalized result of a Turnstile verification. Snake-cased fields from
45
+ * Cloudflare (`error-codes`, `challenge_ts`) are mapped to camelCase.
46
+ *
47
+ * A `success: false` verdict is a **bot/invalid-token** outcome, not an error —
48
+ * it is returned, never thrown. `verifyTurnstile` only throws on transport
49
+ * failure (network error, non-2xx response).
50
+ */
51
51
  interface TurnstileVerifyResult {
52
52
  /** The customer-supplied `action` the widget was rendered with, if any. */
53
53
  action?: string;
@@ -56,9 +56,9 @@ interface TurnstileVerifyResult {
56
56
  /** ISO timestamp of the challenge, if Cloudflare returned one. */
57
57
  challengeTs?: string;
58
58
  /**
59
- * Cloudflare error codes for a failed verification (e.g.
60
- * `"invalid-input-response"`, `"timeout-or-duplicate"`). Empty on success.
61
- */
59
+ * Cloudflare error codes for a failed verification (e.g.
60
+ * `"invalid-input-response"`, `"timeout-or-duplicate"`). Empty on success.
61
+ */
62
62
  errorCodes: string[];
63
63
  /** Hostname the challenge was solved on, if Cloudflare returned one. */
64
64
  hostname?: string;
@@ -66,23 +66,16 @@ interface TurnstileVerifyResult {
66
66
  success: boolean;
67
67
  }
68
68
  /**
69
- * Verify a Turnstile token against Cloudflare's `siteverify` endpoint.
70
- *
71
- * POSTs `application/x-www-form-urlencoded` (`secret`, `response`=token, and an
72
- * optional `remoteip`) and returns the parsed verdict. A `success: false`
73
- * outcome (bot / invalid / expired token) is **returned**, not thrown — callers
74
- * decide how to react. The function throws a structural `LunoraError`-shaped
75
- * error (`{ name: "LunoraError", code: "SERVICE_UNAVAILABLE", status: 503 }`)
76
- * only when the siteverify call itself fails (network error or non-2xx), so a
77
- * "siteverify is down" failure is distinguishable from a "this is a bot"
78
- * verdict.
79
- */
80
- declare const verifyTurnstile: ({
81
- expectedAction,
82
- expectedHostname,
83
- fetch,
84
- remoteip,
85
- secret,
86
- token
87
- }: VerifyTurnstileOptions) => Promise<TurnstileVerifyResult>;
69
+ * Verify a Turnstile token against Cloudflare's `siteverify` endpoint.
70
+ *
71
+ * POSTs `application/x-www-form-urlencoded` (`secret`, `response`=token, and an
72
+ * optional `remoteip`) and returns the parsed verdict. A `success: false`
73
+ * outcome (bot / invalid / expired token) is **returned**, not thrown — callers
74
+ * decide how to react. The function throws a structural `LunoraError`-shaped
75
+ * error (`{ name: "LunoraError", code: "SERVICE_UNAVAILABLE", status: 503 }`)
76
+ * only when the siteverify call itself fails (network error or non-2xx), so a
77
+ * "siteverify is down" failure is distinguishable from a "this is a bot"
78
+ * verdict.
79
+ */
80
+ declare const verifyTurnstile: ({ expectedAction, expectedHostname, fetch, remoteip, secret, token }: VerifyTurnstileOptions) => Promise<TurnstileVerifyResult>;
88
81
  export { type FetchLike, TURNSTILE_VERIFY_ENDPOINT, type TurnstileVerifyResult, type VerifyTurnstileOptions, verifyTurnstile };
@@ -1,54 +1 @@
1
- import { LunoraError } from '@lunora/errors';
2
-
3
- const TURNSTILE_VERIFY_ENDPOINT = "https://challenges.cloudflare.com/turnstile/v0/siteverify";
4
- const asString = (value) => typeof value === "string" ? value : void 0;
5
- const asStringArray = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
6
- const verifyTurnstile = async ({
7
- expectedAction,
8
- expectedHostname,
9
- fetch = globalThis.fetch,
10
- remoteip,
11
- secret,
12
- token
13
- }) => {
14
- const body = new URLSearchParams({ response: token, secret });
15
- if (remoteip !== void 0 && remoteip !== "") {
16
- body.set("remoteip", remoteip);
17
- }
18
- let response;
19
- try {
20
- response = await fetch(TURNSTILE_VERIFY_ENDPOINT, {
21
- body: body.toString(),
22
- headers: { "content-type": "application/x-www-form-urlencoded" },
23
- method: "POST"
24
- });
25
- } catch (error) {
26
- throw new LunoraError("SERVICE_UNAVAILABLE", "turnstile siteverify request failed", { cause: error, status: 503 });
27
- }
28
- if (!response.ok) {
29
- throw new LunoraError("SERVICE_UNAVAILABLE", `turnstile siteverify returned ${String(response.status)}`, { status: 503 });
30
- }
31
- const raw = await response.json();
32
- const action = asString(raw.action);
33
- const hostname = asString(raw.hostname);
34
- const errorCodes = asStringArray(raw["error-codes"]);
35
- let success = raw.success === true;
36
- if (success && expectedHostname !== void 0 && hostname !== expectedHostname) {
37
- success = false;
38
- errorCodes.push("hostname-mismatch");
39
- }
40
- if (success && expectedAction !== void 0 && action !== expectedAction) {
41
- success = false;
42
- errorCodes.push("action-mismatch");
43
- }
44
- return {
45
- action,
46
- cdata: asString(raw.cdata),
47
- challengeTs: asString(raw.challenge_ts),
48
- errorCodes,
49
- hostname,
50
- success
51
- };
52
- };
53
-
54
- export { TURNSTILE_VERIFY_ENDPOINT, verifyTurnstile };
1
+ import{LunoraError as l}from"@lunora/errors";const E="https://challenges.cloudflare.com/turnstile/v0/siteverify",a=t=>typeof t=="string"?t:void 0,m=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"):[],S=async({expectedAction:t,expectedHostname:e,fetch:d=globalThis.fetch,remoteip:n,secret:y,token:w})=>{const h=new URLSearchParams({response:w,secret:y});n!==void 0&&n!==""&&h.set("remoteip",n);let o;try{o=await d(E,{body:h.toString(),headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST"})}catch(c){throw new l("SERVICE_UNAVAILABLE","turnstile siteverify request failed",{cause:c,status:503})}if(!o.ok)throw new l("SERVICE_UNAVAILABLE",`turnstile siteverify returned ${String(o.status)}`,{status:503});let r;try{r=await o.json()}catch(c){throw new l("SERVICE_UNAVAILABLE","turnstile siteverify returned a non-JSON body",{cause:c,status:503})}const u=a(r.action),f=a(r.hostname),i=m(r["error-codes"]);let s=r.success===!0;return s&&e!==void 0&&f!==e&&(s=!1,i.push("hostname-mismatch")),s&&t!==void 0&&u!==t&&(s=!1,i.push("action-mismatch")),{action:u,cdata:a(r.cdata),challengeTs:a(r.challenge_ts),errorCodes:i,hostname:f,success:s}};export{E as TURNSTILE_VERIFY_ENDPOINT,S as verifyTurnstile};
@@ -0,0 +1,9 @@
1
+ export { a as lunoraD1Adapter } from "./packem_shared/adapter.d-RQVSeO5T.mjs";
2
+ export { J as authCanonicalEmailColumn, K as authCredentialColumns, M as authCredentialTableNames, O as authDiscoveryPathsFor, P as authTableNames, R as createAuthAdmin, T as createDoAuthWiring, U as createSqlAuthDataPort, V as effectiveCookieCache, W as handleAuthDiscoveryRequest, X as handleAuthRequest, Y as resolveSessionIdentity } from "./packem_shared/worker.d-CDnMrB5s.mjs";
3
+ export { createAuthAuditReader, createAuthAuditWriter } from "./audit.mjs";
4
+ export { c as createAuth } from "./packem_shared/create-auth.d-B8S7aw9O.mjs";
5
+ export { d1Executor } from "./sql-store.mjs";
6
+ import 'better-auth/adapters';
7
+ import "./store.mjs";
8
+ import '@lunora/errors';
9
+ import 'better-auth';
@@ -0,0 +1,9 @@
1
+ export { a as lunoraD1Adapter } from "./packem_shared/adapter.d-BEvPbvSs.js";
2
+ export { J as authCanonicalEmailColumn, K as authCredentialColumns, M as authCredentialTableNames, O as authDiscoveryPathsFor, P as authTableNames, R as createAuthAdmin, T as createDoAuthWiring, U as createSqlAuthDataPort, V as effectiveCookieCache, W as handleAuthDiscoveryRequest, X as handleAuthRequest, Y as resolveSessionIdentity } from "./packem_shared/worker.d-CVuhZPM3.js";
3
+ export { createAuthAuditReader, createAuthAuditWriter } from "./audit.js";
4
+ export { c as createAuth } from "./packem_shared/create-auth.d-B8S7aw9O.js";
5
+ export { d1Executor } from "./sql-store.js";
6
+ import 'better-auth/adapters';
7
+ import "./store.js";
8
+ import '@lunora/errors';
9
+ import 'better-auth';
@@ -0,0 +1 @@
1
+ import{a as r}from"./packem_shared/adapter-L3XvHnkW.mjs";import{createAuthAdmin as a}from"./packem_shared/LunoraAuthAdminError-Cg94b5lr.mjs";import{c as m,b as h}from"./packem_shared/audit-daeExZWv.mjs";import{authCanonicalEmailColumn as s}from"./packem_shared/authCanonicalEmailColumn-CfhnJ1Wp.mjs";import{effectiveCookieCache as c}from"./packem_shared/effectiveCookieCache-JvL6i6YO.mjs";import{createAuth as n}from"./packem_shared/createAuth-DFkaeVge.mjs";import{authCredentialColumns as x,authCredentialTableNames as d,authTableNames as A,createSqlAuthDataPort as C}from"./packem_shared/authCredentialColumns-CnsISHUl.mjs";import{authDiscoveryPathsFor as v,handleAuthDiscoveryRequest as b}from"./packem_shared/authDiscoveryPaths-BtKCs_3V.mjs";import{createDoAuthWiring as y}from"./packem_shared/createDoAuthWiring-o3mfSSIf.mjs";import{handleAuthRequest as E}from"./packem_shared/handleAuthRequest-Id9Vv_Tk.mjs";import{resolveSessionIdentity as P}from"./packem_shared/resolveSessionIdentity-EBhckRBW.mjs";import{d as T}from"./packem_shared/sql-store-CFeVqF0V.mjs";export{s as authCanonicalEmailColumn,x as authCredentialColumns,d as authCredentialTableNames,v as authDiscoveryPathsFor,A as authTableNames,n as createAuth,a as createAuthAdmin,m as createAuthAuditReader,h as createAuthAuditWriter,y as createDoAuthWiring,C as createSqlAuthDataPort,T as d1Executor,c as effectiveCookieCache,b as handleAuthDiscoveryRequest,E as handleAuthRequest,r as lunoraD1Adapter,P as resolveSessionIdentity};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/auth",
3
- "version": "1.0.0-alpha.28",
3
+ "version": "1.0.0-alpha.280",
4
4
  "description": "Auth for Lunora — a thin better-auth wrapper: email/password, OAuth, plugins, D1-backed",
5
5
  "keywords": [
6
6
  "auth",
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "homepage": "https://lunora.sh",
16
16
  "bugs": "https://github.com/anolilab/lunora/issues",
17
- "license": "FSL-1.1-Apache-2.0",
17
+ "license": "Apache-2.0",
18
18
  "author": {
19
19
  "name": "Daniel Bannert",
20
20
  "email": "d.bannert@anolilab.de"
@@ -48,10 +48,34 @@
48
48
  "types": "./dist/plugins-client.d.ts",
49
49
  "import": "./dist/plugins-client.mjs"
50
50
  },
51
+ "./plugins/enterprise": {
52
+ "types": "./dist/plugins-enterprise.d.ts",
53
+ "import": "./dist/plugins-enterprise.mjs"
54
+ },
55
+ "./plugins/enterprise/client": {
56
+ "types": "./dist/plugins-enterprise-client.d.ts",
57
+ "import": "./dist/plugins-enterprise-client.mjs"
58
+ },
59
+ "./cimd/node": {
60
+ "types": "./dist/cimd-node.d.ts",
61
+ "import": "./dist/cimd-node.mjs"
62
+ },
63
+ "./cimd/workers": {
64
+ "types": "./dist/cimd-workers.d.ts",
65
+ "import": "./dist/cimd-workers.mjs"
66
+ },
51
67
  "./middleware": {
52
68
  "types": "./dist/middleware.d.ts",
53
69
  "import": "./dist/middleware.mjs"
54
70
  },
71
+ "./audit": {
72
+ "types": "./dist/audit.d.ts",
73
+ "import": "./dist/audit.mjs"
74
+ },
75
+ "./email-guard": {
76
+ "types": "./dist/email-guard.d.ts",
77
+ "import": "./dist/email-guard.mjs"
78
+ },
55
79
  "./turnstile": {
56
80
  "types": "./dist/turnstile.d.ts",
57
81
  "import": "./dist/turnstile.mjs"
@@ -72,21 +96,48 @@
72
96
  "types": "./dist/store.d.ts",
73
97
  "import": "./dist/store.mjs"
74
98
  },
99
+ "./migrate": {
100
+ "types": "./dist/migrate.d.ts",
101
+ "import": "./dist/migrate.mjs"
102
+ },
75
103
  "./sql-store": {
76
104
  "types": "./dist/sql-store.d.ts",
77
105
  "import": "./dist/sql-store.mjs"
78
106
  },
107
+ "./worker": {
108
+ "types": "./dist/worker.d.ts",
109
+ "import": "./dist/worker.mjs"
110
+ },
79
111
  "./package.json": "./package.json"
80
112
  },
81
113
  "publishConfig": {
82
114
  "access": "public"
83
115
  },
84
116
  "dependencies": {
85
- "@better-auth/passkey": "^1.6.23",
86
- "@lunora/errors": "1.0.0-alpha.3",
87
- "@lunora/server": "1.0.0-alpha.22",
88
- "@lunora/values": "1.0.0-alpha.6",
89
- "better-auth": "^1.6.23"
117
+ "@better-auth/api-key": "1.7.28",
118
+ "@better-auth/cimd": "1.7.28",
119
+ "@better-auth/mcp": "1.7.28",
120
+ "@better-auth/oauth-provider": "1.7.28",
121
+ "@better-auth/passkey": "1.7.28",
122
+ "@better-auth/scim": "1.7.28",
123
+ "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
124
+ "@lunora/values": "^1.0.0-alpha.95",
125
+ "@lunora/wire": "1.0.0-alpha.6",
126
+ "@visulima/disposable-email-domains": "2.0.10",
127
+ "@visulima/email-verifier": "1.0.54",
128
+ "@visulima/free-email-domains": "2.0.0",
129
+ "@visulima/redact": "5.0.0"
130
+ },
131
+ "peerDependencies": {
132
+ "@better-auth/core": ">=1.7.3 <2.0.0-0",
133
+ "@better-auth/sso": ">=1.7.3 <2.0.0-0",
134
+ "@lunora/server": ">=1.0.0-alpha.24 <2.0.0-0",
135
+ "better-auth": ">=1.7.16 <2.0.0-0"
136
+ },
137
+ "peerDependenciesMeta": {
138
+ "@better-auth/sso": {
139
+ "optional": true
140
+ }
90
141
  },
91
142
  "engines": {
92
143
  "node": "^22.15.0 || >=24.11.0"
@@ -1,11 +0,0 @@
1
- const DEFAULT_AUTH_BASE_PATH = "/api/auth";
2
- const handleAuthRequest = async (auth, request, basePath = DEFAULT_AUTH_BASE_PATH) => {
3
- const url = new URL(request.url);
4
- const base = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
5
- if (url.pathname !== base && !url.pathname.startsWith(`${base}/`)) {
6
- return void 0;
7
- }
8
- return auth.handler(request);
9
- };
10
-
11
- export { DEFAULT_AUTH_BASE_PATH, handleAuthRequest };