galileo-generated 0.2.7 → 0.2.9
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/.release-please-config.json +7 -0
- package/.release-please-manifest.json +1 -1
- package/dist/commonjs/hooks/cert-management.d.ts +73 -0
- package/dist/commonjs/hooks/cert-management.d.ts.map +1 -0
- package/dist/commonjs/hooks/cert-management.js +258 -0
- package/dist/commonjs/hooks/cert-management.js.map +1 -0
- package/dist/commonjs/hooks/registration.d.ts.map +1 -1
- package/dist/commonjs/hooks/registration.js +8 -0
- package/dist/commonjs/hooks/registration.js.map +1 -1
- package/dist/commonjs/hooks/sdk-identifier.d.ts +5 -0
- package/dist/commonjs/hooks/sdk-identifier.d.ts.map +1 -0
- package/dist/commonjs/hooks/sdk-identifier.js +37 -0
- package/dist/commonjs/hooks/sdk-identifier.js.map +1 -0
- package/dist/commonjs/lib/galileo-config.d.ts +101 -12
- package/dist/commonjs/lib/galileo-config.d.ts.map +1 -1
- package/dist/commonjs/lib/galileo-config.js +153 -12
- package/dist/commonjs/lib/galileo-config.js.map +1 -1
- package/dist/commonjs/tests/hooks/cert-management.test.d.ts +2 -0
- package/dist/commonjs/tests/hooks/cert-management.test.d.ts.map +1 -0
- package/dist/commonjs/tests/hooks/cert-management.test.js +794 -0
- package/dist/commonjs/tests/hooks/cert-management.test.js.map +1 -0
- package/dist/commonjs/tests/hooks/sdk-identifier.test.d.ts +2 -0
- package/dist/commonjs/tests/hooks/sdk-identifier.test.d.ts.map +1 -0
- package/dist/commonjs/tests/hooks/sdk-identifier.test.js +136 -0
- package/dist/commonjs/tests/hooks/sdk-identifier.test.js.map +1 -0
- package/dist/commonjs/tests/lib/galileo-config.test.js +101 -0
- package/dist/commonjs/tests/lib/galileo-config.test.js.map +1 -1
- package/dist/esm/hooks/cert-management.d.ts +73 -0
- package/dist/esm/hooks/cert-management.d.ts.map +1 -0
- package/dist/esm/hooks/cert-management.js +254 -0
- package/dist/esm/hooks/cert-management.js.map +1 -0
- package/dist/esm/hooks/registration.d.ts.map +1 -1
- package/dist/esm/hooks/registration.js +8 -0
- package/dist/esm/hooks/registration.js.map +1 -1
- package/dist/esm/hooks/sdk-identifier.d.ts +5 -0
- package/dist/esm/hooks/sdk-identifier.d.ts.map +1 -0
- package/dist/esm/hooks/sdk-identifier.js +33 -0
- package/dist/esm/hooks/sdk-identifier.js.map +1 -0
- package/dist/esm/lib/galileo-config.d.ts +101 -12
- package/dist/esm/lib/galileo-config.d.ts.map +1 -1
- package/dist/esm/lib/galileo-config.js +153 -12
- package/dist/esm/lib/galileo-config.js.map +1 -1
- package/dist/esm/tests/hooks/cert-management.test.d.ts +2 -0
- package/dist/esm/tests/hooks/cert-management.test.d.ts.map +1 -0
- package/dist/esm/tests/hooks/cert-management.test.js +792 -0
- package/dist/esm/tests/hooks/cert-management.test.js.map +1 -0
- package/dist/esm/tests/hooks/sdk-identifier.test.d.ts +2 -0
- package/dist/esm/tests/hooks/sdk-identifier.test.d.ts.map +1 -0
- package/dist/esm/tests/hooks/sdk-identifier.test.js +134 -0
- package/dist/esm/tests/hooks/sdk-identifier.test.js.map +1 -0
- package/dist/esm/tests/lib/galileo-config.test.js +101 -0
- package/dist/esm/tests/lib/galileo-config.test.js.map +1 -1
- package/package.json +5 -3
- package/src/hooks/cert-management.ts +288 -0
- package/src/hooks/registration.ts +10 -0
- package/src/hooks/sdk-identifier.ts +41 -0
- package/src/lib/galileo-config.ts +214 -15
- package/src/tests/hooks/cert-management.test.ts +958 -0
- package/src/tests/hooks/sdk-identifier.test.ts +176 -0
- package/src/tests/lib/galileo-config.test.ts +110 -0
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Galileo config singleton:
|
|
2
|
+
* Galileo config singleton: environment-aware across Node.js, Deno, and browser runtimes.
|
|
3
|
+
*
|
|
4
|
+
* Configuration resolution order (highest to lowest priority):
|
|
5
|
+
* 1. Explicit constructor overrides (via get() method)
|
|
6
|
+
* 2. Environment variables (GALILEO_* or NODE_TLS_* for Node/Deno)
|
|
7
|
+
* 3. Browser global (__GALILEO_AUTH__) or localStorage (galileo_auth_config)
|
|
8
|
+
* 4. Defaults (consoleUrl: "https://console.galileo.ai", apiUrl derived from consoleUrl)
|
|
9
|
+
*
|
|
10
|
+
* Supports multiple authentication methods:
|
|
11
|
+
* - API key: GALILEO_API_KEY
|
|
12
|
+
* - Username/password: GALILEO_USERNAME + GALILEO_PASSWORD
|
|
13
|
+
* - SSO: GALILEO_SSO_ID_TOKEN + GALILEO_SSO_PROVIDER
|
|
14
|
+
*
|
|
15
|
+
* TLS/Certificate configuration:
|
|
16
|
+
* - CA certificates: GALILEO_CA_CERT_PATH or GALILEO_CA_CERT_CONTENT
|
|
17
|
+
* - Client certificates (mTLS): GALILEO_CLIENT_CERT_PATH + GALILEO_CLIENT_KEY_PATH
|
|
18
|
+
* - Certificate validation: GALILEO_REJECT_UNAUTHORIZED or NODE_TLS_REJECT_UNAUTHORIZED
|
|
19
|
+
*
|
|
20
|
+
* For certificate paths in Node.js, use GALILEO_CA_CERT_PATH (replaces default CA list).
|
|
21
|
+
* To append CA certs to the default list, use NODE_EXTRA_CA_CERTS instead.
|
|
3
22
|
*/
|
|
4
23
|
|
|
5
24
|
import { isBrowserLike, isDeno, isNodeLike } from "./runtime.js";
|
|
@@ -7,7 +26,12 @@ import { LOG_LEVEL_PRIORITY } from "../types/sdk-logger.types.js";
|
|
|
7
26
|
import type { LogLevel } from "../types/sdk-logger.types.js";
|
|
8
27
|
|
|
9
28
|
/**
|
|
10
|
-
* Configuration input for the Galileo SDK
|
|
29
|
+
* Configuration input for the Galileo SDK.
|
|
30
|
+
*
|
|
31
|
+
* Includes URLs (console, API), authentication credentials (API key, username/password, SSO tokens),
|
|
32
|
+
* project/log stream identifiers, logging configuration, and TLS/certificate settings.
|
|
33
|
+
*
|
|
34
|
+
* All properties are optional; values resolve from environment variables or browser storage by default.
|
|
11
35
|
*/
|
|
12
36
|
export type GalileoConfigInput = {
|
|
13
37
|
consoleUrl?: string;
|
|
@@ -22,10 +46,23 @@ export type GalileoConfigInput = {
|
|
|
22
46
|
logLevel?: LogLevel | undefined;
|
|
23
47
|
projectName?: string;
|
|
24
48
|
logStreamName?: string;
|
|
49
|
+
/** Path to CA certificate file. */
|
|
50
|
+
caCertPath?: string;
|
|
51
|
+
/** Direct CA certificate content. */
|
|
52
|
+
caCertContent?: string;
|
|
53
|
+
/** Client certificate path. */
|
|
54
|
+
clientCertPath?: string;
|
|
55
|
+
/** Client key path. */
|
|
56
|
+
clientKeyPath?: string;
|
|
57
|
+
/** Whether to reject unauthorized (e.g. self-signed) certificates. */
|
|
58
|
+
rejectUnauthorized?: boolean;
|
|
25
59
|
};
|
|
26
60
|
|
|
27
61
|
/**
|
|
28
|
-
*
|
|
62
|
+
* Resolved authentication credentials extracted from config.
|
|
63
|
+
*
|
|
64
|
+
* Contains one or more of: API key, username/password pair, or SSO credentials.
|
|
65
|
+
* Returned by getAuthCredentials() method.
|
|
29
66
|
*/
|
|
30
67
|
export type AuthCredentials = {
|
|
31
68
|
apiKey?: string;
|
|
@@ -36,13 +73,36 @@ export type AuthCredentials = {
|
|
|
36
73
|
};
|
|
37
74
|
|
|
38
75
|
/**
|
|
39
|
-
*
|
|
76
|
+
* TLS/certificate configuration for API requests.
|
|
77
|
+
*
|
|
78
|
+
* Supports custom CA certificates (via file path or direct content) and mutual TLS (mTLS)
|
|
79
|
+
* with client certificates and keys. Controls whether unauthorized (self-signed) certificates
|
|
80
|
+
* are accepted via rejectUnauthorized flag.
|
|
81
|
+
*
|
|
82
|
+
* Returned by getCertConfig() method or included in config snapshot.
|
|
83
|
+
*/
|
|
84
|
+
export type CertConfig = {
|
|
85
|
+
caCertPath?: string;
|
|
86
|
+
caCertContent?: string;
|
|
87
|
+
clientCertPath?: string;
|
|
88
|
+
clientKeyPath?: string;
|
|
89
|
+
rejectUnauthorized?: boolean;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Config snapshot for BaseEntity compatibility.
|
|
94
|
+
*
|
|
95
|
+
* Flattened representation of resolved configuration including API URL, API key, login credentials
|
|
96
|
+
* (username/password), SSO information (idToken/provider), and TLS certificate configuration.
|
|
97
|
+
*
|
|
98
|
+
* Used for entity authentication and API interactions.
|
|
40
99
|
*/
|
|
41
100
|
export type GalileoConfigSnapshot = {
|
|
42
101
|
apiUrl?: string;
|
|
43
102
|
apiKey?: string;
|
|
44
103
|
login?: { username?: string; password?: string };
|
|
45
104
|
sso?: { idToken?: string; provider?: string };
|
|
105
|
+
cert?: CertConfig;
|
|
46
106
|
};
|
|
47
107
|
|
|
48
108
|
/** Browser global key for auth config (e.g. window.__GALILEO_AUTH__). */
|
|
@@ -73,6 +133,18 @@ const ENV_GALILEO_PROJECT_NAME = "GALILEO_PROJECT_NAME";
|
|
|
73
133
|
const ENV_GALILEO_LOG_STREAM = "GALILEO_LOG_STREAM";
|
|
74
134
|
/** Log stream identifier; same meaning as GALILEO_LOG_STREAM (fallback if GALILEO_LOG_STREAM is unset). */
|
|
75
135
|
const ENV_GALILEO_LOG_STREAM_NAME = "GALILEO_LOG_STREAM_NAME";
|
|
136
|
+
/** Path to CA certificate file (Galileo-specific). */
|
|
137
|
+
const ENV_GALILEO_CA_CERT_PATH = "GALILEO_CA_CERT_PATH";
|
|
138
|
+
/** Direct certificate content. */
|
|
139
|
+
const ENV_GALILEO_CA_CERT_CONTENT = "GALILEO_CA_CERT_CONTENT";
|
|
140
|
+
/** Client certificate path. */
|
|
141
|
+
const ENV_GALILEO_CLIENT_CERT_PATH = "GALILEO_CLIENT_CERT_PATH";
|
|
142
|
+
/** Client key path. */
|
|
143
|
+
const ENV_GALILEO_CLIENT_KEY_PATH = "GALILEO_CLIENT_KEY_PATH";
|
|
144
|
+
/** Boolean to allow/reject self-signed certs (Galileo-specific). */
|
|
145
|
+
const ENV_GALILEO_REJECT_UNAUTHORIZED = "GALILEO_REJECT_UNAUTHORIZED";
|
|
146
|
+
/** Boolean to allow/reject self-signed certs (Node.js standard). */
|
|
147
|
+
const ENV_NODE_TLS_REJECT_UNAUTHORIZED = "NODE_TLS_REJECT_UNAUTHORIZED";
|
|
76
148
|
/** Log level for SDK logging (DEBUG, INFO, WARN, ERROR, etc.). */
|
|
77
149
|
const ENV_GALILEO_LOG_LEVEL = "GALILEO_LOG_LEVEL";
|
|
78
150
|
|
|
@@ -168,9 +240,21 @@ function normalizeInput(value: unknown): GalileoConfigInput | null {
|
|
|
168
240
|
typeof obj["projectName"] === "string" ? obj["projectName"] : undefined;
|
|
169
241
|
const logStreamName =
|
|
170
242
|
typeof obj["logStreamName"] === "string" ? obj["logStreamName"] : undefined;
|
|
243
|
+
const caCertPath =
|
|
244
|
+
typeof obj["caCertPath"] === "string" ? obj["caCertPath"] : undefined;
|
|
245
|
+
const caCertContent =
|
|
246
|
+
typeof obj["caCertContent"] === "string" ? obj["caCertContent"] : undefined;
|
|
247
|
+
const clientCertPath =
|
|
248
|
+
typeof obj["clientCertPath"] === "string" ? obj["clientCertPath"] : undefined;
|
|
249
|
+
const clientKeyPath =
|
|
250
|
+
typeof obj["clientKeyPath"] === "string" ? obj["clientKeyPath"] : undefined;
|
|
251
|
+
const rejectUnauthorized =
|
|
252
|
+
typeof obj["rejectUnauthorized"] === "boolean"
|
|
253
|
+
? obj["rejectUnauthorized"]
|
|
254
|
+
: undefined;
|
|
171
255
|
const rawLogLevel = typeof obj["logLevel"] === "string" ? obj["logLevel"].toLowerCase() : undefined;
|
|
172
256
|
const logLevel = isValidLogLevel(rawLogLevel) ? rawLogLevel : undefined;
|
|
173
|
-
if (!apiKey && !u && !p && !ssoIdToken && !ssoProvider) return null;
|
|
257
|
+
if (!apiKey && !u && !p && !ssoIdToken && !ssoProvider && !caCertPath && !caCertContent && !clientCertPath && !clientKeyPath && rejectUnauthorized === undefined) return null;
|
|
174
258
|
return {
|
|
175
259
|
...(apiKey ? { apiKey } : {}),
|
|
176
260
|
...(u ? { username: String(u) } : {}),
|
|
@@ -181,6 +265,11 @@ function normalizeInput(value: unknown): GalileoConfigInput | null {
|
|
|
181
265
|
...(apiUrl ? { apiUrl } : {}),
|
|
182
266
|
...(projectName ? { projectName } : {}),
|
|
183
267
|
...(logStreamName ? { logStreamName } : {}),
|
|
268
|
+
...(caCertPath ? { caCertPath } : {}),
|
|
269
|
+
...(caCertContent ? { caCertContent } : {}),
|
|
270
|
+
...(clientCertPath ? { clientCertPath } : {}),
|
|
271
|
+
...(clientKeyPath ? { clientKeyPath } : {}),
|
|
272
|
+
...(rejectUnauthorized !== undefined ? { rejectUnauthorized } : {}),
|
|
184
273
|
...(logLevel !== undefined && logLevel.length > 0 ? { logLevel } : {}),
|
|
185
274
|
};
|
|
186
275
|
}
|
|
@@ -209,7 +298,30 @@ function resolveFromEnvironment(): GalileoConfigInput | null {
|
|
|
209
298
|
? rawLogLevel
|
|
210
299
|
: undefined;
|
|
211
300
|
|
|
212
|
-
|
|
301
|
+
// GALILEO_CA_CERT_PATH is used to clean existing CA certs list and use this instead.
|
|
302
|
+
// Use NODE_EXTRA_CA_CERTS if you want to append CA certs to existing (default) list instead.
|
|
303
|
+
const caCertPath =
|
|
304
|
+
env[ENV_GALILEO_CA_CERT_PATH];
|
|
305
|
+
|
|
306
|
+
const caCertContent = env[ENV_GALILEO_CA_CERT_CONTENT];
|
|
307
|
+
const clientCertPath = env[ENV_GALILEO_CLIENT_CERT_PATH];
|
|
308
|
+
const clientKeyPath = env[ENV_GALILEO_CLIENT_KEY_PATH];
|
|
309
|
+
|
|
310
|
+
// Reject unauthorized: GALILEO_REJECT_UNAUTHORIZED > NODE_TLS_REJECT_UNAUTHORIZED
|
|
311
|
+
// Empty strings are treated as undefined (not set) to avoid inadvertently disabling TLS.
|
|
312
|
+
const rejectUnauthorizedRaw =
|
|
313
|
+
env[ENV_GALILEO_REJECT_UNAUTHORIZED] ??
|
|
314
|
+
env[ENV_NODE_TLS_REJECT_UNAUTHORIZED];
|
|
315
|
+
const rejectUnauthorized =
|
|
316
|
+
rejectUnauthorizedRaw === undefined || rejectUnauthorizedRaw === ""
|
|
317
|
+
? undefined
|
|
318
|
+
: rejectUnauthorizedRaw === "true" || rejectUnauthorizedRaw === "1"
|
|
319
|
+
? true
|
|
320
|
+
: rejectUnauthorizedRaw === "false" || rejectUnauthorizedRaw === "0"
|
|
321
|
+
? false
|
|
322
|
+
: undefined;
|
|
323
|
+
|
|
324
|
+
if (!apiKey && !username && !password && !ssoIdToken && !ssoProvider && !apiUrl && !consoleUrl && !projectName && !logStreamName && !logLevel && !caCertPath && !caCertContent && !clientCertPath && !clientKeyPath && rejectUnauthorized === undefined)
|
|
213
325
|
return null;
|
|
214
326
|
return {
|
|
215
327
|
...(apiKey ? { apiKey } : {}),
|
|
@@ -221,6 +333,11 @@ function resolveFromEnvironment(): GalileoConfigInput | null {
|
|
|
221
333
|
...(consoleUrl ? { consoleUrl } : {}),
|
|
222
334
|
...(projectName ? { projectName } : {}),
|
|
223
335
|
...(logStreamName ? { logStreamName } : {}),
|
|
336
|
+
...(caCertPath ? { caCertPath } : {}),
|
|
337
|
+
...(caCertContent ? { caCertContent } : {}),
|
|
338
|
+
...(clientCertPath ? { clientCertPath } : {}),
|
|
339
|
+
...(clientKeyPath ? { clientKeyPath } : {}),
|
|
340
|
+
...(rejectUnauthorized !== undefined ? { rejectUnauthorized } : {}),
|
|
224
341
|
...(logLevel !== undefined && logLevel.length > 0 ? { logLevel } : {}),
|
|
225
342
|
};
|
|
226
343
|
}
|
|
@@ -247,6 +364,11 @@ function merge(
|
|
|
247
364
|
"logLevel",
|
|
248
365
|
"projectName",
|
|
249
366
|
"logStreamName",
|
|
367
|
+
"caCertPath",
|
|
368
|
+
"caCertContent",
|
|
369
|
+
"clientCertPath",
|
|
370
|
+
"clientKeyPath",
|
|
371
|
+
"rejectUnauthorized",
|
|
250
372
|
];
|
|
251
373
|
for (const k of keys) {
|
|
252
374
|
const ov = o[k];
|
|
@@ -302,6 +424,11 @@ export class GalileoConfig {
|
|
|
302
424
|
public readonly logLevel: LogLevel | undefined;
|
|
303
425
|
public readonly projectName: string | undefined;
|
|
304
426
|
public readonly logStreamName: string | undefined;
|
|
427
|
+
public readonly caCertPath: string | undefined;
|
|
428
|
+
public readonly caCertContent: string | undefined;
|
|
429
|
+
public readonly clientCertPath: string | undefined;
|
|
430
|
+
public readonly clientKeyPath: string | undefined;
|
|
431
|
+
public readonly rejectUnauthorized: boolean | undefined;
|
|
305
432
|
|
|
306
433
|
private constructor(input: GalileoConfigInput) {
|
|
307
434
|
this.apiUrl = input.apiUrl ?? resolveApiUrl(input.consoleUrl, undefined, "gen_ai");
|
|
@@ -316,11 +443,22 @@ export class GalileoConfig {
|
|
|
316
443
|
this.logLevel = input.logLevel;
|
|
317
444
|
this.projectName = input.projectName;
|
|
318
445
|
this.logStreamName = input.logStreamName;
|
|
446
|
+
this.caCertPath = input.caCertPath;
|
|
447
|
+
this.caCertContent = input.caCertContent;
|
|
448
|
+
this.clientCertPath = input.clientCertPath;
|
|
449
|
+
this.clientKeyPath = input.clientKeyPath;
|
|
450
|
+
this.rejectUnauthorized = input.rejectUnauthorized;
|
|
319
451
|
}
|
|
320
452
|
|
|
321
453
|
/**
|
|
322
|
-
* Returns a snapshot compatible with BaseEntity
|
|
323
|
-
*
|
|
454
|
+
* Returns a snapshot compatible with BaseEntity, including resolved apiUrl, apiKey, login, sso, and cert.
|
|
455
|
+
*
|
|
456
|
+
* - apiUrl is resolved from consoleUrl if not explicitly set
|
|
457
|
+
* - login contains username and/or password if present
|
|
458
|
+
* - sso contains idToken and/or provider if present
|
|
459
|
+
* - cert contains all configured TLS/certificate settings if any are present
|
|
460
|
+
*
|
|
461
|
+
* @returns The config snapshot for entity authentication and API configuration.
|
|
324
462
|
*/
|
|
325
463
|
get snapshot(): GalileoConfigSnapshot {
|
|
326
464
|
const apiUrl = this.apiUrl ?? this.getApiUrl();
|
|
@@ -342,18 +480,28 @@ export class GalileoConfig {
|
|
|
342
480
|
: {}),
|
|
343
481
|
}
|
|
344
482
|
: undefined;
|
|
483
|
+
const cert = this.getCertConfig();
|
|
345
484
|
return {
|
|
346
485
|
apiUrl,
|
|
347
486
|
...(this.apiKey !== undefined ? { apiKey: this.apiKey } : {}),
|
|
348
487
|
...(login ? { login } : {}),
|
|
349
488
|
...(sso ? { sso } : {}),
|
|
489
|
+
...(cert !== null ? { cert } : {}),
|
|
350
490
|
};
|
|
351
491
|
}
|
|
352
492
|
|
|
353
493
|
/**
|
|
354
|
-
* Returns the singleton config instance,
|
|
494
|
+
* Returns the singleton config instance, resolving from environment and optional overrides.
|
|
495
|
+
*
|
|
496
|
+
* On first call (or when overrides are provided), resolves configuration from:
|
|
497
|
+
* 1. Environment variables or browser storage (via resolveFromEnvironment)
|
|
498
|
+
* 2. Constructor overrides (via merge)
|
|
499
|
+
*
|
|
500
|
+
* The instance is cached and reused on subsequent calls unless overrides are provided.
|
|
501
|
+
* To reset the singleton, call reset().
|
|
502
|
+
*
|
|
355
503
|
* @param overrides - (Optional) Config values to merge over environment and defaults.
|
|
356
|
-
* @returns The GalileoConfig instance.
|
|
504
|
+
* @returns The GalileoConfig singleton instance.
|
|
357
505
|
*/
|
|
358
506
|
public static get(overrides: GalileoConfigInput = {}): GalileoConfig {
|
|
359
507
|
const hasOverrides = Object.keys(overrides).length > 0;
|
|
@@ -367,7 +515,10 @@ export class GalileoConfig {
|
|
|
367
515
|
}
|
|
368
516
|
|
|
369
517
|
/**
|
|
370
|
-
* Clears the singleton instance.
|
|
518
|
+
* Clears the singleton instance.
|
|
519
|
+
*
|
|
520
|
+
* Next call to get() will rebuild the instance from environment variables or browser storage.
|
|
521
|
+
* Useful for testing or when configuration has changed and needs to be reloaded.
|
|
371
522
|
*/
|
|
372
523
|
public static reset(): void {
|
|
373
524
|
GalileoConfig.instance = null;
|
|
@@ -375,16 +526,29 @@ export class GalileoConfig {
|
|
|
375
526
|
|
|
376
527
|
/**
|
|
377
528
|
* Returns the API base URL, resolved from consoleUrl or explicit apiUrl.
|
|
378
|
-
*
|
|
529
|
+
*
|
|
530
|
+
* Resolution logic:
|
|
531
|
+
* 1. If apiUrl is set, return it as-is
|
|
532
|
+
* 2. If consoleUrl is set, derive apiUrl by replacing "app.galileo.ai" or "console" with "api"
|
|
533
|
+
* 3. For localhost consoleUrl, return "http://localhost:8088"
|
|
534
|
+
* 4. If neither consoleUrl nor apiUrl is set, use projectType default (e.g., "gen_ai" → "https://api.galileo.ai")
|
|
535
|
+
* 5. If no projectType and neither URL is set, throw an error
|
|
536
|
+
*
|
|
537
|
+
* @param projectType - (Optional) Default project type for API URL when neither apiUrl nor consoleUrl is set.
|
|
379
538
|
* @returns The resolved API URL.
|
|
539
|
+
* @throws Error if apiUrl, consoleUrl, and projectType are all unset.
|
|
380
540
|
*/
|
|
381
541
|
public getApiUrl(projectType?: string): string {
|
|
382
542
|
return resolveApiUrl(this.consoleUrl, this.apiUrl, projectType);
|
|
383
543
|
}
|
|
384
544
|
|
|
385
545
|
/**
|
|
386
|
-
* Returns the current
|
|
387
|
-
*
|
|
546
|
+
* Returns the current authentication credentials.
|
|
547
|
+
*
|
|
548
|
+
* Extracts and returns all present credentials: API key, username/password pair, and/or SSO tokens.
|
|
549
|
+
* Only populated fields are included in the returned object.
|
|
550
|
+
*
|
|
551
|
+
* @returns The AuthCredentials object with present credential values.
|
|
388
552
|
*/
|
|
389
553
|
public getAuthCredentials(): AuthCredentials {
|
|
390
554
|
return {
|
|
@@ -401,7 +565,39 @@ export class GalileoConfig {
|
|
|
401
565
|
}
|
|
402
566
|
|
|
403
567
|
/**
|
|
404
|
-
*
|
|
568
|
+
* Returns TLS/certificate configuration for API requests.
|
|
569
|
+
*
|
|
570
|
+
* Extracts and returns all present certificate settings: CA certificate (path or content),
|
|
571
|
+
* client certificate and key (for mTLS), and rejectUnauthorized flag.
|
|
572
|
+
* Only populated fields are included in the returned object.
|
|
573
|
+
*
|
|
574
|
+
* @returns The CertConfig object with present values, or null if no certificate configuration is set.
|
|
575
|
+
*/
|
|
576
|
+
public getCertConfig(): CertConfig | null {
|
|
577
|
+
const result: CertConfig = {
|
|
578
|
+
...(this.caCertPath !== undefined ? { caCertPath: this.caCertPath } : {}),
|
|
579
|
+
...(this.caCertContent !== undefined
|
|
580
|
+
? { caCertContent: this.caCertContent }
|
|
581
|
+
: {}),
|
|
582
|
+
...(this.clientCertPath !== undefined
|
|
583
|
+
? { clientCertPath: this.clientCertPath }
|
|
584
|
+
: {}),
|
|
585
|
+
...(this.clientKeyPath !== undefined
|
|
586
|
+
? { clientKeyPath: this.clientKeyPath }
|
|
587
|
+
: {}),
|
|
588
|
+
...(this.rejectUnauthorized !== undefined
|
|
589
|
+
? { rejectUnauthorized: this.rejectUnauthorized }
|
|
590
|
+
: {}),
|
|
591
|
+
};
|
|
592
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Logs a safe summary of the current configuration to the console.
|
|
597
|
+
*
|
|
598
|
+
* Omits sensitive values (passwords, API keys, SSO tokens) and instead logs boolean flags
|
|
599
|
+
* (hasApiKey, hasPassword, hasSsoIdToken) to indicate their presence without revealing content.
|
|
600
|
+
* Useful for debugging configuration issues in production environments.
|
|
405
601
|
*/
|
|
406
602
|
public logConfig(): void {
|
|
407
603
|
const safe = {
|
|
@@ -415,6 +611,9 @@ export class GalileoConfig {
|
|
|
415
611
|
hasSsoIdToken: Boolean(this.ssoIdToken),
|
|
416
612
|
projectName: this.projectName,
|
|
417
613
|
logStreamName: this.logStreamName,
|
|
614
|
+
hasCaCert: Boolean(this.caCertPath || this.caCertContent),
|
|
615
|
+
hasClientCert: Boolean(this.clientCertPath && this.clientKeyPath),
|
|
616
|
+
rejectUnauthorized: this.rejectUnauthorized,
|
|
418
617
|
};
|
|
419
618
|
console.info("[GalileoConfig]", safe);
|
|
420
619
|
}
|