@stackframe/js 2.7.14 → 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 +29 -0
- package/README.md +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +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 +53 -21
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/generated/global-css.d.mts +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.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 +11 -2
- package/dist/lib/stack-app.d.ts +11 -2
- package/dist/lib/stack-app.js +56 -24
- 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 ?? "/";
|
|
@@ -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
|
-
|
|
243
|
+
getBaseUrl: () => getBaseUrl(_options.baseUrl),
|
|
222
244
|
projectId: _options.projectId ?? getDefaultProjectId(),
|
|
223
245
|
clientVersion,
|
|
224
246
|
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
|
|
@@ -719,10 +741,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
719
741
|
return teams.map((crud2) => app._clientTeamFromCrud(crud2, session));
|
|
720
742
|
},
|
|
721
743
|
async createTeam(data) {
|
|
722
|
-
const crud2 = await app._interface.createClientTeam(
|
|
723
|
-
...teamCreateOptionsToCrud(data),
|
|
724
|
-
creator_user_id: "me"
|
|
725
|
-
}, session);
|
|
744
|
+
const crud2 = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
|
|
726
745
|
await app._currentUserTeamsCache.refresh([session]);
|
|
727
746
|
return app._clientTeamFromCrud(crud2, session);
|
|
728
747
|
},
|
|
@@ -808,7 +827,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
808
827
|
_getOwnedAdminApp(forProjectId, session) {
|
|
809
828
|
if (!this._ownedAdminApps.has([session, forProjectId])) {
|
|
810
829
|
this._ownedAdminApps.set([session, forProjectId], new _StackAdminAppImpl({
|
|
811
|
-
baseUrl: this._interface.options.
|
|
830
|
+
baseUrl: this._interface.options.getBaseUrl(),
|
|
812
831
|
projectId: forProjectId,
|
|
813
832
|
tokenStore: null,
|
|
814
833
|
projectOwnerSession: session,
|
|
@@ -836,7 +855,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
836
855
|
if (this._redirectMethod === "none") {
|
|
837
856
|
return;
|
|
838
857
|
}
|
|
839
|
-
if (
|
|
858
|
+
if (isReactServer && this._redirectMethod === "nextjs") {
|
|
840
859
|
NextNavigation.redirect(options.url.toString(), options.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
|
|
841
860
|
} else {
|
|
842
861
|
if (options.replace) {
|
|
@@ -860,7 +879,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
860
879
|
}
|
|
861
880
|
if (!options?.noRedirectBack) {
|
|
862
881
|
if (handlerName === "afterSignIn" || handlerName === "afterSignUp") {
|
|
863
|
-
if (
|
|
882
|
+
if (isReactServer || typeof window === "undefined") {
|
|
864
883
|
try {
|
|
865
884
|
await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
|
|
866
885
|
} catch (e) {
|
|
@@ -870,7 +889,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
870
889
|
url = queryParams.get("after_auth_return_to") || url;
|
|
871
890
|
}
|
|
872
891
|
} else if (handlerName === "signIn" || handlerName === "signUp") {
|
|
873
|
-
if (
|
|
892
|
+
if (isReactServer || typeof window === "undefined") {
|
|
874
893
|
try {
|
|
875
894
|
await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
|
|
876
895
|
} catch (e) {
|
|
@@ -1273,7 +1292,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1273
1292
|
throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
|
|
1274
1293
|
}
|
|
1275
1294
|
return {
|
|
1276
|
-
baseUrl: this.
|
|
1295
|
+
baseUrl: this._options.baseUrl,
|
|
1277
1296
|
projectId: this.projectId,
|
|
1278
1297
|
publishableClientKey: this._interface.options.publishableClientKey,
|
|
1279
1298
|
tokenStore: this._tokenStoreInit,
|
|
@@ -1302,12 +1321,15 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1302
1321
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
1303
1322
|
} : {
|
|
1304
1323
|
interface: new import_stack_shared.StackServerInterface({
|
|
1305
|
-
|
|
1324
|
+
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1306
1325
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1307
1326
|
clientVersion,
|
|
1308
1327
|
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
1309
1328
|
secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey()
|
|
1310
1329
|
}),
|
|
1330
|
+
baseUrl: options.baseUrl,
|
|
1331
|
+
projectId: options.projectId,
|
|
1332
|
+
publishableClientKey: options.publishableClientKey,
|
|
1311
1333
|
tokenStore: options.tokenStore,
|
|
1312
1334
|
urls: options.urls ?? {},
|
|
1313
1335
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {}
|
|
@@ -1488,10 +1510,10 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1488
1510
|
return teams.map((t) => app._serverTeamFromCrud(t));
|
|
1489
1511
|
},
|
|
1490
1512
|
createTeam: async (data) => {
|
|
1491
|
-
const team = await app._interface.createServerTeam({
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
});
|
|
1513
|
+
const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({
|
|
1514
|
+
creatorUserId: crud.id,
|
|
1515
|
+
...data
|
|
1516
|
+
}));
|
|
1495
1517
|
await app._serverTeamsCache.refresh([void 0]);
|
|
1496
1518
|
return app._serverTeamFromCrud(team);
|
|
1497
1519
|
},
|
|
@@ -1710,7 +1732,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1710
1732
|
constructor(options) {
|
|
1711
1733
|
super({
|
|
1712
1734
|
interface: new import_stack_shared.StackAdminInterface({
|
|
1713
|
-
|
|
1735
|
+
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1714
1736
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1715
1737
|
clientVersion,
|
|
1716
1738
|
..."projectOwnerSession" in options ? {
|
|
@@ -1721,6 +1743,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1721
1743
|
superSecretAdminKey: options.superSecretAdminKey ?? getDefaultSuperSecretAdminKey()
|
|
1722
1744
|
}
|
|
1723
1745
|
}),
|
|
1746
|
+
baseUrl: options.baseUrl,
|
|
1747
|
+
projectId: options.projectId,
|
|
1724
1748
|
tokenStore: options.tokenStore,
|
|
1725
1749
|
urls: options.urls,
|
|
1726
1750
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
@@ -2008,7 +2032,10 @@ function serverUserCreateOptionsToCrud(options) {
|
|
|
2008
2032
|
otp_auth_enabled: options.otpAuthEnabled,
|
|
2009
2033
|
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
2010
2034
|
display_name: options.displayName,
|
|
2011
|
-
primary_email_verified: options.primaryEmailVerified
|
|
2035
|
+
primary_email_verified: options.primaryEmailVerified,
|
|
2036
|
+
client_metadata: options.clientMetadata,
|
|
2037
|
+
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
2038
|
+
server_metadata: options.serverMetadata
|
|
2012
2039
|
};
|
|
2013
2040
|
}
|
|
2014
2041
|
function adminProjectUpdateOptionsToCrud(options) {
|
|
@@ -2079,14 +2106,19 @@ function teamUpdateOptionsToCrud(options) {
|
|
|
2079
2106
|
client_metadata: options.clientMetadata
|
|
2080
2107
|
};
|
|
2081
2108
|
}
|
|
2082
|
-
function teamCreateOptionsToCrud(options) {
|
|
2109
|
+
function teamCreateOptionsToCrud(options, creatorUserId) {
|
|
2083
2110
|
return {
|
|
2084
2111
|
display_name: options.displayName,
|
|
2085
|
-
profile_image_url: options.profileImageUrl
|
|
2112
|
+
profile_image_url: options.profileImageUrl,
|
|
2113
|
+
creator_user_id: creatorUserId
|
|
2086
2114
|
};
|
|
2087
2115
|
}
|
|
2088
2116
|
function serverTeamCreateOptionsToCrud(options) {
|
|
2089
|
-
return
|
|
2117
|
+
return {
|
|
2118
|
+
display_name: options.displayName,
|
|
2119
|
+
profile_image_url: options.profileImageUrl,
|
|
2120
|
+
creator_user_id: options.creatorUserId
|
|
2121
|
+
};
|
|
2090
2122
|
}
|
|
2091
2123
|
function serverTeamUpdateOptionsToCrud(options) {
|
|
2092
2124
|
return {
|