@spfn/auth 0.2.0-beta.42 → 0.2.0-beta.44

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.js CHANGED
@@ -4564,7 +4564,7 @@ var init_roles = __esm({
4564
4564
  });
4565
4565
 
4566
4566
  // src/server/entities/users.ts
4567
- import { text as text2, check, boolean as boolean2, index as index2 } from "drizzle-orm/pg-core";
4567
+ import { text as text2, check, boolean as boolean2, index as index2, uuid } from "drizzle-orm/pg-core";
4568
4568
  import { id as id2, timestamps as timestamps2, enumText, utcTimestamp, foreignKey } from "@spfn/core/db";
4569
4569
  import { sql } from "drizzle-orm";
4570
4570
  var users;
@@ -4579,6 +4579,9 @@ var init_users = __esm({
4579
4579
  {
4580
4580
  // Identity
4581
4581
  id: id2(),
4582
+ // Public-facing UUID (for URLs, external APIs)
4583
+ // Never expose internal bigserial ID externally
4584
+ publicId: uuid("public_id").notNull().unique().defaultRandom(),
4582
4585
  // Email address (unique identifier)
4583
4586
  // Used for: login, password reset, notifications
4584
4587
  email: text2("email").unique(),
@@ -4626,6 +4629,7 @@ var init_users = __esm({
4626
4629
  sql`${table.email} IS NOT NULL OR ${table.phone} IS NOT NULL`
4627
4630
  ),
4628
4631
  // Indexes for query optimization
4632
+ index2("users_public_id_idx").on(table.publicId),
4629
4633
  index2("users_email_idx").on(table.email),
4630
4634
  index2("users_phone_idx").on(table.phone),
4631
4635
  index2("users_username_idx").on(table.username),
@@ -4653,8 +4657,8 @@ var init_user_profiles = __esm({
4653
4657
  // Foreign key to users table
4654
4658
  userId: foreignKey2("user", () => users.id).unique(),
4655
4659
  // Display Information
4656
- // Display name shown in UI (required)
4657
- displayName: text3("display_name").notNull(),
4660
+ // Display name shown in UI (optional)
4661
+ displayName: text3("display_name"),
4658
4662
  // First name (optional)
4659
4663
  firstName: text3("first_name"),
4660
4664
  // Last name (optional)
@@ -5355,6 +5359,14 @@ var init_users_repository = __esm({
5355
5359
  const result = await this.readDb.select().from(users).where(eq(users.username, username)).limit(1);
5356
5360
  return result[0] ?? null;
5357
5361
  }
5362
+ /**
5363
+ * Public ID(UUID)로 사용자 조회
5364
+ * Read replica 사용
5365
+ */
5366
+ async findByPublicId(publicId) {
5367
+ const result = await this.readDb.select().from(users).where(eq(users.publicId, publicId)).limit(1);
5368
+ return result[0] ?? null;
5369
+ }
5358
5370
  /**
5359
5371
  * 이메일 또는 전화번호로 사용자 조회
5360
5372
  * Read replica 사용
@@ -5495,6 +5507,7 @@ var init_users_repository = __esm({
5495
5507
  async fetchMinimalUserData(userId) {
5496
5508
  const user = await this.readDb.select({
5497
5509
  id: users.id,
5510
+ publicId: users.publicId,
5498
5511
  email: users.email,
5499
5512
  username: users.username,
5500
5513
  emailVerifiedAt: users.emailVerifiedAt,
@@ -5505,6 +5518,7 @@ var init_users_repository = __esm({
5505
5518
  }
5506
5519
  return {
5507
5520
  userId: user.id,
5521
+ publicId: user.publicId,
5508
5522
  email: user.email,
5509
5523
  username: user.username,
5510
5524
  isEmailVerified: !!user.emailVerifiedAt,
@@ -5521,6 +5535,7 @@ var init_users_repository = __esm({
5521
5535
  async fetchFullUserData(userId) {
5522
5536
  const user = await this.readDb.select({
5523
5537
  id: users.id,
5538
+ publicId: users.publicId,
5524
5539
  email: users.email,
5525
5540
  username: users.username,
5526
5541
  emailVerifiedAt: users.emailVerifiedAt,
@@ -5534,6 +5549,7 @@ var init_users_repository = __esm({
5534
5549
  }
5535
5550
  return {
5536
5551
  userId: user.id,
5552
+ publicId: user.publicId,
5537
5553
  email: user.email,
5538
5554
  username: user.username,
5539
5555
  isEmailVerified: !!user.emailVerifiedAt,
@@ -7246,6 +7262,7 @@ async function registerService(params) {
7246
7262
  });
7247
7263
  const result = {
7248
7264
  userId: String(newUser.id),
7265
+ publicId: newUser.publicId,
7249
7266
  email: newUser.email || void 0,
7250
7267
  phone: newUser.phone || void 0
7251
7268
  };
@@ -7291,6 +7308,7 @@ async function loginService(params) {
7291
7308
  await updateLastLoginService(user.id);
7292
7309
  const result = {
7293
7310
  userId: String(user.id),
7311
+ publicId: user.publicId,
7294
7312
  email: user.email || void 0,
7295
7313
  phone: user.phone || void 0,
7296
7314
  passwordChangeRequired: user.passwordChangeRequired
@@ -7770,6 +7788,7 @@ async function getAuthSessionService(userId) {
7770
7788
  ]);
7771
7789
  return {
7772
7790
  userId: user.userId,
7791
+ publicId: user.publicId,
7773
7792
  email: user.email,
7774
7793
  emailVerified: user.isEmailVerified,
7775
7794
  phoneVerified: user.isPhoneVerified,
@@ -7787,6 +7806,7 @@ async function getUserProfileService(userId) {
7787
7806
  ]);
7788
7807
  return {
7789
7808
  userId: user.userId,
7809
+ publicId: user.publicId,
7790
7810
  email: user.email,
7791
7811
  username: user.username,
7792
7812
  emailVerified: user.isEmailVerified,
@@ -7813,7 +7833,7 @@ async function updateUserProfileService(userId, params) {
7813
7833
  const userIdNum = typeof userId === "string" ? Number(userId) : Number(userId);
7814
7834
  const updateData = {};
7815
7835
  if (params.displayName !== void 0) {
7816
- updateData.displayName = emptyToNull(params.displayName) || "User";
7836
+ updateData.displayName = emptyToNull(params.displayName);
7817
7837
  }
7818
7838
  if (params.firstName !== void 0) {
7819
7839
  updateData.firstName = emptyToNull(params.firstName);
@@ -7854,10 +7874,6 @@ async function updateUserProfileService(userId, params) {
7854
7874
  if (params.metadata !== void 0) {
7855
7875
  updateData.metadata = params.metadata;
7856
7876
  }
7857
- const existing = await userProfilesRepository.findByUserId(userIdNum);
7858
- if (!existing && !updateData.displayName) {
7859
- updateData.displayName = "User";
7860
- }
7861
7877
  await userProfilesRepository.upsertByUserId(userIdNum, updateData);
7862
7878
  const profile = await userProfilesRepository.fetchProfileData(userIdNum);
7863
7879
  return profile;