@withwiz/toolkit 0.6.2 → 0.6.4

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 (74) hide show
  1. package/README.md +2 -2
  2. package/dist/auth/adapters/prisma/index.js +3 -3
  3. package/dist/auth/config.js +2 -1
  4. package/dist/auth/core/jwt/cookie.js +3 -2
  5. package/dist/auth/core/jwt/index.js +3 -2
  6. package/dist/auth/core/jwt/types.js +1 -1
  7. package/dist/auth/core/oauth/index.d.ts +1 -1
  8. package/dist/auth/core/oauth/index.js +12 -4
  9. package/dist/auth/core/oauth/providers/index.d.ts +2 -0
  10. package/dist/auth/core/oauth/providers/index.js +11 -3
  11. package/dist/auth/core/oauth/providers/kakao.js +1 -1
  12. package/dist/auth/core/oauth/providers/meta.d.ts +14 -0
  13. package/dist/auth/core/oauth/providers/meta.js +8 -0
  14. package/dist/auth/core/oauth/providers/microsoft.d.ts +21 -0
  15. package/dist/auth/core/oauth/providers/microsoft.js +8 -0
  16. package/dist/auth/core/password/client-helper.js +1 -1
  17. package/dist/auth/core/password/index.js +1 -1
  18. package/dist/auth/handlers/forgot-password.handler.js +1 -1
  19. package/dist/auth/handlers/index.js +19 -16
  20. package/dist/auth/handlers/login.handler.js +4 -3
  21. package/dist/auth/handlers/logout.handler.js +4 -3
  22. package/dist/auth/handlers/me.handler.js +4 -3
  23. package/dist/auth/handlers/oauth-authorize.handler.js +7 -5
  24. package/dist/auth/handlers/oauth-callback.handler.js +11 -8
  25. package/dist/auth/handlers/refresh.handler.js +5 -4
  26. package/dist/auth/handlers/register.handler.js +3 -3
  27. package/dist/auth/handlers/reset-password.handler.js +1 -1
  28. package/dist/auth/handlers/verify-email.handler.js +1 -1
  29. package/dist/auth/index.js +24 -21
  30. package/dist/auth/services/email-verification.service.js +1 -1
  31. package/dist/auth/services/index.js +8 -7
  32. package/dist/auth/services/login.service.js +4 -3
  33. package/dist/auth/services/oauth-callback.service.js +4 -3
  34. package/dist/auth/services/password-reset.service.js +1 -1
  35. package/dist/auth/services/register.service.js +2 -2
  36. package/dist/auth/services/token-refresh.service.js +4 -3
  37. package/dist/auth/types/index.d.ts +2 -0
  38. package/dist/auth/types/index.js +1 -1
  39. package/dist/{chunk-SI2Z26KP.js → chunk-2NCTRLVH.js} +1 -1
  40. package/dist/{chunk-V3ZIR4UL.js → chunk-2O72OV5X.js} +1 -1
  41. package/dist/{chunk-FNECYXI4.js → chunk-3X7D3NV4.js} +1 -1
  42. package/dist/{chunk-HZLJYEOO.js → chunk-57HPJEZB.js} +9 -1
  43. package/dist/{chunk-O5E36ZIJ.js → chunk-AUDUYK5B.js} +2 -2
  44. package/dist/{chunk-RXVX2DCW.js → chunk-B7QWZ5SW.js} +1 -1
  45. package/dist/{chunk-Q7VFOUFI.js → chunk-D6MIC5AU.js} +1 -1
  46. package/dist/{chunk-ITGUSYUH.js → chunk-G2WAL2T7.js} +3 -1
  47. package/dist/{chunk-6JY6NUR6.js → chunk-GDX3YQGK.js} +1 -1
  48. package/dist/{chunk-ERO4PGNO.js → chunk-HT7HEGH3.js} +1 -1
  49. package/dist/{chunk-MULM3Q5S.js → chunk-JP7FDGGL.js} +1 -1
  50. package/dist/{chunk-LNPZZ23G.js → chunk-JXACXHRL.js} +7 -4
  51. package/dist/chunk-K3OYTLXU.js +63 -0
  52. package/dist/{chunk-6B7VU6RZ.js → chunk-Q26CQW7T.js} +6 -4
  53. package/dist/{chunk-ETMTDHK2.js → chunk-SOQOAFB2.js} +0 -1
  54. package/dist/{chunk-JQFQT4S2.js → chunk-SVHD6WCJ.js} +6 -3
  55. package/dist/{chunk-L74XPPH4.js → chunk-TBMRGMRP.js} +7 -4
  56. package/dist/{chunk-2QQNL4ND.js → chunk-TLZJQR26.js} +17 -6
  57. package/dist/{chunk-4YQ6YBM7.js → chunk-UKE7WA3U.js} +6 -3
  58. package/dist/chunk-VB64KFBD.js +99 -0
  59. package/dist/{chunk-DFSNHVXF.js → chunk-VWPSQQ7E.js} +6 -3
  60. package/dist/{chunk-B6Q7UNCU.js → chunk-WBWDJUF5.js} +3 -3
  61. package/dist/components/ui/DataTable.js +5 -5
  62. package/dist/components/ui/data-table/DataTable.js +5 -5
  63. package/dist/components/ui/data-table/DataTableFilters.js +2 -2
  64. package/dist/components/ui/data-table/index.js +5 -5
  65. package/dist/constants/index.js +22 -22
  66. package/dist/initialize.js +2 -1
  67. package/dist/middleware/auth.js +4 -3
  68. package/dist/middleware/index.js +5 -4
  69. package/dist/middleware/wrappers.js +5 -4
  70. package/dist/system/environment.js +3 -2
  71. package/dist/system/index.js +3 -2
  72. package/package.json +1 -1
  73. package/dist/{chunk-T4MDCVUQ.js → chunk-6CLQRZC2.js} +0 -0
  74. package/dist/{chunk-5UVEOCRU.js → chunk-X2UP5PNN.js} +7 -7
@@ -2,7 +2,7 @@ import {
2
2
  PasswordResetService
3
3
  } from "../../chunk-WC2IYFGC.js";
4
4
  import "../../chunk-GDWEDUHO.js";
5
- import "../../chunk-ITGUSYUH.js";
5
+ import "../../chunk-G2WAL2T7.js";
6
6
  import "../../chunk-YZXGOOFC.js";
7
7
  import "../../chunk-AIH3F7JV.js";
8
8
  import "../../chunk-ORMEWXMH.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  RegisterService
3
- } from "../../chunk-ETMTDHK2.js";
3
+ } from "../../chunk-SOQOAFB2.js";
4
4
  import "../../chunk-GDWEDUHO.js";
5
- import "../../chunk-ITGUSYUH.js";
5
+ import "../../chunk-G2WAL2T7.js";
6
6
  import "../../chunk-YZXGOOFC.js";
7
7
  import "../../chunk-AIH3F7JV.js";
8
8
  import "../../chunk-ORMEWXMH.js";
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  TokenRefreshService
3
- } from "../../chunk-JQFQT4S2.js";
3
+ } from "../../chunk-SVHD6WCJ.js";
4
4
  import "../../chunk-3GAY2T2A.js";
5
- import "../../chunk-V3ZIR4UL.js";
5
+ import "../../chunk-2O72OV5X.js";
6
6
  import "../../chunk-AIH3F7JV.js";
7
- import "../../chunk-LNPZZ23G.js";
7
+ import "../../chunk-JXACXHRL.js";
8
+ import "../../chunk-C4TSQUFA.js";
8
9
  import "../../chunk-K25ICPU4.js";
9
10
  import "../../chunk-2QH66EVQ.js";
10
11
  import "../../chunk-ORMEWXMH.js";
@@ -34,6 +34,8 @@ export declare const OAUTH_PROVIDERS: {
34
34
  readonly GOOGLE: "google";
35
35
  readonly GITHUB: "github";
36
36
  readonly KAKAO: "kakao";
37
+ readonly MICROSOFT: "microsoft";
38
+ readonly META: "meta";
37
39
  };
38
40
  export type OAuthProviderName = typeof OAUTH_PROVIDERS[keyof typeof OAUTH_PROVIDERS];
39
41
  export interface OAuthUserInfo {
@@ -2,7 +2,7 @@ import {
2
2
  OAUTH_PROVIDERS,
3
3
  PasswordStrength,
4
4
  TokenType
5
- } from "../../chunk-ITGUSYUH.js";
5
+ } from "../../chunk-G2WAL2T7.js";
6
6
  import "../../chunk-YZXGOOFC.js";
7
7
  import "../../chunk-ORMEWXMH.js";
8
8
  export {
@@ -17,7 +17,7 @@ import {
17
17
  adminMiddleware,
18
18
  authMiddleware,
19
19
  optionalAuthMiddleware
20
- } from "./chunk-RXVX2DCW.js";
20
+ } from "./chunk-B7QWZ5SW.js";
21
21
  import {
22
22
  corsMiddleware
23
23
  } from "./chunk-A6FKWYO2.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getAuthConfig
3
- } from "./chunk-LNPZZ23G.js";
3
+ } from "./chunk-JXACXHRL.js";
4
4
  import {
5
5
  __spreadValues
6
6
  } from "./chunk-ORMEWXMH.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DataTableFilters
3
- } from "./chunk-5UVEOCRU.js";
3
+ } from "./chunk-X2UP5PNN.js";
4
4
  import {
5
5
  DataTablePagination
6
6
  } from "./chunk-WVDYHSHD.js";
@@ -1,6 +1,12 @@
1
1
  import {
2
2
  KakaoOAuthProvider
3
- } from "./chunk-2QQNL4ND.js";
3
+ } from "./chunk-TLZJQR26.js";
4
+ import {
5
+ MetaOAuthProvider
6
+ } from "./chunk-K3OYTLXU.js";
7
+ import {
8
+ MicrosoftOAuthProvider
9
+ } from "./chunk-VB64KFBD.js";
4
10
  import {
5
11
  GitHubOAuthProvider
6
12
  } from "./chunk-GBLNXNEH.js";
@@ -20,6 +26,8 @@ var OAuthManager = class {
20
26
  this.registerProvider(new GoogleOAuthProvider());
21
27
  this.registerProvider(new GitHubOAuthProvider());
22
28
  this.registerProvider(new KakaoOAuthProvider());
29
+ this.registerProvider(new MicrosoftOAuthProvider());
30
+ this.registerProvider(new MetaOAuthProvider());
23
31
  }
24
32
  /**
25
33
  * 프로바이더 어댑터 등록
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  TokenRefreshService
3
- } from "./chunk-JQFQT4S2.js";
3
+ } from "./chunk-SVHD6WCJ.js";
4
4
  import {
5
5
  setTokenCookies
6
- } from "./chunk-V3ZIR4UL.js";
6
+ } from "./chunk-2O72OV5X.js";
7
7
  import {
8
8
  AuthError
9
9
  } from "./chunk-AIH3F7JV.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-3GAY2T2A.js";
10
10
  import {
11
11
  getAuthConfig
12
- } from "./chunk-LNPZZ23G.js";
12
+ } from "./chunk-JXACXHRL.js";
13
13
  import {
14
14
  logger
15
15
  } from "./chunk-NOAU2JG7.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RegisterService
3
- } from "./chunk-ETMTDHK2.js";
3
+ } from "./chunk-SOQOAFB2.js";
4
4
  import {
5
5
  AuthError
6
6
  } from "./chunk-AIH3F7JV.js";
@@ -2,7 +2,9 @@
2
2
  var OAUTH_PROVIDERS = {
3
3
  GOOGLE: "google",
4
4
  GITHUB: "github",
5
- KAKAO: "kakao"
5
+ KAKAO: "kakao",
6
+ MICROSOFT: "microsoft",
7
+ META: "meta"
6
8
  };
7
9
  var PasswordStrength = /* @__PURE__ */ ((PasswordStrength2) => {
8
10
  PasswordStrength2["VERY_WEAK"] = "VERY_WEAK";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OAuthManager
3
- } from "./chunk-HZLJYEOO.js";
3
+ } from "./chunk-57HPJEZB.js";
4
4
 
5
5
  // src/auth/handlers/oauth-authorize.handler.ts
6
6
  import { NextResponse } from "next/server";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clearTokenCookies
3
- } from "./chunk-V3ZIR4UL.js";
3
+ } from "./chunk-2O72OV5X.js";
4
4
 
5
5
  // src/auth/handlers/logout.handler.ts
6
6
  import { NextResponse } from "next/server";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-LHIVUV7Q.js";
7
7
  import {
8
8
  getAuthConfig
9
- } from "./chunk-LNPZZ23G.js";
9
+ } from "./chunk-JXACXHRL.js";
10
10
  import {
11
11
  getCommonConfig
12
12
  } from "./chunk-WPW4HXW4.js";
@@ -1,3 +1,6 @@
1
+ import {
2
+ JWT_DEFAULTS
3
+ } from "./chunk-C4TSQUFA.js";
1
4
  import {
2
5
  configWarn
3
6
  } from "./chunk-K25ICPU4.js";
@@ -14,15 +17,15 @@ function initializeAuth(config) {
14
17
  throw new ConfigurationError("Auth", "jwtSecret is required");
15
18
  }
16
19
  if (!config.accessTokenExpiry) {
17
- configWarn("Auth", "accessTokenExpiry not provided, using default: 7d");
20
+ configWarn("Auth", `accessTokenExpiry not provided, using default: ${JWT_DEFAULTS.DEFAULT_ACCESS_TOKEN_EXPIRES}`);
18
21
  }
19
22
  if (!config.refreshTokenExpiry) {
20
- configWarn("Auth", "refreshTokenExpiry not provided, using default: 30d");
23
+ configWarn("Auth", `refreshTokenExpiry not provided, using default: ${JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES}`);
21
24
  }
22
25
  globalThis.__withwiz_config.auth = {
23
26
  jwtSecret: config.jwtSecret,
24
- accessTokenExpiry: (_b = config.accessTokenExpiry) != null ? _b : "7d",
25
- refreshTokenExpiry: (_c = config.refreshTokenExpiry) != null ? _c : "30d",
27
+ accessTokenExpiry: (_b = config.accessTokenExpiry) != null ? _b : JWT_DEFAULTS.DEFAULT_ACCESS_TOKEN_EXPIRES,
28
+ refreshTokenExpiry: (_c = config.refreshTokenExpiry) != null ? _c : JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES,
26
29
  cookieSecure: (_d = config.cookieSecure) != null ? _d : false
27
30
  };
28
31
  }
@@ -0,0 +1,63 @@
1
+ import {
2
+ OAuthError
3
+ } from "./chunk-AIH3F7JV.js";
4
+
5
+ // src/auth/core/oauth/providers/meta.ts
6
+ var META_GRAPH_VERSION = "v25.0";
7
+ var MetaOAuthProvider = class {
8
+ constructor() {
9
+ this.name = "meta";
10
+ }
11
+ getLoginUrl(config, state) {
12
+ const params = new URLSearchParams({
13
+ client_id: config.clientId,
14
+ redirect_uri: config.redirectUri,
15
+ response_type: "code",
16
+ scope: "email,public_profile"
17
+ });
18
+ if (state) {
19
+ params.set("state", state);
20
+ }
21
+ return `https://www.facebook.com/${META_GRAPH_VERSION}/dialog/oauth?${params.toString()}`;
22
+ }
23
+ async exchangeCodeForToken(config, code) {
24
+ const params = new URLSearchParams({
25
+ client_id: config.clientId,
26
+ client_secret: config.clientSecret,
27
+ code,
28
+ redirect_uri: config.redirectUri
29
+ });
30
+ const url = `https://graph.facebook.com/${META_GRAPH_VERSION}/oauth/access_token?${params.toString()}`;
31
+ const response = await fetch(url);
32
+ if (!response.ok) {
33
+ const errorData = await response.text();
34
+ throw new OAuthError(`Meta token exchange failed: ${errorData}`, "TOKEN_EXCHANGE_FAILED");
35
+ }
36
+ return response.json();
37
+ }
38
+ async getUserInfo(accessToken) {
39
+ var _a, _b, _c, _d;
40
+ const url = `https://graph.facebook.com/${META_GRAPH_VERSION}/me?fields=id,name,email,picture`;
41
+ const response = await fetch(url, {
42
+ headers: { Authorization: `Bearer ${accessToken}` }
43
+ });
44
+ if (!response.ok) {
45
+ throw new OAuthError("Failed to get Meta user info", "USER_INFO_FAILED");
46
+ }
47
+ const data = await response.json();
48
+ if (!data.id) {
49
+ throw new OAuthError("Invalid Meta response: missing id", "INVALID_RESPONSE");
50
+ }
51
+ return {
52
+ id: data.id,
53
+ email: data.email,
54
+ name: (_a = data.name) != null ? _a : null,
55
+ image: (_d = (_c = (_b = data.picture) == null ? void 0 : _b.data) == null ? void 0 : _c.url) != null ? _d : null,
56
+ emailVerified: !!data.email
57
+ };
58
+ }
59
+ };
60
+
61
+ export {
62
+ MetaOAuthProvider
63
+ };
@@ -4,6 +4,9 @@ import {
4
4
  import {
5
5
  AuthError
6
6
  } from "./chunk-AIH3F7JV.js";
7
+ import {
8
+ JWT_DEFAULTS
9
+ } from "./chunk-C4TSQUFA.js";
7
10
 
8
11
  // src/auth/services/oauth-callback.service.ts
9
12
  var OAuthCallbackService = class {
@@ -13,9 +16,9 @@ var OAuthCallbackService = class {
13
16
  this.oauthRepo = config.oauthAccountRepository;
14
17
  this.jwtService = new JWTService({
15
18
  secret: config.jwtSecret,
16
- accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : "7d",
17
- refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : "30d",
18
- algorithm: "HS256"
19
+ accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : JWT_DEFAULTS.DEFAULT_ACCESS_TOKEN_EXPIRES,
20
+ refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES,
21
+ algorithm: JWT_DEFAULTS.ALGORITHM
19
22
  }, config.logger);
20
23
  this.logger = (_c = config.logger) != null ? _c : { debug() {
21
24
  }, info() {
@@ -59,7 +62,6 @@ var OAuthCallbackService = class {
59
62
  email: input.email,
60
63
  name: input.name,
61
64
  image: input.image,
62
- role: "USER",
63
65
  emailVerified: /* @__PURE__ */ new Date()
64
66
  // OAuth users are auto-verified
65
67
  });
@@ -32,7 +32,6 @@ var RegisterService = class {
32
32
  email: input.email,
33
33
  password: hashedPassword,
34
34
  name: (_a = input.name) != null ? _a : null,
35
- role: "USER",
36
35
  emailVerified: this.emailVerificationRequired ? null : /* @__PURE__ */ new Date()
37
36
  });
38
37
  let verificationSent = false;
@@ -4,6 +4,9 @@ import {
4
4
  import {
5
5
  AuthError
6
6
  } from "./chunk-AIH3F7JV.js";
7
+ import {
8
+ JWT_DEFAULTS
9
+ } from "./chunk-C4TSQUFA.js";
7
10
 
8
11
  // src/auth/services/token-refresh.service.ts
9
12
  var TokenRefreshService = class {
@@ -12,9 +15,9 @@ var TokenRefreshService = class {
12
15
  this.userRepo = config.userRepository;
13
16
  this.jwtService = new JWTService({
14
17
  secret: config.jwtSecret,
15
- accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : "7d",
16
- refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : "30d",
17
- algorithm: "HS256"
18
+ accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : JWT_DEFAULTS.DEFAULT_ACCESS_TOKEN_EXPIRES,
19
+ refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES,
20
+ algorithm: JWT_DEFAULTS.ALGORITHM
18
21
  }, config.logger);
19
22
  this.isTokenBlacklisted = config.isTokenBlacklisted;
20
23
  this.logger = (_c = config.logger) != null ? _c : { debug() {
@@ -3,10 +3,13 @@ import {
3
3
  } from "./chunk-3GAY2T2A.js";
4
4
  import {
5
5
  setTokenCookies
6
- } from "./chunk-V3ZIR4UL.js";
6
+ } from "./chunk-2O72OV5X.js";
7
7
  import {
8
8
  AuthError
9
9
  } from "./chunk-AIH3F7JV.js";
10
+ import {
11
+ JWT_DEFAULTS
12
+ } from "./chunk-C4TSQUFA.js";
10
13
  import {
11
14
  __spreadValues
12
15
  } from "./chunk-ORMEWXMH.js";
@@ -24,9 +27,9 @@ function createLoginHandler(options) {
24
27
  const { dependencies, jwt, hooks, features, cookie } = options;
25
28
  const jwtService = new JWTService({
26
29
  secret: jwt.secret,
27
- accessTokenExpiry: (_a = jwt.accessTokenExpiry) != null ? _a : "7d",
28
- refreshTokenExpiry: (_b = jwt.refreshTokenExpiry) != null ? _b : "30d",
29
- algorithm: "HS256"
30
+ accessTokenExpiry: (_a = jwt.accessTokenExpiry) != null ? _a : JWT_DEFAULTS.DEFAULT_ACCESS_TOKEN_EXPIRES,
31
+ refreshTokenExpiry: (_b = jwt.refreshTokenExpiry) != null ? _b : JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES,
32
+ algorithm: JWT_DEFAULTS.ALGORITHM
30
33
  });
31
34
  return async (request) => {
32
35
  var _a2;
@@ -35,9 +35,17 @@ var KakaoOAuthProvider = class {
35
35
  const errorData = await response.text();
36
36
  throw new OAuthError(`Kakao token exchange failed: ${errorData}`, "TOKEN_EXCHANGE_FAILED");
37
37
  }
38
- return response.json();
38
+ const data = await response.json();
39
+ if (data.error) {
40
+ throw new OAuthError(
41
+ `Kakao token exchange failed: ${data.error}${data.error_description ? ` - ${data.error_description}` : ""}`,
42
+ "TOKEN_EXCHANGE_FAILED"
43
+ );
44
+ }
45
+ return data;
39
46
  }
40
47
  async getUserInfo(accessToken) {
48
+ var _a, _b, _c, _d;
41
49
  const response = await fetch("https://kapi.kakao.com/v2/user/me", {
42
50
  headers: { Authorization: `Bearer ${accessToken}` }
43
51
  });
@@ -45,14 +53,17 @@ var KakaoOAuthProvider = class {
45
53
  throw new OAuthError("Failed to get Kakao user info", "USER_INFO_FAILED");
46
54
  }
47
55
  const data = await response.json();
48
- const account = data.kakao_account || {};
49
- const profile = account.profile || {};
56
+ if (!data.id) {
57
+ throw new OAuthError("Invalid Kakao response: missing id", "INVALID_RESPONSE");
58
+ }
59
+ const account = (_a = data.kakao_account) != null ? _a : {};
60
+ const profile = (_b = account.profile) != null ? _b : {};
50
61
  return {
51
62
  id: data.id.toString(),
52
63
  email: account.email,
53
- name: profile.nickname || null,
54
- image: profile.profile_image_url || null,
55
- emailVerified: account.is_email_verified || false
64
+ name: (_c = profile.nickname) != null ? _c : null,
65
+ image: (_d = profile.profile_image_url) != null ? _d : null,
66
+ emailVerified: account.is_email_valid === true && account.is_email_verified === true
56
67
  };
57
68
  }
58
69
  };
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  JWTService
3
3
  } from "./chunk-3GAY2T2A.js";
4
+ import {
5
+ JWT_DEFAULTS
6
+ } from "./chunk-C4TSQUFA.js";
4
7
  import {
5
8
  __spreadValues
6
9
  } from "./chunk-ORMEWXMH.js";
@@ -12,9 +15,9 @@ function createMeHandler(options) {
12
15
  const { dependencies, jwt, hooks } = options;
13
16
  const jwtService = new JWTService({
14
17
  secret: jwt.secret,
15
- accessTokenExpiry: (_a = jwt.accessTokenExpiry) != null ? _a : "7d",
16
- refreshTokenExpiry: (_b = jwt.refreshTokenExpiry) != null ? _b : "30d",
17
- algorithm: "HS256"
18
+ accessTokenExpiry: (_a = jwt.accessTokenExpiry) != null ? _a : JWT_DEFAULTS.DEFAULT_ACCESS_TOKEN_EXPIRES,
19
+ refreshTokenExpiry: (_b = jwt.refreshTokenExpiry) != null ? _b : JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES,
20
+ algorithm: JWT_DEFAULTS.ALGORITHM
18
21
  });
19
22
  return async (request) => {
20
23
  var _a2, _b2, _c;
@@ -0,0 +1,99 @@
1
+ import {
2
+ OAuthError
3
+ } from "./chunk-AIH3F7JV.js";
4
+
5
+ // src/auth/core/oauth/providers/microsoft.ts
6
+ import { decodeJwt } from "jose";
7
+ var MicrosoftOAuthProvider = class {
8
+ constructor() {
9
+ this.name = "microsoft";
10
+ }
11
+ getLoginUrl(config, state) {
12
+ const params = new URLSearchParams({
13
+ client_id: config.clientId,
14
+ redirect_uri: config.redirectUri,
15
+ response_type: "code",
16
+ response_mode: "query",
17
+ scope: "openid profile email"
18
+ });
19
+ if (state) {
20
+ params.set("state", state);
21
+ }
22
+ return `https://login.microsoftonline.com/common/oauth2/v2.0/authorize?${params.toString()}`;
23
+ }
24
+ async exchangeCodeForToken(config, code) {
25
+ var _a;
26
+ const response = await fetch("https://login.microsoftonline.com/common/oauth2/v2.0/token", {
27
+ method: "POST",
28
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
29
+ body: new URLSearchParams({
30
+ client_id: config.clientId,
31
+ client_secret: config.clientSecret,
32
+ code,
33
+ grant_type: "authorization_code",
34
+ redirect_uri: config.redirectUri,
35
+ scope: "openid profile email"
36
+ })
37
+ });
38
+ if (!response.ok) {
39
+ const errorData = await response.text();
40
+ throw new OAuthError(`Microsoft token exchange failed: ${errorData}`, "TOKEN_EXCHANGE_FAILED");
41
+ }
42
+ const data = await response.json();
43
+ if (data.error) {
44
+ throw new OAuthError(
45
+ `Microsoft token exchange failed: ${data.error}${data.error_description ? ` - ${data.error_description}` : ""}`,
46
+ "TOKEN_EXCHANGE_FAILED"
47
+ );
48
+ }
49
+ if (!data.id_token) {
50
+ throw new OAuthError("Missing id_token in Microsoft token response", "INVALID_RESPONSE");
51
+ }
52
+ const claims = decodeMicrosoftClaims(data.id_token);
53
+ assertMicrosoftClaims(claims, config.clientId);
54
+ return {
55
+ access_token: data.id_token,
56
+ token_type: (_a = data.token_type) != null ? _a : "Bearer",
57
+ expires_in: data.expires_in,
58
+ refresh_token: data.refresh_token,
59
+ scope: data.scope
60
+ };
61
+ }
62
+ async getUserInfo(idToken) {
63
+ var _a, _b;
64
+ const claims = decodeMicrosoftClaims(idToken);
65
+ assertMicrosoftClaims(claims);
66
+ return {
67
+ id: claims.oid,
68
+ email: (_a = claims.email) != null ? _a : claims.preferred_username,
69
+ name: (_b = claims.name) != null ? _b : null,
70
+ image: null,
71
+ emailVerified: claims.email_verified === true
72
+ };
73
+ }
74
+ };
75
+ function decodeMicrosoftClaims(token) {
76
+ try {
77
+ return decodeJwt(token);
78
+ } catch (e) {
79
+ throw new OAuthError("Invalid Microsoft id_token: malformed JWT", "INVALID_RESPONSE");
80
+ }
81
+ }
82
+ function assertMicrosoftClaims(claims, expectedAud) {
83
+ if (!claims.iss || !/^https:\/\/login\.microsoftonline\.com\/(?!common\/|consumers\/|organizations\/)[\w-]+\/v2\.0$/.test(claims.iss)) {
84
+ throw new OAuthError("Invalid Microsoft id_token: bad iss", "INVALID_RESPONSE");
85
+ }
86
+ if (expectedAud !== void 0 && claims.aud !== expectedAud) {
87
+ throw new OAuthError("Invalid Microsoft id_token: aud mismatch", "INVALID_RESPONSE");
88
+ }
89
+ if (!claims.exp || claims.exp < Math.floor(Date.now() / 1e3)) {
90
+ throw new OAuthError("Invalid Microsoft id_token: expired", "INVALID_RESPONSE");
91
+ }
92
+ if (!claims.oid) {
93
+ throw new OAuthError("Invalid Microsoft id_token: missing oid", "INVALID_RESPONSE");
94
+ }
95
+ }
96
+
97
+ export {
98
+ MicrosoftOAuthProvider
99
+ };
@@ -4,6 +4,9 @@ import {
4
4
  import {
5
5
  AuthError
6
6
  } from "./chunk-AIH3F7JV.js";
7
+ import {
8
+ JWT_DEFAULTS
9
+ } from "./chunk-C4TSQUFA.js";
7
10
 
8
11
  // src/auth/services/login.service.ts
9
12
  import { compare } from "bcryptjs";
@@ -13,9 +16,9 @@ var LoginService = class {
13
16
  this.userRepo = config.userRepository;
14
17
  this.jwtService = new JWTService({
15
18
  secret: config.jwtSecret,
16
- accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : "7d",
17
- refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : "30d",
18
- algorithm: "HS256"
19
+ accessTokenExpiry: (_a = config.accessTokenExpiry) != null ? _a : JWT_DEFAULTS.DEFAULT_ACCESS_TOKEN_EXPIRES,
20
+ refreshTokenExpiry: (_b = config.refreshTokenExpiry) != null ? _b : JWT_DEFAULTS.DEFAULT_REFRESH_TOKEN_EXPIRES,
21
+ algorithm: JWT_DEFAULTS.ALGORITHM
19
22
  }, config.logger);
20
23
  this.logger = (_c = config.logger) != null ? _c : { debug() {
21
24
  }, info() {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  OAuthCallbackService
3
- } from "./chunk-6B7VU6RZ.js";
3
+ } from "./chunk-Q26CQW7T.js";
4
4
  import {
5
5
  OAuthManager
6
- } from "./chunk-HZLJYEOO.js";
6
+ } from "./chunk-57HPJEZB.js";
7
7
  import {
8
8
  setTokenCookies
9
- } from "./chunk-V3ZIR4UL.js";
9
+ } from "./chunk-2O72OV5X.js";
10
10
  import {
11
11
  AuthError
12
12
  } from "./chunk-AIH3F7JV.js";
@@ -1,20 +1,20 @@
1
1
  import "../../chunk-R4SXQYIT.js";
2
2
  import {
3
3
  DataTable
4
- } from "../../chunk-FNECYXI4.js";
5
- import "../../chunk-5UVEOCRU.js";
4
+ } from "../../chunk-3X7D3NV4.js";
5
+ import "../../chunk-X2UP5PNN.js";
6
6
  import "../../chunk-WVDYHSHD.js";
7
7
  import "../../chunk-MEFZZE4M.js";
8
8
  import "../../chunk-7IY3RQQL.js";
9
9
  import "../../chunk-CRMXLNLC.js";
10
10
  import "../../chunk-I6Q3WUDT.js";
11
- import "../../chunk-YJWLWUFK.js";
12
- import "../../chunk-WDUFQFDP.js";
13
11
  import "../../chunk-34WAGUT5.js";
14
- import "../../chunk-F6LCSFSU.js";
15
12
  import "../../chunk-L25BNU3E.js";
16
13
  import "../../chunk-RJUVBBZG.js";
17
14
  import "../../chunk-IJEZ7G7S.js";
15
+ import "../../chunk-YJWLWUFK.js";
16
+ import "../../chunk-WDUFQFDP.js";
17
+ import "../../chunk-F6LCSFSU.js";
18
18
  import "../../chunk-62FLBG6B.js";
19
19
  import "../../chunk-ORMEWXMH.js";
20
20
  export {
@@ -1,20 +1,20 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTable
4
- } from "../../../chunk-FNECYXI4.js";
5
- import "../../../chunk-5UVEOCRU.js";
4
+ } from "../../../chunk-3X7D3NV4.js";
5
+ import "../../../chunk-X2UP5PNN.js";
6
6
  import "../../../chunk-WVDYHSHD.js";
7
7
  import "../../../chunk-MEFZZE4M.js";
8
8
  import "../../../chunk-7IY3RQQL.js";
9
9
  import "../../../chunk-CRMXLNLC.js";
10
10
  import "../../../chunk-I6Q3WUDT.js";
11
- import "../../../chunk-YJWLWUFK.js";
12
- import "../../../chunk-WDUFQFDP.js";
13
11
  import "../../../chunk-34WAGUT5.js";
14
- import "../../../chunk-F6LCSFSU.js";
15
12
  import "../../../chunk-L25BNU3E.js";
16
13
  import "../../../chunk-RJUVBBZG.js";
17
14
  import "../../../chunk-IJEZ7G7S.js";
15
+ import "../../../chunk-YJWLWUFK.js";
16
+ import "../../../chunk-WDUFQFDP.js";
17
+ import "../../../chunk-F6LCSFSU.js";
18
18
  import "../../../chunk-62FLBG6B.js";
19
19
  import "../../../chunk-ORMEWXMH.js";
20
20
  export {
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  DataTableFilters
4
- } from "../../../chunk-5UVEOCRU.js";
5
- import "../../../chunk-WDUFQFDP.js";
4
+ } from "../../../chunk-X2UP5PNN.js";
6
5
  import "../../../chunk-L25BNU3E.js";
7
6
  import "../../../chunk-RJUVBBZG.js";
8
7
  import "../../../chunk-IJEZ7G7S.js";
8
+ import "../../../chunk-WDUFQFDP.js";
9
9
  import "../../../chunk-62FLBG6B.js";
10
10
  import "../../../chunk-ORMEWXMH.js";
11
11
  export {