fa-mcp-sdk 0.4.29 → 0.4.30

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
@@ -151,6 +151,7 @@ my-mcp-server/
151
151
  ├── FA-MCP-SDK-DOC/ # FA-MCP-SDK Documentation
152
152
  ├── scripts/ # Utility scripts
153
153
  │ ├── npm/ # NPM utility scripts
154
+ │ ├── generate-jwt.js # CLI JWT token generator
154
155
  │ ├── kill-port.js # Port cleanup utility
155
156
  │ ├── pre-commit # Git pre-commit hook
156
157
  │ └── remove-nul.js # File cleanup utility
@@ -207,7 +208,9 @@ Note: The `dist/` directory (compiled JavaScript) is created after running `npm
207
208
  | `npm run test:mcp-http` | Test HTTP transport |
208
209
  | `npm run test:mcp-sse` | Test SSE transport |
209
210
  | `npm run test:mcp-stdio` | Test STDIO transport |
210
- | `npm run generate-token` | Generate JWT tokens |
211
+ | `npm run generate-token` | Generate JWT tokens (Web UI) |
212
+ | `node scripts/generate-jwt.js` | Generate JWT token (CLI) |
213
+ | `/gen-jwt` | Generate JWT token (Claude Code skill) |
211
214
  | `npm run consul:unreg` | Deregister from Consul |
212
215
 
213
216
 
@@ -215,6 +218,7 @@ Note: The `dist/` directory (compiled JavaScript) is created after running `npm
215
218
  `http://localhost:3000` with:
216
219
  - MCP endpoints at `/mcp/*`
217
220
  - Admin panel for generating access tokens at `/admin`
221
+ - JWT generation API at `/gen-jwt` (when `webServer.genJwtApiEnable: true`)
218
222
  - Swagger UI at `/docs`
219
223
  - Health check at `/health`
220
224
 
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: gen-jwt
3
+ description: "Generate JWT token for MCP server authentication. Use when user asks to generate/create a JWT token, mentions 'jwt', 'token for user', 'токен для', or wants to issue access credentials."
4
+ allowed-tools: Bash(node scripts/generate-jwt.js *), Write
5
+ argument-hint: "[username] [ttl] [options...]"
6
+ ---
7
+
8
+ # JWT Token Generator
9
+
10
+ Generate a JWT token by running `node scripts/generate-jwt.js` with the appropriate parameters.
11
+
12
+ ## Parameter Extraction
13
+
14
+ Parse `$ARGUMENTS` and the user's request to extract:
15
+
16
+ 1. **username** (REQUIRED) — the user the token is issued to
17
+ 2. **ttl** (REQUIRED) — token lifetime in format `<N>s | <N>m | <N>d | <N>y` (seconds, minutes, days, years)
18
+ 3. **request** (optional) — ticket/issue ID if user mentions "заявка", "тикет", "ticket", "request", "issue", "REQ-", "JIRA-" etc. The param key is always `request`
19
+ 4. **ip** (optional) — allowed IP addresses/CIDR masks, comma-separated
20
+ 5. **service** (optional) — service name, passed via `-s`
21
+ 6. **extra params** (optional) — any other key=value pairs
22
+
23
+ ## Interactive Flow
24
+
25
+ ### Step 1: Validate required params
26
+
27
+ If **username** is missing or empty:
28
+ - Tell the user: "Username is required. Please specify the user the token should be issued to."
29
+ - Wait for response. Do not proceed without it.
30
+
31
+ If **ttl** is missing, not provided, or doesn't match `<N>s | <N>m | <N>d | <N>y`:
32
+ - Tell the user: "Token lifetime (TTL) is required in format: `<N>s` (seconds), `<N>m` (minutes), `<N>d` (days), or `<N>y` (years). For example: `30d`, `1y`, `8d`. Please specify."
33
+ - Wait for response. Do not proceed without a valid TTL.
34
+
35
+ ### Step 2: Ask about optional params (only if not already provided)
36
+
37
+ If the user did NOT mention a request/ticket:
38
+ - Ask: "Привязать к заявке? (введите ID заявки или Enter чтобы пропустить)"
39
+ - If user says "no", "skip", "нет", "-", or presses Enter — omit the `request` param.
40
+
41
+ If the user did NOT mention IP restrictions:
42
+ - Ask: "Ограничить по IP? (введите IP/CIDR через запятую или Enter чтобы пропустить)"
43
+ - If user says "no", "skip", "нет", "-", or presses Enter — omit the `ip` param.
44
+
45
+ ### Step 3: Build and run the command
46
+
47
+ Construct the CLI command:
48
+
49
+ ```
50
+ node scripts/generate-jwt.js -u <username> -ttl <ttl> [-s <service>] [-p "<params>"]
51
+ ```
52
+
53
+ The `-p` value is a semicolon-separated string of `key=value` pairs built from:
54
+ - `request=<ticket>` (if provided)
55
+ - `ip=<addresses>` (if provided)
56
+ - Any extra key=value pairs from the user's message
57
+
58
+ **Examples:**
59
+
60
+ User: "Generate jwt for vpupkin, ticket REQ-12345, 1 year, aaa=foo, bbb=boo, IPs 10.0.0.0/24 and 192.168.1.100"
61
+ ```bash
62
+ node scripts/generate-jwt.js -u vpupkin -ttl 1y -p "request=REQ-12345;ip=10.0.0.0/24,192.168.1.100;aaa=foo;bbb=boo"
63
+ ```
64
+
65
+ User: "token for admin on 30 days"
66
+ ```bash
67
+ node scripts/generate-jwt.js -u admin -ttl 30d
68
+ ```
69
+
70
+ User: "jwt для svc-account, сервис my-mcp, на 8 дней"
71
+ ```bash
72
+ node scripts/generate-jwt.js -u svc-account -ttl 8d -s my-mcp
73
+ ```
74
+
75
+ ### Step 4: Save the token to a file
76
+
77
+ After running the command:
78
+ 1. Extract the token string from the output (the long hex line).
79
+ 2. Generate a timestamp in format `YYYYMMDD-HHmmss` (local time).
80
+ 3. Save the token to a file named `<timestamp>-jwt.txt` in the project root directory using the Write tool. The file should contain only the token string (no extra whitespace or newlines).
81
+
82
+ ### Step 5: Present the result
83
+
84
+ After running the command:
85
+
86
+ 1. **Parse the JSON payload**: Extract the JSON object between `__PAYLOAD_JSON__` and `__END_PAYLOAD_JSON__` markers in the script output. This object contains ALL fields that were embedded in the token payload.
87
+
88
+ 2. **Show the executed command**: Display the exact `node scripts/generate-jwt.js ...` command with all flags that was run, so the user can copy/reproduce it.
89
+
90
+ 3. **Show the token**: Display the generated token string (the long hex line from the output).
91
+
92
+ 4. **Show the full payload table**: Render a table with ALL key-value pairs from the parsed JSON payload. Use human-readable labels where possible:
93
+ - `user` → User
94
+ - `service` → Service
95
+ - `ttl` → TTL
96
+ - `expire_iso` → Expires
97
+ - `iat` → Issued At
98
+ - `request` → Request
99
+ - `ip` → IP restriction
100
+ - Any other keys → display as-is (capitalized)
101
+
102
+ 5. **Show the filename** where the token was saved (e.g., `20260413-120530-jwt.txt`).
103
+
104
+ ## Important Rules
105
+
106
+ - NEVER use AskUserQuestion with predefined options for ANY parameter. All parameters are free-form text — ask the user to type values directly in chat. Do NOT suggest choices like "admin", "service-account", "30d", "1y", etc. Just ask the question and let the user type their answer.
107
+ - NEVER skip the interactive prompts for optional params — always ask once if not provided. But accept "skip" gracefully.
108
+ - NEVER proceed without valid username and ttl.
109
+ - If the user provides ttl in natural language ("1 year", "30 days", "на год"), convert it to the CLI format: `1y`, `30d`, etc.
110
+ - Russian/English: understand both. "год/лет" = `y`, "день/дней/дня" = `d`, "минут/минуты" = `m`, "секунд" = `s`.
111
+ - The `-p` flag value must be quoted and semicolon-separated: `"key1=val1;key2=val2"`
112
+ - IP addresses in the `ip` param are comma-separated (no spaces after commas in the value).
113
+ - Run the command from the project root directory.
@@ -30,9 +30,23 @@ npx jest tests/path/to/file.test.ts # single test file
30
30
  # Utilities
31
31
  npm run check-llm # Validate OpenAI API key for Agent Tester
32
32
  npm run generate-token # JWT token generator UI
33
+
34
+ # JWT token generation (CLI)
35
+ node scripts/generate-jwt.js -u <username> -ttl <duration> [-s <service>] [-p <params>]
36
+ # duration: <N>s | <N>m | <N>d | <N>y
37
+ # example: node scripts/generate-jwt.js -u admin -ttl 30d -s my-mcp -p "role=admin;team=ops"
38
+
39
+ # JWT generation API (HTTP endpoint, requires webServer.genJwtApiEnable: true)
40
+ # POST /gen-jwt {"username":"user","ttl":"30d","service":"svc","params":"key=val"}
41
+
33
42
  npm run consul:unreg # deregister from Consul
34
43
  ```
35
44
 
45
+ ## JWT Token Generation (Skill /gen-jwt)
46
+
47
+ Generate JWT tokens for MCP server authentication using the `/gen-jwt` skill.
48
+ Triggers: user asks to generate/create a JWT token, mentions "jwt", "token for user", "токен для", "сгенерируй токен для".
49
+
36
50
  **Start/stop the server**: `npm run build && npm start`. Stop with Ctrl+C. Port is in `config/default.yaml` → `webServer.port`. Force stop: `node scripts/kill-port.js <port>`.
37
51
 
38
52
  **Server endpoints** (HTTP mode): `/mcp/*` (MCP protocol), `/docs` (Swagger UI), `/admin` (token generator), `/health`, `/agent-tester` (chat UI for testing tools).
@@ -16,7 +16,7 @@ npm install fa-mcp-sdk
16
16
  | [02-1-tools-and-api](02-1-tools-and-api.md) | Tool definitions, `toolHandler`, REST API with tsoa, OpenAPI/Swagger | Creating tools, REST endpoints |
17
17
  | [02-2-prompts-and-resources](02-2-prompts-and-resources.md) | Standard/custom prompts, resources, `requireAuth` | Configuring prompts/resources |
18
18
  | [03-configuration](03-configuration.md) | `appConfig`, YAML config, cache, PostgreSQL | Server configuration, DB |
19
- | [04-authentication](04-authentication.md) | JWT, Basic auth, server tokens, `createAuthMW()`, Token Generator | Authentication setup |
19
+ | [04-authentication](04-authentication.md) | JWT, Basic auth, server tokens, `createAuthMW()`, Token Generator, CLI Token Generator, JWT Generation API | Authentication setup |
20
20
  | [05-ad-authorization](05-ad-authorization.md) | AD group authorization at HTTP/tool levels | AD group restrictions |
21
21
  | [06-utilities](06-utilities.md) | `ServerError`, `normalizeHeaders`, logging, Consul, graceful shutdown | Error handling, utilities |
22
22
  | [07-testing-and-operations](07-testing-and-operations.md) | Test clients (STDIO, HTTP, SSE, Streamable HTTP) | Testing, deployment |
@@ -44,6 +44,30 @@ const client = new McpHttpClient('http://localhost:3000');
44
44
  const result = await client.callTool('tool', args, getAuthHeadersForTests());
45
45
  ```
46
46
 
47
+ ## Admin Panel Authentication
48
+
49
+ The admin panel (`/admin`) supports 4 authentication types and can be configured with a single type or multiple types:
50
+
51
+ ```yaml
52
+ # config/default.yaml
53
+ webServer:
54
+ adminAuth:
55
+ enabled: true
56
+ # Single type (string)
57
+ type: 'basic'
58
+ # Or multiple types (array) — login page shows tabs to choose
59
+ type: ['jwtToken', 'basic']
60
+ ```
61
+
62
+ **Supported types:** `permanentServerTokens`, `basic`, `jwtToken`, `ntlm`
63
+
64
+ When multiple types are configured (e.g. `['jwtToken', 'basic']`), the login page shows tabs:
65
+ - **Token** tab — for `permanentServerTokens` and `jwtToken` authentication
66
+ - **Login** tab — for `basic` (username/password) authentication
67
+
68
+ For `permanentServerTokens`, `basic`, `jwtToken` — credentials are taken from `webServer.auth` section.
69
+ For `ntlm` — uses AD configuration from `ad.domains` section.
70
+
47
71
  ## Token Generator Authorization
48
72
 
49
73
  Protect `/admin/` page with custom authorization:
@@ -252,6 +276,105 @@ curl -H "Authorization: Basic $(echo -n 'admin:password' | base64)" http://local
252
276
  curl -H "X-API-Key: custom-key" http://localhost:3000/mcp
253
277
  ```
254
278
 
279
+ ## CLI Token Generator
280
+
281
+ Generate JWT tokens from the command line without starting the server:
282
+
283
+ ```bash
284
+ node scripts/generate-jwt.js -u <username> -ttl <duration> [-s <service>] [-p <params>]
285
+ ```
286
+
287
+ | Option | ENV | Description |
288
+ |--------|-----|-------------|
289
+ | `-u`, `--username` | `JWT_PAYLOAD_USERNAME` | Username (required) |
290
+ | `-ttl` | `JWT_TTL` | Token lifetime: `<N>s` \| `<N>m` \| `<N>d` \| `<N>y` (required) |
291
+ | `-s`, `--service-name` | `JWT_PAYLOAD_SERVICE_NAME` | Service name (optional) |
292
+ | `-p`, `--params` | `JWT_PAYLOAD_PARAMS` | Extra payload `key=value;key=value` (optional) |
293
+
294
+ The `encryptKey` is read from config `webServer.auth.jwtToken.encryptKey` (via `config/local.yaml` or ENV `WS_TOKEN_ENCRYPT_KEY`).
295
+
296
+ **Examples:**
297
+
298
+ ```bash
299
+ # 30-day token with service name
300
+ node scripts/generate-jwt.js -u admin -ttl 30d -s my-mcp-server
301
+
302
+ # 1-year token with extra payload fields
303
+ node scripts/generate-jwt.js -u svc-account -ttl 1y -p "role=admin;team=backend"
304
+
305
+ # Via environment variables
306
+ JWT_PAYLOAD_USERNAME=admin JWT_TTL=8d node scripts/generate-jwt.js
307
+ ```
308
+
309
+ ## Claude Code Skill: `/gen-jwt`
310
+
311
+ Interactive JWT token generation via Claude Code. Invoke with `/gen-jwt` or natural language (e.g. "сгенерируй токен для vpupkin на 1 год").
312
+
313
+ The skill parses your request for `username`, `ttl`, `service`, `request` (ticket ID), `ip`, and extra key=value params. If required params (`username`, `ttl`) are missing, it asks interactively. Optional params (`request`, `ip`) are prompted once with an option to skip.
314
+
315
+ Runs `node scripts/generate-jwt.js` under the hood.
316
+
317
+ **Example:**
318
+ ```
319
+ /gen-jwt для vpupkin, по заявке REQ-12345, на 1 год, role=admin, IP 10.0.0.0/24
320
+ ```
321
+
322
+ Skill location: `.claude/skills/gen-jwt/SKILL.md`
323
+
324
+ ## JWT Generation API
325
+
326
+ HTTP endpoint for programmatic JWT token generation. Disabled by default.
327
+
328
+ ### Configuration
329
+
330
+ ```yaml
331
+ # config/default.yaml
332
+ webServer:
333
+ genJwtApiEnable: true # Enable POST /gen-jwt endpoint
334
+ auth:
335
+ enabled: true # Auth must be enabled — endpoint requires valid credentials
336
+ jwtToken:
337
+ encryptKey: 'your-secret-key-here'
338
+ ```
339
+
340
+ Or via ENV: `WS_GEN_JWT_API_ENABLE=true`
341
+
342
+ ### Usage
343
+
344
+ ```bash
345
+ # POST /gen-jwt with any configured auth method
346
+ curl -X POST http://localhost:3000/gen-jwt \
347
+ -H "Content-Type: application/json" \
348
+ -u "admin:password" \
349
+ -d '{
350
+ "username": "testuser",
351
+ "ttl": "30d",
352
+ "service": "my-mcp-server",
353
+ "params": "role=admin;team=backend"
354
+ }'
355
+ ```
356
+
357
+ ### Request Body
358
+
359
+ | Field | Type | Required | Description |
360
+ |-------|------|----------|-------------|
361
+ | `username` | string | yes | Username for the token |
362
+ | `ttl` | string | yes | Token lifetime: `<N>s` \| `<N>m` \| `<N>d` \| `<N>y` |
363
+ | `service` | string | no | Service name |
364
+ | `params` | string \| object | no | Extra payload. String: `"key=value;key=value"`. Object: `{"key": "value"}` |
365
+
366
+ ### Response
367
+
368
+ ```json
369
+ {
370
+ "success": true,
371
+ "token": "1718000000000.a1b2c3...",
372
+ "user": "testuser",
373
+ "expire": "2025-07-10T12:00:00.000Z",
374
+ "ttlSeconds": 2592000
375
+ }
376
+ ```
377
+
255
378
  ## Token Generator App
256
379
 
257
380
  ```typescript
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "@modelcontextprotocol/sdk": "^1.29.0",
52
52
  "dotenv": "^17.4.1",
53
- "fa-mcp-sdk": "^0.4.29"
53
+ "fa-mcp-sdk": "^0.4.30"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/express": "^5.0.6",
@@ -303,6 +303,13 @@ webServer:
303
303
  #> Password for HTTP Basic auth
304
304
  password: '***'
305
305
 
306
+ #> ========================================================================
307
+ #> JWT TOKEN GENERATION API
308
+ #> POST /gen-jwt — generates a JWT token programmatically.
309
+ #> Requires valid Authorization header (any method configured in webServer.auth).
310
+ #> ========================================================================
311
+ genJwtApiEnable: false
312
+
306
313
  #> ========================================================================
307
314
  #> ADMIN PANEL AUTHENTICATION
308
315
  #> Token generation page available at /admin endpoint
@@ -312,6 +319,11 @@ webServer:
312
319
  #> Enable/disable admin panel
313
320
  enabled: true
314
321
  #> Authentication type for admin panel: 'permanentServerTokens' | 'basic' | 'jwtToken' | 'ntlm'
322
+ #> Accepts a single type (string) or multiple types (array):
323
+ #> type: 'basic'
324
+ #> type: ['jwtToken', 'basic']
315
325
  #> For permanentServerTokens, basic, jwtToken — uses credentials from webServer.auth section
316
326
  #> For ntlm — uses AD configuration from ad.domains section (no additional credentials needed)
327
+ #> When multiple types are set (e.g. ['jwtToken', 'basic']), the login page shows tabs
328
+ #> to choose between Token and Login (username/password) authentication.
317
329
  type: 'basic'
@@ -51,6 +51,7 @@ webServer:
51
51
  basic:
52
52
  username: WS_AUTH_BASIC_USERNAME
53
53
  password: WS_AUTH_BASIC_PASSWORD
54
+ genJwtApiEnable: WS_GEN_JWT_API_ENABLE
54
55
  adminAuth:
55
56
  enabled: WS_ADMIN_AUTH_ENABLED
56
57
  type: WS_ADMIN_AUTH_TYPE # permanentServerTokens | basic | jwtToken | ntlm
@@ -301,6 +301,13 @@ webServer:
301
301
  #> Password for HTTP Basic auth
302
302
  password: '***'
303
303
 
304
+ #> ========================================================================
305
+ #> JWT TOKEN GENERATION API
306
+ #> POST /gen-jwt — generates a JWT token programmatically.
307
+ #> Requires valid Authorization header (any method configured in webServer.auth).
308
+ #> ========================================================================
309
+ genJwtApiEnable: false
310
+
304
311
  #> ========================================================================
305
312
  #> ADMIN PANEL AUTHENTICATION
306
313
  #> Token generation page available at /admin endpoint
@@ -310,6 +317,11 @@ webServer:
310
317
  #> Enable/disable admin panel
311
318
  enabled: true
312
319
  #> Authentication type for admin panel: 'permanentServerTokens' | 'basic' | 'jwtToken' | 'ntlm'
320
+ #> Accepts a single type (string) or multiple types (array):
321
+ #> type: 'basic'
322
+ #> type: ['jwtToken', 'basic']
313
323
  #> For permanentServerTokens, basic, jwtToken — uses credentials from webServer.auth section
314
324
  #> For ntlm — uses AD configuration from ad.domains section (no additional credentials needed)
325
+ #> When multiple types are set (e.g. ['jwtToken', 'basic']), the login page shows tabs
326
+ #> to choose between Token and Login (username/password) authentication.
315
327
  type: 'basic'
package/config/local.yaml CHANGED
@@ -4,8 +4,8 @@ agentTester:
4
4
  showFooterLink: true # true (default) — show Agent Tester link in home page footer; false — hide link without disabling tester
5
5
  useAuth: true
6
6
  openAi:
7
- apiKey: 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
8
7
  apiKeyName: oai-aite-vvmakarov
8
+ apiKey: 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
9
9
  baseURL: ''
10
10
  exposeToClient: false
11
11
 
@@ -81,7 +81,7 @@ mcp:
81
81
  toolAnswerAs: text # text | structuredContent
82
82
 
83
83
  swagger:
84
- servers: # An array of servers that will be added to swagger docs
84
+ servers: # An array of servers that will be added to swagger docs
85
85
  - url: http://localhost:9876
86
86
  description: "Local server"
87
87
 
@@ -89,28 +89,17 @@ webServer:
89
89
  port: 9876
90
90
  auth:
91
91
  enabled: true
92
- # An array of fixed tokens that pass to the MCP (use only for MCPs with green data or for development)
93
- permanentServerTokens: ['test-perm-token']
92
+ permanentServerTokens: [ 'test-perm-token' ]
94
93
  jwtToken:
95
- # Symmetric encryption key to generate a token for this MCP
96
94
  encryptKey: '66666666-7777-8888-9999-000000000000'
97
- # If webServer.auth.enabled and the parameter true, the service name and the service specified in the token will be checked
98
95
  checkMCPName: true
99
- # If true and JWT token contains non-empty 'ip' field,
100
- # the client IP will be checked against the allowed list in the token
101
96
  isCheckIP: false
102
97
  basic:
103
98
  username: vpupkin
104
99
  password: '1'
105
100
 
106
- # ========================================================================
107
- # ADMIN PANEL AUTHENTICATION
108
- # Token generation page available at /admin endpoint
109
- # Supports 4 authentication methods: permanentServerTokens, basic, jwtToken, ntlm
110
- # ========================================================================
101
+ genJwtApiEnable: false
111
102
  adminAuth:
112
- enabled: false
113
- # Authentication type for admin panel: 'permanentServerTokens' | 'basic' | 'jwtToken' | 'ntlm'
114
- # For permanentServerTokens, basic, jwtToken - uses credentials from webServer.auth section
115
- # For ntlm - uses AD configuration from ad.domains section (no additional credentials needed)
116
- type: 'jwtToken'
103
+ enabled: true
104
+ # 'permanentServerTokens' | 'basic' | 'jwtToken' | 'ntlm'
105
+ type: [ 'permanentServerTokens', 'basic', 'jwtToken' ]
@@ -2,6 +2,7 @@ import { IAFDatabasesConfig } from 'af-db-ts';
2
2
  import { TFileLogLevel } from 'af-logger-ts';
3
3
  import { IAFConsulConfig, IAccessPoints } from 'fa-consul';
4
4
  import { IADConfig } from './active-directory-config.js';
5
+ export type AdminAuthType = 'permanentServerTokens' | 'basic' | 'jwtToken' | 'ntlm';
5
6
  interface IWebServerConfig {
6
7
  webServer: {
7
8
  host: string;
@@ -22,8 +23,9 @@ interface IWebServerConfig {
22
23
  };
23
24
  adminAuth: {
24
25
  enabled: boolean;
25
- type: 'permanentServerTokens' | 'basic' | 'jwtToken' | 'ntlm';
26
+ type: AdminAuthType | AdminAuthType[];
26
27
  };
28
+ genJwtApiEnable: boolean;
27
29
  };
28
30
  }
29
31
  interface ILoggerConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/core/_types_/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,UAAU,gBAAgB;IACxB,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,IAAI,EAAE;YACJ,OAAO,EAAE,OAAO,CAAC;YACjB,KAAK,CAAC,EAAE;gBACN,QAAQ,EAAE,MAAM,CAAC;gBACjB,QAAQ,EAAE,MAAM,CAAC;aAClB,CAAC;YACF,QAAQ,EAAE;gBACR,UAAU,EAAE,MAAM,CAAC;gBACnB,YAAY,EAAE,OAAO,CAAC;gBACtB,SAAS,EAAE,OAAO,CAAC;aACpB,CAAA;YACD,qBAAqB,EAAE,MAAM,EAAE,CAAC;SACjC,CAAC;QACF,SAAS,EAAE;YACT,OAAO,EAAE,OAAO,CAAC;YACjB,IAAI,EAAE,uBAAuB,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;SAC/D,CAAC;KACH,CAAA;CACF;AAGD,UAAU,aAAa;IACrB,MAAM,EAAE;QACN,KAAK,EAAE,aAAa,CAAC;QACrB,aAAa,EAAE,O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AM,EAAE,MAAM,CAAC,CAAC;KACtC,CAAA;CACF;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE;QACT,QAAQ,CAAC,EAAE;YACT,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC;QACF,UAAU,CAAC,EAAE;YACX,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC;KACH,CAAC;CACH;AAED,UAAU,YAAY;IACpB,KAAK,EAAE;QACL,UAAU,EAAE,GAAG,CAAC;QAChB,QAAQ,EAAE,IAAI,CAAC;KAChB,CAAA;CACF;AAED,MAAM,WAAW,SAAU,SAAQ,SAAS,EAC1C,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,eAAe;IAEf,YAAY,EAAE,OAAO,CAAC;IAEtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IAEpB,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,eAAe,GAAG;QACxB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;KACH,CAAC;IACF,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;KACjB,CAAA;CACF"}
@@ -1,14 +1,25 @@
1
1
  /**
2
2
  * Admin panel authentication middleware
3
3
  * Supports 4 authentication types: permanentServerTokens, basic, jwtToken, ntlm
4
+ * adminAuth.type accepts a single type or an array of types
4
5
  */
5
6
  import { RequestHandler } from 'express';
6
- export type AdminAuthType = 'permanentServerTokens' | 'basic' | 'jwtToken' | 'ntlm';
7
+ import { AdminAuthType } from '../_types_/config.js';
8
+ export type { AdminAuthType };
9
+ /**
10
+ * Normalizes adminAuth.type to an array
11
+ */
12
+ export declare function getAdminAuthTypes(): AdminAuthType[];
7
13
  /**
8
14
  * Validates admin auth configuration
9
15
  * Returns error message if configuration is invalid, null if valid
10
16
  */
11
17
  export declare function validateAdminAuthConfig(): string | null;
18
+ /**
19
+ * Returns the list of auth methods available for the admin login UI.
20
+ * Maps auth types to UI categories: 'token' (permanentServerTokens, jwtToken) or 'basic'.
21
+ */
22
+ export declare function getAdminAuthMethods(): string[];
12
23
  /**
13
24
  * Creates admin authentication middleware based on adminAuth.type config
14
25
  */
@@ -1 +1 @@
1
- {"version":3,"file":"admin-auth.d.ts","sourceRoot":"","sources":["../../../src/core/auth/admin-auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAc1E,MAAM,MAAM,aAAa,GAAG,uBAAuB,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAGpF;;;GAGG;AACH,wBAAgB,uBAAuB,IAAK,MAAM,GAAG,IAAI,CA8CxD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAK,cAAc,EAAE,CA0FrD"}
1
+ {"version":3,"file":"admin-auth.d.ts","sourceRoot":"","sources":["../../../src/core/auth/admin-auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAarD,YAAY,EAAE,aAAa,EAAE,CAAC;AAG9B;;GAEG;AACH,wBAAgB,iBAAiB,IAAK,aAAa,EAAE,CAGpD;AA6CD;;;GAGG;AACH,wBAAgB,uBAAuB,IAAK,MAAM,GAAG,IAAI,CAgBxD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAK,MAAM,EAAE,CAa/C;AAsCD;;GAEG;AACH,wBAAgB,iBAAiB,IAAK,cAAc,EAAE,CA8DrD"}