@openziti/ziti-mcp-server 0.6.0 → 0.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.
Files changed (41) hide show
  1. package/README.md +129 -34
  2. package/dist/auth/client-credentials-flow.js +32 -13
  3. package/dist/auth/client-credentials-flow.js.map +1 -1
  4. package/dist/auth/device-auth-flow.d.ts +5 -36
  5. package/dist/auth/device-auth-flow.js +105 -84
  6. package/dist/auth/device-auth-flow.js.map +1 -1
  7. package/dist/auth/oidc-discovery.d.ts +51 -0
  8. package/dist/auth/oidc-discovery.js +100 -0
  9. package/dist/auth/oidc-discovery.js.map +1 -0
  10. package/dist/clients/base.js +1 -1
  11. package/dist/clients/base.js.map +1 -1
  12. package/dist/commands/init.d.ts +5 -29
  13. package/dist/commands/init.js +57 -50
  14. package/dist/commands/init.js.map +1 -1
  15. package/dist/commands/logout.js +1 -1
  16. package/dist/commands/logout.js.map +1 -1
  17. package/dist/index.js +6 -7
  18. package/dist/index.js.map +1 -1
  19. package/dist/utils/authenticated-client.js +2 -2
  20. package/dist/utils/authenticated-client.js.map +1 -1
  21. package/dist/utils/config.d.ts +7 -7
  22. package/dist/utils/config.js +7 -7
  23. package/dist/utils/config.js.map +1 -1
  24. package/dist/utils/constants.d.ts +1 -1
  25. package/dist/utils/constants.js +1 -1
  26. package/dist/utils/constants.js.map +1 -1
  27. package/dist/utils/fabric-authenticated-client.js +2 -2
  28. package/dist/utils/fabric-authenticated-client.js.map +1 -1
  29. package/dist/utils/http-utility.js +5 -3
  30. package/dist/utils/http-utility.js.map +1 -1
  31. package/dist/utils/keychain.d.ts +4 -4
  32. package/dist/utils/keychain.js +3 -3
  33. package/dist/utils/keychain.js.map +1 -1
  34. package/dist/utils/logger.js +5 -5
  35. package/dist/utils/logger.js.map +1 -1
  36. package/dist/utils/terminal.js +6 -10
  37. package/dist/utils/terminal.js.map +1 -1
  38. package/package.json +4 -5
  39. package/dist/utils/auth0-client.d.ts +0 -27
  40. package/dist/utils/auth0-client.js +0 -67
  41. package/dist/utils/auth0-client.js.map +0 -1
package/README.md CHANGED
@@ -16,12 +16,19 @@
16
16
 
17
17
  </div>
18
18
 
19
+ The Ziti MCP Server is sponsored by [NetFoundry](https://netfoundry.io) as part of its portfolio of solutions
20
+ for secure workloads and agentic computing.
21
+ NetFoundry is the creator of [OpenZiti](https://netfoundry.io/docs/openziti/)
22
+ and [zrok](https://netfoundry.io/docs/zrok/getting-started).
23
+
19
24
  [MCP (Model Context Protocol)](https://modelcontextprotocol.io/introduction) is an open protocol introduced by Anthropic that standardizes how large language models communicate with external tools, resources or remote services.
20
25
 
21
26
  The Ziti MCP Server integrates with LLMs and AI agents, allowing you to perform various Ziti network management operations using natural language. For instance, you could simply ask Claude Desktop to perform Ziti management operations:
22
27
 
23
28
  - > List which identities exist
24
- - > Which identities have access to the Demo1 service
29
+ - > Tell me if there are any exposures in the network
30
+ - > Do you see potential misconfigurations?
31
+ - > Which identities have access to the Demo1 service?
25
32
  - > Create a new Ziti identity named "Demo" and get its ID
26
33
  - > etc.
27
34
 
@@ -40,30 +47,66 @@ The Ziti MCP Server integrates with LLMs and AI agents, allowing you to perform
40
47
 
41
48
  ### Install the Ziti MCP Server
42
49
 
43
- Install Ziti MCP Server and configure it to work with your preferred MCP Client. The `--tools` parameter specifies which tools should be available (defaults to `*` if not provided).
50
+ Install Ziti MCP Server and configure it to work with your preferred MCP Client. The `--auth-mode` parameter is required and specifies the authentication method:
51
+
52
+ - `device-auth`: Interactive browser-based login (requires `--idp-audience`)
53
+ - `client-credentials`: Service account authentication (requires `--idp-client-secret`)
54
+
55
+ The `--tools` parameter specifies which tools should be available (defaults to `*` if not provided).
44
56
 
45
- **Claude Desktop with all tools**
57
+ **Device Auth Mode (Interactive Login)**
46
58
 
47
59
  ```bash
48
- npx @openziti/ziti-mcp-server init
60
+ npx @openziti/ziti-mcp-server init \
61
+ --auth-mode device-auth \
62
+ --ziti-controller-host <your-controller-host> \
63
+ --idp-domain <your-idp-domain> \
64
+ --idp-client-id <your-client-id> \
65
+ --idp-audience <your-audience>
49
66
  ```
50
67
 
51
- **Claude Desktop with read-only tools**
68
+ **Client Credentials Mode (Service Account)**
52
69
 
53
70
  ```bash
54
- npx @openziti/ziti-mcp-server init --read-only
71
+ npx @openziti/ziti-mcp-server init \
72
+ --auth-mode client-credentials \
73
+ --ziti-controller-host <your-controller-host> \
74
+ --idp-domain <your-idp-domain> \
75
+ --idp-client-id <your-client-id> \
76
+ --idp-client-secret <your-client-secret>
77
+ ```
78
+
79
+ **With read-only tools**
80
+
81
+ ```bash
82
+ npx @openziti/ziti-mcp-server init \
83
+ --auth-mode device-auth \
84
+ --ziti-controller-host <host> \
85
+ --idp-domain <domain> \
86
+ --idp-client-id <id> \
87
+ --idp-audience <audience> \
88
+ --read-only
55
89
  ```
56
90
 
57
91
  You can also explicitly select read-only tools:
58
92
 
59
93
  ```bash
60
- npx @openziti/ziti-mcp-server init --tools 'list*,get*'
94
+ npx @openziti/ziti-mcp-server init \
95
+ --auth-mode device-auth \
96
+ ... \
97
+ --tools 'list*,get*'
61
98
  ```
62
99
 
63
100
  **Windsurf**
64
101
 
65
102
  ```bash
66
- npx @openziti/ziti-mcp-server init --client windsurf
103
+ npx @openziti/ziti-mcp-server init \
104
+ --auth-mode device-auth \
105
+ --client windsurf \
106
+ --ziti-controller-host <host> \
107
+ --idp-domain <domain> \
108
+ --idp-client-id <id> \
109
+ --idp-audience <audience>
67
110
  ```
68
111
 
69
112
  **Cursor**
@@ -75,19 +118,35 @@ Step 1:
75
118
  Step 2:
76
119
 
77
120
  ```bash
78
- npx @openziti/ziti-mcp-server init --client cursor
121
+ npx @openziti/ziti-mcp-server init \
122
+ --auth-mode device-auth \
123
+ --client cursor \
124
+ --ziti-controller-host <host> \
125
+ --idp-domain <domain> \
126
+ --idp-client-id <id> \
127
+ --idp-audience <audience>
79
128
  ```
80
129
 
81
130
  **Cursor with limited tools access**
82
131
 
83
132
  ```bash
84
- npx @openziti/ziti-mcp-server init --client cursor --tools 'listIdentities,listIdentity'
133
+ npx @openziti/ziti-mcp-server init \
134
+ --auth-mode device-auth \
135
+ --client cursor \
136
+ ... \
137
+ --tools 'listIdentities,listIdentity'
85
138
  ```
86
139
 
87
140
  **VS Code**
88
141
 
89
142
  ```bash
90
- npx @openziti/ziti-mcp-server init --client vscode
143
+ npx @openziti/ziti-mcp-server init \
144
+ --auth-mode device-auth \
145
+ --client vscode \
146
+ --ziti-controller-host <host> \
147
+ --idp-domain <domain> \
148
+ --idp-client-id <id> \
149
+ --idp-audience <audience>
91
150
  ```
92
151
 
93
152
  You can configure VS Code for either global or workspace scope:
@@ -100,7 +159,11 @@ The command will prompt you to choose your preferred scope and automatically con
100
159
  **VS Code with limited tools access**
101
160
 
102
161
  ```bash
103
- npx @openziti/ziti-mcp-server init --client vscode --tools 'list*,get*' --read-only
162
+ npx @openziti/ziti-mcp-server init \
163
+ --auth-mode device-auth \
164
+ --client vscode \
165
+ ... \
166
+ --tools 'list*,get*' --read-only
104
167
  ```
105
168
 
106
169
  **Other MCP Clients**
@@ -115,7 +178,7 @@ To use Ziti MCP Server with any other MCP Client, you can manually add this conf
115
178
  "args": ["-y", "@openziti/ziti-mcp-server", "run"],
116
179
  "capabilities": ["tools"],
117
180
  "env": {
118
- "DEBUG": "ziti-mcp"
181
+ "DEBUG": "ziti-mcp-server"
119
182
  }
120
183
  }
121
184
  }
@@ -137,7 +200,7 @@ Restart your MCP Client (Claude Desktop, Windsurf, Cursor, Warp, etc.) and ask i
137
200
 
138
201
  ## 🕸️ Architecture
139
202
 
140
- The Ziti MCP Server implements the Model Context Protocol, allowing Claude to:
203
+ The Ziti MCP Server implements the Model Context Protocol, allowing clients (like Claude) to:
141
204
 
142
205
  1. Request a list of available Ziti tools
143
206
  2. Call specific tools with parameters
@@ -158,13 +221,35 @@ The Ziti MCP Server uses the Ziti Management API and requires authentication to
158
221
 
159
222
  ### Initial Setup
160
223
 
161
- > [!NOTE]
162
- > Users should authenticate with [client credentials](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow). Keep the token lifetime as minimal as possible to reduce security risks. [See more](https://auth0.com/docs/secure/tokens/access-tokens/update-access-token-lifetime)
224
+ The Ziti MCP Server supports two authentication modes:
225
+
226
+ #### Device Auth Mode (Interactive Login)
163
227
 
164
- To authenticate the MCP Server:
228
+ Use this mode for interactive browser-based login. This is recommended for development and user-facing scenarios:
165
229
 
166
230
  ```bash
167
- npx @openziti/ziti-mcp-server init --idp-domain <idp-domain> --idp-client-id <idp-client-id> --idp-client-secret <idp-client-secret>
231
+ npx @openziti/ziti-mcp-server init \
232
+ --auth-mode device-auth \
233
+ --ziti-controller-host <your-controller-host> \
234
+ --idp-domain <your-idp-domain> \
235
+ --idp-client-id <your-client-id> \
236
+ --idp-audience <your-audience>
237
+ ```
238
+
239
+ #### Client Credentials Mode (Service Account)
240
+
241
+ Use this mode for service accounts and automation. Recommended for production environments:
242
+
243
+ > [!NOTE]
244
+ > Keep the token lifetime as minimal as possible to reduce security risks. [See more](https://auth0.com/docs/secure/tokens/access-tokens/update-access-token-lifetime)
245
+
246
+ ```bash
247
+ npx @openziti/ziti-mcp-server init \
248
+ --auth-mode client-credentials \
249
+ --ziti-controller-host <your-controller-host> \
250
+ --idp-domain <your-idp-domain> \
251
+ --idp-client-id <your-client-id> \
252
+ --idp-client-secret <your-client-secret>
168
253
  ```
169
254
 
170
255
  > [!IMPORTANT]
@@ -204,9 +289,19 @@ The Ziti MCP server uses OAuth 2.0 device authorization flow for secure authenti
204
289
  <img src="assets/auth-seq.jpg" alt="Authentication Sequence Diagram" width="800">
205
290
  </div>
206
291
 
207
- ## 🛠️ Supported Tools
292
+ #### NOTE for WSL (Windows Subsystem for Linux) Users
293
+
294
+ The Ziti MCP server uses a package called `keytar` to securely manage the token persistence. `keytar` supports mac, win, and linux, however
295
+ WSL doesn't include a running secret service by default. To ensure the Ziti MCP server can properly secure your token, you need to install
296
+ `gnome-keyring`. You can do thet by running the following command:
297
+
298
+ ```bash
299
+ sudo apt install -y libsecret-1-dev gnome-keyring
300
+ ```
301
+
302
+ ## 🛠️ Supported MCP Tools
208
303
 
209
- The Ziti MCP Server provides **126 tools** for managing your Ziti network through natural language. Tools are organized by resource type.
304
+ The Ziti MCP Server provides **206 tools** for managing your Ziti network through natural language. Tools are organized by resource type.
210
305
 
211
306
  > **Tip:** Use `--read-only` or `--tools` patterns to expose only the tools you need. See [Security Best Practices](#-security-best-practices-for-tool-access).
212
307
 
@@ -705,7 +800,7 @@ npx @openziti/ziti-mcp-server help
705
800
  #### 🐞 Debug Mode
706
801
 
707
802
  - More detailed logging
708
- - Enable by setting environment variable: `export DEBUG=ziti-mcp`
803
+ - Enable by setting environment variable: `export DEBUG=ziti-mcp-server`
709
804
 
710
805
  > [!TIP]
711
806
  > Debug mode is particularly useful when troubleshooting connection or authentication issues.
@@ -720,10 +815,10 @@ The server provides an interactive scope selection interface during initializati
720
815
 
721
816
  ```bash
722
817
  # Select all read scopes
723
- npx @openziti/ziti-mcp-server init --scopes 'read:*'
818
+ npx @openziti/ziti-mcp-server init --auth-mode device-auth ... --scopes 'read:*'
724
819
 
725
820
  # Select multiple scope patterns (comma-separated)
726
- npx @openziti/ziti-mcp-server init --scopes 'read:*,create:identities,update:services'
821
+ npx @openziti/ziti-mcp-server init --auth-mode device-auth ... --scopes 'read:*,create:identities,update:services'
727
822
  ```
728
823
 
729
824
  > [!NOTE]
@@ -743,7 +838,7 @@ To use Ziti MCP Server with any other MCP Client, you can add this configuration
743
838
  "args": ["-y", "@openziti/ziti-mcp-server", "run"],
744
839
  "capabilities": ["tools"],
745
840
  "env": {
746
- "DEBUG": "ziti-mcp"
841
+ "DEBUG": "ziti-mcp-server"
747
842
  }
748
843
  }
749
844
  }
@@ -757,22 +852,22 @@ To use Ziti MCP Server with any other MCP Client, you can add this configuration
757
852
 
758
853
  1. **Authentication Failures**
759
854
  - Ensure you have the correct permissions in your IdP tenant and Ziti network
760
- - Try re-initializing with `npx @openziti/ziti-mcp-server init`
855
+ - Try re-initializing with `npx @openziti/ziti-mcp-server init --auth-mode <mode> ...`
761
856
 
762
857
  2. **Claude Desktop Can't Connect to the Server**
763
858
  - Restart Claude Desktop after installation
764
- - Check that the server is running with `ps aux | grep ziti-mcp`
859
+ - Check that the server is running with `ps aux | grep ziti-mcp-server`
765
860
 
766
861
  3. **API Errors or Permission Issues**
767
- - Enable debug mode with `export DEBUG=ziti-mcp`
862
+ - Enable debug mode with `export DEBUG=ziti-mcp-server`
768
863
  - Check your token status: `npx @openziti/ziti-mcp-server session`
769
- - Reinitialize with specific scopes: `npx @openziti/ziti-mcp-server init --scopes 'read:*,update:*,create:*'`
864
+ - Reinitialize with specific scopes: `npx @openziti/ziti-mcp-server init --auth-mode <mode> ... --scopes 'read:*,update:*,create:*'`
770
865
  - If a specific operation fails, you may be missing the required scope
771
866
 
772
867
  4. **Invalid Configuration Error**
773
868
  - This typically happens when your authorization token is missing or expired
774
869
  - Run `npx @openziti/ziti-mcp-server session` to check your token status
775
- - If expired or missing, run `npx @openziti/ziti-mcp-server init` to authenticate
870
+ - If expired or missing, run `npx @openziti/ziti-mcp-server init --auth-mode <mode> ...` to authenticate
776
871
 
777
872
  > [!TIP]
778
873
  > Most connection issues can be resolved by restarting both the server and Claude Desktop.
@@ -782,7 +877,7 @@ To use Ziti MCP Server with any other MCP Client, you can add this configuration
782
877
  Enable debug mode to view detailed logs:
783
878
 
784
879
  ```sh
785
- export DEBUG=ziti-mcp
880
+ export DEBUG=ziti-mcp-server
786
881
  ```
787
882
 
788
883
  Get detailed MCP Client logs from Claude Desktop:
@@ -795,13 +890,13 @@ tail -n 20 -F ~/Library/Logs/Claude/mcp*.log
795
890
  For advanced troubleshooting, use the MCP Inspector:
796
891
 
797
892
  ```sh
798
- npx @modelcontextprotocol/inspector -e DEBUG='ziti-mcp' @openziti/ziti-mcp-server run
893
+ npx @modelcontextprotocol/inspector -e DEBUG='ziti-mcp-server' @openziti/ziti-mcp-server run
799
894
  ```
800
895
 
801
896
  For detailed MCP Server logs, run the server in debug mode:
802
897
 
803
898
  ```bash
804
- DEBUG=ziti-mcp npx @openziti/ziti-mcp-server run
899
+ DEBUG=ziti-mcp-server npx @openziti/ziti-mcp-server run
805
900
  ```
806
901
 
807
902
  ## 👨‍💻 Development
@@ -819,8 +914,8 @@ npm install
819
914
  # Build the project
820
915
  npm run build
821
916
 
822
- # Initiate device auth flow
823
- npx . init
917
+ # Initiate auth flow (choose your auth mode)
918
+ npx . init --auth-mode device-auth --ziti-controller-host <host> --idp-domain <domain> --idp-client-id <id> --idp-audience <audience>
824
919
 
825
920
  # Configure your MCP Client (e.g. Claude Desktop) with MCP server path
826
921
  npm run setup
@@ -2,7 +2,7 @@ import chalk from 'chalk';
2
2
  import { cliOutput } from '../utils/terminal.js';
3
3
  import { log, logError } from '../utils/logger.js';
4
4
  import { keychain } from '../utils/keychain.js';
5
- import { getAuthenticationClient } from '../utils/auth0-client.js';
5
+ import { getTokenEndpoint } from './oidc-discovery.js';
6
6
  /**
7
7
  * Request authorization using client credentials flow
8
8
  *
@@ -15,15 +15,39 @@ import { getAuthenticationClient } from '../utils/auth0-client.js';
15
15
  export async function requestClientCredentialsAuthorization(config) {
16
16
  log('Initiating client credentials flow authentication...');
17
17
  try {
18
- // Auth client
19
- const authClient = await getAuthenticationClient(config.idpDomain, config.idpClientId, config.idpClientSecret);
20
- // Set audience if provided, otherwise use a default based on the domain
21
- const audience = config.audience || `https://${config.idpDomain}/api/v2/`;
18
+ // Discover token endpoint via OIDC discovery
19
+ log(`Discovering OIDC endpoints for ${config.idpDomain}...`);
20
+ const tokenEndpoint = await getTokenEndpoint(config.idpDomain);
21
+ log(`Using token endpoint: ${tokenEndpoint}`);
22
+ // Build the token request body
23
+ const body = {
24
+ grant_type: 'client_credentials',
25
+ client_id: config.idpClientId,
26
+ client_secret: config.idpClientSecret,
27
+ audience: config.audience || `${config.idpDomain}/api/v2/`,
28
+ };
29
+ if (config.audience) {
30
+ body.audience = config.audience;
31
+ }
32
+ if (config.scopes && config.scopes.length > 0) {
33
+ body.scope = config.scopes.join(' ');
34
+ }
22
35
  // Make the token request
23
- const { data: { access_token, expires_in }, } = await authClient.oauth.clientCredentialsGrant({
24
- audience,
36
+ const response = await fetch(tokenEndpoint, {
37
+ method: 'POST',
38
+ headers: {
39
+ Accept: 'application/json',
40
+ 'Content-Type': 'application/x-www-form-urlencoded',
41
+ },
42
+ body: new URLSearchParams(body),
25
43
  });
26
- const tokenSet = { access_token, expires_in };
44
+ const tokenSet = await response.json();
45
+ if (tokenSet.error) {
46
+ throw new Error(`Token request failed: ${tokenSet.error} - ${tokenSet.error_description || ''}`);
47
+ }
48
+ if (!tokenSet.access_token) {
49
+ throw new Error('Token response did not contain an access_token');
50
+ }
27
51
  // Store the token information
28
52
  await storeTokenInfo(tokenSet, config.zitiControllerHost, config.idpDomain);
29
53
  cliOutput(`\n${chalk.green('✓')} Successfully authenticated to ${chalk.blue(config.idpDomain)} using client credentials.\n`);
@@ -36,13 +60,8 @@ export async function requestClientCredentialsAuthorization(config) {
36
60
  }
37
61
  /**
38
62
  * Store token information from client credentials flow
39
- *
40
- * @param {any} tokenSet - Token response from the server
41
- * @param {string} domain - The domain used for authentication
42
63
  */
43
64
  async function storeTokenInfo(tokenSet, zitiControllerHost, domain) {
44
- // For client credentials flow, we use the provided domain directly,
45
- // as the token may not contain tenant information in the same format as device flow
46
65
  // Store access token
47
66
  await keychain.setToken(tokenSet.access_token);
48
67
  await keychain.setZitiControllerHost(zitiControllerHost);
@@ -1 +1 @@
1
- {"version":3,"file":"client-credentials-flow.js","sourceRoot":"","sources":["../../src/auth/client-credentials-flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAA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SAAS,CAAC,CAAC;QAC5C,GAAG,CAAC,qBAAqB,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
@@ -1,47 +1,16 @@
1
1
  declare function requestAuthorization(selectedScopes?: string[], idpDomain?: string, idpClientId?: string, idpAudience?: string): Promise<void>;
2
- export declare function refreshAccessToken(selectedScopes?: string[]): Promise<string | null>;
2
+ export declare function refreshAccessToken(idpDomain?: string, idpClientId?: string): Promise<string | null>;
3
3
  /**
4
- * Revokes the refresh token that is previously set within keychain when offline_access is requested.
5
- * Returns true if the call is successful or if the refresh token does not exist.
6
- * @returns {Promise<boolean>}
4
+ * Revokes the refresh token stored in the keychain.
5
+ * Returns true if successful or if no refresh token exists.
7
6
  */
8
- export declare function revokeRefreshToken(): Promise<boolean>;
7
+ export declare function revokeRefreshToken(idpDomain?: string, idpClientId?: string): Promise<boolean>;
9
8
  /**
10
9
  * Determines if the current access token is expired or will expire soon.
11
- *
12
- * This security check is crucial for maintaining continuous authenticated access
13
- * to Auth0 APIs. It includes a configurable buffer time to proactively detect
14
- * tokens that will expire soon, preventing potential disruptions during operations
15
- * that might span multiple API calls. This proactive approach allows the system to
16
- * initiate refresh flows before actual expiration occurs.
17
- *
18
- * The function considers a token expired in the following cases:
19
- * - No expiration time is found in the keychain via `keychain.getTokenExpiresAt()`
20
- * - Current time + buffer exceeds the token's expiration time
21
- * - Error occurs during expiration check (fails secure)
22
- *
23
- * This function is used both by `validateAuthorization()` in `run.ts` for user-friendly
24
- * startup validation and by `validateConfig()` for continuous runtime validation.
25
- *
26
- * @param {number} bufferSeconds - Seconds before actual expiration to consider token expired (default: 300s/5min)
27
- * @returns {Promise<boolean>} True if token is expired or will expire within the buffer period
28
10
  */
29
11
  export declare function isTokenExpired(bufferSeconds?: number): Promise<boolean>;
30
12
  /**
31
- * Retrieves a valid access token for OpenZiti Controller Management API operations.
32
- *
33
- * This function serves as the main entry point for credential retrieval,
34
- * ensuring that only valid, non-expired tokens are provided to API operations.
35
- * It implements a critical security checkpoint that prevents operations from
36
- * proceeding with invalid authentication, which could lead to API failures
37
- * or unpredictable behavior.
38
- *
39
- * The function performs these key security checks:
40
- * 1. Verifies token expiration status using isTokenExpired
41
- * 2. Provides clear guidance to users when re-authentication is needed
42
- * 3. Handles errors gracefully with a fail-secure approach
43
- *
44
- * @returns {Promise<string|null>} A valid access token, or null if no valid token is available
13
+ * Retrieves a valid access token for API operations.
45
14
  */
46
15
  export declare function getValidAccessToken(): Promise<string | null>;
47
16
  export { requestAuthorization };