@stackframe/stack 2.4.25 → 2.4.26
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 +9 -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/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/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
package/dist/lib/stack-app.js
CHANGED
|
@@ -60,7 +60,7 @@ var import_sessions = require("@stackframe/stack-shared/dist/sessions");
|
|
|
60
60
|
var import_use_trigger = require("@stackframe/stack-shared/dist/hooks/use-trigger");
|
|
61
61
|
var import_strings = require("@stackframe/stack-shared/dist/utils/strings");
|
|
62
62
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
63
|
-
var clientVersion = "js @stackframe/stack@2.4.
|
|
63
|
+
var clientVersion = "js @stackframe/stack@2.4.26";
|
|
64
64
|
function permissionDefinitionScopeToType(scope) {
|
|
65
65
|
return { "any-team": "team", "specific-team": "team", "global": "global" }[scope.type];
|
|
66
66
|
}
|
|
@@ -120,21 +120,29 @@ function createEmptyTokenStore() {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
var loadingSentinel = Symbol("stackAppCacheLoadingSentinel");
|
|
123
|
+
var cachePromiseByComponentId = /* @__PURE__ */ new Map();
|
|
123
124
|
function useAsyncCache(cache, dependencies, caller) {
|
|
124
125
|
(0, import_react2.suspendIfSsr)(caller);
|
|
126
|
+
const id = import_react.default.useId();
|
|
125
127
|
const subscribe = (0, import_react.useCallback)((cb) => {
|
|
126
|
-
const { unsubscribe } = cache.
|
|
128
|
+
const { unsubscribe } = cache.onStateChange(dependencies, () => {
|
|
129
|
+
cachePromiseByComponentId.delete(id);
|
|
130
|
+
cb();
|
|
131
|
+
});
|
|
127
132
|
return unsubscribe;
|
|
128
133
|
}, [cache, ...dependencies]);
|
|
129
134
|
const getSnapshot = (0, import_react.useCallback)(() => {
|
|
130
|
-
|
|
135
|
+
if (!cachePromiseByComponentId.has(id)) {
|
|
136
|
+
cachePromiseByComponentId.set(id, cache.getOrWait(dependencies, "read-write"));
|
|
137
|
+
}
|
|
138
|
+
return cachePromiseByComponentId.get(id);
|
|
131
139
|
}, [cache, ...dependencies]);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
const promise = import_react.default.useSyncExternalStore(
|
|
141
|
+
subscribe,
|
|
142
|
+
getSnapshot,
|
|
143
|
+
() => (0, import_errors.throwErr)(new Error("getServerSnapshot should never be called in useAsyncCache because we restrict to CSR earlier"))
|
|
144
|
+
);
|
|
145
|
+
return (0, import_react.use)(promise);
|
|
138
146
|
}
|
|
139
147
|
var stackAppInternalsSymbol = Symbol.for("StackAppInternals");
|
|
140
148
|
var allClientApps = /* @__PURE__ */ new Map();
|
|
@@ -386,17 +394,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
386
394
|
if (tokenStoreInit === null) {
|
|
387
395
|
return createEmptyTokenStore();
|
|
388
396
|
} else if (typeof tokenStoreInit === "object" && "headers" in tokenStoreInit) {
|
|
389
|
-
if (this._requestTokenStores.has(tokenStoreInit))
|
|
390
|
-
return this._requestTokenStores.get(tokenStoreInit);
|
|
397
|
+
if (this._requestTokenStores.has(tokenStoreInit)) return this._requestTokenStores.get(tokenStoreInit);
|
|
391
398
|
const stackAuthHeader = tokenStoreInit.headers.get("x-stack-auth");
|
|
392
399
|
if (stackAuthHeader) {
|
|
393
400
|
let parsed2;
|
|
394
401
|
try {
|
|
395
402
|
parsed2 = JSON.parse(stackAuthHeader);
|
|
396
|
-
if (typeof parsed2 !== "object")
|
|
397
|
-
|
|
398
|
-
if (parsed2 === null)
|
|
399
|
-
throw new Error("x-stack-auth header must not be null");
|
|
403
|
+
if (typeof parsed2 !== "object") throw new Error("x-stack-auth header must be a JSON object");
|
|
404
|
+
if (parsed2 === null) throw new Error("x-stack-auth header must not be null");
|
|
400
405
|
} catch (e) {
|
|
401
406
|
throw new Error(`Invalid x-stack-auth header: ${stackAuthHeader}`, { cause: e });
|
|
402
407
|
}
|
|
@@ -437,8 +442,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
437
442
|
const tokenObj = tokenStore.get();
|
|
438
443
|
const sessionKey = import_sessions.InternalSession.calculateSessionKey(tokenObj);
|
|
439
444
|
const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
|
|
440
|
-
if (existing)
|
|
441
|
-
return existing;
|
|
445
|
+
if (existing) return existing;
|
|
442
446
|
const session = this._interface.createSession({
|
|
443
447
|
refreshToken: tokenObj.refreshToken,
|
|
444
448
|
accessToken: tokenObj.accessToken
|
|
@@ -522,8 +526,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
522
526
|
};
|
|
523
527
|
}
|
|
524
528
|
_teamMemberFromJson(json) {
|
|
525
|
-
if (json === null)
|
|
526
|
-
return null;
|
|
529
|
+
if (json === null) return null;
|
|
527
530
|
return {
|
|
528
531
|
teamId: json.teamId,
|
|
529
532
|
userId: json.userId,
|
|
@@ -1202,8 +1205,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1202
1205
|
return currentUser;
|
|
1203
1206
|
}
|
|
1204
1207
|
_serverTeamMemberFromJson(json) {
|
|
1205
|
-
if (json === null)
|
|
1206
|
-
return null;
|
|
1208
|
+
if (json === null) return null;
|
|
1207
1209
|
const app = this;
|
|
1208
1210
|
return {
|
|
1209
1211
|
...app._teamMemberFromJson(json),
|
|
@@ -1436,10 +1438,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1436
1438
|
return this.whyInvalid() === null;
|
|
1437
1439
|
},
|
|
1438
1440
|
whyInvalid() {
|
|
1439
|
-
if (this.expiresAt.getTime() < Date.now())
|
|
1440
|
-
|
|
1441
|
-
if (this.manuallyRevokedAt)
|
|
1442
|
-
return "manually-revoked";
|
|
1441
|
+
if (this.expiresAt.getTime() < Date.now()) return "expired";
|
|
1442
|
+
if (this.manuallyRevokedAt) return "manually-revoked";
|
|
1443
1443
|
return null;
|
|
1444
1444
|
},
|
|
1445
1445
|
async revoke() {
|