@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
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -109,7 +109,9 @@ type Session = {
|
|
|
109
109
|
type Auth = {
|
|
110
110
|
readonly _internalSession: InternalSession;
|
|
111
111
|
readonly currentSession: Session;
|
|
112
|
-
signOut(
|
|
112
|
+
signOut(options?: {
|
|
113
|
+
redirectUrl?: URL | string;
|
|
114
|
+
}): Promise<void>;
|
|
113
115
|
/**
|
|
114
116
|
* Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin
|
|
115
117
|
* requests. Similar to `getAuthJson`, but specifically for HTTP requests.
|
|
@@ -628,8 +630,12 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
628
630
|
}): Promise<Result<undefined, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
|
|
629
631
|
signInWithPasskey(): Promise<Result<undefined, KnownErrors["PasskeyAuthenticationFailed"] | KnownErrors["InvalidTotpCode"] | KnownErrors["PasskeyWebAuthnError"]>>;
|
|
630
632
|
callOAuthCallback(): Promise<boolean>;
|
|
631
|
-
sendForgotPasswordEmail(email: string
|
|
632
|
-
|
|
633
|
+
sendForgotPasswordEmail(email: string, options?: {
|
|
634
|
+
callbackUrl?: string;
|
|
635
|
+
}): Promise<Result<undefined, KnownErrors["UserNotFound"]>>;
|
|
636
|
+
sendMagicLinkEmail(email: string, options?: {
|
|
637
|
+
callbackUrl?: string;
|
|
638
|
+
}): Promise<Result<{
|
|
633
639
|
nonce: string;
|
|
634
640
|
}, KnownErrors["RedirectUrlNotWhitelisted"]>>;
|
|
635
641
|
resetPassword(options: {
|
package/dist/lib/stack-app.js
CHANGED
|
@@ -64,7 +64,7 @@ var import_url = require("../utils/url");
|
|
|
64
64
|
var import_auth = require("./auth");
|
|
65
65
|
var import_cookie = require("./cookie");
|
|
66
66
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
67
|
-
var clientVersion = "js @stackframe/stack@2.6.
|
|
67
|
+
var clientVersion = "js @stackframe/stack@2.6.36";
|
|
68
68
|
function getUrls(partial) {
|
|
69
69
|
const handler = partial.handler ?? "/handler";
|
|
70
70
|
const home = partial.home ?? "/";
|
|
@@ -148,14 +148,15 @@ function useAsyncCache(cache, dependencies, caller) {
|
|
|
148
148
|
const result = import_react2.default.use(promise);
|
|
149
149
|
if (result.status === "error") {
|
|
150
150
|
const error = result.error;
|
|
151
|
-
if (error instanceof Error) {
|
|
151
|
+
if (error instanceof Error && !error.__stackHasConcatenatedStacktraces) {
|
|
152
152
|
(0, import_errors.concatStacktraces)(error, new Error());
|
|
153
|
+
error.__stackHasConcatenatedStacktraces = true;
|
|
153
154
|
}
|
|
154
155
|
throw error;
|
|
155
156
|
}
|
|
156
157
|
return result.data;
|
|
157
158
|
}
|
|
158
|
-
var stackAppInternalsSymbol = Symbol.for("StackAppInternals");
|
|
159
|
+
var stackAppInternalsSymbol = Symbol.for("StackAuth--DO-NOT-USE-OR-YOU-WILL-BE-FIRED--StackAppInternals");
|
|
159
160
|
var allClientApps = /* @__PURE__ */ new Map();
|
|
160
161
|
var createCache = (fetcher) => {
|
|
161
162
|
return new import_caches.AsyncCache(
|
|
@@ -185,6 +186,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
185
186
|
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) {
|
|
186
187
|
await (0, import_promises.wait)(2e3);
|
|
187
188
|
}
|
|
189
|
+
if (session.isKnownToBeInvalid()) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
188
192
|
return await this._interface.getClientUserByToken(session);
|
|
189
193
|
});
|
|
190
194
|
this._currentProjectCache = createCache(async () => {
|
|
@@ -712,8 +716,8 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
712
716
|
await app._refreshUser(session);
|
|
713
717
|
return registrationResult;
|
|
714
718
|
},
|
|
715
|
-
signOut() {
|
|
716
|
-
return app._signOut(session);
|
|
719
|
+
signOut(options) {
|
|
720
|
+
return app._signOut(session, options);
|
|
717
721
|
}
|
|
718
722
|
};
|
|
719
723
|
}
|
|
@@ -831,11 +835,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
831
835
|
async update(update) {
|
|
832
836
|
return await app._updateClientUser(update, session);
|
|
833
837
|
},
|
|
834
|
-
async sendVerificationEmail() {
|
|
838
|
+
async sendVerificationEmail(options) {
|
|
835
839
|
if (!crud.primary_email) {
|
|
836
840
|
throw new import_errors.StackAssertionError("User does not have a primary email");
|
|
837
841
|
}
|
|
838
|
-
|
|
842
|
+
if (!options?.callbackUrl && typeof window === "undefined") {
|
|
843
|
+
throw new Error("Cannot send verification email without a callback URL from the server. Make sure you pass the `callbackUrl` option: `sendVerificationEmail({ callbackUrl: ... })`");
|
|
844
|
+
}
|
|
845
|
+
return await app._interface.sendVerificationEmail(crud.primary_email, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.emailVerification), session);
|
|
839
846
|
},
|
|
840
847
|
async updatePassword(options) {
|
|
841
848
|
const result = await app._interface.updatePassword(options, session);
|
|
@@ -1008,13 +1015,17 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1008
1015
|
async redirectToTeamInvitation(options) {
|
|
1009
1016
|
return await this._redirectToHandler("teamInvitation", options);
|
|
1010
1017
|
}
|
|
1011
|
-
async sendForgotPasswordEmail(email) {
|
|
1012
|
-
|
|
1013
|
-
|
|
1018
|
+
async sendForgotPasswordEmail(email, options) {
|
|
1019
|
+
if (!options?.callbackUrl && typeof window === "undefined") {
|
|
1020
|
+
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: ... })`");
|
|
1021
|
+
}
|
|
1022
|
+
return await this._interface.sendForgotPasswordEmail(email, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.passwordReset));
|
|
1014
1023
|
}
|
|
1015
|
-
async sendMagicLinkEmail(email) {
|
|
1016
|
-
|
|
1017
|
-
|
|
1024
|
+
async sendMagicLinkEmail(email, options) {
|
|
1025
|
+
if (!options?.callbackUrl && typeof window === "undefined") {
|
|
1026
|
+
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: ... })`");
|
|
1027
|
+
}
|
|
1028
|
+
return await this._interface.sendMagicLinkEmail(email, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(this.urls.magicLinkCallback));
|
|
1018
1029
|
}
|
|
1019
1030
|
async resetPassword(options) {
|
|
1020
1031
|
return await this._interface.resetPassword(options);
|
|
@@ -1279,18 +1290,18 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1279
1290
|
}
|
|
1280
1291
|
return false;
|
|
1281
1292
|
}
|
|
1282
|
-
async _signOut(session) {
|
|
1293
|
+
async _signOut(session, options) {
|
|
1283
1294
|
await this._interface.signOut(session);
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1295
|
+
if (options?.redirectUrl) {
|
|
1296
|
+
await _redirectTo(options.redirectUrl);
|
|
1297
|
+
} else {
|
|
1298
|
+
await this.redirectToAfterSignOut();
|
|
1299
|
+
}
|
|
1289
1300
|
}
|
|
1290
|
-
async signOut() {
|
|
1301
|
+
async signOut(options) {
|
|
1291
1302
|
const user = await this.getUser();
|
|
1292
1303
|
if (user) {
|
|
1293
|
-
await user.signOut();
|
|
1304
|
+
await user.signOut(options);
|
|
1294
1305
|
}
|
|
1295
1306
|
}
|
|
1296
1307
|
async getProject() {
|
|
@@ -1366,7 +1377,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1366
1377
|
return {
|
|
1367
1378
|
toClientJson: () => {
|
|
1368
1379
|
if (!("publishableClientKey" in this._interface.options)) {
|
|
1369
|
-
throw
|
|
1380
|
+
throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
|
|
1370
1381
|
}
|
|
1371
1382
|
return {
|
|
1372
1383
|
baseUrl: this._interface.options.baseUrl,
|
|
@@ -1382,6 +1393,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1382
1393
|
(0, import_promises.runAsynchronously)(async () => {
|
|
1383
1394
|
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], import_results.Result.fromPromise(userJsonPromise));
|
|
1384
1395
|
});
|
|
1396
|
+
},
|
|
1397
|
+
sendRequest: async (path, requestOptions, requestType = "client") => {
|
|
1398
|
+
return await this._interface.sendClientRequest(path, requestOptions, await this._getSession(), requestType);
|
|
1385
1399
|
}
|
|
1386
1400
|
};
|
|
1387
1401
|
}
|
|
@@ -1407,6 +1421,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1407
1421
|
});
|
|
1408
1422
|
// TODO override the client user cache to use the server user cache, so we save some requests
|
|
1409
1423
|
this._currentServerUserCache = createCacheBySession(async (session) => {
|
|
1424
|
+
if (session.isKnownToBeInvalid()) {
|
|
1425
|
+
return null;
|
|
1426
|
+
}
|
|
1410
1427
|
return await this._interface.getServerUserByToken(session);
|
|
1411
1428
|
});
|
|
1412
1429
|
this._serverUsersCache = createCache(async ([cursor, limit, orderBy, desc, query]) => {
|
|
@@ -1501,8 +1518,11 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1501
1518
|
isVerified: crud.is_verified,
|
|
1502
1519
|
isPrimary: crud.is_primary,
|
|
1503
1520
|
usedForAuth: crud.used_for_auth,
|
|
1504
|
-
async sendVerificationEmail() {
|
|
1505
|
-
|
|
1521
|
+
async sendVerificationEmail(options) {
|
|
1522
|
+
if (!options?.callbackUrl && typeof window === "undefined") {
|
|
1523
|
+
throw new Error("Cannot send verification email without a callback URL from the server. Make sure you pass the `callbackUrl` option: `sendVerificationEmail({ callbackUrl: ... })`");
|
|
1524
|
+
}
|
|
1525
|
+
await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, options?.callbackUrl ?? (0, import_url.constructRedirectUrl)(app.urls.emailVerification));
|
|
1506
1526
|
},
|
|
1507
1527
|
async update(data) {
|
|
1508
1528
|
await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));
|