@stackframe/stack 2.6.34 → 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 +20 -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/stack-app.js +30 -17
- 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/generated/quetzal-translations.d.mts +2 -2
- package/dist/generated/quetzal-translations.d.ts +2 -2
- package/dist/lib/stack-app.d.mts +6 -2
- package/dist/lib/stack-app.d.ts +6 -2
- package/dist/lib/stack-app.js +30 -17
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +4 -4
package/dist/lib/stack-app.d.mts
CHANGED
|
@@ -630,8 +630,12 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
630
630
|
}): Promise<Result<undefined, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
|
|
631
631
|
signInWithPasskey(): Promise<Result<undefined, KnownErrors["PasskeyAuthenticationFailed"] | KnownErrors["InvalidTotpCode"] | KnownErrors["PasskeyWebAuthnError"]>>;
|
|
632
632
|
callOAuthCallback(): Promise<boolean>;
|
|
633
|
-
sendForgotPasswordEmail(email: string
|
|
634
|
-
|
|
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<{
|
|
635
639
|
nonce: string;
|
|
636
640
|
}, KnownErrors["RedirectUrlNotWhitelisted"]>>;
|
|
637
641
|
resetPassword(options: {
|
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -630,8 +630,12 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
630
630
|
}): Promise<Result<undefined, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
|
|
631
631
|
signInWithPasskey(): Promise<Result<undefined, KnownErrors["PasskeyAuthenticationFailed"] | KnownErrors["InvalidTotpCode"] | KnownErrors["PasskeyWebAuthnError"]>>;
|
|
632
632
|
callOAuthCallback(): Promise<boolean>;
|
|
633
|
-
sendForgotPasswordEmail(email: string
|
|
634
|
-
|
|
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<{
|
|
635
639
|
nonce: string;
|
|
636
640
|
}, KnownErrors["RedirectUrlNotWhitelisted"]>>;
|
|
637
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,8 +148,9 @@ 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
|
}
|
|
@@ -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 () => {
|
|
@@ -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);
|
|
@@ -1287,10 +1298,6 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1287
1298
|
await this.redirectToAfterSignOut();
|
|
1288
1299
|
}
|
|
1289
1300
|
}
|
|
1290
|
-
async _sendVerificationEmail(email, session) {
|
|
1291
|
-
const emailVerificationRedirectUrl = (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
|
|
1292
|
-
return await this._interface.sendVerificationEmail(email, emailVerificationRedirectUrl, session);
|
|
1293
|
-
}
|
|
1294
1301
|
async signOut(options) {
|
|
1295
1302
|
const user = await this.getUser();
|
|
1296
1303
|
if (user) {
|
|
@@ -1370,7 +1377,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1370
1377
|
return {
|
|
1371
1378
|
toClientJson: () => {
|
|
1372
1379
|
if (!("publishableClientKey" in this._interface.options)) {
|
|
1373
|
-
throw
|
|
1380
|
+
throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
|
|
1374
1381
|
}
|
|
1375
1382
|
return {
|
|
1376
1383
|
baseUrl: this._interface.options.baseUrl,
|
|
@@ -1414,6 +1421,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1414
1421
|
});
|
|
1415
1422
|
// TODO override the client user cache to use the server user cache, so we save some requests
|
|
1416
1423
|
this._currentServerUserCache = createCacheBySession(async (session) => {
|
|
1424
|
+
if (session.isKnownToBeInvalid()) {
|
|
1425
|
+
return null;
|
|
1426
|
+
}
|
|
1417
1427
|
return await this._interface.getServerUserByToken(session);
|
|
1418
1428
|
});
|
|
1419
1429
|
this._serverUsersCache = createCache(async ([cursor, limit, orderBy, desc, query]) => {
|
|
@@ -1508,8 +1518,11 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1508
1518
|
isVerified: crud.is_verified,
|
|
1509
1519
|
isPrimary: crud.is_primary,
|
|
1510
1520
|
usedForAuth: crud.used_for_auth,
|
|
1511
|
-
async sendVerificationEmail() {
|
|
1512
|
-
|
|
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));
|
|
1513
1526
|
},
|
|
1514
1527
|
async update(data) {
|
|
1515
1528
|
await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));
|