@stackframe/js 2.8.12 → 2.8.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 +38 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/auth.js +2 -2
- package/dist/esm/lib/cookie.js +1 -129
- package/dist/esm/lib/cookie.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +7 -7
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +51 -20
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +2 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/index.js +3 -3
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +7 -7
- package/dist/esm/lib/stack-app/apps/index.js +3 -3
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js +1 -1
- package/dist/esm/lib/stack-app/common.js.map +1 -1
- package/dist/esm/lib/stack-app/index.js +2 -2
- package/dist/esm/lib/stack-app/internal-api-keys/index.js.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/auth.js +2 -2
- package/dist/lib/cookie.js +4 -132
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +7 -7
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +51 -20
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +2 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/index.js +3 -3
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +7 -7
- package/dist/lib/stack-app/apps/index.js +3 -3
- package/dist/lib/stack-app/apps/interfaces/admin-app.js +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js +1 -1
- package/dist/lib/stack-app/common.js.map +1 -1
- package/dist/lib/stack-app/index.js +2 -2
- package/dist/lib/stack-app/internal-api-keys/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -13,16 +13,16 @@ import { deindent, mergeScopeStrings } from "@stackframe/stack-shared/dist/utils
|
|
|
13
13
|
import { getRelativePart, isRelative } from "@stackframe/stack-shared/dist/utils/urls";
|
|
14
14
|
import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids";
|
|
15
15
|
import * as cookie from "cookie";
|
|
16
|
-
import { constructRedirectUrl } from "../../../../utils/url";
|
|
17
|
-
import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "../../../auth";
|
|
18
|
-
import { createCookieHelper, createPlaceholderCookieHelper, deleteCookieClient, getCookieClient, setOrDeleteCookie, setOrDeleteCookieClient } from "../../../cookie";
|
|
19
|
-
import { apiKeyCreationOptionsToCrud } from "../../api-keys";
|
|
20
|
-
import { stackAppInternalsSymbol } from "../../common";
|
|
21
|
-
import { contactChannelCreateOptionsToCrud, contactChannelUpdateOptionsToCrud } from "../../contact-channels";
|
|
22
|
-
import { adminProjectCreateOptionsToCrud } from "../../projects";
|
|
23
|
-
import { teamCreateOptionsToCrud, teamUpdateOptionsToCrud } from "../../teams";
|
|
24
|
-
import { userUpdateOptionsToCrud } from "../../users";
|
|
25
|
-
import { clientVersion, createCache, createCacheBySession, createEmptyTokenStore, getBaseUrl, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getUrls } from "./common";
|
|
16
|
+
import { constructRedirectUrl } from "../../../../utils/url.js";
|
|
17
|
+
import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "../../../auth.js";
|
|
18
|
+
import { createCookieHelper, createPlaceholderCookieHelper, deleteCookieClient, getCookieClient, setOrDeleteCookie, setOrDeleteCookieClient } from "../../../cookie.js";
|
|
19
|
+
import { apiKeyCreationOptionsToCrud } from "../../api-keys/index.js";
|
|
20
|
+
import { stackAppInternalsSymbol } from "../../common.js";
|
|
21
|
+
import { contactChannelCreateOptionsToCrud, contactChannelUpdateOptionsToCrud } from "../../contact-channels/index.js";
|
|
22
|
+
import { adminProjectCreateOptionsToCrud } from "../../projects/index.js";
|
|
23
|
+
import { teamCreateOptionsToCrud, teamUpdateOptionsToCrud } from "../../teams/index.js";
|
|
24
|
+
import { userUpdateOptionsToCrud } from "../../users/index.js";
|
|
25
|
+
import { clientVersion, createCache, createCacheBySession, createEmptyTokenStore, getBaseUrl, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getUrls } from "./common.js";
|
|
26
26
|
var isReactServer = false;
|
|
27
27
|
var process = globalThis.process ?? { env: {} };
|
|
28
28
|
var allClientApps = /* @__PURE__ */ new Map();
|
|
@@ -950,6 +950,9 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
950
950
|
async redirectToTeamInvitation(options) {
|
|
951
951
|
return await this._redirectToHandler("teamInvitation", options);
|
|
952
952
|
}
|
|
953
|
+
async redirectToMfa(options) {
|
|
954
|
+
return await this._redirectToHandler("mfa", options);
|
|
955
|
+
}
|
|
953
956
|
async sendForgotPasswordEmail(email, options) {
|
|
954
957
|
return await this._interface.sendForgotPasswordEmail(email, options?.callbackUrl ?? constructRedirectUrl(this.urls.passwordReset, "callbackUrl"));
|
|
955
958
|
}
|
|
@@ -1049,19 +1052,14 @@ var __StackClientAppImplIncomplete = class __StackClientAppImplIncomplete {
|
|
|
1049
1052
|
);
|
|
1050
1053
|
}
|
|
1051
1054
|
/**
|
|
1052
|
-
*
|
|
1053
|
-
* TODO remove
|
|
1055
|
+
* Handles MFA verification by redirecting to the OTP page
|
|
1054
1056
|
*/
|
|
1055
1057
|
async _experimentalMfa(error, session) {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
throw new KnownErrors.InvalidTotpCode();
|
|
1058
|
+
if (typeof window !== "undefined") {
|
|
1059
|
+
window.sessionStorage.setItem("stack_mfa_attempt_code", error.details?.attempt_code ?? throwErr("attempt code missing"));
|
|
1059
1060
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
otp,
|
|
1063
|
-
session
|
|
1064
|
-
);
|
|
1061
|
+
await this.redirectToMfa();
|
|
1062
|
+
throw new StackAssertionError("we should have redirected in redirectToMfa()");
|
|
1065
1063
|
}
|
|
1066
1064
|
/**
|
|
1067
1065
|
* @deprecated
|
|
@@ -1245,6 +1243,39 @@ ${url}`);
|
|
|
1245
1243
|
}
|
|
1246
1244
|
return Result.error(new KnownErrors.CliAuthError("Timed out waiting for CLI authentication."));
|
|
1247
1245
|
}
|
|
1246
|
+
/*
|
|
1247
|
+
* Completes the MFA sign-in process by verifying the provided OTP code
|
|
1248
|
+
* @param totp The TOTP (Time-based One-Time Password) provided by the user
|
|
1249
|
+
* @param code The Attempt code provided by the user
|
|
1250
|
+
* @param options Additional options for the sign-in process
|
|
1251
|
+
* @returns A Result indicating success or failure
|
|
1252
|
+
*/
|
|
1253
|
+
async signInWithMfa(totp, code, options) {
|
|
1254
|
+
this._ensurePersistentTokenStore();
|
|
1255
|
+
let result;
|
|
1256
|
+
try {
|
|
1257
|
+
result = await this._catchMfaRequiredError(async () => {
|
|
1258
|
+
return await this._interface.signInWithMfa(totp, code);
|
|
1259
|
+
});
|
|
1260
|
+
} catch (e) {
|
|
1261
|
+
if (e instanceof KnownErrors.InvalidTotpCode) {
|
|
1262
|
+
return Result.error(e);
|
|
1263
|
+
}
|
|
1264
|
+
throw e;
|
|
1265
|
+
}
|
|
1266
|
+
if (result.status === "ok") {
|
|
1267
|
+
await this._signInToAccountWithTokens(result.data);
|
|
1268
|
+
if (!options?.noRedirect) {
|
|
1269
|
+
if (result.data.newUser) {
|
|
1270
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
1271
|
+
} else {
|
|
1272
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return Result.ok(void 0);
|
|
1276
|
+
}
|
|
1277
|
+
return Result.error(result.error);
|
|
1278
|
+
}
|
|
1248
1279
|
async signInWithPasskey() {
|
|
1249
1280
|
this._ensurePersistentTokenStore();
|
|
1250
1281
|
const session = await this._getSession();
|