@stackframe/stack 2.6.33 → 2.6.36
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 +30 -0
- package/README.md +1 -1
- package/dist/components-page/stack-handler.js +13 -3
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +13 -3
- package/dist/esm/components-page/stack-handler.js.map +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/stack-app.js +44 -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 +9 -3
- package/dist/lib/stack-app.d.ts +9 -3
- package/dist/lib/stack-app.js +44 -24
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +4 -4
|
@@ -25,7 +25,7 @@ import { constructRedirectUrl } from "../utils/url";
|
|
|
25
25
|
import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "./auth";
|
|
26
26
|
import { createBrowserCookieHelper, createCookieHelper, deleteCookieClient, getCookieClient, setOrDeleteCookie, setOrDeleteCookieClient } from "./cookie";
|
|
27
27
|
var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
|
|
28
|
-
var clientVersion = "js @stackframe/stack@2.6.
|
|
28
|
+
var clientVersion = "js @stackframe/stack@2.6.36";
|
|
29
29
|
function getUrls(partial) {
|
|
30
30
|
const handler = partial.handler ?? "/handler";
|
|
31
31
|
const home = partial.home ?? "/";
|
|
@@ -109,14 +109,15 @@ function useAsyncCache(cache, dependencies, caller) {
|
|
|
109
109
|
const result = React.use(promise);
|
|
110
110
|
if (result.status === "error") {
|
|
111
111
|
const error = result.error;
|
|
112
|
-
if (error instanceof Error) {
|
|
112
|
+
if (error instanceof Error && !error.__stackHasConcatenatedStacktraces) {
|
|
113
113
|
concatStacktraces(error, new Error());
|
|
114
|
+
error.__stackHasConcatenatedStacktraces = true;
|
|
114
115
|
}
|
|
115
116
|
throw error;
|
|
116
117
|
}
|
|
117
118
|
return result.data;
|
|
118
119
|
}
|
|
119
|
-
var stackAppInternalsSymbol = Symbol.for("StackAppInternals");
|
|
120
|
+
var stackAppInternalsSymbol = Symbol.for("StackAuth--DO-NOT-USE-OR-YOU-WILL-BE-FIRED--StackAppInternals");
|
|
120
121
|
var allClientApps = /* @__PURE__ */ new Map();
|
|
121
122
|
var createCache = (fetcher) => {
|
|
122
123
|
return new AsyncCache(
|
|
@@ -146,6 +147,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
146
147
|
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) {
|
|
147
148
|
await wait(2e3);
|
|
148
149
|
}
|
|
150
|
+
if (session.isKnownToBeInvalid()) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
149
153
|
return await this._interface.getClientUserByToken(session);
|
|
150
154
|
});
|
|
151
155
|
this._currentProjectCache = createCache(async () => {
|
|
@@ -673,8 +677,8 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
673
677
|
await app._refreshUser(session);
|
|
674
678
|
return registrationResult;
|
|
675
679
|
},
|
|
676
|
-
signOut() {
|
|
677
|
-
return app._signOut(session);
|
|
680
|
+
signOut(options) {
|
|
681
|
+
return app._signOut(session, options);
|
|
678
682
|
}
|
|
679
683
|
};
|
|
680
684
|
}
|
|
@@ -792,11 +796,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
792
796
|
async update(update) {
|
|
793
797
|
return await app._updateClientUser(update, session);
|
|
794
798
|
},
|
|
795
|
-
async sendVerificationEmail() {
|
|
799
|
+
async sendVerificationEmail(options) {
|
|
796
800
|
if (!crud.primary_email) {
|
|
797
801
|
throw new StackAssertionError("User does not have a primary email");
|
|
798
802
|
}
|
|
799
|
-
|
|
803
|
+
if (!options?.callbackUrl && typeof window === "undefined") {
|
|
804
|
+
throw new Error("Cannot send verification email without a callback URL from the server. Make sure you pass the `callbackUrl` option: `sendVerificationEmail({ callbackUrl: ... })`");
|
|
805
|
+
}
|
|
806
|
+
return await app._interface.sendVerificationEmail(crud.primary_email, options?.callbackUrl ?? constructRedirectUrl(app.urls.emailVerification), session);
|
|
800
807
|
},
|
|
801
808
|
async updatePassword(options) {
|
|
802
809
|
const result = await app._interface.updatePassword(options, session);
|
|
@@ -969,13 +976,17 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
969
976
|
async redirectToTeamInvitation(options) {
|
|
970
977
|
return await this._redirectToHandler("teamInvitation", options);
|
|
971
978
|
}
|
|
972
|
-
async sendForgotPasswordEmail(email) {
|
|
973
|
-
|
|
974
|
-
|
|
979
|
+
async sendForgotPasswordEmail(email, options) {
|
|
980
|
+
if (!options?.callbackUrl && typeof window === "undefined") {
|
|
981
|
+
throw new Error("Cannot send forgot password email without a callback URL from the server. Make sure you pass the `callbackUrl` option: `sendForgotPasswordEmail({ email, callbackUrl: ... })`");
|
|
982
|
+
}
|
|
983
|
+
return await this._interface.sendForgotPasswordEmail(email, options?.callbackUrl ?? constructRedirectUrl(this.urls.passwordReset));
|
|
975
984
|
}
|
|
976
|
-
async sendMagicLinkEmail(email) {
|
|
977
|
-
|
|
978
|
-
|
|
985
|
+
async sendMagicLinkEmail(email, options) {
|
|
986
|
+
if (!options?.callbackUrl && typeof window === "undefined") {
|
|
987
|
+
throw new Error("Cannot send magic link email without a callback URL from the server. Make sure you pass the `callbackUrl` option: `sendMagicLinkEmail({ email, callbackUrl: ... })`");
|
|
988
|
+
}
|
|
989
|
+
return await this._interface.sendMagicLinkEmail(email, options?.callbackUrl ?? constructRedirectUrl(this.urls.magicLinkCallback));
|
|
979
990
|
}
|
|
980
991
|
async resetPassword(options) {
|
|
981
992
|
return await this._interface.resetPassword(options);
|
|
@@ -1240,18 +1251,18 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1240
1251
|
}
|
|
1241
1252
|
return false;
|
|
1242
1253
|
}
|
|
1243
|
-
async _signOut(session) {
|
|
1254
|
+
async _signOut(session, options) {
|
|
1244
1255
|
await this._interface.signOut(session);
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1256
|
+
if (options?.redirectUrl) {
|
|
1257
|
+
await _redirectTo(options.redirectUrl);
|
|
1258
|
+
} else {
|
|
1259
|
+
await this.redirectToAfterSignOut();
|
|
1260
|
+
}
|
|
1250
1261
|
}
|
|
1251
|
-
async signOut() {
|
|
1262
|
+
async signOut(options) {
|
|
1252
1263
|
const user = await this.getUser();
|
|
1253
1264
|
if (user) {
|
|
1254
|
-
await user.signOut();
|
|
1265
|
+
await user.signOut(options);
|
|
1255
1266
|
}
|
|
1256
1267
|
}
|
|
1257
1268
|
async getProject() {
|
|
@@ -1327,7 +1338,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1327
1338
|
return {
|
|
1328
1339
|
toClientJson: () => {
|
|
1329
1340
|
if (!("publishableClientKey" in this._interface.options)) {
|
|
1330
|
-
throw
|
|
1341
|
+
throw new StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
|
|
1331
1342
|
}
|
|
1332
1343
|
return {
|
|
1333
1344
|
baseUrl: this._interface.options.baseUrl,
|
|
@@ -1343,6 +1354,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1343
1354
|
runAsynchronously(async () => {
|
|
1344
1355
|
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], Result.fromPromise(userJsonPromise));
|
|
1345
1356
|
});
|
|
1357
|
+
},
|
|
1358
|
+
sendRequest: async (path, requestOptions, requestType = "client") => {
|
|
1359
|
+
return await this._interface.sendClientRequest(path, requestOptions, await this._getSession(), requestType);
|
|
1346
1360
|
}
|
|
1347
1361
|
};
|
|
1348
1362
|
}
|
|
@@ -1368,6 +1382,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1368
1382
|
});
|
|
1369
1383
|
// TODO override the client user cache to use the server user cache, so we save some requests
|
|
1370
1384
|
this._currentServerUserCache = createCacheBySession(async (session) => {
|
|
1385
|
+
if (session.isKnownToBeInvalid()) {
|
|
1386
|
+
return null;
|
|
1387
|
+
}
|
|
1371
1388
|
return await this._interface.getServerUserByToken(session);
|
|
1372
1389
|
});
|
|
1373
1390
|
this._serverUsersCache = createCache(async ([cursor, limit, orderBy, desc, query]) => {
|
|
@@ -1462,8 +1479,11 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1462
1479
|
isVerified: crud.is_verified,
|
|
1463
1480
|
isPrimary: crud.is_primary,
|
|
1464
1481
|
usedForAuth: crud.used_for_auth,
|
|
1465
|
-
async sendVerificationEmail() {
|
|
1466
|
-
|
|
1482
|
+
async sendVerificationEmail(options) {
|
|
1483
|
+
if (!options?.callbackUrl && typeof window === "undefined") {
|
|
1484
|
+
throw new Error("Cannot send verification email without a callback URL from the server. Make sure you pass the `callbackUrl` option: `sendVerificationEmail({ callbackUrl: ... })`");
|
|
1485
|
+
}
|
|
1486
|
+
await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, options?.callbackUrl ?? constructRedirectUrl(app.urls.emailVerification));
|
|
1467
1487
|
},
|
|
1468
1488
|
async update(data) {
|
|
1469
1489
|
await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));
|