@basaltkit/api-keys-ui 1.3.0 → 1.4.1
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 +12 -2
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +2 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Self-contained HTML page to **manage API keys** for [`@basaltkit/auth`](https://
|
|
|
10
10
|
|
|
11
11
|
## What this module solves
|
|
12
12
|
|
|
13
|
-
`@basaltkit/auth` already exposes the `POST/GET /apikeys` and `DELETE /apikeys/:id` routes (the plaintext key only appears on creation). This module is the **UI** on top of them: a page that lists the keys, lets you create a new one (revealing the secret once, with a copy button) and revoke existing ones.
|
|
13
|
+
`@basaltkit/auth` already exposes the `POST/GET /apikeys` and `DELETE /apikeys/:id` routes (the plaintext key only appears on creation), plus `PATCH /apikeys/:id` and `POST /apikeys/:id/rotate`, which this page does not use yet. This module is the **UI** on top of them: a page that lists the keys, lets you create a new one (revealing the secret once, with a copy button) and revoke existing ones.
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ Self-contained HTML page to **manage API keys** for [`@basaltkit/auth`](https://
|
|
|
18
18
|
pnpm add @basaltkit/api-keys-ui
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Depends on `@basaltkit/core` and `@basaltkit/
|
|
21
|
+
Depends on `@basaltkit/core` and `@basaltkit/http` (3.x) — not on any single adapter. Requires your app to mount the API key routes from `@basaltkit/auth` (`apiKeysPlugin` + `apiKeyRoutes`).
|
|
22
22
|
|
|
23
23
|
## Getting started in 5 minutes
|
|
24
24
|
|
|
@@ -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
|
|
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
|
+
"version": "1.4.1",
|
|
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/
|
|
22
|
-
"@basaltkit/
|
|
21
|
+
"@basaltkit/core": "^1.6.0",
|
|
22
|
+
"@basaltkit/http": "^3.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^26.
|
|
25
|
+
"@types/node": "^26.6.1",
|
|
26
26
|
"typescript": "^7.0.2",
|
|
27
|
-
"vitest": "^
|
|
28
|
-
"zod": "^4.5
|
|
29
|
-
"@basaltkit/
|
|
30
|
-
"@basaltkit/
|
|
31
|
-
"@basaltkit/tenancy": "^
|
|
27
|
+
"vitest": "^5.0.1",
|
|
28
|
+
"zod": "^4.6.5",
|
|
29
|
+
"@basaltkit/auth": "^5.0.0",
|
|
30
|
+
"@basaltkit/fastify": "^3.0.0",
|
|
31
|
+
"@basaltkit/tenancy": "^4.0.0",
|
|
32
32
|
"@basaltkit/tsconfig": "^0.24.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|