signal-sdk 0.1.0 → 0.1.2

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.
@@ -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, ChangeNumberSession, UploadProgress, PollCreateOptions, PollVoteOptions, PollTerminateOptions, GetAttachmentOptions, GetAvatarOptions, GetStickerOptions, UpdateAccountOptions, AccountUpdateResult, SendContactsOptions, ListGroupsOptions } from './interfaces';
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, UpdateDeviceOptions } 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,8 +117,67 @@ 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[]>;
161
+ /**
162
+ * Update a linked device name (signal-cli v0.13.23+).
163
+ * Allows changing the display name of a linked device.
164
+ *
165
+ * @param options - Device update options
166
+ * @returns Promise that resolves when device is updated
167
+ *
168
+ * @example
169
+ * ```typescript
170
+ * // List devices to get device IDs
171
+ * const devices = await signal.listDevices();
172
+ *
173
+ * // Update device name
174
+ * await signal.updateDevice({
175
+ * deviceId: 2,
176
+ * deviceName: 'My New Device Name'
177
+ * });
178
+ * ```
179
+ */
180
+ updateDevice(options: UpdateDeviceOptions): Promise<void>;
68
181
  listAccounts(): Promise<string[]>;
69
182
  /**
70
183
  * @deprecated Use `connect` and listen for `message` events instead.
@@ -81,6 +194,33 @@ export declare class SignalCli extends EventEmitter {
81
194
  * This method now calls gracefulShutdown() for backward compatibility.
82
195
  */
83
196
  stopDaemon(): void;
197
+ /**
198
+ * Receive messages from Signal with configurable options.
199
+ * This is the modern replacement for the deprecated receiveMessages().
200
+ *
201
+ * @param options - Options for receiving messages
202
+ * @returns Array of received messages
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * // Receive with default timeout
207
+ * const messages = await signal.receive();
208
+ *
209
+ * // Receive with custom options
210
+ * const messages = await signal.receive({
211
+ * timeout: 10,
212
+ * maxMessages: 5,
213
+ * ignoreAttachments: true,
214
+ * sendReadReceipts: true
215
+ * });
216
+ * ```
217
+ */
218
+ receive(options?: ReceiveOptions): Promise<Message[]>;
219
+ /**
220
+ * Parse a message envelope from signal-cli into a Message object.
221
+ * @private
222
+ */
223
+ private parseEnvelope;
84
224
  /**
85
225
  * Remove a contact from the contact list.
86
226
  * @param number - The phone number of the contact to remove
@@ -95,10 +235,22 @@ export declare class SignalCli extends EventEmitter {
95
235
  */
96
236
  getUserStatus(numbers?: string[], usernames?: string[]): Promise<UserStatusResult[]>;
97
237
  /**
98
- * Send a payment notification to a recipient.
99
- * @param recipient - Phone number or group ID to send the notification to
100
- * @param paymentData - Payment notification data including receipt
101
- * @returns Send response with timestamp and other details
238
+ * Send a payment notification to a recipient (MobileCoin).
239
+ * Sends a notification about a cryptocurrency payment made through Signal's MobileCoin integration.
240
+ *
241
+ * @param recipient - The phone number or group ID of the recipient
242
+ * @param paymentData - Payment notification data including receipt and optional note
243
+ * @returns Send result with timestamp
244
+ * @throws {Error} If receipt is invalid or sending fails
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * const receiptBlob = 'base64EncodedReceiptData...';
249
+ * await signal.sendPaymentNotification('+33612345678', {
250
+ * receipt: receiptBlob,
251
+ * note: 'Thanks for dinner!'
252
+ * });
253
+ * ```
102
254
  */
103
255
  sendPaymentNotification(recipient: string, paymentData: PaymentNotificationData): Promise<SendResponse>;
104
256
  /**
@@ -115,19 +267,27 @@ export declare class SignalCli extends EventEmitter {
115
267
  */
116
268
  submitRateLimitChallenge(challenge: string, captcha: string): Promise<RateLimitChallengeResult>;
117
269
  /**
118
- * Start the process of changing phone number.
119
- * @param newNumber - The new phone number to change to
120
- * @param voice - Whether to use voice verification instead of SMS
121
- * @param captcha - Captcha token if required
122
- * @returns Change number session information
270
+ * Start the phone number change process.
271
+ * Initiates SMS or voice verification for changing your account to a new phone number.
272
+ * After calling this, you must verify the new number with finishChangeNumber().
273
+ *
274
+ * @param newNumber - The new phone number in E164 format (e.g., "+33612345678")
275
+ * @param voice - Use voice verification instead of SMS (default: false)
276
+ * @param captcha - Optional captcha token if required
277
+ * @throws {Error} If not a primary device or rate limited
123
278
  */
124
- startChangeNumber(newNumber: string, voice?: boolean, captcha?: string): Promise<ChangeNumberSession>;
279
+ startChangeNumber(newNumber: string, voice?: boolean, captcha?: string): Promise<void>;
125
280
  /**
126
- * Finish the phone number change process with verification code.
127
- * @param verificationCode - The verification code received via SMS/voice
128
- * @param pin - Registration lock PIN if enabled
281
+ * Complete the phone number change process.
282
+ * Verifies the code received via SMS or voice and changes your account to the new number.
283
+ * Must be called after startChangeNumber().
284
+ *
285
+ * @param newNumber - The new phone number (same as startChangeNumber)
286
+ * @param verificationCode - The verification code received via SMS or voice
287
+ * @param pin - Optional registration lock PIN if one was set
288
+ * @throws {Error} If verification fails or incorrect PIN
129
289
  */
130
- finishChangeNumber(verificationCode: string, pin?: string): Promise<void>;
290
+ finishChangeNumber(newNumber: string, verificationCode: string, pin?: string): Promise<void>;
131
291
  /**
132
292
  * Enhanced send message with progress callback support.
133
293
  * @param recipient - Phone number or group ID
@@ -164,6 +324,36 @@ export declare class SignalCli extends EventEmitter {
164
324
  * @returns Account update result
165
325
  */
166
326
  updateAccount(options: UpdateAccountOptions): Promise<AccountUpdateResult>;
327
+ /**
328
+ * Set or update the username for this account.
329
+ * Helper method that wraps updateAccount() for simpler username management.
330
+ *
331
+ * @param username - The username to set (without discriminator)
332
+ * @returns Account update result with username and link
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * const result = await signal.setUsername('myusername');
337
+ * console.log(`Username: ${result.username}`);
338
+ * console.log(`Link: ${result.usernameLink}`);
339
+ * ```
340
+ */
341
+ setUsername(username: string): Promise<AccountUpdateResult>;
342
+ /**
343
+ * Delete the current username from this account.
344
+ * Helper method that wraps updateAccount() for simpler username deletion.
345
+ *
346
+ * @returns Account update result
347
+ *
348
+ * @example
349
+ * ```typescript
350
+ * const result = await signal.deleteUsername();
351
+ * if (result.success) {
352
+ * console.log('Username deleted successfully');
353
+ * }
354
+ * ```
355
+ */
356
+ deleteUsername(): Promise<AccountUpdateResult>;
167
357
  /**
168
358
  * Get raw attachment data as base64 string.
169
359
  * @param options Attachment retrieval options
@@ -202,4 +392,63 @@ export declare class SignalCli extends EventEmitter {
202
392
  name?: string;
203
393
  uuid?: string;
204
394
  }>>;
395
+ /**
396
+ * Extract profile information from a contact.
397
+ * Parses givenName, familyName, mobileCoinAddress from profile data.
398
+ *
399
+ * @param contact - The contact object to parse
400
+ * @returns Enhanced contact with extracted profile fields
401
+ *
402
+ * @example
403
+ * ```typescript
404
+ * const contacts = await signal.listContacts();
405
+ * const enriched = signal.parseContactProfile(contacts[0]);
406
+ * console.log(enriched.givenName, enriched.familyName);
407
+ * ```
408
+ */
409
+ parseContactProfile(contact: Contact): Contact;
410
+ /**
411
+ * Extract group membership details.
412
+ * Parses pendingMembers, bannedMembers, inviteLink from group data.
413
+ *
414
+ * @param group - The group info to parse
415
+ * @returns Enhanced group with extracted membership fields
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * const groups = await signal.listGroups();
420
+ * const enriched = signal.parseGroupDetails(groups[0]);
421
+ * console.log(enriched.pendingMembers, enriched.bannedMembers);
422
+ * ```
423
+ */
424
+ parseGroupDetails(group: GroupInfo): GroupInfo;
425
+ /**
426
+ * Get enriched contacts list with parsed profile information.
427
+ *
428
+ * @returns Array of contacts with full profile data
429
+ *
430
+ * @example
431
+ * ```typescript
432
+ * const contacts = await signal.getContactsWithProfiles();
433
+ * contacts.forEach(c => {
434
+ * console.log(`${c.givenName} ${c.familyName} - ${c.mobileCoinAddress}`);
435
+ * });
436
+ * ```
437
+ */
438
+ getContactsWithProfiles(): Promise<Contact[]>;
439
+ /**
440
+ * Get enriched groups list with parsed membership details.
441
+ *
442
+ * @param options - List groups options
443
+ * @returns Array of groups with full membership data
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * const groups = await signal.getGroupsWithDetails();
448
+ * groups.forEach(g => {
449
+ * console.log(`${g.name}: ${g.members.length} members, ${g.pendingMembers.length} pending`);
450
+ * });
451
+ * ```
452
+ */
453
+ getGroupsWithDetails(options?: ListGroupsOptions): Promise<GroupInfo[]>;
205
454
  }