signal-sdk 0.1.2 → 0.1.3

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 (53) hide show
  1. package/README.md +18 -8
  2. package/dist/MultiAccountManager.js +11 -19
  3. package/dist/SignalBot.js +40 -36
  4. package/dist/SignalCli.d.ts +23 -319
  5. package/dist/SignalCli.js +224 -998
  6. package/dist/__tests__/DeviceManager.test.d.ts +1 -0
  7. package/dist/__tests__/DeviceManager.test.js +135 -0
  8. package/dist/__tests__/MultiAccountManager.coverage.test.d.ts +1 -0
  9. package/dist/__tests__/MultiAccountManager.coverage.test.js +33 -0
  10. package/dist/__tests__/MultiAccountManager.test.js +3 -3
  11. package/dist/__tests__/SignalBot.additional.test.js +40 -37
  12. package/dist/__tests__/SignalBot.coverage.test.d.ts +1 -0
  13. package/dist/__tests__/SignalBot.coverage.test.js +385 -0
  14. package/dist/__tests__/SignalBot.test.js +8 -8
  15. package/dist/__tests__/SignalCli.advanced.test.js +47 -58
  16. package/dist/__tests__/SignalCli.connections.test.d.ts +1 -0
  17. package/dist/__tests__/SignalCli.connections.test.js +110 -0
  18. package/dist/__tests__/SignalCli.e2e.test.js +28 -32
  19. package/dist/__tests__/SignalCli.events.test.d.ts +1 -0
  20. package/dist/__tests__/SignalCli.events.test.js +113 -0
  21. package/dist/__tests__/SignalCli.integration.test.js +6 -5
  22. package/dist/__tests__/SignalCli.methods.test.js +77 -77
  23. package/dist/__tests__/SignalCli.parsing.test.js +4 -13
  24. package/dist/__tests__/SignalCli.simple.test.d.ts +1 -0
  25. package/dist/__tests__/SignalCli.simple.test.js +77 -0
  26. package/dist/__tests__/SignalCli.test.js +96 -82
  27. package/dist/__tests__/config.test.js +19 -29
  28. package/dist/__tests__/errors.test.js +2 -2
  29. package/dist/__tests__/retry.test.js +10 -8
  30. package/dist/__tests__/robustness.test.d.ts +1 -0
  31. package/dist/__tests__/robustness.test.js +59 -0
  32. package/dist/__tests__/security.test.d.ts +1 -0
  33. package/dist/__tests__/security.test.js +50 -0
  34. package/dist/config.js +3 -3
  35. package/dist/interfaces.d.ts +18 -0
  36. package/dist/managers/AccountManager.d.ts +27 -0
  37. package/dist/managers/AccountManager.js +147 -0
  38. package/dist/managers/BaseManager.d.ts +9 -0
  39. package/dist/managers/BaseManager.js +17 -0
  40. package/dist/managers/ContactManager.d.ts +15 -0
  41. package/dist/managers/ContactManager.js +123 -0
  42. package/dist/managers/DeviceManager.d.ts +11 -0
  43. package/dist/managers/DeviceManager.js +139 -0
  44. package/dist/managers/GroupManager.d.ts +12 -0
  45. package/dist/managers/GroupManager.js +78 -0
  46. package/dist/managers/MessageManager.d.ts +18 -0
  47. package/dist/managers/MessageManager.js +301 -0
  48. package/dist/managers/StickerManager.d.ts +8 -0
  49. package/dist/managers/StickerManager.js +39 -0
  50. package/dist/retry.js +3 -3
  51. package/dist/validators.d.ts +9 -0
  52. package/dist/validators.js +20 -0
  53. package/package.json +11 -4
@@ -0,0 +1,8 @@
1
+ import { BaseManager } from './BaseManager';
2
+ import { StickerPack, StickerPackManifest, StickerPackUploadResult, GetStickerOptions } from '../interfaces';
3
+ export declare class StickerManager extends BaseManager {
4
+ listStickerPacks(): Promise<StickerPack[]>;
5
+ addStickerPack(packId: string, packKey: string): Promise<void>;
6
+ uploadStickerPack(manifest: StickerPackManifest): Promise<StickerPackUploadResult>;
7
+ getSticker(options: GetStickerOptions): Promise<string>;
8
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StickerManager = void 0;
4
+ const BaseManager_1 = require("./BaseManager");
5
+ const errors_1 = require("../errors");
6
+ class StickerManager extends BaseManager_1.BaseManager {
7
+ async listStickerPacks() {
8
+ return this.sendRequest('listStickerPacks', { account: this.account });
9
+ }
10
+ async addStickerPack(packId, packKey) {
11
+ await this.sendRequest('addStickerPack', { account: this.account, packId, packKey });
12
+ }
13
+ async uploadStickerPack(manifest) {
14
+ const params = {
15
+ account: this.account,
16
+ path: manifest.path,
17
+ };
18
+ const result = await this.sendRequest('uploadStickerPack', params);
19
+ return {
20
+ packId: result.packId,
21
+ packKey: result.packKey,
22
+ installUrl: result.installUrl,
23
+ };
24
+ }
25
+ async getSticker(options) {
26
+ this.logger.debug('Getting sticker', options);
27
+ if (!options.packId || !options.stickerId) {
28
+ throw new errors_1.MessageError('Pack ID and sticker ID are required');
29
+ }
30
+ const params = {
31
+ packId: options.packId,
32
+ stickerId: options.stickerId,
33
+ account: this.account,
34
+ };
35
+ const result = await this.sendRequest('getSticker', params);
36
+ return result.data || result;
37
+ }
38
+ }
39
+ exports.StickerManager = StickerManager;
package/dist/retry.js CHANGED
@@ -29,7 +29,7 @@ const DEFAULT_RETRY_OPTIONS = {
29
29
  const isClientError = error.code === 401 || error.code === 403 || error.code === 400;
30
30
  return (isConnectionError || isServerError) && !isClientError;
31
31
  },
32
- onRetry: () => { }
32
+ onRetry: () => { },
33
33
  };
34
34
  /**
35
35
  * Executes an operation with retry logic and exponential backoff
@@ -101,7 +101,7 @@ async function withTimeout(promise, timeoutMs) {
101
101
  * @param ms Duration in milliseconds
102
102
  */
103
103
  function sleep(ms) {
104
- return new Promise(resolve => setTimeout(resolve, ms));
104
+ return new Promise((resolve) => setTimeout(resolve, ms));
105
105
  }
106
106
  /**
107
107
  * Rate limiter to prevent exceeding API limits
@@ -141,7 +141,7 @@ class RateLimiter {
141
141
  this.activeRequests++;
142
142
  return Promise.resolve();
143
143
  }
144
- return new Promise(resolve => {
144
+ return new Promise((resolve) => {
145
145
  this.queue.push(() => {
146
146
  this.activeRequests++;
147
147
  resolve();
@@ -57,3 +57,12 @@ export declare function validateDeviceId(deviceId: number): void;
57
57
  * @returns Sanitized string
58
58
  */
59
59
  export declare function sanitizeInput(input: string): string;
60
+ /**
61
+ * Validates a string to ensure it contains no shell-unsafe characters.
62
+ * Used for inputs that might be passed to shell commands (like device names).
63
+ *
64
+ * @param input String to validate
65
+ * @param fieldName Name of the field for error message
66
+ * @throws ValidationError if input contains unsafe characters
67
+ */
68
+ export declare function validateSanitizedString(input: string, fieldName?: string): void;
@@ -13,6 +13,7 @@ exports.validateTimestamp = validateTimestamp;
13
13
  exports.validateEmoji = validateEmoji;
14
14
  exports.validateDeviceId = validateDeviceId;
15
15
  exports.sanitizeInput = sanitizeInput;
16
+ exports.validateSanitizedString = validateSanitizedString;
16
17
  const errors_1 = require("./errors");
17
18
  /**
18
19
  * Validates a phone number format (E.164)
@@ -168,3 +169,22 @@ function sanitizeInput(input) {
168
169
  // Remove null bytes
169
170
  return input.replace(/\0/g, '');
170
171
  }
172
+ /**
173
+ * Validates a string to ensure it contains no shell-unsafe characters.
174
+ * Used for inputs that might be passed to shell commands (like device names).
175
+ *
176
+ * @param input String to validate
177
+ * @param fieldName Name of the field for error message
178
+ * @throws ValidationError if input contains unsafe characters
179
+ */
180
+ function validateSanitizedString(input, fieldName = 'input') {
181
+ if (!input)
182
+ return;
183
+ // Reject characters that have special meaning in shells:
184
+ // & | ; $ > < ` \ ! " ' ( ) [ ] { }
185
+ // Also reject newlines and control characters
186
+ const unsafeRegex = /[&|;$><`\\!"'()[\]{}\n\r\t]/;
187
+ if (unsafeRegex.test(input)) {
188
+ throw new errors_1.ValidationError(`${fieldName} contains unsafe characters. Only alphanumeric and basic punctuation (.,-_) are allowed.`, fieldName);
189
+ }
190
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "signal-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,7 +27,9 @@
27
27
  "example:file-handling": "node examples/sdk/05-file-handling.js",
28
28
  "example:minimal-bot": "node examples/bot/01-minimal-bot.js",
29
29
  "example:advanced-bot": "node examples/bot/02-advanced-bot.js",
30
- "example:advanced-bot-2": "node examples/bot/03-advanced-bot.js"
30
+ "example:advanced-bot-2": "node examples/bot/03-advanced-bot.js",
31
+ "lint": "eslint 'src/**/*.{ts,js}'",
32
+ "format": "prettier --write 'src/**/*.{ts,js}'"
31
33
  },
32
34
  "keywords": [
33
35
  "signal",
@@ -55,10 +57,15 @@
55
57
  "devDependencies": {
56
58
  "@types/jest": "^30.0.0",
57
59
  "@types/node": "^24.0.10",
58
- "dotenv": "^16.4.5",
59
60
  "@types/qrcode-terminal": "^0.12.2",
60
61
  "@types/uuid": "^9.0.8",
62
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
63
+ "@typescript-eslint/parser": "^8.54.0",
64
+ "dotenv": "^16.4.5",
65
+ "eslint": "^9.39.2",
66
+ "eslint-config-prettier": "^10.1.8",
61
67
  "jest": "^30.0.4",
68
+ "prettier": "^3.8.1",
62
69
  "ts-jest": "^29.4.0",
63
70
  "typescript": "^5.8.3"
64
71
  },
@@ -68,4 +75,4 @@
68
75
  "tar": "^7.4.3",
69
76
  "uuid": "^9.0.1"
70
77
  }
71
- }
78
+ }