@stackframe/js 2.7.14 → 2.7.16

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.
@@ -308,6 +308,7 @@ type ServerBaseUser = {
308
308
  readonly serverMetadata: any;
309
309
  setServerMetadata(metadata: any): Promise<void>;
310
310
  setClientReadOnlyMetadata(metadata: any): Promise<void>;
311
+ createTeam(data: Omit<ServerTeamCreateOptions, "creatorUserId">): Promise<ServerTeam>;
311
312
  listContactChannels(): Promise<ServerContactChannel[]>;
312
313
  createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>;
313
314
  update(user: ServerUserUpdateOptions): Promise<void>;
@@ -346,6 +347,9 @@ type ServerUserCreateOptions = {
346
347
  otpAuthEnabled?: boolean;
347
348
  displayName?: string;
348
349
  primaryEmailVerified?: boolean;
350
+ clientMetadata?: any;
351
+ clientReadOnlyMetadata?: any;
352
+ serverMetadata?: any;
349
353
  };
350
354
  type Project = {
351
355
  readonly id: string;
@@ -559,7 +563,9 @@ type ServerListUsersOptions = {
559
563
  desc?: boolean;
560
564
  query?: string;
561
565
  };
562
- type ServerTeamCreateOptions = TeamCreateOptions;
566
+ type ServerTeamCreateOptions = TeamCreateOptions & {
567
+ creatorUserId?: string;
568
+ };
563
569
  type ServerTeamUpdateOptions = TeamUpdateOptions & {
564
570
  clientReadOnlyMetadata?: ReadonlyJson;
565
571
  serverMetadata?: ReadonlyJson;
@@ -62,7 +62,7 @@ var import_url = require("../utils/url");
62
62
  var import_auth = require("./auth");
63
63
  var import_cookie = require("./cookie");
64
64
  var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
65
- var clientVersion = "js @stackframe/js@2.7.14";
65
+ var clientVersion = "js @stackframe/js@2.7.16";
66
66
  function getUrls(partial) {
67
67
  const handler = partial.handler ?? "/handler";
68
68
  const home = partial.home ?? "/";
@@ -88,10 +88,10 @@ function getUrls(partial) {
88
88
  };
89
89
  }
90
90
  function getDefaultProjectId() {
91
- return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || (0, import_errors.throwErr)(new Error("Welcome to Stack Auth! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
91
+ return (0, import_env.getPublicEnvVar)("NEXT_PUBLIC_STACK_PROJECT_ID") || (0, import_errors.throwErr)(new Error("Welcome to Stack Auth! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
92
92
  }
93
93
  function getDefaultPublishableClientKey() {
94
- return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || (0, import_errors.throwErr)(new Error("Welcome to Stack Auth! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
94
+ return (0, import_env.getPublicEnvVar)("NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY") || (0, import_errors.throwErr)(new Error("Welcome to Stack Auth! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
95
95
  }
96
96
  function getDefaultSecretServerKey() {
97
97
  return process.env.STACK_SECRET_SERVER_KEY || (0, import_errors.throwErr)(new Error("No secret server key provided. Please copy your key from the Stack dashboard and put your it in the STACK_SECRET_SERVER_KEY environment variable."));
@@ -100,7 +100,7 @@ function getDefaultSuperSecretAdminKey() {
100
100
  return process.env.STACK_SUPER_SECRET_ADMIN_KEY || (0, import_errors.throwErr)(new Error("No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable."));
101
101
  }
102
102
  function getDefaultBaseUrl() {
103
- const url = process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
103
+ const url = (0, import_env.getPublicEnvVar)("NEXT_PUBLIC_STACK_API_URL") || (0, import_env.getPublicEnvVar)("NEXT_PUBLIC_STACK_URL") || defaultBaseUrl;
104
104
  return url.endsWith("/") ? url.slice(0, -1) : url;
105
105
  }
106
106
  var defaultBaseUrl = "https://api.stack-auth.com";
@@ -218,7 +218,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
218
218
  this._interface = _options.interface;
219
219
  } else {
220
220
  this._interface = new import_stack_shared.StackClientInterface({
221
- baseUrl: _options.baseUrl ?? getDefaultBaseUrl(),
221
+ getBaseUrl: () => _options.baseUrl ?? getDefaultBaseUrl(),
222
222
  projectId: _options.projectId ?? getDefaultProjectId(),
223
223
  clientVersion,
224
224
  publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
@@ -719,10 +719,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
719
719
  return teams.map((crud2) => app._clientTeamFromCrud(crud2, session));
720
720
  },
721
721
  async createTeam(data) {
722
- const crud2 = await app._interface.createClientTeam({
723
- ...teamCreateOptionsToCrud(data),
724
- creator_user_id: "me"
725
- }, session);
722
+ const crud2 = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
726
723
  await app._currentUserTeamsCache.refresh([session]);
727
724
  return app._clientTeamFromCrud(crud2, session);
728
725
  },
@@ -808,7 +805,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
808
805
  _getOwnedAdminApp(forProjectId, session) {
809
806
  if (!this._ownedAdminApps.has([session, forProjectId])) {
810
807
  this._ownedAdminApps.set([session, forProjectId], new _StackAdminAppImpl({
811
- baseUrl: this._interface.options.baseUrl,
808
+ baseUrl: this._interface.options.getBaseUrl(),
812
809
  projectId: forProjectId,
813
810
  tokenStore: null,
814
811
  projectOwnerSession: session,
@@ -1273,7 +1270,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
1273
1270
  throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
1274
1271
  }
1275
1272
  return {
1276
- baseUrl: this._interface.options.baseUrl,
1273
+ baseUrl: this._options.baseUrl,
1277
1274
  projectId: this.projectId,
1278
1275
  publishableClientKey: this._interface.options.publishableClientKey,
1279
1276
  tokenStore: this._tokenStoreInit,
@@ -1302,7 +1299,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1302
1299
  oauthScopesOnSignIn: options.oauthScopesOnSignIn
1303
1300
  } : {
1304
1301
  interface: new import_stack_shared.StackServerInterface({
1305
- baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
1302
+ getBaseUrl: () => options.baseUrl ?? getDefaultBaseUrl(),
1306
1303
  projectId: options.projectId ?? getDefaultProjectId(),
1307
1304
  clientVersion,
1308
1305
  publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
@@ -1488,10 +1485,10 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1488
1485
  return teams.map((t) => app._serverTeamFromCrud(t));
1489
1486
  },
1490
1487
  createTeam: async (data) => {
1491
- const team = await app._interface.createServerTeam({
1492
- ...serverTeamCreateOptionsToCrud(data),
1493
- creator_user_id: crud.id
1494
- });
1488
+ const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({
1489
+ creatorUserId: crud.id,
1490
+ ...data
1491
+ }));
1495
1492
  await app._serverTeamsCache.refresh([void 0]);
1496
1493
  return app._serverTeamFromCrud(team);
1497
1494
  },
@@ -1710,7 +1707,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
1710
1707
  constructor(options) {
1711
1708
  super({
1712
1709
  interface: new import_stack_shared.StackAdminInterface({
1713
- baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
1710
+ getBaseUrl: () => options.baseUrl ?? getDefaultBaseUrl(),
1714
1711
  projectId: options.projectId ?? getDefaultProjectId(),
1715
1712
  clientVersion,
1716
1713
  ..."projectOwnerSession" in options ? {
@@ -2008,7 +2005,10 @@ function serverUserCreateOptionsToCrud(options) {
2008
2005
  otp_auth_enabled: options.otpAuthEnabled,
2009
2006
  primary_email_auth_enabled: options.primaryEmailAuthEnabled,
2010
2007
  display_name: options.displayName,
2011
- primary_email_verified: options.primaryEmailVerified
2008
+ primary_email_verified: options.primaryEmailVerified,
2009
+ client_metadata: options.clientMetadata,
2010
+ client_read_only_metadata: options.clientReadOnlyMetadata,
2011
+ server_metadata: options.serverMetadata
2012
2012
  };
2013
2013
  }
2014
2014
  function adminProjectUpdateOptionsToCrud(options) {
@@ -2079,14 +2079,19 @@ function teamUpdateOptionsToCrud(options) {
2079
2079
  client_metadata: options.clientMetadata
2080
2080
  };
2081
2081
  }
2082
- function teamCreateOptionsToCrud(options) {
2082
+ function teamCreateOptionsToCrud(options, creatorUserId) {
2083
2083
  return {
2084
2084
  display_name: options.displayName,
2085
- profile_image_url: options.profileImageUrl
2085
+ profile_image_url: options.profileImageUrl,
2086
+ creator_user_id: creatorUserId
2086
2087
  };
2087
2088
  }
2088
2089
  function serverTeamCreateOptionsToCrud(options) {
2089
- return teamCreateOptionsToCrud(options);
2090
+ return {
2091
+ display_name: options.displayName,
2092
+ profile_image_url: options.profileImageUrl,
2093
+ creator_user_id: options.creatorUserId
2094
+ };
2090
2095
  }
2091
2096
  function serverTeamUpdateOptionsToCrud(options) {
2092
2097
  return {