@playcademy/sandbox 0.12.2-beta.5 → 0.12.2-beta.6

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/cli.js CHANGED
@@ -2517,7 +2517,7 @@ var package_default;
2517
2517
  var init_package = __esm(() => {
2518
2518
  package_default = {
2519
2519
  name: "@playcademy/sandbox",
2520
- version: "0.12.2-beta.5",
2520
+ version: "0.12.2-beta.6",
2521
2521
  description: "Local development server for Playcademy game development",
2522
2522
  type: "module",
2523
2523
  exports: {
@@ -20895,12 +20895,13 @@ var init_table7 = __esm(() => {
20895
20895
  });
20896
20896
 
20897
20897
  // ../data/src/domains/embed/table.ts
20898
- var embedPartners, embedLaunches, embedLaunchesRelations;
20898
+ var embedContextRoleEnum, embedPartners, embedLaunches, embedLaunchesRelations;
20899
20899
  var init_table8 = __esm(() => {
20900
20900
  init_drizzle_orm();
20901
20901
  init_pg_core();
20902
20902
  init_table5();
20903
20903
  init_table3();
20904
+ embedContextRoleEnum = pgEnum("embed_context_role", ["host"]);
20904
20905
  embedPartners = pgTable("embed_partners", {
20905
20906
  id: uuid("id").primaryKey().defaultRandom(),
20906
20907
  name: text("name").notNull(),
@@ -20918,6 +20919,7 @@ var init_table8 = __esm(() => {
20918
20919
  parentOrigin: text("parent_origin").notNull(),
20919
20920
  timebackCourseId: text("timeback_course_id"),
20920
20921
  contextId: text("context_id"),
20922
+ contextRole: embedContextRoleEnum("context_role"),
20921
20923
  passHash: text("pass_hash").unique(),
20922
20924
  passExpiresAt: timestamp("pass_expires_at", { withTimezone: true }).notNull(),
20923
20925
  redeemedAt: timestamp("redeemed_at", { withTimezone: true }),
@@ -20957,6 +20959,7 @@ __export(exports_tables_index, {
20957
20959
  deploymentProviderEnum: () => deploymentProviderEnum,
20958
20960
  deploymentTargetEnum: () => deploymentTargetEnum,
20959
20961
  developerStatusEnum: () => developerStatusEnum,
20962
+ embedContextRoleEnum: () => embedContextRoleEnum,
20960
20963
  embedLaunches: () => embedLaunches,
20961
20964
  embedLaunchesRelations: () => embedLaunchesRelations,
20962
20965
  embedPartners: () => embedPartners,
@@ -50824,16 +50827,21 @@ function isCanonicalOrigin(value) {
50824
50827
  }
50825
50828
  return url.protocol === "https:" || url.protocol === "http:" && isLocalHostname(url.hostname);
50826
50829
  }
50827
- var LOCAL_HOSTNAMES, EmbedOriginSchema, EmbedContextIdSchema, EmbedPartnerClientIdSchema, EnsureEmbedPartnerSchema, AddEmbedPartnerOriginSchema, CreateEmbedLaunchSchema, RedeemEmbedPassSchema;
50830
+ var LOCAL_HOSTNAMES, EmbedOriginSchema, EmbedContextIdSchema, EmbedContextSchema, EmbedPartnerClientIdSchema, EnsureEmbedPartnerSchema, AddEmbedPartnerOriginSchema, CreateEmbedLaunchSchema, RedeemEmbedPassSchema;
50828
50831
  var init_schemas5 = __esm(() => {
50829
50832
  init_esm();
50833
+ init_table8();
50830
50834
  LOCAL_HOSTNAMES = new Set(["localhost", "127.0.0.1"]);
50831
50835
  EmbedOriginSchema = stringType().refine(isCanonicalOrigin, {
50832
50836
  message: "Origin must be a bare https origin like https://example.com, with no path or slash"
50833
50837
  });
50834
50838
  EmbedContextIdSchema = stringType().regex(/^[A-Za-z0-9._~-]{1,128}$/, {
50835
- message: "contextId must be 1-128 URL-safe characters (letters, digits, . _ ~ -)"
50839
+ message: "context.id must be 1-128 URL-safe characters (letters, digits, . _ ~ -)"
50836
50840
  });
50841
+ EmbedContextSchema = objectType({
50842
+ id: EmbedContextIdSchema,
50843
+ role: enumType(embedContextRoleEnum.enumValues).optional()
50844
+ }).strict();
50837
50845
  EmbedPartnerClientIdSchema = stringType().trim().min(1).max(200);
50838
50846
  EnsureEmbedPartnerSchema = objectType({
50839
50847
  name: stringType().trim().min(1).max(100)
@@ -50846,7 +50854,7 @@ var init_schemas5 = __esm(() => {
50846
50854
  gameSlug: stringType().trim().min(1).max(100),
50847
50855
  parentOrigin: EmbedOriginSchema,
50848
50856
  timebackCourseId: stringType().trim().min(1).max(200).optional(),
50849
- contextId: EmbedContextIdSchema.optional()
50857
+ context: EmbedContextSchema.optional()
50850
50858
  }).strict();
50851
50859
  RedeemEmbedPassSchema = objectType({
50852
50860
  pass: stringType().min(1).max(200),
@@ -95692,7 +95700,15 @@ async function scopedContextId(partnerId, contextId) {
95692
95700
  return sha256Hex(`${partnerId}:${contextId}`);
95693
95701
  }
95694
95702
  function launchTokenClaims(launch) {
95695
- return launch.contextId ? { contextId: launch.contextId } : {};
95703
+ if (!launch.contextId) {
95704
+ return {};
95705
+ }
95706
+ return {
95707
+ context: {
95708
+ id: launch.contextId,
95709
+ ...launch.contextRole && { role: launch.contextRole }
95710
+ }
95711
+ };
95696
95712
  }
95697
95713
 
95698
95714
  class EmbedService {
@@ -95738,7 +95754,8 @@ class EmbedService {
95738
95754
  gameId: game.id,
95739
95755
  parentOrigin: input.parentOrigin,
95740
95756
  timebackCourseId: input.timebackCourseId ?? null,
95741
- contextId: input.contextId ? await scopedContextId(partner.id, input.contextId) : null,
95757
+ contextId: input.context ? await scopedContextId(partner.id, input.context.id) : null,
95758
+ contextRole: input.context?.role ?? null,
95742
95759
  passHash: await sha256Hex(pass),
95743
95760
  passExpiresAt,
95744
95761
  expiresAt: new Date(now + EMBED_LAUNCH_TTL_MS)
@@ -95749,7 +95766,8 @@ class EmbedService {
95749
95766
  setAttributes({
95750
95767
  "app.launch.id": launch.id,
95751
95768
  "app.user.id": user.id,
95752
- "app.embed.has_context": input.contextId !== undefined
95769
+ "app.embed.has_context": input.context !== undefined,
95770
+ ...input.context?.role && { "app.embed.context_role": input.context.role }
95753
95771
  });
95754
95772
  return { launchId: launch.id, pass, passExpiresAt, gameSlug: game.slug };
95755
95773
  }
package/dist/server.js CHANGED
@@ -697,7 +697,7 @@ var package_default;
697
697
  var init_package = __esm(() => {
698
698
  package_default = {
699
699
  name: "@playcademy/sandbox",
700
- version: "0.12.2-beta.5",
700
+ version: "0.12.2-beta.6",
701
701
  description: "Local development server for Playcademy game development",
702
702
  type: "module",
703
703
  exports: {
@@ -19075,12 +19075,13 @@ var init_table7 = __esm(() => {
19075
19075
  });
19076
19076
 
19077
19077
  // ../data/src/domains/embed/table.ts
19078
- var embedPartners, embedLaunches, embedLaunchesRelations;
19078
+ var embedContextRoleEnum, embedPartners, embedLaunches, embedLaunchesRelations;
19079
19079
  var init_table8 = __esm(() => {
19080
19080
  init_drizzle_orm();
19081
19081
  init_pg_core();
19082
19082
  init_table5();
19083
19083
  init_table3();
19084
+ embedContextRoleEnum = pgEnum("embed_context_role", ["host"]);
19084
19085
  embedPartners = pgTable("embed_partners", {
19085
19086
  id: uuid("id").primaryKey().defaultRandom(),
19086
19087
  name: text("name").notNull(),
@@ -19098,6 +19099,7 @@ var init_table8 = __esm(() => {
19098
19099
  parentOrigin: text("parent_origin").notNull(),
19099
19100
  timebackCourseId: text("timeback_course_id"),
19100
19101
  contextId: text("context_id"),
19102
+ contextRole: embedContextRoleEnum("context_role"),
19101
19103
  passHash: text("pass_hash").unique(),
19102
19104
  passExpiresAt: timestamp("pass_expires_at", { withTimezone: true }).notNull(),
19103
19105
  redeemedAt: timestamp("redeemed_at", { withTimezone: true }),
@@ -19137,6 +19139,7 @@ __export(exports_tables_index, {
19137
19139
  deploymentProviderEnum: () => deploymentProviderEnum,
19138
19140
  deploymentTargetEnum: () => deploymentTargetEnum,
19139
19141
  developerStatusEnum: () => developerStatusEnum,
19142
+ embedContextRoleEnum: () => embedContextRoleEnum,
19140
19143
  embedLaunches: () => embedLaunches,
19141
19144
  embedLaunchesRelations: () => embedLaunchesRelations,
19142
19145
  embedPartners: () => embedPartners,
@@ -49004,16 +49007,21 @@ function isCanonicalOrigin(value) {
49004
49007
  }
49005
49008
  return url.protocol === "https:" || url.protocol === "http:" && isLocalHostname(url.hostname);
49006
49009
  }
49007
- var LOCAL_HOSTNAMES, EmbedOriginSchema, EmbedContextIdSchema, EmbedPartnerClientIdSchema, EnsureEmbedPartnerSchema, AddEmbedPartnerOriginSchema, CreateEmbedLaunchSchema, RedeemEmbedPassSchema;
49010
+ var LOCAL_HOSTNAMES, EmbedOriginSchema, EmbedContextIdSchema, EmbedContextSchema, EmbedPartnerClientIdSchema, EnsureEmbedPartnerSchema, AddEmbedPartnerOriginSchema, CreateEmbedLaunchSchema, RedeemEmbedPassSchema;
49008
49011
  var init_schemas5 = __esm(() => {
49009
49012
  init_esm();
49013
+ init_table8();
49010
49014
  LOCAL_HOSTNAMES = new Set(["localhost", "127.0.0.1"]);
49011
49015
  EmbedOriginSchema = stringType().refine(isCanonicalOrigin, {
49012
49016
  message: "Origin must be a bare https origin like https://example.com, with no path or slash"
49013
49017
  });
49014
49018
  EmbedContextIdSchema = stringType().regex(/^[A-Za-z0-9._~-]{1,128}$/, {
49015
- message: "contextId must be 1-128 URL-safe characters (letters, digits, . _ ~ -)"
49019
+ message: "context.id must be 1-128 URL-safe characters (letters, digits, . _ ~ -)"
49016
49020
  });
49021
+ EmbedContextSchema = objectType({
49022
+ id: EmbedContextIdSchema,
49023
+ role: enumType(embedContextRoleEnum.enumValues).optional()
49024
+ }).strict();
49017
49025
  EmbedPartnerClientIdSchema = stringType().trim().min(1).max(200);
49018
49026
  EnsureEmbedPartnerSchema = objectType({
49019
49027
  name: stringType().trim().min(1).max(100)
@@ -49026,7 +49034,7 @@ var init_schemas5 = __esm(() => {
49026
49034
  gameSlug: stringType().trim().min(1).max(100),
49027
49035
  parentOrigin: EmbedOriginSchema,
49028
49036
  timebackCourseId: stringType().trim().min(1).max(200).optional(),
49029
- contextId: EmbedContextIdSchema.optional()
49037
+ context: EmbedContextSchema.optional()
49030
49038
  }).strict();
49031
49039
  RedeemEmbedPassSchema = objectType({
49032
49040
  pass: stringType().min(1).max(200),
@@ -93872,7 +93880,15 @@ async function scopedContextId(partnerId, contextId) {
93872
93880
  return sha256Hex(`${partnerId}:${contextId}`);
93873
93881
  }
93874
93882
  function launchTokenClaims(launch) {
93875
- return launch.contextId ? { contextId: launch.contextId } : {};
93883
+ if (!launch.contextId) {
93884
+ return {};
93885
+ }
93886
+ return {
93887
+ context: {
93888
+ id: launch.contextId,
93889
+ ...launch.contextRole && { role: launch.contextRole }
93890
+ }
93891
+ };
93876
93892
  }
93877
93893
 
93878
93894
  class EmbedService {
@@ -93918,7 +93934,8 @@ class EmbedService {
93918
93934
  gameId: game.id,
93919
93935
  parentOrigin: input.parentOrigin,
93920
93936
  timebackCourseId: input.timebackCourseId ?? null,
93921
- contextId: input.contextId ? await scopedContextId(partner.id, input.contextId) : null,
93937
+ contextId: input.context ? await scopedContextId(partner.id, input.context.id) : null,
93938
+ contextRole: input.context?.role ?? null,
93922
93939
  passHash: await sha256Hex(pass),
93923
93940
  passExpiresAt,
93924
93941
  expiresAt: new Date(now + EMBED_LAUNCH_TTL_MS)
@@ -93929,7 +93946,8 @@ class EmbedService {
93929
93946
  setAttributes({
93930
93947
  "app.launch.id": launch.id,
93931
93948
  "app.user.id": user.id,
93932
- "app.embed.has_context": input.contextId !== undefined
93949
+ "app.embed.has_context": input.context !== undefined,
93950
+ ...input.context?.role && { "app.embed.context_role": input.context.role }
93933
93951
  });
93934
93952
  return { launchId: launch.id, pass, passExpiresAt, gameSlug: game.slug };
93935
93953
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sandbox",
3
- "version": "0.12.2-beta.5",
3
+ "version": "0.12.2-beta.6",
4
4
  "description": "Local development server for Playcademy game development",
5
5
  "type": "module",
6
6
  "exports": {