@playcademy/sandbox 0.3.17-beta.13 → 0.3.17-beta.14

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
@@ -299,7 +299,7 @@ var init_achievements = __esm(() => {
299
299
  });
300
300
 
301
301
  // ../constants/src/auth.ts
302
- var AUTH_PROVIDER_IDS;
302
+ var AUTH_PROVIDER_IDS, DEMO_DISPLAY_NAME_PLACEHOLDER = "Demo Player";
303
303
  var init_auth = __esm(() => {
304
304
  AUTH_PROVIDER_IDS = {
305
305
  TIMEBACK: "timeback",
@@ -386,7 +386,8 @@ var init_overworld = __esm(() => {
386
386
  ERROR: 4000
387
387
  };
388
388
  CORE_GAME_UUIDS = {
389
- PLAYGROUND: "00000000-0000-0000-0000-000000000001"
389
+ PLAYGROUND: "00000000-0000-0000-0000-000000000001",
390
+ DEMO: "00000000-0000-0000-0000-000000000002"
390
391
  };
391
392
  });
392
393
 
@@ -464,13 +465,15 @@ var init_src = __esm(() => {
464
465
  // src/constants/demo-users.ts
465
466
  var now, DEMO_USER_IDS, DEMO_USERS, DEMO_USER;
466
467
  var init_demo_users = __esm(() => {
468
+ init_src();
467
469
  now = new Date;
468
470
  DEMO_USER_IDS = {
469
471
  player: "00000000-0000-0000-0000-000000000001",
470
472
  developer: "00000000-0000-0000-0000-000000000002",
471
473
  admin: "00000000-0000-0000-0000-000000000003",
472
474
  pendingDeveloper: "00000000-0000-0000-0000-000000000004",
473
- unverifiedPlayer: "00000000-0000-0000-0000-000000000005"
475
+ unverifiedPlayer: "00000000-0000-0000-0000-000000000005",
476
+ anonymousPlayer: "00000000-0000-0000-0000-000000000006"
474
477
  };
475
478
  DEMO_USERS = {
476
479
  admin: {
@@ -532,6 +535,19 @@ var init_demo_users = __esm(() => {
532
535
  developerStatus: "none",
533
536
  createdAt: now,
534
537
  updatedAt: now
538
+ },
539
+ anonymousPlayer: {
540
+ id: DEMO_USER_IDS.anonymousPlayer,
541
+ name: DEMO_DISPLAY_NAME_PLACEHOLDER,
542
+ username: "anonymous_demo_player",
543
+ email: "player@anon.demo.playcademy.gg",
544
+ emailVerified: false,
545
+ image: null,
546
+ isAnonymous: true,
547
+ role: "player",
548
+ developerStatus: "none",
549
+ createdAt: now,
550
+ updatedAt: now
535
551
  }
536
552
  };
537
553
  DEMO_USER = DEMO_USERS.player;
@@ -545,6 +561,7 @@ var init_demo_tokens = __esm(() => {
545
561
  "sandbox-demo-token": DEMO_USERS.player,
546
562
  "sandbox-admin-token": DEMO_USERS.admin,
547
563
  "sandbox-player-token": DEMO_USERS.player,
564
+ "sandbox-anonymous-token": DEMO_USERS.anonymousPlayer,
548
565
  "sandbox-developer-token": DEMO_USERS.developer,
549
566
  "sandbox-pending-dev-token": DEMO_USERS.pendingDeveloper,
550
567
  "sandbox-unverified-token": DEMO_USERS.unverifiedPlayer,
@@ -553,6 +570,7 @@ var init_demo_tokens = __esm(() => {
553
570
  };
554
571
  SANDBOX_TOKENS = {
555
572
  player: "sandbox-player-token",
573
+ anonymous: "sandbox-anonymous-token",
556
574
  developer: "sandbox-developer-token",
557
575
  admin: "sandbox-admin-token",
558
576
  pendingDeveloper: "sandbox-pending-dev-token",
@@ -1310,7 +1328,7 @@ var package_default;
1310
1328
  var init_package = __esm(() => {
1311
1329
  package_default = {
1312
1330
  name: "@playcademy/sandbox",
1313
- version: "0.3.17-beta.13",
1331
+ version: "0.3.17-beta.14",
1314
1332
  description: "Local development server for Playcademy game development",
1315
1333
  type: "module",
1316
1334
  exports: {
@@ -11559,6 +11577,7 @@ var init_table6 = __esm(() => {
11559
11577
  name: text("name").notNull(),
11560
11578
  username: text("username").unique(),
11561
11579
  email: text("email").notNull().unique(),
11580
+ isAnonymous: boolean("is_anonymous").notNull().default(false),
11562
11581
  timebackId: text("timeback_id").unique(),
11563
11582
  emailVerified: boolean("email_verified").notNull().default(false),
11564
11583
  image: text("image"),
@@ -32596,7 +32615,7 @@ class LeaderboardService {
32596
32615
  constructor(deps) {
32597
32616
  this.deps = deps;
32598
32617
  }
32599
- async submitScore(gameId, userId, input, sessionId) {
32618
+ async submitScore(gameId, userId, input, isAnonymousUser, sessionId) {
32600
32619
  const db2 = this.deps.db;
32601
32620
  const game = await db2.select({ displayName: games.displayName }).from(games).where(eq(games.id, gameId)).limit(1).then((rows) => rows[0]);
32602
32621
  if (!game) {
@@ -32607,7 +32626,7 @@ class LeaderboardService {
32607
32626
  const prevBestScore = prevBestScoreRows[0]?.score ?? null;
32608
32627
  let prevRank = null;
32609
32628
  if (prevBestScore !== null && prevBestScore !== undefined) {
32610
- const higherCountRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(and(eq(gameScores.gameId, gameId), sql`${gameScores.userId} != ${userId}`, sql`${gameScores.score} > ${prevBestScore}`));
32629
+ const higherCountRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser), sql`${gameScores.userId} != ${userId}`, sql`${gameScores.score} > ${prevBestScore}`));
32611
32630
  const higherCount = higherCountRows[0]?.count ?? 0;
32612
32631
  prevRank = Number(higherCount) + 1;
32613
32632
  }
@@ -32624,13 +32643,13 @@ class LeaderboardService {
32624
32643
  }
32625
32644
  const bestScoreRows = await db2.select({ score: sql`MAX(${gameScores.score})` }).from(gameScores).where(and(eq(gameScores.gameId, gameId), eq(gameScores.userId, userId)));
32626
32645
  const bestScore = bestScoreRows[0]?.score ?? input.score;
32627
- const higherCountNowRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(and(eq(gameScores.gameId, gameId), sql`${gameScores.userId} != ${userId}`, sql`${gameScores.score} > ${bestScore}`));
32646
+ const higherCountNowRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser), sql`${gameScores.userId} != ${userId}`, sql`${gameScores.score} > ${bestScore}`));
32628
32647
  const higherCountNow = higherCountNowRows[0]?.count ?? 0;
32629
32648
  const newRank = Number(higherCountNow) + 1;
32630
- const totalPlayersRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(eq(gameScores.gameId, gameId));
32649
+ const totalPlayersRows = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser)));
32631
32650
  const totalPlayers = Number(totalPlayersRows[0]?.count ?? 1);
32632
32651
  const { shouldNotify, crossedIntoTop3, movedUpWithinTop3, isFirstScore, isPersonalBest } = shouldNotifyRankChange(prevRank, newRank, prevBestScore, input.score);
32633
- if (shouldNotify) {
32652
+ if (shouldNotify && !isAnonymousUser) {
32634
32653
  await this.publishScoreNotifications({
32635
32654
  userId,
32636
32655
  gameId,
@@ -32650,6 +32669,7 @@ class LeaderboardService {
32650
32669
  logger21.info("Score submitted", {
32651
32670
  gameId,
32652
32671
  userId,
32672
+ isAnonymousUser,
32653
32673
  score: input.score,
32654
32674
  newRank,
32655
32675
  isFirstScore,
@@ -32726,7 +32746,7 @@ class LeaderboardService {
32726
32746
  logger21.warn("Failed to publish notification", { error });
32727
32747
  }
32728
32748
  }
32729
- async getLeaderboard(gameId, query) {
32749
+ async getLeaderboard(gameId, query, isAnonymousUser) {
32730
32750
  const { timeframe, limit, offset } = query;
32731
32751
  const db2 = this.deps.db;
32732
32752
  const dateFilter = getTimeframeFilter(timeframe);
@@ -32738,31 +32758,35 @@ class LeaderboardService {
32738
32758
  score: gameScores.score,
32739
32759
  achievedAt: gameScores.achievedAt,
32740
32760
  metadata: gameScores.metadata
32741
- }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), dateFilter)).orderBy(desc(gameScores.score)).limit(limit).offset(offset);
32761
+ }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), dateFilter, eq(users.isAnonymous, isAnonymousUser))).orderBy(desc(gameScores.score)).limit(limit).offset(offset);
32742
32762
  return scores.map((score, index2) => ({
32743
32763
  rank: offset + index2 + 1,
32744
32764
  userId: score.userId,
32745
- username: score.username || score.name?.split(" ")[0] || "Unknown User",
32765
+ username: score.name || score.username || "Unknown User",
32746
32766
  userImage: score.userImage,
32747
32767
  score: score.score,
32748
32768
  achievedAt: score.achievedAt,
32749
32769
  metadata: score.metadata
32750
32770
  }));
32751
32771
  }
32752
- async getGlobalLeaderboard(gameId, query) {
32772
+ async getGlobalLeaderboard(gameId, query, isAnonymousUser) {
32753
32773
  if (!gameId) {
32754
32774
  return [];
32755
32775
  }
32756
32776
  const { timeframe, limit, offset } = query;
32757
32777
  const db2 = this.deps.db;
32758
32778
  const dateFilter = getTimeframeFilter(timeframe);
32759
- const conditions2 = [dateFilter, eq(gameScores.gameId, gameId)];
32779
+ const conditions2 = [
32780
+ dateFilter,
32781
+ eq(gameScores.gameId, gameId),
32782
+ eq(users.isAnonymous, isAnonymousUser)
32783
+ ];
32760
32784
  const bestScoresSubquery = db2.select({
32761
32785
  userId: gameScores.userId,
32762
32786
  gameId: gameScores.gameId,
32763
32787
  score: sql`MAX(${gameScores.score})`.as("max_score"),
32764
32788
  achievedAt: sql`MAX(${gameScores.achievedAt})`.as("max_achieved_at")
32765
- }).from(gameScores).where(and(...conditions2)).groupBy(gameScores.userId, gameScores.gameId).as("best_scores");
32789
+ }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(...conditions2)).groupBy(gameScores.userId, gameScores.gameId).as("best_scores");
32766
32790
  const scores = await db2.select({
32767
32791
  userId: users.id,
32768
32792
  username: users.username,
@@ -32778,7 +32802,7 @@ class LeaderboardService {
32778
32802
  return scores.map((score, index2) => ({
32779
32803
  rank: offset + index2 + 1,
32780
32804
  userId: score.userId,
32781
- username: score.username || score.name?.split(" ")[0] || "Unknown User",
32805
+ username: score.name || score.username || "Unknown User",
32782
32806
  userImage: score.userImage,
32783
32807
  score: score.score,
32784
32808
  achievedAt: score.achievedAt,
@@ -32788,15 +32812,15 @@ class LeaderboardService {
32788
32812
  gameSlug: score.gameSlug || ""
32789
32813
  }));
32790
32814
  }
32791
- async getUserRank(gameId, userId) {
32815
+ async getUserRank(gameId, userId, isAnonymousUser) {
32792
32816
  const db2 = this.deps.db;
32793
- const userScoreResult = await db2.select({ score: gameScores.score }).from(gameScores).where(and(eq(gameScores.gameId, gameId), eq(gameScores.userId, userId))).orderBy(desc(gameScores.score)).limit(1);
32817
+ const userScoreResult = await db2.select({ score: gameScores.score }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(gameScores.userId, userId), eq(users.isAnonymous, isAnonymousUser))).orderBy(desc(gameScores.score)).limit(1);
32794
32818
  if (!userScoreResult.length || !userScoreResult[0]) {
32795
32819
  return null;
32796
32820
  }
32797
32821
  const score = userScoreResult[0].score;
32798
- const countResult = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(and(eq(gameScores.gameId, gameId), sql`${gameScores.score} > ${score}`));
32799
- const totalResult = await db2.select({ total: sql`count(distinct ${gameScores.userId})` }).from(gameScores).where(eq(gameScores.gameId, gameId));
32822
+ const countResult = await db2.select({ count: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser), sql`${gameScores.score} > ${score}`));
32823
+ const totalResult = await db2.select({ total: sql`count(distinct ${gameScores.userId})` }).from(gameScores).innerJoin(users, eq(gameScores.userId, users.id)).where(and(eq(gameScores.gameId, gameId), eq(users.isAnonymous, isAnonymousUser)));
32800
32824
  const count = Number(countResult[0]?.count ?? 0);
32801
32825
  const total = Number(totalResult[0]?.total ?? 0);
32802
32826
  const rank = count + 1;
@@ -34249,6 +34273,35 @@ class UserService {
34249
34273
  timeback: timeback2
34250
34274
  };
34251
34275
  }
34276
+ async getDemoProfile(userId) {
34277
+ const userData = await this.deps.db.query.users.findFirst({
34278
+ where: eq(users.id, userId),
34279
+ columns: { name: true }
34280
+ });
34281
+ if (!userData) {
34282
+ logger32.error("Demo user not found", { userId });
34283
+ throw new NotFoundError("User", userId);
34284
+ }
34285
+ return {
34286
+ displayName: userData.name,
34287
+ isDefault: userData.name === DEMO_DISPLAY_NAME_PLACEHOLDER
34288
+ };
34289
+ }
34290
+ async updateDemoProfile(userId, displayName) {
34291
+ const [updatedUser] = await this.deps.db.update(users).set({
34292
+ name: displayName,
34293
+ updatedAt: new Date
34294
+ }).where(eq(users.id, userId)).returning({ name: users.name });
34295
+ if (!updatedUser) {
34296
+ logger32.error("Demo user not found for profile update", { userId });
34297
+ throw new NotFoundError("User", userId);
34298
+ }
34299
+ logger32.debug("Updated demo profile", { userId, displayName });
34300
+ return {
34301
+ displayName: updatedUser.name,
34302
+ isDefault: updatedUser.name === DEMO_DISPLAY_NAME_PLACEHOLDER
34303
+ };
34304
+ }
34252
34305
  async fetchTimebackData(timebackId, gameId) {
34253
34306
  const [{ role, organizations: allOrganizations }, allEnrollments] = await Promise.all([
34254
34307
  this.fetchStudentProfile(timebackId),
@@ -34341,6 +34394,7 @@ class UserService {
34341
34394
  var logger32;
34342
34395
  var init_user_service = __esm(() => {
34343
34396
  init_drizzle_orm();
34397
+ init_src();
34344
34398
  init_tables_index();
34345
34399
  init_src2();
34346
34400
  init_errors();
@@ -93409,7 +93463,10 @@ var init_drizzle_zod = __esm(() => {
93409
93463
  });
93410
93464
 
93411
93465
  // ../data/src/domains/user/schemas.ts
93412
- var InsertUserSchema;
93466
+ function normalizeDisplayName(value) {
93467
+ return value.trim().replace(/\s+/g, " ");
93468
+ }
93469
+ var InsertUserSchema, DemoProfileSchema;
93413
93470
  var init_schemas = __esm(() => {
93414
93471
  init_drizzle_zod();
93415
93472
  init_esm();
@@ -93418,6 +93475,9 @@ var init_schemas = __esm(() => {
93418
93475
  email: exports_external.string().email(),
93419
93476
  name: exports_external.string().optional()
93420
93477
  });
93478
+ DemoProfileSchema = exports_external.object({
93479
+ displayName: exports_external.string().transform(normalizeDisplayName).refine((value) => value.length >= 2, "Display name must be at least 2 characters").refine((value) => value.length <= 12, "Display name must be 12 characters or fewer")
93480
+ });
93421
93481
  });
93422
93482
 
93423
93483
  // ../data/src/domains/game/schemas.ts
@@ -94035,6 +94095,28 @@ function requireAuth(handler) {
94035
94095
  return handler(ctx);
94036
94096
  };
94037
94097
  }
94098
+ function requireNonAnonymous(handler) {
94099
+ return async (ctx) => {
94100
+ if (!isAuthenticated(ctx)) {
94101
+ throw ApiError.unauthorized("Valid session or bearer token required");
94102
+ }
94103
+ if (ctx.user.isAnonymous) {
94104
+ throw ApiError.forbidden("This operation is not available for demo/anonymous users");
94105
+ }
94106
+ return handler(ctx);
94107
+ };
94108
+ }
94109
+ function requireAnonymous(handler) {
94110
+ return async (ctx) => {
94111
+ if (!isAuthenticated(ctx)) {
94112
+ throw ApiError.unauthorized("Valid session or bearer token required");
94113
+ }
94114
+ if (!ctx.user.isAnonymous) {
94115
+ throw ApiError.forbidden("This operation is only available for demo/anonymous users");
94116
+ }
94117
+ return handler(ctx);
94118
+ };
94119
+ }
94038
94120
  function requireRole(roles2, handler) {
94039
94121
  return async (ctx) => {
94040
94122
  if (!isAuthenticated(ctx)) {
@@ -94275,16 +94357,16 @@ var init_achievement_controller = __esm(() => {
94275
94357
  init_errors();
94276
94358
  init_utils11();
94277
94359
  logger37 = log.scope("AchievementController");
94278
- listCurrent = requireAuth(async (ctx) => {
94360
+ listCurrent = requireNonAnonymous(async (ctx) => {
94279
94361
  logger37.debug("Listing current achievements", { userId: ctx.user.id, gameId: ctx.gameId });
94280
94362
  return ctx.services.achievement.listCurrent(ctx.user, ctx.gameId);
94281
94363
  });
94282
- listHistory = requireAuth(async (ctx) => {
94364
+ listHistory = requireNonAnonymous(async (ctx) => {
94283
94365
  const limit = Math.max(1, Math.min(100, Number(ctx.url.searchParams.get("limit")) || 20));
94284
94366
  logger37.debug("Listing achievement history", { userId: ctx.user.id, limit });
94285
94367
  return ctx.services.achievement.listHistory(ctx.user, limit);
94286
94368
  });
94287
- postProgress = requireAuth(async (ctx) => {
94369
+ postProgress = requireNonAnonymous(async (ctx) => {
94288
94370
  let body2;
94289
94371
  try {
94290
94372
  const json4 = await ctx.request.json();
@@ -94438,11 +94520,11 @@ var init_character_controller = __esm(() => {
94438
94520
  init_errors();
94439
94521
  init_utils11();
94440
94522
  logger40 = log.scope("CharacterController");
94441
- get = requireAuth(async (ctx) => {
94523
+ get = requireNonAnonymous(async (ctx) => {
94442
94524
  logger40.debug("Getting character", { userId: ctx.user.id });
94443
94525
  return ctx.services.character.getByUser(ctx.user);
94444
94526
  });
94445
- getByUserId = requireAuth(async (ctx) => {
94527
+ getByUserId = requireNonAnonymous(async (ctx) => {
94446
94528
  const userId = ctx.params.userId;
94447
94529
  if (!userId) {
94448
94530
  throw ApiError.badRequest("User ID is required in the URL path");
@@ -94450,7 +94532,7 @@ var init_character_controller = __esm(() => {
94450
94532
  logger40.debug("Getting character by user ID", { requestedUserId: userId });
94451
94533
  return ctx.services.character.getByUserId(userId);
94452
94534
  });
94453
- create = requireAuth(async (ctx) => {
94535
+ create = requireNonAnonymous(async (ctx) => {
94454
94536
  let body2;
94455
94537
  try {
94456
94538
  const json4 = await ctx.request.json();
@@ -94470,7 +94552,7 @@ var init_character_controller = __esm(() => {
94470
94552
  });
94471
94553
  return ctx.services.character.create(body2, ctx.user);
94472
94554
  });
94473
- update2 = requireAuth(async (ctx) => {
94555
+ update2 = requireNonAnonymous(async (ctx) => {
94474
94556
  let body2;
94475
94557
  try {
94476
94558
  const json4 = await ctx.request.json();
@@ -94491,7 +94573,7 @@ var init_character_controller = __esm(() => {
94491
94573
  });
94492
94574
  return ctx.services.character.update(body2, ctx.user);
94493
94575
  });
94494
- equipAccessory = requireAuth(async (ctx) => {
94576
+ equipAccessory = requireNonAnonymous(async (ctx) => {
94495
94577
  let body2;
94496
94578
  try {
94497
94579
  const json4 = await ctx.request.json();
@@ -94511,7 +94593,7 @@ var init_character_controller = __esm(() => {
94511
94593
  });
94512
94594
  return ctx.services.character.equipAccessory(body2.slot, body2.accessoryComponentId, ctx.user);
94513
94595
  });
94514
- removeAccessory = requireAuth(async (ctx) => {
94596
+ removeAccessory = requireNonAnonymous(async (ctx) => {
94515
94597
  const slot = ctx.params.slot;
94516
94598
  if (!slot) {
94517
94599
  throw ApiError.badRequest("Slot is required in the URL path");
@@ -94541,11 +94623,11 @@ var init_currency_controller = __esm(() => {
94541
94623
  init_errors();
94542
94624
  init_utils11();
94543
94625
  logger41 = log.scope("CurrencyController");
94544
- list = requireAuth(async (ctx) => {
94626
+ list = requireNonAnonymous(async (ctx) => {
94545
94627
  logger41.debug("Listing currencies", { userId: ctx.user.id });
94546
94628
  return ctx.services.currency.list();
94547
94629
  });
94548
- getById = requireAuth(async (ctx) => {
94630
+ getById = requireNonAnonymous(async (ctx) => {
94549
94631
  const currencyId = ctx.params.currencyId;
94550
94632
  if (!currencyId) {
94551
94633
  throw ApiError.badRequest("Missing currency ID");
@@ -94720,11 +94802,11 @@ var init_developer_controller = __esm(() => {
94720
94802
  init_src2();
94721
94803
  init_utils11();
94722
94804
  logger44 = log.scope("DeveloperController");
94723
- apply = requireAuth(async (ctx) => {
94805
+ apply = requireNonAnonymous(async (ctx) => {
94724
94806
  logger44.debug("Applying for developer status", { userId: ctx.user.id });
94725
94807
  await ctx.services.developer.apply(ctx.user);
94726
94808
  });
94727
- getStatus = requireAuth(async (ctx) => {
94809
+ getStatus = requireNonAnonymous(async (ctx) => {
94728
94810
  logger44.debug("Getting developer status", { userId: ctx.user.id });
94729
94811
  const status = await ctx.services.developer.getStatus(ctx.user.id);
94730
94812
  return { status };
@@ -94826,19 +94908,19 @@ var init_game_controller = __esm(() => {
94826
94908
  init_errors();
94827
94909
  init_utils11();
94828
94910
  logger46 = log.scope("GameController");
94829
- list3 = requireAuth(async (ctx) => {
94911
+ list3 = requireNonAnonymous(async (ctx) => {
94830
94912
  logger46.debug("Listing games", { userId: ctx.user.id });
94831
94913
  return ctx.services.game.list(ctx.user);
94832
94914
  });
94833
- listManageable = requireAuth(async (ctx) => {
94915
+ listManageable = requireNonAnonymous(async (ctx) => {
94834
94916
  logger46.debug("Listing manageable games", { userId: ctx.user.id });
94835
94917
  return ctx.services.game.listManageable(ctx.user);
94836
94918
  });
94837
- getSubjects = requireAuth(async (ctx) => {
94919
+ getSubjects = requireNonAnonymous(async (ctx) => {
94838
94920
  logger46.debug("Getting game subjects", { userId: ctx.user.id });
94839
94921
  return ctx.services.game.getSubjects();
94840
94922
  });
94841
- getById2 = requireAuth(async (ctx) => {
94923
+ getById2 = requireNonAnonymous(async (ctx) => {
94842
94924
  const gameId = ctx.params.gameId;
94843
94925
  if (!gameId) {
94844
94926
  throw ApiError.badRequest("Missing game ID");
@@ -94849,7 +94931,7 @@ var init_game_controller = __esm(() => {
94849
94931
  logger46.debug("Getting game by ID", { userId: ctx.user.id, gameId, launchId: ctx.launchId });
94850
94932
  return ctx.services.game.getById(gameId, ctx.user);
94851
94933
  });
94852
- getBySlug = requireAuth(async (ctx) => {
94934
+ getBySlug = requireNonAnonymous(async (ctx) => {
94853
94935
  const slug2 = ctx.params.slug;
94854
94936
  if (!slug2) {
94855
94937
  throw ApiError.badRequest("Missing game slug");
@@ -94857,7 +94939,7 @@ var init_game_controller = __esm(() => {
94857
94939
  logger46.debug("Getting game by slug", { userId: ctx.user.id, slug: slug2, launchId: ctx.launchId });
94858
94940
  return ctx.services.game.getBySlug(slug2, ctx.user);
94859
94941
  });
94860
- getManifest = requireAuth(async (ctx) => {
94942
+ getManifest = requireNonAnonymous(async (ctx) => {
94861
94943
  const gameId = ctx.params.gameId;
94862
94944
  if (!gameId) {
94863
94945
  throw ApiError.badRequest("Missing game ID");
@@ -94872,7 +94954,7 @@ var init_game_controller = __esm(() => {
94872
94954
  });
94873
94955
  return ctx.services.game.getManifest(gameId, ctx.user);
94874
94956
  });
94875
- upsertBySlug = requireAuth(async (ctx) => {
94957
+ upsertBySlug = requireNonAnonymous(async (ctx) => {
94876
94958
  const slug2 = ctx.params.slug;
94877
94959
  if (!slug2) {
94878
94960
  throw ApiError.badRequest("Missing game slug");
@@ -94892,7 +94974,7 @@ var init_game_controller = __esm(() => {
94892
94974
  logger46.debug("Upserting game", { userId: ctx.user.id, slug: slug2, displayName: body2.displayName });
94893
94975
  return ctx.services.game.upsertBySlug(slug2, body2, ctx.user);
94894
94976
  });
94895
- remove3 = requireAuth(async (ctx) => {
94977
+ remove3 = requireNonAnonymous(async (ctx) => {
94896
94978
  const gameId = ctx.params.gameId;
94897
94979
  if (!gameId) {
94898
94980
  throw ApiError.badRequest("Missing game ID");
@@ -94924,11 +95006,11 @@ var init_inventory_controller = __esm(() => {
94924
95006
  init_errors();
94925
95007
  init_utils11();
94926
95008
  logger47 = log.scope("InventoryController");
94927
- list4 = requireAuth(async (ctx) => {
95009
+ list4 = requireNonAnonymous(async (ctx) => {
94928
95010
  logger47.debug("Listing inventory", { userId: ctx.user.id });
94929
95011
  return ctx.services.inventory.list(ctx.user);
94930
95012
  });
94931
- addItem = requireAuth(async (ctx) => {
95013
+ addItem = requireNonAnonymous(async (ctx) => {
94932
95014
  let body2;
94933
95015
  try {
94934
95016
  const json4 = await ctx.request.json();
@@ -94948,7 +95030,7 @@ var init_inventory_controller = __esm(() => {
94948
95030
  });
94949
95031
  return ctx.services.inventory.addItem(body2.itemId, body2.qty, ctx.user);
94950
95032
  });
94951
- removeItem = requireAuth(async (ctx) => {
95033
+ removeItem = requireNonAnonymous(async (ctx) => {
94952
95034
  let body2;
94953
95035
  try {
94954
95036
  const json4 = await ctx.request.json();
@@ -94985,12 +95067,12 @@ var init_item_controller = __esm(() => {
94985
95067
  init_errors();
94986
95068
  init_utils11();
94987
95069
  logger48 = log.scope("ItemController");
94988
- list5 = requireAuth(async (ctx) => {
95070
+ list5 = requireNonAnonymous(async (ctx) => {
94989
95071
  const gameId = ctx.url.searchParams.get("gameId") || undefined;
94990
95072
  logger48.debug("Listing items", { userId: ctx.user.id, gameId });
94991
95073
  return ctx.services.item.list(gameId);
94992
95074
  });
94993
- getById3 = requireAuth(async (ctx) => {
95075
+ getById3 = requireNonAnonymous(async (ctx) => {
94994
95076
  const itemId = ctx.params.itemId;
94995
95077
  if (!itemId) {
94996
95078
  throw ApiError.badRequest("Missing item ID");
@@ -95001,7 +95083,7 @@ var init_item_controller = __esm(() => {
95001
95083
  logger48.debug("Getting item", { userId: ctx.user.id, itemId });
95002
95084
  return ctx.services.item.getById(itemId);
95003
95085
  });
95004
- resolve2 = requireAuth(async (ctx) => {
95086
+ resolve2 = requireNonAnonymous(async (ctx) => {
95005
95087
  const slug2 = ctx.url.searchParams.get("slug");
95006
95088
  const gameId = ctx.url.searchParams.get("gameId") || undefined;
95007
95089
  if (!slug2) {
@@ -95076,7 +95158,7 @@ var init_item_controller = __esm(() => {
95076
95158
  logger48.debug("Deleting item", { userId: ctx.user.id, itemId });
95077
95159
  await ctx.services.item.delete(itemId);
95078
95160
  });
95079
- listByGame = requireAuth(async (ctx) => {
95161
+ listByGame = requireNonAnonymous(async (ctx) => {
95080
95162
  const gameId = ctx.params.gameId;
95081
95163
  if (!gameId) {
95082
95164
  throw ApiError.badRequest("Missing game ID");
@@ -95087,7 +95169,7 @@ var init_item_controller = __esm(() => {
95087
95169
  logger48.debug("Listing game items", { userId: ctx.user.id, gameId });
95088
95170
  return ctx.services.item.listByGame(gameId);
95089
95171
  });
95090
- createForGame = requireAuth(async (ctx) => {
95172
+ createForGame = requireNonAnonymous(async (ctx) => {
95091
95173
  const gameId = ctx.params.gameId;
95092
95174
  if (!gameId) {
95093
95175
  throw ApiError.badRequest("Missing game ID");
@@ -95115,7 +95197,7 @@ var init_item_controller = __esm(() => {
95115
95197
  });
95116
95198
  return ctx.services.item.createForGame(gameId, body2, ctx.user);
95117
95199
  });
95118
- updateForGame = requireAuth(async (ctx) => {
95200
+ updateForGame = requireNonAnonymous(async (ctx) => {
95119
95201
  const gameId = ctx.params.gameId;
95120
95202
  const itemId = ctx.params.itemId;
95121
95203
  if (!gameId || !itemId) {
@@ -95152,7 +95234,7 @@ var init_item_controller = __esm(() => {
95152
95234
  });
95153
95235
  return ctx.services.item.updateForGame(gameId, itemId, body2, ctx.user);
95154
95236
  });
95155
- deleteForGame = requireAuth(async (ctx) => {
95237
+ deleteForGame = requireNonAnonymous(async (ctx) => {
95156
95238
  const gameId = ctx.params.gameId;
95157
95239
  const itemId = ctx.params.itemId;
95158
95240
  if (!gameId || !itemId) {
@@ -95316,7 +95398,7 @@ var init_leaderboard_controller = __esm(() => {
95316
95398
  gameId,
95317
95399
  score: body2.score
95318
95400
  });
95319
- return ctx.services.leaderboard.submitScore(gameId, ctx.user.id, { score: body2.score, metadata: body2.metadata }, ctx.params.sessionId);
95401
+ return ctx.services.leaderboard.submitScore(gameId, ctx.user.id, { score: body2.score, metadata: body2.metadata }, ctx.user.isAnonymous, ctx.params.sessionId);
95320
95402
  });
95321
95403
  getGlobalLeaderboard = requireAuth(async (ctx) => {
95322
95404
  const url = ctx.url;
@@ -95344,7 +95426,7 @@ var init_leaderboard_controller = __esm(() => {
95344
95426
  gameId,
95345
95427
  ...query
95346
95428
  });
95347
- return ctx.services.leaderboard.getGlobalLeaderboard(gameId, query);
95429
+ return ctx.services.leaderboard.getGlobalLeaderboard(gameId, query, ctx.user.isAnonymous);
95348
95430
  });
95349
95431
  getLeaderboard = requireAuth(async (ctx) => {
95350
95432
  const gameId = ctx.params.gameId;
@@ -95372,9 +95454,9 @@ var init_leaderboard_controller = __esm(() => {
95372
95454
  gameId,
95373
95455
  ...query
95374
95456
  });
95375
- return ctx.services.leaderboard.getLeaderboard(gameId, query);
95457
+ return ctx.services.leaderboard.getLeaderboard(gameId, query, ctx.user.isAnonymous);
95376
95458
  });
95377
- getUserRank = requireAuth(async (ctx) => {
95459
+ getUserRank = requireNonAnonymous(async (ctx) => {
95378
95460
  const { gameId, userId } = ctx.params;
95379
95461
  if (!gameId || !userId) {
95380
95462
  throw ApiError.badRequest("Game ID and User ID are required");
@@ -95384,9 +95466,9 @@ var init_leaderboard_controller = __esm(() => {
95384
95466
  gameId,
95385
95467
  targetUserId: userId
95386
95468
  });
95387
- return ctx.services.leaderboard.getUserRank(gameId, userId);
95469
+ return ctx.services.leaderboard.getUserRank(gameId, userId, ctx.user.isAnonymous);
95388
95470
  });
95389
- getUserAllScores = requireAuth(async (ctx) => {
95471
+ getUserAllScores = requireNonAnonymous(async (ctx) => {
95390
95472
  const userId = ctx.params.userId;
95391
95473
  if (!userId) {
95392
95474
  throw ApiError.badRequest("User ID is required");
@@ -95402,7 +95484,7 @@ var init_leaderboard_controller = __esm(() => {
95402
95484
  });
95403
95485
  return ctx.services.leaderboard.getUserAllScores(userId, { limit, gameId });
95404
95486
  });
95405
- getUserScores = requireAuth(async (ctx) => {
95487
+ getUserScores = requireNonAnonymous(async (ctx) => {
95406
95488
  const { gameId, userId } = ctx.params;
95407
95489
  if (!gameId || !userId) {
95408
95490
  throw ApiError.badRequest("Game ID and User ID are required");
@@ -95450,11 +95532,11 @@ var init_level_controller = __esm(() => {
95450
95532
  init_errors();
95451
95533
  init_utils11();
95452
95534
  logger51 = log.scope("LevelController");
95453
- getByUser = requireAuth(async (ctx) => {
95535
+ getByUser = requireNonAnonymous(async (ctx) => {
95454
95536
  logger51.debug("Getting user level", { userId: ctx.user.id });
95455
95537
  return ctx.services.level.getByUser(ctx.user);
95456
95538
  });
95457
- getProgress = requireAuth(async (ctx) => {
95539
+ getProgress = requireNonAnonymous(async (ctx) => {
95458
95540
  logger51.debug("Getting level progress", { userId: ctx.user.id });
95459
95541
  return ctx.services.level.getProgress(ctx.user);
95460
95542
  });
@@ -95509,7 +95591,7 @@ var init_lti_controller = __esm(() => {
95509
95591
  init_src2();
95510
95592
  init_utils11();
95511
95593
  logger53 = log.scope("LtiController");
95512
- getStatus3 = requireAuth(async (ctx) => {
95594
+ getStatus3 = requireNonAnonymous(async (ctx) => {
95513
95595
  logger53.debug("Getting status", { userId: ctx.user.id });
95514
95596
  return ctx.services.lti.getStatus(ctx.user);
95515
95597
  });
@@ -95528,7 +95610,7 @@ var init_map_controller = __esm(() => {
95528
95610
  init_errors();
95529
95611
  init_utils11();
95530
95612
  logger54 = log.scope("MapController");
95531
- getByIdentifier = requireAuth(async (ctx) => {
95613
+ getByIdentifier = requireNonAnonymous(async (ctx) => {
95532
95614
  const identifier = ctx.params.identifier;
95533
95615
  if (!identifier) {
95534
95616
  throw ApiError.badRequest("Missing map identifier");
@@ -95536,7 +95618,7 @@ var init_map_controller = __esm(() => {
95536
95618
  logger54.debug("Getting map", { userId: ctx.user.id, identifier });
95537
95619
  return ctx.services.map.getByIdentifier(identifier);
95538
95620
  });
95539
- getElements = requireAuth(async (ctx) => {
95621
+ getElements = requireNonAnonymous(async (ctx) => {
95540
95622
  const mapId = ctx.url.searchParams.get("mapId");
95541
95623
  if (!mapId) {
95542
95624
  throw ApiError.badRequest("Missing required query parameter: mapId");
@@ -95547,7 +95629,7 @@ var init_map_controller = __esm(() => {
95547
95629
  logger54.debug("Getting map elements", { userId: ctx.user.id, mapId });
95548
95630
  return ctx.services.map.getElements(mapId);
95549
95631
  });
95550
- getObjects = requireAuth(async (ctx) => {
95632
+ getObjects = requireNonAnonymous(async (ctx) => {
95551
95633
  const mapId = ctx.params.mapId;
95552
95634
  if (!mapId) {
95553
95635
  throw ApiError.badRequest("Missing mapId");
@@ -95558,7 +95640,7 @@ var init_map_controller = __esm(() => {
95558
95640
  logger54.debug("Getting map objects", { userId: ctx.user.id, mapId });
95559
95641
  return ctx.services.map.getObjects(mapId, ctx.user.id);
95560
95642
  });
95561
- createObject = requireAuth(async (ctx) => {
95643
+ createObject = requireNonAnonymous(async (ctx) => {
95562
95644
  const mapId = ctx.params.mapId;
95563
95645
  if (!mapId) {
95564
95646
  throw ApiError.badRequest("Missing mapId");
@@ -95592,7 +95674,7 @@ var init_map_controller = __esm(() => {
95592
95674
  const { mapId: _mapId, ...data } = body2;
95593
95675
  return ctx.services.map.createObject(mapId, data, ctx.user);
95594
95676
  });
95595
- deleteObject = requireAuth(async (ctx) => {
95677
+ deleteObject = requireNonAnonymous(async (ctx) => {
95596
95678
  const { mapId, objectId } = ctx.params;
95597
95679
  if (!mapId) {
95598
95680
  throw ApiError.badRequest("Missing mapId");
@@ -95627,7 +95709,7 @@ var init_notification_controller = __esm(() => {
95627
95709
  init_errors();
95628
95710
  init_utils11();
95629
95711
  logger55 = log.scope("NotificationController");
95630
- list6 = requireAuth(async (ctx) => {
95712
+ list6 = requireNonAnonymous(async (ctx) => {
95631
95713
  const query = {
95632
95714
  status: ctx.url.searchParams.get("status") || undefined,
95633
95715
  type: ctx.url.searchParams.get("type") || undefined,
@@ -95643,7 +95725,7 @@ var init_notification_controller = __esm(() => {
95643
95725
  logger55.debug("Listing notifications", { userId: ctx.user.id, ...result.data });
95644
95726
  return ctx.services.notification.list(ctx.user, result.data);
95645
95727
  });
95646
- updateStatus = requireAuth(async (ctx) => {
95728
+ updateStatus = requireNonAnonymous(async (ctx) => {
95647
95729
  const notificationId = ctx.params.notificationId;
95648
95730
  if (!notificationId) {
95649
95731
  throw ApiError.badRequest("Notification ID required");
@@ -95667,7 +95749,7 @@ var init_notification_controller = __esm(() => {
95667
95749
  });
95668
95750
  return ctx.services.notification.updateStatus(notificationId, body2.status, body2.method);
95669
95751
  });
95670
- getStats2 = requireAuth(async (ctx) => {
95752
+ getStats2 = requireNonAnonymous(async (ctx) => {
95671
95753
  const startDate = ctx.url.searchParams.get("startDate");
95672
95754
  const endDate = ctx.url.searchParams.get("endDate");
95673
95755
  logger55.debug("Getting stats", { userId: ctx.user.id, startDate, endDate });
@@ -95676,7 +95758,7 @@ var init_notification_controller = __esm(() => {
95676
95758
  endDate: endDate ? new Date(endDate) : undefined
95677
95759
  });
95678
95760
  });
95679
- create4 = requireAuth(async (ctx) => {
95761
+ create4 = requireNonAnonymous(async (ctx) => {
95680
95762
  let body2;
95681
95763
  try {
95682
95764
  const json4 = await ctx.request.json();
@@ -95706,7 +95788,7 @@ var init_notification_controller = __esm(() => {
95706
95788
  metadata: body2.metadata
95707
95789
  });
95708
95790
  });
95709
- deliver = requireAuth(async (ctx) => {
95791
+ deliver = requireNonAnonymous(async (ctx) => {
95710
95792
  logger55.debug("Delivering notifications", { userId: ctx.user.id });
95711
95793
  try {
95712
95794
  await ctx.services.notification.deliverPending(ctx.user.id);
@@ -95731,7 +95813,7 @@ var init_realtime_controller = __esm(() => {
95731
95813
  init_src2();
95732
95814
  init_utils11();
95733
95815
  logger56 = log.scope("RealtimeController");
95734
- generateToken2 = requireAuth(async (ctx) => {
95816
+ generateToken2 = requireNonAnonymous(async (ctx) => {
95735
95817
  const gameIdOrSlug = ctx.params.gameId;
95736
95818
  logger56.debug("Generating token", {
95737
95819
  userId: ctx.user.id,
@@ -95897,7 +95979,7 @@ var init_shop_controller = __esm(() => {
95897
95979
  init_src2();
95898
95980
  init_utils11();
95899
95981
  logger60 = log.scope("ShopController");
95900
- getShopView = requireAuth(async (ctx) => {
95982
+ getShopView = requireNonAnonymous(async (ctx) => {
95901
95983
  logger60.debug("Getting shop view", { userId: ctx.user.id });
95902
95984
  return ctx.services.shop.getShopView(ctx.user);
95903
95985
  });
@@ -95992,7 +96074,7 @@ var init_shop_listing_controller = __esm(() => {
95992
96074
  logger61.debug("Deleting listing", { userId: ctx.user.id, listingId });
95993
96075
  await ctx.services.shopListing.delete(listingId);
95994
96076
  });
95995
- listByGame2 = requireAuth(async (ctx) => {
96077
+ listByGame2 = requireNonAnonymous(async (ctx) => {
95996
96078
  const gameId = ctx.params.gameId;
95997
96079
  if (!gameId) {
95998
96080
  throw ApiError.badRequest("Missing game ID");
@@ -96003,7 +96085,7 @@ var init_shop_listing_controller = __esm(() => {
96003
96085
  logger61.debug("Listing game listings", { userId: ctx.user.id, gameId });
96004
96086
  return ctx.services.shopListing.listByGame(gameId, ctx.user);
96005
96087
  });
96006
- getByGameItem = requireAuth(async (ctx) => {
96088
+ getByGameItem = requireNonAnonymous(async (ctx) => {
96007
96089
  const gameId = ctx.params.gameId;
96008
96090
  const itemId = ctx.params.itemId;
96009
96091
  if (!gameId || !itemId) {
@@ -96018,7 +96100,7 @@ var init_shop_listing_controller = __esm(() => {
96018
96100
  logger61.debug("Getting game item listing", { userId: ctx.user.id, gameId, itemId });
96019
96101
  return ctx.services.shopListing.getByGameItem(gameId, itemId, ctx.user);
96020
96102
  });
96021
- createForGameItem = requireAuth(async (ctx) => {
96103
+ createForGameItem = requireNonAnonymous(async (ctx) => {
96022
96104
  const gameId = ctx.params.gameId;
96023
96105
  const itemId = ctx.params.itemId;
96024
96106
  if (!gameId || !itemId) {
@@ -96051,7 +96133,7 @@ var init_shop_listing_controller = __esm(() => {
96051
96133
  });
96052
96134
  return ctx.services.shopListing.createForGameItem(gameId, itemId, body2, ctx.user);
96053
96135
  });
96054
- updateForGameItem = requireAuth(async (ctx) => {
96136
+ updateForGameItem = requireNonAnonymous(async (ctx) => {
96055
96137
  const gameId = ctx.params.gameId;
96056
96138
  const itemId = ctx.params.itemId;
96057
96139
  if (!gameId || !itemId) {
@@ -96085,7 +96167,7 @@ var init_shop_listing_controller = __esm(() => {
96085
96167
  });
96086
96168
  return ctx.services.shopListing.updateForGameItem(gameId, itemId, body2, ctx.user);
96087
96169
  });
96088
- deleteForGameItem = requireAuth(async (ctx) => {
96170
+ deleteForGameItem = requireNonAnonymous(async (ctx) => {
96089
96171
  const gameId = ctx.params.gameId;
96090
96172
  const itemId = ctx.params.itemId;
96091
96173
  if (!gameId || !itemId) {
@@ -96147,17 +96229,17 @@ var init_timeback_controller = __esm(() => {
96147
96229
  init_errors();
96148
96230
  init_utils11();
96149
96231
  logger63 = log.scope("TimebackController");
96150
- getTodayXp = requireAuth(async (ctx) => {
96232
+ getTodayXp = requireNonAnonymous(async (ctx) => {
96151
96233
  const date4 = ctx.url.searchParams.get("date") || undefined;
96152
96234
  const tz = ctx.url.searchParams.get("tz") || undefined;
96153
96235
  logger63.debug("Getting today XP", { userId: ctx.user.id, date: date4, tz });
96154
96236
  return ctx.services.timeback.getTodayXp(ctx.user.id, date4, tz);
96155
96237
  });
96156
- getTotalXp = requireAuth(async (ctx) => {
96238
+ getTotalXp = requireNonAnonymous(async (ctx) => {
96157
96239
  logger63.debug("Getting total XP", { userId: ctx.user.id });
96158
96240
  return ctx.services.timeback.getTotalXp(ctx.user.id);
96159
96241
  });
96160
- updateTodayXp = requireAuth(async (ctx) => {
96242
+ updateTodayXp = requireNonAnonymous(async (ctx) => {
96161
96243
  let body2;
96162
96244
  try {
96163
96245
  const json4 = await ctx.request.json();
@@ -96173,13 +96255,13 @@ var init_timeback_controller = __esm(() => {
96173
96255
  logger63.debug("Updating today XP", { userId: ctx.user.id, xp: body2.xp });
96174
96256
  return ctx.services.timeback.updateTodayXp(ctx.user.id, body2);
96175
96257
  });
96176
- getXpHistory = requireAuth(async (ctx) => {
96258
+ getXpHistory = requireNonAnonymous(async (ctx) => {
96177
96259
  const startDate = ctx.url.searchParams.get("startDate") || undefined;
96178
96260
  const endDate = ctx.url.searchParams.get("endDate") || undefined;
96179
96261
  logger63.debug("Getting XP history", { userId: ctx.user.id, startDate, endDate });
96180
96262
  return ctx.services.timeback.getXpHistory(ctx.user.id, startDate, endDate);
96181
96263
  });
96182
- populateStudent = requireAuth(async (ctx) => {
96264
+ populateStudent = requireNonAnonymous(async (ctx) => {
96183
96265
  let providedNames;
96184
96266
  try {
96185
96267
  const json4 = await ctx.request.json();
@@ -96197,11 +96279,11 @@ var init_timeback_controller = __esm(() => {
96197
96279
  });
96198
96280
  return ctx.services.timeback.populateStudent(ctx.user, providedNames);
96199
96281
  });
96200
- getUser = requireAuth(async (ctx) => {
96282
+ getUser = requireNonAnonymous(async (ctx) => {
96201
96283
  logger63.debug("Getting user", { userId: ctx.user.id, gameId: ctx.gameId });
96202
96284
  return ctx.services.timeback.getUserData(ctx.user.id, ctx.gameId);
96203
96285
  });
96204
- getUserById = requireAuth(async (ctx) => {
96286
+ getUserById = requireNonAnonymous(async (ctx) => {
96205
96287
  const timebackId = ctx.params.timebackId;
96206
96288
  if (!timebackId) {
96207
96289
  throw ApiError.badRequest("Missing timebackId parameter");
@@ -96600,17 +96682,32 @@ var init_upload_controller = __esm(() => {
96600
96682
  });
96601
96683
 
96602
96684
  // ../api-core/src/controllers/user.controller.ts
96603
- var logger65, getMe, users2;
96685
+ var logger65, getMe, getDemoProfile, updateDemoProfile, users2;
96604
96686
  var init_user_controller = __esm(() => {
96687
+ init_schemas_index();
96605
96688
  init_src2();
96606
96689
  init_utils11();
96607
96690
  logger65 = log.scope("UserController");
96608
- getMe = requireAuth(async (ctx) => {
96691
+ getMe = requireNonAnonymous(async (ctx) => {
96609
96692
  logger65.debug("Getting current user", { userId: ctx.user.id, gameId: ctx.gameId });
96610
96693
  return ctx.services.user.getMe(ctx.user, ctx.gameId);
96611
96694
  });
96695
+ getDemoProfile = requireAnonymous(async (ctx) => {
96696
+ logger65.debug("Getting demo profile", { userId: ctx.user.id });
96697
+ return ctx.services.user.getDemoProfile(ctx.user.id);
96698
+ });
96699
+ updateDemoProfile = requireAnonymous(async (ctx) => {
96700
+ const body2 = await parseRequestBody(ctx.request, DemoProfileSchema);
96701
+ logger65.debug("Updating demo profile", {
96702
+ userId: ctx.user.id,
96703
+ displayName: body2.displayName
96704
+ });
96705
+ return ctx.services.user.updateDemoProfile(ctx.user.id, body2.displayName);
96706
+ });
96612
96707
  users2 = {
96613
- getMe
96708
+ getMe,
96709
+ getDemoProfile,
96710
+ updateDemoProfile
96614
96711
  };
96615
96712
  });
96616
96713
 
@@ -96818,6 +96915,8 @@ var init_users = __esm(() => {
96818
96915
  }
96819
96916
  return handle2(users2.getMe)(c2);
96820
96917
  });
96918
+ usersRouter.get("/demo-profile", handle2(users2.getDemoProfile));
96919
+ usersRouter.patch("/demo-profile", handle2(users2.updateDemoProfile));
96821
96920
  usersRouter.get("/level", handle2(levels.getByUser));
96822
96921
  usersRouter.get("/level/progress", handle2(levels.getProgress));
96823
96922
  usersRouter.get("/:userId/scores", handle2(leaderboard.getUserAllScores));
@@ -97162,6 +97261,8 @@ var init_scores = __esm(() => {
97162
97261
  init_api();
97163
97262
  gameScoresRouter = new Hono2;
97164
97263
  gameScoresRouter.post("/:gameId/scores", handle2(leaderboard.submitScore, { status: 201 }));
97264
+ gameScoresRouter.get("/:gameId/leaderboard", handle2(leaderboard.getLeaderboard));
97265
+ gameScoresRouter.get("/:gameId/users/:userId/rank", handle2(leaderboard.getUserRank));
97165
97266
  gameScoresRouter.get("/:gameId/users/:userId/scores", handle2(leaderboard.getUserScores));
97166
97267
  });
97167
97268
 
@@ -97905,6 +98006,7 @@ async function startServer(port, project, options = {}) {
97905
98006
  const mainServer = serve({ fetch: app.fetch, port });
97906
98007
  return {
97907
98008
  main: mainServer,
98009
+ db: db2,
97908
98010
  gameId,
97909
98011
  timebackMode: getTimebackDisplayMode(),
97910
98012
  setRole: (role) => {