@stackframe/stack 2.5.23 → 2.5.25
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/dist/components/oauth-button.js +74 -0
- package/dist/components/oauth-button.js.map +1 -1
- package/dist/components-page/account-settings.js +3 -2
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/esm/components/oauth-button.js +74 -0
- package/dist/esm/components/oauth-button.js.map +1 -1
- package/dist/esm/components-page/account-settings.js +3 -2
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/lib/stack-app.js +45 -35
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/lib/stack-app.d.mts +1 -1
- package/dist/lib/stack-app.d.ts +1 -1
- package/dist/lib/stack-app.js +45 -35
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +4 -4
package/dist/lib/stack-app.d.mts
CHANGED
|
@@ -615,7 +615,7 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
615
615
|
or: 'throw';
|
|
616
616
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
617
617
|
getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
618
|
-
} & AsyncStoreProperty<"users", [], ServerUser[], true> & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
618
|
+
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & AsyncStoreProperty<"users", [], ServerUser[], true> & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
619
619
|
declare const StackServerApp: StackServerAppConstructor;
|
|
620
620
|
type StackAdminAppConstructor = {
|
|
621
621
|
new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -615,7 +615,7 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
615
615
|
or: 'throw';
|
|
616
616
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
617
617
|
getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
618
|
-
} & AsyncStoreProperty<"users", [], ServerUser[], true> & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
618
|
+
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & AsyncStoreProperty<"users", [], ServerUser[], true> & AsyncStoreProperty<"team", [id: string], ServerTeam | null, false> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
619
619
|
declare const StackServerApp: StackServerAppConstructor;
|
|
620
620
|
type StackAdminAppConstructor = {
|
|
621
621
|
new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
package/dist/lib/stack-app.js
CHANGED
|
@@ -63,7 +63,7 @@ var import_url = require("../utils/url");
|
|
|
63
63
|
var import_auth = require("./auth");
|
|
64
64
|
var import_cookie = require("./cookie");
|
|
65
65
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
66
|
-
var clientVersion = "js @stackframe/stack@2.5.
|
|
66
|
+
var clientVersion = "js @stackframe/stack@2.5.25";
|
|
67
67
|
function getUrls(partial) {
|
|
68
68
|
const handler = partial.handler ?? "/handler";
|
|
69
69
|
const home = partial.home ?? "/";
|
|
@@ -1505,24 +1505,29 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1505
1505
|
return this._serverUserFromCrud(crud);
|
|
1506
1506
|
}
|
|
1507
1507
|
async getUser(options) {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1508
|
+
if (typeof options === "string") {
|
|
1509
|
+
const allUsers = await this.listUsers();
|
|
1510
|
+
return allUsers.find((u) => u.id === options) ?? null;
|
|
1511
|
+
} else {
|
|
1512
|
+
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1513
|
+
const session = this._getSession(options?.tokenStore);
|
|
1514
|
+
const crud = await this._currentServerUserCache.getOrWait([session], "write-only");
|
|
1515
|
+
if (crud === null) {
|
|
1516
|
+
switch (options?.or) {
|
|
1517
|
+
case "redirect": {
|
|
1518
|
+
await this.redirectToSignIn({ replace: true });
|
|
1519
|
+
break;
|
|
1520
|
+
}
|
|
1521
|
+
case "throw": {
|
|
1522
|
+
throw new Error("User is not signed in but getUser was called with { or: 'throw' }");
|
|
1523
|
+
}
|
|
1524
|
+
default: {
|
|
1525
|
+
return null;
|
|
1526
|
+
}
|
|
1522
1527
|
}
|
|
1523
1528
|
}
|
|
1529
|
+
return crud && this._currentUserFromCrud(crud, session);
|
|
1524
1530
|
}
|
|
1525
|
-
return crud && this._currentUserFromCrud(crud, session);
|
|
1526
1531
|
}
|
|
1527
1532
|
async getServerUser() {
|
|
1528
1533
|
console.warn("stackServerApp.getServerUser is deprecated; use stackServerApp.getUser instead");
|
|
@@ -1533,28 +1538,33 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1533
1538
|
return crud && this._serverUserFromCrud(crud);
|
|
1534
1539
|
}
|
|
1535
1540
|
useUser(options) {
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1541
|
+
if (typeof options === "string") {
|
|
1542
|
+
const users = this.useUsers();
|
|
1543
|
+
return users.find((u) => u.id === options) ?? null;
|
|
1544
|
+
} else {
|
|
1545
|
+
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
1546
|
+
const router = NextNavigation.useRouter();
|
|
1547
|
+
const session = this._getSession(options?.tokenStore);
|
|
1548
|
+
const crud = useAsyncCache(this._currentServerUserCache, [session], "useUser()");
|
|
1549
|
+
if (crud === null) {
|
|
1550
|
+
switch (options?.or) {
|
|
1551
|
+
case "redirect": {
|
|
1552
|
+
(0, import_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
|
|
1553
|
+
(0, import_react.suspend)();
|
|
1554
|
+
throw new import_errors.StackAssertionError("suspend should never return");
|
|
1555
|
+
}
|
|
1556
|
+
case "throw": {
|
|
1557
|
+
throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
1558
|
+
}
|
|
1559
|
+
case void 0:
|
|
1560
|
+
case "return-null": {
|
|
1561
|
+
}
|
|
1552
1562
|
}
|
|
1553
1563
|
}
|
|
1564
|
+
return (0, import_react2.useMemo)(() => {
|
|
1565
|
+
return crud && this._currentUserFromCrud(crud, session);
|
|
1566
|
+
}, [crud, session, options?.or]);
|
|
1554
1567
|
}
|
|
1555
|
-
return (0, import_react2.useMemo)(() => {
|
|
1556
|
-
return crud && this._currentUserFromCrud(crud, session);
|
|
1557
|
-
}, [crud, session, options?.or]);
|
|
1558
1568
|
}
|
|
1559
1569
|
useUserById(userId) {
|
|
1560
1570
|
const crud = useAsyncCache(this._serverUserCache, [userId], "useUserById()");
|