@stackframe/stack 2.4.25 → 2.4.27
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 +17 -0
- package/dist/components-page/oauth-callback.js +1 -2
- package/dist/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/oauth-callback.js +1 -2
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/global.d.js +1 -0
- package/dist/esm/global.d.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/auth.js +1 -2
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/cookie.js +2 -2
- package/dist/esm/lib/cookie.js.map +1 -1
- package/dist/esm/lib/stack-app.js +27 -27
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/esm/providers/styled-components-registry.js +1 -2
- package/dist/esm/providers/styled-components-registry.js.map +1 -1
- package/dist/esm/utils/email.js +1 -2
- package/dist/esm/utils/email.js.map +1 -1
- package/dist/global.d.d.mts +2 -0
- package/dist/global.d.d.ts +2 -0
- package/dist/global.d.js +2 -0
- package/dist/global.d.js.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/auth.js +1 -2
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/cookie.js +2 -2
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/stack-app.js +25 -25
- package/dist/lib/stack-app.js.map +1 -1
- package/dist/providers/styled-components-registry.js +1 -2
- package/dist/providers/styled-components-registry.js.map +1 -1
- package/dist/utils/email.js +1 -2
- package/dist/utils/email.js.map +1 -1
- package/package.json +7 -5
|
@@ -4,7 +4,7 @@ import { KnownError, KnownErrors, StackAdminInterface, StackClientInterface, Sta
|
|
|
4
4
|
import { deleteCookie, getCookie, setOrDeleteCookie } from "./cookie";
|
|
5
5
|
import { StackAssertionError, throwErr } from "@stackframe/stack-shared/dist/utils/errors";
|
|
6
6
|
import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids";
|
|
7
|
-
import {
|
|
7
|
+
import { Result } from "@stackframe/stack-shared/dist/utils/results";
|
|
8
8
|
import { suspendIfSsr } from "@stackframe/stack-shared/dist/utils/react";
|
|
9
9
|
import { Store } from "@stackframe/stack-shared/dist/utils/stores";
|
|
10
10
|
import { getProductionModeErrors } from "@stackframe/stack-shared/dist/interface/clientInterface";
|
|
@@ -13,7 +13,7 @@ import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "
|
|
|
13
13
|
import * as NextNavigationUnscrambled from "next/navigation";
|
|
14
14
|
import { constructRedirectUrl } from "../utils/url";
|
|
15
15
|
import { deepPlainEquals, filterUndefined, omit, pick } from "@stackframe/stack-shared/dist/utils/objects";
|
|
16
|
-
import { neverResolve,
|
|
16
|
+
import { neverResolve, runAsynchronously, wait } from "@stackframe/stack-shared/dist/utils/promises";
|
|
17
17
|
import { AsyncCache } from "@stackframe/stack-shared/dist/utils/caches";
|
|
18
18
|
import { suspend } from "@stackframe/stack-shared/dist/utils/react";
|
|
19
19
|
import { scrambleDuringCompileTime } from "@stackframe/stack-shared/dist/utils/compile-time";
|
|
@@ -23,7 +23,7 @@ import { InternalSession } from "@stackframe/stack-shared/dist/sessions";
|
|
|
23
23
|
import { useTrigger } from "@stackframe/stack-shared/dist/hooks/use-trigger";
|
|
24
24
|
import { mergeScopeStrings } from "@stackframe/stack-shared/dist/utils/strings";
|
|
25
25
|
var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
|
|
26
|
-
var clientVersion = "js @stackframe/stack@2.4.
|
|
26
|
+
var clientVersion = "js @stackframe/stack@2.4.27";
|
|
27
27
|
function permissionDefinitionScopeToType(scope) {
|
|
28
28
|
return { "any-team": "team", "specific-team": "team", "global": "global" }[scope.type];
|
|
29
29
|
}
|
|
@@ -83,21 +83,29 @@ function createEmptyTokenStore() {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
var loadingSentinel = Symbol("stackAppCacheLoadingSentinel");
|
|
86
|
+
var cachePromiseByComponentId = /* @__PURE__ */ new Map();
|
|
86
87
|
function useAsyncCache(cache, dependencies, caller) {
|
|
87
88
|
suspendIfSsr(caller);
|
|
89
|
+
const id = React.useId();
|
|
88
90
|
const subscribe = useCallback((cb) => {
|
|
89
|
-
const { unsubscribe } = cache.
|
|
91
|
+
const { unsubscribe } = cache.onStateChange(dependencies, () => {
|
|
92
|
+
cachePromiseByComponentId.delete(id);
|
|
93
|
+
cb();
|
|
94
|
+
});
|
|
90
95
|
return unsubscribe;
|
|
91
96
|
}, [cache, ...dependencies]);
|
|
92
97
|
const getSnapshot = useCallback(() => {
|
|
93
|
-
|
|
98
|
+
if (!cachePromiseByComponentId.has(id)) {
|
|
99
|
+
cachePromiseByComponentId.set(id, cache.getOrWait(dependencies, "read-write"));
|
|
100
|
+
}
|
|
101
|
+
return cachePromiseByComponentId.get(id);
|
|
94
102
|
}, [cache, ...dependencies]);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
const promise = React.useSyncExternalStore(
|
|
104
|
+
subscribe,
|
|
105
|
+
getSnapshot,
|
|
106
|
+
() => throwErr(new Error("getServerSnapshot should never be called in useAsyncCache because we restrict to CSR earlier"))
|
|
107
|
+
);
|
|
108
|
+
return use(promise);
|
|
101
109
|
}
|
|
102
110
|
var stackAppInternalsSymbol = Symbol.for("StackAppInternals");
|
|
103
111
|
var allClientApps = /* @__PURE__ */ new Map();
|
|
@@ -349,17 +357,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
349
357
|
if (tokenStoreInit === null) {
|
|
350
358
|
return createEmptyTokenStore();
|
|
351
359
|
} else if (typeof tokenStoreInit === "object" && "headers" in tokenStoreInit) {
|
|
352
|
-
if (this._requestTokenStores.has(tokenStoreInit))
|
|
353
|
-
return this._requestTokenStores.get(tokenStoreInit);
|
|
360
|
+
if (this._requestTokenStores.has(tokenStoreInit)) return this._requestTokenStores.get(tokenStoreInit);
|
|
354
361
|
const stackAuthHeader = tokenStoreInit.headers.get("x-stack-auth");
|
|
355
362
|
if (stackAuthHeader) {
|
|
356
363
|
let parsed2;
|
|
357
364
|
try {
|
|
358
365
|
parsed2 = JSON.parse(stackAuthHeader);
|
|
359
|
-
if (typeof parsed2 !== "object")
|
|
360
|
-
|
|
361
|
-
if (parsed2 === null)
|
|
362
|
-
throw new Error("x-stack-auth header must not be null");
|
|
366
|
+
if (typeof parsed2 !== "object") throw new Error("x-stack-auth header must be a JSON object");
|
|
367
|
+
if (parsed2 === null) throw new Error("x-stack-auth header must not be null");
|
|
363
368
|
} catch (e) {
|
|
364
369
|
throw new Error(`Invalid x-stack-auth header: ${stackAuthHeader}`, { cause: e });
|
|
365
370
|
}
|
|
@@ -400,8 +405,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
400
405
|
const tokenObj = tokenStore.get();
|
|
401
406
|
const sessionKey = InternalSession.calculateSessionKey(tokenObj);
|
|
402
407
|
const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
|
|
403
|
-
if (existing)
|
|
404
|
-
return existing;
|
|
408
|
+
if (existing) return existing;
|
|
405
409
|
const session = this._interface.createSession({
|
|
406
410
|
refreshToken: tokenObj.refreshToken,
|
|
407
411
|
accessToken: tokenObj.accessToken
|
|
@@ -485,8 +489,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
485
489
|
};
|
|
486
490
|
}
|
|
487
491
|
_teamMemberFromJson(json) {
|
|
488
|
-
if (json === null)
|
|
489
|
-
return null;
|
|
492
|
+
if (json === null) return null;
|
|
490
493
|
return {
|
|
491
494
|
teamId: json.teamId,
|
|
492
495
|
userId: json.userId,
|
|
@@ -1165,8 +1168,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1165
1168
|
return currentUser;
|
|
1166
1169
|
}
|
|
1167
1170
|
_serverTeamMemberFromJson(json) {
|
|
1168
|
-
if (json === null)
|
|
1169
|
-
return null;
|
|
1171
|
+
if (json === null) return null;
|
|
1170
1172
|
const app = this;
|
|
1171
1173
|
return {
|
|
1172
1174
|
...app._teamMemberFromJson(json),
|
|
@@ -1399,10 +1401,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1399
1401
|
return this.whyInvalid() === null;
|
|
1400
1402
|
},
|
|
1401
1403
|
whyInvalid() {
|
|
1402
|
-
if (this.expiresAt.getTime() < Date.now())
|
|
1403
|
-
|
|
1404
|
-
if (this.manuallyRevokedAt)
|
|
1405
|
-
return "manually-revoked";
|
|
1404
|
+
if (this.expiresAt.getTime() < Date.now()) return "expired";
|
|
1405
|
+
if (this.manuallyRevokedAt) return "manually-revoked";
|
|
1406
1406
|
return null;
|
|
1407
1407
|
},
|
|
1408
1408
|
async revoke() {
|