@stackframe/js 2.7.19 → 2.7.21

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/esm/index.js.map +1 -1
  3. package/dist/esm/lib/auth.js.map +1 -1
  4. package/dist/esm/lib/cookie.js +5 -8
  5. package/dist/esm/lib/cookie.js.map +1 -1
  6. package/dist/esm/lib/stack-app.js +20 -15
  7. package/dist/esm/lib/stack-app.js.map +1 -1
  8. package/dist/esm/utils/url.js +4 -13
  9. package/dist/esm/utils/url.js.map +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/auth.js.map +1 -1
  12. package/dist/lib/cookie.d.mts +2 -2
  13. package/dist/lib/cookie.d.ts +2 -2
  14. package/dist/lib/cookie.js +6 -9
  15. package/dist/lib/cookie.js.map +1 -1
  16. package/dist/lib/stack-app.d.mts +5 -1
  17. package/dist/lib/stack-app.d.ts +5 -1
  18. package/dist/lib/stack-app.js +19 -14
  19. package/dist/lib/stack-app.js.map +1 -1
  20. package/dist/utils/url.d.mts +1 -2
  21. package/dist/utils/url.d.ts +1 -2
  22. package/dist/utils/url.js +4 -14
  23. package/dist/utils/url.js.map +1 -1
  24. package/package.json +2 -3
  25. package/dist/esm/generated/global-css.js +0 -6
  26. package/dist/esm/generated/global-css.js.map +0 -1
  27. package/dist/esm/generated/quetzal-translations.js +0 -2397
  28. package/dist/esm/generated/quetzal-translations.js.map +0 -1
  29. package/dist/esm/global.d.js +0 -1
  30. package/dist/esm/global.d.js.map +0 -1
  31. package/dist/generated/global-css.d.mts +0 -3
  32. package/dist/generated/global-css.d.ts +0 -3
  33. package/dist/generated/global-css.js +0 -31
  34. package/dist/generated/global-css.js.map +0 -1
  35. package/dist/generated/quetzal-translations.d.mts +0 -4
  36. package/dist/generated/quetzal-translations.d.ts +0 -4
  37. package/dist/generated/quetzal-translations.js +0 -2423
  38. package/dist/generated/quetzal-translations.js.map +0 -1
  39. package/dist/global.d.d.mts +0 -2
  40. package/dist/global.d.d.ts +0 -2
  41. package/dist/global.d.js +0 -2
  42. package/dist/global.d.js.map +0 -1
@@ -14,7 +14,10 @@ type RequestLike = {
14
14
  get: (name: string) => string | null;
15
15
  };
16
16
  };
17
- type RedirectMethod = "window" | "nextjs" | "none";
17
+ type RedirectMethod = "window" | "none" | {
18
+ useNavigate: () => (to: string) => void;
19
+ navigate?: (to: string) => void;
20
+ };
18
21
  type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | RequestLike | {
19
22
  accessToken: string;
20
23
  refreshToken: string;
@@ -622,6 +625,7 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
622
625
  email: string;
623
626
  password: string;
624
627
  noRedirect?: boolean;
628
+ verificationCallbackUrl?: string;
625
629
  }): Promise<Result<undefined, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
626
630
  signInWithPasskey(): Promise<Result<undefined, KnownErrors["PasskeyAuthenticationFailed"] | KnownErrors["InvalidTotpCode"] | KnownErrors["PasskeyWebAuthnError"]>>;
627
631
  callOAuthCallback(): Promise<boolean>;
@@ -14,7 +14,10 @@ type RequestLike = {
14
14
  get: (name: string) => string | null;
15
15
  };
16
16
  };
17
- type RedirectMethod = "window" | "nextjs" | "none";
17
+ type RedirectMethod = "window" | "none" | {
18
+ useNavigate: () => (to: string) => void;
19
+ navigate?: (to: string) => void;
20
+ };
18
21
  type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | RequestLike | {
19
22
  accessToken: string;
20
23
  refreshToken: string;
@@ -622,6 +625,7 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
622
625
  email: string;
623
626
  password: string;
624
627
  noRedirect?: boolean;
628
+ verificationCallbackUrl?: string;
625
629
  }): Promise<Result<undefined, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
626
630
  signInWithPasskey(): Promise<Result<undefined, KnownErrors["PasskeyAuthenticationFailed"] | KnownErrors["InvalidTotpCode"] | KnownErrors["PasskeyWebAuthnError"]>>;
627
631
  callOAuthCallback(): Promise<boolean>;
@@ -44,7 +44,6 @@ var import_production_mode = require("@stackframe/stack-shared/dist/helpers/prod
44
44
  var import_sessions = require("@stackframe/stack-shared/dist/sessions");
45
45
  var import_bytes = require("@stackframe/stack-shared/dist/utils/bytes");
46
46
  var import_caches = require("@stackframe/stack-shared/dist/utils/caches");
47
- var import_compile_time = require("@stackframe/stack-shared/dist/utils/compile-time");
48
47
  var import_env = require("@stackframe/stack-shared/dist/utils/env");
49
48
  var import_errors = require("@stackframe/stack-shared/dist/utils/errors");
50
49
  var import_maps = require("@stackframe/stack-shared/dist/utils/maps");
@@ -56,13 +55,11 @@ var import_strings = require("@stackframe/stack-shared/dist/utils/strings");
56
55
  var import_urls = require("@stackframe/stack-shared/dist/utils/urls");
57
56
  var import_uuids = require("@stackframe/stack-shared/dist/utils/uuids");
58
57
  var cookie = __toESM(require("cookie"));
59
- var NextNavigationUnscrambled = __toESM(require("next/navigation"));
60
58
  var import_url = require("../utils/url");
61
59
  var import_auth = require("./auth");
62
60
  var import_cookie = require("./cookie");
63
61
  var isReactServer = false;
64
- var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
65
- var clientVersion = "js @stackframe/js@2.7.19";
62
+ var clientVersion = "js @stackframe/js@2.7.21";
66
63
  if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
67
64
  throw new import_errors.StackAssertionError("Client version was not replaced. Something went wrong during build!");
68
65
  }
@@ -225,6 +222,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
225
222
  }
226
223
  );
227
224
  this._memoryTokenStore = createEmptyTokenStore();
225
+ this._nextServerCookiesTokenStores = /* @__PURE__ */ new WeakMap();
228
226
  this._requestTokenStores = /* @__PURE__ */ new WeakMap();
229
227
  this._storedBrowserCookieTokenStore = null;
230
228
  /**
@@ -243,7 +241,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
243
241
  getBaseUrl: () => getBaseUrl(_options.baseUrl),
244
242
  projectId: _options.projectId ?? getDefaultProjectId(),
245
243
  clientVersion,
246
- publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
244
+ publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey(),
245
+ prepareRequest: async () => {
246
+ }
247
247
  });
248
248
  }
249
249
  this._tokenStoreInit = _options.tokenStore;
@@ -265,7 +265,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
265
265
  if (this._tokenStoreInit === "nextjs-cookie" || this._tokenStoreInit === "cookie") {
266
266
  return await (0, import_cookie.createCookieHelper)();
267
267
  } else {
268
- return await (0, import_cookie.createEmptyCookieHelper)();
268
+ return await (0, import_cookie.createPlaceholderCookieHelper)();
269
269
  }
270
270
  }
271
271
  async _getUserOAuthConnectionCacheFn(options) {
@@ -854,17 +854,16 @@ var _StackClientAppImpl = class __StackClientAppImpl {
854
854
  async _redirectTo(options) {
855
855
  if (this._redirectMethod === "none") {
856
856
  return;
857
- }
858
- if (isReactServer && this._redirectMethod === "nextjs") {
859
- NextNavigation.redirect(options.url.toString(), options.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
857
+ } else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) {
858
+ this._redirectMethod.navigate(options.url.toString());
860
859
  } else {
861
860
  if (options.replace) {
862
861
  window.location.replace(options.url);
863
862
  } else {
864
863
  window.location.assign(options.url);
865
864
  }
866
- await (0, import_promises.wait)(2e3);
867
865
  }
866
+ await (0, import_promises.wait)(2e3);
868
867
  }
869
868
  async _redirectIfTrusted(url, options) {
870
869
  if (!await this._isTrusted(url)) {
@@ -1104,7 +1103,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
1104
1103
  async signUpWithCredential(options) {
1105
1104
  this._ensurePersistentTokenStore();
1106
1105
  const session = await this._getSession();
1107
- const emailVerificationRedirectUrl = (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
1106
+ const emailVerificationRedirectUrl = options.verificationCallbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
1108
1107
  const result = await this._interface.signUpWithCredential(
1109
1108
  options.email,
1110
1109
  options.password,
@@ -1291,6 +1290,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
1291
1290
  if (!("publishableClientKey" in this._interface.options)) {
1292
1291
  throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
1293
1292
  }
1293
+ if (typeof this._redirectMethod !== "string") {
1294
+ throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application with a non-string redirect method");
1295
+ }
1294
1296
  return {
1295
1297
  baseUrl: this._options.baseUrl,
1296
1298
  projectId: this.projectId,
@@ -1298,7 +1300,8 @@ var _StackClientAppImpl = class __StackClientAppImpl {
1298
1300
  tokenStore: this._tokenStoreInit,
1299
1301
  urls: this._urlOptions,
1300
1302
  oauthScopesOnSignIn: this._oauthScopesOnSignIn,
1301
- uniqueIdentifier: this._getUniqueIdentifier()
1303
+ uniqueIdentifier: this._getUniqueIdentifier(),
1304
+ redirectMethod: this._redirectMethod
1302
1305
  };
1303
1306
  },
1304
1307
  setCurrentUser: (userJsonPromise) => {
@@ -1332,7 +1335,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1332
1335
  publishableClientKey: options.publishableClientKey,
1333
1336
  tokenStore: options.tokenStore,
1334
1337
  urls: options.urls ?? {},
1335
- oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {}
1338
+ oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {},
1339
+ redirectMethod: options.redirectMethod
1336
1340
  });
1337
1341
  // TODO override the client user cache to use the server user cache, so we save some requests
1338
1342
  this._currentServerUserCache = createCacheBySession(async (session) => {
@@ -1747,7 +1751,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
1747
1751
  projectId: options.projectId,
1748
1752
  tokenStore: options.tokenStore,
1749
1753
  urls: options.urls,
1750
- oauthScopesOnSignIn: options.oauthScopesOnSignIn
1754
+ oauthScopesOnSignIn: options.oauthScopesOnSignIn,
1755
+ redirectMethod: options.redirectMethod
1751
1756
  });
1752
1757
  this._adminProjectCache = createCache(async () => {
1753
1758
  return await this._interface.getProject();