signal-sdk 0.0.8 → 0.1.0

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.
Files changed (36) hide show
  1. package/README.md +175 -59
  2. package/dist/SignalBot.d.ts +108 -0
  3. package/dist/SignalBot.js +811 -0
  4. package/dist/SignalCli.d.ts +205 -0
  5. package/dist/SignalCli.js +967 -0
  6. package/dist/__tests__/SignalBot.additional.test.d.ts +5 -0
  7. package/dist/__tests__/SignalBot.additional.test.js +333 -0
  8. package/dist/__tests__/SignalBot.test.d.ts +1 -0
  9. package/dist/__tests__/SignalBot.test.js +102 -0
  10. package/dist/__tests__/SignalCli.integration.test.d.ts +5 -0
  11. package/dist/__tests__/SignalCli.integration.test.js +218 -0
  12. package/dist/__tests__/SignalCli.methods.test.d.ts +5 -0
  13. package/dist/__tests__/SignalCli.methods.test.js +470 -0
  14. package/dist/__tests__/SignalCli.test.d.ts +1 -0
  15. package/dist/__tests__/SignalCli.test.js +479 -0
  16. package/dist/__tests__/config.test.d.ts +5 -0
  17. package/dist/__tests__/config.test.js +252 -0
  18. package/dist/__tests__/errors.test.d.ts +5 -0
  19. package/dist/__tests__/errors.test.js +276 -0
  20. package/dist/__tests__/retry.test.d.ts +4 -0
  21. package/dist/__tests__/retry.test.js +123 -0
  22. package/dist/__tests__/validators.test.d.ts +4 -0
  23. package/dist/__tests__/validators.test.js +147 -0
  24. package/dist/config.d.ts +67 -0
  25. package/dist/config.js +111 -0
  26. package/dist/errors.d.ts +32 -0
  27. package/dist/errors.js +75 -0
  28. package/dist/index.d.ts +7 -0
  29. package/dist/index.js +26 -0
  30. package/dist/interfaces.d.ts +1073 -0
  31. package/dist/interfaces.js +11 -0
  32. package/dist/retry.d.ts +56 -0
  33. package/dist/retry.js +135 -0
  34. package/dist/validators.d.ts +59 -0
  35. package/dist/validators.js +170 -0
  36. package/package.json +5 -6
@@ -0,0 +1,205 @@
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';
2
+ import { EventEmitter } from 'events';
3
+ import { SignalCliConfig } from './config';
4
+ export declare class SignalCli extends EventEmitter {
5
+ private signalCliPath;
6
+ private account?;
7
+ private cliProcess;
8
+ private requestPromises;
9
+ private config;
10
+ private logger;
11
+ private rateLimiter;
12
+ private reconnectAttempts;
13
+ private maxReconnectAttempts;
14
+ constructor(accountOrPath?: string, account?: string, config?: SignalCliConfig);
15
+ connect(): Promise<void>;
16
+ disconnect(): void;
17
+ gracefulShutdown(): Promise<void>;
18
+ private handleRpcResponse;
19
+ private handleStderrData;
20
+ private sendJsonRpcRequest;
21
+ private isGroupId;
22
+ register(number: string, voice?: boolean, captcha?: string): Promise<void>;
23
+ verify(number: string, token: string, pin?: string): Promise<void>;
24
+ sendMessage(recipient: string, message: string, options?: Omit<SendMessageOptions, 'message'>): Promise<SendResponse>;
25
+ sendReaction(recipient: string, targetAuthor: string, targetTimestamp: number, emoji: string, remove?: boolean): Promise<SendResponse>;
26
+ sendTyping(recipient: string, stop?: boolean): Promise<void>;
27
+ remoteDeleteMessage(recipient: string, targetTimestamp: number): Promise<void>;
28
+ updateContact(number: string, name: string, options?: Omit<ContactUpdateOptions, 'name'>): Promise<void>;
29
+ block(recipients: string[], groupId?: string): Promise<void>;
30
+ unblock(recipients: string[], groupId?: string): Promise<void>;
31
+ quitGroup(groupId: string): Promise<void>;
32
+ joinGroup(uri: string): Promise<void>;
33
+ updateProfile(name: string, about?: string, aboutEmoji?: string, avatar?: string): Promise<void>;
34
+ sendReceipt(recipient: string, targetTimestamp: number, type?: ReceiptType): Promise<void>;
35
+ listStickerPacks(): Promise<StickerPack[]>;
36
+ addStickerPack(packId: string, packKey: string): Promise<void>;
37
+ unregister(): Promise<void>;
38
+ deleteLocalAccountData(): Promise<void>;
39
+ updateAccountConfiguration(config: AccountConfiguration): Promise<void>;
40
+ removeDevice(deviceId: number): Promise<void>;
41
+ setPin(pin: string): Promise<void>;
42
+ removePin(): Promise<void>;
43
+ listIdentities(number?: string): Promise<IdentityKey[]>;
44
+ trustIdentity(number: string, safetyNumber: string, verified?: boolean): Promise<void>;
45
+ link(deviceName?: string): Promise<string>;
46
+ /**
47
+ * Link a new device to an existing Signal account with QR code support.
48
+ * This method provides a complete device linking solution with QR code generation.
49
+ *
50
+ * @param options - Linking options including device name and QR code output preferences
51
+ * @returns Promise resolving to LinkingResult with QR code data and linking status
52
+ */
53
+ deviceLink(options?: LinkingOptions): Promise<LinkingResult>;
54
+ /**
55
+ * Display ASCII QR code in console.
56
+ * Uses qrcode-terminal which is included as a dependency.
57
+ */
58
+ private displayQRCode;
59
+ addDevice(uri: string, deviceName?: string): Promise<void>;
60
+ sendSyncRequest(): Promise<void>;
61
+ sendMessageRequestResponse(recipient: string, response: MessageRequestResponseType): Promise<void>;
62
+ getVersion(): Promise<any>;
63
+ createGroup(name: string, members: string[]): Promise<GroupInfo>;
64
+ updateGroup(groupId: string, options: GroupUpdateOptions): Promise<void>;
65
+ listGroups(): Promise<GroupInfo[]>;
66
+ listContacts(): Promise<Contact[]>;
67
+ listDevices(): Promise<Device[]>;
68
+ listAccounts(): Promise<string[]>;
69
+ /**
70
+ * @deprecated Use `connect` and listen for `message` events instead.
71
+ * This method now provides a compatibility layer by connecting and buffering messages.
72
+ */
73
+ receiveMessages(): Promise<Message[]>;
74
+ /**
75
+ * @deprecated Use `connect` instead.
76
+ * This method now calls connect() for backward compatibility.
77
+ */
78
+ startDaemon(): void;
79
+ /**
80
+ * @deprecated Use `gracefulShutdown` or `disconnect` instead.
81
+ * This method now calls gracefulShutdown() for backward compatibility.
82
+ */
83
+ stopDaemon(): void;
84
+ /**
85
+ * Remove a contact from the contact list.
86
+ * @param number - The phone number of the contact to remove
87
+ * @param options - Options for how to remove the contact
88
+ */
89
+ removeContact(number: string, options?: RemoveContactOptions): Promise<void>;
90
+ /**
91
+ * Check if phone numbers are registered with Signal.
92
+ * @param numbers - Array of phone numbers to check
93
+ * @param usernames - Optional array of usernames to check
94
+ * @returns Array of user status results
95
+ */
96
+ getUserStatus(numbers?: string[], usernames?: string[]): Promise<UserStatusResult[]>;
97
+ /**
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
102
+ */
103
+ sendPaymentNotification(recipient: string, paymentData: PaymentNotificationData): Promise<SendResponse>;
104
+ /**
105
+ * Upload a custom sticker pack to Signal.
106
+ * @param manifest - Sticker pack manifest information
107
+ * @returns Upload result with pack ID and key
108
+ */
109
+ uploadStickerPack(manifest: StickerPackManifest): Promise<StickerPackUploadResult>;
110
+ /**
111
+ * Submit a rate limit challenge to lift rate limiting.
112
+ * @param challenge - Challenge token from the proof required error
113
+ * @param captcha - Captcha token from solved captcha
114
+ * @returns Challenge result indicating success/failure
115
+ */
116
+ submitRateLimitChallenge(challenge: string, captcha: string): Promise<RateLimitChallengeResult>;
117
+ /**
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
123
+ */
124
+ startChangeNumber(newNumber: string, voice?: boolean, captcha?: string): Promise<ChangeNumberSession>;
125
+ /**
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
129
+ */
130
+ finishChangeNumber(verificationCode: string, pin?: string): Promise<void>;
131
+ /**
132
+ * Enhanced send message with progress callback support.
133
+ * @param recipient - Phone number or group ID
134
+ * @param message - Message text
135
+ * @param options - Send options including progress callback
136
+ * @returns Send response
137
+ */
138
+ sendMessageWithProgress(recipient: string, message: string, options?: SendMessageOptions & {
139
+ onProgress?: (progress: UploadProgress) => void;
140
+ }): Promise<SendResponse>;
141
+ /**
142
+ * Send a poll create message to a recipient or group.
143
+ * @param options Poll creation options
144
+ * @returns Send response with timestamp
145
+ */
146
+ sendPollCreate(options: PollCreateOptions): Promise<SendResponse>;
147
+ /**
148
+ * Send a poll vote message to vote on a poll.
149
+ * @param recipient Recipient or group ID
150
+ * @param options Poll vote options
151
+ * @returns Send response with timestamp
152
+ */
153
+ sendPollVote(recipient: string, options: PollVoteOptions): Promise<SendResponse>;
154
+ /**
155
+ * Send a poll terminate message to close a poll.
156
+ * @param recipient Recipient or group ID
157
+ * @param options Poll terminate options
158
+ * @returns Send response with timestamp
159
+ */
160
+ sendPollTerminate(recipient: string, options: PollTerminateOptions): Promise<SendResponse>;
161
+ /**
162
+ * Update account information (device name, username, privacy settings).
163
+ * @param options Account update options
164
+ * @returns Account update result
165
+ */
166
+ updateAccount(options: UpdateAccountOptions): Promise<AccountUpdateResult>;
167
+ /**
168
+ * Get raw attachment data as base64 string.
169
+ * @param options Attachment retrieval options
170
+ * @returns Base64 encoded attachment data
171
+ */
172
+ getAttachment(options: GetAttachmentOptions): Promise<string>;
173
+ /**
174
+ * Get raw avatar data as base64 string.
175
+ * @param options Avatar retrieval options
176
+ * @returns Base64 encoded avatar data
177
+ */
178
+ getAvatar(options: GetAvatarOptions): Promise<string>;
179
+ /**
180
+ * Get raw sticker data as base64 string.
181
+ * @param options Sticker retrieval options
182
+ * @returns Base64 encoded sticker data
183
+ */
184
+ getSticker(options: GetStickerOptions): Promise<string>;
185
+ /**
186
+ * Send contacts synchronization message to linked devices.
187
+ * @param options Contacts sync options
188
+ */
189
+ sendContacts(options?: SendContactsOptions): Promise<void>;
190
+ /**
191
+ * List groups with optional filtering and details.
192
+ * @param options List groups options
193
+ * @returns Array of group information
194
+ */
195
+ listGroupsDetailed(options?: ListGroupsOptions): Promise<GroupInfo[]>;
196
+ /**
197
+ * List all local accounts.
198
+ * @returns Array of account phone numbers
199
+ */
200
+ listAccountsDetailed(): Promise<Array<{
201
+ number: string;
202
+ name?: string;
203
+ uuid?: string;
204
+ }>>;
205
+ }