@wazzapi/wazzapi 0.2.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.
- package/README.md +232 -0
- package/advanced-examples/custom-fetch.ts +40 -0
- package/advanced-examples/download-media.ts +27 -0
- package/advanced-examples/http-webhook-server.ts +80 -0
- package/dist/index.cjs +1550 -0
- package/dist/index.d.cts +1012 -0
- package/dist/index.d.ts +1012 -0
- package/dist/index.js +1461 -0
- package/docs/README.md +61 -0
- package/docs/authentication.md +37 -0
- package/docs/client.md +68 -0
- package/docs/contacts.md +194 -0
- package/docs/errors.md +57 -0
- package/docs/groups.md +233 -0
- package/docs/media.md +38 -0
- package/docs/messages.md +151 -0
- package/docs/templates.md +76 -0
- package/docs/webhooks.md +101 -0
- package/examples/create-template.ts +10 -0
- package/examples/list-contacts.ts +8 -0
- package/examples/preview-template.ts +9 -0
- package/examples/send-message.ts +10 -0
- package/examples/verify-webhook.ts +33 -0
- package/package.json +57 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1461 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/errors.ts
|
|
8
|
+
var WazzapiError = class extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "WazzapiError";
|
|
12
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var WazzapiAPIError = class _WazzapiAPIError extends WazzapiError {
|
|
16
|
+
constructor(statusCode, message, options) {
|
|
17
|
+
super(`WazzAPI API error ${statusCode}: ${message}`);
|
|
18
|
+
this.name = "WazzapiAPIError";
|
|
19
|
+
this.statusCode = statusCode;
|
|
20
|
+
this.message = message;
|
|
21
|
+
this.details = options?.details;
|
|
22
|
+
this.responseText = options?.responseText;
|
|
23
|
+
}
|
|
24
|
+
static fromResponseParts(statusCode, reasonPhrase, responseText, payload) {
|
|
25
|
+
let details;
|
|
26
|
+
let message = reasonPhrase || "Request failed";
|
|
27
|
+
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
|
|
28
|
+
const normalizedPayload = payload;
|
|
29
|
+
details = normalizedPayload.detail === void 0 ? payload : normalizedPayload.detail;
|
|
30
|
+
if (typeof details === "string") {
|
|
31
|
+
message = details;
|
|
32
|
+
} else if (Array.isArray(details) && details.length > 0) {
|
|
33
|
+
const firstItem = details[0];
|
|
34
|
+
if (firstItem && typeof firstItem === "object" && "msg" in firstItem && typeof firstItem.msg === "string") {
|
|
35
|
+
message = firstItem.msg;
|
|
36
|
+
} else {
|
|
37
|
+
message = formatErrorMessage(firstItem);
|
|
38
|
+
}
|
|
39
|
+
} else if (normalizedPayload.message !== void 0) {
|
|
40
|
+
message = formatErrorMessage(normalizedPayload.message);
|
|
41
|
+
}
|
|
42
|
+
} else if (payload !== void 0) {
|
|
43
|
+
details = payload;
|
|
44
|
+
message = formatErrorMessage(payload);
|
|
45
|
+
}
|
|
46
|
+
return new _WazzapiAPIError(statusCode, message, {
|
|
47
|
+
details,
|
|
48
|
+
responseText
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function formatErrorMessage(value) {
|
|
53
|
+
if (typeof value === "string") {
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
if (value === void 0 || value === null) {
|
|
57
|
+
return "Request failed";
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const serialized = JSON.stringify(value);
|
|
61
|
+
return serialized ?? "Request failed";
|
|
62
|
+
} catch {
|
|
63
|
+
return "Request failed";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
var WazzapiMediaError = class extends WazzapiError {
|
|
67
|
+
constructor(message) {
|
|
68
|
+
super(message);
|
|
69
|
+
this.name = "WazzapiMediaError";
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/models/base.ts
|
|
74
|
+
function cloneObject(input) {
|
|
75
|
+
if (!input || typeof input !== "object") {
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
const output = {};
|
|
79
|
+
Object.entries(input).forEach(([key, value]) => {
|
|
80
|
+
output[key] = value;
|
|
81
|
+
});
|
|
82
|
+
return output;
|
|
83
|
+
}
|
|
84
|
+
function withDateFields(input, fields) {
|
|
85
|
+
const output = cloneObject(input);
|
|
86
|
+
const mutableOutput = output;
|
|
87
|
+
fields.forEach((field) => {
|
|
88
|
+
if (mutableOutput[field] !== void 0 && mutableOutput[field] !== null) {
|
|
89
|
+
mutableOutput[field] = new Date(
|
|
90
|
+
mutableOutput[field]
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return output;
|
|
95
|
+
}
|
|
96
|
+
function mapArray(value, parser) {
|
|
97
|
+
if (!Array.isArray(value)) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
return value.map((item) => parser(item));
|
|
101
|
+
}
|
|
102
|
+
function serializeData(value) {
|
|
103
|
+
if (value === void 0 || value === null) {
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
if (value instanceof Date) {
|
|
107
|
+
return value.toISOString();
|
|
108
|
+
}
|
|
109
|
+
if (Buffer.isBuffer(value) || value instanceof Uint8Array) {
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
if (Array.isArray(value)) {
|
|
113
|
+
return value.map((item) => serializeData(item)).filter((item) => item !== void 0);
|
|
114
|
+
}
|
|
115
|
+
if (typeof value === "object") {
|
|
116
|
+
const output = {};
|
|
117
|
+
Object.entries(value).forEach(([key, rawValue]) => {
|
|
118
|
+
const serialized = serializeData(rawValue);
|
|
119
|
+
if (serialized !== void 0) {
|
|
120
|
+
output[key] = serialized;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return output;
|
|
124
|
+
}
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
function filterNone(data) {
|
|
128
|
+
if (!data) {
|
|
129
|
+
return void 0;
|
|
130
|
+
}
|
|
131
|
+
const output = {};
|
|
132
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
133
|
+
if (value !== void 0 && value !== null) {
|
|
134
|
+
output[key] = value;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return output;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/resources/base.ts
|
|
141
|
+
var BaseResource = class {
|
|
142
|
+
constructor(client) {
|
|
143
|
+
this._client = client;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/models/index.ts
|
|
148
|
+
var models_exports = {};
|
|
149
|
+
__export(models_exports, {
|
|
150
|
+
parseAddToGroupResponse: () => parseAddToGroupResponse,
|
|
151
|
+
parseBuiltinVariableInfo: () => parseBuiltinVariableInfo,
|
|
152
|
+
parseBuiltinVariablesResponse: () => parseBuiltinVariablesResponse,
|
|
153
|
+
parseBulkDeleteResponse: () => parseBulkDeleteResponse,
|
|
154
|
+
parseCSVExportResponse: () => parseCSVExportResponse,
|
|
155
|
+
parseCSVImportResponse: () => parseCSVImportResponse,
|
|
156
|
+
parseCancelMessageResponse: () => parseCancelMessageResponse,
|
|
157
|
+
parseContactGroupItem: () => parseContactGroupItem,
|
|
158
|
+
parseContactGroupListResponse: () => parseContactGroupListResponse,
|
|
159
|
+
parseContactGroupMembersResponse: () => parseContactGroupMembersResponse,
|
|
160
|
+
parseContactItem: () => parseContactItem,
|
|
161
|
+
parseContactListResponse: () => parseContactListResponse,
|
|
162
|
+
parseContactResponse: () => parseContactResponse,
|
|
163
|
+
parseContactSyncHistoryItem: () => parseContactSyncHistoryItem,
|
|
164
|
+
parseContactSyncHistoryResponse: () => parseContactSyncHistoryResponse,
|
|
165
|
+
parseContactSyncResponse: () => parseContactSyncResponse,
|
|
166
|
+
parseContactSyncStatusResponse: () => parseContactSyncStatusResponse,
|
|
167
|
+
parseContactSyncStatusResponseList: () => parseContactSyncStatusResponseList,
|
|
168
|
+
parseCreateGroupResponseModel: () => parseCreateGroupResponseModel,
|
|
169
|
+
parseGroupDetailResponse: () => parseGroupDetailResponse,
|
|
170
|
+
parseGroupInviteInfoResponseModel: () => parseGroupInviteInfoResponseModel,
|
|
171
|
+
parseGroupInviteLinkResponseModel: () => parseGroupInviteLinkResponseModel,
|
|
172
|
+
parseGroupListItem: () => parseGroupListItem,
|
|
173
|
+
parseGroupListResponse: () => parseGroupListResponse,
|
|
174
|
+
parseGroupOperationResponseModel: () => parseGroupOperationResponseModel,
|
|
175
|
+
parseGroupParticipantItem: () => parseGroupParticipantItem,
|
|
176
|
+
parseGroupParticipantsResponse: () => parseGroupParticipantsResponse,
|
|
177
|
+
parseInteractiveButton: () => parseInteractiveButton,
|
|
178
|
+
parseInteractiveMessageResponse: () => parseInteractiveMessageResponse,
|
|
179
|
+
parseInteractiveRow: () => parseInteractiveRow,
|
|
180
|
+
parseInteractiveSection: () => parseInteractiveSection,
|
|
181
|
+
parseMediaDownloadResult: () => parseMediaDownloadResult,
|
|
182
|
+
parseMessageItem: () => parseMessageItem,
|
|
183
|
+
parseMessageListResponse: () => parseMessageListResponse,
|
|
184
|
+
parseMessageResponse: () => parseMessageResponse,
|
|
185
|
+
parseMessageStatsResponse: () => parseMessageStatsResponse,
|
|
186
|
+
parsePublicDeviceWebhook: () => parsePublicDeviceWebhook,
|
|
187
|
+
parsePublicMessageWebhook: () => parsePublicMessageWebhook,
|
|
188
|
+
parsePublicWebhookDeviceData: () => parsePublicWebhookDeviceData,
|
|
189
|
+
parsePublicWebhookMessageData: () => parsePublicWebhookMessageData,
|
|
190
|
+
parseRetryMessageResponse: () => parseRetryMessageResponse,
|
|
191
|
+
parseSendGroupResponse: () => parseSendGroupResponse,
|
|
192
|
+
parseSendMessageResponse: () => parseSendMessageResponse,
|
|
193
|
+
parseTemplateItem: () => parseTemplateItem,
|
|
194
|
+
parseTemplateListResponse: () => parseTemplateListResponse,
|
|
195
|
+
parseTemplatePreviewResponse: () => parseTemplatePreviewResponse,
|
|
196
|
+
parseTemplateResponse: () => parseTemplateResponse,
|
|
197
|
+
parseWebhookPayload: () => parseWebhookPayload
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// src/models/contacts.ts
|
|
201
|
+
function parseAddToGroupResponse(input) {
|
|
202
|
+
return cloneObject(input);
|
|
203
|
+
}
|
|
204
|
+
function parseBulkDeleteResponse(input) {
|
|
205
|
+
return cloneObject(input);
|
|
206
|
+
}
|
|
207
|
+
function parseCSVExportResponse(input) {
|
|
208
|
+
return cloneObject(input);
|
|
209
|
+
}
|
|
210
|
+
function parseCSVImportResponse(input) {
|
|
211
|
+
const output = cloneObject(input);
|
|
212
|
+
if (!Array.isArray(output.errors)) {
|
|
213
|
+
output.errors = [];
|
|
214
|
+
}
|
|
215
|
+
return output;
|
|
216
|
+
}
|
|
217
|
+
function parseContactGroupItem(input) {
|
|
218
|
+
return withDateFields(input, ["created_at"]);
|
|
219
|
+
}
|
|
220
|
+
function parseContactGroupListResponse(input) {
|
|
221
|
+
const output = cloneObject(input);
|
|
222
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
223
|
+
output.groups = mapArray(typedInput?.groups, parseContactGroupItem);
|
|
224
|
+
return output;
|
|
225
|
+
}
|
|
226
|
+
function parseContactItem(input) {
|
|
227
|
+
const output = withDateFields(input, [
|
|
228
|
+
"last_message_at",
|
|
229
|
+
"created_at"
|
|
230
|
+
]);
|
|
231
|
+
if (!Array.isArray(output.tags)) {
|
|
232
|
+
output.tags = [];
|
|
233
|
+
}
|
|
234
|
+
return output;
|
|
235
|
+
}
|
|
236
|
+
function parseContactGroupMembersResponse(input) {
|
|
237
|
+
const output = cloneObject(input);
|
|
238
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
239
|
+
output.group = parseContactGroupItem(typedInput?.group);
|
|
240
|
+
output.contacts = mapArray(typedInput?.contacts, parseContactItem);
|
|
241
|
+
return output;
|
|
242
|
+
}
|
|
243
|
+
function parseContactListResponse(input) {
|
|
244
|
+
const output = cloneObject(input);
|
|
245
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
246
|
+
output.contacts = mapArray(typedInput?.contacts, parseContactItem);
|
|
247
|
+
return output;
|
|
248
|
+
}
|
|
249
|
+
function parseContactResponse(input) {
|
|
250
|
+
const output = withDateFields(input, [
|
|
251
|
+
"opted_out_at",
|
|
252
|
+
"last_message_at",
|
|
253
|
+
"created_at",
|
|
254
|
+
"updated_at"
|
|
255
|
+
]);
|
|
256
|
+
if (!Array.isArray(output.tags)) {
|
|
257
|
+
output.tags = [];
|
|
258
|
+
}
|
|
259
|
+
return output;
|
|
260
|
+
}
|
|
261
|
+
function parseContactSyncHistoryItem(input) {
|
|
262
|
+
return withDateFields(input, [
|
|
263
|
+
"started_at",
|
|
264
|
+
"completed_at"
|
|
265
|
+
]);
|
|
266
|
+
}
|
|
267
|
+
function parseContactSyncHistoryResponse(input) {
|
|
268
|
+
const output = cloneObject(input);
|
|
269
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
270
|
+
output.history = mapArray(typedInput?.history, parseContactSyncHistoryItem);
|
|
271
|
+
return output;
|
|
272
|
+
}
|
|
273
|
+
function parseContactSyncResponse(input) {
|
|
274
|
+
return cloneObject(input);
|
|
275
|
+
}
|
|
276
|
+
function parseContactSyncStatusResponse(input) {
|
|
277
|
+
return withDateFields(input, ["last_sync_at"]);
|
|
278
|
+
}
|
|
279
|
+
function parseContactSyncStatusResponseList(input) {
|
|
280
|
+
return mapArray(input, parseContactSyncStatusResponse);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// src/models/groups.ts
|
|
284
|
+
function parseGroupListItem(input) {
|
|
285
|
+
const output = cloneObject(input);
|
|
286
|
+
output.participants_count ?? (output.participants_count = 0);
|
|
287
|
+
return output;
|
|
288
|
+
}
|
|
289
|
+
function parseGroupListResponse(input) {
|
|
290
|
+
const output = cloneObject(input);
|
|
291
|
+
output.groups = mapArray(
|
|
292
|
+
input?.groups,
|
|
293
|
+
parseGroupListItem
|
|
294
|
+
);
|
|
295
|
+
return output;
|
|
296
|
+
}
|
|
297
|
+
function parseGroupDetailResponse(input) {
|
|
298
|
+
const output = cloneObject(input);
|
|
299
|
+
output.participants_count ?? (output.participants_count = 0);
|
|
300
|
+
return output;
|
|
301
|
+
}
|
|
302
|
+
function parseGroupParticipantItem(input) {
|
|
303
|
+
const output = cloneObject(input);
|
|
304
|
+
output.is_admin ?? (output.is_admin = false);
|
|
305
|
+
output.is_super_admin ?? (output.is_super_admin = false);
|
|
306
|
+
return output;
|
|
307
|
+
}
|
|
308
|
+
function parseGroupParticipantsResponse(input) {
|
|
309
|
+
const output = cloneObject(input);
|
|
310
|
+
output.participants = mapArray(
|
|
311
|
+
input?.participants,
|
|
312
|
+
parseGroupParticipantItem
|
|
313
|
+
);
|
|
314
|
+
return output;
|
|
315
|
+
}
|
|
316
|
+
function parseGroupOperationResponseModel(input) {
|
|
317
|
+
return cloneObject(input);
|
|
318
|
+
}
|
|
319
|
+
function parseCreateGroupResponseModel(input) {
|
|
320
|
+
return cloneObject(input);
|
|
321
|
+
}
|
|
322
|
+
function parseSendGroupResponse(input) {
|
|
323
|
+
return cloneObject(input);
|
|
324
|
+
}
|
|
325
|
+
function parseGroupInviteLinkResponseModel(input) {
|
|
326
|
+
return cloneObject(input);
|
|
327
|
+
}
|
|
328
|
+
function parseGroupInviteInfoResponseModel(input) {
|
|
329
|
+
const output = cloneObject(input);
|
|
330
|
+
output.participants ?? (output.participants = 0);
|
|
331
|
+
return output;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/models/media.ts
|
|
335
|
+
function parseMediaDownloadResult(input) {
|
|
336
|
+
return cloneObject(input);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/models/messages.ts
|
|
340
|
+
function parseInteractiveButton(input) {
|
|
341
|
+
return cloneObject(input);
|
|
342
|
+
}
|
|
343
|
+
function parseCancelMessageResponse(input) {
|
|
344
|
+
return cloneObject(input);
|
|
345
|
+
}
|
|
346
|
+
function parseInteractiveMessageResponse(input) {
|
|
347
|
+
return cloneObject(input);
|
|
348
|
+
}
|
|
349
|
+
function parseInteractiveRow(input) {
|
|
350
|
+
return cloneObject(input);
|
|
351
|
+
}
|
|
352
|
+
function parseInteractiveSection(input) {
|
|
353
|
+
const output = cloneObject(input);
|
|
354
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
355
|
+
output.rows = mapArray(typedInput?.rows, parseInteractiveRow);
|
|
356
|
+
return output;
|
|
357
|
+
}
|
|
358
|
+
function parseMessageItem(input) {
|
|
359
|
+
const output = withDateFields(input, [
|
|
360
|
+
"scheduled_for",
|
|
361
|
+
"created_at",
|
|
362
|
+
"sent_at",
|
|
363
|
+
"delivered_at",
|
|
364
|
+
"read_at"
|
|
365
|
+
]);
|
|
366
|
+
output.message_type ?? (output.message_type = "text");
|
|
367
|
+
return output;
|
|
368
|
+
}
|
|
369
|
+
function parseMessageListResponse(input) {
|
|
370
|
+
const output = cloneObject(input);
|
|
371
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
372
|
+
output.messages = mapArray(typedInput?.messages, parseMessageItem);
|
|
373
|
+
return output;
|
|
374
|
+
}
|
|
375
|
+
function parseMessageResponse(input) {
|
|
376
|
+
const output = withDateFields(input, [
|
|
377
|
+
"scheduled_for",
|
|
378
|
+
"queued_at",
|
|
379
|
+
"sent_at",
|
|
380
|
+
"delivered_at",
|
|
381
|
+
"read_at",
|
|
382
|
+
"failed_at",
|
|
383
|
+
"created_at",
|
|
384
|
+
"updated_at"
|
|
385
|
+
]);
|
|
386
|
+
output.message_type ?? (output.message_type = "text");
|
|
387
|
+
return output;
|
|
388
|
+
}
|
|
389
|
+
function parseMessageStatsResponse(input) {
|
|
390
|
+
return cloneObject(input);
|
|
391
|
+
}
|
|
392
|
+
function parseRetryMessageResponse(input) {
|
|
393
|
+
return cloneObject(input);
|
|
394
|
+
}
|
|
395
|
+
function parseSendMessageResponse(input) {
|
|
396
|
+
return cloneObject(input);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// src/models/templates.ts
|
|
400
|
+
function parseBuiltinVariableInfo(input) {
|
|
401
|
+
return cloneObject(input);
|
|
402
|
+
}
|
|
403
|
+
function parseBuiltinVariablesResponse(input) {
|
|
404
|
+
const output = cloneObject(input);
|
|
405
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
406
|
+
output.variables = mapArray(typedInput?.variables, parseBuiltinVariableInfo);
|
|
407
|
+
return output;
|
|
408
|
+
}
|
|
409
|
+
function parseTemplateItem(input) {
|
|
410
|
+
const output = withDateFields(input, [
|
|
411
|
+
"last_used_at",
|
|
412
|
+
"created_at"
|
|
413
|
+
]);
|
|
414
|
+
if (!Array.isArray(output.variables)) {
|
|
415
|
+
output.variables = [];
|
|
416
|
+
}
|
|
417
|
+
if (!Array.isArray(output.builtin_variables)) {
|
|
418
|
+
output.builtin_variables = [];
|
|
419
|
+
}
|
|
420
|
+
if (!Array.isArray(output.custom_variables)) {
|
|
421
|
+
output.custom_variables = [];
|
|
422
|
+
}
|
|
423
|
+
return output;
|
|
424
|
+
}
|
|
425
|
+
function parseTemplateListResponse(input) {
|
|
426
|
+
const output = cloneObject(input);
|
|
427
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
428
|
+
output.data = mapArray(typedInput?.data, parseTemplateItem);
|
|
429
|
+
return output;
|
|
430
|
+
}
|
|
431
|
+
function parseTemplatePreviewResponse(input) {
|
|
432
|
+
const output = cloneObject(input);
|
|
433
|
+
if (!Array.isArray(output.all_variables)) {
|
|
434
|
+
output.all_variables = [];
|
|
435
|
+
}
|
|
436
|
+
if (!Array.isArray(output.builtin_variables)) {
|
|
437
|
+
output.builtin_variables = [];
|
|
438
|
+
}
|
|
439
|
+
if (!Array.isArray(output.custom_variables)) {
|
|
440
|
+
output.custom_variables = [];
|
|
441
|
+
}
|
|
442
|
+
if (!Array.isArray(output.missing_variables)) {
|
|
443
|
+
output.missing_variables = [];
|
|
444
|
+
}
|
|
445
|
+
return output;
|
|
446
|
+
}
|
|
447
|
+
function parseTemplateResponse(input) {
|
|
448
|
+
const output = withDateFields(input, [
|
|
449
|
+
"last_used_at",
|
|
450
|
+
"created_at",
|
|
451
|
+
"updated_at"
|
|
452
|
+
]);
|
|
453
|
+
if (!Array.isArray(output.variables)) {
|
|
454
|
+
output.variables = [];
|
|
455
|
+
}
|
|
456
|
+
if (!Array.isArray(output.builtin_variables)) {
|
|
457
|
+
output.builtin_variables = [];
|
|
458
|
+
}
|
|
459
|
+
if (!Array.isArray(output.custom_variables)) {
|
|
460
|
+
output.custom_variables = [];
|
|
461
|
+
}
|
|
462
|
+
return output;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// src/models/webhooks.ts
|
|
466
|
+
function parsePublicWebhookMessageData(input) {
|
|
467
|
+
return withDateFields(input, [
|
|
468
|
+
"sent_at",
|
|
469
|
+
"delivered_at",
|
|
470
|
+
"read_at",
|
|
471
|
+
"failed_at"
|
|
472
|
+
]);
|
|
473
|
+
}
|
|
474
|
+
function parsePublicWebhookDeviceData(input) {
|
|
475
|
+
return withDateFields(input, [
|
|
476
|
+
"sent_at",
|
|
477
|
+
"delivered_at",
|
|
478
|
+
"read_at",
|
|
479
|
+
"failed_at"
|
|
480
|
+
]);
|
|
481
|
+
}
|
|
482
|
+
function parsePublicMessageWebhook(input) {
|
|
483
|
+
const output = withDateFields(input, ["timestamp"]);
|
|
484
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
485
|
+
output.data = parsePublicWebhookMessageData(typedInput?.data);
|
|
486
|
+
return output;
|
|
487
|
+
}
|
|
488
|
+
function parsePublicDeviceWebhook(input) {
|
|
489
|
+
const output = withDateFields(input, ["timestamp"]);
|
|
490
|
+
const typedInput = typeof input === "object" && input ? input : void 0;
|
|
491
|
+
output.data = parsePublicWebhookDeviceData(typedInput?.data);
|
|
492
|
+
return output;
|
|
493
|
+
}
|
|
494
|
+
function parseWebhookPayload(input) {
|
|
495
|
+
const output = cloneObject(input);
|
|
496
|
+
if (typeof output.event_type !== "string") {
|
|
497
|
+
const error = new TypeError("Webhook payload is missing event_type");
|
|
498
|
+
throw error;
|
|
499
|
+
}
|
|
500
|
+
if (output.event_type.startsWith("message.")) {
|
|
501
|
+
return parsePublicMessageWebhook(output);
|
|
502
|
+
}
|
|
503
|
+
if (output.event_type.startsWith("device.")) {
|
|
504
|
+
return parsePublicDeviceWebhook(output);
|
|
505
|
+
}
|
|
506
|
+
throw new TypeError(`Unsupported webhook event type: ${output.event_type}`);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// src/resources/contacts.ts
|
|
510
|
+
var ContactsResource = class extends BaseResource {
|
|
511
|
+
async list(options) {
|
|
512
|
+
return this._client._request("GET", "/api/v1/contacts", {
|
|
513
|
+
params: options,
|
|
514
|
+
responseParser: parseContactListResponse
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
async create(payload) {
|
|
518
|
+
return this._client._request("POST", "/api/v1/contacts", {
|
|
519
|
+
jsonBody: payload,
|
|
520
|
+
responseParser: parseContactResponse
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
async bulkDelete(payload) {
|
|
524
|
+
return this._client._request("POST", "/api/v1/contacts/bulk-delete", {
|
|
525
|
+
jsonBody: payload,
|
|
526
|
+
responseParser: parseBulkDeleteResponse
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
async bulk_delete(payload) {
|
|
530
|
+
return this.bulkDelete(payload);
|
|
531
|
+
}
|
|
532
|
+
async listGroups(options) {
|
|
533
|
+
return this._client._request("GET", "/api/v1/contacts/groups", {
|
|
534
|
+
params: options,
|
|
535
|
+
responseParser: parseContactGroupListResponse
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
async list_groups(options) {
|
|
539
|
+
return this.listGroups(options);
|
|
540
|
+
}
|
|
541
|
+
async createGroup(payload) {
|
|
542
|
+
return this._client._request("POST", "/api/v1/contacts/groups", {
|
|
543
|
+
jsonBody: payload,
|
|
544
|
+
responseParser: parseContactGroupItem
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
async create_group(payload) {
|
|
548
|
+
return this.createGroup(payload);
|
|
549
|
+
}
|
|
550
|
+
async getGroup(groupId, options) {
|
|
551
|
+
return this._client._request("GET", `/api/v1/contacts/groups/${groupId}`, {
|
|
552
|
+
params: options,
|
|
553
|
+
responseParser: parseContactGroupMembersResponse
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
async get_group(groupId, options) {
|
|
557
|
+
return this.getGroup(groupId, options);
|
|
558
|
+
}
|
|
559
|
+
async updateGroup(groupId, payload) {
|
|
560
|
+
return this._client._request(
|
|
561
|
+
"PATCH",
|
|
562
|
+
`/api/v1/contacts/groups/${groupId}`,
|
|
563
|
+
{
|
|
564
|
+
jsonBody: payload,
|
|
565
|
+
responseParser: parseContactGroupItem
|
|
566
|
+
}
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
async update_group(groupId, payload) {
|
|
570
|
+
return this.updateGroup(groupId, payload);
|
|
571
|
+
}
|
|
572
|
+
async deleteGroup(groupId) {
|
|
573
|
+
await this._client._request("DELETE", `/api/v1/contacts/groups/${groupId}`);
|
|
574
|
+
}
|
|
575
|
+
async delete_group(groupId) {
|
|
576
|
+
return this.deleteGroup(groupId);
|
|
577
|
+
}
|
|
578
|
+
async addToGroup(groupId, payload) {
|
|
579
|
+
return this._client._request(
|
|
580
|
+
"POST",
|
|
581
|
+
`/api/v1/contacts/groups/${groupId}/members`,
|
|
582
|
+
{
|
|
583
|
+
jsonBody: payload,
|
|
584
|
+
responseParser: parseAddToGroupResponse
|
|
585
|
+
}
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
async add_to_group(groupId, payload) {
|
|
589
|
+
return this.addToGroup(groupId, payload);
|
|
590
|
+
}
|
|
591
|
+
async removeFromGroup(groupId, payload) {
|
|
592
|
+
return this._client._request(
|
|
593
|
+
"DELETE",
|
|
594
|
+
`/api/v1/contacts/groups/${groupId}/members`,
|
|
595
|
+
{
|
|
596
|
+
jsonBody: payload,
|
|
597
|
+
responseParser: parseAddToGroupResponse
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
async remove_from_group(groupId, payload) {
|
|
602
|
+
return this.removeFromGroup(groupId, payload);
|
|
603
|
+
}
|
|
604
|
+
async importCsv(payload) {
|
|
605
|
+
return this._client._request("POST", "/api/v1/contacts/import/csv", {
|
|
606
|
+
jsonBody: payload,
|
|
607
|
+
responseParser: parseCSVImportResponse
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
async import_csv(payload) {
|
|
611
|
+
return this.importCsv(payload);
|
|
612
|
+
}
|
|
613
|
+
async exportCsv(options) {
|
|
614
|
+
return this._client._request("GET", "/api/v1/contacts/export/csv", {
|
|
615
|
+
params: options,
|
|
616
|
+
responseParser: parseCSVExportResponse
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
async export_csv(options) {
|
|
620
|
+
return this.exportCsv(options);
|
|
621
|
+
}
|
|
622
|
+
async sync(payload) {
|
|
623
|
+
return this._client._request("POST", "/api/v1/contacts/sync", {
|
|
624
|
+
jsonBody: payload,
|
|
625
|
+
responseParser: parseContactSyncResponse
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
async syncStatus() {
|
|
629
|
+
return this._client._request("GET", "/api/v1/contacts/sync/status", {
|
|
630
|
+
responseParser: parseContactSyncStatusResponseList
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
async sync_status() {
|
|
634
|
+
return this.syncStatus();
|
|
635
|
+
}
|
|
636
|
+
async syncHistory(options) {
|
|
637
|
+
return this._client._request("GET", "/api/v1/contacts/sync/history", {
|
|
638
|
+
params: options,
|
|
639
|
+
responseParser: parseContactSyncHistoryResponse
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
async sync_history(options) {
|
|
643
|
+
return this.syncHistory(options);
|
|
644
|
+
}
|
|
645
|
+
async importTemplate() {
|
|
646
|
+
return this._client._request(
|
|
647
|
+
"GET",
|
|
648
|
+
"/api/v1/contacts/import/template"
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
async import_template() {
|
|
652
|
+
return this.importTemplate();
|
|
653
|
+
}
|
|
654
|
+
async get(contactId) {
|
|
655
|
+
return this._client._request("GET", `/api/v1/contacts/${contactId}`, {
|
|
656
|
+
responseParser: parseContactResponse
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
async update(contactId, payload) {
|
|
660
|
+
return this._client._request("PATCH", `/api/v1/contacts/${contactId}`, {
|
|
661
|
+
jsonBody: payload,
|
|
662
|
+
responseParser: parseContactResponse
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
async delete(contactId) {
|
|
666
|
+
await this._client._request("DELETE", `/api/v1/contacts/${contactId}`);
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
// src/resources/groups.ts
|
|
671
|
+
var GroupsResource = class extends BaseResource {
|
|
672
|
+
async list(options) {
|
|
673
|
+
return this._client._request("GET", "/api/v1/groups", {
|
|
674
|
+
params: options,
|
|
675
|
+
responseParser: parseGroupListResponse
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
async get(groupJid, options) {
|
|
679
|
+
return this._client._request("GET", `/api/v1/groups/${groupJid}`, {
|
|
680
|
+
params: options,
|
|
681
|
+
responseParser: parseGroupDetailResponse
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
async getParticipants(groupJid, options) {
|
|
685
|
+
return this._client._request(
|
|
686
|
+
"GET",
|
|
687
|
+
`/api/v1/groups/${groupJid}/participants`,
|
|
688
|
+
{
|
|
689
|
+
params: options,
|
|
690
|
+
responseParser: parseGroupParticipantsResponse
|
|
691
|
+
}
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
async get_participants(groupJid, options) {
|
|
695
|
+
return this.getParticipants(groupJid, options);
|
|
696
|
+
}
|
|
697
|
+
async create(payload) {
|
|
698
|
+
return this._client._request("POST", "/api/v1/groups/create", {
|
|
699
|
+
jsonBody: payload,
|
|
700
|
+
responseParser: parseCreateGroupResponseModel
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
async sendText(payload) {
|
|
704
|
+
return this._client._request("POST", "/api/v1/groups/send", {
|
|
705
|
+
jsonBody: payload,
|
|
706
|
+
responseParser: parseSendGroupResponse
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
async send_text(payload) {
|
|
710
|
+
return this.sendText(payload);
|
|
711
|
+
}
|
|
712
|
+
async sendMedia(payload) {
|
|
713
|
+
return this._client._request("POST", "/api/v1/groups/send/media", {
|
|
714
|
+
jsonBody: payload,
|
|
715
|
+
responseParser: parseSendGroupResponse
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
async send_media(payload) {
|
|
719
|
+
return this.sendMedia(payload);
|
|
720
|
+
}
|
|
721
|
+
async updateParticipants(payload) {
|
|
722
|
+
return this._client._request("POST", "/api/v1/groups/participants", {
|
|
723
|
+
jsonBody: payload,
|
|
724
|
+
responseParser: parseGroupOperationResponseModel
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
async update_participants(payload) {
|
|
728
|
+
return this.updateParticipants(payload);
|
|
729
|
+
}
|
|
730
|
+
async addParticipant(groupJid, options) {
|
|
731
|
+
return this._client._request(
|
|
732
|
+
"POST",
|
|
733
|
+
`/api/v1/groups/${groupJid}/participants/add`,
|
|
734
|
+
{
|
|
735
|
+
params: options,
|
|
736
|
+
responseParser: parseGroupOperationResponseModel
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
async add_participant(groupJid, options) {
|
|
741
|
+
return this.addParticipant(groupJid, options);
|
|
742
|
+
}
|
|
743
|
+
async removeParticipant(groupJid, options) {
|
|
744
|
+
return this._client._request(
|
|
745
|
+
"POST",
|
|
746
|
+
`/api/v1/groups/${groupJid}/participants/remove`,
|
|
747
|
+
{
|
|
748
|
+
params: options,
|
|
749
|
+
responseParser: parseGroupOperationResponseModel
|
|
750
|
+
}
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
async remove_participant(groupJid, options) {
|
|
754
|
+
return this.removeParticipant(groupJid, options);
|
|
755
|
+
}
|
|
756
|
+
async getInviteLink(groupJid, options) {
|
|
757
|
+
return this._client._request(
|
|
758
|
+
"POST",
|
|
759
|
+
`/api/v1/groups/${groupJid}/invite-link`,
|
|
760
|
+
{
|
|
761
|
+
params: options,
|
|
762
|
+
responseParser: parseGroupInviteLinkResponseModel
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
async get_invite_link(groupJid, options) {
|
|
767
|
+
return this.getInviteLink(groupJid, options);
|
|
768
|
+
}
|
|
769
|
+
async getInviteInfo(payload) {
|
|
770
|
+
return this._client._request("POST", "/api/v1/groups/invite-info", {
|
|
771
|
+
jsonBody: payload,
|
|
772
|
+
responseParser: parseGroupInviteInfoResponseModel
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
async get_invite_info(payload) {
|
|
776
|
+
return this.getInviteInfo(payload);
|
|
777
|
+
}
|
|
778
|
+
async join(payload) {
|
|
779
|
+
return this._client._request("POST", "/api/v1/groups/join", {
|
|
780
|
+
jsonBody: payload,
|
|
781
|
+
responseParser: parseGroupOperationResponseModel
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
async leave(groupJid, options) {
|
|
785
|
+
return this._client._request("POST", `/api/v1/groups/${groupJid}/leave`, {
|
|
786
|
+
params: options,
|
|
787
|
+
responseParser: parseGroupOperationResponseModel
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
async setName(groupJid, payload) {
|
|
791
|
+
return this._client._request("POST", `/api/v1/groups/${groupJid}/name`, {
|
|
792
|
+
jsonBody: payload,
|
|
793
|
+
responseParser: parseGroupOperationResponseModel
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
async set_name(groupJid, payload) {
|
|
797
|
+
return this.setName(groupJid, payload);
|
|
798
|
+
}
|
|
799
|
+
async setTopic(groupJid, payload) {
|
|
800
|
+
return this._client._request("POST", `/api/v1/groups/${groupJid}/topic`, {
|
|
801
|
+
jsonBody: payload,
|
|
802
|
+
responseParser: parseGroupOperationResponseModel
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
async set_topic(groupJid, payload) {
|
|
806
|
+
return this.setTopic(groupJid, payload);
|
|
807
|
+
}
|
|
808
|
+
async setPhoto(groupJid, payload) {
|
|
809
|
+
return this._client._request("POST", `/api/v1/groups/${groupJid}/photo`, {
|
|
810
|
+
jsonBody: payload,
|
|
811
|
+
responseParser: parseGroupOperationResponseModel
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
async set_photo(groupJid, payload) {
|
|
815
|
+
return this.setPhoto(groupJid, payload);
|
|
816
|
+
}
|
|
817
|
+
async removePhoto(groupJid, options) {
|
|
818
|
+
return this._client._request("DELETE", `/api/v1/groups/${groupJid}/photo`, {
|
|
819
|
+
params: options,
|
|
820
|
+
responseParser: parseGroupOperationResponseModel
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
async remove_photo(groupJid, options) {
|
|
824
|
+
return this.removePhoto(groupJid, options);
|
|
825
|
+
}
|
|
826
|
+
async setAnnounce(groupJid, payload) {
|
|
827
|
+
return this._client._request(
|
|
828
|
+
"POST",
|
|
829
|
+
`/api/v1/groups/${groupJid}/announce`,
|
|
830
|
+
{
|
|
831
|
+
jsonBody: payload,
|
|
832
|
+
responseParser: parseGroupOperationResponseModel
|
|
833
|
+
}
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
async set_announce(groupJid, payload) {
|
|
837
|
+
return this.setAnnounce(groupJid, payload);
|
|
838
|
+
}
|
|
839
|
+
async setLocked(groupJid, payload) {
|
|
840
|
+
return this._client._request("POST", `/api/v1/groups/${groupJid}/locked`, {
|
|
841
|
+
jsonBody: payload,
|
|
842
|
+
responseParser: parseGroupOperationResponseModel
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
async set_locked(groupJid, payload) {
|
|
846
|
+
return this.setLocked(groupJid, payload);
|
|
847
|
+
}
|
|
848
|
+
async setEphemeral(groupJid, payload) {
|
|
849
|
+
return this._client._request(
|
|
850
|
+
"POST",
|
|
851
|
+
`/api/v1/groups/${groupJid}/ephemeral`,
|
|
852
|
+
{
|
|
853
|
+
jsonBody: payload,
|
|
854
|
+
responseParser: parseGroupOperationResponseModel
|
|
855
|
+
}
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
async set_ephemeral(groupJid, payload) {
|
|
859
|
+
return this.setEphemeral(groupJid, payload);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
// src/resources/messages.ts
|
|
864
|
+
var MessagesResource = class extends BaseResource {
|
|
865
|
+
async lookup(whatsappMessageId) {
|
|
866
|
+
return this._client._request("GET", "/api/v1/messages/lookup", {
|
|
867
|
+
params: { whatsapp_message_id: whatsappMessageId },
|
|
868
|
+
responseParser: parseMessageResponse
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
async list(options) {
|
|
872
|
+
return this._client._request("GET", "/api/v1/messages", {
|
|
873
|
+
params: options,
|
|
874
|
+
responseParser: parseMessageListResponse
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
async get(messageId) {
|
|
878
|
+
return this._client._request("GET", `/api/v1/messages/${messageId}`, {
|
|
879
|
+
responseParser: parseMessageResponse
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
async stats() {
|
|
883
|
+
return this._client._request("GET", "/api/v1/messages/stats/summary", {
|
|
884
|
+
responseParser: parseMessageStatsResponse
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
async send(payload) {
|
|
888
|
+
return this._client._request("POST", "/api/v1/messages/send", {
|
|
889
|
+
jsonBody: payload,
|
|
890
|
+
responseParser: parseSendMessageResponse
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
async sendImage(payload) {
|
|
894
|
+
return this._client._request("POST", "/api/v1/messages/send/image", {
|
|
895
|
+
jsonBody: payload,
|
|
896
|
+
responseParser: parseSendMessageResponse
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
async send_image(payload) {
|
|
900
|
+
return this.sendImage(payload);
|
|
901
|
+
}
|
|
902
|
+
async sendVideo(payload) {
|
|
903
|
+
return this._client._request("POST", "/api/v1/messages/send/video", {
|
|
904
|
+
jsonBody: payload,
|
|
905
|
+
responseParser: parseSendMessageResponse
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
async send_video(payload) {
|
|
909
|
+
return this.sendVideo(payload);
|
|
910
|
+
}
|
|
911
|
+
async sendVoice(payload) {
|
|
912
|
+
return this._client._request("POST", "/api/v1/messages/send/voice", {
|
|
913
|
+
jsonBody: payload,
|
|
914
|
+
responseParser: parseSendMessageResponse
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
async send_voice(payload) {
|
|
918
|
+
return this.sendVoice(payload);
|
|
919
|
+
}
|
|
920
|
+
async sendDocument(payload) {
|
|
921
|
+
return this._client._request("POST", "/api/v1/messages/send/document", {
|
|
922
|
+
jsonBody: payload,
|
|
923
|
+
responseParser: parseSendMessageResponse
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
async send_document(payload) {
|
|
927
|
+
return this.sendDocument(payload);
|
|
928
|
+
}
|
|
929
|
+
async sendLocation(payload) {
|
|
930
|
+
return this._client._request("POST", "/api/v1/messages/send/location", {
|
|
931
|
+
jsonBody: payload,
|
|
932
|
+
responseParser: parseSendMessageResponse
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
async send_location(payload) {
|
|
936
|
+
return this.sendLocation(payload);
|
|
937
|
+
}
|
|
938
|
+
async sendContact(payload) {
|
|
939
|
+
return this._client._request("POST", "/api/v1/messages/send/contact", {
|
|
940
|
+
jsonBody: payload,
|
|
941
|
+
responseParser: parseSendMessageResponse
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
async send_contact(payload) {
|
|
945
|
+
return this.sendContact(payload);
|
|
946
|
+
}
|
|
947
|
+
async retry(messageId) {
|
|
948
|
+
return this._client._request(
|
|
949
|
+
"POST",
|
|
950
|
+
`/api/v1/messages/${messageId}/retry`,
|
|
951
|
+
{
|
|
952
|
+
responseParser: parseRetryMessageResponse
|
|
953
|
+
}
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
async cancel(messageId) {
|
|
957
|
+
return this._client._request(
|
|
958
|
+
"POST",
|
|
959
|
+
`/api/v1/messages/${messageId}/cancel`,
|
|
960
|
+
{
|
|
961
|
+
responseParser: parseCancelMessageResponse
|
|
962
|
+
}
|
|
963
|
+
);
|
|
964
|
+
}
|
|
965
|
+
async sendButtons(payload) {
|
|
966
|
+
return this._client._request(
|
|
967
|
+
"POST",
|
|
968
|
+
"/api/v1/messages/send/interactive/buttons",
|
|
969
|
+
{
|
|
970
|
+
jsonBody: payload,
|
|
971
|
+
responseParser: parseInteractiveMessageResponse
|
|
972
|
+
}
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
async send_buttons(payload) {
|
|
976
|
+
return this.sendButtons(payload);
|
|
977
|
+
}
|
|
978
|
+
async sendList(payload) {
|
|
979
|
+
return this._client._request(
|
|
980
|
+
"POST",
|
|
981
|
+
"/api/v1/messages/send/interactive/list",
|
|
982
|
+
{
|
|
983
|
+
jsonBody: payload,
|
|
984
|
+
responseParser: parseInteractiveMessageResponse
|
|
985
|
+
}
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
async send_list(payload) {
|
|
989
|
+
return this.sendList(payload);
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
// src/resources/templates.ts
|
|
994
|
+
var TemplatesResource = class extends BaseResource {
|
|
995
|
+
async builtinVariables() {
|
|
996
|
+
return this._client._request("GET", "/api/v1/templates/builtin-variables", {
|
|
997
|
+
responseParser: parseBuiltinVariablesResponse
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
async builtin_variables() {
|
|
1001
|
+
return this.builtinVariables();
|
|
1002
|
+
}
|
|
1003
|
+
async list(options) {
|
|
1004
|
+
return this._client._request("GET", "/api/v1/templates", {
|
|
1005
|
+
params: options,
|
|
1006
|
+
responseParser: parseTemplateListResponse
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
async create(payload) {
|
|
1010
|
+
return this._client._request("POST", "/api/v1/templates", {
|
|
1011
|
+
jsonBody: payload,
|
|
1012
|
+
responseParser: parseTemplateResponse
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
async get(templateId) {
|
|
1016
|
+
return this._client._request("GET", `/api/v1/templates/${templateId}`, {
|
|
1017
|
+
responseParser: parseTemplateResponse
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
async update(templateId, payload) {
|
|
1021
|
+
return this._client._request("PATCH", `/api/v1/templates/${templateId}`, {
|
|
1022
|
+
jsonBody: payload,
|
|
1023
|
+
responseParser: parseTemplateResponse
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
async delete(templateId) {
|
|
1027
|
+
await this._client._request("DELETE", `/api/v1/templates/${templateId}`);
|
|
1028
|
+
}
|
|
1029
|
+
async preview(payload) {
|
|
1030
|
+
return this._client._request("POST", "/api/v1/templates/preview", {
|
|
1031
|
+
jsonBody: payload,
|
|
1032
|
+
responseParser: parseTemplatePreviewResponse
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
// src/client.ts
|
|
1038
|
+
var DEFAULT_BASE_URL = "https://api.wazzapi.com";
|
|
1039
|
+
function buildHeaders(apiKey, headers) {
|
|
1040
|
+
const merged = {
|
|
1041
|
+
Accept: "application/json",
|
|
1042
|
+
"Content-Type": "application/json"
|
|
1043
|
+
};
|
|
1044
|
+
if (headers) {
|
|
1045
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
1046
|
+
merged[key] = value;
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
if (apiKey) {
|
|
1050
|
+
merged.Authorization = apiKey.toLowerCase().startsWith("bearer ") ? apiKey : `Bearer ${apiKey}`;
|
|
1051
|
+
}
|
|
1052
|
+
return merged;
|
|
1053
|
+
}
|
|
1054
|
+
function parseJson(text) {
|
|
1055
|
+
if (!text) {
|
|
1056
|
+
return void 0;
|
|
1057
|
+
}
|
|
1058
|
+
return JSON.parse(text);
|
|
1059
|
+
}
|
|
1060
|
+
function normalizeBaseUrl(baseUrl) {
|
|
1061
|
+
return baseUrl.replace(/\/+$/, "");
|
|
1062
|
+
}
|
|
1063
|
+
var WazzapiClient = class {
|
|
1064
|
+
constructor(options = {}) {
|
|
1065
|
+
const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
|
|
1066
|
+
const timeout = options.timeout ?? 3e4;
|
|
1067
|
+
const fetcher = options.fetch ?? fetch;
|
|
1068
|
+
this.http = {
|
|
1069
|
+
baseUrl: normalizeBaseUrl(baseUrl),
|
|
1070
|
+
headers: buildHeaders(options.apiKey, options.headers),
|
|
1071
|
+
timeout,
|
|
1072
|
+
fetch: fetcher
|
|
1073
|
+
};
|
|
1074
|
+
this.contacts = new ContactsResource(this);
|
|
1075
|
+
this.groups = new GroupsResource(this);
|
|
1076
|
+
this.messages = new MessagesResource(this);
|
|
1077
|
+
this.templates = new TemplatesResource(this);
|
|
1078
|
+
}
|
|
1079
|
+
get base_url() {
|
|
1080
|
+
return this.http.baseUrl;
|
|
1081
|
+
}
|
|
1082
|
+
async close() {
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
async _request(method, path, options = {}) {
|
|
1086
|
+
const url = new URL(path, `${this.http.baseUrl}/`);
|
|
1087
|
+
const params = filterNone(options.params);
|
|
1088
|
+
if (params) {
|
|
1089
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
1090
|
+
url.searchParams.set(key, String(value));
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
const body = options.jsonBody ? JSON.stringify(serializeData(options.jsonBody)) : void 0;
|
|
1094
|
+
const controller = new AbortController();
|
|
1095
|
+
const timeoutId = setTimeout(() => {
|
|
1096
|
+
controller.abort();
|
|
1097
|
+
}, this.http.timeout);
|
|
1098
|
+
try {
|
|
1099
|
+
const response = await this.http.fetch(url.toString(), {
|
|
1100
|
+
method,
|
|
1101
|
+
headers: this.http.headers,
|
|
1102
|
+
body,
|
|
1103
|
+
signal: controller.signal
|
|
1104
|
+
});
|
|
1105
|
+
const responseText = await response.text();
|
|
1106
|
+
const payload = responseText.length > 0 ? parseJson(responseText) : void 0;
|
|
1107
|
+
if (response.status >= 400) {
|
|
1108
|
+
throw WazzapiAPIError.fromResponseParts(
|
|
1109
|
+
response.status,
|
|
1110
|
+
response.statusText,
|
|
1111
|
+
responseText,
|
|
1112
|
+
payload
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
if (response.status === 204 || responseText.length === 0) {
|
|
1116
|
+
return void 0;
|
|
1117
|
+
}
|
|
1118
|
+
if (options.responseParser) {
|
|
1119
|
+
return options.responseParser(payload);
|
|
1120
|
+
}
|
|
1121
|
+
return payload ?? responseText;
|
|
1122
|
+
} finally {
|
|
1123
|
+
clearTimeout(timeoutId);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1128
|
+
// src/media.ts
|
|
1129
|
+
import {
|
|
1130
|
+
createDecipheriv,
|
|
1131
|
+
createHash,
|
|
1132
|
+
createHmac,
|
|
1133
|
+
hkdfSync
|
|
1134
|
+
} from "crypto";
|
|
1135
|
+
var WA_MEDIA_INFO = {
|
|
1136
|
+
image: Buffer.from("WhatsApp Image Keys", "utf8"),
|
|
1137
|
+
video: Buffer.from("WhatsApp Video Keys", "utf8"),
|
|
1138
|
+
audio: Buffer.from("WhatsApp Audio Keys", "utf8"),
|
|
1139
|
+
ptt: Buffer.from("WhatsApp Audio Keys", "utf8"),
|
|
1140
|
+
document: Buffer.from("WhatsApp Document Keys", "utf8"),
|
|
1141
|
+
sticker: Buffer.from("WhatsApp Image Keys", "utf8"),
|
|
1142
|
+
history: Buffer.from("WhatsApp History Keys", "utf8")
|
|
1143
|
+
};
|
|
1144
|
+
function _mediaInfoBytes(mimetype) {
|
|
1145
|
+
const mt = mimetype.toLowerCase();
|
|
1146
|
+
if (mt.startsWith("image/")) {
|
|
1147
|
+
return WA_MEDIA_INFO.image;
|
|
1148
|
+
}
|
|
1149
|
+
if (mt.startsWith("video/")) {
|
|
1150
|
+
return WA_MEDIA_INFO.video;
|
|
1151
|
+
}
|
|
1152
|
+
if (mt.startsWith("audio/")) {
|
|
1153
|
+
return WA_MEDIA_INFO.audio;
|
|
1154
|
+
}
|
|
1155
|
+
return WA_MEDIA_INFO.document;
|
|
1156
|
+
}
|
|
1157
|
+
function _decryptWaMedia(mediaKeyBase64, encryptedData, mimetype) {
|
|
1158
|
+
if (encryptedData.length < 10) {
|
|
1159
|
+
throw new WazzapiMediaError("Encrypted data too short");
|
|
1160
|
+
}
|
|
1161
|
+
let mediaKey;
|
|
1162
|
+
try {
|
|
1163
|
+
mediaKey = Buffer.from(mediaKeyBase64, "base64");
|
|
1164
|
+
} catch {
|
|
1165
|
+
throw new WazzapiMediaError("Invalid media_key base64");
|
|
1166
|
+
}
|
|
1167
|
+
if (mediaKey.length === 0) {
|
|
1168
|
+
throw new WazzapiMediaError("Invalid media_key base64");
|
|
1169
|
+
}
|
|
1170
|
+
const expanded = Buffer.from(
|
|
1171
|
+
hkdfSync(
|
|
1172
|
+
"sha256",
|
|
1173
|
+
mediaKey,
|
|
1174
|
+
Buffer.alloc(0),
|
|
1175
|
+
_mediaInfoBytes(mimetype),
|
|
1176
|
+
112
|
|
1177
|
+
)
|
|
1178
|
+
);
|
|
1179
|
+
const iv = expanded.subarray(0, 16);
|
|
1180
|
+
const aesKey = expanded.subarray(16, 48);
|
|
1181
|
+
const macKey = expanded.subarray(48, 80);
|
|
1182
|
+
const ciphertext = encryptedData.subarray(0, -10);
|
|
1183
|
+
const mac = encryptedData.subarray(-10);
|
|
1184
|
+
const computedMac = createHmac("sha256", macKey).update(Buffer.concat([iv, ciphertext])).digest().subarray(0, 10);
|
|
1185
|
+
if (!computedMac.equals(mac)) {
|
|
1186
|
+
throw new WazzapiMediaError(
|
|
1187
|
+
"MAC verification failed \u2014 media may be corrupted or mediaKey is wrong"
|
|
1188
|
+
);
|
|
1189
|
+
}
|
|
1190
|
+
const decipher = createDecipheriv("aes-256-cbc", aesKey, iv);
|
|
1191
|
+
decipher.setAutoPadding(false);
|
|
1192
|
+
const paddedPlaintext = Buffer.concat([
|
|
1193
|
+
decipher.update(ciphertext),
|
|
1194
|
+
decipher.final()
|
|
1195
|
+
]);
|
|
1196
|
+
if (paddedPlaintext.length === 0) {
|
|
1197
|
+
throw new WazzapiMediaError("Decrypted plaintext is empty");
|
|
1198
|
+
}
|
|
1199
|
+
const padLen = paddedPlaintext[paddedPlaintext.length - 1];
|
|
1200
|
+
if (padLen === 0 || padLen > 16 || padLen > paddedPlaintext.length) {
|
|
1201
|
+
throw new WazzapiMediaError("Invalid PKCS7 padding");
|
|
1202
|
+
}
|
|
1203
|
+
for (let i = paddedPlaintext.length - padLen; i < paddedPlaintext.length; i += 1) {
|
|
1204
|
+
if (paddedPlaintext[i] !== padLen) {
|
|
1205
|
+
throw new WazzapiMediaError("Invalid PKCS7 padding");
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return paddedPlaintext.subarray(0, paddedPlaintext.length - padLen);
|
|
1209
|
+
}
|
|
1210
|
+
async function downloadMedia(url, mediaKey, mimetype, options) {
|
|
1211
|
+
const fetcher = options?.fetch ?? fetch;
|
|
1212
|
+
let response;
|
|
1213
|
+
try {
|
|
1214
|
+
response = await fetcher(url);
|
|
1215
|
+
} catch (error) {
|
|
1216
|
+
throw new WazzapiMediaError(`CDN fetch error: ${String(error)}`);
|
|
1217
|
+
}
|
|
1218
|
+
if (!response.ok) {
|
|
1219
|
+
throw new WazzapiMediaError(`CDN fetch failed: ${response.status}`);
|
|
1220
|
+
}
|
|
1221
|
+
const encryptedData = Buffer.from(await response.arrayBuffer());
|
|
1222
|
+
if (options?.file_enc_sha256) {
|
|
1223
|
+
const expectedEncrypted = Buffer.from(options.file_enc_sha256, "base64");
|
|
1224
|
+
const actualEncrypted = createHash("sha256").update(encryptedData).digest();
|
|
1225
|
+
if (!actualEncrypted.equals(expectedEncrypted)) {
|
|
1226
|
+
throw new WazzapiMediaError(
|
|
1227
|
+
`file_enc_sha256 mismatch: CDN returned wrong data (got ${encryptedData.length} bytes)`
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
const plaintext = _decryptWaMedia(mediaKey, encryptedData, mimetype);
|
|
1232
|
+
if (options?.file_sha256) {
|
|
1233
|
+
const expectedPlain = Buffer.from(options.file_sha256, "base64");
|
|
1234
|
+
const actualPlain = createHash("sha256").update(plaintext).digest();
|
|
1235
|
+
if (!actualPlain.equals(expectedPlain)) {
|
|
1236
|
+
throw new WazzapiMediaError("file_sha256 mismatch after decryption");
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
return {
|
|
1240
|
+
content: plaintext,
|
|
1241
|
+
mimetype,
|
|
1242
|
+
file_name: options?.file_name || "media",
|
|
1243
|
+
file_size: plaintext.length
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
var download_media = downloadMedia;
|
|
1247
|
+
var _decrypt_wa_media = _decryptWaMedia;
|
|
1248
|
+
var _media_info_bytes = _mediaInfoBytes;
|
|
1249
|
+
|
|
1250
|
+
// src/webhooks.ts
|
|
1251
|
+
import { createHmac as createHmac2, timingSafeEqual } from "crypto";
|
|
1252
|
+
var SIGNATURE_HEADER = "X-Wazzapi-Signature";
|
|
1253
|
+
var EVENT_HEADER = "X-Wazzapi-Event";
|
|
1254
|
+
var EVENT_ID_HEADER = "X-Wazzapi-Event-ID";
|
|
1255
|
+
var SIGNATURE_PREFIX = "sha256=";
|
|
1256
|
+
var WazzapiWebhookError = class extends Error {
|
|
1257
|
+
constructor(message) {
|
|
1258
|
+
super(message);
|
|
1259
|
+
this.name = "WazzapiWebhookError";
|
|
1260
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
var WazzapiWebhookVerificationError = class extends WazzapiWebhookError {
|
|
1264
|
+
constructor(message) {
|
|
1265
|
+
super(message);
|
|
1266
|
+
this.name = "WazzapiWebhookVerificationError";
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
var WazzapiWebhookParseError = class extends WazzapiWebhookError {
|
|
1270
|
+
constructor(message) {
|
|
1271
|
+
super(message);
|
|
1272
|
+
this.name = "WazzapiWebhookParseError";
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
function toBuffer(payload) {
|
|
1276
|
+
if (typeof payload === "string") {
|
|
1277
|
+
return Buffer.from(payload, "utf8");
|
|
1278
|
+
}
|
|
1279
|
+
return Buffer.from(payload);
|
|
1280
|
+
}
|
|
1281
|
+
function getHeader(headers, name) {
|
|
1282
|
+
const normalizedName = name.toLowerCase();
|
|
1283
|
+
if (typeof Headers !== "undefined" && headers instanceof Headers) {
|
|
1284
|
+
return headers.get(name) ?? void 0;
|
|
1285
|
+
}
|
|
1286
|
+
return Object.entries(headers).find(
|
|
1287
|
+
([key]) => key.toLowerCase() === normalizedName
|
|
1288
|
+
)?.[1];
|
|
1289
|
+
}
|
|
1290
|
+
function generateWebhookSignature(payload, secret) {
|
|
1291
|
+
const digest = createHmac2("sha256", Buffer.from(secret, "utf8")).update(toBuffer(payload)).digest("hex");
|
|
1292
|
+
return `${SIGNATURE_PREFIX}${digest}`;
|
|
1293
|
+
}
|
|
1294
|
+
function verifyWebhookSignature(payload, signature, secret) {
|
|
1295
|
+
const normalizedSignature = signature.trim();
|
|
1296
|
+
const expected = Buffer.from(
|
|
1297
|
+
generateWebhookSignature(payload, secret),
|
|
1298
|
+
"utf8"
|
|
1299
|
+
);
|
|
1300
|
+
const actual = Buffer.from(normalizedSignature, "utf8");
|
|
1301
|
+
if (expected.length !== actual.length) {
|
|
1302
|
+
return false;
|
|
1303
|
+
}
|
|
1304
|
+
return timingSafeEqual(expected, actual);
|
|
1305
|
+
}
|
|
1306
|
+
var WebhookHandler = class {
|
|
1307
|
+
constructor(secret) {
|
|
1308
|
+
this.secret = secret;
|
|
1309
|
+
}
|
|
1310
|
+
generateSignature(payload) {
|
|
1311
|
+
return generateWebhookSignature(payload, this.secret);
|
|
1312
|
+
}
|
|
1313
|
+
verifySignature(payload, signature) {
|
|
1314
|
+
return verifyWebhookSignature(payload, signature, this.secret);
|
|
1315
|
+
}
|
|
1316
|
+
verifyHeaders(payload, headers) {
|
|
1317
|
+
const signature = getHeader(headers, SIGNATURE_HEADER);
|
|
1318
|
+
if (!signature) {
|
|
1319
|
+
throw new WazzapiWebhookVerificationError(
|
|
1320
|
+
`Missing required webhook header: ${SIGNATURE_HEADER}`
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
if (!this.verifySignature(payload, signature)) {
|
|
1324
|
+
throw new WazzapiWebhookVerificationError("Invalid webhook signature");
|
|
1325
|
+
}
|
|
1326
|
+
if (!getHeader(headers, EVENT_HEADER)) {
|
|
1327
|
+
throw new WazzapiWebhookVerificationError(
|
|
1328
|
+
`Missing required webhook header: ${EVENT_HEADER}`
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
if (!getHeader(headers, EVENT_ID_HEADER)) {
|
|
1332
|
+
throw new WazzapiWebhookVerificationError(
|
|
1333
|
+
`Missing required webhook header: ${EVENT_ID_HEADER}`
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
parse(payload) {
|
|
1338
|
+
let rawPayload;
|
|
1339
|
+
try {
|
|
1340
|
+
rawPayload = JSON.parse(toBuffer(payload).toString("utf8"));
|
|
1341
|
+
} catch {
|
|
1342
|
+
throw new WazzapiWebhookParseError("Webhook payload is not valid JSON");
|
|
1343
|
+
}
|
|
1344
|
+
if (!rawPayload || typeof rawPayload !== "object" || Array.isArray(rawPayload)) {
|
|
1345
|
+
throw new WazzapiWebhookParseError(
|
|
1346
|
+
"Webhook payload must be a JSON object"
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
const eventType = rawPayload.event_type;
|
|
1350
|
+
if (typeof eventType !== "string") {
|
|
1351
|
+
throw new WazzapiWebhookParseError(
|
|
1352
|
+
"Webhook payload is missing event_type"
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
if (eventType.startsWith("message.")) {
|
|
1356
|
+
return parsePublicMessageWebhook(rawPayload);
|
|
1357
|
+
}
|
|
1358
|
+
if (eventType.startsWith("device.")) {
|
|
1359
|
+
return parsePublicDeviceWebhook(rawPayload);
|
|
1360
|
+
}
|
|
1361
|
+
throw new WazzapiWebhookParseError(
|
|
1362
|
+
`Unsupported webhook event type: ${eventType}`
|
|
1363
|
+
);
|
|
1364
|
+
}
|
|
1365
|
+
verifyAndParse(payload, headers) {
|
|
1366
|
+
this.verifyHeaders(payload, headers);
|
|
1367
|
+
const parsed = this.parse(payload);
|
|
1368
|
+
const headerEvent = getHeader(headers, EVENT_HEADER);
|
|
1369
|
+
if (headerEvent && headerEvent !== parsed.event_type) {
|
|
1370
|
+
throw new WazzapiWebhookVerificationError(
|
|
1371
|
+
"Webhook event header does not match payload event_type"
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
return parsed;
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
function parseWebhook(payload, headers, secret) {
|
|
1378
|
+
return new WebhookHandler(secret).verifyAndParse(payload, headers);
|
|
1379
|
+
}
|
|
1380
|
+
var generate_webhook_signature = generateWebhookSignature;
|
|
1381
|
+
var verify_webhook_signature = verifyWebhookSignature;
|
|
1382
|
+
var parse_webhook = parseWebhook;
|
|
1383
|
+
|
|
1384
|
+
// src/index.ts
|
|
1385
|
+
var __version__ = "0.2.0";
|
|
1386
|
+
export {
|
|
1387
|
+
DEFAULT_BASE_URL,
|
|
1388
|
+
EVENT_HEADER,
|
|
1389
|
+
EVENT_ID_HEADER,
|
|
1390
|
+
SIGNATURE_HEADER,
|
|
1391
|
+
WazzapiAPIError,
|
|
1392
|
+
WazzapiClient,
|
|
1393
|
+
WazzapiError,
|
|
1394
|
+
WazzapiMediaError,
|
|
1395
|
+
WazzapiWebhookError,
|
|
1396
|
+
WazzapiWebhookParseError,
|
|
1397
|
+
WazzapiWebhookVerificationError,
|
|
1398
|
+
WebhookHandler,
|
|
1399
|
+
__version__,
|
|
1400
|
+
_decryptWaMedia,
|
|
1401
|
+
_decrypt_wa_media,
|
|
1402
|
+
_mediaInfoBytes,
|
|
1403
|
+
_media_info_bytes,
|
|
1404
|
+
downloadMedia,
|
|
1405
|
+
download_media,
|
|
1406
|
+
generateWebhookSignature,
|
|
1407
|
+
generate_webhook_signature,
|
|
1408
|
+
models_exports as models,
|
|
1409
|
+
parseAddToGroupResponse,
|
|
1410
|
+
parseBuiltinVariableInfo,
|
|
1411
|
+
parseBuiltinVariablesResponse,
|
|
1412
|
+
parseBulkDeleteResponse,
|
|
1413
|
+
parseCSVExportResponse,
|
|
1414
|
+
parseCSVImportResponse,
|
|
1415
|
+
parseCancelMessageResponse,
|
|
1416
|
+
parseContactGroupItem,
|
|
1417
|
+
parseContactGroupListResponse,
|
|
1418
|
+
parseContactGroupMembersResponse,
|
|
1419
|
+
parseContactItem,
|
|
1420
|
+
parseContactListResponse,
|
|
1421
|
+
parseContactResponse,
|
|
1422
|
+
parseContactSyncHistoryItem,
|
|
1423
|
+
parseContactSyncHistoryResponse,
|
|
1424
|
+
parseContactSyncResponse,
|
|
1425
|
+
parseContactSyncStatusResponse,
|
|
1426
|
+
parseContactSyncStatusResponseList,
|
|
1427
|
+
parseCreateGroupResponseModel,
|
|
1428
|
+
parseGroupDetailResponse,
|
|
1429
|
+
parseGroupInviteInfoResponseModel,
|
|
1430
|
+
parseGroupInviteLinkResponseModel,
|
|
1431
|
+
parseGroupListItem,
|
|
1432
|
+
parseGroupListResponse,
|
|
1433
|
+
parseGroupOperationResponseModel,
|
|
1434
|
+
parseGroupParticipantItem,
|
|
1435
|
+
parseGroupParticipantsResponse,
|
|
1436
|
+
parseInteractiveButton,
|
|
1437
|
+
parseInteractiveMessageResponse,
|
|
1438
|
+
parseInteractiveRow,
|
|
1439
|
+
parseInteractiveSection,
|
|
1440
|
+
parseMediaDownloadResult,
|
|
1441
|
+
parseMessageItem,
|
|
1442
|
+
parseMessageListResponse,
|
|
1443
|
+
parseMessageResponse,
|
|
1444
|
+
parseMessageStatsResponse,
|
|
1445
|
+
parsePublicDeviceWebhook,
|
|
1446
|
+
parsePublicMessageWebhook,
|
|
1447
|
+
parsePublicWebhookDeviceData,
|
|
1448
|
+
parsePublicWebhookMessageData,
|
|
1449
|
+
parseRetryMessageResponse,
|
|
1450
|
+
parseSendGroupResponse,
|
|
1451
|
+
parseSendMessageResponse,
|
|
1452
|
+
parseTemplateItem,
|
|
1453
|
+
parseTemplateListResponse,
|
|
1454
|
+
parseTemplatePreviewResponse,
|
|
1455
|
+
parseTemplateResponse,
|
|
1456
|
+
parseWebhook,
|
|
1457
|
+
parseWebhookPayload,
|
|
1458
|
+
parse_webhook,
|
|
1459
|
+
verifyWebhookSignature,
|
|
1460
|
+
verify_webhook_signature
|
|
1461
|
+
};
|