signal-sdk 0.0.5 → 0.0.7

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