@dns-data/remote 0.2.8 → 0.2.9
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/bin/dns-data.js +104 -104
- package/native/macos-arm64 +0 -0
- package/native/windows-x64.exe +0 -0
- package/package.json +34 -34
package/bin/dns-data.js
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
const fs=require('fs');
|
|
4
|
-
const path=require('path');
|
|
5
|
-
const crypto=require('crypto');
|
|
6
|
-
const os=require('os');
|
|
7
|
-
const {spawn}=require('child_process');
|
|
8
|
-
|
|
9
|
-
const id=process.platform+'-'+process.arch;
|
|
10
|
-
const binaries={'win32-x64':'windows-x64.exe','darwin-arm64':'macos-arm64'};
|
|
11
|
-
const expected={
|
|
12
|
-
'windows-x64.exe':'
|
|
13
|
-
'macos-arm64':'
|
|
14
|
-
};
|
|
15
|
-
const nativeName=binaries[id];
|
|
16
|
-
if(!nativeName){console.error('[ERROR] DNS-DATA supports Windows x64 and macOS arm64.');process.exit(2);}
|
|
17
|
-
const binary=path.resolve(__dirname,'..','native',nativeName);
|
|
18
|
-
try{
|
|
19
|
-
const hash=crypto.createHash('sha256').update(fs.readFileSync(binary)).digest('hex');
|
|
20
|
-
if(hash.toLowerCase()!==expected[nativeName].toLowerCase()) throw Error('native binary integrity mismatch');
|
|
21
|
-
if(process.platform==='darwin') fs.chmodSync(binary,0o755);
|
|
22
|
-
}catch(e){console.error('[ERROR] DNS-DATA integrity: '+e.message);process.exit(3);}
|
|
23
|
-
|
|
24
|
-
// macOS uses a persistent, per-user Agent path. The executable and its
|
|
25
|
-
// associated network identity no longer change when npx rotates cache paths.
|
|
26
|
-
// All copies are verified against the package's embedded SHA-256. No root,
|
|
27
|
-
// SMB share, SSH daemon, or second macOS application is required.
|
|
28
|
-
let runtimeBinary=binary;
|
|
29
|
-
if(process.platform==='darwin'){
|
|
30
|
-
const stableDir=path.join(os.homedir(),'Library','Application Support',
|
|
31
|
-
'DNS-DATA','Remote-Agent');
|
|
32
|
-
const stableBinary=path.join(stableDir,'dns-data-agent-macos-arm64');
|
|
33
|
-
const digest=(p)=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
|
|
34
|
-
try {
|
|
35
|
-
fs.mkdirSync(stableDir,{recursive:true,mode:0o700});
|
|
36
|
-
const dirInfo=fs.lstatSync(stableDir);
|
|
37
|
-
if(!dirInfo.isDirectory()||dirInfo.isSymbolicLink())
|
|
38
|
-
throw Error('unsafe native agent directory');
|
|
39
|
-
fs.chmodSync(stableDir,0o700);
|
|
40
|
-
let current=false;
|
|
41
|
-
try{
|
|
42
|
-
const st=fs.lstatSync(stableBinary);
|
|
43
|
-
if(!st.isFile()||st.isSymbolicLink())throw Error('unsafe native agent path');
|
|
44
|
-
current=digest(stableBinary)===expected[nativeName];
|
|
45
|
-
}catch(e){if(e.code!=='ENOENT')throw e;}
|
|
46
|
-
if(!current){
|
|
47
|
-
const temp=path.join(stableDir,'.dns-data-agent-'+process.pid+
|
|
48
|
-
'-'+crypto.randomBytes(8).toString('hex')+'.tmp');
|
|
49
|
-
try{
|
|
50
|
-
fs.copyFileSync(binary,temp,fs.constants.COPYFILE_EXCL);
|
|
51
|
-
fs.chmodSync(temp,0o700);
|
|
52
|
-
if(digest(temp)!==expected[nativeName])throw Error('staged native hash mismatch');
|
|
53
|
-
fs.renameSync(temp,stableBinary);
|
|
54
|
-
}finally{if(fs.existsSync(temp))fs.unlinkSync(temp);}
|
|
55
|
-
}
|
|
56
|
-
fs.chmodSync(stableBinary,0o700);
|
|
57
|
-
if(digest(stableBinary)!==expected[nativeName])
|
|
58
|
-
throw Error('installed native hash mismatch');
|
|
59
|
-
runtimeBinary=stableBinary;
|
|
60
|
-
}catch(e){
|
|
61
|
-
console.error('[ERROR] DNS-DATA macOS agent installation: '+e.message);
|
|
62
|
-
process.exit(4);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const args=process.argv.slice(2);
|
|
67
|
-
const safe=new Set(['--version','--start','--pair-only','--hardware-check','--pair-probe','--policy-check']);
|
|
68
|
-
const isPreview=args.length===1&&args[0]==='--flow-preview';
|
|
69
|
-
if(isPreview){
|
|
70
|
-
console.log('DNS-DATA '+require('../package.json').version+': fresh motherboard/CPU/GPU + account -> native Go executor via npx');
|
|
71
|
-
console.log('New device: eight-digit pairing -> fresh hardware recheck -> built-in remote service (no .NET)');
|
|
72
|
-
console.log('V1 pairing, V1 device startup and legacy bootstrap: disabled');
|
|
73
|
-
process.exit(0);
|
|
74
|
-
}
|
|
75
|
-
const isNativeLANCopy=['win32','darwin'].includes(process.platform) &&
|
|
76
|
-
args.length===4 &&
|
|
77
|
-
((args[0]==='--lan-copy-send' && args[2]==='--lan-copy-done') ||
|
|
78
|
-
(args[0]==='--lan-copy-receive' && args[2]==='--lan-copy-offer-file')) &&
|
|
79
|
-
[args[1],args[3]].every(p=>typeof p==='string' && p.length>0 && p.length<4096 &&
|
|
80
|
-
path.isAbsolute(p) && [0,10,13].every(c=>!p.includes(String.fromCharCode(c))));
|
|
81
|
-
if(!isNativeLANCopy && (args.length>1||args.some(a=>!safe.has(a)))){console.error('[ERROR] Unknown or unsafe DNS-DATA arguments.');process.exit(2);}
|
|
82
|
-
// Create or repair one desktop shortcut on every ordinary npm startup, also
|
|
83
|
-
// for already-bound devices. Never trigger this for diagnostic or transfer verbs.
|
|
84
|
-
if(args.length===0 || (args.length===1 && (args[0]==='--start' || args[0]==='--pair-only'))){
|
|
85
|
-
try {
|
|
86
|
-
const shortcut=require('./desktop-shortcut').ensureDesktopShortcut();
|
|
87
|
-
if(shortcut.changed) console.log('DNS-DATA desktop launcher ready: '+shortcut.path);
|
|
88
|
-
} catch(e) {
|
|
89
|
-
// Desktop/OneDrive permissions must not prevent the existing service running.
|
|
90
|
-
console.warn('[WARN] DNS-DATA desktop launcher: '+e.message);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
console.log('DNS-DATA Remote Connection - V2');
|
|
94
|
-
const child=spawn(runtimeBinary,args,{stdio:'inherit',shell:false,windowsHide:false,env:process.env});
|
|
95
|
-
let done=false;
|
|
96
|
-
function finish(code){
|
|
97
|
-
if(done)return;done=true;
|
|
98
|
-
process.exitCode=code;
|
|
99
|
-
}
|
|
100
|
-
child.once('error',e=>{console.error('[ERROR] V2 launcher: '+e.message);finish(1);});
|
|
101
|
-
child.once('exit',(code,signal)=>finish(code===null?(signal==='SIGINT'?130:1):code));
|
|
102
|
-
for(const sig of ['SIGINT','SIGTERM','SIGHUP']){
|
|
103
|
-
try{process.on(sig,()=>{if(process.platform!=='win32'&&!child.killed)child.kill(sig);});}catch(_){}
|
|
104
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const fs=require('fs');
|
|
4
|
+
const path=require('path');
|
|
5
|
+
const crypto=require('crypto');
|
|
6
|
+
const os=require('os');
|
|
7
|
+
const {spawn}=require('child_process');
|
|
8
|
+
|
|
9
|
+
const id=process.platform+'-'+process.arch;
|
|
10
|
+
const binaries={'win32-x64':'windows-x64.exe','darwin-arm64':'macos-arm64'};
|
|
11
|
+
const expected={
|
|
12
|
+
'windows-x64.exe':'8f54d053ad08bcb7afe906bba6c6fd12ab5b465121f18d351a58b79076ab3cb0',
|
|
13
|
+
'macos-arm64':'45871ba1925cd9c4c1e5abdca15be6712adbb397acd4fbe087de2bcedbc1da1b'
|
|
14
|
+
};
|
|
15
|
+
const nativeName=binaries[id];
|
|
16
|
+
if(!nativeName){console.error('[ERROR] DNS-DATA supports Windows x64 and macOS arm64.');process.exit(2);}
|
|
17
|
+
const binary=path.resolve(__dirname,'..','native',nativeName);
|
|
18
|
+
try{
|
|
19
|
+
const hash=crypto.createHash('sha256').update(fs.readFileSync(binary)).digest('hex');
|
|
20
|
+
if(hash.toLowerCase()!==expected[nativeName].toLowerCase()) throw Error('native binary integrity mismatch');
|
|
21
|
+
if(process.platform==='darwin') fs.chmodSync(binary,0o755);
|
|
22
|
+
}catch(e){console.error('[ERROR] DNS-DATA integrity: '+e.message);process.exit(3);}
|
|
23
|
+
|
|
24
|
+
// macOS uses a persistent, per-user Agent path. The executable and its
|
|
25
|
+
// associated network identity no longer change when npx rotates cache paths.
|
|
26
|
+
// All copies are verified against the package's embedded SHA-256. No root,
|
|
27
|
+
// SMB share, SSH daemon, or second macOS application is required.
|
|
28
|
+
let runtimeBinary=binary;
|
|
29
|
+
if(process.platform==='darwin'){
|
|
30
|
+
const stableDir=path.join(os.homedir(),'Library','Application Support',
|
|
31
|
+
'DNS-DATA','Remote-Agent');
|
|
32
|
+
const stableBinary=path.join(stableDir,'dns-data-agent-macos-arm64');
|
|
33
|
+
const digest=(p)=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
|
|
34
|
+
try {
|
|
35
|
+
fs.mkdirSync(stableDir,{recursive:true,mode:0o700});
|
|
36
|
+
const dirInfo=fs.lstatSync(stableDir);
|
|
37
|
+
if(!dirInfo.isDirectory()||dirInfo.isSymbolicLink())
|
|
38
|
+
throw Error('unsafe native agent directory');
|
|
39
|
+
fs.chmodSync(stableDir,0o700);
|
|
40
|
+
let current=false;
|
|
41
|
+
try{
|
|
42
|
+
const st=fs.lstatSync(stableBinary);
|
|
43
|
+
if(!st.isFile()||st.isSymbolicLink())throw Error('unsafe native agent path');
|
|
44
|
+
current=digest(stableBinary)===expected[nativeName];
|
|
45
|
+
}catch(e){if(e.code!=='ENOENT')throw e;}
|
|
46
|
+
if(!current){
|
|
47
|
+
const temp=path.join(stableDir,'.dns-data-agent-'+process.pid+
|
|
48
|
+
'-'+crypto.randomBytes(8).toString('hex')+'.tmp');
|
|
49
|
+
try{
|
|
50
|
+
fs.copyFileSync(binary,temp,fs.constants.COPYFILE_EXCL);
|
|
51
|
+
fs.chmodSync(temp,0o700);
|
|
52
|
+
if(digest(temp)!==expected[nativeName])throw Error('staged native hash mismatch');
|
|
53
|
+
fs.renameSync(temp,stableBinary);
|
|
54
|
+
}finally{if(fs.existsSync(temp))fs.unlinkSync(temp);}
|
|
55
|
+
}
|
|
56
|
+
fs.chmodSync(stableBinary,0o700);
|
|
57
|
+
if(digest(stableBinary)!==expected[nativeName])
|
|
58
|
+
throw Error('installed native hash mismatch');
|
|
59
|
+
runtimeBinary=stableBinary;
|
|
60
|
+
}catch(e){
|
|
61
|
+
console.error('[ERROR] DNS-DATA macOS agent installation: '+e.message);
|
|
62
|
+
process.exit(4);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const args=process.argv.slice(2);
|
|
67
|
+
const safe=new Set(['--version','--start','--pair-only','--hardware-check','--pair-probe','--policy-check']);
|
|
68
|
+
const isPreview=args.length===1&&args[0]==='--flow-preview';
|
|
69
|
+
if(isPreview){
|
|
70
|
+
console.log('DNS-DATA '+require('../package.json').version+': fresh motherboard/CPU/GPU + account -> native Go executor via npx');
|
|
71
|
+
console.log('New device: eight-digit pairing -> fresh hardware recheck -> built-in remote service (no .NET)');
|
|
72
|
+
console.log('V1 pairing, V1 device startup and legacy bootstrap: disabled');
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
const isNativeLANCopy=['win32','darwin'].includes(process.platform) &&
|
|
76
|
+
args.length===4 &&
|
|
77
|
+
((args[0]==='--lan-copy-send' && args[2]==='--lan-copy-done') ||
|
|
78
|
+
(args[0]==='--lan-copy-receive' && args[2]==='--lan-copy-offer-file')) &&
|
|
79
|
+
[args[1],args[3]].every(p=>typeof p==='string' && p.length>0 && p.length<4096 &&
|
|
80
|
+
path.isAbsolute(p) && [0,10,13].every(c=>!p.includes(String.fromCharCode(c))));
|
|
81
|
+
if(!isNativeLANCopy && (args.length>1||args.some(a=>!safe.has(a)))){console.error('[ERROR] Unknown or unsafe DNS-DATA arguments.');process.exit(2);}
|
|
82
|
+
// Create or repair one desktop shortcut on every ordinary npm startup, also
|
|
83
|
+
// for already-bound devices. Never trigger this for diagnostic or transfer verbs.
|
|
84
|
+
if(args.length===0 || (args.length===1 && (args[0]==='--start' || args[0]==='--pair-only'))){
|
|
85
|
+
try {
|
|
86
|
+
const shortcut=require('./desktop-shortcut').ensureDesktopShortcut();
|
|
87
|
+
if(shortcut.changed) console.log('DNS-DATA desktop launcher ready: '+shortcut.path);
|
|
88
|
+
} catch(e) {
|
|
89
|
+
// Desktop/OneDrive permissions must not prevent the existing service running.
|
|
90
|
+
console.warn('[WARN] DNS-DATA desktop launcher: '+e.message);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
console.log('DNS-DATA Remote Connection - V2');
|
|
94
|
+
const child=spawn(runtimeBinary,args,{stdio:'inherit',shell:false,windowsHide:false,env:process.env});
|
|
95
|
+
let done=false;
|
|
96
|
+
function finish(code){
|
|
97
|
+
if(done)return;done=true;
|
|
98
|
+
process.exitCode=code;
|
|
99
|
+
}
|
|
100
|
+
child.once('error',e=>{console.error('[ERROR] V2 launcher: '+e.message);finish(1);});
|
|
101
|
+
child.once('exit',(code,signal)=>finish(code===null?(signal==='SIGINT'?130:1):code));
|
|
102
|
+
for(const sig of ['SIGINT','SIGTERM','SIGHUP']){
|
|
103
|
+
try{process.on(sig,()=>{if(process.platform!=='win32'&&!child.killed)child.kill(sig);});}catch(_){}
|
|
104
|
+
}
|
package/native/macos-arm64
CHANGED
|
Binary file
|
package/native/windows-x64.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dns-data/remote",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "DNS-DATA native Windows and macOS launcher with automatic npm desktop shortcuts and LAN Direct v3",
|
|
5
|
-
"license": "UNLICENSED",
|
|
6
|
-
"private": false,
|
|
7
|
-
"bin": {
|
|
8
|
-
"dns-data": "bin/dns-data.js"
|
|
9
|
-
},
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">=18"
|
|
12
|
-
},
|
|
13
|
-
"os": [
|
|
14
|
-
"win32",
|
|
15
|
-
"darwin"
|
|
16
|
-
],
|
|
17
|
-
"files": [
|
|
18
|
-
"bin/dns-data.js",
|
|
19
|
-
"bin/desktop-shortcut.js",
|
|
20
|
-
"native/windows-x64.exe",
|
|
21
|
-
"native/macos-arm64",
|
|
22
|
-
"README.md",
|
|
23
|
-
"DISCLOSURE"
|
|
24
|
-
],
|
|
25
|
-
"keywords": [
|
|
26
|
-
"dns-data",
|
|
27
|
-
"mcp",
|
|
28
|
-
"remote",
|
|
29
|
-
"native-launcher"
|
|
30
|
-
],
|
|
31
|
-
"contentPolicy": {
|
|
32
|
-
"class": "dual-use"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dns-data/remote",
|
|
3
|
+
"version": "0.2.9",
|
|
4
|
+
"description": "DNS-DATA native Windows and macOS launcher with automatic npm desktop shortcuts and LAN Direct v3",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"private": false,
|
|
7
|
+
"bin": {
|
|
8
|
+
"dns-data": "bin/dns-data.js"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18"
|
|
12
|
+
},
|
|
13
|
+
"os": [
|
|
14
|
+
"win32",
|
|
15
|
+
"darwin"
|
|
16
|
+
],
|
|
17
|
+
"files": [
|
|
18
|
+
"bin/dns-data.js",
|
|
19
|
+
"bin/desktop-shortcut.js",
|
|
20
|
+
"native/windows-x64.exe",
|
|
21
|
+
"native/macos-arm64",
|
|
22
|
+
"README.md",
|
|
23
|
+
"DISCLOSURE"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"dns-data",
|
|
27
|
+
"mcp",
|
|
28
|
+
"remote",
|
|
29
|
+
"native-launcher"
|
|
30
|
+
],
|
|
31
|
+
"contentPolicy": {
|
|
32
|
+
"class": "dual-use"
|
|
33
|
+
}
|
|
34
|
+
}
|