@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,13 +1,3 @@
1
- /**
2
- * Cloudflare Turnstile server-side verification.
3
- *
4
- * Turnstile has **no Cloudflare binding** — verification is a single HTTPS POST
5
- * to the public `siteverify` endpoint with your secret key. The secret lives in
6
- * a plain env var / `.dev.vars` (conventionally `TURNSTILE_SECRET_KEY`), not in
7
- * `wrangler.jsonc`. This module is therefore pure, transport-agnostic, and
8
- * usable from any mutation/action — not just the auth flow.
9
- * @see https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
10
- */
11
1
  /** Cloudflare's public Turnstile `siteverify` endpoint. */
12
2
  declare const TURNSTILE_VERIFY_ENDPOINT = "https://challenges.cloudflare.com/turnstile/v0/siteverify";
13
3
  /** Minimal `fetch` shape we depend on, so callers can inject a stub in tests. */
@@ -18,32 +8,32 @@ type FetchLike = (input: string, init?: {
18
8
  }) => Promise<Response>;
19
9
  interface VerifyTurnstileOptions {
20
10
  /**
21
- * Assert the widget `action` the token was solved for. Cloudflare echoes the
22
- * customer-supplied `action` back in the siteverify response; when this is
23
- * set and the returned `action` does not match, the verdict is downgraded to
24
- * `success: false` (with error code `action-mismatch`). Leave unset to skip
25
- * the check.
26
- */
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
+ */
27
17
  expectedAction?: string;
28
18
  /**
29
- * Assert the `hostname` the challenge was solved on. Cloudflare returns the
30
- * solving hostname in the siteverify response; when this is set and the
31
- * returned `hostname` does not match, the verdict is downgraded to
32
- * `success: false` (with error code `hostname-mismatch`). Set this when a
33
- * single secret/sitekey is shared across multiple domains to stop a token
34
- * harvested on one origin from being replayed against another. Leave unset
35
- * to skip the check.
36
- */
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
+ */
37
27
  expectedHostname?: string;
38
28
  /**
39
- * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. Primarily
40
- * for unit tests — production callers can omit it.
41
- */
29
+ * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. Primarily
30
+ * for unit tests — production callers can omit it.
31
+ */
42
32
  fetch?: FetchLike;
43
33
  /**
44
- * The visitor's IP address, if known. Optional; Cloudflare uses it as an
45
- * extra signal but verification works without it.
46
- */
34
+ * The visitor's IP address, if known. Optional; Cloudflare uses it as an
35
+ * extra signal but verification works without it.
36
+ */
47
37
  remoteip?: string;
48
38
  /** Your Turnstile secret key (the `TURNSTILE_SECRET_KEY` env var). */
49
39
  secret: string;
@@ -51,13 +41,13 @@ interface VerifyTurnstileOptions {
51
41
  token: string;
52
42
  }
53
43
  /**
54
- * The normalized result of a Turnstile verification. Snake-cased fields from
55
- * Cloudflare (`error-codes`, `challenge_ts`) are mapped to camelCase.
56
- *
57
- * A `success: false` verdict is a **bot/invalid-token** outcome, not an error —
58
- * it is returned, never thrown. `verifyTurnstile` only throws on transport
59
- * failure (network error, non-2xx response).
60
- */
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
+ */
61
51
  interface TurnstileVerifyResult {
62
52
  /** The customer-supplied `action` the widget was rendered with, if any. */
63
53
  action?: string;
@@ -66,9 +56,9 @@ interface TurnstileVerifyResult {
66
56
  /** ISO timestamp of the challenge, if Cloudflare returned one. */
67
57
  challengeTs?: string;
68
58
  /**
69
- * Cloudflare error codes for a failed verification (e.g.
70
- * `"invalid-input-response"`, `"timeout-or-duplicate"`). Empty on success.
71
- */
59
+ * Cloudflare error codes for a failed verification (e.g.
60
+ * `"invalid-input-response"`, `"timeout-or-duplicate"`). Empty on success.
61
+ */
72
62
  errorCodes: string[];
73
63
  /** Hostname the challenge was solved on, if Cloudflare returned one. */
74
64
  hostname?: string;
@@ -76,23 +66,16 @@ interface TurnstileVerifyResult {
76
66
  success: boolean;
77
67
  }
78
68
  /**
79
- * Verify a Turnstile token against Cloudflare's `siteverify` endpoint.
80
- *
81
- * POSTs `application/x-www-form-urlencoded` (`secret`, `response`=token, and an
82
- * optional `remoteip`) and returns the parsed verdict. A `success: false`
83
- * outcome (bot / invalid / expired token) is **returned**, not thrown — callers
84
- * decide how to react. The function throws a structural `LunoraError`-shaped
85
- * error (`{ name: "LunoraError", code: "SERVICE_UNAVAILABLE", status: 503 }`)
86
- * only when the siteverify call itself fails (network error or non-2xx), so a
87
- * "siteverify is down" failure is distinguishable from a "this is a bot"
88
- * verdict.
89
- */
90
- declare const verifyTurnstile: ({
91
- expectedAction,
92
- expectedHostname,
93
- fetch,
94
- remoteip,
95
- secret,
96
- token
97
- }: 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>;
98
81
  export { type FetchLike, TURNSTILE_VERIFY_ENDPOINT, type TurnstileVerifyResult, type VerifyTurnstileOptions, verifyTurnstile };
@@ -1,13 +1,3 @@
1
- /**
2
- * Cloudflare Turnstile server-side verification.
3
- *
4
- * Turnstile has **no Cloudflare binding** — verification is a single HTTPS POST
5
- * to the public `siteverify` endpoint with your secret key. The secret lives in
6
- * a plain env var / `.dev.vars` (conventionally `TURNSTILE_SECRET_KEY`), not in
7
- * `wrangler.jsonc`. This module is therefore pure, transport-agnostic, and
8
- * usable from any mutation/action — not just the auth flow.
9
- * @see https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
10
- */
11
1
  /** Cloudflare's public Turnstile `siteverify` endpoint. */
12
2
  declare const TURNSTILE_VERIFY_ENDPOINT = "https://challenges.cloudflare.com/turnstile/v0/siteverify";
13
3
  /** Minimal `fetch` shape we depend on, so callers can inject a stub in tests. */
@@ -18,32 +8,32 @@ type FetchLike = (input: string, init?: {
18
8
  }) => Promise<Response>;
19
9
  interface VerifyTurnstileOptions {
20
10
  /**
21
- * Assert the widget `action` the token was solved for. Cloudflare echoes the
22
- * customer-supplied `action` back in the siteverify response; when this is
23
- * set and the returned `action` does not match, the verdict is downgraded to
24
- * `success: false` (with error code `action-mismatch`). Leave unset to skip
25
- * the check.
26
- */
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
+ */
27
17
  expectedAction?: string;
28
18
  /**
29
- * Assert the `hostname` the challenge was solved on. Cloudflare returns the
30
- * solving hostname in the siteverify response; when this is set and the
31
- * returned `hostname` does not match, the verdict is downgraded to
32
- * `success: false` (with error code `hostname-mismatch`). Set this when a
33
- * single secret/sitekey is shared across multiple domains to stop a token
34
- * harvested on one origin from being replayed against another. Leave unset
35
- * to skip the check.
36
- */
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
+ */
37
27
  expectedHostname?: string;
38
28
  /**
39
- * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. Primarily
40
- * for unit tests — production callers can omit it.
41
- */
29
+ * Inject a `fetch` implementation. Defaults to `globalThis.fetch`. Primarily
30
+ * for unit tests — production callers can omit it.
31
+ */
42
32
  fetch?: FetchLike;
43
33
  /**
44
- * The visitor's IP address, if known. Optional; Cloudflare uses it as an
45
- * extra signal but verification works without it.
46
- */
34
+ * The visitor's IP address, if known. Optional; Cloudflare uses it as an
35
+ * extra signal but verification works without it.
36
+ */
47
37
  remoteip?: string;
48
38
  /** Your Turnstile secret key (the `TURNSTILE_SECRET_KEY` env var). */
49
39
  secret: string;
@@ -51,13 +41,13 @@ interface VerifyTurnstileOptions {
51
41
  token: string;
52
42
  }
53
43
  /**
54
- * The normalized result of a Turnstile verification. Snake-cased fields from
55
- * Cloudflare (`error-codes`, `challenge_ts`) are mapped to camelCase.
56
- *
57
- * A `success: false` verdict is a **bot/invalid-token** outcome, not an error —
58
- * it is returned, never thrown. `verifyTurnstile` only throws on transport
59
- * failure (network error, non-2xx response).
60
- */
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
+ */
61
51
  interface TurnstileVerifyResult {
62
52
  /** The customer-supplied `action` the widget was rendered with, if any. */
63
53
  action?: string;
@@ -66,9 +56,9 @@ interface TurnstileVerifyResult {
66
56
  /** ISO timestamp of the challenge, if Cloudflare returned one. */
67
57
  challengeTs?: string;
68
58
  /**
69
- * Cloudflare error codes for a failed verification (e.g.
70
- * `"invalid-input-response"`, `"timeout-or-duplicate"`). Empty on success.
71
- */
59
+ * Cloudflare error codes for a failed verification (e.g.
60
+ * `"invalid-input-response"`, `"timeout-or-duplicate"`). Empty on success.
61
+ */
72
62
  errorCodes: string[];
73
63
  /** Hostname the challenge was solved on, if Cloudflare returned one. */
74
64
  hostname?: string;
@@ -76,23 +66,16 @@ interface TurnstileVerifyResult {
76
66
  success: boolean;
77
67
  }
78
68
  /**
79
- * Verify a Turnstile token against Cloudflare's `siteverify` endpoint.
80
- *
81
- * POSTs `application/x-www-form-urlencoded` (`secret`, `response`=token, and an
82
- * optional `remoteip`) and returns the parsed verdict. A `success: false`
83
- * outcome (bot / invalid / expired token) is **returned**, not thrown — callers
84
- * decide how to react. The function throws a structural `LunoraError`-shaped
85
- * error (`{ name: "LunoraError", code: "SERVICE_UNAVAILABLE", status: 503 }`)
86
- * only when the siteverify call itself fails (network error or non-2xx), so a
87
- * "siteverify is down" failure is distinguishable from a "this is a bot"
88
- * verdict.
89
- */
90
- declare const verifyTurnstile: ({
91
- expectedAction,
92
- expectedHostname,
93
- fetch,
94
- remoteip,
95
- secret,
96
- token
97
- }: 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>;
98
81
  export { type FetchLike, TURNSTILE_VERIFY_ENDPOINT, type TurnstileVerifyResult, type VerifyTurnstileOptions, verifyTurnstile };
@@ -1,61 +1 @@
1
- const TURNSTILE_VERIFY_ENDPOINT = "https://challenges.cloudflare.com/turnstile/v0/siteverify";
2
- const asString = (value) => typeof value === "string" ? value : void 0;
3
- const asStringArray = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
4
- const verifyTurnstile = async ({
5
- expectedAction,
6
- expectedHostname,
7
- fetch = globalThis.fetch,
8
- remoteip,
9
- secret,
10
- token
11
- }) => {
12
- const body = new URLSearchParams({ response: token, secret });
13
- if (remoteip !== void 0 && remoteip !== "") {
14
- body.set("remoteip", remoteip);
15
- }
16
- let response;
17
- try {
18
- response = await fetch(TURNSTILE_VERIFY_ENDPOINT, {
19
- body: body.toString(),
20
- headers: { "content-type": "application/x-www-form-urlencoded" },
21
- method: "POST"
22
- });
23
- } catch (error) {
24
- throw Object.assign(new Error("turnstile siteverify request failed"), {
25
- cause: error,
26
- code: "SERVICE_UNAVAILABLE",
27
- name: "LunoraError",
28
- status: 503
29
- });
30
- }
31
- if (!response.ok) {
32
- throw Object.assign(new Error(`turnstile siteverify returned ${String(response.status)}`), {
33
- code: "SERVICE_UNAVAILABLE",
34
- name: "LunoraError",
35
- status: 503
36
- });
37
- }
38
- const raw = await response.json();
39
- const action = asString(raw.action);
40
- const hostname = asString(raw.hostname);
41
- const errorCodes = asStringArray(raw["error-codes"]);
42
- let success = raw.success === true;
43
- if (success && expectedHostname !== void 0 && hostname !== expectedHostname) {
44
- success = false;
45
- errorCodes.push("hostname-mismatch");
46
- }
47
- if (success && expectedAction !== void 0 && action !== expectedAction) {
48
- success = false;
49
- errorCodes.push("action-mismatch");
50
- }
51
- return {
52
- action,
53
- cdata: asString(raw.cdata),
54
- challengeTs: asString(raw.challenge_ts),
55
- errorCodes,
56
- hostname,
57
- success
58
- };
59
- };
60
-
61
- 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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/auth",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.200",
4
4
  "description": "Auth for Lunora — a thin better-auth wrapper: email/password, OAuth, plugins, D1-backed",
5
5
  "keywords": [
6
6
  "auth",
@@ -25,7 +25,7 @@
25
25
  "directory": "packages/auth"
26
26
  },
27
27
  "files": [
28
- "dist",
28
+ "./dist",
29
29
  "__assets__",
30
30
  "README.md",
31
31
  "LICENSE.md"
@@ -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"
@@ -82,10 +106,29 @@
82
106
  "access": "public"
83
107
  },
84
108
  "dependencies": {
85
- "@better-auth/passkey": "^1.6.19",
86
- "@lunora/server": "1.0.0-alpha.1",
87
- "@lunora/values": "1.0.0-alpha.1",
88
- "better-auth": "^1.6.19"
109
+ "@better-auth/api-key": "1.7.7",
110
+ "@better-auth/cimd": "1.7.7",
111
+ "@better-auth/mcp": "1.7.7",
112
+ "@better-auth/oauth-provider": "1.7.7",
113
+ "@better-auth/passkey": "1.7.7",
114
+ "@better-auth/scim": "1.7.7",
115
+ "@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
116
+ "@lunora/values": "1.0.0-alpha.61",
117
+ "@visulima/disposable-email-domains": "1.1.14",
118
+ "@visulima/email-verifier": "1.0.30",
119
+ "@visulima/free-email-domains": "1.0.1",
120
+ "@visulima/redact": "5.0.0"
121
+ },
122
+ "peerDependencies": {
123
+ "@better-auth/core": ">=1.7.3 <2.0.0-0",
124
+ "@better-auth/sso": ">=1.7.3 <2.0.0-0",
125
+ "@lunora/server": ">=1.0.0-alpha.24 <2.0.0-0",
126
+ "better-auth": ">=1.7.3 <2.0.0-0"
127
+ },
128
+ "peerDependenciesMeta": {
129
+ "@better-auth/sso": {
130
+ "optional": true
131
+ }
89
132
  },
90
133
  "engines": {
91
134
  "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 };