@basaltkit/api-keys-ui 1.3.0 → 1.4.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 CHANGED
@@ -78,6 +78,16 @@ non-browser clients and is not copied to `localStorage` by this UI.
78
78
 
79
79
  Returns the page's HTML as a string — use it directly if you want to serve it your own way (or on another framework).
80
80
 
81
+ ## Guarding the route
82
+
83
+ The route always requires a logged-in user (`auth: true`). Pass `meta` to add
84
+ your own guard — or a rate limit, OpenAPI tags — merged into the page route;
85
+ `auth: true` is applied on top and cannot be switched off:
86
+
87
+ ```ts
88
+ apiKeysUiRoutes({ meta: { can: 'apikeys:manage' } })
89
+ ```
90
+
81
91
  ## Content-Security-Policy
82
92
 
83
93
  The route sets a route-scoped CSP by default: everything locked down and the
package/dist/plugin.d.ts CHANGED
@@ -10,6 +10,12 @@ export interface ApiKeysUiOptions extends ApiKeysPageOptions {
10
10
  * to send no route-scoped CSP at all.
11
11
  */
12
12
  csp?: string | false;
13
+ /**
14
+ * Extra route metadata merged into the page route — a guard such as
15
+ * `{ can: 'apikeys:manage' }`, a rate limit, OpenAPI tags. `auth: true` is
16
+ * always applied on top and cannot be switched off.
17
+ */
18
+ meta?: Record<string, unknown>;
13
19
  }
14
20
  /**
15
21
  * Serves the API-keys management page at `GET /apikeys/ui` (requires a
package/dist/plugin.js CHANGED
@@ -8,11 +8,12 @@ import { apiKeysPageCsp, apiKeysPageHtml } from './html.js';
8
8
  export function apiKeysUiRoutes(options = {}) {
9
9
  const html = apiKeysPageHtml(options);
10
10
  const csp = options.csp === false ? undefined : (options.csp ?? apiKeysPageCsp(options));
11
+ const meta = { ...options.meta, auth: true };
11
12
  return [
12
13
  route({
13
14
  method: 'GET',
14
15
  url: options.path ?? '/apikeys/ui',
15
- meta: { auth: true },
16
+ meta,
16
17
  async handler({ reply }) {
17
18
  if (csp !== undefined)
18
19
  reply.header('content-security-policy', csp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basaltkit/api-keys-ui",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "engines": {
5
5
  "node": ">=22.5.0"
6
6
  },
@@ -18,17 +18,17 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@basaltkit/http": "^2.0.0",
22
- "@basaltkit/core": "^1.3.1"
21
+ "@basaltkit/core": "^1.6.0",
22
+ "@basaltkit/http": "^2.8.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/node": "^26.4.0",
25
+ "@types/node": "^26.6.1",
26
26
  "typescript": "^7.0.2",
27
- "vitest": "^4.1.11",
28
- "zod": "^4.5.4",
29
- "@basaltkit/fastify": "^2.0.0",
30
- "@basaltkit/auth": "^2.2.0",
31
- "@basaltkit/tenancy": "^1.10.0",
27
+ "vitest": "^5.0.1",
28
+ "zod": "^4.6.5",
29
+ "@basaltkit/auth": "^4.2.0",
30
+ "@basaltkit/fastify": "^2.6.0",
31
+ "@basaltkit/tenancy": "^3.2.0",
32
32
  "@basaltkit/tsconfig": "^0.24.0"
33
33
  },
34
34
  "publishConfig": {