@stackframe/stack 2.7.19 → 2.7.20
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 +10 -0
- package/dist/components/credential-sign-in.js +2 -1
- package/dist/components/credential-sign-in.js.map +1 -1
- package/dist/components/elements/sidebar-layout.js +10 -7
- package/dist/components/elements/sidebar-layout.js.map +1 -1
- package/dist/components/link.d.mts +14 -0
- package/dist/components/link.d.ts +14 -0
- package/dist/components/link.js +63 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/selected-team-switcher.js +4 -5
- package/dist/components/selected-team-switcher.js.map +1 -1
- package/dist/components-page/account-settings.js +2 -3
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/auth-page.js +3 -2
- package/dist/components-page/auth-page.js.map +1 -1
- package/dist/components-page/forgot-password.js +2 -1
- package/dist/components-page/forgot-password.js.map +1 -1
- package/dist/components-page/oauth-callback.js +4 -4
- package/dist/components-page/oauth-callback.js.map +1 -1
- package/dist/components-page/stack-handler.d.mts +5 -3
- package/dist/components-page/stack-handler.d.ts +5 -3
- package/dist/components-page/stack-handler.js +173 -157
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/components-page/team-creation.js +2 -3
- package/dist/components-page/team-creation.js.map +1 -1
- package/dist/esm/components/credential-sign-in.js +2 -1
- package/dist/esm/components/credential-sign-in.js.map +1 -1
- package/dist/esm/components/elements/sidebar-layout.js +10 -7
- package/dist/esm/components/elements/sidebar-layout.js.map +1 -1
- package/dist/esm/components/link.js +28 -0
- package/dist/esm/components/link.js.map +1 -0
- package/dist/esm/components/selected-team-switcher.js +4 -5
- package/dist/esm/components/selected-team-switcher.js.map +1 -1
- package/dist/esm/components-page/account-settings.js +2 -3
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/auth-page.js +2 -1
- package/dist/esm/components-page/auth-page.js.map +1 -1
- package/dist/esm/components-page/forgot-password.js +2 -1
- package/dist/esm/components-page/forgot-password.js.map +1 -1
- package/dist/esm/components-page/oauth-callback.js +4 -4
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +173 -157
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-page/team-creation.js +2 -3
- package/dist/esm/components-page/team-creation.js.map +1 -1
- package/dist/esm/lib/stack-app.js +34 -13
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/esm/providers/stack-provider-client.js +1 -2
- package/dist/esm/providers/stack-provider-client.js.map +1 -1
- package/dist/esm/providers/stack-provider.js +8 -7
- package/dist/esm/providers/stack-provider.js.map +1 -1
- package/dist/esm/providers/translation-provider.js +1 -1
- package/dist/esm/providers/translation-provider.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 +5 -1
- package/dist/lib/stack-app.d.ts +5 -1
- package/dist/lib/stack-app.js +34 -13
- package/dist/lib/stack-app.js.map +1 -1
- package/dist/providers/stack-provider-client.d.mts +2 -1
- package/dist/providers/stack-provider-client.d.ts +2 -1
- package/dist/providers/stack-provider-client.js +1 -2
- package/dist/providers/stack-provider-client.js.map +1 -1
- package/dist/providers/stack-provider.d.mts +2 -2
- package/dist/providers/stack-provider.d.ts +2 -2
- package/dist/providers/stack-provider.js +8 -7
- package/dist/providers/stack-provider.js.map +1 -1
- package/dist/providers/translation-provider.d.mts +1 -1
- package/dist/providers/translation-provider.d.ts +1 -1
- package/dist/providers/translation-provider.js +1 -1
- package/dist/providers/translation-provider.js.map +1 -1
- package/package.json +5 -5
package/dist/lib/stack-app.d.mts
CHANGED
|
@@ -14,7 +14,10 @@ type RequestLike = {
|
|
|
14
14
|
get: (name: string) => string | null;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
type RedirectMethod = "window" | "nextjs" | "none"
|
|
17
|
+
type RedirectMethod = "window" | "nextjs" | "none" | {
|
|
18
|
+
useNavigate: () => (to: string) => void;
|
|
19
|
+
navigate?: (to: string) => void;
|
|
20
|
+
};
|
|
18
21
|
type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | RequestLike | {
|
|
19
22
|
accessToken: string;
|
|
20
23
|
refreshToken: string;
|
|
@@ -677,6 +680,7 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
677
680
|
or: 'throw';
|
|
678
681
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
679
682
|
getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>;
|
|
683
|
+
useNavigate(): (to: string) => void;
|
|
680
684
|
[stackAppInternalsSymbol]: {
|
|
681
685
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
682
686
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -14,7 +14,10 @@ type RequestLike = {
|
|
|
14
14
|
get: (name: string) => string | null;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
type RedirectMethod = "window" | "nextjs" | "none"
|
|
17
|
+
type RedirectMethod = "window" | "nextjs" | "none" | {
|
|
18
|
+
useNavigate: () => (to: string) => void;
|
|
19
|
+
navigate?: (to: string) => void;
|
|
20
|
+
};
|
|
18
21
|
type TokenStoreInit<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? ("cookie" | "nextjs-cookie" | "memory" | RequestLike | {
|
|
19
22
|
accessToken: string;
|
|
20
23
|
refreshToken: string;
|
|
@@ -677,6 +680,7 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
677
680
|
or: 'throw';
|
|
678
681
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
679
682
|
getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>;
|
|
683
|
+
useNavigate(): (to: string) => void;
|
|
680
684
|
[stackAppInternalsSymbol]: {
|
|
681
685
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
682
686
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
package/dist/lib/stack-app.js
CHANGED
|
@@ -63,10 +63,11 @@ var import_url = require("../utils/url");
|
|
|
63
63
|
var import_auth = require("./auth");
|
|
64
64
|
var import_cookie = require("./cookie");
|
|
65
65
|
var sc = __toESM(require("@stackframe/stack-sc"));
|
|
66
|
+
var import_stack_sc = require("@stackframe/stack-sc");
|
|
66
67
|
var isReactServer2 = false;
|
|
67
68
|
isReactServer2 = sc.isReactServer;
|
|
68
69
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
69
|
-
var clientVersion = "js @stackframe/stack@2.7.
|
|
70
|
+
var clientVersion = "js @stackframe/stack@2.7.20";
|
|
70
71
|
if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
|
|
71
72
|
throw new import_errors.StackAssertionError("Client version was not replaced. Something went wrong during build!");
|
|
72
73
|
}
|
|
@@ -280,7 +281,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
280
281
|
getBaseUrl: () => getBaseUrl(_options.baseUrl),
|
|
281
282
|
projectId: _options.projectId ?? getDefaultProjectId(),
|
|
282
283
|
clientVersion,
|
|
283
|
-
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
|
|
284
|
+
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
285
|
+
prepareRequest: async () => {
|
|
286
|
+
await (0, import_stack_sc.cookies)?.();
|
|
287
|
+
}
|
|
284
288
|
});
|
|
285
289
|
}
|
|
286
290
|
this._tokenStoreInit = _options.tokenStore;
|
|
@@ -384,9 +388,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
384
388
|
get _refreshTokenCookieName() {
|
|
385
389
|
return `stack-refresh-${this.projectId}`;
|
|
386
390
|
}
|
|
387
|
-
_getTokensFromCookies(
|
|
388
|
-
const refreshToken =
|
|
389
|
-
const accessTokenObject =
|
|
391
|
+
_getTokensFromCookies(cookies2) {
|
|
392
|
+
const refreshToken = cookies2.refreshTokenCookie;
|
|
393
|
+
const accessTokenObject = cookies2.accessTokenCookie?.startsWith('["') ? JSON.parse(cookies2.accessTokenCookie) : null;
|
|
390
394
|
const accessToken = accessTokenObject && refreshToken === accessTokenObject[0] ? accessTokenObject[1] : null;
|
|
391
395
|
return {
|
|
392
396
|
refreshToken,
|
|
@@ -959,16 +963,29 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
959
963
|
async _redirectTo(options) {
|
|
960
964
|
if (this._redirectMethod === "none") {
|
|
961
965
|
return;
|
|
962
|
-
}
|
|
963
|
-
if (isReactServer2 && this._redirectMethod === "nextjs") {
|
|
966
|
+
} else if (isReactServer2 && this._redirectMethod === "nextjs") {
|
|
964
967
|
NextNavigation.redirect(options.url.toString(), options.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
|
|
968
|
+
} else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) {
|
|
969
|
+
this._redirectMethod.navigate(options.url.toString());
|
|
965
970
|
} else {
|
|
966
971
|
if (options.replace) {
|
|
967
972
|
window.location.replace(options.url);
|
|
968
973
|
} else {
|
|
969
974
|
window.location.assign(options.url);
|
|
970
975
|
}
|
|
971
|
-
|
|
976
|
+
}
|
|
977
|
+
await (0, import_promises.wait)(2e3);
|
|
978
|
+
}
|
|
979
|
+
useNavigate() {
|
|
980
|
+
if (typeof this._redirectMethod === "object") {
|
|
981
|
+
return this._redirectMethod.useNavigate();
|
|
982
|
+
} else if (this._redirectMethod === "window") {
|
|
983
|
+
return () => window.location.assign;
|
|
984
|
+
} else if (this._redirectMethod === "nextjs") {
|
|
985
|
+
return NextNavigation.useRouter().push;
|
|
986
|
+
} else {
|
|
987
|
+
return (to) => {
|
|
988
|
+
};
|
|
972
989
|
}
|
|
973
990
|
}
|
|
974
991
|
async _redirectIfTrusted(url, options) {
|
|
@@ -1135,7 +1152,6 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1135
1152
|
}
|
|
1136
1153
|
useUser(options) {
|
|
1137
1154
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1138
|
-
const router = NextNavigation.useRouter();
|
|
1139
1155
|
const session = this._useSession(options?.tokenStore);
|
|
1140
1156
|
const crud = useAsyncCache(this._currentUserCache, [session], "useUser()");
|
|
1141
1157
|
if (crud === null) {
|
|
@@ -1432,6 +1448,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1432
1448
|
if (!("publishableClientKey" in this._interface.options)) {
|
|
1433
1449
|
throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
|
|
1434
1450
|
}
|
|
1451
|
+
if (typeof this._redirectMethod !== "string") {
|
|
1452
|
+
throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application with a non-string redirect method");
|
|
1453
|
+
}
|
|
1435
1454
|
return {
|
|
1436
1455
|
baseUrl: this._options.baseUrl,
|
|
1437
1456
|
projectId: this.projectId,
|
|
@@ -1439,7 +1458,8 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1439
1458
|
tokenStore: this._tokenStoreInit,
|
|
1440
1459
|
urls: this._urlOptions,
|
|
1441
1460
|
oauthScopesOnSignIn: this._oauthScopesOnSignIn,
|
|
1442
|
-
uniqueIdentifier: this._getUniqueIdentifier()
|
|
1461
|
+
uniqueIdentifier: this._getUniqueIdentifier(),
|
|
1462
|
+
redirectMethod: this._redirectMethod
|
|
1443
1463
|
};
|
|
1444
1464
|
},
|
|
1445
1465
|
setCurrentUser: (userJsonPromise) => {
|
|
@@ -1473,7 +1493,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1473
1493
|
publishableClientKey: options.publishableClientKey,
|
|
1474
1494
|
tokenStore: options.tokenStore,
|
|
1475
1495
|
urls: options.urls ?? {},
|
|
1476
|
-
oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {}
|
|
1496
|
+
oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {},
|
|
1497
|
+
redirectMethod: options.redirectMethod
|
|
1477
1498
|
});
|
|
1478
1499
|
// TODO override the client user cache to use the server user cache, so we save some requests
|
|
1479
1500
|
this._currentServerUserCache = createCacheBySession(async (session) => {
|
|
@@ -1869,7 +1890,6 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1869
1890
|
return this.useUserById(options);
|
|
1870
1891
|
} else {
|
|
1871
1892
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1872
|
-
const router = NextNavigation.useRouter();
|
|
1873
1893
|
const session = this._useSession(options?.tokenStore);
|
|
1874
1894
|
const crud = useAsyncCache(this._currentServerUserCache, [session], "useUser()");
|
|
1875
1895
|
if (crud === null) {
|
|
@@ -1981,7 +2001,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1981
2001
|
projectId: options.projectId,
|
|
1982
2002
|
tokenStore: options.tokenStore,
|
|
1983
2003
|
urls: options.urls,
|
|
1984
|
-
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
2004
|
+
oauthScopesOnSignIn: options.oauthScopesOnSignIn,
|
|
2005
|
+
redirectMethod: options.redirectMethod
|
|
1985
2006
|
});
|
|
1986
2007
|
this._adminProjectCache = createCache(async () => {
|
|
1987
2008
|
return await this._interface.getProject();
|