@devbie/fewbie-cli 1.6.3 → 1.7.0
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/README.md +8 -13
- package/dist/commands/apits-templates.d.ts +1 -1
- package/dist/commands/apits-templates.js +1 -1
- package/dist/commands/apits-templates.js.map +1 -1
- package/dist/commands/apits.js +2 -1
- package/dist/commands/apits.js.map +1 -1
- package/dist/commands/doctor.js +56 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/modules/add.js +2 -1
- package/dist/commands/modules/add.js.map +1 -1
- package/dist/commands/modules/apply.js +4 -3
- package/dist/commands/modules/apply.js.map +1 -1
- package/dist/commands/modules/default.js +2 -1
- package/dist/commands/modules/default.js.map +1 -1
- package/dist/commands/modules/remove.js +2 -1
- package/dist/commands/modules/remove.js.map +1 -1
- package/dist/commands/modules/update.js +3 -2
- package/dist/commands/modules/update.js.map +1 -1
- package/dist/commands/status.js +2 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/template/update.js +100 -11
- package/dist/commands/template/update.js.map +1 -1
- package/dist/lib/modules-file.d.ts +5 -0
- package/dist/lib/modules-file.js +31 -3
- package/dist/lib/modules-file.js.map +1 -1
- package/dist/lib/template-ownership.d.ts +23 -2
- package/dist/lib/template-ownership.js +156 -12
- package/dist/lib/template-ownership.js.map +1 -1
- package/dist/registry/auth/item.json +2 -5
- package/dist/registry/source.d.ts +2 -0
- package/dist/registry/source.js +94 -0
- package/dist/registry/source.js.map +1 -0
- package/dist/registry/store.d.ts +0 -1
- package/dist/registry/store.js +0 -33
- package/dist/registry/store.js.map +1 -1
- package/package.json +1 -1
- package/dist/registry/api-client/item.json +0 -18
- package/dist/registry/app-shell/item.json +0 -20
- package/dist/registry/chart/item.json +0 -43
- package/dist/registry/page-header/item.json +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-ownership.js","sourceRoot":"","sources":["../../src/lib/template-ownership.ts"],"names":[],"m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CAAoC,GAAG,IAAI,OAAO,CAAC,KAAK,MAAM,OAAO,CAAC,GAAG,IAAI,CACpG,CAAC;YACJ,CAAC;YACD,MAAM,YAAY,GAAG,kBAAkB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;YACjE,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;gBAC1B,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK;oBACL,IAAI,EAAE,iBAAiB;oBACvB,WAAW,EAAE,IAAI;oBACjB,iBAAiB,EAAE,IAAI;oBACvB,kBAAkB,EAAE,aAAa;iBAClC,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YACD,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;gBACnC,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kBAAkB,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC;oBACvE,iBAAiB,EAAE,YAAY;oBAC/B,kBAAkB,EAAE,aAAa;iBAClC,CAAC,CAAC;YACL,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,cAAc,KAAK,eAAe,EAAE,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,eAAe;gBAC5B,iBAAiB,EAAE,cAAc;gBACjC,kBAAkB,EAAE,eAAe;aACpC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
1
|
+
{"version":3,"file":"template-ownership.js","sourceRoot":"","sources":["../../src/lib/template-ownership.ts"],"names":[],"mappings":";;;AAmFA,oCAEC;AAwHD,0CAEC;AAuCD,0CAMC;AAGD,gDAEC;AAaD,oDAOC;AAcD,gEAUC;AAGD,kCAEC;AAiBD,wCAMC;AAOD,wDAWC;AAGD,gEAKC;AAMD,wDAsBC;AAwBD,sDAMC;AAgBD,sEAEC;AAGD,gDAKC;AAGD,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;YACX,CAAC;YACD,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;gBACnC,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kBAAkB,CAAC,cAAc,EAAE,aAAa,EAAE,OAAO,CAAC;oBACvE,iBAAiB,EAAE,YAAY;oBAC/B,kBAAkB,EAAE,aAAa;iBAClC,CAAC,CAAC;YACL,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,cAAc,KAAK,eAAe;YAAE,SAAS;QAOjD,IAAI,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,+BAAuB,EAAE,CAAC;YACrE,MAAM,WAAW,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;YAChD,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;gBAC7B,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK;oBACL,IAAI,EAAE,oBAAoB;oBAC1B,WAAW,EAAE,IAAI;oBACjB,iBAAiB,EAAE,cAAc;oBACjC,kBAAkB,EAAE,eAAe;oBACnC,YAAY,EAAE,QAAQ,IAAI,IAAI;iBAC/B,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CAAC;YACX,KAAK;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,eAAe;YAC5B,iBAAiB,EAAE,cAAc;YACjC,kBAAkB,EAAE,eAAe;SACpC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
"name": "auth",
|
|
4
4
|
"type": "registry:lib",
|
|
5
5
|
"title": "Auth utilities",
|
|
6
|
-
"description": "login/logout helpers
|
|
7
|
-
"registryDependencies": [
|
|
8
|
-
"api-client"
|
|
9
|
-
],
|
|
6
|
+
"description": "login/logout helpers and session-expired redirect binding built on the template-provided api client.",
|
|
10
7
|
"postInstall": "Adjust LOGIN_PATH/LOGOUT_PATH and the login response fields in src/lib/auth.ts; call initAuth() once in your authenticated client layout.",
|
|
11
8
|
"files": [
|
|
12
9
|
{
|
|
13
10
|
"path": "src/lib/auth.ts",
|
|
14
|
-
"content": "\"use client\";\n\nimport {
|
|
11
|
+
"content": "\"use client\";\n\nimport { apiClient, clearSession, getAccessToken, onSessionExpired, setSession } from \"@/lib/api-client\";\n\n// ---------------------------------------------------------------------------\n// Project-specific configuration — edit these for your backend contract.\n// ---------------------------------------------------------------------------\n\n/** Login endpoint; accepts the credentials object and returns a session. */\nconst LOGIN_PATH = \"/auth/login\";\n\n/** Logout endpoint (called best-effort; local session is cleared regardless). */\nconst LOGOUT_PATH = \"/auth/logout\";\n\n/** Where to redirect when the session expires or login is required. */\nconst DEFAULT_LOGIN_PATH = \"/login\";\n\n/** Login response envelope (adjust fields to match your backend). */\ninterface LoginResult {\n token: string;\n tokenExpiresInSeconds?: number;\n}\n\nexport interface LoginCredentials {\n account: string;\n password: string;\n}\n\nlet initialized = false;\n\n/**\n * Wire auth behaviour to the router. Call once on the client, e.g. in the\n * authenticated layout's useEffect. No refresh timer is installed: the\n * api-client request gate renews an expiring token on demand (devbie ADR-050).\n */\nexport function initAuth(options?: { loginPath?: string }): void {\n if (initialized || typeof window === \"undefined\") return;\n initialized = true;\n\n const loginPath = options?.loginPath ?? DEFAULT_LOGIN_PATH;\n\n // Avoid bouncing on the login page itself.\n onSessionExpired(() => {\n if (window.location.pathname !== loginPath) {\n const redirect = encodeURIComponent(window.location.pathname + window.location.search);\n window.location.replace(`${loginPath}?redirect=${redirect}`);\n }\n });\n}\n\n/** Log in, persist the session, and return the raw result for callers. */\nexport async function login(credentials: LoginCredentials): Promise<LoginResult> {\n const result = await apiClient.post<LoginResult>(LOGIN_PATH, credentials);\n setSession(result.token, result.tokenExpiresInSeconds);\n return result;\n}\n\n/** Log out; always clears the local session even if the API call fails. */\nexport async function logout(): Promise<void> {\n try {\n await apiClient.post(LOGOUT_PATH);\n } finally {\n clearSession();\n }\n}\n\nexport function isAuthenticated(): boolean {\n return Boolean(getAccessToken());\n}\n",
|
|
15
12
|
"type": "registry:lib"
|
|
16
13
|
}
|
|
17
14
|
]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isRegistryRoot = isRegistryRoot;
|
|
7
|
+
exports.resolveRegistryRoot = resolveRegistryRoot;
|
|
8
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
9
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
10
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const cli_kit_1 = require("@devbie/cli-kit");
|
|
13
|
+
const modules_file_1 = require("../lib/modules-file");
|
|
14
|
+
const REGISTRY_PATH_ENV = "FEWBIE_REGISTRY_PATH";
|
|
15
|
+
const REGISTRY_CACHE_ENV = "FEWBIE_REGISTRY_CACHE_DIR";
|
|
16
|
+
async function isRegistryRoot(candidate) {
|
|
17
|
+
let entries;
|
|
18
|
+
try {
|
|
19
|
+
entries = await promises_1.default.readdir(candidate, { withFileTypes: true });
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
if (!entry.isDirectory())
|
|
26
|
+
continue;
|
|
27
|
+
const hasItem = await promises_1.default
|
|
28
|
+
.access(node_path_1.default.join(candidate, entry.name, "item.json"))
|
|
29
|
+
.then(() => true)
|
|
30
|
+
.catch(() => false);
|
|
31
|
+
if (hasItem)
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
function assertSafeRef(ref) {
|
|
37
|
+
if (ref.startsWith("-") || /\s/.test(ref)) {
|
|
38
|
+
throw new cli_kit_1.CliError(`Invalid registry ref '${ref}': pass a branch, tag or commit without whitespace.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function registryCacheDir(url) {
|
|
42
|
+
const base = process.env[REGISTRY_CACHE_ENV] ?? node_path_1.default.join(node_os_1.default.homedir(), ".fewbie", "registry");
|
|
43
|
+
const digest = node_crypto_1.default.createHash("sha1").update(url).digest("hex").slice(0, 12);
|
|
44
|
+
return node_path_1.default.join(base, digest);
|
|
45
|
+
}
|
|
46
|
+
async function syncGitRegistry(url, ref) {
|
|
47
|
+
if (ref)
|
|
48
|
+
assertSafeRef(ref);
|
|
49
|
+
const cacheDir = registryCacheDir(url);
|
|
50
|
+
try {
|
|
51
|
+
if (!(await (0, cli_kit_1.pathExists)(node_path_1.default.join(cacheDir, ".git")))) {
|
|
52
|
+
if (await (0, cli_kit_1.pathExists)(cacheDir))
|
|
53
|
+
await promises_1.default.rm(cacheDir, { recursive: true, force: true });
|
|
54
|
+
await promises_1.default.mkdir(node_path_1.default.dirname(cacheDir), { recursive: true });
|
|
55
|
+
await (0, cli_kit_1.execCapture)("git", ["clone", "--quiet", "--depth", "1", url, cacheDir]);
|
|
56
|
+
}
|
|
57
|
+
const revision = ref ?? "HEAD";
|
|
58
|
+
await (0, cli_kit_1.execCapture)("git", ["-C", cacheDir, "fetch", "--quiet", "--depth", "1", "origin", revision]);
|
|
59
|
+
await (0, cli_kit_1.execCapture)("git", ["-C", cacheDir, "checkout", "--quiet", "--force", "FETCH_HEAD"]);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw new cli_kit_1.CliError(`Failed to fetch registry ${url}${ref ? `#${ref}` : ""}: ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
if (!(await isRegistryRoot(cacheDir))) {
|
|
65
|
+
throw new cli_kit_1.CliError(`Registry ${url}${ref ? `#${ref}` : ""} contains no <item>/item.json at its root.`);
|
|
66
|
+
}
|
|
67
|
+
return cacheDir;
|
|
68
|
+
}
|
|
69
|
+
async function resolveRegistryRoot(projectRoot) {
|
|
70
|
+
const override = process.env[REGISTRY_PATH_ENV];
|
|
71
|
+
if (override) {
|
|
72
|
+
const candidate = node_path_1.default.resolve(override);
|
|
73
|
+
if (!(await isRegistryRoot(candidate))) {
|
|
74
|
+
throw new cli_kit_1.CliError(`${REGISTRY_PATH_ENV} '${candidate}' is not a registry root (no <item>/item.json).`);
|
|
75
|
+
}
|
|
76
|
+
return candidate;
|
|
77
|
+
}
|
|
78
|
+
if (projectRoot) {
|
|
79
|
+
const declaration = await (0, modules_file_1.readRegistryDeclaration)(projectRoot);
|
|
80
|
+
if (declaration)
|
|
81
|
+
return syncGitRegistry(declaration.url, declaration.ref);
|
|
82
|
+
}
|
|
83
|
+
const candidates = [
|
|
84
|
+
node_path_1.default.resolve(__dirname, "..", "registry"),
|
|
85
|
+
node_path_1.default.resolve(__dirname, "..", "..", "registry"),
|
|
86
|
+
];
|
|
87
|
+
for (const candidate of candidates) {
|
|
88
|
+
if (await isRegistryRoot(candidate)) {
|
|
89
|
+
return candidate;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
throw new cli_kit_1.CliError("Registry not found (expected dist/registry or registry/).");
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/registry/source.ts"],"names":[],"mappings":";;;;;AAmBA,wCAgBC;AAwDD,kDAyBC;AApHD,8DAAiC;AACjC,gEAAkC;AAClC,sDAAyB;AACzB,0DAA6B;AAE7B,6CAAoE;AACpE,sDAA8D;AAG9D,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AA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;IACF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,MAAM,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;YACpC,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,MAAM,IAAI,kBAAQ,CAAC,2DAA2D,CAAC,CAAC;AAClF,CAAC"}
|
package/dist/registry/store.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export interface LoadedItem {
|
|
|
7
7
|
content?: string;
|
|
8
8
|
}>;
|
|
9
9
|
}
|
|
10
|
-
export declare function resolveRegistryRoot(): Promise<string>;
|
|
11
10
|
export declare function listRegistryItemNames(root: string): Promise<string[]>;
|
|
12
11
|
export declare function readItemFileContent(file: LoadedItem["files"][number]): Promise<string>;
|
|
13
12
|
export declare function loadItem(root: string, name: string): Promise<LoadedItem>;
|
package/dist/registry/store.js
CHANGED
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveRegistryRoot = resolveRegistryRoot;
|
|
7
6
|
exports.listRegistryItemNames = listRegistryItemNames;
|
|
8
7
|
exports.readItemFileContent = readItemFileContent;
|
|
9
8
|
exports.loadItem = loadItem;
|
|
@@ -11,38 +10,6 @@ exports.resolveInstallSet = resolveInstallSet;
|
|
|
11
10
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
12
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
12
|
const cli_kit_1 = require("@devbie/cli-kit");
|
|
14
|
-
async function isRegistryRoot(candidate) {
|
|
15
|
-
let entries;
|
|
16
|
-
try {
|
|
17
|
-
entries = await promises_1.default.readdir(candidate, { withFileTypes: true });
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
for (const entry of entries) {
|
|
23
|
-
if (!entry.isDirectory())
|
|
24
|
-
continue;
|
|
25
|
-
const hasItem = await promises_1.default
|
|
26
|
-
.access(node_path_1.default.join(candidate, entry.name, "item.json"))
|
|
27
|
-
.then(() => true)
|
|
28
|
-
.catch(() => false);
|
|
29
|
-
if (hasItem)
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
async function resolveRegistryRoot() {
|
|
35
|
-
const candidates = [
|
|
36
|
-
node_path_1.default.resolve(__dirname, "..", "registry"),
|
|
37
|
-
node_path_1.default.resolve(__dirname, "..", "..", "registry"),
|
|
38
|
-
];
|
|
39
|
-
for (const candidate of candidates) {
|
|
40
|
-
if (await isRegistryRoot(candidate)) {
|
|
41
|
-
return candidate;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
throw new cli_kit_1.CliError("Registry not found (expected dist/registry or registry/).");
|
|
45
|
-
}
|
|
46
13
|
async function readItemFile(root, name) {
|
|
47
14
|
const raw = await promises_1.default.readFile(node_path_1.default.join(root, name, "item.json"), "utf8");
|
|
48
15
|
return JSON.parse(raw);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/registry/store.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/registry/store.ts"],"names":[],"mappings":";;;;;AAmBA,sDAYC;AAGD,kDAEC;AAoBD,4BA8BC;AAMD,8CA+BC;AA3HD,gEAAkC;AAClC,0DAA6B;AAE7B,6CAA2C;AAU3C,KAAK,UAAU,YAAY,CAAC,IAAY,EAAE,IAAY;IACpD,MAAM,GAAG,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,mBAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;IAC1E,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAyC,CAAC;AACjE,CA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AAG,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/r/registry-item.json",
|
|
3
|
-
"name": "api-client",
|
|
4
|
-
"type": "registry:lib",
|
|
5
|
-
"title": "API client",
|
|
6
|
-
"description": "Envelope-aware axios instance with bearer-token auth in memory (no localStorage), httpOnly refresh-cookie rotation, cold-start session bootstrap that tells a signed-out user, a blocked account and an unreachable backend apart, cross-tab Web Lock single-flight 401 retry, proactive token refresh, ADR-048 coded auth-failure classification (SessionFailureKind / CODE_TO_KIND), and UI-agnostic onError/onSessionExpired hooks.",
|
|
7
|
-
"dependencies": [
|
|
8
|
-
"axios@^1.20.0"
|
|
9
|
-
],
|
|
10
|
-
"postInstall": "Call bootstrapSession() from your entry route and branch on its status: authenticated -> render the app, anonymous -> send to login, unavailable -> stay on the page with a retry (an unreachable backend is not a logout; fewbie ADR-001 / devbie ADR-040). Adjust BASE_URL / legacy storage keys / REFRESH_PATH / REFRESH_LOCK_NAME in src/lib/api-client.ts to match your backend contract.",
|
|
11
|
-
"files": [
|
|
12
|
-
{
|
|
13
|
-
"path": "src/lib/api-client.ts",
|
|
14
|
-
"content": "import axios, { type AxiosRequestConfig, type AxiosResponse, type InternalAxiosRequestConfig } from \"axios\";\n\n/**\n * Per-request opt-out for the framework's default error toast.\n *\n * By default every failed request surfaces the backend error via the\n * `onError` hook (currently wired to `toast.error` in request.ts). Set\n * `enabledDefaultErrorToast: false` when the caller renders its own richer\n * error UX (a confirm dialog, an inline form error, ...) so the same\n * failure is not surfaced twice. Defaults to true for backward safety.\n */\ndeclare module \"axios\" {\n interface AxiosRequestConfig {\n enabledDefaultErrorToast?: boolean;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Project-specific configuration — edit these for your backend contract.\n// ---------------------------------------------------------------------------\n\n/** Base URL of the API; same-origin by default. */\nconst BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL ?? \"\";\n\n/**\n * Legacy localStorage keys retired by ADR-040 (access token moved to memory).\n * Still referenced so startup can scrub values left behind by older sessions.\n */\nconst LEGACY_ACCESS_TOKEN_KEY = \"access-token\";\nconst LEGACY_ACCESS_TOKEN_EXPIRES_AT_KEY = \"access-token-expires-at\";\n\n/** Endpoint that exchanges the httpOnly refresh cookie for a new access token. */\nconst REFRESH_PATH = \"/auth/refresh-access-token\";\n\n/** Paths that must never trigger a silent refresh (would recurse). */\nconst AUTH_PATH_PATTERN = /^\\/auth\\//;\n\n/**\n * Hard ceiling for every API request, including the refresh exchange. Without\n * it a hung request (or a refresh that never settles) keeps `refreshPromise`\n * locked forever and every later 401 waits on it (R5-P2-13).\n */\nconst API_TIMEOUT_MS = 15_000;\n\n/** Cross-tab Web Lock that serializes refresh calls (see fewbie ADR-001). */\nconst REFRESH_LOCK_NAME = \"refresh-token\";\n\n/** Refresh this early so business requests never carry an expired token. */\nconst PROACTIVE_REFRESH_LEAD_MS = 60_000;\n\n/** How often the proactive scheduler checks expiry. */\nconst PROACTIVE_REFRESH_CHECK_INTERVAL_MS = 30_000;\n\n/**\n * Pause before retrying a failed refresh. When another tab rotates the\n * refresh cookie, the Set-Cookie reaches this tab a moment later; the retry\n * then carries the renewed cookie.\n */\nconst REFRESH_RETRY_DELAY_MS = 1_500;\n\n/**\n * Pause before the single cold-start retry. A tab that just regained network\n * (wifi rejoin, VPN up, laptop wake) normally succeeds on the second try, and\n * a longer wait would only delay the connection-error screen.\n */\nconst BOOTSTRAP_RETRY_DELAY_MS = 400;\n\n// ---------------------------------------------------------------------------\n// Response envelope (newbie backend contract)\n// ---------------------------------------------------------------------------\n\n/**\n * Standard JSON envelope: success is `{ code: 0, error: null, data }` and\n * failure is a non-2xx status with `{ code, error: { message }, data: null }`.\n */\nexport interface ApiEnvelope<T = unknown> {\n data?: T;\n code?: number;\n error?: { message?: string; description?: string } | null;\n}\n\n/** Whether a response body is a newbie envelope rather than a raw payload. */\nfunction isEnvelope(body: unknown): body is ApiEnvelope {\n if (body === null || typeof body !== \"object\") return false;\n if (Array.isArray(body)) return false;\n const record = body as Record<string, unknown>;\n // Every envelope carries both markers; a domain object that happens to\n // have a `data` field alone is not unwrapped.\n return \"code\" in record && \"data\" in record;\n}\n\n// ---------------------------------------------------------------------------\n// Auth failure classification (devbie ADR-048 §3–§4)\n// ---------------------------------------------------------------------------\n\n/**\n * Wire codes of the auth failure contract (devbie ADR-048 §3). They are\n * duplicated as numeric literals because this module runs in the browser and\n * cannot import the NestJS-side enum. The numbers are the wire contract and\n * never change; the member names here are local and may be renamed freely.\n */\nexport const AUTH_FAILURE_CODES = {\n Credential_Invalid: 1001,\n Credential_NotSet: 1002,\n Login_UserRateLimited: 1003,\n Login_IpRateLimited: 1004,\n ResetPassword_InvalidInput: 1005,\n ResetPassword_InvalidCode: 1006,\n Account_Closed: 1007,\n Account_Disabled: 1008,\n Account_Missing: 1101,\n Session_RefreshRejected: 1102,\n Session_AccessExpired: 1103,\n Session_Revoked: 1104,\n Session_Missing: 1105,\n Request_RateLimited: 2001,\n} as const;\n\nexport type AuthFailureCode = (typeof AUTH_FAILURE_CODES)[keyof typeof AUTH_FAILURE_CODES];\n\n/**\n * What a failed request means for the page and the session (ADR-048 §4).\n * Only `network` may block the whole page; every other kind is a\n * request-level error or an explicit redirect.\n */\nexport type SessionFailureKind =\n | \"network\"\n | \"account-blocked\"\n | \"session-terminated\"\n | \"access-expired\"\n | \"request-error\"\n | \"server-error\"\n | \"permission-denied\"\n | \"unknown\";\n\n/**\n * Explicit many-to-one code → kind map (ADR-048 §4). It cannot be derived\n * from the code list: four codes share `session-terminated` and seven share\n * `request-error` by design. `Record<AuthFailureCode, …>` makes the map\n * exhaustive — adding a code without a kind fails the build.\n */\nexport const CODE_TO_KIND: Record<AuthFailureCode, SessionFailureKind> = {\n [AUTH_FAILURE_CODES.Credential_Invalid]: \"request-error\",\n [AUTH_FAILURE_CODES.Credential_NotSet]: \"request-error\",\n [AUTH_FAILURE_CODES.Login_UserRateLimited]: \"request-error\",\n [AUTH_FAILURE_CODES.Login_IpRateLimited]: \"request-error\",\n [AUTH_FAILURE_CODES.ResetPassword_InvalidInput]: \"request-error\",\n [AUTH_FAILURE_CODES.ResetPassword_InvalidCode]: \"request-error\",\n [AUTH_FAILURE_CODES.Account_Closed]: \"account-blocked\",\n [AUTH_FAILURE_CODES.Account_Disabled]: \"account-blocked\",\n [AUTH_FAILURE_CODES.Account_Missing]: \"session-terminated\",\n [AUTH_FAILURE_CODES.Session_RefreshRejected]: \"session-terminated\",\n [AUTH_FAILURE_CODES.Session_AccessExpired]: \"access-expired\",\n [AUTH_FAILURE_CODES.Session_Revoked]: \"session-terminated\",\n [AUTH_FAILURE_CODES.Session_Missing]: \"session-terminated\",\n [AUTH_FAILURE_CODES.Request_RateLimited]: \"request-error\",\n};\n\nconst AUTH_FAILURE_CODE_SET = new Set<number>(Object.values(AUTH_FAILURE_CODES));\n\nfunction isAuthFailureCode(code: number | undefined): code is AuthFailureCode {\n return typeof code === \"number\" && AUTH_FAILURE_CODE_SET.has(code);\n}\n\n/**\n * Classify a failed request in the order fixed by ADR-048 §4 — the order is\n * part of the contract and the first match wins:\n *\n * 1. no HTTP response → `network`\n * 2. a contract code → its mapped kind\n * 3. 5xx → `server-error`\n * 4. uncoded 403 → `permission-denied`\n * 5. uncoded 401 → `session-terminated` (fail closed: it cannot be\n * refreshed, and calling it `unknown` would revive\n * the refresh → 401 loop this contract removes)\n * 6. any other uncoded 4xx → `unknown`\n */\nexport function classifyFailure(status: number, code?: number): SessionFailureKind {\n if (status === 0) return \"network\";\n if (isAuthFailureCode(code)) return CODE_TO_KIND[code];\n if (status >= 500) return \"server-error\";\n if (status === 403) return \"permission-denied\";\n if (status === 401) return \"session-terminated\";\n return \"unknown\";\n}\n\n/** Whether a silent refresh may be attempted for this 401 (ADR-048 §3). */\nfunction isRefreshable(kind: SessionFailureKind): boolean {\n return kind === \"access-expired\";\n}\n\n// ---------------------------------------------------------------------------\n// Token storage\n// ---------------------------------------------------------------------------\n\n/**\n * ADR-040: the access token lives only in this module's memory, never in\n * localStorage. A same-origin script can still read it for the current page\n * lifetime, but nothing survives a reload or leaves the tab, so one injection\n * no longer equals a durable, off-site reusable session. A cold start (or a\n * new tab) re-establishes the session by exchanging the httpOnly refresh\n * cookie via `bootstrapSession`.\n */\nlet accessToken = \"\";\n/** Expiry epoch of the in-memory token in milliseconds (0 when unknown). */\nlet accessTokenExpiresAt = 0;\nlet legacyKeysCleared = false;\n\n/** Scrub the retired localStorage keys left behind by older sessions. */\nfunction clearLegacyStorage(): void {\n if (typeof window === \"undefined\" || legacyKeysCleared) return;\n legacyKeysCleared = true;\n window.localStorage.removeItem(LEGACY_ACCESS_TOKEN_KEY);\n window.localStorage.removeItem(LEGACY_ACCESS_TOKEN_EXPIRES_AT_KEY);\n}\n\n// Scrub on module init so a stale token does not linger in a browser that\n// never reaches login or bootstrap in this page lifetime.\nif (typeof window !== \"undefined\") clearLegacyStorage();\n\nexport function getAccessToken(): string {\n if (typeof window === \"undefined\") return \"\";\n return accessToken;\n}\n\n/** Persist token + expiry after login or refresh (memory only). */\nexport function setSession(token: string, expiresInSeconds?: number): void {\n if (typeof window === \"undefined\") return;\n clearLegacyStorage();\n accessToken = token;\n // A fresh session re-arms the session-expired notification (R22-06).\n sessionExpiredNotified = false;\n accessTokenExpiresAt =\n typeof expiresInSeconds === \"number\" && expiresInSeconds > 0 ? Date.now() + expiresInSeconds * 1000 : 0;\n}\n\n/** Remove all locally held session data. */\nexport function clearSession(): void {\n if (typeof window === \"undefined\") return;\n accessToken = \"\";\n accessTokenExpiresAt = 0;\n clearLegacyStorage();\n}\n\n// Fires at most once per session: after the first notification the user is on\n// their way to the login page, so repeat calls (concurrent 401s, or the SSE\n// and axios paths racing) must not stack redirects (R22-06). setSession()\n// re-arms it.\nlet sessionExpiredNotified = false;\n\n/**\n * Why the session ended: a dead session goes to the plain login page, while a\n * disabled/closed account must land on the login page's notice banner\n * (ADR-048 §4).\n */\nexport type SessionEndReason = \"session-terminated\" | \"account-blocked\";\n\n/**\n * Fire the session-expired handler directly. Used by non-axios transports\n * (raw fetch for SSE streams) that can't go through the response interceptor\n * but still need the same \"refresh cookie gone → bounce to login\" path.\n */\nexport function triggerSessionExpired(reason: SessionEndReason = \"session-terminated\"): void {\n if (sessionExpiredNotified) return;\n sessionExpiredNotified = true;\n sessionExpiredHandler?.(reason);\n}\n\n/** Normalized error so callers never depend on the axios error shape. */\nexport class ApiError extends Error {\n readonly status: number;\n readonly code?: number;\n /** Page/session consequence of this failure (ADR-048 §4). */\n readonly kind: SessionFailureKind;\n readonly data: unknown;\n\n constructor(message: string, status: number, data?: unknown, code?: number) {\n super(message);\n this.name = \"ApiError\";\n this.status = status;\n this.code = code;\n this.kind = classifyFailure(status, code);\n this.data = data;\n }\n}\n\n/**\n * Hook invoked when the refresh cookie is missing/expired or the account\n * cannot continue. Wire it to your router (e.g. redirect to the login page);\n * the client itself stays router-agnostic.\n */\nlet sessionExpiredHandler: ((reason: SessionEndReason) => void) | null = null;\nexport function onSessionExpired(handler: (reason: SessionEndReason) => void): void {\n sessionExpiredHandler = handler;\n}\n\n/**\n * Hooks invoked exactly once per failed request, after any 401 refresh/replay\n * attempt has been exhausted. Wire them to your toast layer; the client itself\n * never imports a UI library.\n *\n * Subscribers are a Set rather than a single slot: a second mount (Strict Mode,\n * or a nested host) must not silently replace the first listener (R27-01).\n */\nconst errorHandlers = new Set<(error: ApiError) => void>();\n\n/**\n * Failures raised before any subscriber is registered (a request fired during\n * module init, ahead of the toast component's effect). They are replayed to the\n * first subscriber so such failures are not lost; bounded so a permanently\n * subscriber-less client cannot grow without limit.\n */\nconst pendingErrors: ApiError[] = [];\nconst MAX_PENDING_ERRORS = 5;\n\n/**\n * Register an error listener and return the unsubscribe function. Registering\n * flushes any failure buffered before the first listener existed.\n */\nexport function onError(handler: (error: ApiError) => void): () => void {\n errorHandlers.add(handler);\n if (pendingErrors.length > 0) {\n for (const error of pendingErrors.splice(0)) handler(error);\n }\n return () => {\n errorHandlers.delete(handler);\n };\n}\n\n/** Fan a failed request out to every subscriber, or buffer it until one exists. */\nfunction notifyError(error: ApiError): void {\n if (errorHandlers.size === 0) {\n if (pendingErrors.length >= MAX_PENDING_ERRORS) pendingErrors.shift();\n pendingErrors.push(error);\n return;\n }\n for (const handler of errorHandlers) handler(error);\n}\n\n// ---------------------------------------------------------------------------\n// Refresh-token rotation\n// ---------------------------------------------------------------------------\n\nfunction isUnauthorized(error: unknown): boolean {\n return axios.isAxiosError(error) && error.response?.status === 401;\n}\n\n/**\n * Whether the access token is still due for a refresh. After acquiring the\n * cross-tab lock, another tab may have already refreshed while we waited;\n * this check lets us skip the network call and reuse the new token.\n */\nfunction isRefreshStillDue(): boolean {\n if (!accessTokenExpiresAt) return true;\n return Date.now() >= accessTokenExpiresAt - PROACTIVE_REFRESH_LEAD_MS;\n}\n\n/** One refresh round-trip; persists the renewed token and its expiry. */\nasync function requestRefreshOnce(): Promise<string | null> {\n const response = await axios.get(`${BASE_URL}${REFRESH_PATH}`, {\n withCredentials: true,\n timeout: API_TIMEOUT_MS,\n });\n const body = response.data as ApiEnvelope<{\n token?: string;\n tokenExpiresInSeconds?: number;\n }>;\n const token = body?.data?.token ?? \"\";\n if (!token) return null;\n setSession(token, body.data?.tokenExpiresInSeconds);\n return token;\n}\n\n/**\n * Outcome of one refresh attempt: the renewed token plus whether the session\n * is definitively over.\n */\nexport interface RefreshOutcome {\n token: string | null;\n /**\n * True only when the server rejected the refresh exchange (401/400), the\n * account is blocked (coded 403), or a 2xx response carried no token — i.e.\n * the refresh credential can never succeed. Network errors and 5xx are\n * transient: the session must be kept and the caller surfaces the original\n * failure instead of forcing a logout (R22-05).\n */\n sessionOver: boolean;\n /** Why the session ended; undefined while it is still alive (ADR-048). */\n kind?: SessionEndReason;\n}\n\n/** Send the refresh request with one retry on 401 (cross-tab cookie race). */\nasync function requestRefreshWithRetry(): Promise<RefreshOutcome> {\n const classify = (error: unknown): RefreshOutcome => {\n if (!axios.isAxiosError(error)) return { token: null, sessionOver: false };\n const status = error.response?.status ?? 0;\n const body = error.response?.data as ApiEnvelope | undefined;\n const kind = classifyFailure(status, body?.code);\n // A disabled or closed account is a definitive end, but a distinct one:\n // the login page shows the account notice instead of a plain form.\n if (kind === \"account-blocked\") return { token: null, sessionOver: true, kind };\n // Any 401 from the refresh exchange, and a 400 on its input, means the\n // refresh credential can never succeed — a retry cannot fix it.\n if (status === 401 || status === 400) return { token: null, sessionOver: true, kind: \"session-terminated\" };\n // Offline, timeout, 5xx: transient, the session survives (R22-05).\n return { token: null, sessionOver: false };\n };\n try {\n const token = await requestRefreshOnce();\n return { token, sessionOver: token === null };\n } catch (firstError) {\n if (isUnauthorized(firstError)) {\n // Possible cross-tab rotation race: retry once with the renewed cookie.\n await new Promise((resolve) => setTimeout(resolve, REFRESH_RETRY_DELAY_MS));\n try {\n const token = await requestRefreshOnce();\n return { token, sessionOver: token === null };\n } catch (secondError) {\n return classify(secondError);\n }\n }\n // Network or other non-auth failure: nothing a retry can fix.\n return classify(firstError);\n }\n}\n\n// Shared in-flight refresh. The backend rotates the refresh cookie on every\n// call, so concurrent 401s must await the same request instead of issuing\n// parallel refreshes that invalidate each other's cookie.\nlet refreshPromise: Promise<RefreshOutcome> | null = null;\n/** Whether the in-flight refresh was started with force=true (R20-12). */\nlet refreshPromiseForced = false;\n\n/**\n * Exchange the httpOnly refresh cookie for a new access token.\n *\n * Two layers of dedup prevent concurrent refresh calls that would trigger\n * the backend's refresh-token-reuse detection and revoke the session:\n * 1. Single-tab: module-level refreshPromise — concurrent 401s in this tab\n * reuse the same promise.\n * 2. Cross-tab: Web Locks (navigator.locks) serialize refreshes across tabs.\n * After acquiring the lock, re-check whether refresh is still needed.\n * Pass force=true from the 401 reactive path: a 401 proves the token is\n * invalid regardless of the stored expiry, so the lock-time re-check must\n * not short-circuit. A forced caller must not ride a non-forced in-flight\n * refresh either — that promise may resolve through the not-due shortcut\n * with a token the server already rejects — so it chains a forced refresh\n * after the in-flight one instead (R20-12). Environments without Web Locks\n * fall back to the single-flight + retry mitigation.\n *\n * Exported so non-axios transports (raw fetch for SSE streams) can also\n * participate in the 401 silent-refresh chain. The outcome distinguishes a\n * dead refresh credential (`sessionOver`) from a transient failure, so\n * callers only end the session on the former (R22-05).\n */\nexport function refreshAccessToken(force = false): Promise<RefreshOutcome> {\n if (refreshPromise) {\n if (!force || refreshPromiseForced) return refreshPromise;\n return refreshPromise.then((outcome) => (outcome.sessionOver ? outcome : refreshAccessToken(true)));\n }\n\n refreshPromiseForced = force;\n refreshPromise = (async (): Promise<RefreshOutcome> => {\n try {\n if (typeof navigator !== \"undefined\" && navigator.locks) {\n let acquired = false;\n try {\n return await navigator.locks.request(REFRESH_LOCK_NAME, async () => {\n acquired = true;\n if (!force && !isRefreshStillDue()) return { token: getAccessToken(), sessionOver: false };\n return requestRefreshWithRetry();\n });\n } catch (error) {\n // Acquisition can fail for reasons other than contention: a document\n // that is not fully active (prerender, bfcache, unloading) rejects\n // the lock request outright. Every acquisition failure must fall\n // back to the unlocked exchange — otherwise the rejection escapes\n // bootstrapSession, whose callers only handle the outcome states,\n // and the cold start hangs instead of reaching login.\n if (!acquired) return requestRefreshWithRetry();\n throw error;\n }\n }\n // The await matters: without it the finally below runs at construction\n // time and refreshPromise would keep the settled outcome forever, so\n // no-locks environments could never refresh again (R20-12).\n return await requestRefreshWithRetry();\n } finally {\n refreshPromise = null;\n refreshPromiseForced = false;\n }\n })();\n\n return refreshPromise;\n}\n\n/**\n * Result of establishing the in-memory session on a cold start (ADR-040).\n *\n * The states matter because \"the backend said no\" and \"the backend could not\n * be reached\" lead to opposite UI decisions: the first is a real logout, the\n * second must keep the user on the page (R22-05). `blocked` is the third\n * outcome of a real logout: the account itself is disabled or closed, so the\n * login page must show that notice instead of a plain form (ADR-048 §4).\n */\nexport type SessionBootstrapOutcome =\n | { status: \"authenticated\"; token: string }\n | { status: \"anonymous\" }\n | { status: \"blocked\" }\n | { status: \"unavailable\" };\n\n/** Signed out vs. account blocked: both end the session, differently (§4). */\nfunction sessionEndedOutcome(outcome: RefreshOutcome): SessionBootstrapOutcome {\n return outcome.kind === \"account-blocked\" ? { status: \"blocked\" } : { status: \"anonymous\" };\n}\n\n/**\n * Establish the in-memory session on a cold start or a new tab (ADR-040).\n *\n * The access token is no longer persisted, so \"am I signed in?\" can only be\n * answered by exchanging the httpOnly refresh cookie. A forced refresh is\n * used so the lock-time not-due shortcut cannot return an empty token, and it\n * shares the single-flight promise with any 401 refresh already in flight, so\n * a cold start rotates the refresh cookie exactly once.\n *\n * A rejected exchange (401/400 or a 2xx without a token) means anonymous. A\n * transient failure is retried once — that absorbs the \"network just came\n * back\" window — and only then reported as unavailable, so a flaky connection\n * never masquerades as a signed-out user.\n */\nexport async function bootstrapSession(): Promise<SessionBootstrapOutcome> {\n if (typeof window === \"undefined\") return { status: \"unavailable\" };\n const existing = getAccessToken();\n if (existing) return { status: \"authenticated\", token: existing };\n\n const outcome = await refreshAccessToken(true);\n if (outcome.token) return { status: \"authenticated\", token: outcome.token };\n if (outcome.sessionOver) return sessionEndedOutcome(outcome);\n\n await new Promise((resolve) => setTimeout(resolve, BOOTSTRAP_RETRY_DELAY_MS));\n const retried = await refreshAccessToken(true);\n if (retried.token) return { status: \"authenticated\", token: retried.token };\n return retried.sessionOver ? sessionEndedOutcome(retried) : { status: \"unavailable\" };\n}\n\n/** Read the failure kind from a raw fetch response without consuming it. */\nasync function failureKindOfResponse(response: Response): Promise<SessionFailureKind> {\n try {\n const body = (await response.clone().json()) as ApiEnvelope;\n return classifyFailure(response.status, body?.code);\n } catch {\n // Non-JSON body (empty 401, gateway page): classify on the status alone,\n // which keeps an unrecognized 401 failing closed.\n return classifyFailure(response.status);\n }\n}\n\n/**\n * Shared 401 handling for non-axios transports (raw fetch for SSE streams):\n * refresh only an expired access token, then replay once with the renewed\n * token. The session ends when the refresh credential is dead or the 401 is\n * not refreshable; a transient refresh failure keeps the session and hands the\n * original 401 back to the caller (R22-05, R23-06, ADR-048 §4).\n */\nexport async function replayOnUnauthorized(\n response: Response,\n replay: (token: string) => Promise<Response>,\n): Promise<Response> {\n if (response.status !== 401) return response;\n // Only an expired access token may be refreshed (ADR-048 §3); every other\n // 401 — including a code this build does not know — ends the session.\n if (!isRefreshable(await failureKindOfResponse(response))) {\n clearSession();\n triggerSessionExpired(\"session-terminated\");\n return response;\n }\n const outcome = await refreshAccessToken(true);\n if (outcome.token) return replay(outcome.token);\n if (outcome.sessionOver) {\n // Dead refresh credential: same session-end path as the axios interceptor.\n clearSession();\n triggerSessionExpired(outcome.kind ?? \"session-terminated\");\n }\n return response;\n}\n\n// ---------------------------------------------------------------------------\n// Proactive refresh scheduler (module-level singleton)\n// ---------------------------------------------------------------------------\n\nlet schedulerTimer: ReturnType<typeof setInterval> | null = null;\n\n/**\n * Start the scheduler that renews the token shortly before expiry. Call once\n * on the client (e.g. in the authenticated layout). Reactive 401 refresh\n * stays as a fallback for laptop sleep / scheduler drift.\n */\nexport function initProactiveTokenRefresh(): void {\n if (typeof window === \"undefined\" || schedulerTimer) return;\n\n const refreshIfDue = (): void => {\n const token = getAccessToken();\n if (!token) return;\n // A session without a known expiry (a provider that omitted expiresIn)\n // still needs renewal: refresh now and persist the expiry the backend\n // returns, instead of never scheduling a refresh.\n if (!accessTokenExpiresAt || Date.now() >= accessTokenExpiresAt - PROACTIVE_REFRESH_LEAD_MS) {\n void refreshAccessToken().then((outcome) => {\n // A dead refresh cookie found proactively bounces to login now\n // instead of waiting for the next business request to 401 (R22-05).\n if (outcome.sessionOver) {\n clearSession();\n triggerSessionExpired(outcome.kind ?? \"session-terminated\");\n }\n });\n }\n };\n\n // Run immediately (tabs reopened after sleep) and then on an interval.\n refreshIfDue();\n schedulerTimer = setInterval(refreshIfDue, PROACTIVE_REFRESH_CHECK_INTERVAL_MS);\n}\n\n// ---------------------------------------------------------------------------\n// Error normalization (the single failure channel)\n// ---------------------------------------------------------------------------\n\n/** Map any thrown value to the normalized ApiError shape. */\nfunction toApiError(error: unknown): ApiError {\n if (error instanceof ApiError) return error;\n if (axios.isAxiosError(error)) {\n const body = error.response?.data as ApiEnvelope | undefined;\n return new ApiError(\n body?.error?.message ?? error.message,\n error.response?.status ?? 0,\n body ?? error.response?.data,\n body?.code,\n );\n }\n if (error instanceof Error) return new ApiError(error.message, 0);\n return new ApiError(\"Request failed\", 0);\n}\n\n// ---------------------------------------------------------------------------\n// Axios instance\n// ---------------------------------------------------------------------------\n\nexport const api = axios.create({\n baseURL: BASE_URL,\n withCredentials: true,\n timeout: API_TIMEOUT_MS,\n});\n\n/**\n * Absolute URL: either scheme-qualified (`https://host/...`) or protocol-relative\n * (`//host/...`), both of which resolve away from the page origin.\n */\nconst ABSOLUTE_URL_PATTERN = /^(?:[a-z][a-z\\d+\\-.]*:|\\/\\/)/i;\n\nfunction pageOrigin(): string {\n return typeof window !== \"undefined\" ? window.location.origin : \"http://localhost\";\n}\n\n/**\n * Whether a request target resolves to the one origin we may send the bearer\n * token to: the origin of `NEXT_PUBLIC_BASE_URL` when it is absolute, or the\n * page origin when it is relative/empty (the reverse-proxied deployment).\n *\n * Two leaks this closes:\n * - an absolute per-request URL pointing at a third party (R23-02);\n * - a caller-supplied base URL pointing off-site, which the previous check\n * accepted because it compared the target against that same base — so the\n * raw-fetch SSE transports bypassing axios had no working guard at all\n * (R24-04).\n *\n * A relative base such as `/api` must count as our own origin: `new URL(url,\n * \"/api\")` throws, and the old guard swallowed the throw and silently dropped\n * the token on every request.\n *\n * Exported so non-axios transports apply the same judgement instead of a\n * second copy.\n */\nexport function isTrustedApiTarget(url: string | undefined, baseUrl: string | undefined = BASE_URL): boolean {\n const origin = pageOrigin();\n const configured = BASE_URL;\n const base = baseUrl ?? configured;\n const target = ABSOLUTE_URL_PATTERN.test(url ?? \"\") ? (url ?? \"\") : `${base}${url ?? \"\"}`;\n try {\n const trustedOrigin = ABSOLUTE_URL_PATTERN.test(configured) ? new URL(configured).origin : origin;\n return new URL(target, origin).origin === trustedOrigin;\n } catch {\n return false;\n }\n}\n\napi.interceptors.request.use((config) => {\n const token = getAccessToken();\n // Within the interceptor chain headers is always an AxiosHeaders instance.\n if (token && isTrustedApiTarget(config.url, config.baseURL ?? BASE_URL)) {\n config.headers.set(\"Authorization\", `Bearer ${token}`);\n }\n return config;\n});\n\n/**\n * Request config fields owned by the response interceptor.\n *\n * `_retriedAfterRefresh` marks a request that already went through the silent\n * refresh + replay chain once, so a second 401 does not recurse.\n */\ntype RotatingRequestConfig = InternalAxiosRequestConfig & {\n _retriedAfterRefresh?: boolean;\n};\n\n// Success channel: only unwrap the envelope; failures never arrive here\n// (they carry non-2xx status — see newbie ADR-001).\napi.interceptors.response.use(\n (response) => {\n if (isEnvelope(response.data)) {\n return { ...response, data: response.data.data };\n }\n return response;\n },\n async (error) => {\n const original = error?.config as RotatingRequestConfig | undefined;\n const url: string = original?.url ?? \"\";\n const canSilentlyRefresh =\n typeof window !== \"undefined\" && !original?._retriedAfterRefresh && !AUTH_PATH_PATTERN.test(url);\n\n // Single normalization for every final failure: the kind decides both the\n // refresh policy and what the UI shows (ADR-048 §4).\n const normalized = toApiError(error);\n\n if (isUnauthorized(error) && original && canSilentlyRefresh) {\n if (isRefreshable(normalized.kind)) {\n original._retriedAfterRefresh = true;\n const outcome = await refreshAccessToken(true);\n if (outcome.token) {\n original.headers.set(\"Authorization\", `Bearer ${outcome.token}`);\n // Replay goes through the same interceptor chain; its outcome is\n // returned directly so this failure never reaches the handler.\n return api(original);\n }\n if (outcome.sessionOver) {\n // The server rejected the refresh credential: the session is over.\n clearSession();\n triggerSessionExpired(outcome.kind ?? \"session-terminated\");\n // This request failed because the session was already gone; the user\n // is being bounced to the login page, so its message is noise\n // (R21-01). Suppress it through the public per-request opt-out rather\n // than a private marker — one suppression concept, not two (R22-01).\n original.enabledDefaultErrorToast = false;\n }\n // Transient refresh failure (offline/5xx): keep the session and let the\n // original 401 surface normally (R22-05).\n } else {\n // A terminal 401, or a code this build does not recognize: fail closed\n // instead of refreshing into another 401 (ADR-048 INV-4).\n clearSession();\n triggerSessionExpired(\"session-terminated\");\n original.enabledDefaultErrorToast = false;\n }\n } else if (normalized.kind === \"account-blocked\") {\n // A disabled/closed account on any request (including the refresh\n // exchange): same end state, but the login page must show the notice.\n clearSession();\n triggerSessionExpired(\"account-blocked\");\n if (original) original.enabledDefaultErrorToast = false;\n } else if (normalized.kind === \"session-terminated\" && !AUTH_PATH_PATTERN.test(url)) {\n // A terminal 401 from a non-axios-flagged path (e.g. the request already\n // replayed once): the session cannot be revived.\n clearSession();\n triggerSessionExpired(\"session-terminated\");\n if (original) original.enabledDefaultErrorToast = false;\n }\n\n // Callers that render their own error UX pass enabledDefaultErrorToast:\n // false to suppress the default toast and avoid double notification.\n if (error?.config?.enabledDefaultErrorToast !== false) {\n notifyError(normalized);\n }\n throw normalized;\n },\n);\n\n// ---------------------------------------------------------------------------\n// Typed convenience methods — resolve to the unwrapped response body.\n// ---------------------------------------------------------------------------\n\nexport const apiClient = {\n get<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n return api.get<unknown, AxiosResponse<T>>(url, config).then((r) => r.data);\n },\n post<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T> {\n return api.post<unknown, AxiosResponse<T>>(url, data, config).then((r) => r.data);\n },\n put<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T> {\n return api.put<unknown, AxiosResponse<T>>(url, data, config).then((r) => r.data);\n },\n patch<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T> {\n return api.patch<unknown, AxiosResponse<T>>(url, data, config).then((r) => r.data);\n },\n delete<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n return api.delete<unknown, AxiosResponse<T>>(url, config).then((r) => r.data);\n },\n // HEAD/OPTIONS responses carry no body; resolve to the full AxiosResponse\n // so callers can still inspect status and headers.\n head<T>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {\n return api.head<unknown, AxiosResponse<T>>(url, config);\n },\n options<T>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>> {\n return api.options<unknown, AxiosResponse<T>>(url, config);\n },\n};\n",
|
|
15
|
-
"type": "registry:lib"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/r/registry-item.json",
|
|
3
|
-
"name": "app-shell",
|
|
4
|
-
"type": "registry:block",
|
|
5
|
-
"title": "Collapsible app shell",
|
|
6
|
-
"description": "Collapsible sidebar primitives (240px/64px rail, collapsed tooltips, hover flyout menus, persisted collapse state via an external store) plus a minimal nav-array-driven AppShell skeleton.",
|
|
7
|
-
"postInstall": "Run `npx shadcn add popover tooltip` (required ui primitives), fill NAV_ITEMS in src/components/app-shell/app-shell.tsx with your own navigation, and render <AppShell> from your authenticated layout. If you build your own shell from sidebar-chrome.tsx primitives instead of using <AppShell>, wrap it in a TooltipProvider (exported by the shadcn tooltip primitive). Rename DEFAULT_SIDEBAR_COLLAPSED_STORAGE_KEY in sidebar-chrome.tsx if you want a project-specific localStorage namespace.",
|
|
8
|
-
"files": [
|
|
9
|
-
{
|
|
10
|
-
"path": "src/components/app-shell/sidebar-chrome.tsx",
|
|
11
|
-
"content": "\"use client\";\n\nimport * as React from \"react\";\nimport Link from \"next/link\";\nimport { usePathname } from \"next/navigation\";\nimport { ArrowLeft, PanelLeftClose, PanelLeftOpen, type LucideIcon } from \"lucide-react\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@/components/ui/tooltip\";\nimport { cn } from \"cn\";\n\nexport const DEFAULT_SIDEBAR_COLLAPSED_STORAGE_KEY = \"app-shell:sidebar-collapsed\";\n\n// External stores keyed by storage key, so every sidebar shell sharing a key\n// shares one preference without setState-in-effect hydration churn. Sidebars\n// render expanded on the server; the stored value is applied after hydration.\ninterface SidebarCollapsedStore {\n subscribe: (callback: () => void) => () => void;\n getSnapshot: () => boolean;\n set: (value: boolean) => void;\n}\n\nconst collapsedStores = new Map<string, SidebarCollapsedStore>();\n\nfunction getCollapsedStore(storageKey: string): SidebarCollapsedStore {\n const existing = collapsedStores.get(storageKey);\n if (existing) return existing;\n\n const listeners = new Set<() => void>();\n const store: SidebarCollapsedStore = {\n subscribe(callback) {\n listeners.add(callback);\n window.addEventListener(\"storage\", callback);\n return () => {\n listeners.delete(callback);\n window.removeEventListener(\"storage\", callback);\n };\n },\n getSnapshot() {\n return window.localStorage.getItem(storageKey) === \"1\";\n },\n set(value) {\n window.localStorage.setItem(storageKey, value ? \"1\" : \"0\");\n listeners.forEach((listener) => listener());\n },\n };\n collapsedStores.set(storageKey, store);\n return store;\n}\n\nexport function useSidebarCollapsed(\n storageKey: string = DEFAULT_SIDEBAR_COLLAPSED_STORAGE_KEY,\n): [boolean, (value: boolean) => void] {\n const store = getCollapsedStore(storageKey);\n const collapsed = React.useSyncExternalStore(store.subscribe, store.getSnapshot, () => false);\n return [collapsed, store.set];\n}\n\ninterface SidebarNavLinkProps {\n href: string;\n label: string;\n icon: LucideIcon;\n active: boolean;\n collapsed: boolean;\n /** Render as a non-clickable placeholder for upcoming features. */\n disabled?: boolean;\n /** Native hover title explaining why the entry is disabled. */\n disabledHint?: string;\n}\n\n// Leaf navigation row: full row when expanded, centered icon button with a\n// tooltip when collapsed.\nexport function SidebarNavLink({\n href,\n label,\n icon: Icon,\n active,\n collapsed,\n disabled,\n disabledHint,\n}: SidebarNavLinkProps) {\n const iconColor = disabled ? \"text-muted-foreground/50\" : active ? \"text-primary\" : \"text-muted-foreground\";\n\n const className = collapsed\n ? cn(\n \"mx-auto mt-1 flex h-10 w-10 items-center justify-center rounded-md\",\n disabled\n ? \"cursor-not-allowed text-muted-foreground/50\"\n : active\n ? \"bg-accent font-semibold text-primary\"\n : \"text-foreground hover:bg-accent\",\n )\n : cn(\n \"mt-1 flex min-h-10 items-center gap-3 rounded-md px-4\",\n disabled\n ? \"cursor-not-allowed text-muted-foreground/50\"\n : active\n ? \"bg-accent font-semibold text-primary\"\n : \"text-foreground hover:bg-accent\",\n );\n\n const inner = disabled ? (\n <div className={className} title={disabledHint} aria-disabled=\"true\">\n <Icon className={cn(\"size-4\", iconColor)} />\n {!collapsed && <span>{label}</span>}\n </div>\n ) : (\n <Link href={href} className={className} aria-current={active ? \"page\" : undefined}>\n <Icon className={cn(\"size-4\", iconColor)} />\n {!collapsed && <span>{label}</span>}\n </Link>\n );\n\n if (!collapsed) return inner;\n\n return (\n <Tooltip>\n <TooltipTrigger asChild>{inner}</TooltipTrigger>\n <TooltipContent side=\"right\">{label}</TooltipContent>\n </Tooltip>\n );\n}\n\ninterface SidebarBackButtonProps {\n collapsed: boolean;\n label: string;\n backAriaLabel: string;\n onClick: () => void;\n}\n\n// Header button: wide back-to-list button when expanded, square icon when\n// collapsed.\nexport function SidebarBackButton({ collapsed, label, backAriaLabel, onClick }: SidebarBackButtonProps) {\n if (collapsed) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n aria-label={backAriaLabel}\n className=\"mx-auto flex size-10 cursor-pointer items-center justify-center rounded-md border border-border bg-card text-foreground hover:border-primary hover:bg-accent hover:text-primary focus:outline-none\"\n >\n <ArrowLeft className=\"size-5 text-muted-foreground\" />\n </button>\n );\n }\n\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className=\"flex w-full max-w-[240px] cursor-pointer items-center rounded-md border border-border bg-card text-base font-medium text-foreground hover:border-primary hover:bg-accent hover:text-primary focus:outline-none\"\n >\n <span className=\"flex w-14 items-center justify-center\">\n <ArrowLeft className=\"size-5 text-muted-foreground\" />\n </span>\n <span className=\"max-w-[170px] truncate pr-4 text-left\">{label}</span>\n </button>\n );\n}\n\ninterface SidebarCollapseToggleProps {\n collapsed: boolean;\n onToggle: (value: boolean) => void;\n collapseLabel: string;\n expandLabel: string;\n}\n\n// Footer button that flips the sidebar between 240px and 64px.\nexport function SidebarCollapseToggle({ collapsed, onToggle, collapseLabel, expandLabel }: SidebarCollapseToggleProps) {\n const button = (\n <button\n type=\"button\"\n onClick={() => onToggle(!collapsed)}\n aria-label={collapsed ? expandLabel : collapseLabel}\n aria-expanded={!collapsed}\n className={cn(\n \"flex h-10 w-full cursor-pointer items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground focus:outline-none\",\n collapsed ? \"justify-center\" : \"gap-2.5 px-3\",\n )}\n >\n {collapsed ? <PanelLeftOpen className=\"size-4\" /> : <PanelLeftClose className=\"size-4\" />}\n {!collapsed && <span className=\"text-sm\">{collapseLabel}</span>}\n </button>\n );\n\n return (\n <div className=\"shrink-0 border-t border-border p-2\">\n {collapsed ? (\n <Tooltip>\n <TooltipTrigger asChild>{button}</TooltipTrigger>\n <TooltipContent side=\"right\">{expandLabel}</TooltipContent>\n </Tooltip>\n ) : (\n button\n )}\n </div>\n );\n}\n\n// Hairline divider replacing text group labels in collapsed mode.\nexport function CollapsedGroupDivider() {\n return <div className=\"mx-2 border-t border-border\" />;\n}\n\ninterface CollapsedFlyoutMenuProps {\n icon: LucideIcon;\n /** Trigger aria label and flyout title (e.g. a group name). */\n label: string;\n active: boolean;\n children: React.ReactNode;\n}\n\n// Hover-opened flyout for groups whose children do not fit in the 64px rail.\nexport function CollapsedFlyoutMenu({ icon: Icon, label, active, children }: CollapsedFlyoutMenuProps) {\n const pathname = usePathname();\n const [open, setOpen] = React.useState(false);\n const [trackedPathname, setTrackedPathname] = React.useState(pathname);\n const closeTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Close after navigation; the shell layout outlives page changes. Adjusting\n // state during render (React's documented prop-change pattern) avoids an\n // effect that fires after the destination page paints.\n if (pathname !== trackedPathname) {\n setTrackedPathname(pathname);\n if (open) setOpen(false);\n }\n\n const cancelClose = React.useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n\n const openMenu = React.useCallback(() => {\n cancelClose();\n setOpen(true);\n }, [cancelClose]);\n\n const scheduleClose = React.useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => setOpen(false), 120);\n }, [cancelClose]);\n\n // Clear any pending close timer on unmount.\n React.useEffect(() => cancelClose, [cancelClose]);\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n onMouseEnter={openMenu}\n onMouseLeave={scheduleClose}\n onFocus={openMenu}\n aria-label={label}\n className={cn(\n \"mx-auto mt-1 flex h-10 w-10 items-center justify-center rounded-md\",\n active ? \"bg-accent font-semibold text-primary\" : \"text-foreground hover:bg-accent\",\n )}\n >\n <Icon className={cn(\"size-4\", active ? \"text-primary\" : \"text-muted-foreground\")} />\n </button>\n </PopoverTrigger>\n <PopoverContent\n side=\"right\"\n align=\"start\"\n sideOffset={8}\n onMouseEnter={openMenu}\n onMouseLeave={scheduleClose}\n className=\"flex w-52 flex-col gap-0 p-1.5\"\n >\n <h2 className=\"truncate px-2 py-1.5 text-sm\">{label}</h2>\n {children}\n </PopoverContent>\n </Popover>\n );\n}\n\ninterface FlyoutLinkProps {\n href: string;\n label: string;\n active: boolean;\n indented?: boolean;\n}\n\nexport function FlyoutLink({ href, label, active, indented }: FlyoutLinkProps) {\n return (\n <Link\n href={href}\n aria-current={active ? \"page\" : undefined}\n className={cn(\n \"block rounded-md py-1.5 pr-2 text-sm\",\n indented ? \"pl-5\" : \"pl-2\",\n active ? \"bg-accent font-semibold text-primary\" : \"text-muted-foreground hover:bg-accent hover:text-foreground\",\n )}\n >\n {label}\n </Link>\n );\n}\n\nexport function FlyoutSectionLabel({ children }: { children: React.ReactNode }) {\n return (\n <div className=\"px-2 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground\">{children}</div>\n );\n}\n",
|
|
12
|
-
"type": "registry:block"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"path": "src/components/app-shell/app-shell.tsx",
|
|
16
|
-
"content": "\"use client\";\n\nimport * as React from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport { House, type LucideIcon } from \"lucide-react\";\nimport { cn } from \"cn\";\n\nimport { TooltipProvider } from \"@/components/ui/tooltip\";\nimport { SidebarCollapseToggle, SidebarNavLink, useSidebarCollapsed } from \"@/components/app-shell/sidebar-chrome\";\n\nexport interface AppShellNavItem {\n href: string;\n label: string;\n icon: LucideIcon;\n /** Render as a non-clickable placeholder for upcoming features. */\n disabled?: boolean;\n}\n\n// Placeholder navigation; replace with the project's own entries.\nconst NAV_ITEMS: AppShellNavItem[] = [{ href: \"/\", label: \"Home\", icon: House }];\n\ninterface AppShellProps {\n children: React.ReactNode;\n navItems?: AppShellNavItem[];\n}\n\n// Minimal collapsible app shell: a 240px sidebar that folds to a 64px icon\n// rail (preference persisted by useSidebarCollapsed) next to the page body.\nexport function AppShell({ children, navItems = NAV_ITEMS }: AppShellProps) {\n const pathname = usePathname();\n const [collapsed, setCollapsed] = useSidebarCollapsed();\n\n return (\n <TooltipProvider>\n <div className=\"flex min-h-screen\">\n <aside className={cn(\"flex shrink-0 flex-col border-r border-border\", collapsed ? \"w-16\" : \"w-60\")}>\n <nav className=\"flex-1 px-2 py-2\">\n {navItems.map((item) => (\n <SidebarNavLink\n key={item.href}\n href={item.href}\n label={item.label}\n icon={item.icon}\n active={pathname === item.href}\n collapsed={collapsed}\n disabled={item.disabled}\n />\n ))}\n </nav>\n <SidebarCollapseToggle\n collapsed={collapsed}\n onToggle={setCollapsed}\n collapseLabel=\"Collapse\"\n expandLabel=\"Expand sidebar\"\n />\n </aside>\n <main className=\"min-w-0 flex-1\">{children}</main>\n </div>\n </TooltipProvider>\n );\n}\n",
|
|
17
|
-
"type": "registry:block"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|