@withwiz/toolkit 0.5.2 → 0.6.1

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 (184) hide show
  1. package/dist/auth/adapters/prisma/index.js +24 -23
  2. package/dist/auth/config.js +2 -2
  3. package/dist/auth/core/jwt/cookie.js +3 -3
  4. package/dist/auth/core/jwt/index.js +3 -3
  5. package/dist/auth/core/jwt/types.js +2 -1
  6. package/dist/auth/core/oauth/index.js +2 -1
  7. package/dist/auth/core/password/client-helper.js +2 -1
  8. package/dist/auth/core/password/index.js +2 -1
  9. package/dist/auth/email/index.d.ts +2 -0
  10. package/dist/auth/email/index.js +7 -0
  11. package/dist/auth/email/sender.d.ts +54 -0
  12. package/dist/auth/email/sender.js +7 -0
  13. package/dist/auth/handlers/forgot-password.handler.d.ts +3 -0
  14. package/dist/auth/handlers/forgot-password.handler.js +12 -0
  15. package/dist/auth/handlers/index.d.ts +25 -0
  16. package/dist/auth/handlers/index.js +79 -0
  17. package/dist/auth/handlers/login.handler.d.ts +3 -0
  18. package/dist/auth/handlers/login.handler.js +13 -0
  19. package/dist/auth/handlers/logout.handler.d.ts +3 -0
  20. package/dist/auth/handlers/logout.handler.js +11 -0
  21. package/dist/auth/handlers/me.handler.d.ts +3 -0
  22. package/dist/auth/handlers/me.handler.js +13 -0
  23. package/dist/auth/handlers/oauth-authorize.handler.d.ts +3 -0
  24. package/dist/auth/handlers/oauth-authorize.handler.js +15 -0
  25. package/dist/auth/handlers/oauth-callback.handler.d.ts +3 -0
  26. package/dist/auth/handlers/oauth-callback.handler.js +21 -0
  27. package/dist/auth/handlers/refresh.handler.d.ts +3 -0
  28. package/dist/auth/handlers/refresh.handler.js +14 -0
  29. package/dist/auth/handlers/register.handler.d.ts +3 -0
  30. package/dist/auth/handlers/register.handler.js +12 -0
  31. package/dist/auth/handlers/reset-password.handler.d.ts +3 -0
  32. package/dist/auth/handlers/reset-password.handler.js +12 -0
  33. package/dist/auth/handlers/verify-email.handler.d.ts +3 -0
  34. package/dist/auth/handlers/verify-email.handler.js +12 -0
  35. package/dist/auth/index.js +21 -20
  36. package/dist/auth/services/email-verification.service.d.ts +18 -0
  37. package/dist/auth/services/email-verification.service.js +11 -0
  38. package/dist/auth/services/index.d.ts +12 -0
  39. package/dist/auth/services/index.js +36 -0
  40. package/dist/auth/services/login.service.d.ts +19 -0
  41. package/dist/auth/services/login.service.js +13 -0
  42. package/dist/auth/services/oauth-callback.service.d.ts +32 -0
  43. package/dist/auth/services/oauth-callback.service.js +13 -0
  44. package/dist/auth/services/password-reset.service.d.ts +20 -0
  45. package/dist/auth/services/password-reset.service.js +11 -0
  46. package/dist/auth/services/register.service.d.ts +28 -0
  47. package/dist/auth/services/register.service.js +11 -0
  48. package/dist/auth/services/token-refresh.service.d.ts +25 -0
  49. package/dist/auth/services/token-refresh.service.js +13 -0
  50. package/dist/auth/types/handler-types.d.ts +68 -0
  51. package/dist/auth/types/handler-types.js +1 -0
  52. package/dist/auth/types/index.d.ts +1 -0
  53. package/dist/auth/types/index.js +2 -1
  54. package/dist/cache/cache-config.js +6 -6
  55. package/dist/cache/cache-env.js +5 -5
  56. package/dist/cache/cache-factory.js +14 -14
  57. package/dist/cache/cache-invalidation.js +15 -15
  58. package/dist/cache/cache-redis.js +8 -8
  59. package/dist/cache/cache-wrapper.js +15 -15
  60. package/dist/cache/cache.js +22 -22
  61. package/dist/cache/config.js +2 -2
  62. package/dist/cache/hybrid-cache-manager.js +10 -10
  63. package/dist/cache/index.js +22 -22
  64. package/dist/cache/inmemory-cache-manager.js +4 -4
  65. package/dist/cache/noop-cache-manager.js +7 -7
  66. package/dist/cache/redis-cache-manager.js +9 -9
  67. package/dist/{chunk-7ZQQ6PJ4.js → chunk-2VMTIYLX.js} +2 -2
  68. package/dist/{chunk-ZX7PHFX3.js → chunk-3AJHXCDG.js} +2 -2
  69. package/dist/{chunk-6YQU2AIK.js → chunk-3ECJUXLM.js} +3 -3
  70. package/dist/{chunk-PEFRPADW.js → chunk-4BGAE7NU.js} +1 -1
  71. package/dist/chunk-4YQ6YBM7.js +50 -0
  72. package/dist/chunk-6B7VU6RZ.js +90 -0
  73. package/dist/chunk-6JY6NUR6.js +38 -0
  74. package/dist/{chunk-YIB6H6P7.js → chunk-77BJRPMN.js} +4 -4
  75. package/dist/{chunk-LTEXLSIE.js → chunk-7JKZBEVB.js} +12 -12
  76. package/dist/{chunk-3TD5OAQS.js → chunk-7KZRPDQD.js} +4 -4
  77. package/dist/{chunk-QHDOMDC6.js → chunk-BEV7PQM3.js} +1 -1
  78. package/dist/{chunk-ZRXE4WSP.js → chunk-CKK55QFQ.js} +1 -1
  79. package/dist/{chunk-PAYLVMZN.js → chunk-CMU52MEQ.js} +6 -6
  80. package/dist/{chunk-MAATEX2R.js → chunk-CRMXLNLC.js} +1 -1
  81. package/dist/{chunk-7GKSYCKZ.js → chunk-CW3INZMV.js} +1 -1
  82. package/dist/{chunk-5FSPXXNB.js → chunk-DBHISLC6.js} +4 -4
  83. package/dist/chunk-DFSNHVXF.js +54 -0
  84. package/dist/chunk-ETMTDHK2.js +53 -0
  85. package/dist/{chunk-HHJZTDXL.js → chunk-EXJQKCTN.js} +6 -6
  86. package/dist/chunk-FI46LV42.js +56 -0
  87. package/dist/{chunk-LX2EYD74.js → chunk-FNECYXI4.js} +10 -10
  88. package/dist/chunk-FRY3TNJ6.js +37 -0
  89. package/dist/{chunk-ZEIFD4OQ.js → chunk-G2Q4TI3Q.js} +1 -1
  90. package/dist/{chunk-LCKQOHXI.js → chunk-G5OMETUS.js} +1 -1
  91. package/dist/chunk-GTPUVHSV.js +30 -0
  92. package/dist/{chunk-GCR4PGRY.js → chunk-HHCDMWEF.js} +1 -1
  93. package/dist/{chunk-ENIKCCAV.js → chunk-IHUQRVPV.js} +2 -2
  94. package/dist/chunk-JQFQT4S2.js +55 -0
  95. package/dist/{chunk-5E66FUBP.js → chunk-KF3O2DAV.js} +1 -1
  96. package/dist/chunk-KY7JZ54O.js +62 -0
  97. package/dist/{chunk-33BG6FPO.js → chunk-L5WLPC2T.js} +1 -1
  98. package/dist/{chunk-YGJJIC6S.js → chunk-LFKPXF5E.js} +4 -4
  99. package/dist/{chunk-DCUQNXVP.js → chunk-MDTID4D2.js} +3 -3
  100. package/dist/{chunk-KHYY4KCV.js → chunk-MEFZZE4M.js} +4 -4
  101. package/dist/chunk-MGQV723O.js +104 -0
  102. package/dist/chunk-N6TMHITU.js +49 -0
  103. package/dist/{chunk-BYHP4EH3.js → chunk-O35V6RIF.js} +3 -3
  104. package/dist/{chunk-2B4EKCV6.js → chunk-OCI7QCLM.js} +2 -2
  105. package/dist/{chunk-XKWT6W4K.js → chunk-ON7HZ3PW.js} +1 -1
  106. package/dist/{chunk-OBNS4ADX.js → chunk-PAF5OGDU.js} +7 -7
  107. package/dist/{chunk-S2O22ULX.js → chunk-PYVYYO4X.js} +7 -7
  108. package/dist/{chunk-ORYZZD5P.js → chunk-Q6KXN7HL.js} +2 -2
  109. package/dist/chunk-Q7VFOUFI.js +68 -0
  110. package/dist/chunk-QYXI45KH.js +62 -0
  111. package/dist/chunk-R4SXQYIT.js +0 -0
  112. package/dist/chunk-S7OQWKUJ.js +83 -0
  113. package/dist/{chunk-UWD5AHWI.js → chunk-SR3SQL72.js} +2 -2
  114. package/dist/{chunk-D7OUX5VJ.js → chunk-SSS6XSEG.js} +1 -1
  115. package/dist/{chunk-L6OEQBOM.js → chunk-TEXVRHPF.js} +1 -1
  116. package/dist/chunk-TFZOOP3V.js +50 -0
  117. package/dist/{chunk-HW732FCA.js → chunk-VCOA6LMN.js} +1 -1
  118. package/dist/{chunk-QWAMNYUT.js → chunk-W2GBKW2T.js} +2 -2
  119. package/dist/chunk-WC2IYFGC.js +51 -0
  120. package/dist/{chunk-XIDMCDD3.js → chunk-WJSMXUZB.js} +1 -1
  121. package/dist/chunk-WNEXLSDB.js +17 -0
  122. package/dist/{chunk-TCQ2DA6Y.js → chunk-WRWWB2NU.js} +4 -4
  123. package/dist/{chunk-IPXPCBDO.js → chunk-WVDYHSHD.js} +1 -1
  124. package/dist/{chunk-4J4D27BV.js → chunk-X6MGVFT3.js} +1 -1
  125. package/dist/chunk-YZXGOOFC.js +0 -0
  126. package/dist/components/ui/DataTable.js +10 -9
  127. package/dist/components/ui/data-table/DataTable.js +9 -9
  128. package/dist/components/ui/data-table/DataTableBulkActions.js +2 -2
  129. package/dist/components/ui/data-table/DataTableFilters.js +3 -3
  130. package/dist/components/ui/data-table/DataTablePagination.js +2 -2
  131. package/dist/components/ui/data-table/DataTableSearch.js +3 -3
  132. package/dist/components/ui/data-table/index.js +42 -0
  133. package/dist/components/ui/data-table/types.js +9 -0
  134. package/dist/config/common.js +2 -2
  135. package/dist/config/registry.d.ts +8 -15
  136. package/dist/config/registry.js +1 -4
  137. package/dist/error/error-handler.js +4 -4
  138. package/dist/error/index.js +4 -4
  139. package/dist/geolocation/batch-processor.js +4 -4
  140. package/dist/geolocation/config.js +2 -2
  141. package/dist/geolocation/index.js +12 -12
  142. package/dist/geolocation/providers/index.js +9 -9
  143. package/dist/geolocation/providers/ipgeolocation-provider.js +3 -3
  144. package/dist/geolocation/providers/maxmind-provider.js +3 -3
  145. package/dist/initialize.d.ts +1 -1
  146. package/dist/initialize.js +15 -17
  147. package/dist/logger/config.js +2 -2
  148. package/dist/logger/logger.js +3 -3
  149. package/dist/middleware/auth.js +6 -6
  150. package/dist/middleware/cors-config.js +2 -2
  151. package/dist/middleware/cors.js +5 -5
  152. package/dist/middleware/error-handler.js +5 -5
  153. package/dist/middleware/index.js +15 -15
  154. package/dist/middleware/middleware-chain.js +4 -4
  155. package/dist/middleware/rate-limit.js +4 -4
  156. package/dist/middleware/response-logger.js +4 -4
  157. package/dist/middleware/security.js +4 -4
  158. package/dist/middleware/wrappers.js +15 -15
  159. package/dist/storage/config.js +2 -2
  160. package/dist/storage/r2-storage.js +2 -2
  161. package/dist/system/cpu.js +5 -5
  162. package/dist/system/disk.js +5 -5
  163. package/dist/system/environment.js +10 -10
  164. package/dist/system/health-check.js +7 -7
  165. package/dist/system/index.js +15 -15
  166. package/dist/system/memory.js +5 -5
  167. package/dist/system/network.js +5 -5
  168. package/dist/system/utils.js +4 -4
  169. package/dist/utils/cors.js +4 -4
  170. package/dist/utils/csv-export.js +4 -4
  171. package/dist/utils/error-processor.js +4 -4
  172. package/dist/utils/index.js +16 -16
  173. package/package.json +6 -2
  174. package/dist/chunk-6PGZTY4N.js +0 -30
  175. package/dist/{chunk-2VNDWG6P.js → chunk-3CBGGMIY.js} +3 -3
  176. package/dist/{chunk-SEZJN4TC.js → chunk-5UVEOCRU.js} +6 -6
  177. package/dist/{chunk-OSNQ3TUX.js → chunk-A2XAOU55.js} +3 -3
  178. package/dist/{chunk-PL33DK2X.js → chunk-AYZJN32D.js} +3 -3
  179. package/dist/{chunk-23LXAAMU.js → chunk-GFWGLWTS.js} +3 -3
  180. package/dist/{chunk-NY5QXT33.js → chunk-I6Q3WUDT.js} +0 -0
  181. package/dist/{chunk-QKC73SWB.js → chunk-ITGUSYUH.js} +0 -0
  182. package/dist/{chunk-6O3I4ORK.js → chunk-OHBAELPZ.js} +3 -3
  183. package/dist/{chunk-XICTHSUH.js → chunk-SFPMFVSD.js} +3 -3
  184. package/dist/{chunk-AN7GU7PF.js → chunk-UCIUAZQT.js} +3 -3
@@ -0,0 +1,68 @@
1
+ import {
2
+ RegisterService
3
+ } from "./chunk-ETMTDHK2.js";
4
+ import {
5
+ AuthError
6
+ } from "./chunk-AIH3F7JV.js";
7
+
8
+ // src/auth/handlers/register.handler.ts
9
+ import { NextResponse } from "next/server";
10
+ import { z } from "zod";
11
+ var registerSchema = z.object({
12
+ email: z.string().email(),
13
+ password: z.string().min(8),
14
+ name: z.string().min(1).optional()
15
+ });
16
+ function createRegisterHandler(options) {
17
+ var _a;
18
+ const { dependencies, hooks, features } = options;
19
+ const registerService = new RegisterService({
20
+ userRepository: dependencies.userRepository,
21
+ emailTokenRepository: dependencies.emailTokenRepository,
22
+ emailSender: dependencies.emailSender,
23
+ emailVerificationRequired: (_a = features == null ? void 0 : features.emailVerificationRequired) != null ? _a : true,
24
+ logger: dependencies.logger
25
+ });
26
+ return async (request) => {
27
+ try {
28
+ const body = await request.json();
29
+ const parsed = registerSchema.safeParse(body);
30
+ if (!parsed.success) {
31
+ return NextResponse.json(
32
+ { success: false, error: "Invalid input", details: parsed.error.flatten() },
33
+ { status: 400 }
34
+ );
35
+ }
36
+ if (hooks == null ? void 0 : hooks.allowEmail) {
37
+ const allowed = await hooks.allowEmail(parsed.data.email);
38
+ if (!allowed) return NextResponse.json({ success: false, error: "Email not allowed" }, { status: 403 });
39
+ }
40
+ if (hooks == null ? void 0 : hooks.onBeforeRegister) {
41
+ const hookResult = await hooks.onBeforeRegister({ email: parsed.data.email, name: parsed.data.name });
42
+ if (hookResult instanceof Response) return hookResult;
43
+ }
44
+ const result = await registerService.register(parsed.data);
45
+ if (hooks == null ? void 0 : hooks.onAfterRegister) await hooks.onAfterRegister(result.user);
46
+ return NextResponse.json(
47
+ {
48
+ success: true,
49
+ user: { id: result.user.id, email: result.user.email, name: result.user.name },
50
+ verificationSent: result.verificationSent
51
+ },
52
+ { status: 201 }
53
+ );
54
+ } catch (error) {
55
+ if (error instanceof AuthError) {
56
+ return NextResponse.json(
57
+ { success: false, error: error.message, code: error.code },
58
+ { status: error.statusCode }
59
+ );
60
+ }
61
+ return NextResponse.json({ success: false, error: "Internal server error" }, { status: 500 });
62
+ }
63
+ };
64
+ }
65
+
66
+ export {
67
+ createRegisterHandler
68
+ };
@@ -0,0 +1,62 @@
1
+ import {
2
+ EmailVerificationService
3
+ } from "./chunk-N6TMHITU.js";
4
+ import {
5
+ AuthError
6
+ } from "./chunk-AIH3F7JV.js";
7
+
8
+ // src/auth/handlers/verify-email.handler.ts
9
+ import { NextResponse } from "next/server";
10
+ import { z } from "zod";
11
+ var schema = z.object({
12
+ email: z.string().email(),
13
+ token: z.string().min(1)
14
+ });
15
+ function createVerifyEmailHandler(options) {
16
+ const { dependencies } = options;
17
+ return async (request) => {
18
+ var _a, _b;
19
+ try {
20
+ let email, token;
21
+ if (request.method === "GET") {
22
+ const url = new URL(request.url);
23
+ email = (_a = url.searchParams.get("email")) != null ? _a : "";
24
+ token = (_b = url.searchParams.get("token")) != null ? _b : "";
25
+ } else {
26
+ const body = await request.json();
27
+ const parsed = schema.safeParse(body);
28
+ if (!parsed.success) {
29
+ return NextResponse.json({ success: false, error: "Invalid input" }, { status: 400 });
30
+ }
31
+ email = parsed.data.email;
32
+ token = parsed.data.token;
33
+ }
34
+ if (!email || !token) {
35
+ return NextResponse.json({ success: false, error: "Missing email or token" }, { status: 400 });
36
+ }
37
+ if (!dependencies.emailSender) {
38
+ return NextResponse.json({ success: false, error: "Email service not configured" }, { status: 500 });
39
+ }
40
+ const service = new EmailVerificationService({
41
+ userRepository: dependencies.userRepository,
42
+ emailTokenRepository: dependencies.emailTokenRepository,
43
+ emailSender: dependencies.emailSender,
44
+ logger: dependencies.logger
45
+ });
46
+ await service.verify(email, token);
47
+ return NextResponse.json({ success: true });
48
+ } catch (error) {
49
+ if (error instanceof AuthError) {
50
+ return NextResponse.json(
51
+ { success: false, error: error.message },
52
+ { status: error.statusCode }
53
+ );
54
+ }
55
+ return NextResponse.json({ success: false, error: "Verification failed" }, { status: 500 });
56
+ }
57
+ };
58
+ }
59
+
60
+ export {
61
+ createVerifyEmailHandler
62
+ };
File without changes
@@ -0,0 +1,83 @@
1
+ import {
2
+ OAuthCallbackService
3
+ } from "./chunk-6B7VU6RZ.js";
4
+ import {
5
+ OAuthManager
6
+ } from "./chunk-HZLJYEOO.js";
7
+ import {
8
+ setTokenCookies
9
+ } from "./chunk-G2Q4TI3Q.js";
10
+ import {
11
+ AuthError
12
+ } from "./chunk-AIH3F7JV.js";
13
+
14
+ // src/auth/handlers/oauth-callback.handler.ts
15
+ import { NextResponse } from "next/server";
16
+ function createOAuthCallbackHandler(options) {
17
+ const { dependencies, jwt, oauth, hooks, cookie, urls } = options;
18
+ const callbackService = new OAuthCallbackService({
19
+ userRepository: dependencies.userRepository,
20
+ oauthAccountRepository: dependencies.oauthAccountRepository,
21
+ jwtSecret: jwt.secret,
22
+ accessTokenExpiry: jwt.accessTokenExpiry,
23
+ refreshTokenExpiry: jwt.refreshTokenExpiry,
24
+ logger: dependencies.logger
25
+ });
26
+ return async (request) => {
27
+ var _a, _b, _c, _d;
28
+ try {
29
+ const url = new URL(request.url);
30
+ const code = url.searchParams.get("code");
31
+ const provider = (_a = url.searchParams.get("provider")) != null ? _a : url.pathname.split("/").pop();
32
+ if (!code || !provider || !(oauth == null ? void 0 : oauth[provider])) {
33
+ return NextResponse.json({ success: false, error: "Invalid callback" }, { status: 400 });
34
+ }
35
+ const providers = {};
36
+ for (const [name, config] of Object.entries(oauth)) {
37
+ providers[name] = config;
38
+ }
39
+ const noopLogger = { debug() {
40
+ }, info() {
41
+ }, warn() {
42
+ }, error() {
43
+ } };
44
+ const manager = new OAuthManager({ providers }, (_b = dependencies.logger) != null ? _b : noopLogger);
45
+ const accessToken = await manager.exchangeCodeForToken(provider, code);
46
+ const userInfo = await manager.getUserInfo(provider, accessToken);
47
+ if (hooks == null ? void 0 : hooks.allowEmail) {
48
+ const allowed = await hooks.allowEmail(userInfo.email);
49
+ if (!allowed) return NextResponse.json({ success: false, error: "Email not allowed" }, { status: 403 });
50
+ }
51
+ const result = await callbackService.handleCallback({
52
+ provider,
53
+ providerAccountId: userInfo.id,
54
+ email: userInfo.email,
55
+ name: userInfo.name,
56
+ image: userInfo.image,
57
+ accessToken
58
+ });
59
+ if (hooks == null ? void 0 : hooks.onAfterOAuth) await hooks.onAfterOAuth(result.user, provider, result.isNewUser);
60
+ if (result.isNewUser && (hooks == null ? void 0 : hooks.onOAuthFirstLogin)) {
61
+ const redirect = await hooks.onOAuthFirstLogin(result.user, provider);
62
+ if (redirect) {
63
+ const response2 = NextResponse.redirect(redirect);
64
+ setTokenCookies(response2, result.tokens, { secure: cookie == null ? void 0 : cookie.secure });
65
+ return response2;
66
+ }
67
+ }
68
+ const redirectUrl = (_d = (_c = urls.afterOAuth) != null ? _c : urls.afterLogin) != null ? _d : "/";
69
+ const response = NextResponse.redirect(new URL(redirectUrl, urls.baseUrl));
70
+ setTokenCookies(response, result.tokens, { secure: cookie == null ? void 0 : cookie.secure });
71
+ return response;
72
+ } catch (error) {
73
+ if (error instanceof AuthError) {
74
+ return NextResponse.json({ success: false, error: error.message }, { status: error.statusCode });
75
+ }
76
+ return NextResponse.json({ success: false, error: "OAuth callback failed" }, { status: 500 });
77
+ }
78
+ };
79
+ }
80
+
81
+ export {
82
+ createOAuthCallbackHandler
83
+ };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-4J4D27BV.js";
4
+ } from "./chunk-X6MGVFT3.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-L6OEQBOM.js";
7
+ } from "./chunk-TEXVRHPF.js";
8
8
 
9
9
  // src/system/cpu.ts
10
10
  import os from "os";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-L6OEQBOM.js";
3
+ } from "./chunk-TEXVRHPF.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getLoggerConfig
3
- } from "./chunk-6O3I4ORK.js";
3
+ } from "./chunk-OHBAELPZ.js";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -0,0 +1,50 @@
1
+ import {
2
+ PasswordResetService
3
+ } from "./chunk-WC2IYFGC.js";
4
+ import {
5
+ AuthError
6
+ } from "./chunk-AIH3F7JV.js";
7
+
8
+ // src/auth/handlers/reset-password.handler.ts
9
+ import { NextResponse } from "next/server";
10
+ import { z } from "zod";
11
+ var schema = z.object({
12
+ email: z.string().email(),
13
+ token: z.string().min(1),
14
+ password: z.string().min(8)
15
+ });
16
+ function createResetPasswordHandler(options) {
17
+ const { dependencies } = options;
18
+ return async (request) => {
19
+ try {
20
+ const body = await request.json();
21
+ const parsed = schema.safeParse(body);
22
+ if (!parsed.success) {
23
+ return NextResponse.json({ success: false, error: "Invalid input" }, { status: 400 });
24
+ }
25
+ if (!dependencies.emailSender) {
26
+ return NextResponse.json({ success: false, error: "Email service not configured" }, { status: 500 });
27
+ }
28
+ const service = new PasswordResetService({
29
+ userRepository: dependencies.userRepository,
30
+ emailTokenRepository: dependencies.emailTokenRepository,
31
+ emailSender: dependencies.emailSender,
32
+ logger: dependencies.logger
33
+ });
34
+ await service.resetPassword(parsed.data.email, parsed.data.token, parsed.data.password);
35
+ return NextResponse.json({ success: true });
36
+ } catch (error) {
37
+ if (error instanceof AuthError) {
38
+ return NextResponse.json(
39
+ { success: false, error: error.message },
40
+ { status: error.statusCode }
41
+ );
42
+ }
43
+ return NextResponse.json({ success: false, error: "Reset failed" }, { status: 500 });
44
+ }
45
+ };
46
+ }
47
+
48
+ export {
49
+ createResetPasswordHandler
50
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-L6OEQBOM.js";
3
+ } from "./chunk-TEXVRHPF.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  runCommand,
3
3
  runMacCommand
4
- } from "./chunk-4J4D27BV.js";
4
+ } from "./chunk-X6MGVFT3.js";
5
5
  import {
6
6
  logger
7
- } from "./chunk-L6OEQBOM.js";
7
+ } from "./chunk-TEXVRHPF.js";
8
8
 
9
9
  // src/system/disk.ts
10
10
  async function getDiskInfo() {
@@ -0,0 +1,51 @@
1
+ import {
2
+ TokenGenerator
3
+ } from "./chunk-GDWEDUHO.js";
4
+ import {
5
+ AuthError
6
+ } from "./chunk-AIH3F7JV.js";
7
+
8
+ // src/auth/services/password-reset.service.ts
9
+ import { hash } from "bcryptjs";
10
+ var PasswordResetService = class {
11
+ constructor(config) {
12
+ var _a, _b, _c;
13
+ this.userRepo = config.userRepository;
14
+ this.tokenRepo = config.emailTokenRepository;
15
+ this.emailSender = config.emailSender;
16
+ this.tokenExpiryHours = (_a = config.tokenExpiryHours) != null ? _a : 1;
17
+ this.bcryptRounds = (_b = config.bcryptRounds) != null ? _b : 12;
18
+ this.logger = (_c = config.logger) != null ? _c : { debug() {
19
+ }, info() {
20
+ }, warn() {
21
+ }, error() {
22
+ } };
23
+ }
24
+ async requestReset(email) {
25
+ const user = await this.userRepo.findByEmail(email);
26
+ if (!user) return;
27
+ const token = TokenGenerator.generate();
28
+ const expires = new Date(Date.now() + this.tokenExpiryHours * 60 * 60 * 1e3);
29
+ await this.tokenRepo.create(email, token, "PASSWORD_RESET" /* PASSWORD_RESET */, expires);
30
+ await this.emailSender.sendPasswordResetEmail(email, token);
31
+ this.logger.info("Password reset requested", { email });
32
+ }
33
+ async resetPassword(email, token, newPassword) {
34
+ const tokenRecord = await this.tokenRepo.findByEmailAndToken(email, token, "PASSWORD_RESET" /* PASSWORD_RESET */);
35
+ if (!tokenRecord || tokenRecord.expires < /* @__PURE__ */ new Date()) {
36
+ throw new AuthError("Invalid or expired token", "TOKEN_INVALID", 400);
37
+ }
38
+ const user = await this.userRepo.findByEmail(email);
39
+ if (!user) {
40
+ throw new AuthError("User not found", "USER_NOT_FOUND", 404);
41
+ }
42
+ const hashedPassword = await hash(newPassword, this.bcryptRounds);
43
+ await this.userRepo.update(user.id, { password: hashedPassword });
44
+ await this.tokenRepo.delete(email, token, "PASSWORD_RESET" /* PASSWORD_RESET */);
45
+ this.logger.info("Password reset completed", { userId: user.id });
46
+ }
47
+ };
48
+
49
+ export {
50
+ PasswordResetService
51
+ };
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-SNTLJ646.js";
7
7
  import {
8
8
  logger
9
- } from "./chunk-L6OEQBOM.js";
9
+ } from "./chunk-TEXVRHPF.js";
10
10
 
11
11
  // src/middleware/rate-limit.ts
12
12
  var GLOBAL_KEY = "__withwiz_rateLimitAdapter__";
@@ -0,0 +1,17 @@
1
+ import {
2
+ clearTokenCookies
3
+ } from "./chunk-G2Q4TI3Q.js";
4
+
5
+ // src/auth/handlers/logout.handler.ts
6
+ import { NextResponse } from "next/server";
7
+ function createLogoutHandler(_options) {
8
+ return async (_request) => {
9
+ const response = NextResponse.json({ success: true });
10
+ clearTokenCookies(response);
11
+ return response;
12
+ };
13
+ }
14
+
15
+ export {
16
+ createLogoutHandler
17
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AUTH_ERROR_CODE_MAP
3
- } from "./chunk-DCUQNXVP.js";
3
+ } from "./chunk-MDTID4D2.js";
4
4
  import {
5
5
  AppError
6
6
  } from "./chunk-EOEMOXNT.js";
@@ -11,12 +11,12 @@ import {
11
11
  ERROR_CODES,
12
12
  classifyError
13
13
  } from "./chunk-SNTLJ646.js";
14
- import {
15
- logger
16
- } from "./chunk-L6OEQBOM.js";
17
14
  import {
18
15
  AuthError
19
16
  } from "./chunk-AIH3F7JV.js";
17
+ import {
18
+ logger
19
+ } from "./chunk-TEXVRHPF.js";
20
20
  import {
21
21
  __spreadValues
22
22
  } from "./chunk-ORMEWXMH.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  formatLabel
3
- } from "./chunk-NY5QXT33.js";
3
+ } from "./chunk-I6Q3WUDT.js";
4
4
  import {
5
5
  Pagination,
6
6
  PaginationContent,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-L6OEQBOM.js";
3
+ } from "./chunk-TEXVRHPF.js";
4
4
 
5
5
  // src/system/utils.ts
6
6
  import { exec } from "child_process";
File without changes
@@ -1,19 +1,20 @@
1
+ import "../../chunk-R4SXQYIT.js";
1
2
  import {
2
3
  DataTable
3
- } from "../../chunk-LX2EYD74.js";
4
+ } from "../../chunk-FNECYXI4.js";
5
+ import "../../chunk-5UVEOCRU.js";
6
+ import "../../chunk-WVDYHSHD.js";
7
+ import "../../chunk-MEFZZE4M.js";
4
8
  import "../../chunk-7IY3RQQL.js";
5
- import "../../chunk-MAATEX2R.js";
6
- import "../../chunk-SEZJN4TC.js";
7
- import "../../chunk-IPXPCBDO.js";
8
- import "../../chunk-KHYY4KCV.js";
9
- import "../../chunk-NY5QXT33.js";
10
- import "../../chunk-34WAGUT5.js";
11
- import "../../chunk-RJUVBBZG.js";
12
- import "../../chunk-IJEZ7G7S.js";
9
+ import "../../chunk-CRMXLNLC.js";
10
+ import "../../chunk-I6Q3WUDT.js";
13
11
  import "../../chunk-YJWLWUFK.js";
14
12
  import "../../chunk-WDUFQFDP.js";
13
+ import "../../chunk-34WAGUT5.js";
15
14
  import "../../chunk-F6LCSFSU.js";
16
15
  import "../../chunk-L25BNU3E.js";
16
+ import "../../chunk-RJUVBBZG.js";
17
+ import "../../chunk-IJEZ7G7S.js";
17
18
  import "../../chunk-62FLBG6B.js";
18
19
  import "../../chunk-ORMEWXMH.js";
19
20
  export {
@@ -1,20 +1,20 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTable
4
- } from "../../../chunk-LX2EYD74.js";
4
+ } from "../../../chunk-FNECYXI4.js";
5
+ import "../../../chunk-5UVEOCRU.js";
6
+ import "../../../chunk-WVDYHSHD.js";
7
+ import "../../../chunk-MEFZZE4M.js";
5
8
  import "../../../chunk-7IY3RQQL.js";
6
- import "../../../chunk-MAATEX2R.js";
7
- import "../../../chunk-SEZJN4TC.js";
8
- import "../../../chunk-IPXPCBDO.js";
9
- import "../../../chunk-KHYY4KCV.js";
10
- import "../../../chunk-NY5QXT33.js";
11
- import "../../../chunk-34WAGUT5.js";
12
- import "../../../chunk-RJUVBBZG.js";
13
- import "../../../chunk-IJEZ7G7S.js";
9
+ import "../../../chunk-CRMXLNLC.js";
10
+ import "../../../chunk-I6Q3WUDT.js";
14
11
  import "../../../chunk-YJWLWUFK.js";
15
12
  import "../../../chunk-WDUFQFDP.js";
13
+ import "../../../chunk-34WAGUT5.js";
16
14
  import "../../../chunk-F6LCSFSU.js";
17
15
  import "../../../chunk-L25BNU3E.js";
16
+ import "../../../chunk-RJUVBBZG.js";
17
+ import "../../../chunk-IJEZ7G7S.js";
18
18
  import "../../../chunk-62FLBG6B.js";
19
19
  import "../../../chunk-ORMEWXMH.js";
20
20
  export {
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTableBulkActions
4
- } from "../../../chunk-MAATEX2R.js";
5
- import "../../../chunk-NY5QXT33.js";
4
+ } from "../../../chunk-CRMXLNLC.js";
5
+ import "../../../chunk-I6Q3WUDT.js";
6
6
  import "../../../chunk-34WAGUT5.js";
7
7
  import "../../../chunk-L25BNU3E.js";
8
8
  import "../../../chunk-62FLBG6B.js";
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTableFilters
4
- } from "../../../chunk-SEZJN4TC.js";
5
- import "../../../chunk-RJUVBBZG.js";
6
- import "../../../chunk-IJEZ7G7S.js";
4
+ } from "../../../chunk-5UVEOCRU.js";
7
5
  import "../../../chunk-WDUFQFDP.js";
8
6
  import "../../../chunk-L25BNU3E.js";
7
+ import "../../../chunk-RJUVBBZG.js";
8
+ import "../../../chunk-IJEZ7G7S.js";
9
9
  import "../../../chunk-62FLBG6B.js";
10
10
  import "../../../chunk-ORMEWXMH.js";
11
11
  export {
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTablePagination
4
- } from "../../../chunk-IPXPCBDO.js";
5
- import "../../../chunk-NY5QXT33.js";
4
+ } from "../../../chunk-WVDYHSHD.js";
5
+ import "../../../chunk-I6Q3WUDT.js";
6
6
  import "../../../chunk-YJWLWUFK.js";
7
7
  import "../../../chunk-62FLBG6B.js";
8
8
  import "../../../chunk-ORMEWXMH.js";
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTableSearch
4
- } from "../../../chunk-KHYY4KCV.js";
5
- import "../../../chunk-NY5QXT33.js";
6
- import "../../../chunk-RJUVBBZG.js";
4
+ } from "../../../chunk-MEFZZE4M.js";
5
+ import "../../../chunk-I6Q3WUDT.js";
7
6
  import "../../../chunk-L25BNU3E.js";
7
+ import "../../../chunk-RJUVBBZG.js";
8
8
  import "../../../chunk-62FLBG6B.js";
9
9
  import "../../../chunk-ORMEWXMH.js";
10
10
  export {
@@ -0,0 +1,42 @@
1
+ import "../../../chunk-R4SXQYIT.js";
2
+ import {
3
+ DataTable
4
+ } from "../../../chunk-FNECYXI4.js";
5
+ import {
6
+ DataTableFilters
7
+ } from "../../../chunk-5UVEOCRU.js";
8
+ import {
9
+ DataTablePagination
10
+ } from "../../../chunk-WVDYHSHD.js";
11
+ import {
12
+ DataTableSearch
13
+ } from "../../../chunk-MEFZZE4M.js";
14
+ import {
15
+ DataTableBody
16
+ } from "../../../chunk-7IY3RQQL.js";
17
+ import {
18
+ DataTableBulkActions
19
+ } from "../../../chunk-CRMXLNLC.js";
20
+ import {
21
+ DEFAULT_LABELS,
22
+ formatLabel
23
+ } from "../../../chunk-I6Q3WUDT.js";
24
+ import "../../../chunk-YJWLWUFK.js";
25
+ import "../../../chunk-WDUFQFDP.js";
26
+ import "../../../chunk-34WAGUT5.js";
27
+ import "../../../chunk-F6LCSFSU.js";
28
+ import "../../../chunk-L25BNU3E.js";
29
+ import "../../../chunk-RJUVBBZG.js";
30
+ import "../../../chunk-IJEZ7G7S.js";
31
+ import "../../../chunk-62FLBG6B.js";
32
+ import "../../../chunk-ORMEWXMH.js";
33
+ export {
34
+ DEFAULT_LABELS,
35
+ DataTable,
36
+ DataTableBody,
37
+ DataTableBulkActions,
38
+ DataTableFilters,
39
+ DataTablePagination,
40
+ DataTableSearch,
41
+ formatLabel
42
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ DEFAULT_LABELS,
3
+ formatLabel
4
+ } from "../../../chunk-I6Q3WUDT.js";
5
+ import "../../../chunk-ORMEWXMH.js";
6
+ export {
7
+ DEFAULT_LABELS,
8
+ formatLabel
9
+ };
@@ -2,9 +2,9 @@ import {
2
2
  getCommonConfig,
3
3
  initializeCommon,
4
4
  resetCommon
5
- } from "../chunk-XICTHSUH.js";
6
- import "../chunk-2QH66EVQ.js";
5
+ } from "../chunk-SFPMFVSD.js";
7
6
  import "../chunk-K25ICPU4.js";
7
+ import "../chunk-2QH66EVQ.js";
8
8
  import "../chunk-ORMEWXMH.js";
9
9
  export {
10
10
  getCommonConfig,