signal-sdk 0.0.2 → 0.0.4

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
@@ -1,478 +1,494 @@
1
- # Signal CLI SDK - TypeScript Wrapper for Signal CLI
2
-
3
- A comprehensive TypeScript SDK for interacting with [signal-cli](https://github.com/AsamK/signal-cli), providing JSON-RPC communication and a powerful bot framework.
4
-
5
- [![npm version](https://badge.fury.io/js/signal-sdk.svg)](https://badge.fury.io/js/signal-sdk)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
- [![signal-cli](https://img.shields.io/badge/signal--cli-v0.13.17-blue.svg)](https://github.com/AsamK/signal-cli)
8
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.8+-blue.svg)](https://www.typescriptlang.org/)
9
- [![Node.js](https://img.shields.io/badge/Node.js-16+-green.svg)](https://nodejs.org/)
10
-
11
- ## Features
12
-
13
- ### Core Capabilities
14
-
15
- - **JSON-RPC Communication** - Direct communication with signal-cli daemon via JSON-RPC
16
- - **TypeScript Support** - Complete type definitions with full IntelliSense support
17
- - **Message Management** - Send, receive, and manage Signal messages
18
- - **Real-time Events** - Listen to incoming messages and notifications
19
- - **Production Ready** - Robust error handling and connection management
20
-
21
- ### SignalBot Framework
22
-
23
- - **Simple Bot Creation** - Create powerful bots with minimal setup
24
- - **Command System** - Built-in command parsing and routing
25
- - **Event Handling** - React to messages, group events, and user actions
26
- - **Admin Controls** - Role-based permissions and access control
27
- - **Group Management** - Automated group creation and member management
28
- - **Extensible** - Plugin-style architecture for custom functionality
29
-
30
- ### Advanced Features
31
-
32
- - **File Attachments** - Send and receive files, images, and media
33
- - **Group Operations** - Create, manage, and configure groups
34
- - **Contact Management** - Add, update, remove, and manage contacts
35
- - **Message Reactions** - React to messages with emoji reactions
36
- - **Typing Indicators** - Send and receive typing notifications
37
- - **Read Receipts** - Track message delivery and read status
38
- - **Profile Management** - Update profile information and avatars
39
- - **Payment Notifications** - Send payment receipts and notifications
40
- - **Custom Sticker Packs** - Upload and manage custom sticker packs
41
- - **User Status Checking** - Verify Signal registration status
42
- - **Rate Limit Recovery** - Handle and recover from rate limiting
43
- - **Phone Number Changes** - Change registered phone numbers
44
- - **Progress Tracking** - Monitor upload progress for large files
45
-
46
- ## Quick Start
47
-
48
- ### Installation
49
-
50
- ```bash
51
- npm install
52
- ```
53
-
54
- ### Prerequisites
55
-
56
- 1. **Node.js** (version 16 or later)
57
- 2. **Java Runtime Environment** (required by signal-cli)
58
- 3. **signal-cli** - Download and setup instructions available in [installation guide](./docs/installation.md)
59
-
60
- [Detailed installation guide](./docs/installation.md)
61
-
62
- ### Device Linking
63
-
64
- Before using the SDK, you need to link a device to your Signal account:
65
-
66
- ```bash
67
- # Using npx (recommended)
68
- npx signal-sdk connect
69
-
70
- # Or with a custom device name
71
- npx signal-sdk connect "My Bot Device"
72
-
73
- # Or using npm script after installation
74
- cd node_modules/signal-sdk
75
- npm run connect
76
- ```
77
-
78
- This command will:
79
- 1. šŸ”— Generate a QR code in your terminal
80
- 2. šŸ“± Display instructions for scanning with your Signal app
81
- 3. āœ… Complete the device linking process
82
-
83
- **Note:** You only need to do this once per device. After linking, your device will be permanently connected to your Signal account.
84
-
85
- ### Basic Usage
86
-
87
- ```javascript
88
- const { SignalCli } = require("signal-sdk");
89
-
90
- // Initialize SignalCli with phone number
91
- const signal = new SignalCli(undefined, "+1234567890");
92
-
93
- // Connect to signal-cli daemon
94
- await signal.connect();
95
-
96
- // Send a message
97
- await signal.sendMessage("+0987654321", "Hello from Signal CLI SDK!");
98
-
99
- // Listen for incoming messages
100
- signal.on("message", (message) => {
101
- console.log("Received message:", message.envelope.dataMessage.message);
102
- });
103
-
104
- // Graceful shutdown
105
- await signal.gracefulShutdown();
106
- ```
107
-
108
- ### Create a Bot
109
-
110
- ```javascript
111
- const { SignalBot } = require("signal-sdk");
112
-
113
- // Initialize bot with configuration
114
- const bot = new SignalBot({
115
- phoneNumber: "+1234567890",
116
- admins: ["+0987654321"],
117
- group: {
118
- name: "My Bot Group",
119
- description: "A group managed by my bot",
120
- createIfNotExists: true,
121
- },
122
- });
123
-
124
- // Add custom commands
125
- bot.addCommand({
126
- name: "hello",
127
- description: "Greet the user",
128
- handler: async (message, args) => {
129
- const name = args.join(" ") || "friend";
130
- return `Hello ${name}! How can I help you today?`;
131
- },
132
- });
133
-
134
- // Handle events
135
- bot.on("ready", () => {
136
- console.log("Bot is ready and listening for messages!");
137
- });
138
-
139
- bot.on("message", (message) => {
140
- console.log(`Received: ${message.text} from ${message.sender}`);
141
- });
142
-
143
- // Start the bot
144
- await bot.start();
145
- ```
146
-
147
- Your bot will automatically:
148
-
149
- - Handle command parsing (default prefix: `/`)
150
- - Provide built-in commands (`/help`, `/ping`)
151
- - Manage group creation and membership
152
- - Enforce admin permissions
153
- - Handle errors gracefully
154
-
155
- ## Documentation
156
-
157
- ### Getting Started
158
-
159
- - [Installation & Setup](./docs/installation.md)
160
- - [Getting Started Guide](./docs/getting-started.md)
161
- - [Device Linking](./docs/device-linking.md)
162
-
163
- ### API Reference
164
-
165
- - [SignalCli Class](./docs/api-reference.md#signalcli)
166
- - [SignalBot Class](./docs/api-reference.md#signalbot)
167
- - [TypeScript Interfaces](./docs/api-reference.md#interfaces)
168
-
169
- ### Examples
170
-
171
- - [Device Linking](./examples/sdk/00-device-linking.js) - Link your device to Signal
172
- - [Basic SDK Usage](./examples/sdk/01-basic-usage.js) - Simple message sending
173
- - [Quick Start](./examples/sdk/02-quick-start.js) - Complete getting started example
174
- - [Group Management](./examples/sdk/03-group-management.js) - Create and manage groups
175
- - [Contact Management](./examples/sdk/04-contact-management.js) - Handle contacts
176
- - [File Handling](./examples/sdk/05-file-handling.js) - Send and receive files
177
- - [Minimal Bot](./examples/bot/01-minimal-bot.js) - Simple bot implementation
178
- - [Advanced Bot](./examples/bot/02-advanced-bot.js) - Full-featured bot example
179
-
180
- ### Advanced Topics
181
-
182
- - [Advanced Features](./docs/advanced-features.md)
183
- - [SignalBot Framework](./docs/signalbot-framework.md)
184
- - [Feature Coverage Analysis](./FEATURE_COVERAGE.md)
185
- - [Implementation Plan](./IMPLEMENTATION_PLAN.md)
186
- - [FAQ](./docs/faq.md)
187
- - [Troubleshooting](./docs/troubleshooting.md)
188
-
189
- ## Common Use Cases
190
-
191
- ### Send Messages
192
-
193
- ```javascript
194
- const { SignalCli } = require("signal-sdk");
195
- const signal = new SignalCli(undefined, "+1234567890");
196
-
197
- await signal.connect();
198
- await signal.sendMessage("+0987654321", "Hello World!");
199
- await signal.gracefulShutdown();
200
- ```
201
-
202
- ### Send Files
203
-
204
- ```javascript
205
- // Send file with message
206
- await signal.sendMessage("+0987654321", "Here's the document:", {
207
- attachments: ["./path/to/document.pdf"],
208
- });
209
-
210
- // Send multiple files
211
- await signal.sendMessage("+0987654321", "Photos from today:", {
212
- attachments: ["./photo1.jpg", "./photo2.jpg"],
213
- });
214
- ```
215
-
216
- ### Group Management
217
-
218
- ```javascript
219
- // Create a new group
220
- const group = await signal.createGroup("My Group", [
221
- "+0987654321",
222
- "+1122334455",
223
- ]);
224
- console.log("Group ID:", group.groupId);
225
-
226
- // Send message to group
227
- await signal.sendMessage(group.groupId, "Welcome to the group!");
228
-
229
- // Update group info
230
- await signal.updateGroup(group.groupId, {
231
- title: "Updated Group Name",
232
- description: "This is our group chat",
233
- });
234
- ```
235
-
236
- ### Bot with Custom Commands
237
-
238
- ```javascript
239
- const { SignalBot } = require("signal-sdk");
240
-
241
- const bot = new SignalBot({
242
- phoneNumber: "+1234567890",
243
- admins: ["+0987654321"],
244
- });
245
-
246
- // Add weather command
247
- bot.addCommand({
248
- name: "weather",
249
- description: "Get weather information",
250
- handler: async (message, args) => {
251
- const city = args.join(" ") || "New York";
252
- // Integrate with weather API
253
- return `Weather in ${city}: 22°C, sunny`;
254
- },
255
- });
256
-
257
- // Add custom event handler
258
- bot.on("groupMemberJoined", async (event) => {
259
- await bot.sendMessage(event.groupId, `Welcome ${event.member.name}!`);
260
- });
261
-
262
- await bot.start();
263
- ```
264
-
265
- ## Testing
266
-
267
- ```bash
268
- # Run all tests
269
- npm test
270
-
271
- # Run specific test suite
272
- npm test -- --testNamePattern="SignalCli"
273
-
274
- # Run with coverage
275
- npm run test:coverage
276
- ```
277
-
278
- ## Development
279
-
280
- ```bash
281
- # Clone the repository
282
- git clone https://github.com/your-username/signal-cli-sdk.git
283
- cd signal-cli-sdk
284
-
285
- # Install dependencies
286
- npm install
287
-
288
- # Build the project
289
- npm run build
290
-
291
- # Run examples
292
- npm run build && node examples/sdk/01-basic-usage.js
293
-
294
- # Run tests
295
- npm test
296
- ```
297
-
298
- ## Configuration
299
-
300
- ### Environment Variables
301
-
302
- Create a `.env` file in your project root:
303
-
304
- ```env
305
- SIGNAL_PHONE_NUMBER="+1234567890"
306
- SIGNAL_ADMIN_NUMBER="+0987654321"
307
- SIGNAL_RECIPIENT_NUMBER="+1122334455"
308
- SIGNAL_GROUP_NAME="My Bot Group"
309
- ```
310
-
311
- ### SignalCli Configuration
312
-
313
- ```javascript
314
- const { SignalCli } = require("signal-sdk");
315
-
316
- // Basic configuration
317
- const signal = new SignalCli(configPath, phoneNumber);
318
- // configPath: Path to signal-cli config directory (optional)
319
- // phoneNumber: Your registered Signal phone number (required)
320
-
321
- // Example with custom config path
322
- const signal = new SignalCli("/custom/signal-cli/config", "+1234567890");
323
- ```
324
-
325
- ### SignalBot Configuration
326
-
327
- ```javascript
328
- const { SignalBot } = require("signal-sdk");
329
-
330
- const bot = new SignalBot({
331
- phoneNumber: "+1234567890", // Required: Your Signal phone number
332
- admins: ["+0987654321"], // Required: Admin phone numbers
333
- group: {
334
- name: "My Bot Group", // Group name
335
- description: "Managed by my bot", // Group description
336
- createIfNotExists: true, // Create group if it doesn't exist
337
- avatar: "./group-avatar.jpg", // Group avatar image
338
- },
339
- settings: {
340
- commandPrefix: "/", // Command prefix (default: "/")
341
- logMessages: true, // Log incoming messages (default: false)
342
- welcomeNewMembers: true, // Welcome message for new members
343
- cooldownSeconds: 2, // Command cooldown in seconds
344
- },
345
- });
346
- ```
347
-
348
- ## Troubleshooting
349
-
350
- ### Common Issues
351
-
352
- 1. **signal-cli not found**
353
-
354
- ```bash
355
- # Make sure signal-cli is installed and in your PATH
356
- # Download from: https://github.com/AsamK/signal-cli/releases
357
- signal-cli --version
358
- ```
359
-
360
- 2. **Java not installed**
361
-
362
- ```bash
363
- # Install Java (required by signal-cli)
364
- # Ubuntu/Debian
365
- sudo apt update && sudo apt install default-jre
366
-
367
- # macOS with Homebrew
368
- brew install openjdk
369
-
370
- # Windows: Download from Oracle or use package manager
371
- ```
372
-
373
- 3. **Phone number not registered**
374
-
375
- ```bash
376
- # Register your phone number with Signal first
377
- signal-cli -a +1234567890 register
378
- signal-cli -a +1234567890 verify CODE_FROM_SMS
379
- ```
380
-
381
- 4. **Connection timeout**
382
-
383
- ```bash
384
- # Test signal-cli directly
385
- signal-cli -a +1234567890 send +0987654321 "Test message"
386
- ```
387
-
388
- 5. **Permission denied on config directory**
389
- ```bash
390
- # Fix permissions on signal-cli config directory
391
- chmod -R 755 ~/.local/share/signal-cli/
392
- ```
393
-
394
- [Complete troubleshooting guide](./docs/troubleshooting.md)
395
-
396
- ## Contributing
397
-
398
- We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
399
-
400
- 1. Fork the repository
401
- 2. Create a feature branch
402
- 3. Make your changes
403
- 4. Add tests
404
- 5. Submit a pull request
405
-
406
- ## License
407
-
408
- This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
409
-
410
- ## Acknowledgments
411
-
412
- - [signal-cli](https://github.com/AsamK/signal-cli) - The underlying Signal CLI client
413
- - [Signal Protocol](https://signal.org/docs/) - The Signal messaging protocol
414
- - The Signal community for their excellent work
415
-
416
- ## Support
417
-
418
- - **Documentation**: [docs/](./docs/)
419
- - **Examples**: [examples/](./examples/)
420
- - **Issues**: Report bugs and request features
421
- - **Contributing**: See [CONTRIBUTING.md](./CONTRIBUTING.md)
422
-
423
- ---
424
-
425
- **Built with TypeScript for the Signal community**
426
-
427
- ---
428
-
429
- ## Development Status
430
-
431
- ### Current Coverage: 39/39 signal-cli commands (100%) āœ…
432
-
433
- The SDK now provides **complete feature parity** with signal-cli, implementing all available commands and functionality.
434
-
435
- **Latest Updates:**
436
-
437
- - āœ… **Contact Management**: Complete removal with options (hide/forget)
438
- - āœ… **User Status**: Check Signal registration status
439
- - āœ… **Payment Notifications**: Send payment receipts and notes
440
- - āœ… **Custom Stickers**: Upload and manage sticker packs
441
- - āœ… **Rate Limit Recovery**: Handle rate limiting with captcha challenges
442
- - āœ… **Phone Number Changes**: Change registered phone numbers
443
- - āœ… **Enhanced Messaging**: Progress tracking for large file uploads
444
-
445
- [**View Complete Feature Coverage Analysis →**](./FEATURE_COVERAGE.md)
446
- [**View Implementation Details →**](./IMPLEMENTATION_PLAN.md)
447
-
448
- ---
449
-
450
- ## API Methods
451
-
452
- Compatible with signal-cli v0.13.17 - **100% Feature Coverage**
453
-
454
- | Category | Method | Description | Status |
455
- | ------------- | -------------------------- | ---------------------------------- | ------ |
456
- | **Messaging** | `send` | Send text messages and attachments | āœ… |
457
- | | `sendReaction` | React to messages with emoji | āœ… |
458
- | | `sendTyping` | Send typing indicators | āœ… |
459
- | | `sendReceipt` | Send read receipts | āœ… |
460
- | | `sendPaymentNotification` | Send payment notifications | āœ… |
461
- | **Groups** | `createGroup` | Create new groups | āœ… |
462
- | | `updateGroup` | Update group settings | āœ… |
463
- | | `listGroups` | List all groups | āœ… |
464
- | | `quitGroup` | Leave a group | āœ… |
465
- | **Contacts** | `listContacts` | List all contacts | āœ… |
466
- | | `updateContact` | Update contact information | āœ… |
467
- | | `removeContact` | Remove contacts with options | āœ… |
468
- | | `block` / `unblock` | Block/unblock contacts | āœ… |
469
- | | `getUserStatus` | Check registration status | āœ… |
470
- | **Stickers** | `listStickerPacks` | List sticker packs | āœ… |
471
- | | `addStickerPack` | Install sticker packs | āœ… |
472
- | | `uploadStickerPack` | Upload custom sticker packs | āœ… |
473
- | **Advanced** | `submitRateLimitChallenge` | Handle rate limiting | āœ… |
474
- | | `startChangeNumber` | Start phone number change | āœ… |
475
- | | `finishChangeNumber` | Complete phone number change | āœ… |
476
- | | `sendMessageWithProgress` | Enhanced messaging with progress | āœ… |
477
-
478
- [Complete API documentation](./docs/api-reference.md)
1
+ # Signal SDK - TypeScript SDK for Signal Messenger
2
+
3
+ A comprehensive TypeScript SDK for interacting with [signal-cli](https://github.com/AsamK/signal-cli), providing JSON-RPC communication and a powerful bot framework.
4
+
5
+ [![npm version](https://badge.fury.io/js/signal-sdk.svg)](https://badge.fury.io/js/signal-sdk)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+ [![signal-cli](https://img.shields.io/badge/signal--cli-v0.13.17-blue.svg)](https://github.com/AsamK/signal-cli)
8
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.8+-blue.svg)](https://www.typescriptlang.org/)
9
+ [![Node.js](https://img.shields.io/badge/Node.js-16+-green.svg)](https://nodejs.org/)
10
+
11
+ ## Features
12
+
13
+ ### Core Capabilities
14
+
15
+ - **JSON-RPC Communication** - Direct communication with signal-cli daemon via JSON-RPC
16
+ - **TypeScript Support** - Complete type definitions with full IntelliSense support
17
+ - **Message Management** - Send, receive, and manage Signal messages
18
+ - **Real-time Events** - Listen to incoming messages and notifications
19
+ - **Production Ready** - Robust error handling and connection management
20
+
21
+ ### SignalBot Framework
22
+
23
+ - **Simple Bot Creation** - Create powerful bots with minimal setup
24
+ - **Command System** - Built-in command parsing and routing
25
+ - **Event Handling** - React to messages, group events, and user actions
26
+ - **Admin Controls** - Role-based permissions and access control
27
+ - **Group Management** - Automated group creation and member management
28
+ - **Extensible** - Plugin-style architecture for custom functionality
29
+
30
+ ### Advanced Features
31
+
32
+ - **File Attachments** - Send and receive files, images, and media
33
+ - **Group Operations** - Create, manage, and configure groups
34
+ - **Contact Management** - Add, update, remove, and manage contacts
35
+ - **Message Reactions** - React to messages with emoji reactions
36
+ - **Typing Indicators** - Send and receive typing notifications
37
+ - **Read Receipts** - Track message delivery and read status
38
+ - **Profile Management** - Update profile information and avatars
39
+ - **Payment Notifications** - Send payment receipts and notifications
40
+ - **Custom Sticker Packs** - Upload and manage custom sticker packs
41
+ - **User Status Checking** - Verify Signal registration status
42
+ - **Rate Limit Recovery** - Handle and recover from rate limiting
43
+ - **Phone Number Changes** - Change registered phone numbers
44
+ - **Progress Tracking** - Monitor upload progress for large files
45
+
46
+ ## Quick Start
47
+
48
+ ### Installation
49
+
50
+ ```bash
51
+ npm install signal-sdk
52
+ ```
53
+
54
+ ### Prerequisites
55
+
56
+ 1. **Node.js** (version 16 or later)
57
+ 2. **Java Runtime Environment** (required by signal-cli)
58
+
59
+ **Note:** signal-cli binaries are included with the SDK - no separate installation required.
60
+
61
+ [Detailed installation guide](./docs/installation.md)
62
+
63
+ ### CLI Commands
64
+
65
+ The SDK includes a command-line interface for common operations:
66
+
67
+ ```bash
68
+ # View all available commands
69
+ npx signal-sdk --help
70
+
71
+ # Link a new device to your Signal account
72
+ npx signal-sdk connect
73
+
74
+ # Link with a custom device name
75
+ npx signal-sdk connect "My Custom Device Name"
76
+ ```
77
+
78
+ ### Device Linking
79
+
80
+ Before using the SDK, you need to link a device to your Signal account:
81
+
82
+ ```bash
83
+ # Using npx (recommended)
84
+ npx signal-sdk connect
85
+
86
+ # Or with a custom device name
87
+ npx signal-sdk connect "My Bot Device"
88
+
89
+ # Get help for the CLI
90
+ npx signal-sdk --help
91
+ ```
92
+
93
+ This command will:
94
+
95
+ 1. Generate a QR code in your terminal
96
+ 2. Display instructions for scanning with your Signal app
97
+ 3. Complete the device linking process
98
+
99
+ **Note:** You only need to do this once per device. After linking, your device will be permanently connected to your Signal account.
100
+
101
+ ### Basic Usage
102
+
103
+ ```javascript
104
+ const { SignalCli } = require("signal-sdk");
105
+
106
+ // Initialize SignalCli with phone number
107
+ const signal = new SignalCli("+1234567890");
108
+
109
+ // Connect to signal-cli daemon
110
+ await signal.connect();
111
+
112
+ // Send a message
113
+ await signal.sendMessage("+0987654321", "Hello from Signal CLI SDK!");
114
+
115
+ // Listen for incoming messages
116
+ signal.on("message", (message) => {
117
+ console.log("Received message:", message.envelope.dataMessage.message);
118
+ });
119
+
120
+ // Graceful shutdown
121
+ await signal.gracefulShutdown();
122
+ ```
123
+
124
+ ### Create a Bot
125
+
126
+ ```javascript
127
+ const { SignalBot } = require("signal-sdk");
128
+
129
+ // Initialize bot with configuration
130
+ const bot = new SignalBot({
131
+ phoneNumber: "+1234567890",
132
+ admins: ["+0987654321"],
133
+ group: {
134
+ name: "My Bot Group",
135
+ description: "A group managed by my bot",
136
+ createIfNotExists: true,
137
+ },
138
+ });
139
+
140
+ // Add custom commands
141
+ bot.addCommand({
142
+ name: "hello",
143
+ description: "Greet the user",
144
+ handler: async (message, args) => {
145
+ const name = args.join(" ") || "friend";
146
+ return `Hello ${name}! How can I help you today?`;
147
+ },
148
+ });
149
+
150
+ // Handle events
151
+ bot.on("ready", () => {
152
+ console.log("Bot is ready and listening for messages!");
153
+ });
154
+
155
+ bot.on("message", (message) => {
156
+ console.log(`Received: ${message.text} from ${message.sender}`);
157
+ });
158
+
159
+ // Start the bot
160
+ await bot.start();
161
+ ```
162
+
163
+ Your bot will automatically:
164
+
165
+ - Handle command parsing (default prefix: `/`)
166
+ - Provide built-in commands (`/help`, `/ping`)
167
+ - Manage group creation and membership
168
+ - Enforce admin permissions
169
+ - Handle errors gracefully
170
+
171
+ ## Documentation
172
+
173
+ ### Getting Started
174
+
175
+ - [Installation & Setup](./docs/installation.md)
176
+ - [Getting Started Guide](./docs/getting-started.md)
177
+ - [Device Linking](./docs/device-linking.md)
178
+
179
+ ### API Reference
180
+
181
+ - [SignalCli Class](./docs/api-reference.md#signalcli)
182
+ - [SignalBot Class](./docs/api-reference.md#signalbot)
183
+ - [TypeScript Interfaces](./docs/api-reference.md#interfaces)
184
+
185
+ ### Examples
186
+
187
+ - [Device Linking](./examples/sdk/00-device-linking.js) - Link your device to Signal
188
+ - [Basic SDK Usage](./examples/sdk/01-basic-usage.js) - Simple message sending
189
+ - [Quick Start](./examples/sdk/02-quick-start.js) - Complete getting started example
190
+ - [Group Management](./examples/sdk/03-group-management.js) - Create and manage groups
191
+ - [Contact Management](./examples/sdk/04-contact-management.js) - Handle contacts
192
+ - [File Handling](./examples/sdk/05-file-handling.js) - Send and receive files
193
+ - [Minimal Bot](./examples/bot/01-minimal-bot.js) - Simple bot implementation
194
+ - [Advanced Bot](./examples/bot/02-advanced-bot.js) - Full-featured bot example
195
+
196
+ ### Advanced Topics
197
+
198
+ - [Advanced Features](./docs/advanced-features.md)
199
+ - [SignalBot Framework](./docs/signalbot-framework.md)
200
+ - [Feature Coverage Analysis](./FEATURE_COVERAGE.md)
201
+ - [Implementation Plan](./IMPLEMENTATION_PLAN.md)
202
+ - [FAQ](./docs/faq.md)
203
+ - [Troubleshooting](./docs/troubleshooting.md)
204
+
205
+ ## Common Use Cases
206
+
207
+ ### Send Messages
208
+
209
+ ```javascript
210
+ const { SignalCli } = require("signal-sdk");
211
+ const signal = new SignalCli("+1234567890");
212
+
213
+ await signal.connect();
214
+ await signal.sendMessage("+0987654321", "Hello World!");
215
+ await signal.gracefulShutdown();
216
+ ```
217
+
218
+ ### Send Files
219
+
220
+ ```javascript
221
+ // Send file with message
222
+ await signal.sendMessage("+0987654321", "Here's the document:", {
223
+ attachments: ["./path/to/document.pdf"],
224
+ });
225
+
226
+ // Send multiple files
227
+ await signal.sendMessage("+0987654321", "Photos from today:", {
228
+ attachments: ["./photo1.jpg", "./photo2.jpg"],
229
+ });
230
+ ```
231
+
232
+ ### Group Management
233
+
234
+ ```javascript
235
+ // Create a new group
236
+ const group = await signal.createGroup("My Group", [
237
+ "+0987654321",
238
+ "+1122334455",
239
+ ]);
240
+ console.log("Group ID:", group.groupId);
241
+
242
+ // Send message to group
243
+ await signal.sendMessage(group.groupId, "Welcome to the group!");
244
+
245
+ // Update group info
246
+ await signal.updateGroup(group.groupId, {
247
+ title: "Updated Group Name",
248
+ description: "This is our group chat",
249
+ });
250
+ ```
251
+
252
+ ### Bot with Custom Commands
253
+
254
+ ```javascript
255
+ const { SignalBot } = require("signal-sdk");
256
+
257
+ const bot = new SignalBot({
258
+ phoneNumber: "+1234567890",
259
+ admins: ["+0987654321"],
260
+ });
261
+
262
+ // Add weather command
263
+ bot.addCommand({
264
+ name: "weather",
265
+ description: "Get weather information",
266
+ handler: async (message, args) => {
267
+ const city = args.join(" ") || "New York";
268
+ // Integrate with weather API
269
+ return `Weather in ${city}: 22°C, sunny`;
270
+ },
271
+ });
272
+
273
+ // Add custom event handler
274
+ bot.on("groupMemberJoined", async (event) => {
275
+ await bot.sendMessage(event.groupId, `Welcome ${event.member.name}!`);
276
+ });
277
+
278
+ await bot.start();
279
+ ```
280
+
281
+ ## Testing
282
+
283
+ ```bash
284
+ # Run all tests
285
+ npm test
286
+
287
+ # Run specific test suite
288
+ npm test -- --testNamePattern="SignalCli"
289
+
290
+ # Run with coverage
291
+ npm run test:coverage
292
+ ```
293
+
294
+ ## Development
295
+
296
+ ```bash
297
+ # Clone the repository
298
+ git clone https://github.com/your-username/signal-cli-sdk.git
299
+ cd signal-cli-sdk
300
+
301
+ # Install dependencies
302
+ npm install
303
+
304
+ # Build the project
305
+ npm run build
306
+
307
+ # Run examples
308
+ npm run build && node examples/sdk/01-basic-usage.js
309
+
310
+ # Run tests
311
+ npm test
312
+ ```
313
+
314
+ ## Configuration
315
+
316
+ ### Environment Variables
317
+
318
+ Create a `.env` file in your project root:
319
+
320
+ ```env
321
+ SIGNAL_PHONE_NUMBER="+1234567890"
322
+ SIGNAL_ADMIN_NUMBER="+0987654321"
323
+ SIGNAL_RECIPIENT_NUMBER="+1122334455"
324
+ SIGNAL_GROUP_NAME="My Bot Group"
325
+ ```
326
+
327
+ ### SignalCli Configuration
328
+
329
+ ```javascript
330
+ const { SignalCli } = require("signal-sdk");
331
+
332
+ // Basic configuration
333
+ const signal = new SignalCli(configPath, phoneNumber);
334
+ // configPath: Path to signal-cli config directory (optional)
335
+ // phoneNumber: Your registered Signal phone number (required)
336
+
337
+ // Example with custom config path
338
+ const signal = new SignalCli("/custom/signal-cli/config", "+1234567890");
339
+ ```
340
+
341
+ ### SignalBot Configuration
342
+
343
+ ```javascript
344
+ const { SignalBot } = require("signal-sdk");
345
+
346
+ const bot = new SignalBot({
347
+ phoneNumber: "+1234567890", // Required: Your Signal phone number
348
+ admins: ["+0987654321"], // Required: Admin phone numbers
349
+ group: {
350
+ name: "My Bot Group", // Group name
351
+ description: "Managed by my bot", // Group description
352
+ createIfNotExists: true, // Create group if it doesn't exist
353
+ avatar: "./group-avatar.jpg", // Group avatar image
354
+ },
355
+ settings: {
356
+ commandPrefix: "/", // Command prefix (default: "/")
357
+ logMessages: true, // Log incoming messages (default: false)
358
+ welcomeNewMembers: true, // Welcome message for new members
359
+ cooldownSeconds: 2, // Command cooldown in seconds
360
+ },
361
+ });
362
+ ```
363
+
364
+ ## Troubleshooting
365
+
366
+ ### Common Issues
367
+
368
+ 1. **signal-cli not found**
369
+
370
+ ```bash
371
+ # Make sure signal-cli is installed and in your PATH
372
+ # Download from: https://github.com/AsamK/signal-cli/releases
373
+ signal-cli --version
374
+ ```
375
+
376
+ 2. **Java not installed**
377
+
378
+ ```bash
379
+ # Install Java (required by signal-cli)
380
+ # Ubuntu/Debian
381
+ sudo apt update && sudo apt install default-jre
382
+
383
+ # macOS with Homebrew
384
+ brew install openjdk
385
+
386
+ # Windows: Download from Oracle or use package manager
387
+ ```
388
+
389
+ 3. **Phone number not registered**
390
+
391
+ ```bash
392
+ # Register your phone number with Signal first
393
+ signal-cli -a +1234567890 register
394
+ signal-cli -a +1234567890 verify CODE_FROM_SMS
395
+ ```
396
+
397
+ 4. **Connection timeout**
398
+
399
+ ```bash
400
+ # Test signal-cli directly
401
+ signal-cli -a +1234567890 send +0987654321 "Test message"
402
+ ```
403
+
404
+ 5. **Permission denied on config directory**
405
+ ```bash
406
+ # Fix permissions on signal-cli config directory
407
+ chmod -R 755 ~/.local/share/signal-cli/
408
+ ```
409
+
410
+ [Complete troubleshooting guide](./docs/troubleshooting.md)
411
+
412
+ ## Contributing
413
+
414
+ We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
415
+
416
+ 1. Fork the repository
417
+ 2. Create a feature branch
418
+ 3. Make your changes
419
+ 4. Add tests
420
+ 5. Submit a pull request
421
+
422
+ ## License
423
+
424
+ This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
425
+
426
+ ## Acknowledgments
427
+
428
+ - [signal-cli](https://github.com/AsamK/signal-cli) - The underlying Signal CLI client
429
+ - [Signal Protocol](https://signal.org/docs/) - The Signal messaging protocol
430
+ - The Signal community for their excellent work
431
+
432
+ ## Support
433
+
434
+ - **Documentation**: [docs/](./docs/)
435
+ - **Examples**: [examples/](./examples/)
436
+ - **Issues**: Report bugs and request features
437
+ - **Contributing**: See [CONTRIBUTING.md](./CONTRIBUTING.md)
438
+
439
+ ---
440
+
441
+ **Built with TypeScript for the Signal community**
442
+
443
+ ---
444
+
445
+ ## Development Status
446
+
447
+ ### Current Coverage: 39/39 signal-cli commands (100%) āœ…
448
+
449
+ The SDK now provides **complete feature parity** with signal-cli, implementing all available commands and functionality.
450
+
451
+ **Latest Updates:**
452
+
453
+ - āœ… **Contact Management**: Complete removal with options (hide/forget)
454
+ - āœ… **User Status**: Check Signal registration status
455
+ - āœ… **Payment Notifications**: Send payment receipts and notes
456
+ - āœ… **Custom Stickers**: Upload and manage sticker packs
457
+ - āœ… **Rate Limit Recovery**: Handle rate limiting with captcha challenges
458
+ - āœ… **Phone Number Changes**: Change registered phone numbers
459
+ - āœ… **Enhanced Messaging**: Progress tracking for large file uploads
460
+
461
+ [**View Complete Feature Coverage Analysis →**](./FEATURE_COVERAGE.md)
462
+ [**View Implementation Details →**](./IMPLEMENTATION_PLAN.md)
463
+
464
+ ---
465
+
466
+ ## API Methods
467
+
468
+ Compatible with signal-cli v0.13.17 - **100% Feature Coverage**
469
+
470
+ | Category | Method | Description | Status |
471
+ | ------------- | -------------------------- | ---------------------------------- | ------ |
472
+ | **Messaging** | `send` | Send text messages and attachments | āœ… |
473
+ | | `sendReaction` | React to messages with emoji | āœ… |
474
+ | | `sendTyping` | Send typing indicators | āœ… |
475
+ | | `sendReceipt` | Send read receipts | āœ… |
476
+ | | `sendPaymentNotification` | Send payment notifications | āœ… |
477
+ | **Groups** | `createGroup` | Create new groups | āœ… |
478
+ | | `updateGroup` | Update group settings | āœ… |
479
+ | | `listGroups` | List all groups | āœ… |
480
+ | | `quitGroup` | Leave a group | āœ… |
481
+ | **Contacts** | `listContacts` | List all contacts | āœ… |
482
+ | | `updateContact` | Update contact information | āœ… |
483
+ | | `removeContact` | Remove contacts with options | āœ… |
484
+ | | `block` / `unblock` | Block/unblock contacts | āœ… |
485
+ | | `getUserStatus` | Check registration status | āœ… |
486
+ | **Stickers** | `listStickerPacks` | List sticker packs | āœ… |
487
+ | | `addStickerPack` | Install sticker packs | āœ… |
488
+ | | `uploadStickerPack` | Upload custom sticker packs | āœ… |
489
+ | **Advanced** | `submitRateLimitChallenge` | Handle rate limiting | āœ… |
490
+ | | `startChangeNumber` | Start phone number change | āœ… |
491
+ | | `finishChangeNumber` | Complete phone number change | āœ… |
492
+ | | `sendMessageWithProgress` | Enhanced messaging with progress | āœ… |
493
+
494
+ [Complete API documentation](./docs/api-reference.md)
@@ -5,7 +5,7 @@ export declare class SignalCli extends EventEmitter {
5
5
  private account?;
6
6
  private cliProcess;
7
7
  private requestPromises;
8
- constructor(signalCliPath?: string, account?: string);
8
+ constructor(accountOrPath?: string, account?: string);
9
9
  connect(): Promise<void>;
10
10
  disconnect(): void;
11
11
  gracefulShutdown(): Promise<void>;
package/dist/SignalCli.js CHANGED
@@ -40,10 +40,25 @@ const qrcodeTerminal = __importStar(require("qrcode-terminal"));
40
40
  const events_1 = require("events");
41
41
  const path = __importStar(require("path"));
42
42
  class SignalCli extends events_1.EventEmitter {
43
- constructor(signalCliPath, account) {
43
+ constructor(accountOrPath, account) {
44
44
  super();
45
45
  this.cliProcess = null;
46
46
  this.requestPromises = new Map();
47
+ let signalCliPath;
48
+ let phoneNumber;
49
+ // Smart parameter detection
50
+ if (typeof accountOrPath === 'string') {
51
+ if (accountOrPath.startsWith('+')) {
52
+ // First parameter is a phone number
53
+ phoneNumber = accountOrPath;
54
+ signalCliPath = undefined;
55
+ }
56
+ else {
57
+ // First parameter is a path, second is phone number
58
+ signalCliPath = accountOrPath;
59
+ phoneNumber = account;
60
+ }
61
+ }
47
62
  // Determine the correct signal-cli path based on platform
48
63
  let defaultPath;
49
64
  if (process.platform === 'win32') {
@@ -54,7 +69,7 @@ class SignalCli extends events_1.EventEmitter {
54
69
  defaultPath = path.join(__dirname, '..', 'bin', 'bin', 'signal-cli');
55
70
  }
56
71
  this.signalCliPath = signalCliPath || defaultPath;
57
- this.account = account;
72
+ this.account = phoneNumber;
58
73
  }
59
74
  async connect() {
60
75
  const args = this.account ? ['-a', this.account, 'jsonRpc'] : ['jsonRpc'];
package/package.json CHANGED
@@ -1,72 +1,72 @@
1
- {
2
- "name": "signal-sdk",
3
- "version": "0.0.2",
4
- "description": "A comprehensive TypeScript SDK for Signal CLI 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.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
+ }
72
72
  }
@@ -19,14 +19,14 @@
19
19
  const { SignalCli } = require('../dist/SignalCli');
20
20
 
21
21
  async function connectDevice() {
22
- console.log('šŸ”— Signal SDK - Device Connection');
22
+ console.log('Signal SDK - Device Connection');
23
23
  console.log('==================================\n');
24
24
 
25
25
  // Get device name from command line arguments
26
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');
27
+
28
+ console.log(`Device name: ${deviceName}`);
29
+ console.log('Generating QR code for device linking...\n');
30
30
 
31
31
  // Initialize the SDK without an account (for linking)
32
32
  const signalCli = new SignalCli();
@@ -40,34 +40,34 @@ async function connectDevice() {
40
40
 
41
41
  if (linkingResult.success) {
42
42
  if (linkingResult.isLinked) {
43
- console.log('āœ… Device successfully linked!');
44
- console.log(`šŸ“± Device name: ${linkingResult.deviceName}`);
45
- console.log('\nšŸŽ‰ You can now use this device to send and receive Signal messages.');
46
- console.log('\nšŸ’” Next steps:');
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
47
  console.log(' 1. Import SignalCli in your Node.js project');
48
48
  console.log(' 2. Initialize with your phone number');
49
49
  console.log(' 3. Start sending and receiving messages');
50
- console.log('\nšŸ“– Example usage:');
50
+ console.log('\nExample usage:');
51
51
  console.log(' const { SignalCli } = require("signal-sdk");');
52
- console.log(' const signalCli = new SignalCli(undefined, "+YourPhoneNumber");');
52
+ console.log(' const signalCli = new SignalCli("+YourPhoneNumber");');
53
53
  console.log(' await signalCli.connect();');
54
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('\nšŸ“ Instructions:');
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
58
  console.log(' 1. Open Signal on your phone');
59
59
  console.log(' 2. Go to Settings > Linked devices');
60
60
  console.log(' 3. Tap "Link new device"');
61
61
  console.log(' 4. Scan the QR code displayed above');
62
- console.log('\nā³ Waiting for device linking...');
62
+ console.log('\nWaiting for device linking...');
63
63
  console.log(' (This process may take a few moments)');
64
64
  }
65
65
  } else {
66
- console.error('āŒ Device linking failed');
66
+ console.error('Device linking failed');
67
67
  if (linkingResult.error) {
68
68
  console.error(` Error: ${linkingResult.error}`);
69
69
  }
70
- console.error('\nšŸ”§ Troubleshooting:');
70
+ console.error('\nTroubleshooting:');
71
71
  console.error(' • Make sure signal-cli is properly installed');
72
72
  console.error(' • Check your internet connection');
73
73
  console.error(' • Ensure your Signal app is up to date');
@@ -75,8 +75,8 @@ async function connectDevice() {
75
75
  process.exit(1);
76
76
  }
77
77
  } catch (error) {
78
- console.error('āŒ Fatal error during device linking:', error.message);
79
- console.error('\nšŸ”§ Common solutions:');
78
+ console.error('Fatal error during device linking:', error.message);
79
+ console.error('\nCommon solutions:');
80
80
  console.error(' • Install signal-cli: https://github.com/AsamK/signal-cli');
81
81
  console.error(' • Make sure Java is installed and accessible');
82
82
  console.error(' • Check that signal-cli is in your PATH');
@@ -87,12 +87,12 @@ async function connectDevice() {
87
87
 
88
88
  // Handle graceful shutdown
89
89
  process.on('SIGINT', () => {
90
- console.log('\n\nā¹ļø Device linking cancelled by user.');
90
+ console.log('\n\nDevice linking cancelled by user.');
91
91
  process.exit(0);
92
92
  });
93
93
 
94
94
  process.on('SIGTERM', () => {
95
- console.log('\n\nā¹ļø Device linking terminated.');
95
+ console.log('\n\nDevice linking terminated.');
96
96
  process.exit(0);
97
97
  });
98
98