@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Elf Industries, LLC.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Periscope
|
|
2
|
+
|
|
3
|
+
Secure tunnels from localhost to the internet — [hosted by Elf 5](https://elf5.com) or self-hosted on your own infrastructure.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @elf5/periscope
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
periscope connect my-app --target http://localhost:3000
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The CLI opens a browser to authenticate on first run, then prints your public tunnel URL.
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
periscope connect <name> --target <url> # Create a tunnel
|
|
23
|
+
periscope auth login # Authenticate
|
|
24
|
+
periscope auth logout # Sign out
|
|
25
|
+
periscope config set --server <url> # Set server URL
|
|
26
|
+
periscope config show # Show configuration
|
|
27
|
+
periscope status # Check connection and auth status
|
|
28
|
+
periscope feedback "<message>" # Send feedback to Elf 5
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Beta
|
|
32
|
+
|
|
33
|
+
Periscope is currently in free beta — no credit card required, limited to 100 users. [Get started at elf5.com](https://elf5.com/getting-started).
|
|
34
|
+
|
|
35
|
+
## Support
|
|
36
|
+
|
|
37
|
+
Email [support@elf5.com](mailto:support@elf5.com) or run `periscope feedback "your message"`.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CLI Test Utilities
|
|
3
|
+
*
|
|
4
|
+
* Common helpers for CLI E2E tests to keep tests DRY.
|
|
5
|
+
*/
|
|
6
|
+
import { ChildProcess } from 'child_process';
|
|
7
|
+
import * as http from 'http';
|
|
8
|
+
export declare const CLI_PATH: string;
|
|
9
|
+
export interface ExecResult {
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
exitCode: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ExecOptions {
|
|
15
|
+
env?: Record<string, string>;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
input?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CliTestContext {
|
|
20
|
+
tempConfigDir: string;
|
|
21
|
+
cleanup: () => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Verify CLI binary exists, throw if not
|
|
25
|
+
*/
|
|
26
|
+
export declare function ensureCliBinaryExists(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Create isolated test context with temp directory
|
|
29
|
+
*/
|
|
30
|
+
export declare function createCliTestContext(prefix: string): CliTestContext;
|
|
31
|
+
/**
|
|
32
|
+
* Create an execCli function bound to a specific config directory and base env
|
|
33
|
+
*/
|
|
34
|
+
export declare function createExecCli(tempConfigDir: string, baseEnv?: Record<string, string>): (args: string[], options?: ExecOptions) => Promise<ExecResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Spawn a long-running CLI process with output capture
|
|
37
|
+
*/
|
|
38
|
+
export declare function spawnCliProcess(args: string[], tempConfigDir: string, extraEnv?: Record<string, string>, timeoutMs?: number): {
|
|
39
|
+
child: ChildProcess;
|
|
40
|
+
getOutput: () => {
|
|
41
|
+
stdout: string;
|
|
42
|
+
stderr: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Wait for a condition in process output or timeout
|
|
47
|
+
*/
|
|
48
|
+
export declare function waitForOutput(getOutput: () => {
|
|
49
|
+
stdout: string;
|
|
50
|
+
stderr: string;
|
|
51
|
+
}, condition: (output: {
|
|
52
|
+
stdout: string;
|
|
53
|
+
stderr: string;
|
|
54
|
+
}) => boolean, timeoutMs?: number): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Kill process and wait for exit
|
|
57
|
+
*/
|
|
58
|
+
export declare function killAndWait(child: ChildProcess, signal?: NodeJS.Signals): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Extract the remote URL from CLI connect output
|
|
61
|
+
*/
|
|
62
|
+
export declare function extractRemoteUrl(output: string): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Extract hostname from a URL
|
|
65
|
+
*/
|
|
66
|
+
export declare function extractHostname(url: string): string | null;
|
|
67
|
+
/**
|
|
68
|
+
* Make an HTTP request with a custom Host header.
|
|
69
|
+
*
|
|
70
|
+
* Node.js fetch() doesn't allow overriding the Host header for security reasons
|
|
71
|
+
* (see https://github.com/nodejs/node/issues/50305).
|
|
72
|
+
* We need to use http.request() directly to set custom Host headers.
|
|
73
|
+
*/
|
|
74
|
+
export declare function httpRequestWithHost(url: string, hostHeader: string, timeoutMs?: number): Promise<{
|
|
75
|
+
status: number;
|
|
76
|
+
body: string;
|
|
77
|
+
headers: http.IncomingHttpHeaders;
|
|
78
|
+
}>;
|
|
79
|
+
//# sourceMappingURL=cli-test-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-test-utils.d.ts","sourceRoot":"","sources":["../../../src/__tests__/e2e/cli-test-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAS,YAAY,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAY7B,eAAO,MAAM,QAAQ,QAA+C,CAAC;AAMrE,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAMD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAM5C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAanE;AAMD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,IAGlC,MAAM,MAAM,EAAE,EACd,UAAS,WAAgB,KACxB,OAAO,CAAC,UAAU,CAAC,CAuCvB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EAAE,EACd,aAAa,EAAE,MAAM,EACrB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACrC,SAAS,GAAE,MAAc,GACxB;IACD,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,MAAM;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACrD,CA0BA;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACnD,SAAS,EAAE,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,EAClE,SAAS,GAAE,MAAc,GACxB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,YAAY,EACnB,MAAM,GAAE,MAAM,CAAC,OAAmB,GACjC,OAAO,CAAC,IAAI,CAAC,CAMf;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,MAAc,GACxB,OAAO,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC;CACnC,CAAC,CAiCD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock Server Responses for Dual-Mode Testing
|
|
3
|
+
*
|
|
4
|
+
* When the real server is not available, these mocks are used.
|
|
5
|
+
* This allows tests to run locally without a server while still
|
|
6
|
+
* exercising the same code paths.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Mock MSAL configuration matching real server response structure.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MOCK_MSAL_CONFIG: {
|
|
12
|
+
clientId: string;
|
|
13
|
+
authority: string;
|
|
14
|
+
scopes: string[];
|
|
15
|
+
};
|
|
16
|
+
export declare const MOCK_OPENAPI_SPEC: {
|
|
17
|
+
openapi: string;
|
|
18
|
+
info: {
|
|
19
|
+
title: string;
|
|
20
|
+
version: string;
|
|
21
|
+
};
|
|
22
|
+
paths: {
|
|
23
|
+
'/api/user': {};
|
|
24
|
+
'/api/user/tunnel': {};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const MOCK_SWAGGER_HTML = "\n<!DOCTYPE html>\n<html>\n<head><title>Swagger UI</title></head>\n<body>Swagger UI mock</body>\n</html>\n";
|
|
28
|
+
/**
|
|
29
|
+
* Mock fetch that returns canned responses for known endpoints.
|
|
30
|
+
* Used when the real server is not available.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createMockFetch(baseUrl: string): (input: string | URL | Request, _init?: RequestInit) => Promise<Response>;
|
|
33
|
+
/**
|
|
34
|
+
* Install mock fetch globally.
|
|
35
|
+
* Call in beforeAll/beforeEach when server is not available.
|
|
36
|
+
*/
|
|
37
|
+
export declare function installMockFetch(baseUrl: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Restore original fetch.
|
|
40
|
+
* Call in afterAll/afterEach to clean up.
|
|
41
|
+
*/
|
|
42
|
+
export declare function restoreFetch(): void;
|
|
43
|
+
//# sourceMappingURL=mock-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../../src/__tests__/e2e/mock-server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;CAU7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,+GAM7B,CAAC;AAMF;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,IAE3C,OAAO,MAAM,GAAG,GAAG,GAAG,OAAO,EAC7B,QAAQ,WAAW,KAClB,OAAO,CAAC,QAAQ,CAAC,CAoCrB;AAQD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAGtD;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAKnC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Server for E2E Testing
|
|
3
|
+
*
|
|
4
|
+
* A simple HTTP server that can be:
|
|
5
|
+
* 1. Controlled programmatically in tests (start/stop/restart)
|
|
6
|
+
* 2. Run standalone via: npx tsx src/__tests__/e2e/test-server.ts
|
|
7
|
+
*
|
|
8
|
+
* The server returns HTML that includes the request path, which tests
|
|
9
|
+
* can verify to confirm traffic is flowing through the tunnel.
|
|
10
|
+
*/
|
|
11
|
+
export interface TestServerOptions {
|
|
12
|
+
port?: number;
|
|
13
|
+
host?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class TestServer {
|
|
16
|
+
private server;
|
|
17
|
+
private port;
|
|
18
|
+
private host;
|
|
19
|
+
constructor(options?: TestServerOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Start the test server
|
|
22
|
+
*/
|
|
23
|
+
start(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Stop the test server
|
|
26
|
+
*/
|
|
27
|
+
stop(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Restart the test server
|
|
30
|
+
*/
|
|
31
|
+
restart(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Check if server is running
|
|
34
|
+
*/
|
|
35
|
+
isRunning(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get the server URL
|
|
38
|
+
*/
|
|
39
|
+
getUrl(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get the port
|
|
42
|
+
*/
|
|
43
|
+
getPort(): number;
|
|
44
|
+
private handleRequest;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=test-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-server.d.ts","sourceRoot":"","sources":["../../../src/__tests__/e2e/test-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;gBAET,OAAO,GAAE,iBAAsB;IAK3C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB3B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACH,OAAO,IAAI,MAAM;IAIjB,OAAO,CAAC,aAAa;CA+JtB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared E2E Test Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides common configuration and helpers for all E2E tests.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Server URL for E2E tests - requires a TEST server (not dev server)
|
|
8
|
+
*
|
|
9
|
+
* The test server must be running with ASPNETCORE_ENVIRONMENT=Test
|
|
10
|
+
* which enables TestAuthHandler for X-Test-User header authentication.
|
|
11
|
+
*
|
|
12
|
+
* Priority:
|
|
13
|
+
* 1. PERISCOPE_TEST_SERVER_URL (explicit test server)
|
|
14
|
+
* 2. PERISCOPE_SERVER_URL (used by CI workflows)
|
|
15
|
+
* 3. In CI: fallback to http://localhost:8080
|
|
16
|
+
* 4. Otherwise: empty string (tests will skip)
|
|
17
|
+
*
|
|
18
|
+
* NOTE: The dev server at periscope-server:8080 is NOT suitable for
|
|
19
|
+
* E2E tests as it uses real Azure AD authentication.
|
|
20
|
+
*/
|
|
21
|
+
export declare const TEST_SERVER_URL: string;
|
|
22
|
+
export declare const TEST_USER_HEADER = "X-Test-User";
|
|
23
|
+
export declare const DEFAULT_TEST_USER = "test@example.com";
|
|
24
|
+
/**
|
|
25
|
+
* Check if test server is available
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkTestServer(): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Initialize test server availability check (call in beforeAll)
|
|
30
|
+
* Returns true if server is available, false otherwise
|
|
31
|
+
*/
|
|
32
|
+
export declare function initTestServer(): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Get current server availability status
|
|
35
|
+
*/
|
|
36
|
+
export declare function isServerAvailable(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Skip helper - returns true if test should be skipped
|
|
39
|
+
* Use: if (skipIfNoServer()) return;
|
|
40
|
+
*/
|
|
41
|
+
export declare function skipIfNoServer(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Generate unique name for test resources to avoid conflicts
|
|
44
|
+
*/
|
|
45
|
+
export declare const uniqueName: (prefix: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Set up test authentication for CLI commands.
|
|
48
|
+
*
|
|
49
|
+
* This writes a fake token to the token cache that the CLI will read
|
|
50
|
+
* and send as a Bearer token. The test server's TestAuthHandler will
|
|
51
|
+
* extract the email from the token format: "test-token-{email}"
|
|
52
|
+
*
|
|
53
|
+
* @param email - Test user email (default: test@example.com)
|
|
54
|
+
* @param homeDir - Custom home directory (default: os.homedir())
|
|
55
|
+
*/
|
|
56
|
+
export declare function setupTestAuth(email?: string, homeDir?: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Clear test authentication.
|
|
59
|
+
*
|
|
60
|
+
* Removes the cached token to simulate logged-out state.
|
|
61
|
+
*
|
|
62
|
+
* @param homeDir - Custom home directory (default: os.homedir())
|
|
63
|
+
*/
|
|
64
|
+
export declare function clearTestAuth(homeDir?: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get the path to the token cache file.
|
|
67
|
+
*
|
|
68
|
+
* @param homeDir - Custom home directory (default: os.homedir())
|
|
69
|
+
*/
|
|
70
|
+
export declare function getTokenCachePath(homeDir?: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Generate and register an SSH key pair for e2e tests that create tunnels.
|
|
73
|
+
*
|
|
74
|
+
* With ELF-184, SSH keys are client-side. setupTestAuth() only writes the MSAL
|
|
75
|
+
* token; this function generates a key and registers the public key with the
|
|
76
|
+
* server so tunnel SSH authentication succeeds.
|
|
77
|
+
*
|
|
78
|
+
* Must be called after setupTestAuth() and only when the server is available.
|
|
79
|
+
*
|
|
80
|
+
* @param homeDir - Temp config dir used as HOME for the CLI process
|
|
81
|
+
* @param email - Test user email passed as PERISCOPE_TEST_USER
|
|
82
|
+
*/
|
|
83
|
+
export declare function setupTestSshKey(homeDir: string, email?: string): void;
|
|
84
|
+
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../src/__tests__/e2e/test-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,QAGqB,CAAC;AAElD,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AAQpD;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAaxD;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CA8BvD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAMxC;AAMD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,KAAG,MACyB,CAAC;AAkBtE;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,KAAK,GAAE,MAA0B,EACjC,OAAO,GAAE,MAAqB,GAC7B,IAAI,CAsBN;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,MAAqB,GAAG,IAAI,CAmBlE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,MAAqB,GAAG,MAAM,CAExE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,MAA0B,GAChC,IAAI,CAkBN"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function assertTunnelValid(tunnel: any): void;
|
|
2
|
+
export declare function assertConfigValid(config: any): void;
|
|
3
|
+
export declare function assertAuthValid(auth: any): void;
|
|
4
|
+
export declare function assertMSALConfigValid(msalConfig: any): void;
|
|
5
|
+
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/assertions.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,QAM5C;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,QAe5C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,QAKxC;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,GAAG,QAMpD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock factory functions for creating test data
|
|
3
|
+
*/
|
|
4
|
+
export declare const mockConfig: (overrides?: {}) => {
|
|
5
|
+
serverUrl: string;
|
|
6
|
+
logLevel: string;
|
|
7
|
+
allowUntrustedCerts: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const mockTunnel: (overrides?: {}) => {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
clientPort: number;
|
|
13
|
+
sshTunnelPort: number;
|
|
14
|
+
remoteURL: string;
|
|
15
|
+
status: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const mockMSALConfig: (overrides?: {}) => {
|
|
19
|
+
clientId: string;
|
|
20
|
+
authority: string;
|
|
21
|
+
scopes: string[];
|
|
22
|
+
};
|
|
23
|
+
export declare const mockAuthToken: (overrides?: {}) => {
|
|
24
|
+
accessToken: string;
|
|
25
|
+
expiresOn: Date;
|
|
26
|
+
account: {
|
|
27
|
+
username: string;
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=mock-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-factory.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/mock-factory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,UAAU,GAAI,cAAc;;;;CAKvC,CAAC;AAEH,eAAO,MAAM,UAAU,GAAI,cAAc;;;;;;;;CASvC,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,cAAc;;;;CAK3C,CAAC;AAEH,eAAO,MAAM,aAAa,GAAI,cAAc;;;;;;;CAQ1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/setup.ts"],"names":[],"mappings":""}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|