@elf5/periscope 1.0.64
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 +41 -0
- package/dist/__tests__/e2e/cli-test-utils.d.ts +79 -0
- package/dist/__tests__/e2e/cli-test-utils.d.ts.map +1 -0
- package/dist/__tests__/e2e/mock-server.d.ts +43 -0
- package/dist/__tests__/e2e/mock-server.d.ts.map +1 -0
- package/dist/__tests__/e2e/test-server.d.ts +46 -0
- package/dist/__tests__/e2e/test-server.d.ts.map +1 -0
- package/dist/__tests__/e2e/test-utils.d.ts +84 -0
- package/dist/__tests__/e2e/test-utils.d.ts.map +1 -0
- package/dist/__tests__/helpers/assertions.d.ts +5 -0
- package/dist/__tests__/helpers/assertions.d.ts.map +1 -0
- package/dist/__tests__/helpers/mock-factory.d.ts +31 -0
- package/dist/__tests__/helpers/mock-factory.d.ts.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +5156 -0
- package/dist/cli.js.map +7 -0
- package/dist/commands/auth.d.ts +14 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/base-command.d.ts +56 -0
- package/dist/commands/base-command.d.ts.map +1 -0
- package/dist/commands/config.d.ts +15 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/feedback.d.ts +15 -0
- package/dist/commands/feedback.d.ts.map +1 -0
- package/dist/commands/status.d.ts +8 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/tunnel.d.ts +31 -0
- package/dist/commands/tunnel.d.ts.map +1 -0
- package/dist/commands/user.d.ts +18 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4976 -0
- package/dist/index.js.map +7 -0
- package/dist/interactive.d.ts +25 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/lib/__tests__/__mocks__/ssh-client.mock.d.ts +18 -0
- package/dist/lib/__tests__/__mocks__/ssh-client.mock.d.ts.map +1 -0
- package/dist/lib/auth-callback-server.d.ts +25 -0
- package/dist/lib/auth-callback-server.d.ts.map +1 -0
- package/dist/lib/auth-types.d.ts +24 -0
- package/dist/lib/auth-types.d.ts.map +1 -0
- package/dist/lib/auth0-auth-manager.d.ts +73 -0
- package/dist/lib/auth0-auth-manager.d.ts.map +1 -0
- package/dist/lib/cache-utils.d.ts +14 -0
- package/dist/lib/cache-utils.d.ts.map +1 -0
- package/dist/lib/client.d.ts +181 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/config-manager.d.ts +34 -0
- package/dist/lib/config-manager.d.ts.map +1 -0
- package/dist/lib/error-classifier.d.ts +55 -0
- package/dist/lib/error-classifier.d.ts.map +1 -0
- package/dist/lib/interactive-utils.d.ts +14 -0
- package/dist/lib/interactive-utils.d.ts.map +1 -0
- package/dist/lib/logger.d.ts +99 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/msal-auth-manager.d.ts +54 -0
- package/dist/lib/msal-auth-manager.d.ts.map +1 -0
- package/dist/lib/msal-cache-plugin.d.ts +29 -0
- package/dist/lib/msal-cache-plugin.d.ts.map +1 -0
- package/dist/lib/process-lifecycle.d.ts +13 -0
- package/dist/lib/process-lifecycle.d.ts.map +1 -0
- package/dist/lib/readline-instance.d.ts +6 -0
- package/dist/lib/readline-instance.d.ts.map +1 -0
- package/dist/lib/request-monitor.d.ts +21 -0
- package/dist/lib/request-monitor.d.ts.map +1 -0
- package/dist/lib/secure-memory.d.ts +28 -0
- package/dist/lib/secure-memory.d.ts.map +1 -0
- package/dist/lib/server-config.d.ts +25 -0
- package/dist/lib/server-config.d.ts.map +1 -0
- package/dist/lib/ssh-key-manager.d.ts +50 -0
- package/dist/lib/ssh-key-manager.d.ts.map +1 -0
- package/dist/lib/telemetry.d.ts +42 -0
- package/dist/lib/telemetry.d.ts.map +1 -0
- package/dist/lib/terms.d.ts +8 -0
- package/dist/lib/terms.d.ts.map +1 -0
- package/dist/lib/tunnel-manager.d.ts +82 -0
- package/dist/lib/tunnel-manager.d.ts.map +1 -0
- package/dist/lib/tunnel-utils.d.ts +20 -0
- package/dist/lib/tunnel-utils.d.ts.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare class InteractiveMode {
|
|
2
|
+
private static instance;
|
|
3
|
+
constructor();
|
|
4
|
+
private get rl();
|
|
5
|
+
private setupLineHandler;
|
|
6
|
+
/**
|
|
7
|
+
* Tab completion for interactive mode.
|
|
8
|
+
* Maps the command tree so Tab expands to the next token at each level.
|
|
9
|
+
*/
|
|
10
|
+
private tabCompleter;
|
|
11
|
+
private setupSignalHandling;
|
|
12
|
+
start(): Promise<void>;
|
|
13
|
+
private handleCommand;
|
|
14
|
+
private showHelp;
|
|
15
|
+
private handleAuthCommand;
|
|
16
|
+
private handleUserCommand;
|
|
17
|
+
private handleConfigCommand;
|
|
18
|
+
private handleConnectCommand;
|
|
19
|
+
/**
|
|
20
|
+
* Trigger a new prompt (useful for background operations)
|
|
21
|
+
*/
|
|
22
|
+
static triggerPrompt(): void;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=interactive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAqBA,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgC;;IAYvD,OAAO,KAAK,EAAE,GAEb;IAED,OAAO,CAAC,gBAAgB;IAIxB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAgDpB,OAAO,CAAC,mBAAmB;IASrB,KAAK;YAWG,aAAa;IA0D3B,OAAO,CAAC,QAAQ;YAsCF,iBAAiB;YAmBjB,iBAAiB;YAgCjB,mBAAmB;YAoCnB,oBAAoB;IA8BlC;;OAEG;WACW,aAAa,IAAI,IAAI;IAS7B,KAAK;CASZ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface SshSession {
|
|
2
|
+
forwardPort(localPort: number, remoteHost: string, remotePort: number): Promise<void>;
|
|
3
|
+
close(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export declare class SshClient {
|
|
6
|
+
connect(options: {
|
|
7
|
+
hostname: string;
|
|
8
|
+
port: number;
|
|
9
|
+
username: string;
|
|
10
|
+
privateKey: string;
|
|
11
|
+
hostKey?: string;
|
|
12
|
+
}): Promise<SshSession>;
|
|
13
|
+
}
|
|
14
|
+
export declare class MockSshSession implements SshSession {
|
|
15
|
+
forwardPort(localPort: number, remoteHost: string, remotePort: number): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ssh-client.mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh-client.mock.d.ts","sourceRoot":"","sources":["../../../../src/lib/__tests__/__mocks__/ssh-client.mock.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,WAAW,CACT,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,qBAAa,SAAS;IACd,OAAO,CAAC,OAAO,EAAE;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,UAAU,CAAC;CAUxB;AAED,qBAAa,cAAe,YAAW,UAAU;IACzC,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAOV,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared local HTTP callback server for OAuth redirect flows.
|
|
3
|
+
* Used by both MsalAuthManager and Auth0AuthManager.
|
|
4
|
+
*/
|
|
5
|
+
export interface AuthCallbackResult {
|
|
6
|
+
/** The authorization code from the callback */
|
|
7
|
+
code: string;
|
|
8
|
+
/** The full raw URL path from the callback (preserves state for CSRF validation) */
|
|
9
|
+
fullPath: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Start a local HTTP server to listen for an OAuth authorization code callback.
|
|
13
|
+
*
|
|
14
|
+
* - On error callback: shows sanitized error page, resolves null.
|
|
15
|
+
* - On code callback with matching state: shows success page, resolves with code + full path.
|
|
16
|
+
* - On code callback with stale state: shows retry page, redirects to authUrl, keeps waiting.
|
|
17
|
+
* - On any other request: 302 redirects to authUrl (no script injection).
|
|
18
|
+
* - Times out after 5 minutes.
|
|
19
|
+
*
|
|
20
|
+
* @param port - Port to listen on (must be pre-registered as allowed callback URL)
|
|
21
|
+
* @param authUrl - Authorization URL to redirect the browser to
|
|
22
|
+
* @param expectedState - Expected OAuth state parameter to reject stale callbacks
|
|
23
|
+
*/
|
|
24
|
+
export declare function listenForAuthCode(port: number, authUrl: string, expectedState?: string): Promise<AuthCallbackResult | null>;
|
|
25
|
+
//# sourceMappingURL=auth-callback-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-callback-server.d.ts","sourceRoot":"","sources":["../../src/lib/auth-callback-server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAuHpC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared authentication types used by all auth provider implementations.
|
|
3
|
+
*/
|
|
4
|
+
/** Returns true if the token expiry time is within the safety buffer. */
|
|
5
|
+
export declare function isTokenExpired(expiresAt: Date): boolean;
|
|
6
|
+
export interface AuthToken {
|
|
7
|
+
accessToken: string;
|
|
8
|
+
expiresOn: Date;
|
|
9
|
+
refreshToken?: string;
|
|
10
|
+
}
|
|
11
|
+
export type PromptValue = 'select_account' | 'login' | 'consent' | 'none';
|
|
12
|
+
/**
|
|
13
|
+
* Common interface for authentication managers.
|
|
14
|
+
* Implemented by MsalAuthManager (Entra) and Auth0AuthManager (Auth0).
|
|
15
|
+
*/
|
|
16
|
+
export interface IAuthManager {
|
|
17
|
+
authenticate(): Promise<AuthToken>;
|
|
18
|
+
authenticateInteractive(prompt?: PromptValue): Promise<AuthToken>;
|
|
19
|
+
tryGetValidTokenSilently(): Promise<string | null>;
|
|
20
|
+
getValidToken(): Promise<string>;
|
|
21
|
+
isAuthenticated(): boolean;
|
|
22
|
+
logout(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=auth-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-types.d.ts","sourceRoot":"","sources":["../../src/lib/auth-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,SAAS,EAAE,IAAI,GAAG,OAAO,CAEvD;AAED,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IACnC,uBAAuB,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAClE,wBAAwB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACnD,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,eAAe,IAAI,OAAO,CAAC;IAC3B,MAAM,IAAI,IAAI,CAAC;CAChB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type AuthToken, type IAuthManager, type PromptValue } from './auth-types.js';
|
|
2
|
+
export interface Auth0Config {
|
|
3
|
+
/** Auth0 authority URL, e.g. https://periscope.auth0.com/ */
|
|
4
|
+
authority: string;
|
|
5
|
+
/** Auth0 application client ID */
|
|
6
|
+
clientId: string;
|
|
7
|
+
/** OAuth2 scopes to request */
|
|
8
|
+
scopes: string[];
|
|
9
|
+
/** Auth0 API audience identifier (required for JWT access tokens) */
|
|
10
|
+
audience?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Auth0 authentication manager using openid-client (RFC-compliant OIDC).
|
|
14
|
+
* Supports authorization code + PKCE browser flow (interactive) and
|
|
15
|
+
* device code flow (headless/fallback), plus token refresh.
|
|
16
|
+
*/
|
|
17
|
+
export declare class Auth0AuthManager implements IAuthManager {
|
|
18
|
+
private static readonly TOKEN_CACHE_FILE;
|
|
19
|
+
private static readonly REDIRECT_PORT;
|
|
20
|
+
private oidcConfig;
|
|
21
|
+
private config;
|
|
22
|
+
constructor(config?: Auth0Config);
|
|
23
|
+
/**
|
|
24
|
+
* Discover OIDC endpoints and initialize the openid-client Configuration.
|
|
25
|
+
* Lazy-loaded on first use.
|
|
26
|
+
*/
|
|
27
|
+
private ensureOidcConfig;
|
|
28
|
+
/**
|
|
29
|
+
* Authenticate using the device code flow (RFC 8628).
|
|
30
|
+
* Displays a code + URL, opens the browser, and polls for completion.
|
|
31
|
+
*/
|
|
32
|
+
authenticate(): Promise<AuthToken>;
|
|
33
|
+
/**
|
|
34
|
+
* Authenticate using the interactive browser flow (Authorization Code + PKCE).
|
|
35
|
+
* Opens the browser directly to Auth0 Universal Login — user enters email,
|
|
36
|
+
* receives OTP, enters it, and is redirected back. Single code, no device confirmation.
|
|
37
|
+
*/
|
|
38
|
+
authenticateInteractive(_prompt?: PromptValue): Promise<AuthToken>;
|
|
39
|
+
/**
|
|
40
|
+
* Try to get a valid token without user interaction.
|
|
41
|
+
* Checks cache first, then tries refresh token.
|
|
42
|
+
*/
|
|
43
|
+
tryGetValidTokenSilently(): Promise<string | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Get a valid access token, refreshing or re-authenticating if necessary.
|
|
46
|
+
*
|
|
47
|
+
* Falls back to the device code flow (not browser PKCE) so this method can be
|
|
48
|
+
* called in headless environments (e.g., mid-tunnel token refresh). Callers that
|
|
49
|
+
* need browser-based re-authentication should call authenticateInteractive() directly.
|
|
50
|
+
*/
|
|
51
|
+
getValidToken(): Promise<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a valid cached token exists.
|
|
54
|
+
*/
|
|
55
|
+
isAuthenticated(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Clear all cached Auth0 token data.
|
|
58
|
+
*/
|
|
59
|
+
logout(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Use a refresh token to obtain a new access token.
|
|
62
|
+
*/
|
|
63
|
+
private refreshAccessToken;
|
|
64
|
+
/**
|
|
65
|
+
* Process a token endpoint response into our AuthToken format and cache it.
|
|
66
|
+
*/
|
|
67
|
+
private processTokenResponse;
|
|
68
|
+
private getScopes;
|
|
69
|
+
private getCachedTokens;
|
|
70
|
+
private cacheTokens;
|
|
71
|
+
private getTokenCachePath;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=auth0-auth-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-auth-manager.d.ts","sourceRoot":"","sources":["../../src/lib/auth0-auth-manager.ts"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AASD;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAA4B;IACpE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAS;IAE9C,OAAO,CAAC,UAAU,CAAqC;IACvD,OAAO,CAAC,MAAM,CAA4B;gBAE9B,MAAM,CAAC,EAAE,WAAW;IAMhC;;;OAGG;YACW,gBAAgB;IAgB9B;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,SAAS,CAAC;IA4CxC;;;;OAIG;IACG,uBAAuB,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IA8DxE;;;OAGG;IACG,wBAAwB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAkCxD;;;;;;OAMG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAStC;;OAEG;IACH,eAAe,IAAI,OAAO;IAM1B;;OAEG;IACH,MAAM,IAAI,IAAI;IAWd;;OAEG;YACW,kBAAkB;IAShC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+B5B,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,iBAAiB;CAG1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the cache directory path, computed at runtime to respect HOME env var overrides.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getCacheDir(): string;
|
|
5
|
+
/**
|
|
6
|
+
* Ensure the cache directory exists, creating it if necessary.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ensureCacheDir(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Write data to a file with owner-only permissions (0o600).
|
|
11
|
+
* Creates the cache directory if it doesn't exist.
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeSecureFile(filePath: string, data: string): void;
|
|
14
|
+
//# sourceMappingURL=cache-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-utils.d.ts","sourceRoot":"","sources":["../../src/lib/cache-utils.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAGpE"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { PeriscopeConfig } from './config-manager.js';
|
|
2
|
+
import type { AuthToken, PromptValue } from './auth-types.js';
|
|
3
|
+
import { PeriscopeApi } from '@elf-5/periscope-api-client';
|
|
4
|
+
export type UserInfo = PeriscopeApi.UserDto;
|
|
5
|
+
/**
|
|
6
|
+
* Account status values returned by the server.
|
|
7
|
+
* Mirrors the UserStatus enum in Periscope.Shared.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AccountStatus: {
|
|
10
|
+
readonly PENDING_APPROVAL: "PendingApproval";
|
|
11
|
+
readonly ACTIVE: "Active";
|
|
12
|
+
readonly REJECTED: "Rejected";
|
|
13
|
+
readonly INACTIVE: "Inactive";
|
|
14
|
+
};
|
|
15
|
+
export interface HealthStatus {
|
|
16
|
+
healthy: boolean;
|
|
17
|
+
version?: string;
|
|
18
|
+
uptime?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class PeriscopeClient {
|
|
21
|
+
private config;
|
|
22
|
+
private authManager;
|
|
23
|
+
private apiClient;
|
|
24
|
+
private logger;
|
|
25
|
+
private httpsAgent;
|
|
26
|
+
private authInitPromise;
|
|
27
|
+
constructor(config: PeriscopeConfig);
|
|
28
|
+
/**
|
|
29
|
+
* Perform fetch with SSL configuration
|
|
30
|
+
*/
|
|
31
|
+
private fetchWithOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the auth manager with configuration from the API.
|
|
34
|
+
* Selects MSAL (Entra) or Auth0 based on the server's authProvider field.
|
|
35
|
+
* Uses a cached promise to prevent duplicate initialization attempts.
|
|
36
|
+
*/
|
|
37
|
+
private initializeAuth;
|
|
38
|
+
/**
|
|
39
|
+
* Internal auth initialization logic.
|
|
40
|
+
* Uses the centralized ServerConfig cache to avoid duplicate /api/configuration requests.
|
|
41
|
+
*/
|
|
42
|
+
private doInitializeAuth;
|
|
43
|
+
/**
|
|
44
|
+
* Create a custom fetch implementation that includes authentication headers.
|
|
45
|
+
* Dynamically fetches a fresh token on each request via authManager so that
|
|
46
|
+
* long-lived API clients (e.g., during tunnel reconnection) automatically
|
|
47
|
+
* pick up refreshed tokens instead of replaying an expired one.
|
|
48
|
+
*/
|
|
49
|
+
private createAuthenticatedFetch;
|
|
50
|
+
/**
|
|
51
|
+
* Create an unauthenticated fetch implementation for public endpoints
|
|
52
|
+
*/
|
|
53
|
+
private createUnauthenticatedFetch;
|
|
54
|
+
/**
|
|
55
|
+
* Initialize the API client with authentication token
|
|
56
|
+
*/
|
|
57
|
+
private initializeApiClient;
|
|
58
|
+
/**
|
|
59
|
+
* Check if API client is initialized and ready
|
|
60
|
+
*/
|
|
61
|
+
private isApiClientReady;
|
|
62
|
+
/**
|
|
63
|
+
* Authenticate and ensure we have a valid token
|
|
64
|
+
*/
|
|
65
|
+
authenticate(): Promise<AuthToken>;
|
|
66
|
+
/**
|
|
67
|
+
* Authenticate using interactive flow with prompt control
|
|
68
|
+
*/
|
|
69
|
+
authenticateInteractive(prompt?: PromptValue): Promise<AuthToken>;
|
|
70
|
+
/**
|
|
71
|
+
* Check if currently authenticated.
|
|
72
|
+
*
|
|
73
|
+
* Checks in order:
|
|
74
|
+
* 1. Already initialized authManager with valid token
|
|
75
|
+
* 2. Cached token on disk (without needing server config)
|
|
76
|
+
* 3. Initialize auth from server and check
|
|
77
|
+
*
|
|
78
|
+
* This layered approach allows the CLI to work even when the server
|
|
79
|
+
* doesn't provide auth configuration (e.g., test environments).
|
|
80
|
+
*/
|
|
81
|
+
isAuthenticated(): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Use isAuthenticated() instead. This alias exists for backwards compatibility.
|
|
84
|
+
*/
|
|
85
|
+
isAuthenticatedAsync(): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Try to initialize from a cached token file without needing server config.
|
|
88
|
+
* Checks both MSAL and Auth0 token caches.
|
|
89
|
+
* Returns true if a valid cached token was found and API client initialized.
|
|
90
|
+
*
|
|
91
|
+
* NOTE: Config-less managers are used only to read the cache and extract
|
|
92
|
+
* a still-valid access token. They are NOT stored as this.authManager
|
|
93
|
+
* because they lack server config needed for re-authentication and
|
|
94
|
+
* token refresh. The full authManager is set later via initializeAuth().
|
|
95
|
+
*/
|
|
96
|
+
private tryInitializeFromCachedToken;
|
|
97
|
+
/**
|
|
98
|
+
* Ensure API client is initialized if we have valid authentication.
|
|
99
|
+
*/
|
|
100
|
+
private ensureApiClientInitialized;
|
|
101
|
+
/**
|
|
102
|
+
* Logout and clear authentication data.
|
|
103
|
+
* Clears both MSAL and Auth0 caches to ensure a clean slate.
|
|
104
|
+
*/
|
|
105
|
+
logout(): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Get auth configuration from server (unauthenticated endpoint)
|
|
108
|
+
*/
|
|
109
|
+
getAuthConfig(): Promise<PeriscopeApi.PeriscopeConfigDto>;
|
|
110
|
+
checkHealth(): Promise<HealthStatus>;
|
|
111
|
+
/**
|
|
112
|
+
* Register the client's SSH public key with the server.
|
|
113
|
+
* Returns the normalized public key string accepted by the server.
|
|
114
|
+
*/
|
|
115
|
+
registerPublicKey(publicKey: string): Promise<string>;
|
|
116
|
+
getSSHCredentials(): Promise<PeriscopeApi.SshCredentialsDto>;
|
|
117
|
+
/**
|
|
118
|
+
* Get current user information
|
|
119
|
+
*/
|
|
120
|
+
getCurrentUser(): Promise<PeriscopeApi.UserDto>;
|
|
121
|
+
/**
|
|
122
|
+
* Get current user's account status from the server.
|
|
123
|
+
* Returns the status string (e.g., "Active", "PendingApproval").
|
|
124
|
+
* Throws if the status cannot be determined (fail-closed).
|
|
125
|
+
*/
|
|
126
|
+
getUserStatus(): Promise<string>;
|
|
127
|
+
/**
|
|
128
|
+
* Get current user's Terms of Service acceptance status.
|
|
129
|
+
* Uses direct fetch since these endpoints may not yet be in the generated API client.
|
|
130
|
+
*/
|
|
131
|
+
getTermsStatus(): Promise<TermsStatus>;
|
|
132
|
+
/**
|
|
133
|
+
* Accept the Terms of Service for the current user.
|
|
134
|
+
*/
|
|
135
|
+
acceptTerms(termsVersion: string): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Update the user's slug for tunnel namespacing (ELF-166).
|
|
138
|
+
* Requires authentication.
|
|
139
|
+
*/
|
|
140
|
+
updateSlug(request: {
|
|
141
|
+
slug: string;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Validate the SSH host key received during the SSH handshake (ELF-198).
|
|
145
|
+
* Sends the raw SSH wire-format public key bytes (base64-encoded) to the server,
|
|
146
|
+
* which compares them against its own key using constant-time comparison.
|
|
147
|
+
* Throws ApiException with status 422 if the key does not match (potential MITM).
|
|
148
|
+
*/
|
|
149
|
+
validateSshHostKey(keyBytes: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Submit user feedback to create a Linear issue.
|
|
152
|
+
* Requires authentication.
|
|
153
|
+
*/
|
|
154
|
+
submitFeedback(message: string): Promise<FeedbackResponse>;
|
|
155
|
+
/**
|
|
156
|
+
* Get the Application Insights connection string from the authenticated telemetry endpoint.
|
|
157
|
+
* Returns null if not authenticated or if the server has no connection string configured.
|
|
158
|
+
*/
|
|
159
|
+
getTelemetryConnectionString(): Promise<string | null>;
|
|
160
|
+
/**
|
|
161
|
+
* Get the configuration object
|
|
162
|
+
*/
|
|
163
|
+
getConfig(): PeriscopeConfig;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Terms of Service status response from server
|
|
167
|
+
*/
|
|
168
|
+
export interface TermsStatus {
|
|
169
|
+
accepted: boolean;
|
|
170
|
+
termsVersion: string | null;
|
|
171
|
+
acceptedAt: string | null;
|
|
172
|
+
currentVersion: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Feedback response from server
|
|
176
|
+
*/
|
|
177
|
+
export interface FeedbackResponse {
|
|
178
|
+
success?: boolean;
|
|
179
|
+
message?: string | undefined;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAgB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAO3D,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAGX,M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;IAkBlE;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC;IAqBrD;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAQtC;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IA+B5C;;OAEG;IACG,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BtD;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB1D;;;;;OAKG;IACG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzD;;;OAGG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmBhE;;;OAGG;IACG,4BAA4B,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAa5D;;OAEG;IACH,SAAS,IAAI,eAAe;CAG7B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface PeriscopeConfig {
|
|
2
|
+
serverUrl?: string;
|
|
3
|
+
logLevel?: string;
|
|
4
|
+
caCertPath?: string;
|
|
5
|
+
showRequestLog?: boolean;
|
|
6
|
+
sshKeyPath?: string;
|
|
7
|
+
allowExternalKey?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class ConfigManager {
|
|
10
|
+
private static readonly CONFIG_DIR;
|
|
11
|
+
private static readonly CONFIG_FILE;
|
|
12
|
+
private static testConfig;
|
|
13
|
+
static getConfigPath(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Set a test configuration that bypasses file system operations
|
|
16
|
+
* Only use this in tests!
|
|
17
|
+
*/
|
|
18
|
+
static setTestConfig(config: PeriscopeConfig | null): void;
|
|
19
|
+
/**
|
|
20
|
+
* Load configuration from file, environment variables, and .env file
|
|
21
|
+
* Priority order: environment variables > .env file > config file
|
|
22
|
+
*/
|
|
23
|
+
static load(): PeriscopeConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Load .env file from current working directory or project root
|
|
26
|
+
*/
|
|
27
|
+
private static loadDotEnv;
|
|
28
|
+
/**
|
|
29
|
+
* Merge environment variables into configuration
|
|
30
|
+
*/
|
|
31
|
+
private static mergeEnvironmentVariables;
|
|
32
|
+
static save(config: PeriscopeConfig): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=config-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-manager.d.ts","sourceRoot":"","sources":["../../src/lib/config-manager.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAE5B;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAyC;IAC3E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAiB;IACpD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAgC;IAEzD,MAAM,CAAC,aAAa,IAAI,MAAM;IAI9B;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI;IAO1D;;;OAGG;IACH,MAAM,CAAC,IAAI,IAAI,eAAe;IA6B9B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAoBzB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IA8BxC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;CA2B3C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error classification system for enhanced error handling
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ErrorType {
|
|
5
|
+
AUTHENTICATION = "authentication",
|
|
6
|
+
AUTHORIZATION = "authorization",
|
|
7
|
+
NETWORK = "network",
|
|
8
|
+
VALIDATION = "validation",
|
|
9
|
+
SERVER = "server",
|
|
10
|
+
TUNNEL = "tunnel",
|
|
11
|
+
UNKNOWN = "unknown"
|
|
12
|
+
}
|
|
13
|
+
export declare enum ErrorSeverity {
|
|
14
|
+
LOW = "low",
|
|
15
|
+
MEDIUM = "medium",
|
|
16
|
+
HIGH = "high",
|
|
17
|
+
CRITICAL = "critical"
|
|
18
|
+
}
|
|
19
|
+
export interface ClassifiedError {
|
|
20
|
+
type: ErrorType;
|
|
21
|
+
severity: ErrorSeverity;
|
|
22
|
+
httpStatus?: number;
|
|
23
|
+
isRetryable: boolean;
|
|
24
|
+
userMessage: string;
|
|
25
|
+
suggestedActions: string[];
|
|
26
|
+
technicalDetails?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Enhanced error classifier with granular categorization
|
|
30
|
+
*/
|
|
31
|
+
export declare class ErrorClassifier {
|
|
32
|
+
/**
|
|
33
|
+
* Classify an error based on various signals
|
|
34
|
+
*/
|
|
35
|
+
static classify(error: unknown, context?: string): ClassifiedError;
|
|
36
|
+
/**
|
|
37
|
+
* Extract message from various error formats
|
|
38
|
+
*/
|
|
39
|
+
private static extractMessage;
|
|
40
|
+
private static extractHttpStatus;
|
|
41
|
+
private static isAuthenticationError;
|
|
42
|
+
private static isAuthorizationError;
|
|
43
|
+
private static isNetworkError;
|
|
44
|
+
private static isValidationError;
|
|
45
|
+
private static isServerError;
|
|
46
|
+
private static isTunnelError;
|
|
47
|
+
private static createAuthenticationError;
|
|
48
|
+
private static createAuthorizationError;
|
|
49
|
+
private static createNetworkError;
|
|
50
|
+
private static createValidationError;
|
|
51
|
+
private static createServerError;
|
|
52
|
+
private static createTunnelError;
|
|
53
|
+
private static createUnknownError;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=error-classifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-classifier.d.ts","sourceRoot":"","sources":["../../src/lib/error-classifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoDH,oBAAY,SAAS;IACnB,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAMD;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,eAAe;IAsClE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAa7B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA0BhC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAuBpC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAsBnC,OAAO,CAAC,MAAM,CAAC,cAAc;IAwC7B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAiBhC,OAAO,CAAC,MAAM,CAAC,aAAa;IAe5B,OAAO,CAAC,MAAM,CAAC,aAAa;IA4B5B,OAAO,CAAC,MAAM,CAAC,yBAAyB;IA8BxC,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAoDvC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IA4EjC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAmBpC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA0BhC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA0DhC,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAkBlC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if we're currently running in interactive mode
|
|
3
|
+
*/
|
|
4
|
+
export declare function isInteractiveMode(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Exit or throw error based on context
|
|
7
|
+
* In interactive mode, throws an error instead of calling process.exit
|
|
8
|
+
*
|
|
9
|
+
* Note: telemetry is flushed in the signal handlers (secure-memory.ts)
|
|
10
|
+
* and the main CLI exit paths (cli.ts), not here. This function is sync
|
|
11
|
+
* and cannot await an async flush.
|
|
12
|
+
*/
|
|
13
|
+
export declare function exitOrThrow(code: number, message?: string): never;
|
|
14
|
+
//# sourceMappingURL=interactive-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive-utils.d.ts","sourceRoot":"","sources":["../../src/lib/interactive-utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CASjE"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
ERROR = 0,
|
|
3
|
+
WARN = 1,
|
|
4
|
+
INFO = 2,
|
|
5
|
+
DEBUG = 3,
|
|
6
|
+
TRACE = 4
|
|
7
|
+
}
|
|
8
|
+
export interface LoggerConfig {
|
|
9
|
+
level: LogLevel;
|
|
10
|
+
prefix?: string;
|
|
11
|
+
timestamp?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class Logger {
|
|
14
|
+
private config;
|
|
15
|
+
constructor(config?: LoggerConfig);
|
|
16
|
+
/**
|
|
17
|
+
* Set the current log level
|
|
18
|
+
*/
|
|
19
|
+
setLevel(level: LogLevel): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get the current log level
|
|
22
|
+
*/
|
|
23
|
+
getLevel(): LogLevel;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a log level should be output
|
|
26
|
+
*/
|
|
27
|
+
private shouldLog;
|
|
28
|
+
/**
|
|
29
|
+
* Format an argument for logging
|
|
30
|
+
* Stack traces are only included at DEBUG level or higher
|
|
31
|
+
*/
|
|
32
|
+
private formatArg;
|
|
33
|
+
/**
|
|
34
|
+
* Format the log message with optional timestamp and prefix
|
|
35
|
+
*/
|
|
36
|
+
private formatMessage;
|
|
37
|
+
/**
|
|
38
|
+
* Error level logging (always shown unless level is below ERROR)
|
|
39
|
+
*/
|
|
40
|
+
error(message: string, ...args: unknown[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Warning level logging
|
|
43
|
+
*/
|
|
44
|
+
warn(message: string, ...args: unknown[]): void;
|
|
45
|
+
/**
|
|
46
|
+
* Info level logging (user-facing information)
|
|
47
|
+
*/
|
|
48
|
+
info(message: string, ...args: unknown[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Success logging (special case of info)
|
|
51
|
+
*/
|
|
52
|
+
success(message: string, ...args: unknown[]): void;
|
|
53
|
+
/**
|
|
54
|
+
* Debug level logging (internal operations, verbose)
|
|
55
|
+
*/
|
|
56
|
+
debug(message: string, ...args: unknown[]): void;
|
|
57
|
+
/**
|
|
58
|
+
* Trace level logging (very detailed, internal state)
|
|
59
|
+
*/
|
|
60
|
+
trace(message: string, ...args: unknown[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* Raw output without formatting (for CLI output that shouldn't be logged)
|
|
63
|
+
*/
|
|
64
|
+
raw(message: string, ...args: unknown[]): void;
|
|
65
|
+
/**
|
|
66
|
+
* Print a blank line without any icon or prefix.
|
|
67
|
+
*/
|
|
68
|
+
blank(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Print a section header: blank line + bold text, no icon.
|
|
71
|
+
* Use instead of log.info('\nSection Title:') for section headings.
|
|
72
|
+
*/
|
|
73
|
+
header(text: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Print a horizontal separator line without any icon or prefix.
|
|
76
|
+
*/
|
|
77
|
+
separator(length?: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Create a child logger with additional prefix
|
|
80
|
+
*/
|
|
81
|
+
child(prefix: string): Logger;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get or create the global logger instance
|
|
85
|
+
*/
|
|
86
|
+
export declare function getLogger(): Logger;
|
|
87
|
+
export declare const log: {
|
|
88
|
+
error: (message: string, ...args: unknown[]) => void;
|
|
89
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
90
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
91
|
+
success: (message: string, ...args: unknown[]) => void;
|
|
92
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
93
|
+
trace: (message: string, ...args: unknown[]) => void;
|
|
94
|
+
raw: (message: string, ...args: unknown[]) => void;
|
|
95
|
+
blank: () => void;
|
|
96
|
+
header: (text: string) => void;
|
|
97
|
+
separator: (length?: number) => void;
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL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