@narcisbodea/smstunnel-sdk 1.0.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.
@@ -0,0 +1,241 @@
1
+ interface SmsTunnelConfig {
2
+ serverUrl: string;
3
+ apiKey: string;
4
+ siteToken: string;
5
+ deviceName: string;
6
+ }
7
+ interface SmsTunnelStorageAdapter {
8
+ getConfig(): Promise<Partial<SmsTunnelConfig>>;
9
+ updateConfig(partial: Partial<SmsTunnelConfig>): Promise<void>;
10
+ clearConfig(): Promise<void>;
11
+ }
12
+ interface SmsTunnelStatus {
13
+ paired: boolean;
14
+ serverUrl?: string;
15
+ deviceName?: string;
16
+ }
17
+ interface SendSmsResult {
18
+ success: boolean;
19
+ messageId?: string;
20
+ error?: string;
21
+ }
22
+ interface CreateTokenResult {
23
+ success: boolean;
24
+ token?: string;
25
+ qrData?: string;
26
+ expiresAt?: string;
27
+ pollUrl?: string;
28
+ error?: string;
29
+ }
30
+ interface PairingStatusResult {
31
+ status: string;
32
+ displayName?: string;
33
+ error?: string;
34
+ }
35
+ interface PairingCallbackBody {
36
+ event: string;
37
+ token: string;
38
+ apiKey: string;
39
+ deviceId?: string;
40
+ deviceName?: string;
41
+ userId?: string;
42
+ }
43
+
44
+ interface SmsTunnelLabels {
45
+ title: string;
46
+ description: string;
47
+ serverUrlLabel: string;
48
+ serverUrlPlaceholder: string;
49
+ saveButton: string;
50
+ pairedStatus: string;
51
+ deviceLabel: string;
52
+ unpairButton: string;
53
+ unpairConfirm: string;
54
+ notPairedStatus: string;
55
+ notPairedDescription: string;
56
+ connectButton: string;
57
+ scanQrPrompt: string;
58
+ waitingForPairing: string;
59
+ cancelButton: string;
60
+ qrExpired: string;
61
+ testSmsTitle: string;
62
+ testPhonePlaceholder: string;
63
+ testMessagePlaceholder: string;
64
+ sendTestButton: string;
65
+ smsSentSuccess: string;
66
+ smsError: string;
67
+ }
68
+ declare const EN_LABELS: SmsTunnelLabels;
69
+ declare const RO_LABELS: SmsTunnelLabels;
70
+
71
+ /**
72
+ * Framework-agnostic SMSTunnel client.
73
+ *
74
+ * Works with Angular, Svelte, Astro, Solid, Vanilla JS, or any framework.
75
+ * For React use `smstunnel-sdk/react`, for Vue use `smstunnel-sdk/vue`.
76
+ */
77
+ interface SmsTunnelClientOptions {
78
+ apiBaseUrl: string;
79
+ getAuthHeaders?: () => Record<string, string>;
80
+ routePrefix?: string;
81
+ pollInterval?: number;
82
+ }
83
+ interface SmsTunnelStatusResponse {
84
+ paired: boolean;
85
+ serverUrl?: string;
86
+ deviceName?: string;
87
+ }
88
+ interface CreateTokenResponse {
89
+ success: boolean;
90
+ token?: string;
91
+ qrData?: string;
92
+ expiresAt?: string;
93
+ pollUrl?: string;
94
+ error?: string;
95
+ }
96
+ interface PairingStatusResponse {
97
+ status: 'pending' | 'completed' | 'expired' | 'error';
98
+ source?: string;
99
+ displayName?: string;
100
+ pairedDeviceId?: string;
101
+ pairingId?: string;
102
+ error?: string;
103
+ }
104
+ interface SendSmsResponse {
105
+ success: boolean;
106
+ messageId?: string;
107
+ queued?: boolean;
108
+ data?: {
109
+ messageId: string;
110
+ branded: boolean;
111
+ queued: boolean;
112
+ remaining: number;
113
+ };
114
+ error?: string;
115
+ }
116
+ interface SmsStatusResponse {
117
+ success: boolean;
118
+ data?: {
119
+ messageId: string;
120
+ status: 'sent' | 'pending' | 'failed' | 'delivered';
121
+ recipient: string;
122
+ sentAt?: string;
123
+ };
124
+ error?: string;
125
+ }
126
+ interface SendBulkSmsRequest {
127
+ messages: Array<{
128
+ to: string;
129
+ message: string;
130
+ }>;
131
+ }
132
+ interface SendBulkSmsResponse {
133
+ success: boolean;
134
+ results?: Array<{
135
+ to: string;
136
+ messageId?: string;
137
+ error?: string;
138
+ }>;
139
+ error?: string;
140
+ }
141
+ interface Send2faRequest {
142
+ to: string;
143
+ code: string;
144
+ template?: string;
145
+ }
146
+ interface ReceivedSmsResponse {
147
+ success: boolean;
148
+ data?: Array<{
149
+ from: string;
150
+ message: string;
151
+ receivedAt: string;
152
+ }>;
153
+ error?: string;
154
+ }
155
+ interface DevicesResponse {
156
+ success: boolean;
157
+ data?: Array<{
158
+ id: string;
159
+ clientId: string;
160
+ name: string;
161
+ brand?: string;
162
+ model?: string;
163
+ connected?: boolean;
164
+ }>;
165
+ error?: string;
166
+ }
167
+ interface AccountUsageResponse {
168
+ success: boolean;
169
+ data?: {
170
+ messagesSent: number;
171
+ messagesReceived: number;
172
+ messagesSentToday: number;
173
+ messagesSentMonth: number;
174
+ dailyLimit?: number;
175
+ monthlyLimit?: number;
176
+ };
177
+ error?: string;
178
+ }
179
+ interface PairingInfo {
180
+ _id: string;
181
+ deviceId: string;
182
+ type: string;
183
+ name: string;
184
+ status: 'active' | 'paused' | 'revoked';
185
+ messagesSent: number;
186
+ createdAt: string;
187
+ source: string;
188
+ }
189
+ type PairingEventCallback = (event: 'completed' | 'expired' | 'error', data?: any) => void;
190
+ declare class SmsTunnelClient {
191
+ private readonly baseUrl;
192
+ private readonly prefix;
193
+ private readonly pollInterval;
194
+ private readonly getAuthHeaders;
195
+ private pollTimer;
196
+ constructor(options: SmsTunnelClientOptions);
197
+ /** Get current pairing status */
198
+ getStatus(): Promise<SmsTunnelStatusResponse>;
199
+ /** Create a pairing token (generates QR data) */
200
+ createToken(): Promise<CreateTokenResponse>;
201
+ /** Check pairing status for a token (no auth needed) */
202
+ getPairingStatus(token: string): Promise<PairingStatusResponse>;
203
+ /**
204
+ * Start polling for pairing completion.
205
+ * Returns a cleanup function to stop polling.
206
+ */
207
+ startPolling(token: string, callback: PairingEventCallback): () => void;
208
+ /** Stop polling */
209
+ stopPolling(): void;
210
+ /** Unpair the connected device */
211
+ unpair(): Promise<{
212
+ success: boolean;
213
+ }>;
214
+ /** List active pairings (proxied through backend) */
215
+ getPairings(): Promise<PairingInfo[]>;
216
+ /** Send a single SMS */
217
+ sendSms(to: string, message: string): Promise<SendSmsResponse>;
218
+ /** Send a 2FA SMS */
219
+ send2fa(to: string, code: string, template?: string): Promise<SendSmsResponse>;
220
+ /** Send bulk SMS */
221
+ sendBulk(messages: Array<{
222
+ to: string;
223
+ message: string;
224
+ }>): Promise<SendBulkSmsResponse>;
225
+ /** Get SMS delivery status */
226
+ getSmsStatus(messageId: string): Promise<SmsStatusResponse>;
227
+ /** Get received SMS (inbox) */
228
+ getReceivedSms(): Promise<ReceivedSmsResponse>;
229
+ /** List paired devices */
230
+ getDevices(): Promise<DevicesResponse>;
231
+ /** Get account usage stats */
232
+ getUsage(): Promise<AccountUsageResponse>;
233
+ /** Update server URL configuration */
234
+ updateServerUrl(serverUrl: string): Promise<{
235
+ success: boolean;
236
+ }>;
237
+ /** Destroy - cleanup polling */
238
+ destroy(): void;
239
+ }
240
+
241
+ export { type AccountUsageResponse, type CreateTokenResponse, type CreateTokenResult, type DevicesResponse, EN_LABELS, type PairingCallbackBody, type PairingEventCallback, type PairingInfo, type PairingStatusResponse, type PairingStatusResult, RO_LABELS, type ReceivedSmsResponse, type Send2faRequest, type SendBulkSmsRequest, type SendBulkSmsResponse, type SendSmsResponse, type SendSmsResult, type SmsStatusResponse, SmsTunnelClient, type SmsTunnelClientOptions, type SmsTunnelConfig, type SmsTunnelLabels, type SmsTunnelStatus, type SmsTunnelStatusResponse, type SmsTunnelStorageAdapter };
@@ -0,0 +1,241 @@
1
+ interface SmsTunnelConfig {
2
+ serverUrl: string;
3
+ apiKey: string;
4
+ siteToken: string;
5
+ deviceName: string;
6
+ }
7
+ interface SmsTunnelStorageAdapter {
8
+ getConfig(): Promise<Partial<SmsTunnelConfig>>;
9
+ updateConfig(partial: Partial<SmsTunnelConfig>): Promise<void>;
10
+ clearConfig(): Promise<void>;
11
+ }
12
+ interface SmsTunnelStatus {
13
+ paired: boolean;
14
+ serverUrl?: string;
15
+ deviceName?: string;
16
+ }
17
+ interface SendSmsResult {
18
+ success: boolean;
19
+ messageId?: string;
20
+ error?: string;
21
+ }
22
+ interface CreateTokenResult {
23
+ success: boolean;
24
+ token?: string;
25
+ qrData?: string;
26
+ expiresAt?: string;
27
+ pollUrl?: string;
28
+ error?: string;
29
+ }
30
+ interface PairingStatusResult {
31
+ status: string;
32
+ displayName?: string;
33
+ error?: string;
34
+ }
35
+ interface PairingCallbackBody {
36
+ event: string;
37
+ token: string;
38
+ apiKey: string;
39
+ deviceId?: string;
40
+ deviceName?: string;
41
+ userId?: string;
42
+ }
43
+
44
+ interface SmsTunnelLabels {
45
+ title: string;
46
+ description: string;
47
+ serverUrlLabel: string;
48
+ serverUrlPlaceholder: string;
49
+ saveButton: string;
50
+ pairedStatus: string;
51
+ deviceLabel: string;
52
+ unpairButton: string;
53
+ unpairConfirm: string;
54
+ notPairedStatus: string;
55
+ notPairedDescription: string;
56
+ connectButton: string;
57
+ scanQrPrompt: string;
58
+ waitingForPairing: string;
59
+ cancelButton: string;
60
+ qrExpired: string;
61
+ testSmsTitle: string;
62
+ testPhonePlaceholder: string;
63
+ testMessagePlaceholder: string;
64
+ sendTestButton: string;
65
+ smsSentSuccess: string;
66
+ smsError: string;
67
+ }
68
+ declare const EN_LABELS: SmsTunnelLabels;
69
+ declare const RO_LABELS: SmsTunnelLabels;
70
+
71
+ /**
72
+ * Framework-agnostic SMSTunnel client.
73
+ *
74
+ * Works with Angular, Svelte, Astro, Solid, Vanilla JS, or any framework.
75
+ * For React use `smstunnel-sdk/react`, for Vue use `smstunnel-sdk/vue`.
76
+ */
77
+ interface SmsTunnelClientOptions {
78
+ apiBaseUrl: string;
79
+ getAuthHeaders?: () => Record<string, string>;
80
+ routePrefix?: string;
81
+ pollInterval?: number;
82
+ }
83
+ interface SmsTunnelStatusResponse {
84
+ paired: boolean;
85
+ serverUrl?: string;
86
+ deviceName?: string;
87
+ }
88
+ interface CreateTokenResponse {
89
+ success: boolean;
90
+ token?: string;
91
+ qrData?: string;
92
+ expiresAt?: string;
93
+ pollUrl?: string;
94
+ error?: string;
95
+ }
96
+ interface PairingStatusResponse {
97
+ status: 'pending' | 'completed' | 'expired' | 'error';
98
+ source?: string;
99
+ displayName?: string;
100
+ pairedDeviceId?: string;
101
+ pairingId?: string;
102
+ error?: string;
103
+ }
104
+ interface SendSmsResponse {
105
+ success: boolean;
106
+ messageId?: string;
107
+ queued?: boolean;
108
+ data?: {
109
+ messageId: string;
110
+ branded: boolean;
111
+ queued: boolean;
112
+ remaining: number;
113
+ };
114
+ error?: string;
115
+ }
116
+ interface SmsStatusResponse {
117
+ success: boolean;
118
+ data?: {
119
+ messageId: string;
120
+ status: 'sent' | 'pending' | 'failed' | 'delivered';
121
+ recipient: string;
122
+ sentAt?: string;
123
+ };
124
+ error?: string;
125
+ }
126
+ interface SendBulkSmsRequest {
127
+ messages: Array<{
128
+ to: string;
129
+ message: string;
130
+ }>;
131
+ }
132
+ interface SendBulkSmsResponse {
133
+ success: boolean;
134
+ results?: Array<{
135
+ to: string;
136
+ messageId?: string;
137
+ error?: string;
138
+ }>;
139
+ error?: string;
140
+ }
141
+ interface Send2faRequest {
142
+ to: string;
143
+ code: string;
144
+ template?: string;
145
+ }
146
+ interface ReceivedSmsResponse {
147
+ success: boolean;
148
+ data?: Array<{
149
+ from: string;
150
+ message: string;
151
+ receivedAt: string;
152
+ }>;
153
+ error?: string;
154
+ }
155
+ interface DevicesResponse {
156
+ success: boolean;
157
+ data?: Array<{
158
+ id: string;
159
+ clientId: string;
160
+ name: string;
161
+ brand?: string;
162
+ model?: string;
163
+ connected?: boolean;
164
+ }>;
165
+ error?: string;
166
+ }
167
+ interface AccountUsageResponse {
168
+ success: boolean;
169
+ data?: {
170
+ messagesSent: number;
171
+ messagesReceived: number;
172
+ messagesSentToday: number;
173
+ messagesSentMonth: number;
174
+ dailyLimit?: number;
175
+ monthlyLimit?: number;
176
+ };
177
+ error?: string;
178
+ }
179
+ interface PairingInfo {
180
+ _id: string;
181
+ deviceId: string;
182
+ type: string;
183
+ name: string;
184
+ status: 'active' | 'paused' | 'revoked';
185
+ messagesSent: number;
186
+ createdAt: string;
187
+ source: string;
188
+ }
189
+ type PairingEventCallback = (event: 'completed' | 'expired' | 'error', data?: any) => void;
190
+ declare class SmsTunnelClient {
191
+ private readonly baseUrl;
192
+ private readonly prefix;
193
+ private readonly pollInterval;
194
+ private readonly getAuthHeaders;
195
+ private pollTimer;
196
+ constructor(options: SmsTunnelClientOptions);
197
+ /** Get current pairing status */
198
+ getStatus(): Promise<SmsTunnelStatusResponse>;
199
+ /** Create a pairing token (generates QR data) */
200
+ createToken(): Promise<CreateTokenResponse>;
201
+ /** Check pairing status for a token (no auth needed) */
202
+ getPairingStatus(token: string): Promise<PairingStatusResponse>;
203
+ /**
204
+ * Start polling for pairing completion.
205
+ * Returns a cleanup function to stop polling.
206
+ */
207
+ startPolling(token: string, callback: PairingEventCallback): () => void;
208
+ /** Stop polling */
209
+ stopPolling(): void;
210
+ /** Unpair the connected device */
211
+ unpair(): Promise<{
212
+ success: boolean;
213
+ }>;
214
+ /** List active pairings (proxied through backend) */
215
+ getPairings(): Promise<PairingInfo[]>;
216
+ /** Send a single SMS */
217
+ sendSms(to: string, message: string): Promise<SendSmsResponse>;
218
+ /** Send a 2FA SMS */
219
+ send2fa(to: string, code: string, template?: string): Promise<SendSmsResponse>;
220
+ /** Send bulk SMS */
221
+ sendBulk(messages: Array<{
222
+ to: string;
223
+ message: string;
224
+ }>): Promise<SendBulkSmsResponse>;
225
+ /** Get SMS delivery status */
226
+ getSmsStatus(messageId: string): Promise<SmsStatusResponse>;
227
+ /** Get received SMS (inbox) */
228
+ getReceivedSms(): Promise<ReceivedSmsResponse>;
229
+ /** List paired devices */
230
+ getDevices(): Promise<DevicesResponse>;
231
+ /** Get account usage stats */
232
+ getUsage(): Promise<AccountUsageResponse>;
233
+ /** Update server URL configuration */
234
+ updateServerUrl(serverUrl: string): Promise<{
235
+ success: boolean;
236
+ }>;
237
+ /** Destroy - cleanup polling */
238
+ destroy(): void;
239
+ }
240
+
241
+ export { type AccountUsageResponse, type CreateTokenResponse, type CreateTokenResult, type DevicesResponse, EN_LABELS, type PairingCallbackBody, type PairingEventCallback, type PairingInfo, type PairingStatusResponse, type PairingStatusResult, RO_LABELS, type ReceivedSmsResponse, type Send2faRequest, type SendBulkSmsRequest, type SendBulkSmsResponse, type SendSmsResponse, type SendSmsResult, type SmsStatusResponse, SmsTunnelClient, type SmsTunnelClientOptions, type SmsTunnelConfig, type SmsTunnelLabels, type SmsTunnelStatus, type SmsTunnelStatusResponse, type SmsTunnelStorageAdapter };