@robinmordasiewicz/f5xc-auth 1.0.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/LICENSE +21 -0
- package/README.md +153 -0
- package/dist/auth/credential-manager.d.ts +177 -0
- package/dist/auth/credential-manager.d.ts.map +1 -0
- package/dist/auth/credential-manager.js +417 -0
- package/dist/auth/credential-manager.js.map +1 -0
- package/dist/auth/http-client.d.ts +86 -0
- package/dist/auth/http-client.d.ts.map +1 -0
- package/dist/auth/http-client.js +255 -0
- package/dist/auth/http-client.js.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +5 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/paths.d.ts +36 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +68 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/profile/index.d.ts +6 -0
- package/dist/profile/index.d.ts.map +1 -0
- package/dist/profile/index.js +6 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/profile/manager.d.ts +74 -0
- package/dist/profile/manager.d.ts.map +1 -0
- package/dist/profile/manager.js +326 -0
- package/dist/profile/manager.js.map +1 -0
- package/dist/profile/types.d.ts +53 -0
- package/dist/profile/types.d.ts.map +1 -0
- package/dist/profile/types.js +7 -0
- package/dist/profile/types.js.map +1 -0
- package/dist/utils/errors.d.ts +66 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +179 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logging.d.ts +75 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/logging.js +131 -0
- package/dist/utils/logging.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authenticated HTTP Client for F5 Distributed Cloud API
|
|
3
|
+
*
|
|
4
|
+
* Provides a configured Axios client for making authenticated API requests.
|
|
5
|
+
* Supports both API token and P12 certificate (mTLS) authentication.
|
|
6
|
+
*/
|
|
7
|
+
import axios from "axios";
|
|
8
|
+
import https from "https";
|
|
9
|
+
import { AuthMode } from "./credential-manager.js";
|
|
10
|
+
import { logger } from "../utils/logging.js";
|
|
11
|
+
import { F5XCApiError, AuthenticationError, wrapSSLError } from "../utils/errors.js";
|
|
12
|
+
/**
|
|
13
|
+
* Default HTTP client configuration
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_CONFIG = {
|
|
16
|
+
timeout: 30000, // 30 seconds
|
|
17
|
+
headers: {},
|
|
18
|
+
debug: false,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* HTTP Client for F5XC API
|
|
22
|
+
*
|
|
23
|
+
* Creates and manages an authenticated Axios instance for making
|
|
24
|
+
* API requests to F5 Distributed Cloud.
|
|
25
|
+
*/
|
|
26
|
+
export class HttpClient {
|
|
27
|
+
client = null;
|
|
28
|
+
credentialManager;
|
|
29
|
+
config;
|
|
30
|
+
constructor(credentialManager, config = {}) {
|
|
31
|
+
this.credentialManager = credentialManager;
|
|
32
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
33
|
+
if (this.credentialManager.isAuthenticated()) {
|
|
34
|
+
this.client = this.createClient();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build HTTPS agent options from credential manager TLS configuration
|
|
39
|
+
* Handles SSL/TLS configuration including insecure mode and custom CA
|
|
40
|
+
*/
|
|
41
|
+
buildHttpsAgentOptions() {
|
|
42
|
+
const options = {
|
|
43
|
+
rejectUnauthorized: true, // Secure default
|
|
44
|
+
};
|
|
45
|
+
// Check for custom CA bundle
|
|
46
|
+
const caBundle = this.credentialManager.getCaBundle();
|
|
47
|
+
if (caBundle) {
|
|
48
|
+
options.ca = caBundle;
|
|
49
|
+
logger.info("Using custom CA bundle for TLS verification");
|
|
50
|
+
}
|
|
51
|
+
// Check for insecure mode (staging/development ONLY)
|
|
52
|
+
const tlsInsecure = this.credentialManager.getTlsInsecure();
|
|
53
|
+
if (tlsInsecure) {
|
|
54
|
+
options.rejectUnauthorized = false;
|
|
55
|
+
// Output to stderr for maximum visibility (always shown, even if logs are filtered)
|
|
56
|
+
const apiUrl = this.credentialManager.getApiUrl() ?? "unknown";
|
|
57
|
+
console.error("\n\x1b[33m⚠️ WARNING: TLS certificate verification is DISABLED\x1b[0m");
|
|
58
|
+
console.error(` URL: ${apiUrl}`);
|
|
59
|
+
console.error(" This should ONLY be used for staging/development environments!");
|
|
60
|
+
console.error(" Consider using F5XC_CA_BUNDLE for a more secure solution.\n");
|
|
61
|
+
logger.warn("TLS certificate verification DISABLED - this is insecure and should only be used for staging/development");
|
|
62
|
+
}
|
|
63
|
+
return options;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create configured Axios client
|
|
67
|
+
*/
|
|
68
|
+
createClient() {
|
|
69
|
+
const authMode = this.credentialManager.getAuthMode();
|
|
70
|
+
const baseURL = this.credentialManager.getApiUrl();
|
|
71
|
+
if (!baseURL) {
|
|
72
|
+
throw new AuthenticationError("API URL not configured");
|
|
73
|
+
}
|
|
74
|
+
const axiosConfig = {
|
|
75
|
+
baseURL,
|
|
76
|
+
timeout: this.config.timeout,
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
Accept: "application/json",
|
|
80
|
+
...this.config.headers,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
// Get TLS configuration options
|
|
84
|
+
const tlsOptions = this.buildHttpsAgentOptions();
|
|
85
|
+
// Configure authentication
|
|
86
|
+
if (authMode === AuthMode.TOKEN) {
|
|
87
|
+
const token = this.credentialManager.getToken();
|
|
88
|
+
if (!token) {
|
|
89
|
+
throw new AuthenticationError("API token not configured");
|
|
90
|
+
}
|
|
91
|
+
axiosConfig.headers = {
|
|
92
|
+
...axiosConfig.headers,
|
|
93
|
+
Authorization: `APIToken ${token}`,
|
|
94
|
+
};
|
|
95
|
+
// Apply TLS configuration for token auth (needed for custom CA or insecure mode)
|
|
96
|
+
if (tlsOptions.ca || !tlsOptions.rejectUnauthorized) {
|
|
97
|
+
axiosConfig.httpsAgent = new https.Agent(tlsOptions);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (authMode === AuthMode.CERTIFICATE) {
|
|
101
|
+
const p12Buffer = this.credentialManager.getP12Certificate();
|
|
102
|
+
const cert = this.credentialManager.getCert();
|
|
103
|
+
const key = this.credentialManager.getKey();
|
|
104
|
+
if (p12Buffer) {
|
|
105
|
+
// Create HTTPS agent with P12 certificate for mTLS
|
|
106
|
+
// F5XC P12 certificates typically don't require a password
|
|
107
|
+
axiosConfig.httpsAgent = new https.Agent({
|
|
108
|
+
...tlsOptions,
|
|
109
|
+
pfx: p12Buffer,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else if (cert && key) {
|
|
113
|
+
// Create HTTPS agent with separate cert/key for mTLS
|
|
114
|
+
axiosConfig.httpsAgent = new https.Agent({
|
|
115
|
+
...tlsOptions,
|
|
116
|
+
cert,
|
|
117
|
+
key,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
throw new AuthenticationError("Certificate not loaded - provide P12 bundle or cert/key pair");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const client = axios.create(axiosConfig);
|
|
125
|
+
// Add request interceptor for logging
|
|
126
|
+
client.interceptors.request.use((config) => {
|
|
127
|
+
// Add request timestamp for duration calculation
|
|
128
|
+
config.metadata = {
|
|
129
|
+
startTime: Date.now(),
|
|
130
|
+
};
|
|
131
|
+
if (this.config.debug) {
|
|
132
|
+
logger.debug("API Request", {
|
|
133
|
+
method: config.method?.toUpperCase(),
|
|
134
|
+
url: config.url,
|
|
135
|
+
baseURL: config.baseURL,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return config;
|
|
139
|
+
}, (error) => {
|
|
140
|
+
logger.error("Request interceptor error", { error });
|
|
141
|
+
return Promise.reject(error);
|
|
142
|
+
});
|
|
143
|
+
// Add response interceptor for logging and error handling
|
|
144
|
+
client.interceptors.response.use((response) => {
|
|
145
|
+
const config = response.config;
|
|
146
|
+
const duration = config.metadata ? Date.now() - config.metadata.startTime : 0;
|
|
147
|
+
if (this.config.debug) {
|
|
148
|
+
logger.debug("API Response", {
|
|
149
|
+
status: response.status,
|
|
150
|
+
url: response.config.url,
|
|
151
|
+
duration: `${duration}ms`,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return response;
|
|
155
|
+
}, (error) => {
|
|
156
|
+
if (axios.isAxiosError(error)) {
|
|
157
|
+
// Check for SSL/TLS certificate errors first
|
|
158
|
+
const errorCode = error.code?.toLowerCase() ?? "";
|
|
159
|
+
const errorMessage = error.message.toLowerCase();
|
|
160
|
+
if (errorCode === "err_tls_cert_altname_invalid" ||
|
|
161
|
+
errorCode === "unable_to_verify_leaf_signature" ||
|
|
162
|
+
errorCode === "depth_zero_self_signed_cert" ||
|
|
163
|
+
errorCode === "cert_has_expired" ||
|
|
164
|
+
errorMessage.includes("certificate") ||
|
|
165
|
+
errorMessage.includes("altnames") ||
|
|
166
|
+
errorMessage.includes("self signed")) {
|
|
167
|
+
// Wrap SSL error with actionable guidance
|
|
168
|
+
throw wrapSSLError(error, baseURL);
|
|
169
|
+
}
|
|
170
|
+
const status = error.response?.status;
|
|
171
|
+
const message = error.response?.data?.message ?? error.message;
|
|
172
|
+
logger.error("API Error", {
|
|
173
|
+
status,
|
|
174
|
+
message,
|
|
175
|
+
url: error.config?.url,
|
|
176
|
+
});
|
|
177
|
+
// Transform to F5XC API error
|
|
178
|
+
throw new F5XCApiError(message, status, error.response?.data);
|
|
179
|
+
}
|
|
180
|
+
throw error;
|
|
181
|
+
});
|
|
182
|
+
logger.info("HTTP client created", {
|
|
183
|
+
baseURL,
|
|
184
|
+
authMode,
|
|
185
|
+
timeout: this.config.timeout,
|
|
186
|
+
});
|
|
187
|
+
return client;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Check if the client is available (authenticated mode)
|
|
191
|
+
*/
|
|
192
|
+
isAvailable() {
|
|
193
|
+
return this.client !== null;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Make a GET request
|
|
197
|
+
*/
|
|
198
|
+
async get(path, config) {
|
|
199
|
+
return this.request("GET", path, undefined, config);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Make a POST request
|
|
203
|
+
*/
|
|
204
|
+
async post(path, data, config) {
|
|
205
|
+
return this.request("POST", path, data, config);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Make a PUT request
|
|
209
|
+
*/
|
|
210
|
+
async put(path, data, config) {
|
|
211
|
+
return this.request("PUT", path, data, config);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Make a DELETE request
|
|
215
|
+
*/
|
|
216
|
+
async delete(path, config) {
|
|
217
|
+
return this.request("DELETE", path, undefined, config);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Make a generic request
|
|
221
|
+
*/
|
|
222
|
+
async request(method, path, data, config) {
|
|
223
|
+
if (!this.client) {
|
|
224
|
+
throw new AuthenticationError("HTTP client not available - server is in documentation mode. " +
|
|
225
|
+
"Set F5XC_API_URL and F5XC_API_TOKEN (or F5XC_P12_BUNDLE for certificate auth) to enable API execution.");
|
|
226
|
+
}
|
|
227
|
+
const startTime = Date.now();
|
|
228
|
+
const response = await this.client.request({
|
|
229
|
+
method,
|
|
230
|
+
url: path,
|
|
231
|
+
data,
|
|
232
|
+
...config,
|
|
233
|
+
});
|
|
234
|
+
const duration = Date.now() - startTime;
|
|
235
|
+
return {
|
|
236
|
+
data: response.data,
|
|
237
|
+
status: response.status,
|
|
238
|
+
headers: response.headers,
|
|
239
|
+
duration,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Get the underlying Axios instance
|
|
244
|
+
*/
|
|
245
|
+
getAxiosInstance() {
|
|
246
|
+
return this.client;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Create HTTP client from credential manager
|
|
251
|
+
*/
|
|
252
|
+
export function createHttpClient(credentialManager, config) {
|
|
253
|
+
return new HttpClient(credentialManager, config);
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/auth/http-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAKN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAqB,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAcrF;;GAEG;AACH,MAAM,cAAc,GAA+B;IACjD,OAAO,EAAE,KAAK,EAAE,aAAa;IAC7B,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,KAAK;CACb,CAAC;AAgBF;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACb,MAAM,GAAyB,IAAI,CAAC;IACpC,iBAAiB,CAAoB;IACrC,MAAM,CAA6B;IAE3C,YAAY,iBAAoC,EAAE,SAA2B,EAAE;QAC7E,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;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"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XDG Base Directory compliant paths for F5 XC configuration
|
|
3
|
+
* See: https://specifications.freedesktop.org/basedir/latest/
|
|
4
|
+
*
|
|
5
|
+
* This is the single source of truth for all application paths.
|
|
6
|
+
* All modules should import from here instead of constructing paths directly.
|
|
7
|
+
*
|
|
8
|
+
* Default paths:
|
|
9
|
+
* - Config: ~/.config/f5xc/
|
|
10
|
+
* - State: ~/.local/state/f5xc/
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Get XDG-compliant config directory
|
|
14
|
+
* Config files: settings, profiles, preferences
|
|
15
|
+
* Default: ~/.config/f5xc
|
|
16
|
+
*/
|
|
17
|
+
export declare function getConfigDir(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get XDG-compliant state directory
|
|
20
|
+
* State files: history, logs, undo history, session state
|
|
21
|
+
* Default: ~/.local/state/f5xc
|
|
22
|
+
*/
|
|
23
|
+
export declare function getStateDir(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Centralized path definitions
|
|
26
|
+
* Use these getters for all file path access throughout the application
|
|
27
|
+
*/
|
|
28
|
+
export declare const paths: {
|
|
29
|
+
readonly configDir: string;
|
|
30
|
+
readonly profilesDir: string;
|
|
31
|
+
readonly activeProfile: string;
|
|
32
|
+
readonly settings: string;
|
|
33
|
+
readonly stateDir: string;
|
|
34
|
+
readonly history: string;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAMpC;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK;wBAEC,MAAM;0BAGJ,MAAM;4BAGJ,MAAM;uBAGX,MAAM;uBAKN,MAAM;sBAGP,MAAM;CAGtB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XDG Base Directory compliant paths for F5 XC configuration
|
|
3
|
+
* See: https://specifications.freedesktop.org/basedir/latest/
|
|
4
|
+
*
|
|
5
|
+
* This is the single source of truth for all application paths.
|
|
6
|
+
* All modules should import from here instead of constructing paths directly.
|
|
7
|
+
*
|
|
8
|
+
* Default paths:
|
|
9
|
+
* - Config: ~/.config/f5xc/
|
|
10
|
+
* - State: ~/.local/state/f5xc/
|
|
11
|
+
*/
|
|
12
|
+
import { homedir } from "os";
|
|
13
|
+
import { join } from "path";
|
|
14
|
+
/**
|
|
15
|
+
* Application name for XDG-compliant directory structure
|
|
16
|
+
*/
|
|
17
|
+
const APP_NAME = "f5xc";
|
|
18
|
+
/**
|
|
19
|
+
* Get XDG-compliant config directory
|
|
20
|
+
* Config files: settings, profiles, preferences
|
|
21
|
+
* Default: ~/.config/f5xc
|
|
22
|
+
*/
|
|
23
|
+
export function getConfigDir() {
|
|
24
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
25
|
+
if (xdgConfig) {
|
|
26
|
+
return join(xdgConfig, APP_NAME);
|
|
27
|
+
}
|
|
28
|
+
return join(homedir(), ".config", APP_NAME);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get XDG-compliant state directory
|
|
32
|
+
* State files: history, logs, undo history, session state
|
|
33
|
+
* Default: ~/.local/state/f5xc
|
|
34
|
+
*/
|
|
35
|
+
export function getStateDir() {
|
|
36
|
+
const xdgState = process.env.XDG_STATE_HOME;
|
|
37
|
+
if (xdgState) {
|
|
38
|
+
return join(xdgState, APP_NAME);
|
|
39
|
+
}
|
|
40
|
+
return join(homedir(), ".local", "state", APP_NAME);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Centralized path definitions
|
|
44
|
+
* Use these getters for all file path access throughout the application
|
|
45
|
+
*/
|
|
46
|
+
export const paths = {
|
|
47
|
+
// Config files (XDG_CONFIG_HOME)
|
|
48
|
+
get configDir() {
|
|
49
|
+
return getConfigDir();
|
|
50
|
+
},
|
|
51
|
+
get profilesDir() {
|
|
52
|
+
return join(getConfigDir(), "profiles");
|
|
53
|
+
},
|
|
54
|
+
get activeProfile() {
|
|
55
|
+
return join(getConfigDir(), "active_profile");
|
|
56
|
+
},
|
|
57
|
+
get settings() {
|
|
58
|
+
return join(getConfigDir(), "config.yaml");
|
|
59
|
+
},
|
|
60
|
+
// State files (XDG_STATE_HOME)
|
|
61
|
+
get stateDir() {
|
|
62
|
+
return getStateDir();
|
|
63
|
+
},
|
|
64
|
+
get history() {
|
|
65
|
+
return join(getStateDir(), "history");
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B;;GAEG;AACH,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAA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
4
|
+
* Shared authentication library for F5 Distributed Cloud MCP servers.
|
|
5
|
+
* Provides XDG-compliant profile management and credential handling.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { CredentialManager, ProfileManager, getProfileManager } from '@robinmordasiewicz/f5xc-auth';
|
|
10
|
+
*
|
|
11
|
+
* // Initialize credentials
|
|
12
|
+
* const credentialManager = new CredentialManager();
|
|
13
|
+
* await credentialManager.initialize();
|
|
14
|
+
*
|
|
15
|
+
* if (credentialManager.isAuthenticated()) {
|
|
16
|
+
* console.log(`Authenticated as: ${credentialManager.getTenant()}`);
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // Manage profiles
|
|
20
|
+
* const profileManager = getProfileManager();
|
|
21
|
+
* const profiles = await profileManager.list();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export { CredentialManager, AuthMode, AUTH_ENV_VARS, normalizeApiUrl, extractTenantFromUrl, type Credentials, } from "./auth/credential-manager.js";
|
|
25
|
+
export { HttpClient, createHttpClient, type HttpClientConfig, type ApiResponse, } from "./auth/http-client.js";
|
|
26
|
+
export { ProfileManager, getProfileManager, type Profile, type ProfileConfig, type ProfileResult, type ProfileValidationError, } from "./profile/index.js";
|
|
27
|
+
export { paths, getConfigDir, getStateDir } from "./config/paths.js";
|
|
28
|
+
export { logger, createLogger, LogLevel, type LoggerConfig, } from "./utils/logging.js";
|
|
29
|
+
export { F5XCError, AuthenticationError, F5XCApiError, ConfigurationError, SSLCertificateError, wrapSSLError, } from "./utils/errors.js";
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,KAAK,WAAW,GACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,sBAAsB,GAC5B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EACL,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @robinmordasiewicz/f5xc-auth
|
|
3
|
+
*
|
|
4
|
+
* Shared authentication library for F5 Distributed Cloud MCP servers.
|
|
5
|
+
* Provides XDG-compliant profile management and credential handling.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { CredentialManager, ProfileManager, getProfileManager } from '@robinmordasiewicz/f5xc-auth';
|
|
10
|
+
*
|
|
11
|
+
* // Initialize credentials
|
|
12
|
+
* const credentialManager = new CredentialManager();
|
|
13
|
+
* await credentialManager.initialize();
|
|
14
|
+
*
|
|
15
|
+
* if (credentialManager.isAuthenticated()) {
|
|
16
|
+
* console.log(`Authenticated as: ${credentialManager.getTenant()}`);
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // Manage profiles
|
|
20
|
+
* const profileManager = getProfileManager();
|
|
21
|
+
* const profiles = await profileManager.list();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
// Auth module
|
|
25
|
+
export { CredentialManager, AuthMode, AUTH_ENV_VARS, normalizeApiUrl, extractTenantFromUrl, } from "./auth/credential-manager.js";
|
|
26
|
+
export { HttpClient, createHttpClient, } from "./auth/http-client.js";
|
|
27
|
+
// Profile module
|
|
28
|
+
export { ProfileManager, getProfileManager, } from "./profile/index.js";
|
|
29
|
+
// Config module
|
|
30
|
+
export { paths, getConfigDir, getStateDir } from "./config/paths.js";
|
|
31
|
+
// Utils module
|
|
32
|
+
export { logger, createLogger, LogLevel, } from "./utils/logging.js";
|
|
33
|
+
export { F5XCError, AuthenticationError, F5XCApiError, ConfigurationError, SSLCertificateError, wrapSSLError, } from "./utils/errors.js";
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,cAAc;AACd,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,aAAa,EACb,eAAe,EACf,oBAAoB,GAErB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,UAAU,EACV,gBAAgB,GAGjB,MAAM,uBAAuB,CAAC;AAE/B,iBAAiB;AACjB,OAAO,EACL,cAAc,EACd,iBAAiB,GAKlB,MAAM,oBAAoB,CAAC;AAE5B,gBAAgB;AAChB,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErE,eAAe;AACf,OAAO,EACL,MAAM,EACN,YAAY,EACZ,QAAQ,GAET,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/profile/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/profile/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProfileManager - XDG-compliant profile storage and management
|
|
3
|
+
*
|
|
4
|
+
* Profiles are stored in ~/.config/f5xc/profiles/ (XDG Base Directory compliant)
|
|
5
|
+
*/
|
|
6
|
+
import type { Profile, ProfileResult } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* ProfileManager handles profile CRUD operations with secure file storage
|
|
9
|
+
*/
|
|
10
|
+
export declare class ProfileManager {
|
|
11
|
+
private config;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Ensure config directories exist
|
|
15
|
+
*/
|
|
16
|
+
ensureDirectories(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Get path to profile JSON file
|
|
19
|
+
*/
|
|
20
|
+
private getProfilePath;
|
|
21
|
+
/**
|
|
22
|
+
* Validate profile name (alphanumeric, dash, underscore only)
|
|
23
|
+
*/
|
|
24
|
+
private isValidName;
|
|
25
|
+
/**
|
|
26
|
+
* Validate API URL format
|
|
27
|
+
*/
|
|
28
|
+
private isValidUrl;
|
|
29
|
+
/**
|
|
30
|
+
* List all saved profiles
|
|
31
|
+
*/
|
|
32
|
+
list(): Promise<Profile[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Get a profile by name
|
|
35
|
+
*/
|
|
36
|
+
get(name: string): Promise<Profile | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Save a profile (create or update)
|
|
39
|
+
*/
|
|
40
|
+
save(profile: Profile): Promise<ProfileResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Delete a profile by name
|
|
43
|
+
*/
|
|
44
|
+
delete(name: string): Promise<ProfileResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the name of the active profile
|
|
47
|
+
*/
|
|
48
|
+
getActive(): Promise<string | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Clear the active profile (used for force delete)
|
|
51
|
+
*/
|
|
52
|
+
clearActive(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Set the active profile
|
|
55
|
+
*/
|
|
56
|
+
setActive(name: string): Promise<ProfileResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Get the active profile (full profile data)
|
|
59
|
+
*/
|
|
60
|
+
getActiveProfile(): Promise<Profile | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Check if a profile exists
|
|
63
|
+
*/
|
|
64
|
+
exists(name: string): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Mask sensitive fields for display
|
|
67
|
+
*/
|
|
68
|
+
maskProfile(profile: Profile): Record<string, string>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the global ProfileManager instance
|
|
72
|
+
*/
|
|
73
|
+
export declare function getProfileManager(): ProfileManager;
|
|
74
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/profile/manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAiB,aAAa,EAAE,MAAM,YAAY,CAAC;AAoBxE;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAgB;;IAU9B;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOxC;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,UAAU;IASlB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAuChC;;OAEG;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