@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,614 @@
1
+ import type { AuthContext } from "@gatwech/core";
2
+ import * as z from "zod";
3
+ import { type AuditEventType } from "./events";
4
+ import { schema } from "./schema";
5
+ import type { AuditEvent, AuditLogOptions } from "./types";
6
+ export * from "./events";
7
+ export type * from "./types";
8
+ export declare const AUDIT_LOG_ERROR_CODES: {
9
+ readonly AUDIT_LOG_ACCESS_DENIED: "You don't have access to these audit logs";
10
+ readonly AUDIT_LOG_UNAVAILABLE: "Audit logs are temporarily unavailable";
11
+ };
12
+ export declare const auditLog: (options?: AuditLogOptions | undefined) => {
13
+ id: "audit-log";
14
+ init(ctx: AuthContext<import("@gatwech/core").PayvoAuthOptions>): {
15
+ options: {
16
+ databaseHooks: {
17
+ user: {
18
+ create: {
19
+ after(user: {
20
+ id: string;
21
+ createdAt: Date;
22
+ updatedAt: Date;
23
+ email: string;
24
+ emailVerified: boolean;
25
+ name: string;
26
+ image?: string | null | undefined;
27
+ } & Record<string, unknown>, context: import("@gatwech/core").GenericEndpointContext<import("@gatwech/core").PayvoAuthOptions> | undefined): Promise<void>;
28
+ };
29
+ update: {
30
+ before(data: Partial<{
31
+ id: string;
32
+ createdAt: Date;
33
+ updatedAt: Date;
34
+ email: string;
35
+ emailVerified: boolean;
36
+ name: string;
37
+ image?: string | null | undefined;
38
+ }> & Record<string, unknown>, context: import("@gatwech/core").GenericEndpointContext<import("@gatwech/core").PayvoAuthOptions> | undefined): Promise<{
39
+ data: Partial<{
40
+ id: string;
41
+ createdAt: Date;
42
+ updatedAt: Date;
43
+ email: string;
44
+ emailVerified: boolean;
45
+ name: string;
46
+ image?: string | null | undefined;
47
+ }> & Record<string, unknown>;
48
+ }>;
49
+ after(user: {
50
+ id: string;
51
+ createdAt: Date;
52
+ updatedAt: Date;
53
+ email: string;
54
+ emailVerified: boolean;
55
+ name: string;
56
+ image?: string | null | undefined;
57
+ } & Record<string, unknown>, context: import("@gatwech/core").GenericEndpointContext<import("@gatwech/core").PayvoAuthOptions> | undefined): Promise<void>;
58
+ };
59
+ delete: {
60
+ after(user: {
61
+ id: string;
62
+ createdAt: Date;
63
+ updatedAt: Date;
64
+ email: string;
65
+ emailVerified: boolean;
66
+ name: string;
67
+ image?: string | null | undefined;
68
+ } & Record<string, unknown>, context: import("@gatwech/core").GenericEndpointContext<import("@gatwech/core").PayvoAuthOptions> | undefined): Promise<void>;
69
+ };
70
+ };
71
+ session: {
72
+ create: {
73
+ after(session: {
74
+ id: string;
75
+ createdAt: Date;
76
+ updatedAt: Date;
77
+ userId: string;
78
+ expiresAt: Date;
79
+ token: string;
80
+ ipAddress?: string | null | undefined;
81
+ userAgent?: string | null | undefined;
82
+ } & Record<string, unknown>, context: import("@gatwech/core").GenericEndpointContext<import("@gatwech/core").PayvoAuthOptions> | undefined): Promise<void>;
83
+ };
84
+ };
85
+ account: {
86
+ create: {
87
+ after(account: {
88
+ id: string;
89
+ createdAt: Date;
90
+ updatedAt: Date;
91
+ providerId: string;
92
+ accountId: string;
93
+ userId: string;
94
+ accessToken?: string | null | undefined;
95
+ refreshToken?: string | null | undefined;
96
+ idToken?: string | null | undefined;
97
+ accessTokenExpiresAt?: Date | null | undefined;
98
+ refreshTokenExpiresAt?: Date | null | undefined;
99
+ scope?: string | null | undefined;
100
+ password?: string | null | undefined;
101
+ }, context: import("@gatwech/core").GenericEndpointContext<import("@gatwech/core").PayvoAuthOptions> | undefined): Promise<void>;
102
+ };
103
+ };
104
+ };
105
+ };
106
+ };
107
+ hooks: {
108
+ before: {
109
+ matcher(context: import("@gatwech/core").HookEndpointContext): boolean;
110
+ handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
111
+ }[];
112
+ after: {
113
+ matcher(context: import("@gatwech/core").HookEndpointContext): boolean;
114
+ handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
115
+ }[];
116
+ };
117
+ endpoints: {
118
+ getAuditLogs: {
119
+ <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
120
+ body?: undefined;
121
+ } & {
122
+ method?: "GET" | undefined;
123
+ } & {
124
+ query?: {
125
+ limit?: string | number | undefined;
126
+ offset?: string | number | undefined;
127
+ eventType?: string | undefined;
128
+ identifier?: string | undefined;
129
+ organizationId?: string | undefined;
130
+ userId?: string | undefined;
131
+ startDate?: string | undefined;
132
+ endDate?: string | undefined;
133
+ } | undefined;
134
+ } & {
135
+ params?: Record<string, any>;
136
+ } & {
137
+ request?: Request;
138
+ } & {
139
+ headers?: HeadersInit;
140
+ } & {
141
+ asResponse?: boolean;
142
+ returnHeaders?: boolean;
143
+ use?: import("better-call").Middleware[];
144
+ path?: string;
145
+ } & {
146
+ asResponse?: AsResponse | undefined;
147
+ returnHeaders?: ReturnHeaders | undefined;
148
+ }) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
149
+ headers: Headers;
150
+ response: {
151
+ events: AuditEvent[];
152
+ total: number;
153
+ limit: number;
154
+ offset: number;
155
+ };
156
+ } : {
157
+ events: AuditEvent[];
158
+ total: number;
159
+ limit: number;
160
+ offset: number;
161
+ }>;
162
+ options: {
163
+ method: "GET";
164
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
165
+ session: {
166
+ session: Record<string, any> & {
167
+ id: string;
168
+ createdAt: Date;
169
+ updatedAt: Date;
170
+ userId: string;
171
+ expiresAt: Date;
172
+ token: string;
173
+ ipAddress?: string | null | undefined;
174
+ userAgent?: string | null | undefined;
175
+ };
176
+ user: Record<string, any> & {
177
+ id: string;
178
+ createdAt: Date;
179
+ updatedAt: Date;
180
+ email: string;
181
+ emailVerified: boolean;
182
+ name: string;
183
+ image?: string | null | undefined;
184
+ };
185
+ };
186
+ }>)[];
187
+ query: z.ZodOptional<z.ZodObject<{
188
+ limit: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
189
+ offset: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
190
+ eventType: z.ZodOptional<z.ZodString>;
191
+ identifier: z.ZodOptional<z.ZodString>;
192
+ organizationId: z.ZodOptional<z.ZodString>;
193
+ userId: z.ZodOptional<z.ZodString>;
194
+ startDate: z.ZodOptional<z.ZodString>;
195
+ endDate: z.ZodOptional<z.ZodString>;
196
+ }, z.core.$strip>>;
197
+ metadata: {
198
+ openapi: {
199
+ operationId: string;
200
+ summary: string;
201
+ description: string;
202
+ responses: {
203
+ 200: {
204
+ description: string;
205
+ content: {
206
+ "application/json": {
207
+ schema: {
208
+ type: "object";
209
+ properties: {
210
+ events: {
211
+ type: string;
212
+ items: {
213
+ type: string;
214
+ properties: {
215
+ id: {
216
+ type: string;
217
+ };
218
+ eventType: {
219
+ type: string;
220
+ };
221
+ status: {
222
+ type: string;
223
+ };
224
+ userId: {
225
+ type: string;
226
+ nullable: boolean;
227
+ };
228
+ identifier: {
229
+ type: string;
230
+ nullable: boolean;
231
+ };
232
+ organizationId: {
233
+ type: string;
234
+ nullable: boolean;
235
+ };
236
+ path: {
237
+ type: string;
238
+ nullable: boolean;
239
+ };
240
+ ipAddress: {
241
+ type: string;
242
+ nullable: boolean;
243
+ };
244
+ userAgent: {
245
+ type: string;
246
+ nullable: boolean;
247
+ };
248
+ visitorId: {
249
+ type: string;
250
+ nullable: boolean;
251
+ };
252
+ eventData: {
253
+ type: string;
254
+ nullable: boolean;
255
+ };
256
+ createdAt: {
257
+ type: string;
258
+ format: string;
259
+ };
260
+ };
261
+ };
262
+ };
263
+ total: {
264
+ type: string;
265
+ };
266
+ limit: {
267
+ type: string;
268
+ };
269
+ offset: {
270
+ type: string;
271
+ };
272
+ };
273
+ required: string[];
274
+ };
275
+ };
276
+ };
277
+ };
278
+ };
279
+ };
280
+ };
281
+ } & {
282
+ use: any[];
283
+ };
284
+ path: "/audit-log/get-audit-logs";
285
+ };
286
+ getAllAuditLogs: {
287
+ <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
288
+ body?: undefined;
289
+ } & {
290
+ method?: "GET" | undefined;
291
+ } & {
292
+ query?: {
293
+ limit?: string | number | undefined;
294
+ offset?: string | number | undefined;
295
+ eventType?: string | undefined;
296
+ identifier?: string | undefined;
297
+ organizationId?: string | undefined;
298
+ userId?: string | undefined;
299
+ startDate?: string | undefined;
300
+ endDate?: string | undefined;
301
+ } | undefined;
302
+ } & {
303
+ params?: Record<string, any>;
304
+ } & {
305
+ request?: Request;
306
+ } & {
307
+ headers?: HeadersInit;
308
+ } & {
309
+ asResponse?: boolean;
310
+ returnHeaders?: boolean;
311
+ use?: import("better-call").Middleware[];
312
+ path?: string;
313
+ } & {
314
+ asResponse?: AsResponse | undefined;
315
+ returnHeaders?: ReturnHeaders | undefined;
316
+ }) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
317
+ headers: Headers;
318
+ response: {
319
+ events: AuditEvent[];
320
+ total: number;
321
+ limit: number;
322
+ offset: number;
323
+ };
324
+ } : {
325
+ events: AuditEvent[];
326
+ total: number;
327
+ limit: number;
328
+ offset: number;
329
+ }>;
330
+ options: {
331
+ method: "GET";
332
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
333
+ session: {
334
+ session: Record<string, any> & {
335
+ id: string;
336
+ createdAt: Date;
337
+ updatedAt: Date;
338
+ userId: string;
339
+ expiresAt: Date;
340
+ token: string;
341
+ ipAddress?: string | null | undefined;
342
+ userAgent?: string | null | undefined;
343
+ };
344
+ user: Record<string, any> & {
345
+ id: string;
346
+ createdAt: Date;
347
+ updatedAt: Date;
348
+ email: string;
349
+ emailVerified: boolean;
350
+ name: string;
351
+ image?: string | null | undefined;
352
+ };
353
+ };
354
+ }>)[];
355
+ query: z.ZodOptional<z.ZodObject<{
356
+ limit: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
357
+ offset: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
358
+ eventType: z.ZodOptional<z.ZodString>;
359
+ identifier: z.ZodOptional<z.ZodString>;
360
+ organizationId: z.ZodOptional<z.ZodString>;
361
+ userId: z.ZodOptional<z.ZodString>;
362
+ startDate: z.ZodOptional<z.ZodString>;
363
+ endDate: z.ZodOptional<z.ZodString>;
364
+ }, z.core.$strip>>;
365
+ metadata: {
366
+ openapi: {
367
+ operationId: string;
368
+ summary: string;
369
+ description: string;
370
+ responses: {
371
+ 200: {
372
+ description: string;
373
+ content: {
374
+ "application/json": {
375
+ schema: {
376
+ type: "object";
377
+ properties: {
378
+ events: {
379
+ type: string;
380
+ items: {
381
+ type: string;
382
+ properties: {
383
+ id: {
384
+ type: string;
385
+ };
386
+ eventType: {
387
+ type: string;
388
+ };
389
+ status: {
390
+ type: string;
391
+ };
392
+ userId: {
393
+ type: string;
394
+ nullable: boolean;
395
+ };
396
+ identifier: {
397
+ type: string;
398
+ nullable: boolean;
399
+ };
400
+ organizationId: {
401
+ type: string;
402
+ nullable: boolean;
403
+ };
404
+ path: {
405
+ type: string;
406
+ nullable: boolean;
407
+ };
408
+ ipAddress: {
409
+ type: string;
410
+ nullable: boolean;
411
+ };
412
+ userAgent: {
413
+ type: string;
414
+ nullable: boolean;
415
+ };
416
+ visitorId: {
417
+ type: string;
418
+ nullable: boolean;
419
+ };
420
+ eventData: {
421
+ type: string;
422
+ nullable: boolean;
423
+ };
424
+ createdAt: {
425
+ type: string;
426
+ format: string;
427
+ };
428
+ };
429
+ };
430
+ };
431
+ total: {
432
+ type: string;
433
+ };
434
+ limit: {
435
+ type: string;
436
+ };
437
+ offset: {
438
+ type: string;
439
+ };
440
+ };
441
+ required: string[];
442
+ };
443
+ };
444
+ };
445
+ };
446
+ };
447
+ };
448
+ };
449
+ } & {
450
+ use: any[];
451
+ };
452
+ path: "/audit-log/get-all-audit-logs";
453
+ };
454
+ getEventTypes: {
455
+ <AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
456
+ body?: undefined;
457
+ } & {
458
+ method?: "GET" | undefined;
459
+ } & {
460
+ query?: Record<string, any> | undefined;
461
+ } & {
462
+ params?: Record<string, any>;
463
+ } & {
464
+ request?: Request;
465
+ } & {
466
+ headers?: HeadersInit;
467
+ } & {
468
+ asResponse?: boolean;
469
+ returnHeaders?: boolean;
470
+ use?: import("better-call").Middleware[];
471
+ path?: string;
472
+ } & {
473
+ asResponse?: AsResponse | undefined;
474
+ returnHeaders?: ReturnHeaders | undefined;
475
+ }) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
476
+ headers: Headers;
477
+ response: {
478
+ types: AuditEventType[];
479
+ };
480
+ } : {
481
+ types: AuditEventType[];
482
+ }>;
483
+ options: {
484
+ method: "GET";
485
+ use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
486
+ session: {
487
+ session: Record<string, any> & {
488
+ id: string;
489
+ createdAt: Date;
490
+ updatedAt: Date;
491
+ userId: string;
492
+ expiresAt: Date;
493
+ token: string;
494
+ ipAddress?: string | null | undefined;
495
+ userAgent?: string | null | undefined;
496
+ };
497
+ user: Record<string, any> & {
498
+ id: string;
499
+ createdAt: Date;
500
+ updatedAt: Date;
501
+ email: string;
502
+ emailVerified: boolean;
503
+ name: string;
504
+ image?: string | null | undefined;
505
+ };
506
+ };
507
+ }>)[];
508
+ metadata: {
509
+ openapi: {
510
+ operationId: string;
511
+ summary: string;
512
+ description: string;
513
+ responses: {
514
+ 200: {
515
+ description: string;
516
+ content: {
517
+ "application/json": {
518
+ schema: {
519
+ type: "object";
520
+ properties: {
521
+ types: {
522
+ type: string;
523
+ items: {
524
+ type: string;
525
+ };
526
+ };
527
+ };
528
+ required: string[];
529
+ };
530
+ };
531
+ };
532
+ };
533
+ };
534
+ };
535
+ };
536
+ } & {
537
+ use: any[];
538
+ };
539
+ path: "/audit-log/get-event-types";
540
+ };
541
+ };
542
+ schema: {
543
+ auditLog: {
544
+ fields: {
545
+ eventType: {
546
+ type: "string";
547
+ required: true;
548
+ };
549
+ userId: {
550
+ type: "string";
551
+ required: false;
552
+ };
553
+ identifier: {
554
+ type: "string";
555
+ required: false;
556
+ };
557
+ organizationId: {
558
+ type: "string";
559
+ required: false;
560
+ };
561
+ status: {
562
+ type: "string";
563
+ required: true;
564
+ };
565
+ path: {
566
+ type: "string";
567
+ required: false;
568
+ };
569
+ ipAddress: {
570
+ type: "string";
571
+ required: false;
572
+ };
573
+ userAgent: {
574
+ type: "string";
575
+ required: false;
576
+ };
577
+ visitorId: {
578
+ type: "string";
579
+ required: false;
580
+ };
581
+ eventData: {
582
+ type: "json";
583
+ required: false;
584
+ };
585
+ createdAt: {
586
+ type: "date";
587
+ required: true;
588
+ };
589
+ };
590
+ };
591
+ };
592
+ $ERROR_CODES: {
593
+ readonly AUDIT_LOG_ACCESS_DENIED: "You don't have access to these audit logs";
594
+ readonly AUDIT_LOG_UNAVAILABLE: "Audit logs are temporarily unavailable";
595
+ };
596
+ options: {
597
+ database: boolean;
598
+ trackFailedSignIns: boolean;
599
+ adminRoles: string[];
600
+ remote?: {
601
+ apiUrl?: string | undefined;
602
+ apiKey?: string | undefined;
603
+ timeout?: number | undefined;
604
+ headers?: Record<string, string> | undefined;
605
+ batch?: {
606
+ maxSize?: number | undefined;
607
+ flushIntervalMs?: number | undefined;
608
+ } | undefined;
609
+ } | false | undefined;
610
+ onEvent?: ((event: AuditEvent) => void | Promise<void>) | undefined;
611
+ exclude?: AuditEventType[] | undefined;
612
+ schema?: import("..").InferOptionSchema<typeof schema> | undefined;
613
+ };
614
+ };
@@ -0,0 +1,13 @@
1
+ import type { AuthContext } from "@gatwech/core";
2
+ import type { AuditEvent } from "./types";
3
+ /** Shape shared by hook contexts, database hook contexts and `onRequest` */
4
+ export type EventContext = {
5
+ path?: string | undefined;
6
+ headers?: Headers | undefined;
7
+ request?: Request | undefined;
8
+ body?: any;
9
+ context?: Partial<AuthContext> | undefined;
10
+ };
11
+ export type RecordAuditEvent = (ctx: EventContext | undefined, event: Pick<AuditEvent, "eventType"> & Partial<Omit<AuditEvent, "id" | "eventType" | "createdAt">>) => Promise<void>;
12
+ export declare function registerAuditRecorder(context: Pick<AuthContext, "adapter">, record: RecordAuditEvent): void;
13
+ export declare function getAuditRecorder(context: Pick<AuthContext, "adapter">): RecordAuditEvent | undefined;
@@ -0,0 +1,34 @@
1
+ import type { AuthContext } from "@gatwech/core";
2
+ import type { AuditEvent, AuditLogOptions } from "./types";
3
+ export type RemoteQuery = {
4
+ limit: number;
5
+ offset: number;
6
+ eventType?: string | undefined;
7
+ identifier?: string | undefined;
8
+ userId?: string | undefined;
9
+ organizationId?: string | undefined;
10
+ startDate?: string | undefined;
11
+ endDate?: string | undefined;
12
+ userIds?: string[] | undefined;
13
+ organizationIds?: string[] | undefined;
14
+ };
15
+ interface RemoteSink {
16
+ push(event: AuditEvent, logger: AuthContext["logger"]): void;
17
+ flush(logger?: AuthContext["logger"]): Promise<void>;
18
+ query(query: RemoteQuery): Promise<{
19
+ events: AuditEvent[];
20
+ total: number;
21
+ limit: number;
22
+ offset: number;
23
+ }>;
24
+ }
25
+ /**
26
+ * Batches events and sends them to the hosted backend. Sending is never
27
+ * awaited by the auth flow, and failures are logged and dropped.
28
+ */
29
+ export declare function createRemoteSink(options: AuditLogOptions["remote"]): {
30
+ sink: RemoteSink | null;
31
+ /** Remote logging was configured but the URL or key is missing */
32
+ misconfigured: boolean;
33
+ };
34
+ export {};