@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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/lib/stack-app.ts
|
|
2
2
|
import { WebAuthnError, startAuthentication, startRegistration } from "@simplewebauthn/browser";
|
|
3
|
-
import { isReactServer } from "@stackframe/stack-sc";
|
|
4
3
|
import { KnownErrors, StackAdminInterface, StackClientInterface, StackServerInterface } from "@stackframe/stack-shared";
|
|
5
4
|
import { getProductionModeErrors } from "@stackframe/stack-shared/dist/helpers/production-mode";
|
|
6
5
|
import { InternalSession } from "@stackframe/stack-shared/dist/sessions";
|
|
@@ -22,8 +21,13 @@ import * as NextNavigationUnscrambled from "next/navigation";
|
|
|
22
21
|
import { constructRedirectUrl } from "../utils/url";
|
|
23
22
|
import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "./auth";
|
|
24
23
|
import { createCookieHelper, createEmptyCookieHelper, deleteCookieClient, getCookieClient, setOrDeleteCookie, setOrDeleteCookieClient } from "./cookie";
|
|
24
|
+
var isReactServer = false;
|
|
25
25
|
var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
|
|
26
|
-
var clientVersion = "js @stackframe/js@2.7.
|
|
26
|
+
var clientVersion = "js @stackframe/js@2.7.17";
|
|
27
|
+
if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
|
|
28
|
+
throw new StackAssertionError("Client version was not replaced. Something went wrong during build!");
|
|
29
|
+
}
|
|
30
|
+
var process = globalThis.process ?? { env: {} };
|
|
27
31
|
function getUrls(partial) {
|
|
28
32
|
const handler = partial.handler ?? "/handler";
|
|
29
33
|
const home = partial.home ?? "/";
|
|
@@ -60,8 +64,26 @@ function getDefaultSecretServerKey() {
|
|
|
60
64
|
function getDefaultSuperSecretAdminKey() {
|
|
61
65
|
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
66
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
67
|
+
function getBaseUrl(userSpecifiedBaseUrl) {
|
|
68
|
+
let url;
|
|
69
|
+
if (userSpecifiedBaseUrl) {
|
|
70
|
+
if (typeof userSpecifiedBaseUrl === "string") {
|
|
71
|
+
url = userSpecifiedBaseUrl;
|
|
72
|
+
} else {
|
|
73
|
+
if (isBrowserLike()) {
|
|
74
|
+
url = userSpecifiedBaseUrl.browser;
|
|
75
|
+
} else {
|
|
76
|
+
url = userSpecifiedBaseUrl.server;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
if (isBrowserLike()) {
|
|
81
|
+
url = process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL;
|
|
82
|
+
} else {
|
|
83
|
+
url = process.env.NEXT_PUBLIC_SERVER_STACK_API_URL;
|
|
84
|
+
}
|
|
85
|
+
url = url || process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
|
|
86
|
+
}
|
|
65
87
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
66
88
|
}
|
|
67
89
|
var defaultBaseUrl = "https://api.stack-auth.com";
|
|
@@ -179,7 +201,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
179
201
|
this._interface = _options.interface;
|
|
180
202
|
} else {
|
|
181
203
|
this._interface = new StackClientInterface({
|
|
182
|
-
|
|
204
|
+
getBaseUrl: () => getBaseUrl(_options.baseUrl),
|
|
183
205
|
projectId: _options.projectId ?? getDefaultProjectId(),
|
|
184
206
|
clientVersion,
|
|
185
207
|
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
|
|
@@ -680,10 +702,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
680
702
|
return teams.map((crud2) => app._clientTeamFromCrud(crud2, session));
|
|
681
703
|
},
|
|
682
704
|
async createTeam(data) {
|
|
683
|
-
const crud2 = await app._interface.createClientTeam(
|
|
684
|
-
...teamCreateOptionsToCrud(data),
|
|
685
|
-
creator_user_id: "me"
|
|
686
|
-
}, session);
|
|
705
|
+
const crud2 = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
|
|
687
706
|
await app._currentUserTeamsCache.refresh([session]);
|
|
688
707
|
return app._clientTeamFromCrud(crud2, session);
|
|
689
708
|
},
|
|
@@ -769,7 +788,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
769
788
|
_getOwnedAdminApp(forProjectId, session) {
|
|
770
789
|
if (!this._ownedAdminApps.has([session, forProjectId])) {
|
|
771
790
|
this._ownedAdminApps.set([session, forProjectId], new _StackAdminAppImpl({
|
|
772
|
-
baseUrl: this._interface.options.
|
|
791
|
+
baseUrl: this._interface.options.getBaseUrl(),
|
|
773
792
|
projectId: forProjectId,
|
|
774
793
|
tokenStore: null,
|
|
775
794
|
projectOwnerSession: session,
|
|
@@ -1234,7 +1253,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1234
1253
|
throw new StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
|
|
1235
1254
|
}
|
|
1236
1255
|
return {
|
|
1237
|
-
baseUrl: this.
|
|
1256
|
+
baseUrl: this._options.baseUrl,
|
|
1238
1257
|
projectId: this.projectId,
|
|
1239
1258
|
publishableClientKey: this._interface.options.publishableClientKey,
|
|
1240
1259
|
tokenStore: this._tokenStoreInit,
|
|
@@ -1263,12 +1282,15 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1263
1282
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
1264
1283
|
} : {
|
|
1265
1284
|
interface: new StackServerInterface({
|
|
1266
|
-
|
|
1285
|
+
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1267
1286
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1268
1287
|
clientVersion,
|
|
1269
1288
|
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
1270
1289
|
secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey()
|
|
1271
1290
|
}),
|
|
1291
|
+
baseUrl: options.baseUrl,
|
|
1292
|
+
projectId: options.projectId,
|
|
1293
|
+
publishableClientKey: options.publishableClientKey,
|
|
1272
1294
|
tokenStore: options.tokenStore,
|
|
1273
1295
|
urls: options.urls ?? {},
|
|
1274
1296
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {}
|
|
@@ -1449,10 +1471,10 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1449
1471
|
return teams.map((t) => app._serverTeamFromCrud(t));
|
|
1450
1472
|
},
|
|
1451
1473
|
createTeam: async (data) => {
|
|
1452
|
-
const team = await app._interface.createServerTeam({
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
});
|
|
1474
|
+
const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({
|
|
1475
|
+
creatorUserId: crud.id,
|
|
1476
|
+
...data
|
|
1477
|
+
}));
|
|
1456
1478
|
await app._serverTeamsCache.refresh([void 0]);
|
|
1457
1479
|
return app._serverTeamFromCrud(team);
|
|
1458
1480
|
},
|
|
@@ -1671,7 +1693,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1671
1693
|
constructor(options) {
|
|
1672
1694
|
super({
|
|
1673
1695
|
interface: new StackAdminInterface({
|
|
1674
|
-
|
|
1696
|
+
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1675
1697
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1676
1698
|
clientVersion,
|
|
1677
1699
|
..."projectOwnerSession" in options ? {
|
|
@@ -1682,6 +1704,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1682
1704
|
superSecretAdminKey: options.superSecretAdminKey ?? getDefaultSuperSecretAdminKey()
|
|
1683
1705
|
}
|
|
1684
1706
|
}),
|
|
1707
|
+
baseUrl: options.baseUrl,
|
|
1708
|
+
projectId: options.projectId,
|
|
1685
1709
|
tokenStore: options.tokenStore,
|
|
1686
1710
|
urls: options.urls,
|
|
1687
1711
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
@@ -1969,7 +1993,10 @@ function serverUserCreateOptionsToCrud(options) {
|
|
|
1969
1993
|
otp_auth_enabled: options.otpAuthEnabled,
|
|
1970
1994
|
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
1971
1995
|
display_name: options.displayName,
|
|
1972
|
-
primary_email_verified: options.primaryEmailVerified
|
|
1996
|
+
primary_email_verified: options.primaryEmailVerified,
|
|
1997
|
+
client_metadata: options.clientMetadata,
|
|
1998
|
+
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
1999
|
+
server_metadata: options.serverMetadata
|
|
1973
2000
|
};
|
|
1974
2001
|
}
|
|
1975
2002
|
function adminProjectUpdateOptionsToCrud(options) {
|
|
@@ -2040,14 +2067,19 @@ function teamUpdateOptionsToCrud(options) {
|
|
|
2040
2067
|
client_metadata: options.clientMetadata
|
|
2041
2068
|
};
|
|
2042
2069
|
}
|
|
2043
|
-
function teamCreateOptionsToCrud(options) {
|
|
2070
|
+
function teamCreateOptionsToCrud(options, creatorUserId) {
|
|
2044
2071
|
return {
|
|
2045
2072
|
display_name: options.displayName,
|
|
2046
|
-
profile_image_url: options.profileImageUrl
|
|
2073
|
+
profile_image_url: options.profileImageUrl,
|
|
2074
|
+
creator_user_id: creatorUserId
|
|
2047
2075
|
};
|
|
2048
2076
|
}
|
|
2049
2077
|
function serverTeamCreateOptionsToCrud(options) {
|
|
2050
|
-
return
|
|
2078
|
+
return {
|
|
2079
|
+
display_name: options.displayName,
|
|
2080
|
+
profile_image_url: options.profileImageUrl,
|
|
2081
|
+
creator_user_id: options.creatorUserId
|
|
2082
|
+
};
|
|
2051
2083
|
}
|
|
2052
2084
|
function serverTeamUpdateOptionsToCrud(options) {
|
|
2053
2085
|
return {
|