signal-sdk 0.1.0 → 0.1.1
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 +21 -14
- package/dist/MultiAccountManager.d.ts +149 -0
- package/dist/MultiAccountManager.js +320 -0
- package/dist/SignalBot.d.ts +1 -0
- package/dist/SignalBot.js +20 -2
- package/dist/SignalCli.d.ts +244 -15
- package/dist/SignalCli.js +623 -25
- package/dist/__tests__/MultiAccountManager.test.d.ts +4 -0
- package/dist/__tests__/MultiAccountManager.test.js +209 -0
- package/dist/__tests__/SignalBot.additional.test.js +31 -11
- package/dist/__tests__/SignalBot.test.js +5 -0
- package/dist/__tests__/SignalCli.advanced.test.d.ts +5 -0
- package/dist/__tests__/SignalCli.advanced.test.js +295 -0
- package/dist/__tests__/SignalCli.e2e.test.d.ts +5 -0
- package/dist/__tests__/SignalCli.e2e.test.js +240 -0
- package/dist/__tests__/SignalCli.integration.test.js +9 -2
- package/dist/__tests__/SignalCli.methods.test.js +87 -1
- package/dist/__tests__/SignalCli.parsing.test.d.ts +5 -0
- package/dist/__tests__/SignalCli.parsing.test.js +258 -0
- package/dist/__tests__/SignalCli.test.js +5 -13
- package/dist/config.d.ts +16 -1
- package/dist/config.js +6 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/interfaces.d.ts +64 -9
- package/dist/retry.js +25 -8
- package/package.json +1 -1
package/dist/SignalCli.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Message, Contact, GroupUpdateOptions, SendMessageOptions, ContactUpdateOptions, AccountConfiguration, Device, ReceiptType, StickerPack, IdentityKey, LinkingOptions, LinkingResult, MessageRequestResponseType, SendResponse, GroupInfo, RemoveContactOptions, UserStatusResult, PaymentNotificationData, StickerPackManifest, StickerPackUploadResult, RateLimitChallengeResult,
|
|
1
|
+
import { Message, Contact, GroupUpdateOptions, SendMessageOptions, ContactUpdateOptions, AccountConfiguration, Device, ReceiptType, StickerPack, IdentityKey, LinkingOptions, LinkingResult, MessageRequestResponseType, SendResponse, GroupInfo, RemoveContactOptions, UserStatusResult, PaymentNotificationData, StickerPackManifest, StickerPackUploadResult, RateLimitChallengeResult, ReceiveOptions, UploadProgress, PollCreateOptions, PollVoteOptions, PollTerminateOptions, GetAttachmentOptions, GetAvatarOptions, GetStickerOptions, UpdateAccountOptions, AccountUpdateResult, SendContactsOptions, ListGroupsOptions } from './interfaces';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { SignalCliConfig } from './config';
|
|
4
4
|
export declare class SignalCli extends EventEmitter {
|
|
@@ -13,6 +13,11 @@ export declare class SignalCli extends EventEmitter {
|
|
|
13
13
|
private maxReconnectAttempts;
|
|
14
14
|
constructor(accountOrPath?: string, account?: string, config?: SignalCliConfig);
|
|
15
15
|
connect(): Promise<void>;
|
|
16
|
+
private connectJsonRpc;
|
|
17
|
+
private connectUnixSocket;
|
|
18
|
+
private connectTcp;
|
|
19
|
+
private connectHttp;
|
|
20
|
+
private httpRequest;
|
|
16
21
|
disconnect(): void;
|
|
17
22
|
gracefulShutdown(): Promise<void>;
|
|
18
23
|
private handleRpcResponse;
|
|
@@ -42,6 +47,55 @@ export declare class SignalCli extends EventEmitter {
|
|
|
42
47
|
removePin(): Promise<void>;
|
|
43
48
|
listIdentities(number?: string): Promise<IdentityKey[]>;
|
|
44
49
|
trustIdentity(number: string, safetyNumber: string, verified?: boolean): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Get the safety number for a specific contact.
|
|
52
|
+
* This is a helper method that extracts just the safety number from identity information.
|
|
53
|
+
*
|
|
54
|
+
* @param number - The phone number of the contact
|
|
55
|
+
* @returns The safety number string, or null if not found
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const safetyNumber = await signal.getSafetyNumber('+33123456789');
|
|
60
|
+
* console.log(`Safety number: ${safetyNumber}`);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
getSafetyNumber(number: string): Promise<string | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Verify a safety number for a contact.
|
|
66
|
+
* Checks if the provided safety number matches the stored one and marks it as trusted if it does.
|
|
67
|
+
*
|
|
68
|
+
* @param number - The phone number of the contact
|
|
69
|
+
* @param safetyNumber - The safety number to verify
|
|
70
|
+
* @returns True if the safety number matches and was trusted, false otherwise
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const verified = await signal.verifySafetyNumber('+33123456789', '123456 78901...');
|
|
75
|
+
* if (verified) {
|
|
76
|
+
* console.log('Safety number verified and trusted');
|
|
77
|
+
* } else {
|
|
78
|
+
* console.log('Safety number does not match!');
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
verifySafetyNumber(number: string, safetyNumber: string): Promise<boolean>;
|
|
83
|
+
/**
|
|
84
|
+
* List all untrusted identities.
|
|
85
|
+
* Returns identities that have not been explicitly trusted.
|
|
86
|
+
*
|
|
87
|
+
* @returns Array of untrusted identity keys
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const untrusted = await signal.listUntrustedIdentities();
|
|
92
|
+
* console.log(`Found ${untrusted.length} untrusted identities`);
|
|
93
|
+
* untrusted.forEach(id => {
|
|
94
|
+
* console.log(`${id.number}: ${id.safetyNumber}`);
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
listUntrustedIdentities(): Promise<IdentityKey[]>;
|
|
45
99
|
link(deviceName?: string): Promise<string>;
|
|
46
100
|
/**
|
|
47
101
|
* Link a new device to an existing Signal account with QR code support.
|
|
@@ -63,6 +117,45 @@ export declare class SignalCli extends EventEmitter {
|
|
|
63
117
|
createGroup(name: string, members: string[]): Promise<GroupInfo>;
|
|
64
118
|
updateGroup(groupId: string, options: GroupUpdateOptions): Promise<void>;
|
|
65
119
|
listGroups(): Promise<GroupInfo[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Send group invite link to a recipient.
|
|
122
|
+
* Retrieves and sends the invitation link for a group.
|
|
123
|
+
*
|
|
124
|
+
* @param groupId - The group ID
|
|
125
|
+
* @param recipient - The recipient to send the invite link to
|
|
126
|
+
* @returns Send response
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* await signal.sendGroupInviteLink('groupId123==', '+33123456789');
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
sendGroupInviteLink(groupId: string, recipient: string): Promise<SendResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* Set banned members for a group.
|
|
136
|
+
* Ban specific members from the group.
|
|
137
|
+
*
|
|
138
|
+
* @param groupId - The group ID
|
|
139
|
+
* @param members - Array of phone numbers to ban
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* await signal.setBannedMembers('groupId123==', ['+33111111111', '+33222222222']);
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
setBannedMembers(groupId: string, members: string[]): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Reset group invite link.
|
|
149
|
+
* Invalidates the current group invite link and generates a new one.
|
|
150
|
+
*
|
|
151
|
+
* @param groupId - The group ID
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* await signal.resetGroupLink('groupId123==');
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
resetGroupLink(groupId: string): Promise<void>;
|
|
66
159
|
listContacts(): Promise<Contact[]>;
|
|
67
160
|
listDevices(): Promise<Device[]>;
|
|
68
161
|
listAccounts(): Promise<string[]>;
|
|
@@ -81,6 +174,33 @@ export declare class SignalCli extends EventEmitter {
|
|
|
81
174
|
* This method now calls gracefulShutdown() for backward compatibility.
|
|
82
175
|
*/
|
|
83
176
|
stopDaemon(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Receive messages from Signal with configurable options.
|
|
179
|
+
* This is the modern replacement for the deprecated receiveMessages().
|
|
180
|
+
*
|
|
181
|
+
* @param options - Options for receiving messages
|
|
182
|
+
* @returns Array of received messages
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* // Receive with default timeout
|
|
187
|
+
* const messages = await signal.receive();
|
|
188
|
+
*
|
|
189
|
+
* // Receive with custom options
|
|
190
|
+
* const messages = await signal.receive({
|
|
191
|
+
* timeout: 10,
|
|
192
|
+
* maxMessages: 5,
|
|
193
|
+
* ignoreAttachments: true,
|
|
194
|
+
* sendReadReceipts: true
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
receive(options?: ReceiveOptions): Promise<Message[]>;
|
|
199
|
+
/**
|
|
200
|
+
* Parse a message envelope from signal-cli into a Message object.
|
|
201
|
+
* @private
|
|
202
|
+
*/
|
|
203
|
+
private parseEnvelope;
|
|
84
204
|
/**
|
|
85
205
|
* Remove a contact from the contact list.
|
|
86
206
|
* @param number - The phone number of the contact to remove
|
|
@@ -95,10 +215,22 @@ export declare class SignalCli extends EventEmitter {
|
|
|
95
215
|
*/
|
|
96
216
|
getUserStatus(numbers?: string[], usernames?: string[]): Promise<UserStatusResult[]>;
|
|
97
217
|
/**
|
|
98
|
-
* Send a payment notification to a recipient.
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* @
|
|
218
|
+
* Send a payment notification to a recipient (MobileCoin).
|
|
219
|
+
* Sends a notification about a cryptocurrency payment made through Signal's MobileCoin integration.
|
|
220
|
+
*
|
|
221
|
+
* @param recipient - The phone number or group ID of the recipient
|
|
222
|
+
* @param paymentData - Payment notification data including receipt and optional note
|
|
223
|
+
* @returns Send result with timestamp
|
|
224
|
+
* @throws {Error} If receipt is invalid or sending fails
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const receiptBlob = 'base64EncodedReceiptData...';
|
|
229
|
+
* await signal.sendPaymentNotification('+33612345678', {
|
|
230
|
+
* receipt: receiptBlob,
|
|
231
|
+
* note: 'Thanks for dinner!'
|
|
232
|
+
* });
|
|
233
|
+
* ```
|
|
102
234
|
*/
|
|
103
235
|
sendPaymentNotification(recipient: string, paymentData: PaymentNotificationData): Promise<SendResponse>;
|
|
104
236
|
/**
|
|
@@ -115,19 +247,27 @@ export declare class SignalCli extends EventEmitter {
|
|
|
115
247
|
*/
|
|
116
248
|
submitRateLimitChallenge(challenge: string, captcha: string): Promise<RateLimitChallengeResult>;
|
|
117
249
|
/**
|
|
118
|
-
* Start the
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* @
|
|
250
|
+
* Start the phone number change process.
|
|
251
|
+
* Initiates SMS or voice verification for changing your account to a new phone number.
|
|
252
|
+
* After calling this, you must verify the new number with finishChangeNumber().
|
|
253
|
+
*
|
|
254
|
+
* @param newNumber - The new phone number in E164 format (e.g., "+33612345678")
|
|
255
|
+
* @param voice - Use voice verification instead of SMS (default: false)
|
|
256
|
+
* @param captcha - Optional captcha token if required
|
|
257
|
+
* @throws {Error} If not a primary device or rate limited
|
|
123
258
|
*/
|
|
124
|
-
startChangeNumber(newNumber: string, voice?: boolean, captcha?: string): Promise<
|
|
259
|
+
startChangeNumber(newNumber: string, voice?: boolean, captcha?: string): Promise<void>;
|
|
125
260
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
261
|
+
* Complete the phone number change process.
|
|
262
|
+
* Verifies the code received via SMS or voice and changes your account to the new number.
|
|
263
|
+
* Must be called after startChangeNumber().
|
|
264
|
+
*
|
|
265
|
+
* @param newNumber - The new phone number (same as startChangeNumber)
|
|
266
|
+
* @param verificationCode - The verification code received via SMS or voice
|
|
267
|
+
* @param pin - Optional registration lock PIN if one was set
|
|
268
|
+
* @throws {Error} If verification fails or incorrect PIN
|
|
129
269
|
*/
|
|
130
|
-
finishChangeNumber(verificationCode: string, pin?: string): Promise<void>;
|
|
270
|
+
finishChangeNumber(newNumber: string, verificationCode: string, pin?: string): Promise<void>;
|
|
131
271
|
/**
|
|
132
272
|
* Enhanced send message with progress callback support.
|
|
133
273
|
* @param recipient - Phone number or group ID
|
|
@@ -164,6 +304,36 @@ export declare class SignalCli extends EventEmitter {
|
|
|
164
304
|
* @returns Account update result
|
|
165
305
|
*/
|
|
166
306
|
updateAccount(options: UpdateAccountOptions): Promise<AccountUpdateResult>;
|
|
307
|
+
/**
|
|
308
|
+
* Set or update the username for this account.
|
|
309
|
+
* Helper method that wraps updateAccount() for simpler username management.
|
|
310
|
+
*
|
|
311
|
+
* @param username - The username to set (without discriminator)
|
|
312
|
+
* @returns Account update result with username and link
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* const result = await signal.setUsername('myusername');
|
|
317
|
+
* console.log(`Username: ${result.username}`);
|
|
318
|
+
* console.log(`Link: ${result.usernameLink}`);
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
setUsername(username: string): Promise<AccountUpdateResult>;
|
|
322
|
+
/**
|
|
323
|
+
* Delete the current username from this account.
|
|
324
|
+
* Helper method that wraps updateAccount() for simpler username deletion.
|
|
325
|
+
*
|
|
326
|
+
* @returns Account update result
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* const result = await signal.deleteUsername();
|
|
331
|
+
* if (result.success) {
|
|
332
|
+
* console.log('Username deleted successfully');
|
|
333
|
+
* }
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
deleteUsername(): Promise<AccountUpdateResult>;
|
|
167
337
|
/**
|
|
168
338
|
* Get raw attachment data as base64 string.
|
|
169
339
|
* @param options Attachment retrieval options
|
|
@@ -202,4 +372,63 @@ export declare class SignalCli extends EventEmitter {
|
|
|
202
372
|
name?: string;
|
|
203
373
|
uuid?: string;
|
|
204
374
|
}>>;
|
|
375
|
+
/**
|
|
376
|
+
* Extract profile information from a contact.
|
|
377
|
+
* Parses givenName, familyName, mobileCoinAddress from profile data.
|
|
378
|
+
*
|
|
379
|
+
* @param contact - The contact object to parse
|
|
380
|
+
* @returns Enhanced contact with extracted profile fields
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* const contacts = await signal.listContacts();
|
|
385
|
+
* const enriched = signal.parseContactProfile(contacts[0]);
|
|
386
|
+
* console.log(enriched.givenName, enriched.familyName);
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
parseContactProfile(contact: Contact): Contact;
|
|
390
|
+
/**
|
|
391
|
+
* Extract group membership details.
|
|
392
|
+
* Parses pendingMembers, bannedMembers, inviteLink from group data.
|
|
393
|
+
*
|
|
394
|
+
* @param group - The group info to parse
|
|
395
|
+
* @returns Enhanced group with extracted membership fields
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```typescript
|
|
399
|
+
* const groups = await signal.listGroups();
|
|
400
|
+
* const enriched = signal.parseGroupDetails(groups[0]);
|
|
401
|
+
* console.log(enriched.pendingMembers, enriched.bannedMembers);
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
parseGroupDetails(group: GroupInfo): GroupInfo;
|
|
405
|
+
/**
|
|
406
|
+
* Get enriched contacts list with parsed profile information.
|
|
407
|
+
*
|
|
408
|
+
* @returns Array of contacts with full profile data
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* const contacts = await signal.getContactsWithProfiles();
|
|
413
|
+
* contacts.forEach(c => {
|
|
414
|
+
* console.log(`${c.givenName} ${c.familyName} - ${c.mobileCoinAddress}`);
|
|
415
|
+
* });
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
getContactsWithProfiles(): Promise<Contact[]>;
|
|
419
|
+
/**
|
|
420
|
+
* Get enriched groups list with parsed membership details.
|
|
421
|
+
*
|
|
422
|
+
* @param options - List groups options
|
|
423
|
+
* @returns Array of groups with full membership data
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```typescript
|
|
427
|
+
* const groups = await signal.getGroupsWithDetails();
|
|
428
|
+
* groups.forEach(g => {
|
|
429
|
+
* console.log(`${g.name}: ${g.members.length} members, ${g.pendingMembers.length} pending`);
|
|
430
|
+
* });
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
getGroupsWithDetails(options?: ListGroupsOptions): Promise<GroupInfo[]>;
|
|
205
434
|
}
|