@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.
@@ -7,7 +7,7 @@ import { InternalSession } from "@stackframe/stack-shared/dist/sessions";
7
7
  import { encodeBase64 } from "@stackframe/stack-shared/dist/utils/bytes";
8
8
  import { AsyncCache } from "@stackframe/stack-shared/dist/utils/caches";
9
9
  import { scrambleDuringCompileTime } from "@stackframe/stack-shared/dist/utils/compile-time";
10
- import { isBrowserLike } from "@stackframe/stack-shared/dist/utils/env";
10
+ import { getPublicEnvVar, isBrowserLike } from "@stackframe/stack-shared/dist/utils/env";
11
11
  import { StackAssertionError, throwErr } from "@stackframe/stack-shared/dist/utils/errors";
12
12
  import { DependenciesMap } from "@stackframe/stack-shared/dist/utils/maps";
13
13
  import { deepPlainEquals, filterUndefined, omit, pick } from "@stackframe/stack-shared/dist/utils/objects";
@@ -23,7 +23,7 @@ import { constructRedirectUrl } from "../utils/url";
23
23
  import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "./auth";
24
24
  import { createCookieHelper, createEmptyCookieHelper, deleteCookieClient, getCookieClient, setOrDeleteCookie, setOrDeleteCookieClient } from "./cookie";
25
25
  var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
26
- var clientVersion = "js @stackframe/js@2.7.14";
26
+ var clientVersion = "js @stackframe/js@2.7.16";
27
27
  function getUrls(partial) {
28
28
  const handler = partial.handler ?? "/handler";
29
29
  const home = partial.home ?? "/";
@@ -49,10 +49,10 @@ function getUrls(partial) {
49
49
  };
50
50
  }
51
51
  function getDefaultProjectId() {
52
- return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || 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."));
52
+ return getPublicEnvVar("NEXT_PUBLIC_STACK_PROJECT_ID") || 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."));
53
53
  }
54
54
  function getDefaultPublishableClientKey() {
55
- return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || 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."));
55
+ return getPublicEnvVar("NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY") || 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."));
56
56
  }
57
57
  function getDefaultSecretServerKey() {
58
58
  return process.env.STACK_SECRET_SERVER_KEY || 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."));
@@ -61,7 +61,7 @@ function getDefaultSuperSecretAdminKey() {
61
61
  return process.env.STACK_SUPER_SECRET_ADMIN_KEY || 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."));
62
62
  }
63
63
  function getDefaultBaseUrl() {
64
- const url = process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
64
+ const url = getPublicEnvVar("NEXT_PUBLIC_STACK_API_URL") || getPublicEnvVar("NEXT_PUBLIC_STACK_URL") || defaultBaseUrl;
65
65
  return url.endsWith("/") ? url.slice(0, -1) : url;
66
66
  }
67
67
  var defaultBaseUrl = "https://api.stack-auth.com";
@@ -179,7 +179,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
179
179
  this._interface = _options.interface;
180
180
  } else {
181
181
  this._interface = new StackClientInterface({
182
- baseUrl: _options.baseUrl ?? getDefaultBaseUrl(),
182
+ getBaseUrl: () => _options.baseUrl ?? getDefaultBaseUrl(),
183
183
  projectId: _options.projectId ?? getDefaultProjectId(),
184
184
  clientVersion,
185
185
  publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
@@ -680,10 +680,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
680
680
  return teams.map((crud2) => app._clientTeamFromCrud(crud2, session));
681
681
  },
682
682
  async createTeam(data) {
683
- const crud2 = await app._interface.createClientTeam({
684
- ...teamCreateOptionsToCrud(data),
685
- creator_user_id: "me"
686
- }, session);
683
+ const crud2 = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
687
684
  await app._currentUserTeamsCache.refresh([session]);
688
685
  return app._clientTeamFromCrud(crud2, session);
689
686
  },
@@ -769,7 +766,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
769
766
  _getOwnedAdminApp(forProjectId, session) {
770
767
  if (!this._ownedAdminApps.has([session, forProjectId])) {
771
768
  this._ownedAdminApps.set([session, forProjectId], new _StackAdminAppImpl({
772
- baseUrl: this._interface.options.baseUrl,
769
+ baseUrl: this._interface.options.getBaseUrl(),
773
770
  projectId: forProjectId,
774
771
  tokenStore: null,
775
772
  projectOwnerSession: session,
@@ -1234,7 +1231,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
1234
1231
  throw new StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
1235
1232
  }
1236
1233
  return {
1237
- baseUrl: this._interface.options.baseUrl,
1234
+ baseUrl: this._options.baseUrl,
1238
1235
  projectId: this.projectId,
1239
1236
  publishableClientKey: this._interface.options.publishableClientKey,
1240
1237
  tokenStore: this._tokenStoreInit,
@@ -1263,7 +1260,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1263
1260
  oauthScopesOnSignIn: options.oauthScopesOnSignIn
1264
1261
  } : {
1265
1262
  interface: new StackServerInterface({
1266
- baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
1263
+ getBaseUrl: () => options.baseUrl ?? getDefaultBaseUrl(),
1267
1264
  projectId: options.projectId ?? getDefaultProjectId(),
1268
1265
  clientVersion,
1269
1266
  publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
@@ -1449,10 +1446,10 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1449
1446
  return teams.map((t) => app._serverTeamFromCrud(t));
1450
1447
  },
1451
1448
  createTeam: async (data) => {
1452
- const team = await app._interface.createServerTeam({
1453
- ...serverTeamCreateOptionsToCrud(data),
1454
- creator_user_id: crud.id
1455
- });
1449
+ const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({
1450
+ creatorUserId: crud.id,
1451
+ ...data
1452
+ }));
1456
1453
  await app._serverTeamsCache.refresh([void 0]);
1457
1454
  return app._serverTeamFromCrud(team);
1458
1455
  },
@@ -1671,7 +1668,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
1671
1668
  constructor(options) {
1672
1669
  super({
1673
1670
  interface: new StackAdminInterface({
1674
- baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
1671
+ getBaseUrl: () => options.baseUrl ?? getDefaultBaseUrl(),
1675
1672
  projectId: options.projectId ?? getDefaultProjectId(),
1676
1673
  clientVersion,
1677
1674
  ..."projectOwnerSession" in options ? {
@@ -1969,7 +1966,10 @@ function serverUserCreateOptionsToCrud(options) {
1969
1966
  otp_auth_enabled: options.otpAuthEnabled,
1970
1967
  primary_email_auth_enabled: options.primaryEmailAuthEnabled,
1971
1968
  display_name: options.displayName,
1972
- primary_email_verified: options.primaryEmailVerified
1969
+ primary_email_verified: options.primaryEmailVerified,
1970
+ client_metadata: options.clientMetadata,
1971
+ client_read_only_metadata: options.clientReadOnlyMetadata,
1972
+ server_metadata: options.serverMetadata
1973
1973
  };
1974
1974
  }
1975
1975
  function adminProjectUpdateOptionsToCrud(options) {
@@ -2040,14 +2040,19 @@ function teamUpdateOptionsToCrud(options) {
2040
2040
  client_metadata: options.clientMetadata
2041
2041
  };
2042
2042
  }
2043
- function teamCreateOptionsToCrud(options) {
2043
+ function teamCreateOptionsToCrud(options, creatorUserId) {
2044
2044
  return {
2045
2045
  display_name: options.displayName,
2046
- profile_image_url: options.profileImageUrl
2046
+ profile_image_url: options.profileImageUrl,
2047
+ creator_user_id: creatorUserId
2047
2048
  };
2048
2049
  }
2049
2050
  function serverTeamCreateOptionsToCrud(options) {
2050
- return teamCreateOptionsToCrud(options);
2051
+ return {
2052
+ display_name: options.displayName,
2053
+ profile_image_url: options.profileImageUrl,
2054
+ creator_user_id: options.creatorUserId
2055
+ };
2051
2056
  }
2052
2057
  function serverTeamUpdateOptionsToCrud(options) {
2053
2058
  return {