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

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 (224) hide show
  1. package/README.md +8 -14
  2. package/dist/{access-C6O_osEz.mjs → access-CrwEFPHE.mjs} +1 -1
  3. package/dist/{access-DT1f6l5k.mjs → access-bhklJd7m.mjs} +1 -1
  4. package/dist/{adapter-factory-BZ2Qiqpn.mjs → adapter-factory-xbLUJt85.mjs} +2 -2
  5. package/dist/adapters/drizzle-adapter/index.mjs +6 -5
  6. package/dist/adapters/index.d.mts +5 -5
  7. package/dist/adapters/index.mjs +6 -5
  8. package/dist/adapters/kysely-adapter/index.d.mts +1 -1
  9. package/dist/adapters/kysely-adapter/index.mjs +8 -7
  10. package/dist/adapters/memory-adapter/index.d.mts +1 -1
  11. package/dist/adapters/memory-adapter/index.mjs +6 -5
  12. package/dist/adapters/mongodb-adapter/index.mjs +6 -5
  13. package/dist/adapters/prisma-adapter/index.mjs +6 -5
  14. package/dist/adapters/test.mjs +4 -3
  15. package/dist/{admin-Bcq53Nwj.mjs → admin-BzUJL6tr.mjs} +6 -6
  16. package/dist/{anonymous-CRt1imBW.mjs → anonymous-BjlTk4gl.mjs} +5 -5
  17. package/dist/api/index.d.mts +5 -5
  18. package/dist/api/index.mjs +12 -11
  19. package/dist/{api-0pR_I-Nx.mjs → api-Dk8Yj_J5.mjs} +15 -5
  20. package/dist/audit-log-DKsUWR8O.mjs +772 -0
  21. package/dist/{auth-CBUoBX6o.mjs → auth-vfCyIIeV.mjs} +8 -8
  22. package/dist/{bearer-Djf_awfo.mjs → bearer-DvQLM00l.mjs} +2 -2
  23. package/dist/client/index.d.mts +21 -21
  24. package/dist/client/index.mjs +4 -4
  25. package/dist/client/plugins/index.d.mts +53 -45
  26. package/dist/client/plugins/index.mjs +16 -12
  27. package/dist/client/react/index.d.mts +19 -19
  28. package/dist/client/react/index.mjs +2 -2
  29. package/dist/client-4QEb0rUr.mjs +95 -0
  30. package/dist/client-CSOs1YN7.d.mts +14 -0
  31. package/dist/client-DZHNfxuR.d.mts +75 -0
  32. package/dist/client-DzOqXJUm.mjs +15 -0
  33. package/dist/{client-aExCkfwm.mjs → client-xga7yFIX.mjs} +2 -2
  34. package/dist/cookies/index.d.mts +6 -6
  35. package/dist/cookies/index.mjs +2 -2
  36. package/dist/{cookies-cJObLwn1.mjs → cookies-BuvlgcA-.mjs} +1 -1
  37. package/dist/crypto/index.mjs +2 -1
  38. package/dist/{crypto-Bb42eMrH.mjs → crypto-CCyta8xj.mjs} +1 -6
  39. package/dist/{custom-session-L3t7ecsd.mjs → custom-session-DN_-pfi_.mjs} +2 -2
  40. package/dist/db/index.d.mts +5 -5
  41. package/dist/db/index.mjs +9 -8
  42. package/dist/{db-BrstmDhc.mjs → db-7vHnL1XA.mjs} +15 -9
  43. package/dist/{device-authorization-V4s3h4Mj.mjs → device-authorization-BKnNhlsz.mjs} +4 -4
  44. package/dist/{dialect-CeddeGHf.mjs → dialect-HsWUfpYY.mjs} +2 -2
  45. package/dist/{email-otp-BtDHSw14.mjs → email-otp-Dw0DypjQ.mjs} +7 -6
  46. package/dist/{generic-oauth-CL5X27ZI.mjs → generic-oauth-DFj27JY8.mjs} +4 -4
  47. package/dist/{has-permission-BpAr7uCn.mjs → has-permission-Bvg8de8g.mjs} +1 -1
  48. package/dist/{haveibeenpwned-cMpJvmzI.mjs → haveibeenpwned-CzNda7Tn.mjs} +28 -15
  49. package/dist/{client-CNY0tn9g.d.mts → index-BAVzFqII.d.mts} +21 -21
  50. package/dist/{index-DaBcikv9.d.mts → index-BNDRYfTF.d.mts} +2 -2
  51. package/dist/{index-Cxi7TbLE.d.mts → index-BNhJglHC.d.mts} +122 -122
  52. package/dist/{index-BYMI9r_d.d.mts → index-Blmhq6eA.d.mts} +4 -4
  53. package/dist/{index-BHoQlf7a.d.mts → index-CKnPAS5n.d.mts} +178 -178
  54. package/dist/{index-34ONrP8l.d.mts → index-COGe8UJx.d.mts} +11 -11
  55. package/dist/{index-Buhn3hkR.d.mts → index-CP3FNbOZ.d.mts} +8 -8
  56. package/dist/{index-D_k662QG.d.mts → index-CUknVRZp.d.mts} +14 -14
  57. package/dist/{index-DKNNV1kb.d.mts → index-CaqpCfE5.d.mts} +8 -8
  58. package/dist/{index-BBm8nQ9Q.d.mts → index-CgeC2eGC.d.mts} +2 -2
  59. package/dist/{index-DR0xXno9.d.mts → index-CsxtcAO0.d.mts} +1 -1
  60. package/dist/{index-CuFzhoS6.d.mts → index-Cv9iMevV.d.mts} +10 -10
  61. package/dist/{index-C7fQuk-V.d.mts → index-CxlWnL9c.d.mts} +1 -1
  62. package/dist/{index-zjjNBRY2.d.mts → index-DG-X1PK5.d.mts} +6 -6
  63. package/dist/index-DRM35ir1.d.mts +3769 -0
  64. package/dist/{index-BqhKCbPH.d.mts → index-DS-R7st3.d.mts} +6 -6
  65. package/dist/{index-C-u1h_WX.d.mts → index-DXVU0HGr.d.mts} +5 -5
  66. package/dist/{index-DoXZYQpq.d.mts → index-Db8jqUq2.d.mts} +10 -10
  67. package/dist/{index-65G5U5DB-DSdjzreF.d.mts → index-Df0KhQRf-BEa5tdwJ.d.mts} +3 -2
  68. package/dist/{index-B-XKqFvY.d.mts → index-Df4SvZaE.d.mts} +11 -4
  69. package/dist/{index-G6V0Z_Mn.d.mts → index-DyH_CgmX.d.mts} +10 -10
  70. package/dist/{admin-DtfO1PLg.d.mts → index-EABwA_BH.d.mts} +36 -36
  71. package/dist/{index-z0KSvE5i.d.mts → index-QmocqGM-.d.mts} +1 -1
  72. package/dist/{index-DlaMq1nb.d.mts → index-mxEUX2Gs.d.mts} +14 -14
  73. package/dist/{client-BOX93C3d.d.mts → index-xoYsoOiR.d.mts} +52 -52
  74. package/dist/{index-B3n8e37d.d.mts → index-zBdYQGaS.d.mts} +7 -7
  75. package/dist/index.d.mts +5 -5
  76. package/dist/index.mjs +16 -15
  77. package/dist/integrations/next-js.mjs +2 -2
  78. package/dist/integrations/node.d.mts +5 -5
  79. package/dist/integrations/react-start.d.mts +4 -4
  80. package/dist/integrations/react-start.mjs +2 -2
  81. package/dist/{jwt-lHV4QHpD.mjs → jwt-DBN2mu0r.mjs} +4 -4
  82. package/dist/{kysely-adapter-DpzYO8Yf.mjs → kysely-adapter-Bkm1liPW.mjs} +1 -1
  83. package/dist/{magic-link-Bk-ueorR.mjs → magic-link-D9Em1aOR.mjs} +3 -3
  84. package/dist/{multi-session-DRrLKrg9.mjs → multi-session-Dno_8DxC.mjs} +5 -5
  85. package/dist/{oauth-proxy-D1sWh9B_.mjs → oauth-proxy-DW-zt8wv.mjs} +2 -2
  86. package/dist/oauth2/index.d.mts +5 -5
  87. package/dist/oauth2/index.mjs +12 -11
  88. package/dist/{one-tap-DMswkTEc.mjs → one-tap-CodeyQb8.mjs} +2 -2
  89. package/dist/{organization-BArHO_5v.mjs → organization-CkTKs7bx.mjs} +9 -9
  90. package/dist/{passkey-CcD4CnhM.mjs → passkey-JNQTz5a0.mjs} +5 -5
  91. package/dist/{phone-number-rHDIlh-2.mjs → phone-number-Dqz8aeyF.mjs} +4 -4
  92. package/dist/plugins/access/index.d.mts +2 -2
  93. package/dist/plugins/access/index.mjs +1 -1
  94. package/dist/plugins/admin/access/index.d.mts +2 -2
  95. package/dist/plugins/admin/access/index.mjs +2 -2
  96. package/dist/plugins/admin/index.d.mts +7 -8
  97. package/dist/plugins/admin/index.mjs +17 -16
  98. package/dist/plugins/anonymous/index.d.mts +6 -6
  99. package/dist/plugins/anonymous/index.mjs +13 -12
  100. package/dist/plugins/audit-log/client.d.mts +30 -0
  101. package/dist/plugins/audit-log/client.mjs +3 -0
  102. package/dist/plugins/audit-log/index.d.mts +29 -0
  103. package/dist/plugins/audit-log/index.mjs +20 -0
  104. package/dist/plugins/bearer/index.d.mts +1 -1
  105. package/dist/plugins/bearer/index.mjs +3 -3
  106. package/dist/plugins/captcha/index.d.mts +1 -1
  107. package/dist/plugins/captcha/index.mjs +1 -1
  108. package/dist/plugins/custom-session/index.d.mts +6 -6
  109. package/dist/plugins/custom-session/index.mjs +14 -13
  110. package/dist/plugins/device-authorization/index.d.mts +3 -3
  111. package/dist/plugins/device-authorization/index.mjs +13 -12
  112. package/dist/plugins/email-otp/index.d.mts +2 -2
  113. package/dist/plugins/email-otp/index.mjs +14 -13
  114. package/dist/plugins/generic-oauth/index.d.mts +6 -6
  115. package/dist/plugins/generic-oauth/index.mjs +13 -12
  116. package/dist/plugins/haveibeenpwned/index.d.mts +2 -2
  117. package/dist/plugins/haveibeenpwned/index.mjs +14 -13
  118. package/dist/plugins/index.d.mts +29 -139
  119. package/dist/plugins/index.mjs +47 -42
  120. package/dist/plugins/jwt/index.d.mts +6 -6
  121. package/dist/plugins/jwt/index.mjs +13 -12
  122. package/dist/plugins/magic-link/index.d.mts +1 -1
  123. package/dist/plugins/magic-link/index.mjs +13 -12
  124. package/dist/plugins/multi-session/index.d.mts +2 -2
  125. package/dist/plugins/multi-session/index.mjs +13 -12
  126. package/dist/plugins/oauth-proxy/index.d.mts +1 -1
  127. package/dist/plugins/oauth-proxy/index.mjs +13 -12
  128. package/dist/plugins/one-tap/index.d.mts +1 -1
  129. package/dist/plugins/one-tap/index.mjs +13 -12
  130. package/dist/plugins/one-time-token/index.d.mts +6 -6
  131. package/dist/plugins/one-time-token/index.mjs +46 -41
  132. package/dist/plugins/organization/access/index.d.mts +3 -3
  133. package/dist/plugins/organization/access/index.mjs +2 -2
  134. package/dist/plugins/organization/index.d.mts +8 -8
  135. package/dist/plugins/organization/index.mjs +17 -16
  136. package/dist/plugins/passkey/index.d.mts +6 -6
  137. package/dist/plugins/passkey/index.mjs +13 -12
  138. package/dist/plugins/phone-number/index.d.mts +6 -6
  139. package/dist/plugins/phone-number/index.mjs +13 -12
  140. package/dist/plugins/sentinel/client.d.mts +30 -0
  141. package/dist/plugins/sentinel/client.mjs +5 -0
  142. package/dist/plugins/sentinel/index.d.mts +29 -0
  143. package/dist/plugins/sentinel/index.mjs +22 -0
  144. package/dist/plugins/two-factor/index.d.mts +6 -6
  145. package/dist/plugins/two-factor/index.mjs +15 -14
  146. package/dist/plugins/username/index.d.mts +3 -3
  147. package/dist/plugins/username/index.mjs +13 -12
  148. package/dist/{plugins-hFZT3hmK.d.mts → plugins-Dy_FrD4Y.d.mts} +1 -1
  149. package/dist/{plugins-3jfNste3.mjs → plugins-yF8CFUDR.mjs} +11 -8
  150. package/dist/pow-OK01yPG3.mjs +61 -0
  151. package/dist/{proxy-CL9PZXJA.mjs → proxy-C_KXfOhk.mjs} +1 -1
  152. package/dist/random-32E3cU5o.mjs +7 -0
  153. package/dist/registry-CqG_3Qnx.mjs +194 -0
  154. package/dist/sentinel-C-D1IHJo.mjs +1395 -0
  155. package/dist/{session-Dgp133Yt.mjs → session-BB3oqApE.mjs} +2 -2
  156. package/dist/src/adapters/memory-adapter/memory-adapter.d.ts +1 -1
  157. package/dist/src/adapters/prisma-adapter/test/auth.d.ts +1 -1
  158. package/dist/src/adapters/tests/auth-flow.d.ts +3 -3
  159. package/dist/src/adapters/tests/normal.d.ts +1 -1
  160. package/dist/src/adapters/tests/number-id.d.ts +3 -3
  161. package/dist/src/adapters/tests/performance.d.ts +3 -3
  162. package/dist/src/adapters/tests/transactions.d.ts +3 -3
  163. package/dist/src/api/index.d.ts +8 -8
  164. package/dist/src/client/plugins/index.d.ts +2 -0
  165. package/dist/src/plugins/admin/admin.d.ts +2 -2
  166. package/dist/src/plugins/api-key/index.d.ts +2 -2
  167. package/dist/src/plugins/audit-log/client.d.ts +10 -0
  168. package/dist/src/plugins/audit-log/events.d.ts +90 -0
  169. package/dist/src/plugins/audit-log/index.d.ts +614 -0
  170. package/dist/src/plugins/audit-log/registry.d.ts +13 -0
  171. package/dist/src/plugins/audit-log/remote.d.ts +34 -0
  172. package/dist/src/plugins/audit-log/schema.d.ts +50 -0
  173. package/dist/src/plugins/audit-log/types.d.ts +117 -0
  174. package/dist/src/plugins/email-otp/index.d.ts +1 -1
  175. package/dist/src/plugins/haveibeenpwned/index.d.ts +6 -0
  176. package/dist/src/plugins/index.d.ts +2 -0
  177. package/dist/src/plugins/multi-session/index.d.ts +8 -8
  178. package/dist/src/plugins/organization/organization.d.ts +5 -5
  179. package/dist/src/plugins/organization/routes/crud-access-control.d.ts +8 -8
  180. package/dist/src/plugins/organization/routes/crud-invites.d.ts +46 -46
  181. package/dist/src/plugins/organization/routes/crud-members.d.ts +40 -40
  182. package/dist/src/plugins/organization/routes/crud-org.d.ts +36 -36
  183. package/dist/src/plugins/organization/routes/crud-team.d.ts +50 -50
  184. package/dist/src/plugins/sentinel/actions.d.ts +64 -0
  185. package/dist/src/plugins/sentinel/client.d.ts +67 -0
  186. package/dist/src/plugins/sentinel/email.d.ts +22 -0
  187. package/dist/src/plugins/sentinel/geo.d.ts +22 -0
  188. package/dist/src/plugins/sentinel/index.d.ts +326 -0
  189. package/dist/src/plugins/sentinel/intel.d.ts +45 -0
  190. package/dist/src/plugins/sentinel/pow.d.ts +21 -0
  191. package/dist/src/plugins/sentinel/schema.d.ts +110 -0
  192. package/dist/src/plugins/sentinel/store.d.ts +37 -0
  193. package/dist/src/plugins/sentinel/types.d.ts +412 -0
  194. package/dist/src/test-utils/memory-secondary-storage.d.ts +16 -0
  195. package/dist/src/test-utils/password.d.ts +12 -0
  196. package/dist/src/test-utils/test-instance.d.ts +25 -25
  197. package/dist/test-utils/index.d.mts +1048 -1048
  198. package/dist/test-utils/index.mjs +53 -48
  199. package/dist/{two-factor-ClUXxom2.mjs → two-factor-CDVjxx4f.mjs} +6 -5
  200. package/dist/types/index.d.mts +5 -5
  201. package/dist/types/index.mjs +1 -1
  202. package/dist/{username-DiGklOGl.mjs → username-BHNvcvsY.mjs} +3 -3
  203. package/dist/{utils-SOMB4Px5.mjs → utils-B03WRaGi.mjs} +2 -1
  204. package/package.json +36 -3
  205. package/dist/index-CM-CFWwr.d.mts +0 -1919
  206. package/dist/index-DB7t8whN.d.mts +0 -1
  207. /package/dist/{access-BO2g7QVe.mjs → access-BM6jSA5j.mjs} +0 -0
  208. /package/dist/{bun-sqlite-dialect-CeNvMaZz.mjs → bun-sqlite-dialect-CDGusFqF.mjs} +0 -0
  209. /package/dist/{captcha-BqaMxlKC.mjs → captcha-DGP9lCRe.mjs} +0 -0
  210. /package/dist/{client-CygJhqeB.mjs → client-BuveH3MN.mjs} +0 -0
  211. /package/dist/{client-WiN43tAS.mjs → client-cBiytuOL.mjs} +0 -0
  212. /package/dist/{date-Cx2yCiC4.mjs → date-CMr04reD.mjs} +0 -0
  213. /package/dist/{esm-C-QicDNz.mjs → esm-BbvI87Z2.mjs} +0 -0
  214. /package/dist/{get-tables-BQP7YW9c.mjs → get-tables-CKvSyDST.mjs} +0 -0
  215. /package/dist/{helper-tmxW3BHj.d.mts → helper-BgOIGHsu.d.mts} +0 -0
  216. /package/dist/{misc-beA1w3XV.mjs → misc-fKH4d5XQ.mjs} +0 -0
  217. /package/dist/{node-sqlite-dialect-BcKxBQnm.mjs → node-sqlite-dialect-CIOjcg31.mjs} +0 -0
  218. /package/dist/{parser-DcrIEuXE.mjs → parser-D7EkhAjZ.mjs} +0 -0
  219. /package/dist/{password-sVC4nePO.mjs → password-5CdcAVaH.mjs} +0 -0
  220. /package/dist/{permission-DLYUF3cW.mjs → permission-CDDWgA_O.mjs} +0 -0
  221. /package/dist/{plugin-helper-4L-lzsjZ.mjs → plugin-helper-RJJBTOba.mjs} +0 -0
  222. /package/dist/{promise-8rrEHRXd.mjs → promise-D7Oo6_cY.mjs} +0 -0
  223. /package/dist/{types-Bjn15Uy6.mjs → types-DCPpFKUB.mjs} +0 -0
  224. /package/dist/{types-B1OL7hyf.d.mts → types-DNQ9XQrB.d.mts} +0 -0
@@ -0,0 +1,412 @@
1
+ import type { User } from "../../types";
2
+ import type { InferOptionSchema } from "../../types/plugins";
3
+ import type { schema } from "./schema";
4
+ /**
5
+ * The action to take when a security check fails
6
+ *
7
+ * - `log`: record the event and let the request through
8
+ * - `challenge`: respond with `423` and a proof-of-work challenge
9
+ * - `block`: respond with `403`
10
+ */
11
+ export type SecurityAction = "log" | "challenge" | "block";
12
+ export type GeoLocation = {
13
+ /**
14
+ * ISO 3166-1 alpha-2 country code, e.g. "US"
15
+ */
16
+ country: string | null;
17
+ city?: string | null | undefined;
18
+ latitude?: number | null | undefined;
19
+ longitude?: number | null | undefined;
20
+ };
21
+ export interface SentinelOptions {
22
+ /**
23
+ * The hosted backend API URL
24
+ *
25
+ * @default process.env.PAYVO_INFRA_API_URL
26
+ */
27
+ apiUrl?: string | undefined;
28
+ /**
29
+ * The hosted backend API key
30
+ *
31
+ * @default process.env.PAYVO_INFRA_API_KEY
32
+ */
33
+ apiKey?: string | undefined;
34
+ /**
35
+ * The hosted identification service URL, used to check that visitor ids
36
+ * sent by clients are genuine
37
+ *
38
+ * @default process.env.PAYVO_INFRA_KV_URL
39
+ */
40
+ kvUrl?: string | undefined;
41
+ /**
42
+ * Identification service HTTP options
43
+ */
44
+ kvOptions?: {
45
+ /**
46
+ * Request timeout in milliseconds
47
+ *
48
+ * @default 1000
49
+ */
50
+ timeout?: number | undefined;
51
+ /**
52
+ * Retries after a failed request, with exponential backoff
53
+ *
54
+ * @default { attempts: 2, baseDelay: 400, maxDelay: 600 }
55
+ */
56
+ retry?: {
57
+ attempts?: number | undefined;
58
+ baseDelay?: number | undefined;
59
+ maxDelay?: number | undefined;
60
+ } | undefined;
61
+ /**
62
+ * Additional headers sent with every request
63
+ */
64
+ headers?: Record<string, string> | undefined;
65
+ } | undefined;
66
+ /**
67
+ * Hosted backend HTTP options
68
+ */
69
+ apiOptions?: {
70
+ /**
71
+ * Request timeout in milliseconds
72
+ *
73
+ * @default 3000
74
+ */
75
+ timeout?: number | undefined;
76
+ /**
77
+ * Additional headers sent with every request
78
+ */
79
+ headers?: Record<string, string> | undefined;
80
+ } | undefined;
81
+ /**
82
+ * Allow requests through when a check can't complete, e.g. the hosted
83
+ * backend or secondary storage is unavailable
84
+ *
85
+ * @default true
86
+ */
87
+ failOpen?: boolean | undefined;
88
+ /**
89
+ * Local providers that replace the hosted backend
90
+ */
91
+ providers?: {
92
+ /**
93
+ * Resolve the client IP of a request
94
+ *
95
+ * By default the IP is read from the configured IP address headers
96
+ */
97
+ getClientIp?: ((request: Request | Headers) => string | null) | undefined;
98
+ /**
99
+ * Whether an IP address is known to be malicious
100
+ */
101
+ isSuspiciousIp?: ((ip: string) => boolean | Promise<boolean>) | undefined;
102
+ /**
103
+ * Whether a request comes from an automated client
104
+ */
105
+ isBot?: ((request: Request) => boolean | Promise<boolean>) | undefined;
106
+ /**
107
+ * Resolve the location of an IP address
108
+ */
109
+ resolveGeo?: ((ip: string) => GeoLocation | null | Promise<GeoLocation | null>) | undefined;
110
+ } | undefined;
111
+ /**
112
+ * Send a security notification, e.g. by email. Required for
113
+ * `unknownDeviceNotification` and the stale account notifications.
114
+ */
115
+ sendNotification?: ((notification: {
116
+ type: "unknown-device" | "stale-account";
117
+ /**
118
+ * Who the notification is for
119
+ */
120
+ recipient: "user" | "admin";
121
+ /**
122
+ * The address to send the notification to
123
+ */
124
+ email: string;
125
+ user: User;
126
+ signIn: {
127
+ at: Date;
128
+ ipAddress: string | null;
129
+ userAgent: string | null;
130
+ /**
131
+ * City and country, when known, e.g. "Berlin, DE"
132
+ */
133
+ location: string | null;
134
+ };
135
+ /**
136
+ * Days since the account was last active, for stale accounts
137
+ */
138
+ daysInactive?: number | undefined;
139
+ }) => void | Promise<void>) | undefined;
140
+ security?: {
141
+ /**
142
+ * Detect credential stuffing by tracking failed sign-in attempts per
143
+ * visitor, falling back to the IP address
144
+ */
145
+ credentialStuffing?: {
146
+ enabled: boolean;
147
+ /**
148
+ * Set to `log` to only record attempts. Otherwise the thresholds
149
+ * decide between a challenge and a block.
150
+ *
151
+ * @default "challenge"
152
+ */
153
+ action?: SecurityAction | undefined;
154
+ /**
155
+ * Number of failed attempts before a challenge or a block
156
+ *
157
+ * @default { challenge: 3, block: 5 }
158
+ */
159
+ thresholds?: {
160
+ challenge: number;
161
+ block: number;
162
+ } | undefined;
163
+ /**
164
+ * Window in seconds in which failed attempts are counted
165
+ *
166
+ * @default 3600
167
+ */
168
+ windowSeconds?: number | undefined;
169
+ /**
170
+ * Seconds a visitor stays blocked after reaching the block
171
+ * threshold
172
+ *
173
+ * @default 900
174
+ */
175
+ cooldownSeconds?: number | undefined;
176
+ } | undefined;
177
+ /**
178
+ * Limit how often authentication operations can be performed
179
+ */
180
+ velocity?: {
181
+ enabled: boolean;
182
+ /**
183
+ * Number of authentication requests per visitor in the window
184
+ * before a challenge or a block
185
+ *
186
+ * @default { challenge: 10, block: 20 }
187
+ */
188
+ thresholds?: {
189
+ challenge: number;
190
+ block: number;
191
+ } | undefined;
192
+ /**
193
+ * Maximum sign-ups per visitor in the window
194
+ *
195
+ * @default 5
196
+ */
197
+ maxSignupsPerVisitor?: number | undefined;
198
+ /**
199
+ * Maximum password reset requests per IP address in the window
200
+ *
201
+ * @default 10
202
+ */
203
+ maxPasswordResetsPerIp?: number | undefined;
204
+ /**
205
+ * Maximum sign-in attempts per IP address in the window
206
+ *
207
+ * @default 50
208
+ */
209
+ maxSignInsPerIp?: number | undefined;
210
+ /**
211
+ * Window in seconds
212
+ *
213
+ * @default 3600
214
+ */
215
+ windowSeconds?: number | undefined;
216
+ /**
217
+ * Action when a `max*` limit is exceeded
218
+ *
219
+ * @default "challenge"
220
+ */
221
+ action?: SecurityAction | undefined;
222
+ } | undefined;
223
+ /**
224
+ * Limit how many accounts a visitor can create
225
+ */
226
+ freeTrialAbuse?: {
227
+ enabled: boolean;
228
+ /**
229
+ * Number of accounts a visitor already created before a
230
+ * challenge or a block. Takes precedence over
231
+ * `maxAccountsPerVisitor`.
232
+ */
233
+ thresholds?: {
234
+ challenge: number;
235
+ block: number;
236
+ } | undefined;
237
+ /**
238
+ * Maximum accounts per visitor
239
+ *
240
+ * @default 3
241
+ */
242
+ maxAccountsPerVisitor?: number | undefined;
243
+ /**
244
+ * How long sign-ups are remembered per visitor, in seconds.
245
+ * Clamped to between 1 and 365 days.
246
+ *
247
+ * @default 7776000 (90 days)
248
+ */
249
+ retentionSeconds?: number | undefined;
250
+ /**
251
+ * Action when `maxAccountsPerVisitor` is reached
252
+ *
253
+ * @default "block"
254
+ */
255
+ action?: SecurityAction | undefined;
256
+ } | undefined;
257
+ /**
258
+ * Detect automated clients. `true` challenges them.
259
+ */
260
+ botBlocking?: (boolean | {
261
+ action: SecurityAction;
262
+ }) | undefined;
263
+ /**
264
+ * Detect requests from IP addresses known to be malicious. `true`
265
+ * blocks them.
266
+ */
267
+ suspiciousIpBlocking?: (boolean | {
268
+ action: SecurityAction;
269
+ }) | undefined;
270
+ /**
271
+ * Proof-of-work difficulty, in leading zero bits of the solution hash
272
+ *
273
+ * @default 18
274
+ */
275
+ /**
276
+ * Notify users when they sign in from a device they haven't used
277
+ * before, identified by the visitor id
278
+ *
279
+ * @default false
280
+ */
281
+ unknownDeviceNotification?: boolean | undefined;
282
+ /**
283
+ * Detect sign-ins from locations too far apart to travel between in
284
+ * the time since the previous sign-in. Checked once the credentials
285
+ * are verified; a challenge blocks sign-ins that can't be repeated,
286
+ * like magic links and one-time codes.
287
+ */
288
+ impossibleTravel?: {
289
+ enabled: boolean;
290
+ /**
291
+ * Fastest realistic travel speed, in km/h
292
+ *
293
+ * @default 1000
294
+ */
295
+ maxSpeedKmh?: number | undefined;
296
+ /**
297
+ * @default "challenge"
298
+ */
299
+ action?: SecurityAction | undefined;
300
+ } | undefined;
301
+ /**
302
+ * Challenge or block requests by country. Use either `allowList`
303
+ * or `denyList`.
304
+ */
305
+ geoBlocking?: {
306
+ /**
307
+ * Only allow these countries (ISO 3166-1 alpha-2)
308
+ */
309
+ allowList?: string[] | undefined;
310
+ /**
311
+ * Block these countries (ISO 3166-1 alpha-2)
312
+ */
313
+ denyList?: string[] | undefined;
314
+ /**
315
+ * @default "block"
316
+ */
317
+ action?: Exclude<SecurityAction, "log"> | undefined;
318
+ } | undefined;
319
+ /**
320
+ * Check new passwords against known breaches. Only the first 5
321
+ * characters of the password's SHA-1 hash are sent.
322
+ */
323
+ compromisedPassword?: {
324
+ enabled: boolean;
325
+ /**
326
+ * @default "block"
327
+ */
328
+ action?: SecurityAction | undefined;
329
+ /**
330
+ * Minimum number of breaches a password must appear in
331
+ *
332
+ * @default 1
333
+ */
334
+ minBreachCount?: number | undefined;
335
+ } | undefined;
336
+ /**
337
+ * Reject disposable email addresses and invalid email domains on
338
+ * sign-up and email changes
339
+ */
340
+ emailValidation?: {
341
+ enabled: boolean;
342
+ /**
343
+ * - `low`: block known disposable domains
344
+ * - `medium`: also require MX records
345
+ * - `high`: also reject addresses that look generated
346
+ *
347
+ * @default "medium"
348
+ */
349
+ strictness?: ("low" | "medium" | "high") | undefined;
350
+ /**
351
+ * @default "block"
352
+ */
353
+ action?: SecurityAction | undefined;
354
+ /**
355
+ * Domains that skip every check (exact match)
356
+ */
357
+ domainAllowlist?: string[] | undefined;
358
+ } | undefined;
359
+ /**
360
+ * Match aliases of the same mailbox, e.g. `j.doe+news@gmail.com` and
361
+ * `jdoe@gmail.com`. Addresses are kept as typed; an alias of an
362
+ * existing account signs in to it and can't be used for a new one.
363
+ * Adds a `normalizedEmail` field to users, set for existing users on
364
+ * their next sign-in.
365
+ */
366
+ emailNormalization?: {
367
+ /**
368
+ * @default false
369
+ */
370
+ enabled?: boolean | undefined;
371
+ } | undefined;
372
+ /**
373
+ * Detect sign-ins to accounts that haven't been used for a long time.
374
+ * Checked once the credentials are verified. Accounts are tracked
375
+ * from their first sign-in after sentinel is enabled.
376
+ */
377
+ staleUsers?: {
378
+ enabled: boolean;
379
+ /**
380
+ * Days of inactivity after which an account is stale
381
+ *
382
+ * @default 90
383
+ */
384
+ staleDays?: number | undefined;
385
+ /**
386
+ * @default "log"
387
+ */
388
+ action?: SecurityAction | undefined;
389
+ /**
390
+ * Notify the user through `sendNotification`
391
+ *
392
+ * @default false
393
+ */
394
+ notifyUser?: boolean | undefined;
395
+ /**
396
+ * Notify `adminEmail` through `sendNotification`
397
+ *
398
+ * @default false
399
+ */
400
+ notifyAdmin?: boolean | undefined;
401
+ /**
402
+ * Required when `notifyAdmin` is true
403
+ */
404
+ adminEmail?: string | undefined;
405
+ } | undefined;
406
+ challengeDifficulty?: number | undefined;
407
+ } | undefined;
408
+ /**
409
+ * Custom schema for the sentinel plugin
410
+ */
411
+ schema?: InferOptionSchema<typeof schema> | undefined;
412
+ }
@@ -0,0 +1,16 @@
1
+ import type { SecondaryStorage } from "@gatwech/core/db";
2
+ /**
3
+ * In-memory secondary storage for tests. Expiry follows `Date.now()`, so it
4
+ * works with faked timers. The atomic operations are optional, to test both
5
+ * code paths.
6
+ */
7
+ export declare function createMemorySecondaryStorage(options?: {
8
+ increment?: boolean;
9
+ getAndDelete?: boolean;
10
+ }): {
11
+ storage: SecondaryStorage;
12
+ /** Keys that currently hold a value */
13
+ keys: () => string[];
14
+ /** The TTL, in seconds, a key was last written with */
15
+ ttl: (key: string) => number | undefined;
16
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Password hashing without key derivation, for tests that sign in many times
3
+ * and don't test hashing itself. Each real hash takes a few hundred
4
+ * milliseconds, which adds up when test files run in parallel.
5
+ */
6
+ export declare const fastPasswordHashing: {
7
+ hash(password: string): Promise<string>;
8
+ verify({ hash, password }: {
9
+ hash: string;
10
+ password: string;
11
+ }): Promise<boolean>;
12
+ };
@@ -2721,8 +2721,8 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
2721
2721
  returnHeaders?: ReturnHeaders | undefined;
2722
2722
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
2723
2723
  headers: Headers;
2724
- response: import("packages/core/dist/index-65G5U5DB.mjs").X;
2725
- } : import("packages/core/dist/index-65G5U5DB.mjs").X>;
2724
+ response: import("packages/core/dist/index-Df0KhQRf.mjs").X;
2725
+ } : import("packages/core/dist/index-Df0KhQRf.mjs").X>;
2726
2726
  options: {
2727
2727
  method: "POST";
2728
2728
  body: import("zod").ZodObject<{
@@ -2896,11 +2896,11 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
2896
2896
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
2897
2897
  headers: Headers;
2898
2898
  response: {
2899
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
2899
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
2900
2900
  data: Record<string, any>;
2901
2901
  } | null;
2902
2902
  } : {
2903
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
2903
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
2904
2904
  data: Record<string, any>;
2905
2905
  } | null>;
2906
2906
  options: {
@@ -5633,8 +5633,8 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
5633
5633
  returnHeaders?: ReturnHeaders | undefined;
5634
5634
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
5635
5635
  headers: Headers;
5636
- response: import("packages/core/dist/index-65G5U5DB.mjs").X;
5637
- } : import("packages/core/dist/index-65G5U5DB.mjs").X>;
5636
+ response: import("packages/core/dist/index-Df0KhQRf.mjs").X;
5637
+ } : import("packages/core/dist/index-Df0KhQRf.mjs").X>;
5638
5638
  options: {
5639
5639
  method: "POST";
5640
5640
  body: import("zod").ZodObject<{
@@ -5808,11 +5808,11 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
5808
5808
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
5809
5809
  headers: Headers;
5810
5810
  response: {
5811
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
5811
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
5812
5812
  data: Record<string, any>;
5813
5813
  } | null;
5814
5814
  } : {
5815
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
5815
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
5816
5816
  data: Record<string, any>;
5817
5817
  } | null>;
5818
5818
  options: {
@@ -8620,8 +8620,8 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
8620
8620
  returnHeaders?: ReturnHeaders | undefined;
8621
8621
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
8622
8622
  headers: Headers;
8623
- response: import("packages/core/dist/index-65G5U5DB.mjs").X;
8624
- } : import("packages/core/dist/index-65G5U5DB.mjs").X>;
8623
+ response: import("packages/core/dist/index-Df0KhQRf.mjs").X;
8624
+ } : import("packages/core/dist/index-Df0KhQRf.mjs").X>;
8625
8625
  options: {
8626
8626
  method: "POST";
8627
8627
  body: import("zod").ZodObject<{
@@ -8795,11 +8795,11 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
8795
8795
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
8796
8796
  headers: Headers;
8797
8797
  response: {
8798
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
8798
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
8799
8799
  data: Record<string, any>;
8800
8800
  } | null;
8801
8801
  } : {
8802
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
8802
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
8803
8803
  data: Record<string, any>;
8804
8804
  } | null>;
8805
8805
  options: {
@@ -11532,8 +11532,8 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
11532
11532
  returnHeaders?: ReturnHeaders | undefined;
11533
11533
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
11534
11534
  headers: Headers;
11535
- response: import("packages/core/dist/index-65G5U5DB.mjs").X;
11536
- } : import("packages/core/dist/index-65G5U5DB.mjs").X>;
11535
+ response: import("packages/core/dist/index-Df0KhQRf.mjs").X;
11536
+ } : import("packages/core/dist/index-Df0KhQRf.mjs").X>;
11537
11537
  options: {
11538
11538
  method: "POST";
11539
11539
  body: import("zod").ZodObject<{
@@ -11707,11 +11707,11 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
11707
11707
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
11708
11708
  headers: Headers;
11709
11709
  response: {
11710
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
11710
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
11711
11711
  data: Record<string, any>;
11712
11712
  } | null;
11713
11713
  } : {
11714
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
11714
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
11715
11715
  data: Record<string, any>;
11716
11716
  } | null>;
11717
11717
  options: {
@@ -14591,8 +14591,8 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
14591
14591
  returnHeaders?: ReturnHeaders | undefined;
14592
14592
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
14593
14593
  headers: Headers;
14594
- response: import("packages/core/dist/index-65G5U5DB.mjs").X;
14595
- } : import("packages/core/dist/index-65G5U5DB.mjs").X>;
14594
+ response: import("packages/core/dist/index-Df0KhQRf.mjs").X;
14595
+ } : import("packages/core/dist/index-Df0KhQRf.mjs").X>;
14596
14596
  options: {
14597
14597
  method: "POST";
14598
14598
  body: import("zod").ZodObject<{
@@ -14766,11 +14766,11 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
14766
14766
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
14767
14767
  headers: Headers;
14768
14768
  response: {
14769
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
14769
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
14770
14770
  data: Record<string, any>;
14771
14771
  } | null;
14772
14772
  } : {
14773
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
14773
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
14774
14774
  data: Record<string, any>;
14775
14775
  } | null>;
14776
14776
  options: {
@@ -17503,8 +17503,8 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
17503
17503
  returnHeaders?: ReturnHeaders | undefined;
17504
17504
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
17505
17505
  headers: Headers;
17506
- response: import("packages/core/dist/index-65G5U5DB.mjs").X;
17507
- } : import("packages/core/dist/index-65G5U5DB.mjs").X>;
17506
+ response: import("packages/core/dist/index-Df0KhQRf.mjs").X;
17507
+ } : import("packages/core/dist/index-Df0KhQRf.mjs").X>;
17508
17508
  options: {
17509
17509
  method: "POST";
17510
17510
  body: import("zod").ZodObject<{
@@ -17678,11 +17678,11 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
17678
17678
  }): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
17679
17679
  headers: Headers;
17680
17680
  response: {
17681
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
17681
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
17682
17682
  data: Record<string, any>;
17683
17683
  } | null;
17684
17684
  } : {
17685
- user: import("packages/core/dist/index-65G5U5DB.mjs").Z;
17685
+ user: import("packages/core/dist/index-Df0KhQRf.mjs").Z;
17686
17686
  data: Record<string, any>;
17687
17687
  } | null>;
17688
17688
  options: {
@@ -17844,6 +17844,6 @@ export declare function getTestInstance<O extends Partial<PayvoAuthOptions>, C e
17844
17844
  cookieSetter: typeof setCookieToHeader;
17845
17845
  customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
17846
17846
  sessionSetter: (headers: Headers) => (context: SuccessContext) => void;
17847
- db: import("packages/core/dist/index-65G5U5DB.mjs").nt<PayvoAuthOptions>;
17847
+ db: import("packages/core/dist/index-Df0KhQRf.mjs").nt<PayvoAuthOptions>;
17848
17848
  runWithUser: (email: string, password: string, fn: (headers: Headers) => Promise<void> | void) => Promise<void>;
17849
17849
  }>;