@stackframe/js 2.7.19 → 2.7.20

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.
@@ -5,7 +5,6 @@ import { getProductionModeErrors } from "@stackframe/stack-shared/dist/helpers/p
5
5
  import { InternalSession } from "@stackframe/stack-shared/dist/sessions";
6
6
  import { encodeBase64 } from "@stackframe/stack-shared/dist/utils/bytes";
7
7
  import { AsyncCache } from "@stackframe/stack-shared/dist/utils/caches";
8
- import { scrambleDuringCompileTime } from "@stackframe/stack-shared/dist/utils/compile-time";
9
8
  import { isBrowserLike } from "@stackframe/stack-shared/dist/utils/env";
10
9
  import { StackAssertionError, throwErr } from "@stackframe/stack-shared/dist/utils/errors";
11
10
  import { DependenciesMap } from "@stackframe/stack-shared/dist/utils/maps";
@@ -17,13 +16,11 @@ import { mergeScopeStrings } from "@stackframe/stack-shared/dist/utils/strings";
17
16
  import { getRelativePart, isRelative } from "@stackframe/stack-shared/dist/utils/urls";
18
17
  import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids";
19
18
  import * as cookie from "cookie";
20
- import * as NextNavigationUnscrambled from "next/navigation";
21
19
  import { constructRedirectUrl } from "../utils/url";
22
20
  import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "./auth";
23
21
  import { createCookieHelper, createEmptyCookieHelper, deleteCookieClient, getCookieClient, setOrDeleteCookie, setOrDeleteCookieClient } from "./cookie";
24
22
  var isReactServer = false;
25
- var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
26
- var clientVersion = "js @stackframe/js@2.7.19";
23
+ var clientVersion = "js @stackframe/js@2.7.20";
27
24
  if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
28
25
  throw new StackAssertionError("Client version was not replaced. Something went wrong during build!");
29
26
  }
@@ -204,7 +201,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
204
201
  getBaseUrl: () => getBaseUrl(_options.baseUrl),
205
202
  projectId: _options.projectId ?? getDefaultProjectId(),
206
203
  clientVersion,
207
- publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
204
+ publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey(),
205
+ prepareRequest: async () => {
206
+ }
208
207
  });
209
208
  }
210
209
  this._tokenStoreInit = _options.tokenStore;
@@ -815,17 +814,16 @@ var _StackClientAppImpl = class __StackClientAppImpl {
815
814
  async _redirectTo(options) {
816
815
  if (this._redirectMethod === "none") {
817
816
  return;
818
- }
819
- if (isReactServer && this._redirectMethod === "nextjs") {
820
- NextNavigation.redirect(options.url.toString(), options.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
817
+ } else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) {
818
+ this._redirectMethod.navigate(options.url.toString());
821
819
  } else {
822
820
  if (options.replace) {
823
821
  window.location.replace(options.url);
824
822
  } else {
825
823
  window.location.assign(options.url);
826
824
  }
827
- await wait(2e3);
828
825
  }
826
+ await wait(2e3);
829
827
  }
830
828
  async _redirectIfTrusted(url, options) {
831
829
  if (!await this._isTrusted(url)) {
@@ -1252,6 +1250,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
1252
1250
  if (!("publishableClientKey" in this._interface.options)) {
1253
1251
  throw new StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
1254
1252
  }
1253
+ if (typeof this._redirectMethod !== "string") {
1254
+ throw new StackAssertionError("Cannot serialize to JSON from an application with a non-string redirect method");
1255
+ }
1255
1256
  return {
1256
1257
  baseUrl: this._options.baseUrl,
1257
1258
  projectId: this.projectId,
@@ -1259,7 +1260,8 @@ var _StackClientAppImpl = class __StackClientAppImpl {
1259
1260
  tokenStore: this._tokenStoreInit,
1260
1261
  urls: this._urlOptions,
1261
1262
  oauthScopesOnSignIn: this._oauthScopesOnSignIn,
1262
- uniqueIdentifier: this._getUniqueIdentifier()
1263
+ uniqueIdentifier: this._getUniqueIdentifier(),
1264
+ redirectMethod: this._redirectMethod
1263
1265
  };
1264
1266
  },
1265
1267
  setCurrentUser: (userJsonPromise) => {
@@ -1293,7 +1295,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1293
1295
  publishableClientKey: options.publishableClientKey,
1294
1296
  tokenStore: options.tokenStore,
1295
1297
  urls: options.urls ?? {},
1296
- oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {}
1298
+ oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {},
1299
+ redirectMethod: options.redirectMethod
1297
1300
  });
1298
1301
  // TODO override the client user cache to use the server user cache, so we save some requests
1299
1302
  this._currentServerUserCache = createCacheBySession(async (session) => {
@@ -1708,7 +1711,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
1708
1711
  projectId: options.projectId,
1709
1712
  tokenStore: options.tokenStore,
1710
1713
  urls: options.urls,
1711
- oauthScopesOnSignIn: options.oauthScopesOnSignIn
1714
+ oauthScopesOnSignIn: options.oauthScopesOnSignIn,
1715
+ redirectMethod: options.redirectMethod
1712
1716
  });
1713
1717
  this._adminProjectCache = createCache(async () => {
1714
1718
  return await this._interface.getProject();