@spfn/auth 0.2.0-beta.33 → 0.2.0-beta.35

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.
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { k as AuthInitOptions, l as KeyAlgorithmType, n as InvitationStatus, f as VerificationPurpose, j as PermissionCategory, p as SocialProvider, q as AuthContext } from './authenticate-CGslXjZb.js';
2
- export { B as ChangePasswordParams, w as CheckAccountExistsParams, C as CheckAccountExistsResult, a6 as EmailSchema, I as INVITATION_STATUSES, K as KEY_ALGORITHM, y as LoginParams, L as LoginResult, z as LogoutParams, a2 as OAuthCallbackParams, a3 as OAuthCallbackResult, a1 as OAuthStartParams, O as OAuthStartResult, a8 as PasswordSchema, a7 as PhoneSchema, x as RegisterParams, Q as RegisterPublicKeyParams, a as RegisterResult, W as RevokeKeyParams, T as RotateKeyParams, b as RotateKeyResult, e as SOCIAL_PROVIDERS, F as SendVerificationCodeParams, S as SendVerificationCodeResult, a9 as TargetTypeSchema, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, aa as VerificationPurposeSchema, V as VerificationTargetType, G as VerifyCodeParams, H as VerifyCodeResult, m as authRouter, a4 as authenticate, Z as buildOAuthErrorUrl, v as changePasswordService, r as checkAccountExistsService, $ as getEnabledOAuthProviders, a0 as getGoogleAccessToken, _ as isOAuthProviderEnabled, t as loginService, u as logoutService, Y as oauthCallbackService, X as oauthStartService, a5 as optionalAuth, J as registerPublicKeyService, s as registerService, N as revokeKeyService, M as rotateKeyService, D as sendVerificationCodeService, E as verifyCodeService } from './authenticate-CGslXjZb.js';
1
+ import { k as AuthInitOptions, l as KeyAlgorithmType, n as InvitationStatus, f as VerificationPurpose, j as PermissionCategory, p as SocialProvider, q as AuthContext } from './authenticate-vcXIhj1J.js';
2
+ export { B as ChangePasswordParams, w as CheckAccountExistsParams, C as CheckAccountExistsResult, a6 as EmailSchema, I as INVITATION_STATUSES, K as KEY_ALGORITHM, y as LoginParams, L as LoginResult, z as LogoutParams, a2 as OAuthCallbackParams, a3 as OAuthCallbackResult, a1 as OAuthStartParams, O as OAuthStartResult, a8 as PasswordSchema, a7 as PhoneSchema, x as RegisterParams, Q as RegisterPublicKeyParams, a as RegisterResult, W as RevokeKeyParams, T as RotateKeyParams, b as RotateKeyResult, e as SOCIAL_PROVIDERS, F as SendVerificationCodeParams, S as SendVerificationCodeResult, a9 as TargetTypeSchema, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, aa as VerificationPurposeSchema, V as VerificationTargetType, G as VerifyCodeParams, H as VerifyCodeResult, m as authRouter, a4 as authenticate, Z as buildOAuthErrorUrl, v as changePasswordService, r as checkAccountExistsService, $ as getEnabledOAuthProviders, a0 as getGoogleAccessToken, _ as isOAuthProviderEnabled, t as loginService, u as logoutService, Y as oauthCallbackService, X as oauthStartService, a5 as optionalAuth, J as registerPublicKeyService, s as registerService, N as revokeKeyService, M as rotateKeyService, D as sendVerificationCodeService, E as verifyCodeService } from './authenticate-vcXIhj1J.js';
3
3
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
4
4
  import { UserProfile as UserProfile$1, ProfileInfo } from '@spfn/auth';
5
5
  import { BaseRepository } from '@spfn/core/db';
@@ -168,11 +168,11 @@ declare const users: drizzle_orm_pg_core.PgTableWithColumns<{
168
168
  name: `${string}_id`;
169
169
  tableName: "users";
170
170
  dataType: "number";
171
- columnType: "PgBigSerial53";
171
+ columnType: "PgBigInt53";
172
172
  data: number;
173
- driverParam: number;
173
+ driverParam: string | number;
174
174
  notNull: true;
175
- hasDefault: true;
175
+ hasDefault: false;
176
176
  isPrimaryKey: false;
177
177
  isAutoincrement: false;
178
178
  hasRuntimeDefault: false;
@@ -930,11 +930,11 @@ declare const userInvitations: drizzle_orm_pg_core.PgTableWithColumns<{
930
930
  name: `${string}_id`;
931
931
  tableName: "user_invitations";
932
932
  dataType: "number";
933
- columnType: "PgBigSerial53";
933
+ columnType: "PgBigInt53";
934
934
  data: number;
935
- driverParam: number;
935
+ driverParam: string | number;
936
936
  notNull: true;
937
- hasDefault: true;
937
+ hasDefault: false;
938
938
  isPrimaryKey: false;
939
939
  isAutoincrement: false;
940
940
  hasRuntimeDefault: false;
@@ -947,11 +947,11 @@ declare const userInvitations: drizzle_orm_pg_core.PgTableWithColumns<{
947
947
  name: `${string}_id`;
948
948
  tableName: "user_invitations";
949
949
  dataType: "number";
950
- columnType: "PgBigSerial53";
950
+ columnType: "PgBigInt53";
951
951
  data: number;
952
- driverParam: number;
952
+ driverParam: string | number;
953
953
  notNull: true;
954
- hasDefault: true;
954
+ hasDefault: false;
955
955
  isPrimaryKey: false;
956
956
  isAutoincrement: false;
957
957
  hasRuntimeDefault: false;
@@ -1305,7 +1305,7 @@ declare function getAuthSessionService(userId: string | number | bigint): Promis
1305
1305
  id: number;
1306
1306
  name: string;
1307
1307
  displayName: string;
1308
- category: "custom" | "user" | "auth" | "rbac" | "system" | undefined;
1308
+ category: "auth" | "custom" | "user" | "rbac" | "system" | undefined;
1309
1309
  }[];
1310
1310
  userId: number;
1311
1311
  email: string | null;
@@ -1355,6 +1355,16 @@ interface UpdateProfileParams {
1355
1355
  * ```
1356
1356
  */
1357
1357
  declare function getUserProfileService(userId: string | number | bigint): Promise<UserProfile$1>;
1358
+ /**
1359
+ * Update user locale
1360
+ *
1361
+ * @param userId - User ID
1362
+ * @param locale - Locale code (e.g., 'en', 'ko', 'ja')
1363
+ * @returns Updated locale
1364
+ */
1365
+ declare function updateLocaleService(userId: string | number | bigint, locale: string): Promise<{
1366
+ locale: string;
1367
+ }>;
1358
1368
  /**
1359
1369
  * Update user profile (upsert)
1360
1370
  *
@@ -1458,11 +1468,11 @@ declare const userProfiles: drizzle_orm_pg_core.PgTableWithColumns<{
1458
1468
  name: `${string}_id`;
1459
1469
  tableName: "user_profiles";
1460
1470
  dataType: "number";
1461
- columnType: "PgBigSerial53";
1471
+ columnType: "PgBigInt53";
1462
1472
  data: number;
1463
- driverParam: number;
1473
+ driverParam: string | number;
1464
1474
  notNull: true;
1465
- hasDefault: true;
1475
+ hasDefault: false;
1466
1476
  isPrimaryKey: false;
1467
1477
  isAutoincrement: false;
1468
1478
  hasRuntimeDefault: false;
@@ -1752,11 +1762,11 @@ declare const userPublicKeys: drizzle_orm_pg_core.PgTableWithColumns<{
1752
1762
  name: `${string}_id`;
1753
1763
  tableName: "user_public_keys";
1754
1764
  dataType: "number";
1755
- columnType: "PgBigSerial53";
1765
+ columnType: "PgBigInt53";
1756
1766
  data: number;
1757
- driverParam: number;
1767
+ driverParam: string | number;
1758
1768
  notNull: true;
1759
- hasDefault: true;
1769
+ hasDefault: false;
1760
1770
  isPrimaryKey: false;
1761
1771
  isAutoincrement: false;
1762
1772
  hasRuntimeDefault: false;
@@ -2005,11 +2015,11 @@ declare const userSocialAccounts: drizzle_orm_pg_core.PgTableWithColumns<{
2005
2015
  name: `${string}_id`;
2006
2016
  tableName: "user_social_accounts";
2007
2017
  dataType: "number";
2008
- columnType: "PgBigSerial53";
2018
+ columnType: "PgBigInt53";
2009
2019
  data: number;
2010
- driverParam: number;
2020
+ driverParam: string | number;
2011
2021
  notNull: true;
2012
- hasDefault: true;
2022
+ hasDefault: false;
2013
2023
  isPrimaryKey: false;
2014
2024
  isAutoincrement: false;
2015
2025
  hasRuntimeDefault: false;
@@ -2434,7 +2444,7 @@ declare const permissions: drizzle_orm_pg_core.PgTableWithColumns<{
2434
2444
  tableName: "permissions";
2435
2445
  dataType: "string";
2436
2446
  columnType: "PgText";
2437
- data: "custom" | "user" | "auth" | "rbac" | "system";
2447
+ data: "auth" | "custom" | "user" | "rbac" | "system";
2438
2448
  driverParam: string;
2439
2449
  notNull: false;
2440
2450
  hasDefault: false;
@@ -2592,11 +2602,11 @@ declare const rolePermissions: drizzle_orm_pg_core.PgTableWithColumns<{
2592
2602
  name: `${string}_id`;
2593
2603
  tableName: "role_permissions";
2594
2604
  dataType: "number";
2595
- columnType: "PgBigSerial53";
2605
+ columnType: "PgBigInt53";
2596
2606
  data: number;
2597
- driverParam: number;
2607
+ driverParam: string | number;
2598
2608
  notNull: true;
2599
- hasDefault: true;
2609
+ hasDefault: false;
2600
2610
  isPrimaryKey: false;
2601
2611
  isAutoincrement: false;
2602
2612
  hasRuntimeDefault: false;
@@ -2609,11 +2619,11 @@ declare const rolePermissions: drizzle_orm_pg_core.PgTableWithColumns<{
2609
2619
  name: `${string}_id`;
2610
2620
  tableName: "role_permissions";
2611
2621
  dataType: "number";
2612
- columnType: "PgBigSerial53";
2622
+ columnType: "PgBigInt53";
2613
2623
  data: number;
2614
- driverParam: number;
2624
+ driverParam: string | number;
2615
2625
  notNull: true;
2616
- hasDefault: true;
2626
+ hasDefault: false;
2617
2627
  isPrimaryKey: false;
2618
2628
  isAutoincrement: false;
2619
2629
  hasRuntimeDefault: false;
@@ -2701,11 +2711,11 @@ declare const userPermissions: drizzle_orm_pg_core.PgTableWithColumns<{
2701
2711
  name: `${string}_id`;
2702
2712
  tableName: "user_permissions";
2703
2713
  dataType: "number";
2704
- columnType: "PgBigSerial53";
2714
+ columnType: "PgBigInt53";
2705
2715
  data: number;
2706
- driverParam: number;
2716
+ driverParam: string | number;
2707
2717
  notNull: true;
2708
- hasDefault: true;
2718
+ hasDefault: false;
2709
2719
  isPrimaryKey: false;
2710
2720
  isAutoincrement: false;
2711
2721
  hasRuntimeDefault: false;
@@ -2718,11 +2728,11 @@ declare const userPermissions: drizzle_orm_pg_core.PgTableWithColumns<{
2718
2728
  name: `${string}_id`;
2719
2729
  tableName: "user_permissions";
2720
2730
  dataType: "number";
2721
- columnType: "PgBigSerial53";
2731
+ columnType: "PgBigInt53";
2722
2732
  data: number;
2723
- driverParam: number;
2733
+ driverParam: string | number;
2724
2734
  notNull: true;
2725
- hasDefault: true;
2735
+ hasDefault: false;
2726
2736
  isPrimaryKey: false;
2727
2737
  isAutoincrement: false;
2728
2738
  hasRuntimeDefault: false;
@@ -2934,14 +2944,14 @@ declare class UsersRepository extends BaseRepository {
2934
2944
  create(data: NewUser): Promise<{
2935
2945
  email: string | null;
2936
2946
  phone: string | null;
2937
- status: "active" | "inactive" | "suspended";
2938
- username: string | null;
2939
2947
  id: number;
2940
- createdAt: Date;
2941
- updatedAt: Date;
2948
+ username: string | null;
2942
2949
  passwordHash: string | null;
2943
2950
  passwordChangeRequired: boolean;
2944
2951
  roleId: number;
2952
+ createdAt: Date;
2953
+ updatedAt: Date;
2954
+ status: "active" | "inactive" | "suspended";
2945
2955
  emailVerifiedAt: Date | null;
2946
2956
  phoneVerifiedAt: Date | null;
2947
2957
  lastLoginAt: Date | null;
@@ -3010,14 +3020,14 @@ declare class UsersRepository extends BaseRepository {
3010
3020
  deleteById(id: number): Promise<{
3011
3021
  email: string | null;
3012
3022
  phone: string | null;
3013
- status: "active" | "inactive" | "suspended";
3014
- username: string | null;
3015
3023
  id: number;
3016
- createdAt: Date;
3017
- updatedAt: Date;
3024
+ username: string | null;
3018
3025
  passwordHash: string | null;
3019
3026
  passwordChangeRequired: boolean;
3020
3027
  roleId: number;
3028
+ createdAt: Date;
3029
+ updatedAt: Date;
3030
+ status: "active" | "inactive" | "suspended";
3021
3031
  emailVerifiedAt: Date | null;
3022
3032
  phoneVerifiedAt: Date | null;
3023
3033
  lastLoginAt: Date | null;
@@ -3040,7 +3050,7 @@ declare class UsersRepository extends BaseRepository {
3040
3050
  id: number;
3041
3051
  name: string;
3042
3052
  displayName: string;
3043
- category: "custom" | "user" | "auth" | "rbac" | "system" | undefined;
3053
+ category: "auth" | "custom" | "user" | "rbac" | "system" | undefined;
3044
3054
  }[];
3045
3055
  }>;
3046
3056
  /**
@@ -3152,16 +3162,16 @@ declare class KeysRepository extends BaseRepository {
3152
3162
  * Write primary 사용
3153
3163
  */
3154
3164
  create(data: NewUserPublicKey): Promise<{
3155
- userId: number;
3165
+ publicKey: string;
3156
3166
  keyId: string;
3167
+ fingerprint: string;
3168
+ algorithm: "ES256" | "RS256";
3169
+ userId: number;
3157
3170
  id: number;
3158
3171
  isActive: boolean;
3159
3172
  createdAt: Date;
3160
- publicKey: string;
3161
- algorithm: "ES256" | "RS256";
3162
- fingerprint: string;
3163
- lastUsedAt: Date | null;
3164
3173
  expiresAt: Date | null;
3174
+ lastUsedAt: Date | null;
3165
3175
  revokedAt: Date | null;
3166
3176
  revokedReason: string | null;
3167
3177
  }>;
@@ -3188,16 +3198,16 @@ declare class KeysRepository extends BaseRepository {
3188
3198
  * Write primary 사용
3189
3199
  */
3190
3200
  deleteByKeyIdAndUserId(keyId: string, userId: number): Promise<{
3191
- userId: number;
3201
+ publicKey: string;
3192
3202
  keyId: string;
3203
+ fingerprint: string;
3204
+ algorithm: "ES256" | "RS256";
3205
+ userId: number;
3193
3206
  id: number;
3194
3207
  isActive: boolean;
3195
3208
  createdAt: Date;
3196
- publicKey: string;
3197
- algorithm: "ES256" | "RS256";
3198
- fingerprint: string;
3199
- lastUsedAt: Date | null;
3200
3209
  expiresAt: Date | null;
3210
+ lastUsedAt: Date | null;
3201
3211
  revokedAt: Date | null;
3202
3212
  revokedReason: string | null;
3203
3213
  }>;
@@ -3312,14 +3322,14 @@ declare class VerificationCodesRepository extends BaseRepository {
3312
3322
  * Write primary 사용
3313
3323
  */
3314
3324
  create(data: NewVerificationCode): Promise<{
3325
+ target: string;
3326
+ targetType: "email" | "phone";
3327
+ purpose: "registration" | "login" | "password_reset" | "email_change" | "phone_change";
3328
+ code: string;
3315
3329
  id: number;
3316
3330
  createdAt: Date;
3317
3331
  updatedAt: Date;
3318
3332
  expiresAt: Date;
3319
- target: string;
3320
- targetType: "email" | "phone";
3321
- code: string;
3322
- purpose: "registration" | "login" | "password_reset" | "email_change" | "phone_change";
3323
3333
  usedAt: Date | null;
3324
3334
  attempts: number;
3325
3335
  }>;
@@ -3508,7 +3518,7 @@ declare class PermissionsRepository extends BaseRepository {
3508
3518
  name: string;
3509
3519
  displayName: string;
3510
3520
  description: string | null;
3511
- category: "custom" | "user" | "auth" | "rbac" | "system" | null;
3521
+ category: "auth" | "custom" | "user" | "rbac" | "system" | null;
3512
3522
  isBuiltin: boolean;
3513
3523
  isSystem: boolean;
3514
3524
  isActive: boolean;
@@ -3524,7 +3534,7 @@ declare class PermissionsRepository extends BaseRepository {
3524
3534
  name: string;
3525
3535
  displayName: string;
3526
3536
  description: string | null;
3527
- category: "custom" | "user" | "auth" | "rbac" | "system" | null;
3537
+ category: "auth" | "custom" | "user" | "rbac" | "system" | null;
3528
3538
  isBuiltin: boolean;
3529
3539
  isSystem: boolean;
3530
3540
  isActive: boolean;
@@ -3564,7 +3574,7 @@ declare class PermissionsRepository extends BaseRepository {
3564
3574
  name: string;
3565
3575
  displayName: string;
3566
3576
  description: string | null;
3567
- category: "custom" | "user" | "auth" | "rbac" | "system" | null;
3577
+ category: "auth" | "custom" | "user" | "rbac" | "system" | null;
3568
3578
  isBuiltin: boolean;
3569
3579
  isSystem: boolean;
3570
3580
  isActive: boolean;
@@ -3583,8 +3593,8 @@ declare class PermissionsRepository extends BaseRepository {
3583
3593
  isActive: boolean;
3584
3594
  createdAt: Date;
3585
3595
  updatedAt: Date;
3596
+ category: "auth" | "custom" | "user" | "rbac" | "system" | null;
3586
3597
  metadata: Record<string, any> | null;
3587
- category: "custom" | "user" | "auth" | "rbac" | "system" | null;
3588
3598
  }>;
3589
3599
  }
3590
3600
  declare const permissionsRepository: PermissionsRepository;
@@ -3629,9 +3639,9 @@ declare class RolePermissionsRepository extends BaseRepository {
3629
3639
  */
3630
3640
  createMany(data: NewRolePermission[]): Promise<{
3631
3641
  id: number;
3642
+ roleId: number;
3632
3643
  createdAt: Date;
3633
3644
  updatedAt: Date;
3634
- roleId: number;
3635
3645
  permissionId: number;
3636
3646
  }[]>;
3637
3647
  /**
@@ -3647,9 +3657,9 @@ declare class RolePermissionsRepository extends BaseRepository {
3647
3657
  */
3648
3658
  setPermissionsForRole(roleId: number, permissionIds: number[]): Promise<{
3649
3659
  id: number;
3660
+ roleId: number;
3650
3661
  createdAt: Date;
3651
3662
  updatedAt: Date;
3652
- roleId: number;
3653
3663
  permissionId: number;
3654
3664
  }[]>;
3655
3665
  }
@@ -3714,10 +3724,10 @@ declare class UserPermissionsRepository extends BaseRepository {
3714
3724
  id: number;
3715
3725
  createdAt: Date;
3716
3726
  updatedAt: Date;
3717
- expiresAt: Date | null;
3718
3727
  permissionId: number;
3719
- granted: boolean;
3728
+ expiresAt: Date | null;
3720
3729
  reason: string | null;
3730
+ granted: boolean;
3721
3731
  }>;
3722
3732
  /**
3723
3733
  * 사용자 권한 오버라이드 업데이트
@@ -3740,10 +3750,10 @@ declare class UserPermissionsRepository extends BaseRepository {
3740
3750
  id: number;
3741
3751
  createdAt: Date;
3742
3752
  updatedAt: Date;
3743
- expiresAt: Date | null;
3744
3753
  permissionId: number;
3745
- granted: boolean;
3754
+ expiresAt: Date | null;
3746
3755
  reason: string | null;
3756
+ granted: boolean;
3747
3757
  }>;
3748
3758
  /**
3749
3759
  * 사용자의 모든 권한 오버라이드 삭제
@@ -3790,6 +3800,10 @@ declare class UserProfilesRepository extends BaseRepository {
3790
3800
  jobTitle: string | null;
3791
3801
  metadata: Record<string, any> | null;
3792
3802
  }>;
3803
+ /**
3804
+ * User ID로 locale만 조회 (경량)
3805
+ */
3806
+ findLocaleByUserId(userId: number): Promise<string>;
3793
3807
  /**
3794
3808
  * User ID로 프로필 조회
3795
3809
  */
@@ -3822,6 +3836,7 @@ declare class UserProfilesRepository extends BaseRepository {
3822
3836
  displayName: string;
3823
3837
  createdAt: Date;
3824
3838
  updatedAt: Date;
3839
+ metadata: Record<string, any> | null;
3825
3840
  firstName: string | null;
3826
3841
  lastName: string | null;
3827
3842
  avatarUrl: string | null;
@@ -3834,7 +3849,6 @@ declare class UserProfilesRepository extends BaseRepository {
3834
3849
  location: string | null;
3835
3850
  company: string | null;
3836
3851
  jobTitle: string | null;
3837
- metadata: Record<string, any> | null;
3838
3852
  }>;
3839
3853
  /**
3840
3854
  * 프로필 업데이트 (by ID)
@@ -3891,6 +3905,7 @@ declare class UserProfilesRepository extends BaseRepository {
3891
3905
  displayName: string;
3892
3906
  createdAt: Date;
3893
3907
  updatedAt: Date;
3908
+ metadata: Record<string, any> | null;
3894
3909
  firstName: string | null;
3895
3910
  lastName: string | null;
3896
3911
  avatarUrl: string | null;
@@ -3903,7 +3918,6 @@ declare class UserProfilesRepository extends BaseRepository {
3903
3918
  location: string | null;
3904
3919
  company: string | null;
3905
3920
  jobTitle: string | null;
3906
- metadata: Record<string, any> | null;
3907
3921
  }>;
3908
3922
  /**
3909
3923
  * 프로필 삭제 (by User ID)
@@ -3914,6 +3928,7 @@ declare class UserProfilesRepository extends BaseRepository {
3914
3928
  displayName: string;
3915
3929
  createdAt: Date;
3916
3930
  updatedAt: Date;
3931
+ metadata: Record<string, any> | null;
3917
3932
  firstName: string | null;
3918
3933
  lastName: string | null;
3919
3934
  avatarUrl: string | null;
@@ -3926,7 +3941,6 @@ declare class UserProfilesRepository extends BaseRepository {
3926
3941
  location: string | null;
3927
3942
  company: string | null;
3928
3943
  jobTitle: string | null;
3929
- metadata: Record<string, any> | null;
3930
3944
  }>;
3931
3945
  /**
3932
3946
  * 프로필 Upsert (by User ID)
@@ -3940,6 +3954,7 @@ declare class UserProfilesRepository extends BaseRepository {
3940
3954
  displayName: string;
3941
3955
  createdAt: Date;
3942
3956
  updatedAt: Date;
3957
+ metadata: Record<string, any> | null;
3943
3958
  firstName: string | null;
3944
3959
  lastName: string | null;
3945
3960
  avatarUrl: string | null;
@@ -3952,7 +3967,6 @@ declare class UserProfilesRepository extends BaseRepository {
3952
3967
  location: string | null;
3953
3968
  company: string | null;
3954
3969
  jobTitle: string | null;
3955
- metadata: Record<string, any> | null;
3956
3970
  }>;
3957
3971
  /**
3958
3972
  * User ID로 프로필 데이터 조회 (formatted)
@@ -4080,15 +4094,15 @@ declare class InvitationsRepository extends BaseRepository {
4080
4094
  */
4081
4095
  create(data: NewInvitation): Promise<{
4082
4096
  email: string;
4083
- status: "pending" | "accepted" | "expired" | "cancelled";
4084
4097
  id: number;
4098
+ roleId: number;
4085
4099
  createdAt: Date;
4086
4100
  updatedAt: Date;
4087
- roleId: number;
4101
+ status: "pending" | "accepted" | "expired" | "cancelled";
4088
4102
  metadata: Record<string, any> | null;
4089
- expiresAt: Date;
4090
4103
  token: string;
4091
4104
  invitedBy: number;
4105
+ expiresAt: Date;
4092
4106
  acceptedAt: Date | null;
4093
4107
  cancelledAt: Date | null;
4094
4108
  }>;
@@ -4114,15 +4128,15 @@ declare class InvitationsRepository extends BaseRepository {
4114
4128
  */
4115
4129
  deleteById(id: number): Promise<{
4116
4130
  email: string;
4117
- status: "pending" | "accepted" | "expired" | "cancelled";
4118
4131
  id: number;
4132
+ roleId: number;
4119
4133
  createdAt: Date;
4120
4134
  updatedAt: Date;
4121
- roleId: number;
4135
+ status: "pending" | "accepted" | "expired" | "cancelled";
4122
4136
  metadata: Record<string, any> | null;
4123
- expiresAt: Date;
4124
4137
  token: string;
4125
4138
  invitedBy: number;
4139
+ expiresAt: Date;
4126
4140
  acceptedAt: Date | null;
4127
4141
  cancelledAt: Date | null;
4128
4142
  }>;
@@ -4789,14 +4803,14 @@ declare function getUser(c: Context | {
4789
4803
  }): {
4790
4804
  email: string | null;
4791
4805
  phone: string | null;
4792
- status: "active" | "inactive" | "suspended";
4793
- username: string | null;
4794
4806
  id: number;
4795
- createdAt: Date;
4796
- updatedAt: Date;
4807
+ username: string | null;
4797
4808
  passwordHash: string | null;
4798
4809
  passwordChangeRequired: boolean;
4799
4810
  roleId: number;
4811
+ createdAt: Date;
4812
+ updatedAt: Date;
4813
+ status: "active" | "inactive" | "suspended";
4800
4814
  emailVerifiedAt: Date | null;
4801
4815
  phoneVerifiedAt: Date | null;
4802
4816
  lastLoginAt: Date | null;
@@ -4831,6 +4845,22 @@ declare function getUserId(c: Context | {
4831
4845
  declare function getRole(c: Context | {
4832
4846
  raw: Context;
4833
4847
  }): string | null;
4848
+ /**
4849
+ * Get authenticated user's locale from route context
4850
+ *
4851
+ * @returns Locale string (e.g., 'en', 'ko')
4852
+ *
4853
+ * @example
4854
+ * ```typescript
4855
+ * app.bind(contract, [authenticate], async (c) => {
4856
+ * const locale = getLocale(c);
4857
+ * // 'en' | 'ko' | ...
4858
+ * });
4859
+ * ```
4860
+ */
4861
+ declare function getLocale(c: Context | {
4862
+ raw: Context;
4863
+ }): string;
4834
4864
  /**
4835
4865
  * Get current key ID from route context
4836
4866
  *
@@ -5285,4 +5315,4 @@ declare const authRegisterEvent: _spfn_core_event.EventDef<{
5285
5315
  type AuthLoginPayload = typeof authLoginEvent._payload;
5286
5316
  type AuthRegisterPayload = typeof authRegisterEvent._payload;
5287
5317
 
5288
- export { type AuthConfig, AuthContext, type AuthLoginPayload, AuthProviderSchema, type AuthRegisterPayload, COOKIE_NAMES, type CreateOAuthStateParams, type GoogleTokenResponse, type GoogleUserInfo, type Invitation, InvitationStatus, InvitationsRepository, KeyAlgorithmType, type KeyPair, KeysRepository, type NewInvitation, type NewPermission, type NewPermissionEntity, type NewRole, type NewRoleEntity, type NewRolePermission, type NewUser, type NewUserPermission, type NewUserProfile, type NewUserPublicKey, type NewUserSocialAccount, type NewVerificationCode, type OAuthState, type Permission, type PermissionEntity, PermissionsRepository, type Role, type RoleEntity, type RoleGuardOptions, type RolePermission, RolePermissionsRepository, RolesRepository, type SessionData, type SessionPayload, SocialAccountsRepository, SocialProvider, type TokenPayload, type UpdateProfileParams, type User, type UserPermission, UserPermissionsRepository, type UserProfile, UserProfilesRepository, type UserPublicKey, type UserSocialAccount, UsersRepository, type VerificationCode, VerificationCodesRepository, VerificationPurpose, acceptInvitation, addPermissionToRole, authLogger, authLoginEvent, authRegisterEvent, authSchema, cancelInvitation, checkUsernameAvailableService, configureAuth, createAuthLifecycle, createInvitation, createOAuthState, createRole, decodeToken, deleteInvitation, deleteRole, exchangeCodeForTokens, expireOldInvitations, generateClientToken, generateKeyPair, generateKeyPairES256, generateKeyPairRS256, generateToken, getAllRoles, getAuth, getAuthConfig, getAuthSessionService, getGoogleAuthUrl, getGoogleOAuthConfig, getGoogleUserInfo, getInvitationByToken, getInvitationWithDetails, getKeyId, getKeySize, getOptionalAuth, getRole, getRoleByName, getRolePermissions, getSessionInfo, getSessionTtl, getUser, getUserByEmailService, getUserByIdService, getUserByPhoneService, getUserId, getUserPermissions, getUserProfileService, getUserRole, hasAllPermissions, hasAnyPermission, hasAnyRole, hasPermission, hasRole, hashPassword, initializeAuth, invitationsRepository, isGoogleOAuthEnabled, keysRepository, listInvitations, parseDuration, permissions, permissionsRepository, refreshAccessToken, removePermissionFromRole, requireAnyPermission, requirePermissions, requireRole, resendInvitation, roleGuard, rolePermissions, rolePermissionsRepository, roles, rolesRepository, sealSession, setRolePermissions, shouldRefreshSession, shouldRotateKey, socialAccountsRepository, unsealSession, updateLastLoginService, updateRole, updateUserProfileService, updateUserService, updateUsernameService, userInvitations, userPermissions, userPermissionsRepository, userProfiles, userProfilesRepository, userPublicKeys, userSocialAccounts, users, usersRepository, validateInvitation, validatePasswordStrength, verificationCodes, verificationCodesRepository, verifyClientToken, verifyKeyFingerprint, verifyOAuthState, verifyPassword, verifyToken };
5318
+ export { type AuthConfig, AuthContext, type AuthLoginPayload, AuthProviderSchema, type AuthRegisterPayload, COOKIE_NAMES, type CreateOAuthStateParams, type GoogleTokenResponse, type GoogleUserInfo, type Invitation, InvitationStatus, InvitationsRepository, KeyAlgorithmType, type KeyPair, KeysRepository, type NewInvitation, type NewPermission, type NewPermissionEntity, type NewRole, type NewRoleEntity, type NewRolePermission, type NewUser, type NewUserPermission, type NewUserProfile, type NewUserPublicKey, type NewUserSocialAccount, type NewVerificationCode, type OAuthState, type Permission, type PermissionEntity, PermissionsRepository, type Role, type RoleEntity, type RoleGuardOptions, type RolePermission, RolePermissionsRepository, RolesRepository, type SessionData, type SessionPayload, SocialAccountsRepository, SocialProvider, type TokenPayload, type UpdateProfileParams, type User, type UserPermission, UserPermissionsRepository, type UserProfile, UserProfilesRepository, type UserPublicKey, type UserSocialAccount, UsersRepository, type VerificationCode, VerificationCodesRepository, VerificationPurpose, acceptInvitation, addPermissionToRole, authLogger, authLoginEvent, authRegisterEvent, authSchema, cancelInvitation, checkUsernameAvailableService, configureAuth, createAuthLifecycle, createInvitation, createOAuthState, createRole, decodeToken, deleteInvitation, deleteRole, exchangeCodeForTokens, expireOldInvitations, generateClientToken, generateKeyPair, generateKeyPairES256, generateKeyPairRS256, generateToken, getAllRoles, getAuth, getAuthConfig, getAuthSessionService, getGoogleAuthUrl, getGoogleOAuthConfig, getGoogleUserInfo, getInvitationByToken, getInvitationWithDetails, getKeyId, getKeySize, getLocale, getOptionalAuth, getRole, getRoleByName, getRolePermissions, getSessionInfo, getSessionTtl, getUser, getUserByEmailService, getUserByIdService, getUserByPhoneService, getUserId, getUserPermissions, getUserProfileService, getUserRole, hasAllPermissions, hasAnyPermission, hasAnyRole, hasPermission, hasRole, hashPassword, initializeAuth, invitationsRepository, isGoogleOAuthEnabled, keysRepository, listInvitations, parseDuration, permissions, permissionsRepository, refreshAccessToken, removePermissionFromRole, requireAnyPermission, requirePermissions, requireRole, resendInvitation, roleGuard, rolePermissions, rolePermissionsRepository, roles, rolesRepository, sealSession, setRolePermissions, shouldRefreshSession, shouldRotateKey, socialAccountsRepository, unsealSession, updateLastLoginService, updateLocaleService, updateRole, updateUserProfileService, updateUserService, updateUsernameService, userInvitations, userPermissions, userPermissionsRepository, userProfiles, userProfilesRepository, userPublicKeys, userSocialAccounts, users, usersRepository, validateInvitation, validatePasswordStrength, verificationCodes, verificationCodesRepository, verifyClientToken, verifyKeyFingerprint, verifyOAuthState, verifyPassword, verifyToken };
package/dist/server.js CHANGED
@@ -6119,6 +6119,13 @@ var init_user_profiles_repository = __esm({
6119
6119
  const result = await this.readDb.select().from(userProfiles).where(eq8(userProfiles.id, id11)).limit(1);
6120
6120
  return result[0] ?? null;
6121
6121
  }
6122
+ /**
6123
+ * User ID로 locale만 조회 (경량)
6124
+ */
6125
+ async findLocaleByUserId(userId) {
6126
+ const result = await this.readDb.select({ locale: userProfiles.locale }).from(userProfiles).where(eq8(userProfiles.userId, userId)).limit(1);
6127
+ return result[0]?.locale || "en";
6128
+ }
6122
6129
  /**
6123
6130
  * User ID로 프로필 조회
6124
6131
  */
@@ -6813,6 +6820,9 @@ function getUserId(c) {
6813
6820
  function getRole(c) {
6814
6821
  return getAuth(c).role;
6815
6822
  }
6823
+ function getLocale(c) {
6824
+ return getAuth(c).locale;
6825
+ }
6816
6826
  function getKeyId(c) {
6817
6827
  return getAuth(c).keyId;
6818
6828
  }
@@ -7736,6 +7746,12 @@ async function getUserProfileService(userId) {
7736
7746
  profile
7737
7747
  };
7738
7748
  }
7749
+ async function updateLocaleService(userId, locale) {
7750
+ const userIdNum = Number(userId);
7751
+ const normalized = locale.trim() || "en";
7752
+ await userProfilesRepository.upsertByUserId(userIdNum, { locale: normalized });
7753
+ return { locale: normalized };
7754
+ }
7739
7755
  function emptyToNull(value) {
7740
7756
  if (value === "") {
7741
7757
  return null;
@@ -8298,7 +8314,7 @@ import { EMAIL_PATTERN as EMAIL_PATTERN2, UUID_PATTERN } from "@spfn/auth";
8298
8314
  // src/server/middleware/authenticate.ts
8299
8315
  import { defineMiddleware } from "@spfn/core/route";
8300
8316
  import { UnauthorizedError } from "@spfn/core/errors";
8301
- import { verifyClientToken as verifyClientToken2, decodeToken as decodeToken2, authLogger as authLogger2, keysRepository as keysRepository2, usersRepository as usersRepository2 } from "@spfn/auth/server";
8317
+ import { verifyClientToken as verifyClientToken2, decodeToken as decodeToken2, authLogger as authLogger2, keysRepository as keysRepository2, usersRepository as usersRepository2, userProfilesRepository as userProfilesRepository2 } from "@spfn/auth/server";
8302
8318
  import {
8303
8319
  InvalidTokenError,
8304
8320
  TokenExpiredError,
@@ -8345,7 +8361,10 @@ var authenticate = defineMiddleware("auth", async (c, next) => {
8345
8361
  }
8346
8362
  throw new UnauthorizedError({ message: "Authentication failed" });
8347
8363
  }
8348
- const result = await usersRepository2.findByIdWithRole(keyRecord.userId);
8364
+ const [result, locale] = await Promise.all([
8365
+ usersRepository2.findByIdWithRole(keyRecord.userId),
8366
+ userProfilesRepository2.findLocaleByUserId(keyRecord.userId)
8367
+ ]);
8349
8368
  if (!result) {
8350
8369
  throw new UnauthorizedError({ message: "User not found" });
8351
8370
  }
@@ -8358,7 +8377,8 @@ var authenticate = defineMiddleware("auth", async (c, next) => {
8358
8377
  user,
8359
8378
  userId: String(user.id),
8360
8379
  keyId,
8361
- role: role?.name ?? null
8380
+ role: role?.name ?? null,
8381
+ locale
8362
8382
  });
8363
8383
  const method = c.req.method;
8364
8384
  const path = c.req.path;
@@ -8401,7 +8421,10 @@ var optionalAuth = defineMiddleware("optionalAuth", async (c, next) => {
8401
8421
  keyRecord.publicKey,
8402
8422
  keyRecord.algorithm
8403
8423
  );
8404
- const result = await usersRepository2.findByIdWithRole(keyRecord.userId);
8424
+ const [result, locale] = await Promise.all([
8425
+ usersRepository2.findByIdWithRole(keyRecord.userId),
8426
+ userProfilesRepository2.findLocaleByUserId(keyRecord.userId)
8427
+ ]);
8405
8428
  if (!result || result.user.status !== "active") {
8406
8429
  await next();
8407
8430
  return;
@@ -8412,7 +8435,8 @@ var optionalAuth = defineMiddleware("optionalAuth", async (c, next) => {
8412
8435
  user,
8413
8436
  userId: String(user.id),
8414
8437
  keyId,
8415
- role: role?.name ?? null
8438
+ role: role?.name ?? null,
8439
+ locale
8416
8440
  });
8417
8441
  } catch {
8418
8442
  }
@@ -8809,11 +8833,21 @@ var updateUsername = route3.patch("/_auth/users/username").input({
8809
8833
  const { body } = await c.data();
8810
8834
  return await updateUsernameService(userId, body.username);
8811
8835
  });
8836
+ var updateLocale = route3.patch("/_auth/users/locale").input({
8837
+ body: Type.Object({
8838
+ locale: Type.String({ minLength: 1, description: "Locale code (e.g., en, ko, ja)" })
8839
+ })
8840
+ }).handler(async (c) => {
8841
+ const { userId } = getAuth(c);
8842
+ const { body } = await c.data();
8843
+ return await updateLocaleService(userId, body.locale);
8844
+ });
8812
8845
  var userRouter = defineRouter3({
8813
8846
  getUserProfile,
8814
8847
  updateUserProfile,
8815
8848
  checkUsername,
8816
- updateUsername
8849
+ updateUsername,
8850
+ updateLocale
8817
8851
  });
8818
8852
 
8819
8853
  // src/server/routes/oauth/index.ts
@@ -9050,6 +9084,7 @@ var mainAuthRouter = defineRouter5({
9050
9084
  updateUserProfile,
9051
9085
  checkUsername,
9052
9086
  updateUsername,
9087
+ updateLocale,
9053
9088
  // Admin routes (superadmin only)
9054
9089
  listRoles,
9055
9090
  createAdminRole,
@@ -9430,6 +9465,7 @@ export {
9430
9465
  getInvitationWithDetails,
9431
9466
  getKeyId,
9432
9467
  getKeySize,
9468
+ getLocale,
9433
9469
  getOptionalAuth,
9434
9470
  getRole,
9435
9471
  getRoleByName,
@@ -9487,6 +9523,7 @@ export {
9487
9523
  socialAccountsRepository,
9488
9524
  unsealSession,
9489
9525
  updateLastLoginService,
9526
+ updateLocaleService,
9490
9527
  updateRole,
9491
9528
  updateUserProfileService,
9492
9529
  updateUserService,