@speedscale/proxymock 2.3.645

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/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # proxymock
2
+
3
+ A free command-line tool that automatically creates mocks and tests from watching your app run. proxymock is a backend service emulator that lets you run your app as if it were in a live environment.
4
+
5
+ ## What is proxymock?
6
+
7
+ proxymock allows you to record, visualize, mock, and replay traffic on your local system. It captures your application's interactions with external services and creates realistic mocks that can be used for development and testing without hitting real APIs or databases.
8
+
9
+ ### Key Features
10
+
11
+ - **Free for Local Development**: Complete functionality available at no cost
12
+ - **Record & Replay**: Capture real traffic from your application and replay it later
13
+ - **Smart Proxy**: Intercepts and mocks outbound requests without code changes
14
+ - **Realistic Mocks**: Generate mocks from actual production-like traffic
15
+ - **Multiple Protocols**: Support for HTTP, HTTPS, gRPC, and other TCP protocols
16
+ - **MCP Integration**: Model Context Protocol support for AI development tools
17
+
18
+ ### Use Cases
19
+
20
+ - Develop locally without depending on live backend services
21
+ - Test applications when external services are unavailable or unreliable
22
+ - Bypass API rate limits during development
23
+ - Create consistent test environments
24
+ - Generate realistic test data from production traffic
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ # Run the latest version
30
+ npx -y @speedscale/proxymock --help
31
+ ```
32
+
33
+ The binary will be automatically downloaded and cached in `~/.speedscale/` on first run.
34
+
35
+ ## Getting Started
36
+
37
+ For complete setup instructions and tutorials, visit the [proxymock documentation](https://docs.speedscale.com/proxymock/getting-started/quickstart-cli/).
38
+
39
+ ## MCP (Model Context Protocol) Support
40
+
41
+ proxymock includes an MCP server for integration with AI development tools like Cursor and Claude Desktop. Add the following to your MCP config file and ask your AI coding tool what proxymock can do:
42
+
43
+ ```bash
44
+ {
45
+ "mcpServers": {
46
+ "proxymock-simulator": {
47
+ "type": "stdio",
48
+ "command": "npx",
49
+ "args": [
50
+ "-y",
51
+ "@speedscale/proxymock",
52
+ "mcp"
53
+ ]
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ## Support
60
+
61
+ Join our [Slack community](https://slack.speedscale.com/). Seriously, come talk to us.
62
+
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from "child_process";
4
+ import { join, dirname } from "path";
5
+ import { existsSync } from "fs";
6
+ import { homedir } from "os";
7
+ import { fileURLToPath } from "url";
8
+
9
+ // Determine the binary path
10
+ const INSTALLROOT = process.env.INSTALLROOT || join(homedir(), ".speedscale");
11
+ const binaryPath = join(INSTALLROOT, "proxymock");
12
+
13
+ function runProxyMock() {
14
+ const child = spawn(binaryPath, process.argv.slice(2), {
15
+ stdio: "inherit",
16
+ env: process.env,
17
+ });
18
+
19
+ child.on("error", (err) => {
20
+ console.error("Failed to start proxymock:", err);
21
+ process.exit(1);
22
+ });
23
+
24
+ child.on("exit", (code) => {
25
+ process.exit(code || 0);
26
+ });
27
+ }
28
+
29
+ // Check if proxymock is installed
30
+ if (!existsSync(binaryPath)) {
31
+ // Run the installation
32
+ const __filename = fileURLToPath(import.meta.url);
33
+ const __dirname = dirname(__filename);
34
+ const installScript = join(__dirname, "..", "lib", "install.js");
35
+ const installProcess = spawn("node", [installScript], { stdio: "inherit" });
36
+
37
+ installProcess.on("exit", (code) => {
38
+ if (code !== 0) {
39
+ console.error("Installation failed");
40
+ process.exit(1);
41
+ }
42
+ // Run proxymock after successful installation
43
+ runProxyMock();
44
+ });
45
+ } else {
46
+ // Binary exists, run it directly
47
+ runProxyMock();
48
+ }
package/lib/install.js ADDED
@@ -0,0 +1,157 @@
1
+ import { get } from "https";
2
+ import {
3
+ createWriteStream,
4
+ createReadStream,
5
+ readFileSync,
6
+ copyFileSync,
7
+ unlinkSync,
8
+ mkdirSync,
9
+ chmodSync,
10
+ } from "fs";
11
+ import { join, dirname } from "path";
12
+ import { tmpdir, platform, arch, homedir } from "os";
13
+ import { createHash } from "crypto";
14
+ import { fileURLToPath } from "url";
15
+
16
+ async function downloadFile(url, destPath) {
17
+ return new Promise((resolve, reject) => {
18
+ const file = createWriteStream(destPath);
19
+
20
+ get(url, (response) => {
21
+ if (response.statusCode !== 200) {
22
+ reject(new Error(`Failed to download: ${response.statusCode}`));
23
+ return;
24
+ }
25
+
26
+ response.pipe(file);
27
+
28
+ file.on("finish", () => {
29
+ file.close(resolve);
30
+ });
31
+ }).on("error", reject);
32
+ });
33
+ }
34
+
35
+ function getPlatformBinary() {
36
+ const os = platform();
37
+ const architecture = arch();
38
+
39
+ let osName, archName;
40
+
41
+ // Map Node.js platform names to our binary names
42
+ switch (os) {
43
+ case "darwin":
44
+ osName = "darwin";
45
+ break;
46
+ case "linux":
47
+ osName = "linux";
48
+ break;
49
+ case "win32":
50
+ return "proxymock.exe"; // Windows binary doesn't have arch suffix
51
+ default:
52
+ throw new Error(`Unsupported platform: ${os}`);
53
+ }
54
+
55
+ // Map Node.js arch names to our binary names
56
+ switch (architecture) {
57
+ case "x64":
58
+ archName = "amd64";
59
+ break;
60
+ case "arm64":
61
+ archName = "arm64";
62
+ break;
63
+ default:
64
+ throw new Error(`Unsupported architecture: ${architecture}`);
65
+ }
66
+
67
+ return `proxymock-${osName}-${archName}`;
68
+ }
69
+
70
+ async function validateChecksum(filePath, expectedChecksum) {
71
+ return new Promise((resolve, reject) => {
72
+ const hash = createHash("sha256");
73
+ const stream = createReadStream(filePath);
74
+
75
+ stream.on("data", (data) => {
76
+ hash.update(data);
77
+ });
78
+
79
+ stream.on("end", () => {
80
+ const actualChecksum = hash.digest("hex");
81
+ resolve(actualChecksum === expectedChecksum);
82
+ });
83
+
84
+ stream.on("error", reject);
85
+ });
86
+ }
87
+
88
+ function getPackageVersion() {
89
+ const __dirname = dirname(fileURLToPath(import.meta.url));
90
+ const packageJson = JSON.parse(
91
+ readFileSync(join(__dirname, "..", "package.json"), "utf8"),
92
+ );
93
+ return packageJson.version;
94
+ }
95
+
96
+ async function install() {
97
+ try {
98
+ // Read version from package.json
99
+ const npmVersion = getPackageVersion();
100
+
101
+ // Convert npm version to proxymock version format
102
+ // npm: "2.3.660" -> proxymock: "v2.3.660"
103
+ const proxymockVersion = `v${npmVersion}`;
104
+
105
+ const srcfile = getPlatformBinary();
106
+
107
+ // Build versioned URL
108
+ const baseUrl = `https://downloads.speedscale.com/proxymock/${proxymockVersion}`;
109
+ const srcUrl = `${baseUrl}/${srcfile}`;
110
+ const shaUrl = `${baseUrl}/${srcfile}.sha256`;
111
+
112
+ const INSTALLROOT =
113
+ process.env.INSTALLROOT || join(homedir(), ".speedscale");
114
+
115
+ // Ensure install directory exists
116
+ mkdirSync(INSTALLROOT, { recursive: true });
117
+
118
+ // Download checksum first
119
+ const tempShaPath = join(tmpdir(), `${srcfile}.sha256`);
120
+ await downloadFile(shaUrl, tempShaPath);
121
+ const expectedChecksum = readFileSync(tempShaPath, "utf8")
122
+ .trim()
123
+ .split(" ")[0];
124
+
125
+ // Download binary
126
+ const tempBinPath = join(tmpdir(), srcfile);
127
+ await downloadFile(srcUrl, tempBinPath);
128
+
129
+ // Validate checksum
130
+ const isValid = await validateChecksum(tempBinPath, expectedChecksum);
131
+
132
+ if (!isValid) {
133
+ throw new Error("Checksum validation failed");
134
+ }
135
+
136
+ // Install - always as "proxymock" since npm version provides isolation
137
+ const dstPath = join(INSTALLROOT, "proxymock");
138
+ copyFileSync(tempBinPath, dstPath);
139
+
140
+ // Make executable on Unix-like systems
141
+ if (platform() !== "win32") {
142
+ chmodSync(dstPath, "755");
143
+ }
144
+
145
+ // Cleanup
146
+ unlinkSync(tempShaPath);
147
+ unlinkSync(tempBinPath);
148
+ } catch (error) {
149
+ console.error("Installation failed:", error.message);
150
+ process.exit(1);
151
+ }
152
+ }
153
+
154
+ // Run installation if this script is executed directly
155
+ if (import.meta.url === `file://${process.argv[1]}`) {
156
+ install();
157
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@speedscale/proxymock",
3
+ "version": "2.3.645",
4
+ "description": "A free desktop CLI that automatically creates mocks and tests from watching your app run.",
5
+ "keywords": [
6
+ "api",
7
+ "mock",
8
+ "mocking",
9
+ "bug",
10
+ "debug",
11
+ "environment",
12
+ "mcp",
13
+ "observability",
14
+ "observe",
15
+ "proxymock",
16
+ "real",
17
+ "realistic",
18
+ "record",
19
+ "replay",
20
+ "test",
21
+ "traffic",
22
+ "validate"
23
+ ],
24
+ "license": "Apache-2.0",
25
+ "author": "Speedscale <support@speedscale.com>",
26
+ "type": "module",
27
+ "bin": {
28
+ "proxymock": "bin/proxymock.js"
29
+ },
30
+ "homepage": "https://proxymock.io/",
31
+ "bugs": {
32
+ "url": "https://slack.speedscale.com/"
33
+ },
34
+ "scripts": {
35
+ "test": "node --test || echo 'No tests defined'",
36
+ "validate": "npm pack && echo 'Package validation complete'"
37
+ }
38
+ }