signal-sdk 0.0.9 → 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 +184 -61
- 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 +315 -16
- package/dist/SignalCli.js +880 -26
- package/dist/__tests__/MultiAccountManager.test.d.ts +4 -0
- package/dist/__tests__/MultiAccountManager.test.js +209 -0
- package/dist/__tests__/SignalBot.additional.test.d.ts +5 -0
- package/dist/__tests__/SignalBot.additional.test.js +353 -0
- 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.d.ts +5 -0
- package/dist/__tests__/SignalCli.integration.test.js +225 -0
- package/dist/__tests__/SignalCli.methods.test.d.ts +5 -0
- package/dist/__tests__/SignalCli.methods.test.js +556 -0
- 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 +249 -13
- package/dist/__tests__/config.test.d.ts +5 -0
- package/dist/__tests__/config.test.js +252 -0
- package/dist/__tests__/errors.test.d.ts +5 -0
- package/dist/__tests__/errors.test.js +276 -0
- package/dist/__tests__/retry.test.d.ts +4 -0
- package/dist/__tests__/retry.test.js +123 -0
- package/dist/__tests__/validators.test.d.ts +4 -0
- package/dist/__tests__/validators.test.js +147 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.js +116 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +75 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7 -1
- package/dist/interfaces.d.ts +200 -10
- package/dist/interfaces.js +1 -1
- package/dist/retry.d.ts +56 -0
- package/dist/retry.js +152 -0
- package/dist/validators.d.ts +59 -0
- package/dist/validators.js +170 -0
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Basic tests for validators
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const validators_1 = require("../validators");
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
describe('Validators', () => {
|
|
9
|
+
describe('validatePhoneNumber', () => {
|
|
10
|
+
it('should accept valid E.164 phone numbers', () => {
|
|
11
|
+
expect(() => (0, validators_1.validatePhoneNumber)('+33123456789')).not.toThrow();
|
|
12
|
+
expect(() => (0, validators_1.validatePhoneNumber)('+1234567890')).not.toThrow();
|
|
13
|
+
expect(() => (0, validators_1.validatePhoneNumber)('+49123456789012')).not.toThrow();
|
|
14
|
+
});
|
|
15
|
+
it('should reject invalid phone numbers', () => {
|
|
16
|
+
expect(() => (0, validators_1.validatePhoneNumber)('123456789')).toThrow(errors_1.ValidationError);
|
|
17
|
+
expect(() => (0, validators_1.validatePhoneNumber)('+0123456789')).toThrow(errors_1.ValidationError);
|
|
18
|
+
expect(() => (0, validators_1.validatePhoneNumber)('invalid')).toThrow(errors_1.ValidationError);
|
|
19
|
+
expect(() => (0, validators_1.validatePhoneNumber)('')).toThrow(errors_1.ValidationError);
|
|
20
|
+
});
|
|
21
|
+
it('should reject non-string inputs', () => {
|
|
22
|
+
expect(() => (0, validators_1.validatePhoneNumber)(null)).toThrow(errors_1.ValidationError);
|
|
23
|
+
expect(() => (0, validators_1.validatePhoneNumber)(undefined)).toThrow(errors_1.ValidationError);
|
|
24
|
+
expect(() => (0, validators_1.validatePhoneNumber)(123)).toThrow(errors_1.ValidationError);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('validateGroupId', () => {
|
|
28
|
+
it('should accept non-empty strings', () => {
|
|
29
|
+
expect(() => (0, validators_1.validateGroupId)('abc123==')).not.toThrow();
|
|
30
|
+
expect(() => (0, validators_1.validateGroupId)('groupId')).not.toThrow();
|
|
31
|
+
});
|
|
32
|
+
it('should reject empty or invalid group IDs', () => {
|
|
33
|
+
expect(() => (0, validators_1.validateGroupId)('')).toThrow(errors_1.ValidationError);
|
|
34
|
+
expect(() => (0, validators_1.validateGroupId)(null)).toThrow(errors_1.ValidationError);
|
|
35
|
+
expect(() => (0, validators_1.validateGroupId)(undefined)).toThrow(errors_1.ValidationError);
|
|
36
|
+
});
|
|
37
|
+
it('should reject non-string group IDs', () => {
|
|
38
|
+
expect(() => (0, validators_1.validateGroupId)(123)).toThrow(errors_1.ValidationError);
|
|
39
|
+
expect(() => (0, validators_1.validateGroupId)({})).toThrow(errors_1.ValidationError);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('validateRecipient', () => {
|
|
43
|
+
it('should accept valid phone numbers', () => {
|
|
44
|
+
expect(() => (0, validators_1.validateRecipient)('+33123456789')).not.toThrow();
|
|
45
|
+
});
|
|
46
|
+
it('should accept usernames', () => {
|
|
47
|
+
expect(() => (0, validators_1.validateRecipient)('u:username.001')).not.toThrow();
|
|
48
|
+
});
|
|
49
|
+
it('should accept UUIDs', () => {
|
|
50
|
+
expect(() => (0, validators_1.validateRecipient)('12345678-1234-1234-1234-123456789012')).not.toThrow();
|
|
51
|
+
expect(() => (0, validators_1.validateRecipient)('PNI:12345678-1234-1234-1234-123456789012')).not.toThrow();
|
|
52
|
+
});
|
|
53
|
+
it('should reject invalid recipients', () => {
|
|
54
|
+
expect(() => (0, validators_1.validateRecipient)('')).toThrow(errors_1.ValidationError);
|
|
55
|
+
expect(() => (0, validators_1.validateRecipient)('u:')).toThrow(errors_1.ValidationError);
|
|
56
|
+
});
|
|
57
|
+
it('should reject non-string recipients', () => {
|
|
58
|
+
expect(() => (0, validators_1.validateRecipient)(null)).toThrow(errors_1.ValidationError);
|
|
59
|
+
expect(() => (0, validators_1.validateRecipient)(123)).toThrow(errors_1.ValidationError);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('validateMessage', () => {
|
|
63
|
+
it('should accept valid messages', () => {
|
|
64
|
+
expect(() => (0, validators_1.validateMessage)('Hello')).not.toThrow();
|
|
65
|
+
expect(() => (0, validators_1.validateMessage)('', 10)).not.toThrow();
|
|
66
|
+
});
|
|
67
|
+
it('should reject messages exceeding max length', () => {
|
|
68
|
+
expect(() => (0, validators_1.validateMessage)('Hello World', 5)).toThrow(errors_1.ValidationError);
|
|
69
|
+
});
|
|
70
|
+
it('should reject non-string messages', () => {
|
|
71
|
+
expect(() => (0, validators_1.validateMessage)(null)).toThrow(errors_1.ValidationError);
|
|
72
|
+
expect(() => (0, validators_1.validateMessage)(undefined)).toThrow(errors_1.ValidationError);
|
|
73
|
+
expect(() => (0, validators_1.validateMessage)(123)).toThrow(errors_1.ValidationError);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('validateAttachments', () => {
|
|
77
|
+
it('should accept valid attachment arrays', () => {
|
|
78
|
+
expect(() => (0, validators_1.validateAttachments)(['file1.txt', 'file2.jpg'])).not.toThrow();
|
|
79
|
+
expect(() => (0, validators_1.validateAttachments)([])).not.toThrow();
|
|
80
|
+
});
|
|
81
|
+
it('should reject non-array inputs', () => {
|
|
82
|
+
expect(() => (0, validators_1.validateAttachments)('not-an-array')).toThrow(errors_1.ValidationError);
|
|
83
|
+
expect(() => (0, validators_1.validateAttachments)(null)).toThrow(errors_1.ValidationError);
|
|
84
|
+
});
|
|
85
|
+
it('should reject non-string attachment paths', () => {
|
|
86
|
+
expect(() => (0, validators_1.validateAttachments)([123])).toThrow(errors_1.ValidationError);
|
|
87
|
+
expect(() => (0, validators_1.validateAttachments)([null])).toThrow(errors_1.ValidationError);
|
|
88
|
+
});
|
|
89
|
+
it('should reject empty attachment paths', () => {
|
|
90
|
+
expect(() => (0, validators_1.validateAttachments)([''])).toThrow(errors_1.ValidationError);
|
|
91
|
+
expect(() => (0, validators_1.validateAttachments)(['file1.txt', ''])).toThrow(errors_1.ValidationError);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('validateTimestamp', () => {
|
|
95
|
+
it('should accept valid timestamps', () => {
|
|
96
|
+
expect(() => (0, validators_1.validateTimestamp)(Date.now())).not.toThrow();
|
|
97
|
+
expect(() => (0, validators_1.validateTimestamp)(1234567890)).not.toThrow();
|
|
98
|
+
});
|
|
99
|
+
it('should reject invalid timestamps', () => {
|
|
100
|
+
expect(() => (0, validators_1.validateTimestamp)(0)).toThrow(errors_1.ValidationError);
|
|
101
|
+
expect(() => (0, validators_1.validateTimestamp)(-1)).toThrow(errors_1.ValidationError);
|
|
102
|
+
expect(() => (0, validators_1.validateTimestamp)(Infinity)).toThrow(errors_1.ValidationError);
|
|
103
|
+
expect(() => (0, validators_1.validateTimestamp)('123')).toThrow(errors_1.ValidationError);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('validateEmoji', () => {
|
|
107
|
+
it('should accept valid emojis', () => {
|
|
108
|
+
expect(() => (0, validators_1.validateEmoji)('👍')).not.toThrow();
|
|
109
|
+
expect(() => (0, validators_1.validateEmoji)('❤️')).not.toThrow();
|
|
110
|
+
expect(() => (0, validators_1.validateEmoji)('😀')).not.toThrow();
|
|
111
|
+
});
|
|
112
|
+
it('should reject invalid emojis', () => {
|
|
113
|
+
expect(() => (0, validators_1.validateEmoji)('')).toThrow(errors_1.ValidationError);
|
|
114
|
+
expect(() => (0, validators_1.validateEmoji)('this is too long')).toThrow(errors_1.ValidationError);
|
|
115
|
+
});
|
|
116
|
+
it('should reject non-string emojis', () => {
|
|
117
|
+
expect(() => (0, validators_1.validateEmoji)(null)).toThrow(errors_1.ValidationError);
|
|
118
|
+
expect(() => (0, validators_1.validateEmoji)(123)).toThrow(errors_1.ValidationError);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
describe('validateDeviceId', () => {
|
|
122
|
+
it('should accept valid device IDs', () => {
|
|
123
|
+
expect(() => (0, validators_1.validateDeviceId)(1)).not.toThrow();
|
|
124
|
+
expect(() => (0, validators_1.validateDeviceId)(123)).not.toThrow();
|
|
125
|
+
});
|
|
126
|
+
it('should reject invalid device IDs', () => {
|
|
127
|
+
expect(() => (0, validators_1.validateDeviceId)(0)).toThrow(errors_1.ValidationError);
|
|
128
|
+
expect(() => (0, validators_1.validateDeviceId)(-1)).toThrow(errors_1.ValidationError);
|
|
129
|
+
expect(() => (0, validators_1.validateDeviceId)(1.5)).toThrow(errors_1.ValidationError);
|
|
130
|
+
expect(() => (0, validators_1.validateDeviceId)('1')).toThrow(errors_1.ValidationError);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('sanitizeInput', () => {
|
|
134
|
+
it('should remove null bytes', () => {
|
|
135
|
+
expect((0, validators_1.sanitizeInput)('hello\0world')).toBe('helloworld');
|
|
136
|
+
expect((0, validators_1.sanitizeInput)('test\0\0test')).toBe('testtest');
|
|
137
|
+
});
|
|
138
|
+
it('should handle non-string inputs', () => {
|
|
139
|
+
expect((0, validators_1.sanitizeInput)(null)).toBe('');
|
|
140
|
+
expect((0, validators_1.sanitizeInput)(undefined)).toBe('');
|
|
141
|
+
expect((0, validators_1.sanitizeInput)(123)).toBe('');
|
|
142
|
+
});
|
|
143
|
+
it('should preserve normal strings', () => {
|
|
144
|
+
expect((0, validators_1.sanitizeInput)('hello world')).toBe('hello world');
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for Signal SDK
|
|
3
|
+
* Provides centralized configuration with validation
|
|
4
|
+
*/
|
|
5
|
+
export interface SignalCliConfig {
|
|
6
|
+
/** Path to signal-cli binary */
|
|
7
|
+
signalCliPath?: string;
|
|
8
|
+
/** Signal account phone number */
|
|
9
|
+
account?: string;
|
|
10
|
+
/** Connection timeout in milliseconds */
|
|
11
|
+
connectionTimeout?: number;
|
|
12
|
+
/** Request timeout in milliseconds */
|
|
13
|
+
requestTimeout?: number;
|
|
14
|
+
/** Enable retry on failures */
|
|
15
|
+
enableRetry?: boolean;
|
|
16
|
+
/** Maximum retry attempts */
|
|
17
|
+
maxRetries?: number;
|
|
18
|
+
/** Initial retry delay in milliseconds */
|
|
19
|
+
retryDelay?: number;
|
|
20
|
+
/** Enable detailed logging */
|
|
21
|
+
verbose?: boolean;
|
|
22
|
+
/** Log file path */
|
|
23
|
+
logFile?: string;
|
|
24
|
+
/** Rate limit: max concurrent requests */
|
|
25
|
+
maxConcurrentRequests?: number;
|
|
26
|
+
/** Rate limit: minimum interval between requests (ms) */
|
|
27
|
+
minRequestInterval?: number;
|
|
28
|
+
/** Auto-reconnect on connection loss */
|
|
29
|
+
autoReconnect?: boolean;
|
|
30
|
+
/** Trust new identities mode */
|
|
31
|
+
trustNewIdentities?: 'on-first-use' | 'always' | 'never';
|
|
32
|
+
/** Disable send log (for message resending) */
|
|
33
|
+
disableSendLog?: boolean;
|
|
34
|
+
/** Daemon connection mode: json-rpc (default), unix-socket, tcp, http */
|
|
35
|
+
daemonMode?: 'json-rpc' | 'unix-socket' | 'tcp' | 'http';
|
|
36
|
+
/** Unix socket path (for unix-socket mode) */
|
|
37
|
+
socketPath?: string;
|
|
38
|
+
/** TCP host (for tcp mode) */
|
|
39
|
+
tcpHost?: string;
|
|
40
|
+
/** TCP port (for tcp or http mode) */
|
|
41
|
+
tcpPort?: number;
|
|
42
|
+
/** HTTP base URL (for http mode) */
|
|
43
|
+
httpBaseUrl?: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const DEFAULT_CONFIG: Required<Omit<SignalCliConfig, 'socketPath' | 'tcpHost' | 'tcpPort' | 'httpBaseUrl'> & {
|
|
46
|
+
socketPath: string;
|
|
47
|
+
tcpHost: string;
|
|
48
|
+
tcpPort: number;
|
|
49
|
+
httpBaseUrl: string;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Validates and merges configuration with defaults
|
|
53
|
+
* @param userConfig User-provided configuration
|
|
54
|
+
* @returns Validated configuration
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateConfig(userConfig?: SignalCliConfig): Required<SignalCliConfig>;
|
|
57
|
+
/**
|
|
58
|
+
* Logger configuration and utilities
|
|
59
|
+
*/
|
|
60
|
+
export interface LoggerConfig {
|
|
61
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
62
|
+
enableConsole: boolean;
|
|
63
|
+
enableFile: boolean;
|
|
64
|
+
filePath?: string;
|
|
65
|
+
includeTimestamp: boolean;
|
|
66
|
+
includeLevel: boolean;
|
|
67
|
+
}
|
|
68
|
+
export declare const DEFAULT_LOGGER_CONFIG: LoggerConfig;
|
|
69
|
+
/**
|
|
70
|
+
* Simple logger implementation
|
|
71
|
+
*/
|
|
72
|
+
export declare class Logger {
|
|
73
|
+
private config;
|
|
74
|
+
private levels;
|
|
75
|
+
constructor(config?: Partial<LoggerConfig>);
|
|
76
|
+
private shouldLog;
|
|
77
|
+
private format;
|
|
78
|
+
debug(message: string, data?: any): void;
|
|
79
|
+
info(message: string, data?: any): void;
|
|
80
|
+
warn(message: string, data?: any): void;
|
|
81
|
+
error(message: string, data?: any): void;
|
|
82
|
+
}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration management for Signal SDK
|
|
4
|
+
* Provides centralized configuration with validation
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Logger = exports.DEFAULT_LOGGER_CONFIG = exports.DEFAULT_CONFIG = void 0;
|
|
8
|
+
exports.validateConfig = validateConfig;
|
|
9
|
+
exports.DEFAULT_CONFIG = {
|
|
10
|
+
signalCliPath: '',
|
|
11
|
+
account: '',
|
|
12
|
+
connectionTimeout: 30000,
|
|
13
|
+
requestTimeout: 60000,
|
|
14
|
+
enableRetry: true,
|
|
15
|
+
maxRetries: 3,
|
|
16
|
+
retryDelay: 1000,
|
|
17
|
+
verbose: false,
|
|
18
|
+
logFile: '',
|
|
19
|
+
maxConcurrentRequests: 5,
|
|
20
|
+
minRequestInterval: 100,
|
|
21
|
+
autoReconnect: true,
|
|
22
|
+
trustNewIdentities: 'on-first-use',
|
|
23
|
+
disableSendLog: false,
|
|
24
|
+
daemonMode: 'json-rpc',
|
|
25
|
+
socketPath: '/tmp/signal-cli.sock',
|
|
26
|
+
tcpHost: 'localhost',
|
|
27
|
+
tcpPort: 7583,
|
|
28
|
+
httpBaseUrl: 'http://localhost:8080'
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Validates and merges configuration with defaults
|
|
32
|
+
* @param userConfig User-provided configuration
|
|
33
|
+
* @returns Validated configuration
|
|
34
|
+
*/
|
|
35
|
+
function validateConfig(userConfig = {}) {
|
|
36
|
+
const config = { ...exports.DEFAULT_CONFIG, ...userConfig };
|
|
37
|
+
// Validate numeric values
|
|
38
|
+
if (config.connectionTimeout < 0) {
|
|
39
|
+
throw new Error('connectionTimeout must be non-negative');
|
|
40
|
+
}
|
|
41
|
+
if (config.requestTimeout < 0) {
|
|
42
|
+
throw new Error('requestTimeout must be non-negative');
|
|
43
|
+
}
|
|
44
|
+
if (config.maxRetries < 0) {
|
|
45
|
+
throw new Error('maxRetries must be non-negative');
|
|
46
|
+
}
|
|
47
|
+
if (config.retryDelay < 0) {
|
|
48
|
+
throw new Error('retryDelay must be non-negative');
|
|
49
|
+
}
|
|
50
|
+
if (config.maxConcurrentRequests < 1) {
|
|
51
|
+
throw new Error('maxConcurrentRequests must be at least 1');
|
|
52
|
+
}
|
|
53
|
+
if (config.minRequestInterval < 0) {
|
|
54
|
+
throw new Error('minRequestInterval must be non-negative');
|
|
55
|
+
}
|
|
56
|
+
return config;
|
|
57
|
+
}
|
|
58
|
+
exports.DEFAULT_LOGGER_CONFIG = {
|
|
59
|
+
level: 'info',
|
|
60
|
+
enableConsole: true,
|
|
61
|
+
enableFile: false,
|
|
62
|
+
includeTimestamp: true,
|
|
63
|
+
includeLevel: true
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Simple logger implementation
|
|
67
|
+
*/
|
|
68
|
+
class Logger {
|
|
69
|
+
constructor(config = {}) {
|
|
70
|
+
this.levels = {
|
|
71
|
+
debug: 0,
|
|
72
|
+
info: 1,
|
|
73
|
+
warn: 2,
|
|
74
|
+
error: 3
|
|
75
|
+
};
|
|
76
|
+
this.config = { ...exports.DEFAULT_LOGGER_CONFIG, ...config };
|
|
77
|
+
}
|
|
78
|
+
shouldLog(level) {
|
|
79
|
+
return this.levels[level] >= this.levels[this.config.level];
|
|
80
|
+
}
|
|
81
|
+
format(level, message, data) {
|
|
82
|
+
const parts = [];
|
|
83
|
+
if (this.config.includeTimestamp) {
|
|
84
|
+
parts.push(`[${new Date().toISOString()}]`);
|
|
85
|
+
}
|
|
86
|
+
if (this.config.includeLevel) {
|
|
87
|
+
parts.push(`[${level.toUpperCase()}]`);
|
|
88
|
+
}
|
|
89
|
+
parts.push(message);
|
|
90
|
+
if (data !== undefined) {
|
|
91
|
+
parts.push(JSON.stringify(data, null, 2));
|
|
92
|
+
}
|
|
93
|
+
return parts.join(' ');
|
|
94
|
+
}
|
|
95
|
+
debug(message, data) {
|
|
96
|
+
if (this.shouldLog('debug') && this.config.enableConsole) {
|
|
97
|
+
console.debug(this.format('debug', message, data));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
info(message, data) {
|
|
101
|
+
if (this.shouldLog('info') && this.config.enableConsole) {
|
|
102
|
+
console.info(this.format('info', message, data));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
warn(message, data) {
|
|
106
|
+
if (this.shouldLog('warn') && this.config.enableConsole) {
|
|
107
|
+
console.warn(this.format('warn', message, data));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
error(message, data) {
|
|
111
|
+
if (this.shouldLog('error') && this.config.enableConsole) {
|
|
112
|
+
console.error(this.format('error', message, data));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.Logger = Logger;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for Signal SDK
|
|
3
|
+
* Provides typed errors for better error handling
|
|
4
|
+
*/
|
|
5
|
+
export declare class SignalError extends Error {
|
|
6
|
+
code?: string | undefined;
|
|
7
|
+
constructor(message: string, code?: string | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare class ConnectionError extends SignalError {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class AuthenticationError extends SignalError {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class RateLimitError extends SignalError {
|
|
16
|
+
retryAfter?: number | undefined;
|
|
17
|
+
challenge?: string | undefined;
|
|
18
|
+
constructor(message: string, retryAfter?: number | undefined, challenge?: string | undefined);
|
|
19
|
+
}
|
|
20
|
+
export declare class ValidationError extends SignalError {
|
|
21
|
+
field?: string | undefined;
|
|
22
|
+
constructor(message: string, field?: string | undefined);
|
|
23
|
+
}
|
|
24
|
+
export declare class TimeoutError extends SignalError {
|
|
25
|
+
constructor(message?: string);
|
|
26
|
+
}
|
|
27
|
+
export declare class GroupError extends SignalError {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
export declare class MessageError extends SignalError {
|
|
31
|
+
constructor(message: string);
|
|
32
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom error classes for Signal SDK
|
|
4
|
+
* Provides typed errors for better error handling
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MessageError = exports.GroupError = exports.TimeoutError = exports.ValidationError = exports.RateLimitError = exports.AuthenticationError = exports.ConnectionError = exports.SignalError = void 0;
|
|
8
|
+
class SignalError extends Error {
|
|
9
|
+
constructor(message, code) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.name = 'SignalError';
|
|
13
|
+
Object.setPrototypeOf(this, SignalError.prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.SignalError = SignalError;
|
|
17
|
+
class ConnectionError extends SignalError {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message, 'CONNECTION_ERROR');
|
|
20
|
+
this.name = 'ConnectionError';
|
|
21
|
+
Object.setPrototypeOf(this, ConnectionError.prototype);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ConnectionError = ConnectionError;
|
|
25
|
+
class AuthenticationError extends SignalError {
|
|
26
|
+
constructor(message) {
|
|
27
|
+
super(message, 'AUTH_ERROR');
|
|
28
|
+
this.name = 'AuthenticationError';
|
|
29
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.AuthenticationError = AuthenticationError;
|
|
33
|
+
class RateLimitError extends SignalError {
|
|
34
|
+
constructor(message, retryAfter, challenge) {
|
|
35
|
+
super(message, 'RATE_LIMIT');
|
|
36
|
+
this.retryAfter = retryAfter;
|
|
37
|
+
this.challenge = challenge;
|
|
38
|
+
this.name = 'RateLimitError';
|
|
39
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.RateLimitError = RateLimitError;
|
|
43
|
+
class ValidationError extends SignalError {
|
|
44
|
+
constructor(message, field) {
|
|
45
|
+
super(message, 'VALIDATION_ERROR');
|
|
46
|
+
this.field = field;
|
|
47
|
+
this.name = 'ValidationError';
|
|
48
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.ValidationError = ValidationError;
|
|
52
|
+
class TimeoutError extends SignalError {
|
|
53
|
+
constructor(message = 'Operation timed out') {
|
|
54
|
+
super(message, 'TIMEOUT');
|
|
55
|
+
this.name = 'TimeoutError';
|
|
56
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.TimeoutError = TimeoutError;
|
|
60
|
+
class GroupError extends SignalError {
|
|
61
|
+
constructor(message) {
|
|
62
|
+
super(message, 'GROUP_ERROR');
|
|
63
|
+
this.name = 'GroupError';
|
|
64
|
+
Object.setPrototypeOf(this, GroupError.prototype);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.GroupError = GroupError;
|
|
68
|
+
class MessageError extends SignalError {
|
|
69
|
+
constructor(message) {
|
|
70
|
+
super(message, 'MESSAGE_ERROR');
|
|
71
|
+
this.name = 'MessageError';
|
|
72
|
+
Object.setPrototypeOf(this, MessageError.prototype);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.MessageError = MessageError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export { SignalCli } from './SignalCli';
|
|
2
2
|
export { SignalBot } from './SignalBot';
|
|
3
|
+
export { MultiAccountManager } from './MultiAccountManager';
|
|
3
4
|
export * from './interfaces';
|
|
5
|
+
export * from './errors';
|
|
6
|
+
export * from './validators';
|
|
7
|
+
export * from './retry';
|
|
8
|
+
export * from './config';
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SignalBot = exports.SignalCli = void 0;
|
|
17
|
+
exports.MultiAccountManager = exports.SignalBot = exports.SignalCli = void 0;
|
|
18
18
|
var SignalCli_1 = require("./SignalCli");
|
|
19
19
|
Object.defineProperty(exports, "SignalCli", { enumerable: true, get: function () { return SignalCli_1.SignalCli; } });
|
|
20
20
|
var SignalBot_1 = require("./SignalBot");
|
|
21
21
|
Object.defineProperty(exports, "SignalBot", { enumerable: true, get: function () { return SignalBot_1.SignalBot; } });
|
|
22
|
+
var MultiAccountManager_1 = require("./MultiAccountManager");
|
|
23
|
+
Object.defineProperty(exports, "MultiAccountManager", { enumerable: true, get: function () { return MultiAccountManager_1.MultiAccountManager; } });
|
|
22
24
|
__exportStar(require("./interfaces"), exports);
|
|
25
|
+
__exportStar(require("./errors"), exports);
|
|
26
|
+
__exportStar(require("./validators"), exports);
|
|
27
|
+
__exportStar(require("./retry"), exports);
|
|
28
|
+
__exportStar(require("./config"), exports);
|