signal-sdk 0.0.4 → 0.0.6

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/dist/SignalCli.js CHANGED
@@ -62,11 +62,11 @@ class SignalCli extends events_1.EventEmitter {
62
62
  // Determine the correct signal-cli path based on platform
63
63
  let defaultPath;
64
64
  if (process.platform === 'win32') {
65
- defaultPath = path.join(__dirname, '..', 'bin', 'bin', 'signal-cli.bat');
65
+ defaultPath = path.join(__dirname, '..', 'bin', 'signal-cli.bat');
66
66
  }
67
67
  else {
68
68
  // For Unix/Linux systems, use the shell script
69
- defaultPath = path.join(__dirname, '..', 'bin', 'bin', 'signal-cli');
69
+ defaultPath = path.join(__dirname, '..', 'bin', 'signal-cli');
70
70
  }
71
71
  this.signalCliPath = signalCliPath || defaultPath;
72
72
  this.account = phoneNumber;
package/package.json CHANGED
@@ -1,72 +1,74 @@
1
- {
2
- "name": "signal-sdk",
3
- "version": "0.0.4",
4
- "description": "A comprehensive TypeScript SDK for Signal Messenger with native JSON-RPC support, providing high-performance messaging, bot framework, and full signal-cli integration.",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "bin": {
8
- "signal-sdk": "scripts/cli.js"
9
- },
10
- "files": [
11
- "dist/",
12
- "scripts/",
13
- "README.md",
14
- "LICENSE"
15
- ],
16
- "scripts": {
17
- "build": "tsc",
18
- "test": "jest",
19
- "postinstall": "node scripts/install.js",
20
- "connect": "node scripts/connect.js",
21
- "signal:connect": "node examples/sdk/00-device-linking.js",
22
- "example:basic": "node examples/sdk/01-basic-usage.js",
23
- "example:quick-start": "node examples/sdk/02-quick-start.js",
24
- "example:group-management": "node examples/sdk/03-group-management.js",
25
- "example:contact-management": "node examples/sdk/04-contact-management.js",
26
- "example:file-handling": "node examples/sdk/05-file-handling.js",
27
- "example:minimal-bot": "node examples/bot/01-minimal-bot.js",
28
- "example:advanced-bot": "node examples/bot/02-advanced-bot.js"
29
- },
30
- "keywords": [
31
- "signal",
32
- "signal-cli",
33
- "messaging",
34
- "bot",
35
- "typescript",
36
- "json-rpc",
37
- "sdk",
38
- "automation"
39
- ],
40
- "author": "devbyben",
41
- "license": "MIT",
42
- "repository": {
43
- "type": "git",
44
- "url": "https://github.com/benoitpetit/signal-sdk.git"
45
- },
46
- "homepage": "https://github.com/benoitpetit/signal-sdk#readme",
47
- "bugs": {
48
- "url": "https://github.com/benoitpetit/signal-sdk/issues"
49
- },
50
- "engines": {
51
- "node": ">=18.0.0"
52
- },
53
- "devDependencies": {
54
- "@types/jest": "^30.0.0",
55
- "@types/node": "^24.0.10",
56
- "@types/qrcode-terminal": "^0.12.2",
57
- "@types/uuid": "^9.0.8",
58
- "jest": "^30.0.4",
59
- "ts-jest": "^29.4.0",
60
- "typescript": "^5.8.3"
61
- },
62
- "dependencies": {
63
- "axios": "^1.10.0",
64
- "dotenv": "^16.4.5",
65
- "duckduckgo-chat-interface": "^1.1.5",
66
- "events": "^3.3.0",
67
- "qrcode": "^1.5.3",
68
- "qrcode-terminal": "^0.12.0",
69
- "tar": "^7.4.3",
70
- "uuid": "^9.0.1"
71
- }
1
+ {
2
+ "name": "signal-sdk",
3
+ "version": "0.0.6",
4
+ "description": "A comprehensive TypeScript SDK for Signal Messenger with native JSON-RPC support, providing high-performance messaging, bot framework, and full signal-cli integration.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "signal-sdk": "scripts/cli.js"
9
+ },
10
+ "files": [
11
+ "dist/",
12
+ "!dist/__tests__/",
13
+ "scripts/",
14
+ "README.md",
15
+ "LICENSE"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "test": "jest",
20
+ "prepublishOnly": "npm run build",
21
+ "postinstall": "node scripts/install.js",
22
+ "connect": "node scripts/connect.js",
23
+ "signal:connect": "node examples/sdk/00-device-linking.js",
24
+ "example:basic": "node examples/sdk/01-basic-usage.js",
25
+ "example:quick-start": "node examples/sdk/02-quick-start.js",
26
+ "example:group-management": "node examples/sdk/03-group-management.js",
27
+ "example:contact-management": "node examples/sdk/04-contact-management.js",
28
+ "example:file-handling": "node examples/sdk/05-file-handling.js",
29
+ "example:minimal-bot": "node examples/bot/01-minimal-bot.js",
30
+ "example:advanced-bot": "node examples/bot/02-advanced-bot.js"
31
+ },
32
+ "keywords": [
33
+ "signal",
34
+ "signal-cli",
35
+ "messaging",
36
+ "bot",
37
+ "typescript",
38
+ "json-rpc",
39
+ "sdk",
40
+ "automation"
41
+ ],
42
+ "author": "devbyben",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/benoitpetit/signal-sdk.git"
47
+ },
48
+ "homepage": "https://github.com/benoitpetit/signal-sdk#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/benoitpetit/signal-sdk/issues"
51
+ },
52
+ "engines": {
53
+ "node": ">=18.0.0"
54
+ },
55
+ "devDependencies": {
56
+ "@types/jest": "^30.0.0",
57
+ "@types/node": "^24.0.10",
58
+ "@types/qrcode-terminal": "^0.12.2",
59
+ "@types/uuid": "^9.0.8",
60
+ "jest": "^30.0.4",
61
+ "ts-jest": "^29.4.0",
62
+ "typescript": "^5.8.3"
63
+ },
64
+ "dependencies": {
65
+ "axios": "^1.10.0",
66
+ "dotenv": "^16.4.5",
67
+ "duckduckgo-chat-interface": "^1.1.5",
68
+ "events": "^3.3.0",
69
+ "qrcode": "^1.5.3",
70
+ "qrcode-terminal": "^0.12.0",
71
+ "tar": "^7.4.3",
72
+ "uuid": "^9.0.1"
73
+ }
72
74
  }
package/scripts/cli.js CHANGED
@@ -1,68 +1,68 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Signal SDK - CLI Tool
5
- *
6
- * Command-line interface for Signal SDK operations
7
- */
8
-
9
- const { spawn } = require('child_process');
10
- const path = require('path');
11
-
12
- function showHelp() {
13
- console.log('Signal SDK - Command Line Interface');
14
- console.log('===================================\n');
15
- console.log('Usage:');
16
- console.log(' npx signal-sdk <command> [options]\n');
17
- console.log('Commands:');
18
- console.log(' connect [device-name] Link a new device with QR code');
19
- console.log(' help Show this help message\n');
20
- console.log('Examples:');
21
- console.log(' npx signal-sdk connect');
22
- console.log(' npx signal-sdk connect "My Bot Device"');
23
- console.log(' npx signal-sdk help\n');
24
- console.log('For more information, visit: https://github.com/benoitpetit/signal-sdk');
25
- }
26
-
27
- function runCommand(scriptName, args = []) {
28
- const scriptPath = path.join(__dirname, `${scriptName}.js`);
29
- const child = spawn('node', [scriptPath, ...args], {
30
- stdio: 'inherit',
31
- cwd: process.cwd()
32
- });
33
-
34
- child.on('exit', (code) => {
35
- process.exit(code || 0);
36
- });
37
-
38
- child.on('error', (error) => {
39
- console.error('Error running command:', error.message);
40
- process.exit(1);
41
- });
42
- }
43
-
44
- // Parse command line arguments
45
- const [,, command, ...args] = process.argv;
46
-
47
- switch (command) {
48
- case 'connect':
49
- runCommand('connect', args);
50
- break;
51
-
52
- case 'help':
53
- case '--help':
54
- case '-h':
55
- showHelp();
56
- break;
57
-
58
- default:
59
- if (!command) {
60
- console.log('Signal SDK - No command specified\n');
61
- showHelp();
62
- } else {
63
- console.log(`Signal SDK - Unknown command: ${command}\n`);
64
- showHelp();
65
- process.exit(1);
66
- }
67
- break;
68
- }
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Signal SDK - CLI Tool
5
+ *
6
+ * Command-line interface for Signal SDK operations
7
+ */
8
+
9
+ const { spawn } = require('child_process');
10
+ const path = require('path');
11
+
12
+ function showHelp() {
13
+ console.log('Signal SDK - Command Line Interface');
14
+ console.log('===================================\n');
15
+ console.log('Usage:');
16
+ console.log(' npx signal-sdk <command> [options]\n');
17
+ console.log('Commands:');
18
+ console.log(' connect [device-name] Link a new device with QR code');
19
+ console.log(' help Show this help message\n');
20
+ console.log('Examples:');
21
+ console.log(' npx signal-sdk connect');
22
+ console.log(' npx signal-sdk connect "My Bot Device"');
23
+ console.log(' npx signal-sdk help\n');
24
+ console.log('For more information, visit: https://github.com/benoitpetit/signal-sdk');
25
+ }
26
+
27
+ function runCommand(scriptName, args = []) {
28
+ const scriptPath = path.join(__dirname, `${scriptName}.js`);
29
+ const child = spawn('node', [scriptPath, ...args], {
30
+ stdio: 'inherit',
31
+ cwd: process.cwd()
32
+ });
33
+
34
+ child.on('exit', (code) => {
35
+ process.exit(code || 0);
36
+ });
37
+
38
+ child.on('error', (error) => {
39
+ console.error('Error running command:', error.message);
40
+ process.exit(1);
41
+ });
42
+ }
43
+
44
+ // Parse command line arguments
45
+ const [,, command, ...args] = process.argv;
46
+
47
+ switch (command) {
48
+ case 'connect':
49
+ runCommand('connect', args);
50
+ break;
51
+
52
+ case 'help':
53
+ case '--help':
54
+ case '-h':
55
+ showHelp();
56
+ break;
57
+
58
+ default:
59
+ if (!command) {
60
+ console.log('Signal SDK - No command specified\n');
61
+ showHelp();
62
+ } else {
63
+ console.log(`Signal SDK - Unknown command: ${command}\n`);
64
+ showHelp();
65
+ process.exit(1);
66
+ }
67
+ break;
68
+ }
@@ -1,119 +1,119 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Signal SDK - Device Connection Script
5
- *
6
- * This script allows you to link a new device to an existing Signal account
7
- * by generating and displaying a QR code that can be scanned with your phone.
8
- *
9
- * Usage:
10
- * node scripts/connect.js [device-name]
11
- *
12
- * Examples:
13
- * node scripts/connect.js
14
- * node scripts/connect.js "My Bot Device"
15
- * npx signal-sdk connect
16
- * npx signal-sdk connect "My Custom Device"
17
- */
18
-
19
- const { SignalCli } = require('../dist/SignalCli');
20
-
21
- async function connectDevice() {
22
- console.log('Signal SDK - Device Connection');
23
- console.log('==================================\n');
24
-
25
- // Get device name from command line arguments
26
- const deviceName = process.argv[2] || 'Signal SDK Device';
27
-
28
- console.log(`Device name: ${deviceName}`);
29
- console.log('Generating QR code for device linking...\n');
30
-
31
- // Initialize the SDK without an account (for linking)
32
- const signalCli = new SignalCli();
33
-
34
- try {
35
- // Start device linking with QR code output to console
36
- const linkingResult = await signalCli.deviceLink({
37
- name: deviceName,
38
- qrCodeOutput: 'console'
39
- });
40
-
41
- if (linkingResult.success) {
42
- if (linkingResult.isLinked) {
43
- console.log('Device successfully linked!');
44
- console.log(`Device name: ${linkingResult.deviceName}`);
45
- console.log('\nYou can now use this device to send and receive Signal messages.');
46
- console.log('\nNext steps:');
47
- console.log(' 1. Import SignalCli in your Node.js project');
48
- console.log(' 2. Initialize with your phone number');
49
- console.log(' 3. Start sending and receiving messages');
50
- console.log('\nExample usage:');
51
- console.log(' const { SignalCli } = require("signal-sdk");');
52
- console.log(' const signalCli = new SignalCli("+YourPhoneNumber");');
53
- console.log(' await signalCli.connect();');
54
- } else {
55
- console.log('QR code generated successfully!');
56
- console.log('Scan the QR code above with your Signal app to link this device.');
57
- console.log('\nInstructions:');
58
- console.log(' 1. Open Signal on your phone');
59
- console.log(' 2. Go to Settings > Linked devices');
60
- console.log(' 3. Tap "Link new device"');
61
- console.log(' 4. Scan the QR code displayed above');
62
- console.log('\nWaiting for device linking...');
63
- console.log(' (This process may take a few moments)');
64
- }
65
- } else {
66
- console.error('Device linking failed');
67
- if (linkingResult.error) {
68
- console.error(` Error: ${linkingResult.error}`);
69
- }
70
- console.error('\nTroubleshooting:');
71
- console.error(' • Make sure signal-cli is properly installed');
72
- console.error(' • Check your internet connection');
73
- console.error(' • Ensure your Signal app is up to date');
74
- console.error(' • Try running the command again');
75
- process.exit(1);
76
- }
77
- } catch (error) {
78
- console.error('Fatal error during device linking:', error.message);
79
- console.error('\nCommon solutions:');
80
- console.error(' • Install signal-cli: https://github.com/AsamK/signal-cli');
81
- console.error(' • Make sure Java is installed and accessible');
82
- console.error(' • Check that signal-cli is in your PATH');
83
- console.error(' • Verify your internet connection');
84
- process.exit(1);
85
- }
86
- }
87
-
88
- // Handle graceful shutdown
89
- process.on('SIGINT', () => {
90
- console.log('\n\nDevice linking cancelled by user.');
91
- process.exit(0);
92
- });
93
-
94
- process.on('SIGTERM', () => {
95
- console.log('\n\nDevice linking terminated.');
96
- process.exit(0);
97
- });
98
-
99
- // Display help if requested
100
- if (process.argv.includes('--help') || process.argv.includes('-h')) {
101
- console.log('Signal SDK - Device Connection Script');
102
- console.log('=====================================\n');
103
- console.log('Usage:');
104
- console.log(' node scripts/connect.js [device-name]');
105
- console.log(' npx signal-sdk connect [device-name]\n');
106
- console.log('Arguments:');
107
- console.log(' device-name Optional name for the linked device (default: "Signal SDK Device")\n');
108
- console.log('Examples:');
109
- console.log(' node scripts/connect.js');
110
- console.log(' node scripts/connect.js "My Bot Device"');
111
- console.log(' npx signal-sdk connect');
112
- console.log(' npx signal-sdk connect "My Custom Device"\n');
113
- console.log('This script generates a QR code that you can scan with your Signal app');
114
- console.log('to link a new device for use with the Signal SDK.');
115
- process.exit(0);
116
- }
117
-
118
- // Run the connection process
119
- connectDevice();
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Signal SDK - Device Connection Script
5
+ *
6
+ * This script allows you to link a new device to an existing Signal account
7
+ * by generating and displaying a QR code that can be scanned with your phone.
8
+ *
9
+ * Usage:
10
+ * node scripts/connect.js [device-name]
11
+ *
12
+ * Examples:
13
+ * node scripts/connect.js
14
+ * node scripts/connect.js "My Bot Device"
15
+ * npx signal-sdk connect
16
+ * npx signal-sdk connect "My Custom Device"
17
+ */
18
+
19
+ const { SignalCli } = require('../dist/SignalCli');
20
+
21
+ async function connectDevice() {
22
+ console.log('Signal SDK - Device Connection');
23
+ console.log('==================================\n');
24
+
25
+ // Get device name from command line arguments
26
+ const deviceName = process.argv[2] || 'Signal SDK Device';
27
+
28
+ console.log(`Device name: ${deviceName}`);
29
+ console.log('Generating QR code for device linking...\n');
30
+
31
+ // Initialize the SDK without an account (for linking)
32
+ const signalCli = new SignalCli();
33
+
34
+ try {
35
+ // Start device linking with QR code output to console
36
+ const linkingResult = await signalCli.deviceLink({
37
+ name: deviceName,
38
+ qrCodeOutput: 'console'
39
+ });
40
+
41
+ if (linkingResult.success) {
42
+ if (linkingResult.isLinked) {
43
+ console.log('Device successfully linked!');
44
+ console.log(`Device name: ${linkingResult.deviceName}`);
45
+ console.log('\nYou can now use this device to send and receive Signal messages.');
46
+ console.log('\nNext steps:');
47
+ console.log(' 1. Import SignalCli in your Node.js project');
48
+ console.log(' 2. Initialize with your phone number');
49
+ console.log(' 3. Start sending and receiving messages');
50
+ console.log('\nExample usage:');
51
+ console.log(' const { SignalCli } = require("signal-sdk");');
52
+ console.log(' const signalCli = new SignalCli("+YourPhoneNumber");');
53
+ console.log(' await signalCli.connect();');
54
+ } else {
55
+ console.log('QR code generated successfully!');
56
+ console.log('Scan the QR code above with your Signal app to link this device.');
57
+ console.log('\nInstructions:');
58
+ console.log(' 1. Open Signal on your phone');
59
+ console.log(' 2. Go to Settings > Linked devices');
60
+ console.log(' 3. Tap "Link new device"');
61
+ console.log(' 4. Scan the QR code displayed above');
62
+ console.log('\nWaiting for device linking...');
63
+ console.log(' (This process may take a few moments)');
64
+ }
65
+ } else {
66
+ console.error('Device linking failed');
67
+ if (linkingResult.error) {
68
+ console.error(` Error: ${linkingResult.error}`);
69
+ }
70
+ console.error('\nTroubleshooting:');
71
+ console.error(' • Make sure signal-cli is properly installed');
72
+ console.error(' • Check your internet connection');
73
+ console.error(' • Ensure your Signal app is up to date');
74
+ console.error(' • Try running the command again');
75
+ process.exit(1);
76
+ }
77
+ } catch (error) {
78
+ console.error('Fatal error during device linking:', error.message);
79
+ console.error('\nCommon solutions:');
80
+ console.error(' • Install signal-cli: https://github.com/AsamK/signal-cli');
81
+ console.error(' • Make sure Java is installed and accessible');
82
+ console.error(' • Check that signal-cli is in your PATH');
83
+ console.error(' • Verify your internet connection');
84
+ process.exit(1);
85
+ }
86
+ }
87
+
88
+ // Handle graceful shutdown
89
+ process.on('SIGINT', () => {
90
+ console.log('\n\nDevice linking cancelled by user.');
91
+ process.exit(0);
92
+ });
93
+
94
+ process.on('SIGTERM', () => {
95
+ console.log('\n\nDevice linking terminated.');
96
+ process.exit(0);
97
+ });
98
+
99
+ // Display help if requested
100
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
101
+ console.log('Signal SDK - Device Connection Script');
102
+ console.log('=====================================\n');
103
+ console.log('Usage:');
104
+ console.log(' node scripts/connect.js [device-name]');
105
+ console.log(' npx signal-sdk connect [device-name]\n');
106
+ console.log('Arguments:');
107
+ console.log(' device-name Optional name for the linked device (default: "Signal SDK Device")\n');
108
+ console.log('Examples:');
109
+ console.log(' node scripts/connect.js');
110
+ console.log(' node scripts/connect.js "My Bot Device"');
111
+ console.log(' npx signal-sdk connect');
112
+ console.log(' npx signal-sdk connect "My Custom Device"\n');
113
+ console.log('This script generates a QR code that you can scan with your Signal app');
114
+ console.log('to link a new device for use with the Signal SDK.');
115
+ process.exit(0);
116
+ }
117
+
118
+ // Run the connection process
119
+ connectDevice();
@@ -1,9 +1,9 @@
1
1
  const axios = require('axios');
2
- const tar = require('tar');
3
2
  const fs = require('fs');
4
3
  const path = require('path');
4
+ const { execSync } = require('child_process');
5
5
 
6
- const VERSION = '0.13.17';
6
+ const VERSION = '0.13.18';
7
7
  const BASE_URL = `https://github.com/AsamK/signal-cli/releases/download/v${VERSION}`;
8
8
 
9
9
  const platform = process.platform;
@@ -21,7 +21,7 @@ async function install() {
21
21
  const response = await axios({
22
22
  url,
23
23
  method: 'GET',
24
- responseType: 'stream'
24
+ responseType: 'arraybuffer'
25
25
  });
26
26
 
27
27
  const binDir = path.join(__dirname, '..', 'bin');
@@ -29,13 +29,26 @@ async function install() {
29
29
  fs.mkdirSync(binDir, { recursive: true });
30
30
  }
31
31
 
32
- response.data.pipe(tar.x({ C: binDir, strip: 1 }));
32
+ // Write tar file temporarily
33
+ const tempFile = path.join(binDir, 'signal-cli.tar.gz');
34
+ fs.writeFileSync(tempFile, response.data);
35
+
36
+ // Extract using system tar command
37
+ try {
38
+ execSync(`tar -xzf "${tempFile}" -C "${binDir}"`, { stdio: 'inherit' });
39
+ } catch (error) {
40
+ console.error('Failed to extract archive:', error.message);
41
+ throw error;
42
+ }
43
+
44
+ // Remove temp file
45
+ fs.unlinkSync(tempFile);
33
46
 
34
47
  console.log('signal-cli downloaded and extracted successfully.');
35
48
 
36
49
  // Set executable permissions on Unix/Linux systems
37
50
  if (platform !== 'win32') {
38
- const signalCliExecutable = path.join(binDir, 'bin', 'signal-cli');
51
+ const signalCliExecutable = path.join(binDir, 'signal-cli');
39
52
  if (fs.existsSync(signalCliExecutable)) {
40
53
  try {
41
54
  fs.chmodSync(signalCliExecutable, '755');
@@ -48,13 +61,13 @@ async function install() {
48
61
 
49
62
  if (platform === 'win32') {
50
63
  console.log('Windows detected. Make sure you have Java installed and signal-cli.bat is executable.');
51
- console.log('signal-cli.bat is located at: ' + path.join(binDir, 'bin', 'signal-cli.bat'));
64
+ console.log('signal-cli.bat is located at: ' + path.join(binDir, 'signal-cli.bat'));
52
65
  } else if (platform === 'linux') {
53
66
  console.log('Linux detected. signal-cli executable is ready.');
54
- console.log('signal-cli is located at: ' + path.join(binDir, 'bin', 'signal-cli'));
67
+ console.log('signal-cli is located at: ' + path.join(binDir, 'signal-cli'));
55
68
  } else {
56
69
  console.log('Please ensure you have Java installed on your system for signal-cli to work.');
57
- console.log('signal-cli is located at: ' + path.join(binDir, 'bin', 'signal-cli'));
70
+ console.log('signal-cli is located at: ' + path.join(binDir, 'signal-cli'));
58
71
  }
59
72
  }
60
73
 
@@ -1 +0,0 @@
1
- export {};