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 +494 -478
- package/dist/SignalCli.d.ts +1 -1
- package/dist/SignalCli.js +17 -2
- package/package.json +71 -71
- package/scripts/connect.js +20 -20
package/README.md
CHANGED
|
@@ -1,478 +1,494 @@
|
|
|
1
|
-
# Signal
|
|
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
|
-
[](https://badge.fury.io/js/signal-sdk)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://github.com/AsamK/signal-cli)
|
|
8
|
-
[](https://www.typescriptlang.org/)
|
|
9
|
-
[](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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
- [
|
|
176
|
-
- [
|
|
177
|
-
- [
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
- [
|
|
183
|
-
- [
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
- [
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
]
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
// Send
|
|
227
|
-
await signal.sendMessage(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
5.
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
**
|
|
436
|
-
|
|
437
|
-
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
|
471
|
-
|
|
|
472
|
-
|
|
|
473
|
-
|
|
|
474
|
-
| | `
|
|
475
|
-
| | `
|
|
476
|
-
| | `
|
|
477
|
-
|
|
478
|
-
|
|
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
|
+
[](https://badge.fury.io/js/signal-sdk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/AsamK/signal-cli)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
[](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)
|
package/dist/SignalCli.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class SignalCli extends EventEmitter {
|
|
|
5
5
|
private account?;
|
|
6
6
|
private cliProcess;
|
|
7
7
|
private requestPromises;
|
|
8
|
-
constructor(
|
|
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(
|
|
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 =
|
|
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.
|
|
4
|
-
"description": "A comprehensive TypeScript SDK for Signal
|
|
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
|
}
|
package/scripts/connect.js
CHANGED
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
const { SignalCli } = require('../dist/SignalCli');
|
|
20
20
|
|
|
21
21
|
async function connectDevice() {
|
|
22
|
-
console.log('
|
|
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(
|
|
29
|
-
console.log('
|
|
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('
|
|
44
|
-
console.log(
|
|
45
|
-
console.log('\
|
|
46
|
-
console.log('\
|
|
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('\
|
|
50
|
+
console.log('\nExample usage:');
|
|
51
51
|
console.log(' const { SignalCli } = require("signal-sdk");');
|
|
52
|
-
console.log(' const signalCli = new SignalCli(
|
|
52
|
+
console.log(' const signalCli = new SignalCli("+YourPhoneNumber");');
|
|
53
53
|
console.log(' await signalCli.connect();');
|
|
54
54
|
} else {
|
|
55
|
-
console.log('
|
|
56
|
-
console.log('
|
|
57
|
-
console.log('\
|
|
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('\
|
|
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('
|
|
66
|
+
console.error('Device linking failed');
|
|
67
67
|
if (linkingResult.error) {
|
|
68
68
|
console.error(` Error: ${linkingResult.error}`);
|
|
69
69
|
}
|
|
70
|
-
console.error('\
|
|
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('
|
|
79
|
-
console.error('\
|
|
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\
|
|
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\
|
|
95
|
+
console.log('\n\nDevice linking terminated.');
|
|
96
96
|
process.exit(0);
|
|
97
97
|
});
|
|
98
98
|
|