@gatwech/auth 1.0.0-beta.19 → 1.0.0-beta.20

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 (61) hide show
  1. package/dist/client/index.d.mts +16 -16
  2. package/dist/client/plugins/index.d.mts +45 -45
  3. package/dist/client/react/index.d.mts +14 -14
  4. package/dist/{client-DZHNfxuR.d.mts → client-C_qmyez2.d.mts} +4 -4
  5. package/dist/{client-CSOs1YN7.d.mts → client-F67q-Lbi.d.mts} +1 -1
  6. package/dist/{index-Blmhq6eA.d.mts → index-4I1YhYhk.d.mts} +4 -4
  7. package/dist/{index-mxEUX2Gs.d.mts → index-BX7rl07Z.d.mts} +13 -13
  8. package/dist/{index-xoYsoOiR.d.mts → index-Bml-PCqP.d.mts} +20 -20
  9. package/dist/{index-DG-X1PK5.d.mts → index-BsSKcKgO.d.mts} +5 -5
  10. package/dist/{index-CP3FNbOZ.d.mts → index-CBiGsvDd.d.mts} +7 -7
  11. package/dist/{index-CUknVRZp.d.mts → index-CC920PPp.d.mts} +13 -13
  12. package/dist/{index-zBdYQGaS.d.mts → index-CNd5jqLl.d.mts} +5 -5
  13. package/dist/{index-DS-R7st3.d.mts → index-CP8x1TFq.d.mts} +6 -6
  14. package/dist/{index-CaqpCfE5.d.mts → index-CofuaNMl.d.mts} +6 -6
  15. package/dist/{index-Cv9iMevV.d.mts → index-CzpdkTdv.d.mts} +9 -9
  16. package/dist/{index-DRM35ir1.d.mts → index-D57DuhZR.d.mts} +110 -110
  17. package/dist/{index-DXVU0HGr.d.mts → index-D6ku0rUC.d.mts} +4 -4
  18. package/dist/{index-BAVzFqII.d.mts → index-DFSRYWFI.d.mts} +6 -6
  19. package/dist/{index-CgeC2eGC.d.mts → index-DGeoJ4gu.d.mts} +2 -2
  20. package/dist/{index-DyH_CgmX.d.mts → index-DTkcY7xH.d.mts} +10 -10
  21. package/dist/{index-COGe8UJx.d.mts → index-Dnd8S4S4.d.mts} +8 -8
  22. package/dist/{index-Df4SvZaE.d.mts → index-DwPAddfE.d.mts} +3 -3
  23. package/dist/{index-Db8jqUq2.d.mts → index-DyXi7S2M.d.mts} +9 -9
  24. package/dist/{index-CKnPAS5n.d.mts → index-KhbNmMmG.d.mts} +165 -165
  25. package/dist/{index-EABwA_BH.d.mts → index-XfE0WjTN.d.mts} +32 -32
  26. package/dist/{index-BNDRYfTF.d.mts → index-sb-UFLuo.d.mts} +2 -2
  27. package/dist/integrations/next-js.d.mts +4 -4
  28. package/dist/integrations/react-start.d.mts +4 -4
  29. package/dist/plugins/admin/index.d.mts +1 -1
  30. package/dist/plugins/anonymous/index.d.mts +1 -1
  31. package/dist/plugins/audit-log/client.d.mts +22 -22
  32. package/dist/plugins/audit-log/index.d.mts +21 -21
  33. package/dist/plugins/bearer/index.d.mts +1 -1
  34. package/dist/plugins/captcha/index.d.mts +1 -1
  35. package/dist/plugins/custom-session/index.d.mts +1 -1
  36. package/dist/plugins/device-authorization/index.d.mts +1 -1
  37. package/dist/plugins/email-otp/index.d.mts +1 -1
  38. package/dist/plugins/generic-oauth/index.d.mts +1 -1
  39. package/dist/plugins/haveibeenpwned/index.d.mts +1 -1
  40. package/dist/plugins/index.d.mts +21 -21
  41. package/dist/plugins/index.mjs +1 -1
  42. package/dist/plugins/jwt/index.d.mts +1 -1
  43. package/dist/plugins/magic-link/index.d.mts +1 -1
  44. package/dist/plugins/multi-session/index.d.mts +1 -1
  45. package/dist/plugins/oauth-proxy/index.d.mts +1 -1
  46. package/dist/plugins/one-tap/index.d.mts +1 -1
  47. package/dist/plugins/one-time-token/index.d.mts +1 -1
  48. package/dist/plugins/one-time-token/index.mjs +1 -1
  49. package/dist/plugins/organization/index.d.mts +1 -1
  50. package/dist/plugins/passkey/index.d.mts +1 -1
  51. package/dist/plugins/phone-number/index.d.mts +1 -1
  52. package/dist/plugins/sentinel/client.d.mts +22 -22
  53. package/dist/plugins/sentinel/index.d.mts +21 -21
  54. package/dist/plugins/sentinel/index.mjs +1 -1
  55. package/dist/plugins/two-factor/index.d.mts +1 -1
  56. package/dist/plugins/username/index.d.mts +1 -1
  57. package/dist/{sentinel-C-D1IHJo.mjs → sentinel-DiPqydKG.mjs} +39 -8
  58. package/dist/src/plugins/sentinel/email.d.ts +9 -3
  59. package/dist/test-utils/index.d.mts +1042 -1042
  60. package/dist/test-utils/index.mjs +1 -1
  61. package/package.json +3 -3
@@ -3,5 +3,5 @@ import "../../index-BNhJglHC.mjs";
3
3
  import "../../types-DNQ9XQrB.mjs";
4
4
  import "../../index-Df0KhQRf-BEa5tdwJ.mjs";
5
5
  import "../../plugins-Dy_FrD4Y.mjs";
6
- import { n as UserWithPhoneNumber, r as phoneNumber, t as PhoneNumberOptions } from "../../index-CaqpCfE5.mjs";
6
+ import { n as UserWithPhoneNumber, r as phoneNumber, t as PhoneNumberOptions } from "../../index-CofuaNMl.mjs";
7
7
  export { PhoneNumberOptions, UserWithPhoneNumber, phoneNumber };
@@ -4,27 +4,27 @@ import "../../types-DNQ9XQrB.mjs";
4
4
  import "../../index-Df0KhQRf-BEa5tdwJ.mjs";
5
5
  import "../../plugins-Dy_FrD4Y.mjs";
6
6
  import "../../index-CxlWnL9c.mjs";
7
- import "../../index-EABwA_BH.mjs";
8
- import "../../index-zBdYQGaS.mjs";
9
- import "../../index-DRM35ir1.mjs";
10
- import "../../index-DS-R7st3.mjs";
11
- import "../../index-CgeC2eGC.mjs";
12
- import "../../index-DG-X1PK5.mjs";
13
- import "../../index-BAVzFqII.mjs";
14
- import "../../index-CUknVRZp.mjs";
15
- import "../../index-CP3FNbOZ.mjs";
16
- import "../../index-Df4SvZaE.mjs";
17
- import "../../index-COGe8UJx.mjs";
18
- import "../../index-Blmhq6eA.mjs";
19
- import "../../index-Db8jqUq2.mjs";
20
- import "../../index-DyH_CgmX.mjs";
21
- import "../../index-BNDRYfTF.mjs";
22
- import "../../index-DXVU0HGr.mjs";
7
+ import "../../index-XfE0WjTN.mjs";
8
+ import "../../index-CNd5jqLl.mjs";
9
+ import "../../index-D57DuhZR.mjs";
10
+ import "../../index-CP8x1TFq.mjs";
11
+ import "../../index-DGeoJ4gu.mjs";
12
+ import "../../index-BsSKcKgO.mjs";
13
+ import "../../index-DFSRYWFI.mjs";
14
+ import "../../index-CC920PPp.mjs";
15
+ import "../../index-CBiGsvDd.mjs";
16
+ import "../../index-DwPAddfE.mjs";
17
+ import "../../index-Dnd8S4S4.mjs";
18
+ import "../../index-4I1YhYhk.mjs";
19
+ import "../../index-DyXi7S2M.mjs";
20
+ import "../../index-DTkcY7xH.mjs";
21
+ import "../../index-sb-UFLuo.mjs";
22
+ import "../../index-D6ku0rUC.mjs";
23
23
  import "../../index-QmocqGM-.mjs";
24
- import "../../index-CKnPAS5n.mjs";
25
- import "../../index-CaqpCfE5.mjs";
26
- import "../../index-xoYsoOiR.mjs";
27
- import "../../index-mxEUX2Gs.mjs";
28
- import "../../index-Cv9iMevV.mjs";
29
- import { t as sentinelClient } from "../../client-DZHNfxuR.mjs";
24
+ import "../../index-KhbNmMmG.mjs";
25
+ import "../../index-CofuaNMl.mjs";
26
+ import "../../index-Bml-PCqP.mjs";
27
+ import "../../index-BX7rl07Z.mjs";
28
+ import "../../index-CzpdkTdv.mjs";
29
+ import { t as sentinelClient } from "../../client-C_qmyez2.mjs";
30
30
  export { sentinelClient };
@@ -4,26 +4,26 @@ import "../../types-DNQ9XQrB.mjs";
4
4
  import "../../index-Df0KhQRf-BEa5tdwJ.mjs";
5
5
  import "../../plugins-Dy_FrD4Y.mjs";
6
6
  import "../../index-CxlWnL9c.mjs";
7
- import "../../index-EABwA_BH.mjs";
8
- import "../../index-zBdYQGaS.mjs";
9
- import { S as SentinelOptions, _ as haversineDistanceKm, b as GeoLocation, c as sentinel, d as POW_SOLUTION_HEADER, f as createNonce, g as verifySolution, h as solveChallenge, l as POW_CHALLENGE_HEADER, m as parsePowHeader, p as hasLeadingZeroBits, u as POW_REASON_HEADER, v as normalizeEmail, x as SecurityAction, y as SENTINEL_ERROR_CODES } from "../../index-DRM35ir1.mjs";
10
- import "../../index-DS-R7st3.mjs";
11
- import "../../index-CgeC2eGC.mjs";
12
- import "../../index-DG-X1PK5.mjs";
13
- import "../../index-BAVzFqII.mjs";
14
- import "../../index-CUknVRZp.mjs";
15
- import "../../index-CP3FNbOZ.mjs";
16
- import "../../index-Df4SvZaE.mjs";
17
- import "../../index-COGe8UJx.mjs";
18
- import "../../index-Blmhq6eA.mjs";
19
- import "../../index-Db8jqUq2.mjs";
20
- import "../../index-DyH_CgmX.mjs";
21
- import "../../index-BNDRYfTF.mjs";
22
- import "../../index-DXVU0HGr.mjs";
7
+ import "../../index-XfE0WjTN.mjs";
8
+ import "../../index-CNd5jqLl.mjs";
9
+ import { S as SentinelOptions, _ as haversineDistanceKm, b as GeoLocation, c as sentinel, d as POW_SOLUTION_HEADER, f as createNonce, g as verifySolution, h as solveChallenge, l as POW_CHALLENGE_HEADER, m as parsePowHeader, p as hasLeadingZeroBits, u as POW_REASON_HEADER, v as normalizeEmail, x as SecurityAction, y as SENTINEL_ERROR_CODES } from "../../index-D57DuhZR.mjs";
10
+ import "../../index-CP8x1TFq.mjs";
11
+ import "../../index-DGeoJ4gu.mjs";
12
+ import "../../index-BsSKcKgO.mjs";
13
+ import "../../index-DFSRYWFI.mjs";
14
+ import "../../index-CC920PPp.mjs";
15
+ import "../../index-CBiGsvDd.mjs";
16
+ import "../../index-DwPAddfE.mjs";
17
+ import "../../index-Dnd8S4S4.mjs";
18
+ import "../../index-4I1YhYhk.mjs";
19
+ import "../../index-DyXi7S2M.mjs";
20
+ import "../../index-DTkcY7xH.mjs";
21
+ import "../../index-sb-UFLuo.mjs";
22
+ import "../../index-D6ku0rUC.mjs";
23
23
  import "../../index-QmocqGM-.mjs";
24
- import "../../index-CKnPAS5n.mjs";
25
- import "../../index-CaqpCfE5.mjs";
26
- import "../../index-xoYsoOiR.mjs";
27
- import "../../index-mxEUX2Gs.mjs";
28
- import "../../index-Cv9iMevV.mjs";
24
+ import "../../index-KhbNmMmG.mjs";
25
+ import "../../index-CofuaNMl.mjs";
26
+ import "../../index-Bml-PCqP.mjs";
27
+ import "../../index-BX7rl07Z.mjs";
28
+ import "../../index-CzpdkTdv.mjs";
29
29
  export { GeoLocation, POW_CHALLENGE_HEADER, POW_REASON_HEADER, POW_SOLUTION_HEADER, SENTINEL_ERROR_CODES, SecurityAction, SentinelOptions, createNonce, hasLeadingZeroBits, haversineDistanceKm, normalizeEmail, parsePowHeader, sentinel, solveChallenge, verifySolution };
@@ -17,6 +17,6 @@ import "../../session-BB3oqApE.mjs";
17
17
  import "../../registry-CqG_3Qnx.mjs";
18
18
  import "../../haveibeenpwned-CzNda7Tn.mjs";
19
19
  import { a as hasLeadingZeroBits, c as verifySolution, i as createNonce, n as POW_REASON_HEADER, o as parsePowHeader, r as POW_SOLUTION_HEADER, s as solveChallenge, t as POW_CHALLENGE_HEADER } from "../../pow-OK01yPG3.mjs";
20
- import { i as SENTINEL_ERROR_CODES, n as haversineDistanceKm, r as normalizeEmail, t as sentinel } from "../../sentinel-C-D1IHJo.mjs";
20
+ import { i as SENTINEL_ERROR_CODES, n as haversineDistanceKm, r as normalizeEmail, t as sentinel } from "../../sentinel-DiPqydKG.mjs";
21
21
 
22
22
  export { POW_CHALLENGE_HEADER, POW_REASON_HEADER, POW_SOLUTION_HEADER, SENTINEL_ERROR_CODES, createNonce, hasLeadingZeroBits, haversineDistanceKm, normalizeEmail, parsePowHeader, sentinel, solveChallenge, verifySolution };
@@ -3,5 +3,5 @@ import "../../index-BNhJglHC.mjs";
3
3
  import "../../types-DNQ9XQrB.mjs";
4
4
  import "../../index-Df0KhQRf-BEa5tdwJ.mjs";
5
5
  import "../../plugins-Dy_FrD4Y.mjs";
6
- import { a as TwoFactorProvider, i as TwoFactorOptions, n as twoFactorClient, o as TwoFactorTable, r as TWO_FACTOR_ERROR_CODES, s as UserWithTwoFactor, t as twoFactor } from "../../index-xoYsoOiR.mjs";
6
+ import { a as TwoFactorProvider, i as TwoFactorOptions, n as twoFactorClient, o as TwoFactorTable, r as TWO_FACTOR_ERROR_CODES, s as UserWithTwoFactor, t as twoFactor } from "../../index-Bml-PCqP.mjs";
7
7
  export { TWO_FACTOR_ERROR_CODES, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, UserWithTwoFactor, twoFactor, twoFactorClient };
@@ -1,4 +1,4 @@
1
1
  import "../../helper-BgOIGHsu.mjs";
2
2
  import "../../plugins-Dy_FrD4Y.mjs";
3
- import { n as username, r as USERNAME_ERROR_CODES, t as UsernameOptions } from "../../index-Cv9iMevV.mjs";
3
+ import { n as username, r as USERNAME_ERROR_CODES, t as UsernameOptions } from "../../index-CzpdkTdv.mjs";
4
4
  export { USERNAME_ERROR_CODES, UsernameOptions, username };
@@ -194,23 +194,54 @@ async function isDisposableDomain(domain) {
194
194
  for (let i = 0; i < labels.length - 1; i++) if (isDisposable(labels.slice(i).join("."))) return true;
195
195
  return false;
196
196
  }
197
+ /** How long a mail lookup may take before it counts as unknown */
198
+ const MAIL_LOOKUP_TIMEOUT_MS = 2e3;
199
+ /** The lookup found nothing, as opposed to failing */
200
+ const isMissingRecord = (e) => {
201
+ const code = e.code;
202
+ return code === "ENOTFOUND" || code === "ENODATA" || code === "ENOTIMP";
203
+ };
204
+ /** Whether a domain has an A or AAAA record, null when a lookup failed */
205
+ async function hasAddressRecords(dns, domain) {
206
+ const results = await Promise.allSettled([dns.resolve4(domain), dns.resolve6(domain)]);
207
+ if (results.some((r) => r.status === "fulfilled" && r.value.length > 0)) return true;
208
+ return results.some((r) => r.status === "rejected" && !isMissingRecord(r.reason)) ? null : false;
209
+ }
210
+ async function lookupMail(dns, domain) {
211
+ try {
212
+ const records = await dns.resolveMx(domain);
213
+ if (records.length === 1 && (records[0].exchange === "" || records[0].exchange === ".")) return false;
214
+ if (records.length > 0) return true;
215
+ } catch (e) {
216
+ const code = e.code;
217
+ if (code === "ENOTFOUND" || code === "ENOTIMP") return false;
218
+ if (!isMissingRecord(e)) return null;
219
+ }
220
+ return hasAddressRecords(dns, domain);
221
+ }
197
222
  /**
198
- * Whether a domain has at least one MX record. Returns null when the lookup
199
- * isn't possible, e.g. on runtimes without DNS access.
223
+ * Whether a domain can receive mail: it has an MX record, or an address
224
+ * record to fall back to when it has none. A null MX record, which marks a
225
+ * domain that accepts no mail, doesn't count.
226
+ *
227
+ * Returns null when that can't be told: runtimes without DNS access, lookup
228
+ * failures, or a lookup that takes longer than `timeoutMs`.
200
229
  */
201
- async function hasMxRecords(domain) {
230
+ async function hasMxRecords(domain, options = {}) {
202
231
  let dns;
203
232
  try {
204
233
  dns = await import("node:dns/promises");
205
234
  } catch {
206
235
  return null;
207
236
  }
237
+ let timer;
238
+ const timeout = new Promise((resolve) => {
239
+ timer = setTimeout(() => resolve(null), options.timeoutMs ?? MAIL_LOOKUP_TIMEOUT_MS);
240
+ });
208
241
  try {
209
- return (await dns.resolveMx(domain)).length > 0;
210
- } catch (e) {
211
- const code = e.code;
212
- if (code === "ENOTFOUND" || code === "ENODATA" || code === "ENOTIMP") return false;
213
- return null;
242
+ return await Promise.race([lookupMail(dns, domain), timeout]);
243
+ } finally {
244
+ clearTimeout(timer);
214
245
  }
215
246
  }
216
247
  /**
@@ -11,10 +11,16 @@ export declare function getEmailDomain(email: string): string;
11
11
  */
12
12
  export declare function isDisposableDomain(domain: string): Promise<boolean>;
13
13
  /**
14
- * Whether a domain has at least one MX record. Returns null when the lookup
15
- * isn't possible, e.g. on runtimes without DNS access.
14
+ * Whether a domain can receive mail: it has an MX record, or an address
15
+ * record to fall back to when it has none. A null MX record, which marks a
16
+ * domain that accepts no mail, doesn't count.
17
+ *
18
+ * Returns null when that can't be told: runtimes without DNS access, lookup
19
+ * failures, or a lookup that takes longer than `timeoutMs`.
16
20
  */
17
- export declare function hasMxRecords(domain: string): Promise<boolean | null>;
21
+ export declare function hasMxRecords(domain: string, options?: {
22
+ timeoutMs?: number | undefined;
23
+ }): Promise<boolean | null>;
18
24
  /**
19
25
  * Heuristics for addresses that look generated rather than chosen by a
20
26
  * person