@robinmordasiewicz/f5xc-api-mcp 2.0.21-2601081701 → 2.0.21-2601090213

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 (52) hide show
  1. package/dist/generator/tool-generator.d.ts +1 -2
  2. package/dist/generator/tool-generator.d.ts.map +1 -1
  3. package/dist/generator/tool-generator.js +1 -1
  4. package/dist/generator/tool-generator.js.map +1 -1
  5. package/dist/resources/handlers.d.ts +1 -2
  6. package/dist/resources/handlers.d.ts.map +1 -1
  7. package/dist/resources/handlers.js +1 -1
  8. package/dist/resources/handlers.js.map +1 -1
  9. package/dist/server.d.ts +1 -1
  10. package/dist/server.d.ts.map +1 -1
  11. package/dist/server.js +1 -2
  12. package/dist/server.js.map +1 -1
  13. package/dist/tools/configure-auth.d.ts +1 -1
  14. package/dist/tools/configure-auth.d.ts.map +1 -1
  15. package/dist/tools/configure-auth.js +1 -1
  16. package/dist/tools/configure-auth.js.map +1 -1
  17. package/dist/tools/discovery/execute.d.ts +1 -1
  18. package/dist/tools/discovery/execute.d.ts.map +1 -1
  19. package/dist/tools/discovery/execute.js +1 -2
  20. package/dist/tools/discovery/execute.js.map +1 -1
  21. package/dist/version.d.ts +1 -1
  22. package/dist/version.js +1 -1
  23. package/manifest.json +1 -1
  24. package/package.json +2 -1
  25. package/dist/auth/credential-manager.d.ts +0 -177
  26. package/dist/auth/credential-manager.d.ts.map +0 -1
  27. package/dist/auth/credential-manager.js +0 -417
  28. package/dist/auth/credential-manager.js.map +0 -1
  29. package/dist/auth/http-client.d.ts +0 -86
  30. package/dist/auth/http-client.d.ts.map +0 -1
  31. package/dist/auth/http-client.js +0 -255
  32. package/dist/auth/http-client.js.map +0 -1
  33. package/dist/auth/index.d.ts +0 -12
  34. package/dist/auth/index.d.ts.map +0 -1
  35. package/dist/auth/index.js +0 -10
  36. package/dist/auth/index.js.map +0 -1
  37. package/dist/config/paths.d.ts +0 -36
  38. package/dist/config/paths.d.ts.map +0 -1
  39. package/dist/config/paths.js +0 -68
  40. package/dist/config/paths.js.map +0 -1
  41. package/dist/profile/index.d.ts +0 -8
  42. package/dist/profile/index.d.ts.map +0 -1
  43. package/dist/profile/index.js +0 -7
  44. package/dist/profile/index.js.map +0 -1
  45. package/dist/profile/manager.d.ts +0 -74
  46. package/dist/profile/manager.d.ts.map +0 -1
  47. package/dist/profile/manager.js +0 -326
  48. package/dist/profile/manager.js.map +0 -1
  49. package/dist/profile/types.d.ts +0 -53
  50. package/dist/profile/types.d.ts.map +0 -1
  51. package/dist/profile/types.js +0 -7
  52. package/dist/profile/types.js.map +0 -1
@@ -1,177 +0,0 @@
1
- /**
2
- * Credential Manager for F5 Distributed Cloud API
3
- *
4
- * Handles authentication configuration and URL normalization.
5
- * Supports dual-mode operation:
6
- * - Documentation mode: No credentials required
7
- * - Execution mode: API token or P12/Certificate authentication
8
- *
9
- * Uses XDG-compliant profile storage at ~/.config/f5xc/
10
- */
11
- /**
12
- * Authentication modes supported by the server
13
- */
14
- export declare enum AuthMode {
15
- /** No authentication - documentation mode only */
16
- NONE = "none",
17
- /** API token authentication */
18
- TOKEN = "token",
19
- /** P12 certificate authentication (mTLS) */
20
- CERTIFICATE = "certificate"
21
- }
22
- /**
23
- * Environment variable names for authentication
24
- * These take priority over profile settings
25
- */
26
- export declare const AUTH_ENV_VARS: {
27
- readonly API_URL: "F5XC_API_URL";
28
- readonly API_TOKEN: "F5XC_API_TOKEN";
29
- readonly P12_BUNDLE: "F5XC_P12_BUNDLE";
30
- readonly CERT: "F5XC_CERT";
31
- readonly KEY: "F5XC_KEY";
32
- readonly NAMESPACE: "F5XC_NAMESPACE";
33
- readonly TLS_INSECURE: "F5XC_TLS_INSECURE";
34
- readonly CA_BUNDLE: "F5XC_CA_BUNDLE";
35
- };
36
- /**
37
- * Credential configuration for API access
38
- */
39
- export interface Credentials {
40
- /** Authentication mode */
41
- mode: AuthMode;
42
- /** Normalized API URL */
43
- apiUrl: string | null;
44
- /** API token (for token auth) */
45
- token: string | null;
46
- /** P12 certificate buffer (for cert auth) */
47
- p12Certificate: Buffer | null;
48
- /** Certificate content (for mTLS) */
49
- cert: string | null;
50
- /** Private key content (for mTLS) */
51
- key: string | null;
52
- /** Default namespace */
53
- namespace: string | null;
54
- /** Disable TLS certificate verification (staging/development only) */
55
- tlsInsecure: boolean;
56
- /** Custom CA bundle for TLS verification */
57
- caBundle: Buffer | null;
58
- }
59
- /**
60
- * Normalize F5XC tenant URL to standard API endpoint format
61
- *
62
- * Handles various input formats:
63
- * - tenant.volterra.us -> tenant.console.ves.volterra.io/api (production)
64
- * - tenant.staging.volterra.us -> tenant.staging.volterra.us/api (staging - keep as-is)
65
- * - tenant.console.ves.volterra.io -> tenant.console.ves.volterra.io/api
66
- * - Any of the above with trailing slashes or /api suffix
67
- *
68
- * @param input - Raw URL from user configuration
69
- * @returns Normalized API URL
70
- */
71
- export declare function normalizeApiUrl(input: string): string;
72
- /**
73
- * Extract tenant name from a normalized URL
74
- *
75
- * @param url - Normalized API URL
76
- * @returns Tenant name or null if not parseable
77
- */
78
- export declare function extractTenantFromUrl(url: string): string | null;
79
- /**
80
- * Credential Manager
81
- *
82
- * Manages authentication credentials for F5 Distributed Cloud API.
83
- * Supports credential loading with priority:
84
- * 1. Environment variables (highest priority - overrides all)
85
- * 2. Active profile from ~/.config/f5xc/ (XDG Base Directory compliant)
86
- * 3. No credentials (documentation mode - lowest priority)
87
- */
88
- export declare class CredentialManager {
89
- private credentials;
90
- private activeProfileName;
91
- private initialized;
92
- constructor();
93
- /**
94
- * Initialize credentials asynchronously
95
- * Must be called before using credentials
96
- */
97
- initialize(): Promise<void>;
98
- /**
99
- * Load credentials from environment variables
100
- */
101
- private loadFromEnvironment;
102
- /**
103
- * Load credentials from active profile
104
- */
105
- private loadFromProfile;
106
- /**
107
- * Build credentials object from profile data
108
- */
109
- private buildCredentials;
110
- /**
111
- * Load credentials with priority order:
112
- * 1. Environment variables (highest)
113
- * 2. Active profile from ~/.config/f5xc/
114
- * 3. No credentials - documentation mode (lowest)
115
- */
116
- private loadCredentials;
117
- /**
118
- * Get the active profile name (if any)
119
- * Returns null if credentials are from environment variables or no profile is active
120
- */
121
- getActiveProfile(): string | null;
122
- /**
123
- * Get the current authentication mode
124
- */
125
- getAuthMode(): AuthMode;
126
- /**
127
- * Check if the server is in authenticated mode
128
- */
129
- isAuthenticated(): boolean;
130
- /**
131
- * Get the normalized API URL
132
- */
133
- getApiUrl(): string | null;
134
- /**
135
- * Get the tenant name
136
- */
137
- getTenant(): string | null;
138
- /**
139
- * Get API token (for token authentication)
140
- */
141
- getToken(): string | null;
142
- /**
143
- * Get P12 certificate buffer (for certificate authentication)
144
- */
145
- getP12Certificate(): Buffer | null;
146
- /**
147
- * Get certificate content (for mTLS)
148
- */
149
- getCert(): string | null;
150
- /**
151
- * Get private key content (for mTLS)
152
- */
153
- getKey(): string | null;
154
- /**
155
- * Get default namespace
156
- */
157
- getNamespace(): string | null;
158
- /**
159
- * Check if TLS certificate verification is disabled
160
- * WARNING: Only use for staging/development environments
161
- */
162
- getTlsInsecure(): boolean;
163
- /**
164
- * Get custom CA bundle for TLS verification
165
- */
166
- getCaBundle(): Buffer | null;
167
- /**
168
- * Get full credentials object
169
- */
170
- getCredentials(): Readonly<Credentials>;
171
- /**
172
- * Reload credentials from environment/profile
173
- * Useful for testing or when credentials change
174
- */
175
- reload(): Promise<void>;
176
- }
177
- //# sourceMappingURL=credential-manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credential-manager.d.ts","sourceRoot":"","sources":["../../src/auth/credential-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;GAEG;AACH,oBAAY,QAAQ;IAClB,kDAAkD;IAClD,IAAI,SAAS;IACb,+BAA+B;IAC/B,KAAK,UAAU;IACf,4CAA4C;IAC5C,WAAW,gBAAgB;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;CAUhB,CAAC;AAEX;;G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IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B;;OAEG;IACH,QAAQ,IAAI,MAAM,GAAG,IAAI;IAIzB;;OAEG;IACH,iBAAiB,IAAI,MAAM,GAAG,IAAI;IAIlC;;OAEG;IACH,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB;;OAEG;IACH,MAAM,IAAI,MAAM,GAAG,IAAI;IAIvB;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI;IAI7B;;;OAGG;IACH,cAAc,IAAI,OAAO;IAIzB;;OAEG;IACH,WAAW,IAAI,MAAM,GAAG,IAAI;IAI5B;;OAEG;IACH,cAAc,IAAI,QAAQ,CAAC,WAAW,CAAC;IAIvC;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9B"}
@@ -1,417 +0,0 @@
1
- /**
2
- * Credential Manager for F5 Distributed Cloud API
3
- *
4
- * Handles authentication configuration and URL normalization.
5
- * Supports dual-mode operation:
6
- * - Documentation mode: No credentials required
7
- * - Execution mode: API token or P12/Certificate authentication
8
- *
9
- * Uses XDG-compliant profile storage at ~/.config/f5xc/
10
- */
11
- import { readFileSync } from "fs";
12
- import { logger } from "../utils/logging.js";
13
- import { getProfileManager } from "../profile/index.js";
14
- /**
15
- * Authentication modes supported by the server
16
- */
17
- export var AuthMode;
18
- (function (AuthMode) {
19
- /** No authentication - documentation mode only */
20
- AuthMode["NONE"] = "none";
21
- /** API token authentication */
22
- AuthMode["TOKEN"] = "token";
23
- /** P12 certificate authentication (mTLS) */
24
- AuthMode["CERTIFICATE"] = "certificate";
25
- })(AuthMode || (AuthMode = {}));
26
- /**
27
- * Environment variable names for authentication
28
- * These take priority over profile settings
29
- */
30
- export const AUTH_ENV_VARS = {
31
- API_URL: "F5XC_API_URL",
32
- API_TOKEN: "F5XC_API_TOKEN",
33
- P12_BUNDLE: "F5XC_P12_BUNDLE",
34
- CERT: "F5XC_CERT",
35
- KEY: "F5XC_KEY",
36
- NAMESPACE: "F5XC_NAMESPACE",
37
- // TLS configuration
38
- TLS_INSECURE: "F5XC_TLS_INSECURE",
39
- CA_BUNDLE: "F5XC_CA_BUNDLE",
40
- };
41
- /**
42
- * URL normalization patterns
43
- */
44
- const URL_PATTERNS = {
45
- // Match staging short-form URLs: tenant.staging.volterra.us (keep as-is)
46
- STAGING_SHORT_FORM: /^https?:\/\/([^./]+)\.staging\.volterra\.us\/?/i,
47
- // Match production short-form URLs: tenant.volterra.us (convert to console.ves)
48
- PROD_SHORT_FORM: /^https?:\/\/([^./]+)\.volterra\.us\/?/i,
49
- // Match console URLs: tenant.console.ves.volterra.io or tenant.staging.console.ves.volterra.io
50
- CONSOLE_FORM: /^https?:\/\/([^./]+)\.(staging\.)?console\.ves\.volterra\.io\/?/i,
51
- // Trailing slashes and /api suffix
52
- TRAILING_CLEANUP: /\/+$|\/api\/?$/gi,
53
- };
54
- /**
55
- * Normalize F5XC tenant URL to standard API endpoint format
56
- *
57
- * Handles various input formats:
58
- * - tenant.volterra.us -> tenant.console.ves.volterra.io/api (production)
59
- * - tenant.staging.volterra.us -> tenant.staging.volterra.us/api (staging - keep as-is)
60
- * - tenant.console.ves.volterra.io -> tenant.console.ves.volterra.io/api
61
- * - Any of the above with trailing slashes or /api suffix
62
- *
63
- * @param input - Raw URL from user configuration
64
- * @returns Normalized API URL
65
- */
66
- export function normalizeApiUrl(input) {
67
- // Remove trailing slashes and existing /api suffix
68
- let url = input.replace(URL_PATTERNS.TRAILING_CLEANUP, "");
69
- // Handle staging short-form URLs - keep as-is (don't convert to console.ves)
70
- const stagingMatch = url.match(URL_PATTERNS.STAGING_SHORT_FORM);
71
- if (stagingMatch) {
72
- const tenant = stagingMatch[1];
73
- url = `https://${tenant}.staging.volterra.us`;
74
- // Ensure /api suffix and return early
75
- return `${url}/api`;
76
- }
77
- // Handle production short-form URLs (tenant.volterra.us -> tenant.console.ves.volterra.io)
78
- const prodMatch = url.match(URL_PATTERNS.PROD_SHORT_FORM);
79
- if (prodMatch) {
80
- const tenant = prodMatch[1];
81
- url = `https://${tenant}.console.ves.volterra.io`;
82
- }
83
- // Handle console URLs - ensure https
84
- const consoleMatch = url.match(URL_PATTERNS.CONSOLE_FORM);
85
- if (consoleMatch) {
86
- const tenant = consoleMatch[1];
87
- const staging = consoleMatch[2] ?? "";
88
- url = `https://${tenant}.${staging}console.ves.volterra.io`;
89
- }
90
- // Ensure /api suffix
91
- return `${url}/api`;
92
- }
93
- /**
94
- * Extract tenant name from a normalized URL
95
- *
96
- * @param url - Normalized API URL
97
- * @returns Tenant name or null if not parseable
98
- */
99
- export function extractTenantFromUrl(url) {
100
- const match = url.match(/https?:\/\/([^./]+)\./);
101
- return match?.[1] ?? null;
102
- }
103
- /**
104
- * Credential Manager
105
- *
106
- * Manages authentication credentials for F5 Distributed Cloud API.
107
- * Supports credential loading with priority:
108
- * 1. Environment variables (highest priority - overrides all)
109
- * 2. Active profile from ~/.config/f5xc/ (XDG Base Directory compliant)
110
- * 3. No credentials (documentation mode - lowest priority)
111
- */
112
- export class CredentialManager {
113
- credentials;
114
- activeProfileName = null;
115
- initialized = false;
116
- constructor() {
117
- // Initialize with empty credentials - will be loaded async
118
- this.credentials = {
119
- mode: AuthMode.NONE,
120
- apiUrl: null,
121
- token: null,
122
- p12Certificate: null,
123
- cert: null,
124
- key: null,
125
- namespace: null,
126
- tlsInsecure: false,
127
- caBundle: null,
128
- };
129
- }
130
- /**
131
- * Initialize credentials asynchronously
132
- * Must be called before using credentials
133
- */
134
- async initialize() {
135
- if (this.initialized)
136
- return;
137
- this.credentials = await this.loadCredentials();
138
- this.initialized = true;
139
- }
140
- /**
141
- * Load credentials from environment variables
142
- */
143
- loadFromEnvironment() {
144
- const apiUrl = process.env[AUTH_ENV_VARS.API_URL];
145
- const apiToken = process.env[AUTH_ENV_VARS.API_TOKEN];
146
- const p12Bundle = process.env[AUTH_ENV_VARS.P12_BUNDLE];
147
- const cert = process.env[AUTH_ENV_VARS.CERT];
148
- const key = process.env[AUTH_ENV_VARS.KEY];
149
- const defaultNamespace = process.env[AUTH_ENV_VARS.NAMESPACE];
150
- const tlsInsecure = process.env[AUTH_ENV_VARS.TLS_INSECURE]?.toLowerCase() === "true";
151
- const caBundle = process.env[AUTH_ENV_VARS.CA_BUNDLE];
152
- const hasAuth = !!(apiToken || p12Bundle || (cert && key));
153
- return {
154
- name: "__env__",
155
- apiUrl: apiUrl || "",
156
- apiToken,
157
- p12Bundle,
158
- cert,
159
- key,
160
- defaultNamespace,
161
- hasAuth,
162
- tlsInsecure,
163
- caBundle,
164
- };
165
- }
166
- /**
167
- * Load credentials from active profile
168
- */
169
- async loadFromProfile() {
170
- try {
171
- const profileManager = getProfileManager();
172
- const profile = await profileManager.getActiveProfile();
173
- if (profile) {
174
- this.activeProfileName = profile.name;
175
- return profile;
176
- }
177
- return null;
178
- }
179
- catch (error) {
180
- logger.debug("Failed to load credentials from profile", {
181
- error: error instanceof Error ? error.message : String(error),
182
- });
183
- return null;
184
- }
185
- }
186
- /**
187
- * Build credentials object from profile data
188
- */
189
- buildCredentials(profile) {
190
- const apiUrl = profile.apiUrl;
191
- // Determine authentication mode
192
- let mode = AuthMode.NONE;
193
- let normalizedUrl = null;
194
- let p12Certificate = null;
195
- let cert = null;
196
- let key = null;
197
- // TLS configuration
198
- const tlsInsecure = profile.tlsInsecure ?? false;
199
- let caBundle = null;
200
- // Load CA bundle if specified
201
- if (profile.caBundle) {
202
- try {
203
- caBundle = readFileSync(profile.caBundle);
204
- logger.info("Loaded CA bundle", { file: profile.caBundle });
205
- }
206
- catch (error) {
207
- logger.warn("Failed to load CA bundle", {
208
- file: profile.caBundle,
209
- error: error instanceof Error ? error.message : String(error),
210
- });
211
- }
212
- }
213
- // Log TLS insecure mode warning
214
- if (tlsInsecure) {
215
- logger.warn("TLS certificate verification is DISABLED. This is insecure and should only be used for staging/development environments.");
216
- }
217
- if (apiUrl) {
218
- normalizedUrl = normalizeApiUrl(apiUrl);
219
- if (profile.p12Bundle) {
220
- // P12 certificate authentication
221
- mode = AuthMode.CERTIFICATE;
222
- try {
223
- p12Certificate = readFileSync(profile.p12Bundle);
224
- logger.info("Loaded P12 certificate", { file: profile.p12Bundle });
225
- }
226
- catch (error) {
227
- logger.error("Failed to load P12 certificate", {
228
- file: profile.p12Bundle,
229
- error: error instanceof Error ? error.message : String(error),
230
- });
231
- // Fall back to token auth if certificate load fails
232
- if (profile.apiToken) {
233
- mode = AuthMode.TOKEN;
234
- logger.info("Falling back to token authentication");
235
- }
236
- else {
237
- mode = AuthMode.NONE;
238
- }
239
- }
240
- }
241
- else if (profile.cert && profile.key) {
242
- // Certificate + key authentication
243
- mode = AuthMode.CERTIFICATE;
244
- try {
245
- cert = readFileSync(profile.cert, "utf-8");
246
- key = readFileSync(profile.key, "utf-8");
247
- logger.info("Loaded certificate and key", {
248
- cert: profile.cert,
249
- key: profile.key,
250
- });
251
- }
252
- catch (error) {
253
- logger.error("Failed to load certificate/key", {
254
- error: error instanceof Error ? error.message : String(error),
255
- });
256
- if (profile.apiToken) {
257
- mode = AuthMode.TOKEN;
258
- logger.info("Falling back to token authentication");
259
- }
260
- else {
261
- mode = AuthMode.NONE;
262
- }
263
- }
264
- }
265
- else if (profile.apiToken) {
266
- mode = AuthMode.TOKEN;
267
- }
268
- }
269
- return {
270
- mode,
271
- apiUrl: normalizedUrl,
272
- token: profile.apiToken ?? null,
273
- p12Certificate,
274
- cert,
275
- key,
276
- namespace: profile.defaultNamespace ?? null,
277
- tlsInsecure,
278
- caBundle,
279
- };
280
- }
281
- /**
282
- * Load credentials with priority order:
283
- * 1. Environment variables (highest)
284
- * 2. Active profile from ~/.config/f5xc/
285
- * 3. No credentials - documentation mode (lowest)
286
- */
287
- async loadCredentials() {
288
- // Step 1: Check environment variables first (highest priority)
289
- const envCreds = this.loadFromEnvironment();
290
- if (envCreds.apiUrl && envCreds.hasAuth) {
291
- const credentials = this.buildCredentials(envCreds);
292
- const tenant = credentials.apiUrl ? extractTenantFromUrl(credentials.apiUrl) : null;
293
- logger.info("Credentials loaded from environment variables", {
294
- mode: credentials.mode,
295
- tenant,
296
- });
297
- return credentials;
298
- }
299
- // Step 2: Try active profile from ~/.config/f5xc/
300
- const profile = await this.loadFromProfile();
301
- if (profile) {
302
- const credentials = this.buildCredentials(profile);
303
- if (credentials.mode !== AuthMode.NONE) {
304
- const tenant = credentials.apiUrl ? extractTenantFromUrl(credentials.apiUrl) : null;
305
- logger.info("Credentials loaded from profile", {
306
- mode: credentials.mode,
307
- tenant,
308
- profile: this.activeProfileName,
309
- });
310
- return credentials;
311
- }
312
- }
313
- // Step 3: No credentials - documentation mode (lowest priority)
314
- logger.info("No credentials configured - running in documentation mode");
315
- return {
316
- mode: AuthMode.NONE,
317
- apiUrl: null,
318
- token: null,
319
- p12Certificate: null,
320
- cert: null,
321
- key: null,
322
- namespace: null,
323
- tlsInsecure: false,
324
- caBundle: null,
325
- };
326
- }
327
- /**
328
- * Get the active profile name (if any)
329
- * Returns null if credentials are from environment variables or no profile is active
330
- */
331
- getActiveProfile() {
332
- return this.activeProfileName;
333
- }
334
- /**
335
- * Get the current authentication mode
336
- */
337
- getAuthMode() {
338
- return this.credentials.mode;
339
- }
340
- /**
341
- * Check if the server is in authenticated mode
342
- */
343
- isAuthenticated() {
344
- return this.credentials.mode !== AuthMode.NONE;
345
- }
346
- /**
347
- * Get the normalized API URL
348
- */
349
- getApiUrl() {
350
- return this.credentials.apiUrl;
351
- }
352
- /**
353
- * Get the tenant name
354
- */
355
- getTenant() {
356
- return this.credentials.apiUrl ? extractTenantFromUrl(this.credentials.apiUrl) : null;
357
- }
358
- /**
359
- * Get API token (for token authentication)
360
- */
361
- getToken() {
362
- return this.credentials.token;
363
- }
364
- /**
365
- * Get P12 certificate buffer (for certificate authentication)
366
- */
367
- getP12Certificate() {
368
- return this.credentials.p12Certificate;
369
- }
370
- /**
371
- * Get certificate content (for mTLS)
372
- */
373
- getCert() {
374
- return this.credentials.cert;
375
- }
376
- /**
377
- * Get private key content (for mTLS)
378
- */
379
- getKey() {
380
- return this.credentials.key;
381
- }
382
- /**
383
- * Get default namespace
384
- */
385
- getNamespace() {
386
- return this.credentials.namespace;
387
- }
388
- /**
389
- * Check if TLS certificate verification is disabled
390
- * WARNING: Only use for staging/development environments
391
- */
392
- getTlsInsecure() {
393
- return this.credentials.tlsInsecure;
394
- }
395
- /**
396
- * Get custom CA bundle for TLS verification
397
- */
398
- getCaBundle() {
399
- return this.credentials.caBundle;
400
- }
401
- /**
402
- * Get full credentials object
403
- */
404
- getCredentials() {
405
- return Object.freeze({ ...this.credentials });
406
- }
407
- /**
408
- * Reload credentials from environment/profile
409
- * Useful for testing or when credentials change
410
- */
411
- async reload() {
412
- this.initialized = false;
413
- this.activeProfileName = null;
414
- await this.initialize();
415
- }
416
- }
417
- //# sourceMappingURL=credential-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../src/auth/credential-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAgB,MAAM,qBAAqB,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,kDAAkD;IAClD,yBAAa,CAAA;IACb,+BAA+B;IAC/B,2BAAe,CAAA;IACf,4CAA4C;IAC5C,uCAA2B,CAAA;AAC7B,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,cAAc;IACvB,SAAS,EAAE,gBAAgB;IAC3B,UAAU,EAAE,iBAAiB;IAC7B,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,UAAU;IACf,SAAS,EAAE,gBAAgB;IAC3B,oBAAoB;IACpB,YAAY,EAAE,mBAAmB;IACjC,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