@stackframe/js 2.7.16 → 2.7.17
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/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/esm/lib/cookie.js +1 -59
- package/dist/esm/lib/cookie.js.map +1 -1
- package/dist/esm/lib/stack-app.js +37 -10
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/lib/auth.d.mts +1 -1
- package/dist/lib/auth.d.ts +1 -1
- package/dist/lib/cookie.js +1 -59
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/stack-app.d.mts +4 -1
- package/dist/lib/stack-app.d.ts +4 -1
- package/dist/lib/stack-app.js +39 -12
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +2 -3
package/dist/lib/stack-app.js
CHANGED
|
@@ -39,7 +39,6 @@ __export(stack_app_exports, {
|
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(stack_app_exports);
|
|
41
41
|
var import_browser = require("@simplewebauthn/browser");
|
|
42
|
-
var import_stack_sc = require("@stackframe/stack-sc");
|
|
43
42
|
var import_stack_shared = require("@stackframe/stack-shared");
|
|
44
43
|
var import_production_mode = require("@stackframe/stack-shared/dist/helpers/production-mode");
|
|
45
44
|
var import_sessions = require("@stackframe/stack-shared/dist/sessions");
|
|
@@ -61,8 +60,13 @@ var NextNavigationUnscrambled = __toESM(require("next/navigation"));
|
|
|
61
60
|
var import_url = require("../utils/url");
|
|
62
61
|
var import_auth = require("./auth");
|
|
63
62
|
var import_cookie = require("./cookie");
|
|
63
|
+
var isReactServer = false;
|
|
64
64
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
65
|
-
var clientVersion = "js @stackframe/js@2.7.
|
|
65
|
+
var clientVersion = "js @stackframe/js@2.7.17";
|
|
66
|
+
if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
|
|
67
|
+
throw new import_errors.StackAssertionError("Client version was not replaced. Something went wrong during build!");
|
|
68
|
+
}
|
|
69
|
+
var process = globalThis.process ?? { env: {} };
|
|
66
70
|
function getUrls(partial) {
|
|
67
71
|
const handler = partial.handler ?? "/handler";
|
|
68
72
|
const home = partial.home ?? "/";
|
|
@@ -88,10 +92,10 @@ function getUrls(partial) {
|
|
|
88
92
|
};
|
|
89
93
|
}
|
|
90
94
|
function getDefaultProjectId() {
|
|
91
|
-
return
|
|
95
|
+
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."));
|
|
92
96
|
}
|
|
93
97
|
function getDefaultPublishableClientKey() {
|
|
94
|
-
return
|
|
98
|
+
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."));
|
|
95
99
|
}
|
|
96
100
|
function getDefaultSecretServerKey() {
|
|
97
101
|
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."));
|
|
@@ -99,8 +103,26 @@ function getDefaultSecretServerKey() {
|
|
|
99
103
|
function getDefaultSuperSecretAdminKey() {
|
|
100
104
|
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
105
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
106
|
+
function getBaseUrl(userSpecifiedBaseUrl) {
|
|
107
|
+
let url;
|
|
108
|
+
if (userSpecifiedBaseUrl) {
|
|
109
|
+
if (typeof userSpecifiedBaseUrl === "string") {
|
|
110
|
+
url = userSpecifiedBaseUrl;
|
|
111
|
+
} else {
|
|
112
|
+
if ((0, import_env.isBrowserLike)()) {
|
|
113
|
+
url = userSpecifiedBaseUrl.browser;
|
|
114
|
+
} else {
|
|
115
|
+
url = userSpecifiedBaseUrl.server;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
if ((0, import_env.isBrowserLike)()) {
|
|
120
|
+
url = process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL;
|
|
121
|
+
} else {
|
|
122
|
+
url = process.env.NEXT_PUBLIC_SERVER_STACK_API_URL;
|
|
123
|
+
}
|
|
124
|
+
url = url || process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
|
|
125
|
+
}
|
|
104
126
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
105
127
|
}
|
|
106
128
|
var defaultBaseUrl = "https://api.stack-auth.com";
|
|
@@ -218,7 +240,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
218
240
|
this._interface = _options.interface;
|
|
219
241
|
} else {
|
|
220
242
|
this._interface = new import_stack_shared.StackClientInterface({
|
|
221
|
-
getBaseUrl: () => _options.baseUrl
|
|
243
|
+
getBaseUrl: () => getBaseUrl(_options.baseUrl),
|
|
222
244
|
projectId: _options.projectId ?? getDefaultProjectId(),
|
|
223
245
|
clientVersion,
|
|
224
246
|
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
|
|
@@ -833,7 +855,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
833
855
|
if (this._redirectMethod === "none") {
|
|
834
856
|
return;
|
|
835
857
|
}
|
|
836
|
-
if (
|
|
858
|
+
if (isReactServer && this._redirectMethod === "nextjs") {
|
|
837
859
|
NextNavigation.redirect(options.url.toString(), options.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
|
|
838
860
|
} else {
|
|
839
861
|
if (options.replace) {
|
|
@@ -857,7 +879,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
857
879
|
}
|
|
858
880
|
if (!options?.noRedirectBack) {
|
|
859
881
|
if (handlerName === "afterSignIn" || handlerName === "afterSignUp") {
|
|
860
|
-
if (
|
|
882
|
+
if (isReactServer || typeof window === "undefined") {
|
|
861
883
|
try {
|
|
862
884
|
await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
|
|
863
885
|
} catch (e) {
|
|
@@ -867,7 +889,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
867
889
|
url = queryParams.get("after_auth_return_to") || url;
|
|
868
890
|
}
|
|
869
891
|
} else if (handlerName === "signIn" || handlerName === "signUp") {
|
|
870
|
-
if (
|
|
892
|
+
if (isReactServer || typeof window === "undefined") {
|
|
871
893
|
try {
|
|
872
894
|
await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
|
|
873
895
|
} catch (e) {
|
|
@@ -1299,12 +1321,15 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1299
1321
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
1300
1322
|
} : {
|
|
1301
1323
|
interface: new import_stack_shared.StackServerInterface({
|
|
1302
|
-
getBaseUrl: () => options.baseUrl
|
|
1324
|
+
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1303
1325
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1304
1326
|
clientVersion,
|
|
1305
1327
|
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
1306
1328
|
secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey()
|
|
1307
1329
|
}),
|
|
1330
|
+
baseUrl: options.baseUrl,
|
|
1331
|
+
projectId: options.projectId,
|
|
1332
|
+
publishableClientKey: options.publishableClientKey,
|
|
1308
1333
|
tokenStore: options.tokenStore,
|
|
1309
1334
|
urls: options.urls ?? {},
|
|
1310
1335
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {}
|
|
@@ -1707,7 +1732,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1707
1732
|
constructor(options) {
|
|
1708
1733
|
super({
|
|
1709
1734
|
interface: new import_stack_shared.StackAdminInterface({
|
|
1710
|
-
getBaseUrl: () => options.baseUrl
|
|
1735
|
+
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1711
1736
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1712
1737
|
clientVersion,
|
|
1713
1738
|
..."projectOwnerSession" in options ? {
|
|
@@ -1718,6 +1743,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1718
1743
|
superSecretAdminKey: options.superSecretAdminKey ?? getDefaultSuperSecretAdminKey()
|
|
1719
1744
|
}
|
|
1720
1745
|
}),
|
|
1746
|
+
baseUrl: options.baseUrl,
|
|
1747
|
+
projectId: options.projectId,
|
|
1721
1748
|
tokenStore: options.tokenStore,
|
|
1722
1749
|
urls: options.urls,
|
|
1723
1750
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|