@withpotter/pages-admin 0.13.0-next.64 → 0.13.0-next.66
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.
|
@@ -10,15 +10,9 @@ const SESSION_KEYS = [
|
|
|
10
10
|
"tenant",
|
|
11
11
|
"pb_workspaces_cache"
|
|
12
12
|
];
|
|
13
|
-
const encode = (value) => btoa(JSON.stringify(value)).replace(/=+$/, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
14
13
|
async function seedOwnerSession() {
|
|
15
14
|
const owner = await apiFetch("/accounts/me");
|
|
16
|
-
const exp = Math.floor(Date.now() / 1e3) + 60 * 60;
|
|
17
15
|
clearOwnerSession();
|
|
18
|
-
localStorage.setItem(
|
|
19
|
-
"pb_token",
|
|
20
|
-
`${encode({ alg: "none", typ: "JWT" })}.${encode({ sub: owner.id, email: owner.email, exp, ownerView: true })}.owner-view`
|
|
21
|
-
);
|
|
22
16
|
localStorage.setItem("pb_account_id", owner.id);
|
|
23
17
|
localStorage.setItem("pb_user", JSON.stringify(owner));
|
|
24
18
|
localStorage.setItem("userEmail", owner.email);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/accounts/owner-session.ts"],"sourcesContent":["import { apiFetch } from '@withpotter/lib/api';\n\n/**\n * Hand the merchant dashboard the owner's session after \"View as owner\".\n *\n * The API's impersonation sets the owner's session as an httpOnly cookie on\n * this origin, which every merchant API call already authenticates with. The\n * merchant app, though, decides whether anyone is signed in from
|
|
1
|
+
{"version":3,"sources":["../../../src/admin/accounts/owner-session.ts"],"sourcesContent":["import { apiFetch } from '@withpotter/lib/api';\n\n/**\n * Hand the merchant dashboard the owner's session after \"View as owner\".\n *\n * The API's impersonation sets the owner's session as an httpOnly cookie on\n * this origin, which every merchant API call already authenticates with. The\n * merchant app, though, decides whether anyone is signed in from the cached\n * account (`pb_user`); finding nothing, it sent the tab to /login and the Admin\n * host bounced it home. So we read the owner through the cookie and seed that.\n */\nconst SESSION_KEYS = [\n 'pb_token',\n 'pb_user',\n 'pb_account_id',\n 'userEmail',\n 'organizationId',\n 'currentWorkspace',\n 'pb_current_tenant',\n 'tenant',\n 'pb_workspaces_cache',\n];\n\ninterface OwnerAccount {\n id: string;\n email: string;\n [key: string]: unknown;\n}\n\nexport async function seedOwnerSession(): Promise<void> {\n const owner = await apiFetch<OwnerAccount>('/accounts/me');\n\n clearOwnerSession();\n localStorage.setItem('pb_account_id', owner.id);\n localStorage.setItem('pb_user', JSON.stringify(owner));\n localStorage.setItem('userEmail', owner.email);\n}\n\n/** Drops any merchant session cached in this browser (and its workspace). */\nexport function clearOwnerSession(): void {\n try {\n SESSION_KEYS.forEach((key) => localStorage.removeItem(key));\n } catch {\n // Storage blocked: nothing cached to clear.\n }\n}\n"],"mappings":"AAAA,SAAS,gBAAgB;AAWzB,MAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQA,eAAsB,mBAAkC;AACtD,QAAM,QAAQ,MAAM,SAAuB,cAAc;AAEzD,oBAAkB;AAClB,eAAa,QAAQ,iBAAiB,MAAM,EAAE;AAC9C,eAAa,QAAQ,WAAW,KAAK,UAAU,KAAK,CAAC;AACrD,eAAa,QAAQ,aAAa,MAAM,KAAK;AAC/C;AAGO,SAAS,oBAA0B;AACxC,MAAI;AACF,iBAAa,QAAQ,CAAC,QAAQ,aAAa,WAAW,GAAG,CAAC;AAAA,EAC5D,QAAQ;AAAA,EAER;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@withpotter/pages-admin",
|
|
3
|
-
"version": "0.13.0-next.
|
|
3
|
+
"version": "0.13.0-next.66",
|
|
4
4
|
"description": "Box console platform-admin routes: overview, revenue, accounts, tenants, admins, roles, audit.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@radix-ui/react-popover": "^1.1.23",
|
|
33
33
|
"@tanstack/react-query": "^5.90.20",
|
|
34
|
-
"@withpotter/lib": "^0.13.0-next.
|
|
35
|
-
"@withpotter/platform-admin": "^0.13.0-next.
|
|
36
|
-
"@withpotter/ui-kit": "^0.13.0-next.
|
|
34
|
+
"@withpotter/lib": "^0.13.0-next.66",
|
|
35
|
+
"@withpotter/platform-admin": "^0.13.0-next.66",
|
|
36
|
+
"@withpotter/ui-kit": "^0.13.0-next.66",
|
|
37
37
|
"lucide-react": "^0.562.0",
|
|
38
38
|
"motion": "^12.42.2"
|
|
39
39
|
},
|