@share2us/cli 0.1.9 → 0.1.11

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 CHANGED
@@ -12,8 +12,8 @@ transfers with no account and no cloud.
12
12
  npm install -g @share2us/cli
13
13
  ```
14
14
 
15
- This downloads the prebuilt binary for your platform (linux/macOS, x64/arm64) from
16
- [GitHub Releases](https://github.com/share2us/cli/releases). Then:
15
+ This downloads the prebuilt binary for your platform (Linux, macOS, and Windows;
16
+ x64/arm64) from [GitHub Releases](https://github.com/share2us/cli/releases). Then:
17
17
 
18
18
  ```sh
19
19
  s2u login
@@ -22,7 +22,9 @@ s2u get s.share2.us/7Kf9aQ2m
22
22
  s2u help # full command reference
23
23
  ```
24
24
 
25
- Prefer a script installer instead? `curl -fsSL https://share2.us/install.sh | sh`
25
+ Prefer a script installer instead?
26
+ - Linux / macOS: `curl -fsSL https://share2.us/install.sh | sh`
27
+ - Windows (PowerShell): `irm https://share2.us/install.ps1 | iex`
26
28
 
27
29
  ## Notes
28
30
 
package/bin/s2u.js CHANGED
@@ -6,7 +6,10 @@ const fs = require("fs");
6
6
  const path = require("path");
7
7
  const { spawnSync } = require("child_process");
8
8
 
9
- const bin = path.join(__dirname, "share2us-bin");
9
+ const bin = path.join(
10
+ __dirname,
11
+ process.platform === "win32" ? "share2us-bin.exe" : "share2us-bin"
12
+ );
10
13
 
11
14
  if (!fs.existsSync(bin)) {
12
15
  console.error("share2us: the CLI binary is missing (install scripts may have been skipped).");
package/install.js CHANGED
@@ -30,7 +30,7 @@ function fail(msg) {
30
30
  }
31
31
 
32
32
  function platform() {
33
- const osName = { linux: "linux", darwin: "darwin" }[process.platform];
33
+ const osName = { linux: "linux", darwin: "darwin", win32: "windows" }[process.platform];
34
34
  const arch = { x64: "amd64", arm64: "arm64" }[process.arch];
35
35
  if (!osName || !arch) {
36
36
  fail(
@@ -38,7 +38,15 @@ function platform() {
38
38
  "Build from source (https://github.com/share2us/cli) or use https://share2.us/install.sh"
39
39
  );
40
40
  }
41
- return { archive: `share2us_${osName}_${arch}.tar.gz` };
41
+ // Windows releases ship share2us.exe in a .zip; every other platform ships a
42
+ // bare binary in a .tar.gz.
43
+ const isWindows = osName === "windows";
44
+ return {
45
+ archive: `share2us_${osName}_${arch}.${isWindows ? "zip" : "tar.gz"}`,
46
+ binaryInArchive: isWindows ? "share2us.exe" : "share2us",
47
+ binaryOnDisk: isWindows ? "share2us-bin.exe" : "share2us-bin",
48
+ isWindows,
49
+ };
42
50
  }
43
51
 
44
52
  function assetURL(archive) {
@@ -71,38 +79,68 @@ function download(url, dest, redirects = 0) {
71
79
  });
72
80
  }
73
81
 
82
+ // Integrity check. Unix mirrors install.sh (system cksum + .crc32 sidecar);
83
+ // Windows has no cksum, so it verifies the .sha256 sidecar with Node's crypto.
84
+ async function verifyIntegrity(archivePath, base, isWindows) {
85
+ try {
86
+ if (isWindows) {
87
+ const sidecar = archivePath + ".sha256";
88
+ await download(base + ".sha256", sidecar);
89
+ const crypto = require("crypto");
90
+ const got = crypto
91
+ .createHash("sha256")
92
+ .update(fs.readFileSync(archivePath))
93
+ .digest("hex");
94
+ const want = fs.readFileSync(sidecar, "utf8").trim().split(/\s+/)[0];
95
+ if (got.toLowerCase() !== String(want).toLowerCase()) {
96
+ fail(`SHA-256 check failed for ${path.basename(archivePath)}`);
97
+ }
98
+ } else {
99
+ const crc = archivePath + ".crc32";
100
+ await download(base + ".crc32", crc);
101
+ const got = execFileSync("cksum", [archivePath]).toString().trim().split(/\s+/);
102
+ const want = fs.readFileSync(crc, "utf8").trim().split(/\s+/);
103
+ if (got[0] !== want[0] || got[1] !== want[1]) {
104
+ fail(`CRC check failed for ${path.basename(archivePath)}`);
105
+ }
106
+ }
107
+ } catch (e) {
108
+ if (String(e && e.message).includes("check failed")) throw e;
109
+ // sidecar/tool unavailable: HTTPS already protects the transfer.
110
+ }
111
+ }
112
+
74
113
  async function main() {
75
- const { archive } = platform();
114
+ const { archive, binaryInArchive, binaryOnDisk, isWindows } = platform();
76
115
  const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "s2u-install-"));
77
- const tgz = path.join(tmp, archive);
78
- const crc = tgz + ".crc32";
116
+ const archivePath = path.join(tmp, archive);
79
117
  const base = assetURL(archive);
80
118
 
81
119
  console.log(`share2us: downloading ${archive} (${VERSION})...`);
82
- await download(base, tgz);
120
+ await download(base, archivePath);
83
121
 
84
- // Integrity: system cksum against the .crc32 sidecar (same as install.sh).
85
- try {
86
- await download(base + ".crc32", crc);
87
- const got = execFileSync("cksum", [tgz]).toString().trim().split(/\s+/);
88
- const want = fs.readFileSync(crc, "utf8").trim().split(/\s+/);
89
- if (got[0] !== want[0] || got[1] !== want[1]) {
90
- fail(`CRC check failed for ${archive}`);
91
- }
92
- } catch (e) {
93
- if (String(e && e.message).includes("CRC check failed")) throw e;
94
- // sidecar/cksum unavailable: HTTPS already protects the transfer.
95
- }
122
+ await verifyIntegrity(archivePath, base, isWindows);
96
123
 
97
- // Extract the `share2us` binary and place it beside the shim.
98
- execFileSync("tar", ["-xzf", tgz, "-C", tmp]);
99
- const src = path.join(tmp, "share2us");
100
- if (!fs.existsSync(src)) fail("archive did not contain the share2us binary");
124
+ // Extract the binary and place it beside the shim. Unix uses system tar on
125
+ // the .tar.gz; Windows uses PowerShell's Expand-Archive on the .zip (always
126
+ // present, unlike a modern bsdtar).
127
+ if (isWindows) {
128
+ execFileSync("powershell", [
129
+ "-NoProfile",
130
+ "-NonInteractive",
131
+ "-Command",
132
+ `Expand-Archive -Force -LiteralPath '${archivePath}' -DestinationPath '${tmp}'`,
133
+ ]);
134
+ } else {
135
+ execFileSync("tar", ["-xf", archivePath, "-C", tmp]);
136
+ }
137
+ const src = path.join(tmp, binaryInArchive);
138
+ if (!fs.existsSync(src)) fail(`archive did not contain ${binaryInArchive}`);
101
139
  const binDir = path.join(__dirname, "bin");
102
140
  fs.mkdirSync(binDir, { recursive: true });
103
- const out = path.join(binDir, "share2us-bin");
141
+ const out = path.join(binDir, binaryOnDisk);
104
142
  fs.copyFileSync(src, out);
105
- fs.chmodSync(out, 0o755);
143
+ if (!isWindows) fs.chmodSync(out, 0o755);
106
144
  fs.rmSync(tmp, { recursive: true, force: true });
107
145
 
108
146
  console.log("share2us: installed. Run `s2u login` to get started.");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@share2us/cli",
3
- "version": "0.1.9",
4
- "share2usCliVersion": "v20260719135327",
3
+ "version": "0.1.11",
4
+ "share2usCliVersion": "v20260721080007",
5
5
  "description": "Share2Us CLI (s2u) — share files and text from your terminal, browser, or AI agent via one opaque, expiring link.",
6
6
  "keywords": [
7
7
  "share2us",
@@ -36,7 +36,8 @@
36
36
  ],
37
37
  "os": [
38
38
  "linux",
39
- "darwin"
39
+ "darwin",
40
+ "win32"
40
41
  ],
41
42
  "cpu": [
42
43
  "x64",