idfon 0.2.0
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 +23 -0
- package/bin/idfon.js +73 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# idfon
|
|
2
|
+
|
|
3
|
+
Peer-to-peer content transfer and live audio over [iroh](https://www.iroh.computer).
|
|
4
|
+
`npx idfon` runs the CLI with no install; the npm package wraps prebuilt
|
|
5
|
+
platform binaries (no Node code, no compile step).
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
# daemon status / identity
|
|
9
|
+
npx idfon status
|
|
10
|
+
|
|
11
|
+
# peerless transfer: blob tickets via stdout
|
|
12
|
+
npx idfon put --file demo.mp4 # prints a BlobTicket
|
|
13
|
+
npx idfon get <ticket> --out demo.mp4
|
|
14
|
+
|
|
15
|
+
# peer-directed: chat, signaled blobs, 1:1 live audio
|
|
16
|
+
npx idfon send PEER --text "hello"
|
|
17
|
+
npx idfon send PEER --file demo.mp4
|
|
18
|
+
npx idfon send PEER --stream --file audio.wav
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Supported platforms: macOS (arm64, x64), Linux (x64, arm64). The first command
|
|
22
|
+
starts a background daemon (`idfond`, shipped in the same package); see the
|
|
23
|
+
[repo](https://github.com/donpark/idfon) for the full CLI reference.
|
package/bin/idfon.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// Thin launcher: resolves the prebuilt platform binary and execs it with all
|
|
4
|
+
// arguments. The CLI itself (and the idfond daemon it auto-spawns from its own
|
|
5
|
+
// directory) does all the work; no logic lives here beyond platform selection.
|
|
6
|
+
|
|
7
|
+
const { spawn } = require("child_process");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
|
|
11
|
+
const packages = {
|
|
12
|
+
"darwin-arm64": "idfon-darwin-arm64",
|
|
13
|
+
"darwin-x64": "idfon-darwin-x64",
|
|
14
|
+
"linux-arm64": "idfon-linux-arm64",
|
|
15
|
+
"linux-x64": "idfon-linux-x64",
|
|
16
|
+
// ponytail: no win32 — idfond IPC is a Unix socket (std::os::unix); add a
|
|
17
|
+
// named-pipe transport to idfon-client first, then an idfon-win32-x64 package.
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const key = `${process.platform}-${process.arch}`;
|
|
21
|
+
const pkg = packages[key];
|
|
22
|
+
if (!pkg) {
|
|
23
|
+
console.error(`idfon: no prebuilt binary for ${key}`);
|
|
24
|
+
console.error(`supported platforms: ${Object.keys(packages).join(", ")}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let bin;
|
|
29
|
+
try {
|
|
30
|
+
bin = path.join(
|
|
31
|
+
path.dirname(require.resolve(`${pkg}/package.json`)),
|
|
32
|
+
"bin",
|
|
33
|
+
"idfon"
|
|
34
|
+
);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
// Repo-layout fallback: platform packages sitting at npm/* without a
|
|
37
|
+
// node_modules install (dev use, scripts/build-npm.sh output).
|
|
38
|
+
const devBin = path.join(__dirname, "..", "..", pkg, "bin", "idfon");
|
|
39
|
+
if (fs.existsSync(devBin)) {
|
|
40
|
+
bin = devBin;
|
|
41
|
+
} else {
|
|
42
|
+
console.error(`idfon: platform package ${pkg} is not installed (${err.code || err.message})`);
|
|
43
|
+
console.error("reinstall with: npm install idfon");
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
let child;
|
|
50
|
+
try {
|
|
51
|
+
child = spawn(bin, args, { stdio: "inherit" });
|
|
52
|
+
} catch (err) {
|
|
53
|
+
if (err.code === "EACCES") {
|
|
54
|
+
// Some environments strip the exec bit from installed files.
|
|
55
|
+
try {
|
|
56
|
+
fs.chmodSync(bin, 0o755);
|
|
57
|
+
} catch {}
|
|
58
|
+
child = spawn(bin, args, { stdio: "inherit" });
|
|
59
|
+
} else {
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
65
|
+
process.on(sig, () => child.kill(sig));
|
|
66
|
+
}
|
|
67
|
+
child.on("error", (err) => {
|
|
68
|
+
console.error(`idfon: failed to run ${bin}: ${err.message}`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
});
|
|
71
|
+
child.on("exit", (code, signal) => {
|
|
72
|
+
process.exit(signal ? 1 : (code ?? 0));
|
|
73
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "idfon",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Peer-to-peer content transfer and live audio over iroh: put/get tickets, peer push, 1:1 streams.",
|
|
5
|
+
"license": "(MIT OR Apache-2.0)",
|
|
6
|
+
"repository": "github:donpark/idfon",
|
|
7
|
+
"bin": {
|
|
8
|
+
"idfon": "bin/idfon.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"LICENSE-APACHE",
|
|
12
|
+
"LICENSE-MIT",
|
|
13
|
+
"LICENSE-APACHE",
|
|
14
|
+
"LICENSE-MIT",
|
|
15
|
+
"bin",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"idfon-darwin-arm64": "0.2.0",
|
|
20
|
+
"idfon-darwin-x64": "0.2.0",
|
|
21
|
+
"idfon-linux-arm64": "0.2.0",
|
|
22
|
+
"idfon-linux-x64": "0.2.0"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
}
|
|
27
|
+
}
|