@stackframe/js 2.7.8 → 2.7.16
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/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/lib/stack-app.js +34 -24
- 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/stack-app.d.mts +10 -4
- package/dist/lib/stack-app.d.ts +10 -4
- package/dist/lib/stack-app.js +33 -23
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +3 -3
|
@@ -7,7 +7,7 @@ import { InternalSession } from "@stackframe/stack-shared/dist/sessions";
|
|
|
7
7
|
import { encodeBase64 } from "@stackframe/stack-shared/dist/utils/bytes";
|
|
8
8
|
import { AsyncCache } from "@stackframe/stack-shared/dist/utils/caches";
|
|
9
9
|
import { scrambleDuringCompileTime } from "@stackframe/stack-shared/dist/utils/compile-time";
|
|
10
|
-
import { isBrowserLike } from "@stackframe/stack-shared/dist/utils/env";
|
|
10
|
+
import { getPublicEnvVar, isBrowserLike } from "@stackframe/stack-shared/dist/utils/env";
|
|
11
11
|
import { StackAssertionError, throwErr } from "@stackframe/stack-shared/dist/utils/errors";
|
|
12
12
|
import { DependenciesMap } from "@stackframe/stack-shared/dist/utils/maps";
|
|
13
13
|
import { deepPlainEquals, filterUndefined, omit, pick } from "@stackframe/stack-shared/dist/utils/objects";
|
|
@@ -23,7 +23,7 @@ import { constructRedirectUrl } from "../utils/url";
|
|
|
23
23
|
import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "./auth";
|
|
24
24
|
import { createCookieHelper, createEmptyCookieHelper, deleteCookieClient, getCookieClient, setOrDeleteCookie, setOrDeleteCookieClient } from "./cookie";
|
|
25
25
|
var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
|
|
26
|
-
var clientVersion = "js @stackframe/js@2.7.
|
|
26
|
+
var clientVersion = "js @stackframe/js@2.7.16";
|
|
27
27
|
function getUrls(partial) {
|
|
28
28
|
const handler = partial.handler ?? "/handler";
|
|
29
29
|
const home = partial.home ?? "/";
|
|
@@ -49,10 +49,10 @@ function getUrls(partial) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
function getDefaultProjectId() {
|
|
52
|
-
return
|
|
52
|
+
return getPublicEnvVar("NEXT_PUBLIC_STACK_PROJECT_ID") || 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."));
|
|
53
53
|
}
|
|
54
54
|
function getDefaultPublishableClientKey() {
|
|
55
|
-
return
|
|
55
|
+
return getPublicEnvVar("NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY") || 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."));
|
|
56
56
|
}
|
|
57
57
|
function getDefaultSecretServerKey() {
|
|
58
58
|
return process.env.STACK_SECRET_SERVER_KEY || 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."));
|
|
@@ -61,7 +61,8 @@ function getDefaultSuperSecretAdminKey() {
|
|
|
61
61
|
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
62
|
}
|
|
63
63
|
function getDefaultBaseUrl() {
|
|
64
|
-
|
|
64
|
+
const url = getPublicEnvVar("NEXT_PUBLIC_STACK_API_URL") || getPublicEnvVar("NEXT_PUBLIC_STACK_URL") || defaultBaseUrl;
|
|
65
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
65
66
|
}
|
|
66
67
|
var defaultBaseUrl = "https://api.stack-auth.com";
|
|
67
68
|
function createEmptyTokenStore() {
|
|
@@ -178,7 +179,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
178
179
|
this._interface = _options.interface;
|
|
179
180
|
} else {
|
|
180
181
|
this._interface = new StackClientInterface({
|
|
181
|
-
|
|
182
|
+
getBaseUrl: () => _options.baseUrl ?? getDefaultBaseUrl(),
|
|
182
183
|
projectId: _options.projectId ?? getDefaultProjectId(),
|
|
183
184
|
clientVersion,
|
|
184
185
|
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
|
|
@@ -679,10 +680,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
679
680
|
return teams.map((crud2) => app._clientTeamFromCrud(crud2, session));
|
|
680
681
|
},
|
|
681
682
|
async createTeam(data) {
|
|
682
|
-
const crud2 = await app._interface.createClientTeam(
|
|
683
|
-
...teamCreateOptionsToCrud(data),
|
|
684
|
-
creator_user_id: "me"
|
|
685
|
-
}, session);
|
|
683
|
+
const crud2 = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
|
|
686
684
|
await app._currentUserTeamsCache.refresh([session]);
|
|
687
685
|
return app._clientTeamFromCrud(crud2, session);
|
|
688
686
|
},
|
|
@@ -768,7 +766,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
768
766
|
_getOwnedAdminApp(forProjectId, session) {
|
|
769
767
|
if (!this._ownedAdminApps.has([session, forProjectId])) {
|
|
770
768
|
this._ownedAdminApps.set([session, forProjectId], new _StackAdminAppImpl({
|
|
771
|
-
baseUrl: this._interface.options.
|
|
769
|
+
baseUrl: this._interface.options.getBaseUrl(),
|
|
772
770
|
projectId: forProjectId,
|
|
773
771
|
tokenStore: null,
|
|
774
772
|
projectOwnerSession: session,
|
|
@@ -1133,8 +1131,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1133
1131
|
} catch (e) {
|
|
1134
1132
|
if (e instanceof KnownErrors.InvalidTotpCode) {
|
|
1135
1133
|
alert("Invalid TOTP code. Please try signing in again.");
|
|
1134
|
+
return false;
|
|
1135
|
+
} else {
|
|
1136
|
+
throw e;
|
|
1136
1137
|
}
|
|
1137
|
-
throw e;
|
|
1138
1138
|
}
|
|
1139
1139
|
if (result.status === "ok" && result.data) {
|
|
1140
1140
|
await this._signInToAccountWithTokens(result.data);
|
|
@@ -1231,7 +1231,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1231
1231
|
throw new StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
|
|
1232
1232
|
}
|
|
1233
1233
|
return {
|
|
1234
|
-
baseUrl: this.
|
|
1234
|
+
baseUrl: this._options.baseUrl,
|
|
1235
1235
|
projectId: this.projectId,
|
|
1236
1236
|
publishableClientKey: this._interface.options.publishableClientKey,
|
|
1237
1237
|
tokenStore: this._tokenStoreInit,
|
|
@@ -1260,7 +1260,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1260
1260
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
1261
1261
|
} : {
|
|
1262
1262
|
interface: new StackServerInterface({
|
|
1263
|
-
|
|
1263
|
+
getBaseUrl: () => options.baseUrl ?? getDefaultBaseUrl(),
|
|
1264
1264
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1265
1265
|
clientVersion,
|
|
1266
1266
|
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
@@ -1446,10 +1446,10 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1446
1446
|
return teams.map((t) => app._serverTeamFromCrud(t));
|
|
1447
1447
|
},
|
|
1448
1448
|
createTeam: async (data) => {
|
|
1449
|
-
const team = await app._interface.createServerTeam({
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
});
|
|
1449
|
+
const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({
|
|
1450
|
+
creatorUserId: crud.id,
|
|
1451
|
+
...data
|
|
1452
|
+
}));
|
|
1453
1453
|
await app._serverTeamsCache.refresh([void 0]);
|
|
1454
1454
|
return app._serverTeamFromCrud(team);
|
|
1455
1455
|
},
|
|
@@ -1658,7 +1658,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1658
1658
|
async _refreshUsers() {
|
|
1659
1659
|
await Promise.all([
|
|
1660
1660
|
super._refreshUsers(),
|
|
1661
|
-
this.
|
|
1661
|
+
this._serverUserCache.refreshWhere(() => true),
|
|
1662
|
+
this._serverUsersCache.refreshWhere(() => true),
|
|
1663
|
+
this._serverContactChannelsCache.refreshWhere(() => true)
|
|
1662
1664
|
]);
|
|
1663
1665
|
}
|
|
1664
1666
|
};
|
|
@@ -1666,7 +1668,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1666
1668
|
constructor(options) {
|
|
1667
1669
|
super({
|
|
1668
1670
|
interface: new StackAdminInterface({
|
|
1669
|
-
|
|
1671
|
+
getBaseUrl: () => options.baseUrl ?? getDefaultBaseUrl(),
|
|
1670
1672
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1671
1673
|
clientVersion,
|
|
1672
1674
|
..."projectOwnerSession" in options ? {
|
|
@@ -1964,7 +1966,10 @@ function serverUserCreateOptionsToCrud(options) {
|
|
|
1964
1966
|
otp_auth_enabled: options.otpAuthEnabled,
|
|
1965
1967
|
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
1966
1968
|
display_name: options.displayName,
|
|
1967
|
-
primary_email_verified: options.primaryEmailVerified
|
|
1969
|
+
primary_email_verified: options.primaryEmailVerified,
|
|
1970
|
+
client_metadata: options.clientMetadata,
|
|
1971
|
+
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
1972
|
+
server_metadata: options.serverMetadata
|
|
1968
1973
|
};
|
|
1969
1974
|
}
|
|
1970
1975
|
function adminProjectUpdateOptionsToCrud(options) {
|
|
@@ -2035,14 +2040,19 @@ function teamUpdateOptionsToCrud(options) {
|
|
|
2035
2040
|
client_metadata: options.clientMetadata
|
|
2036
2041
|
};
|
|
2037
2042
|
}
|
|
2038
|
-
function teamCreateOptionsToCrud(options) {
|
|
2043
|
+
function teamCreateOptionsToCrud(options, creatorUserId) {
|
|
2039
2044
|
return {
|
|
2040
2045
|
display_name: options.displayName,
|
|
2041
|
-
profile_image_url: options.profileImageUrl
|
|
2046
|
+
profile_image_url: options.profileImageUrl,
|
|
2047
|
+
creator_user_id: creatorUserId
|
|
2042
2048
|
};
|
|
2043
2049
|
}
|
|
2044
2050
|
function serverTeamCreateOptionsToCrud(options) {
|
|
2045
|
-
return
|
|
2051
|
+
return {
|
|
2052
|
+
display_name: options.displayName,
|
|
2053
|
+
profile_image_url: options.profileImageUrl,
|
|
2054
|
+
creator_user_id: options.creatorUserId
|
|
2055
|
+
};
|
|
2046
2056
|
}
|
|
2047
2057
|
function serverTeamUpdateOptionsToCrud(options) {
|
|
2048
2058
|
return {
|