@polymorfa/sdk 0.1.0-dev.20260922093854

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1881 -0
  3. package/dist/bridge.d.ts +31 -0
  4. package/dist/bridge.d.ts.map +1 -0
  5. package/dist/bridge.js +39 -0
  6. package/dist/bridge.js.map +1 -0
  7. package/dist/calls/api.d.ts +109 -0
  8. package/dist/calls/api.d.ts.map +1 -0
  9. package/dist/calls/api.js +179 -0
  10. package/dist/calls/api.js.map +1 -0
  11. package/dist/calls/call.d.ts +286 -0
  12. package/dist/calls/call.d.ts.map +1 -0
  13. package/dist/calls/call.js +860 -0
  14. package/dist/calls/call.js.map +1 -0
  15. package/dist/calls/client.d.ts +124 -0
  16. package/dist/calls/client.d.ts.map +1 -0
  17. package/dist/calls/client.js +447 -0
  18. package/dist/calls/client.js.map +1 -0
  19. package/dist/calls/diagnostics.d.ts +74 -0
  20. package/dist/calls/diagnostics.d.ts.map +1 -0
  21. package/dist/calls/diagnostics.js +133 -0
  22. package/dist/calls/diagnostics.js.map +1 -0
  23. package/dist/calls/errors.d.ts +37 -0
  24. package/dist/calls/errors.d.ts.map +1 -0
  25. package/dist/calls/errors.js +52 -0
  26. package/dist/calls/errors.js.map +1 -0
  27. package/dist/calls/events.d.ts +15 -0
  28. package/dist/calls/events.d.ts.map +1 -0
  29. package/dist/calls/events.js +34 -0
  30. package/dist/calls/events.js.map +1 -0
  31. package/dist/calls/index.d.ts +6 -0
  32. package/dist/calls/index.d.ts.map +1 -0
  33. package/dist/calls/index.js +7 -0
  34. package/dist/calls/index.js.map +1 -0
  35. package/dist/calls/internal.d.ts +18 -0
  36. package/dist/calls/internal.d.ts.map +1 -0
  37. package/dist/calls/internal.js +18 -0
  38. package/dist/calls/internal.js.map +1 -0
  39. package/dist/calls/lifecycle.d.ts +111 -0
  40. package/dist/calls/lifecycle.d.ts.map +1 -0
  41. package/dist/calls/lifecycle.js +490 -0
  42. package/dist/calls/lifecycle.js.map +1 -0
  43. package/dist/calls/media.d.ts +102 -0
  44. package/dist/calls/media.d.ts.map +1 -0
  45. package/dist/calls/media.js +414 -0
  46. package/dist/calls/media.js.map +1 -0
  47. package/dist/calls/protocol.d.ts +216 -0
  48. package/dist/calls/protocol.d.ts.map +1 -0
  49. package/dist/calls/protocol.js +268 -0
  50. package/dist/calls/protocol.js.map +1 -0
  51. package/dist/calls/token.d.ts +43 -0
  52. package/dist/calls/token.d.ts.map +1 -0
  53. package/dist/calls/token.js +146 -0
  54. package/dist/calls/token.js.map +1 -0
  55. package/dist/client.d.ts +65 -0
  56. package/dist/client.d.ts.map +1 -0
  57. package/dist/client.js +119 -0
  58. package/dist/client.js.map +1 -0
  59. package/dist/credentials.d.ts +50 -0
  60. package/dist/credentials.d.ts.map +1 -0
  61. package/dist/credentials.js +73 -0
  62. package/dist/credentials.js.map +1 -0
  63. package/dist/errors.d.ts +71 -0
  64. package/dist/errors.d.ts.map +1 -0
  65. package/dist/errors.js +129 -0
  66. package/dist/errors.js.map +1 -0
  67. package/dist/index.d.ts +70 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +61 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/media/whatsapp.d.ts +105 -0
  72. package/dist/media/whatsapp.d.ts.map +1 -0
  73. package/dist/media/whatsapp.js +624 -0
  74. package/dist/media/whatsapp.js.map +1 -0
  75. package/dist/messaging/bansafe.d.ts +30 -0
  76. package/dist/messaging/bansafe.d.ts.map +1 -0
  77. package/dist/messaging/bansafe.js +86 -0
  78. package/dist/messaging/bansafe.js.map +1 -0
  79. package/dist/messaging/business.d.ts +35 -0
  80. package/dist/messaging/business.d.ts.map +1 -0
  81. package/dist/messaging/business.js +145 -0
  82. package/dist/messaging/business.js.map +1 -0
  83. package/dist/messaging/calls.d.ts +9 -0
  84. package/dist/messaging/calls.d.ts.map +1 -0
  85. package/dist/messaging/calls.js +16 -0
  86. package/dist/messaging/calls.js.map +1 -0
  87. package/dist/messaging/campaigns.d.ts +19 -0
  88. package/dist/messaging/campaigns.d.ts.map +1 -0
  89. package/dist/messaging/campaigns.js +77 -0
  90. package/dist/messaging/campaigns.js.map +1 -0
  91. package/dist/messaging/channels.d.ts +23 -0
  92. package/dist/messaging/channels.d.ts.map +1 -0
  93. package/dist/messaging/channels.js +104 -0
  94. package/dist/messaging/channels.js.map +1 -0
  95. package/dist/messaging/chats.d.ts +14 -0
  96. package/dist/messaging/chats.d.ts.map +1 -0
  97. package/dist/messaging/chats.js +51 -0
  98. package/dist/messaging/chats.js.map +1 -0
  99. package/dist/messaging/client-tokens.d.ts +15 -0
  100. package/dist/messaging/client-tokens.d.ts.map +1 -0
  101. package/dist/messaging/client-tokens.js +64 -0
  102. package/dist/messaging/client-tokens.js.map +1 -0
  103. package/dist/messaging/client.d.ts +58 -0
  104. package/dist/messaging/client.d.ts.map +1 -0
  105. package/dist/messaging/client.js +100 -0
  106. package/dist/messaging/client.js.map +1 -0
  107. package/dist/messaging/contacts.d.ts +20 -0
  108. package/dist/messaging/contacts.d.ts.map +1 -0
  109. package/dist/messaging/contacts.js +75 -0
  110. package/dist/messaging/contacts.js.map +1 -0
  111. package/dist/messaging/groups.d.ts +34 -0
  112. package/dist/messaging/groups.d.ts.map +1 -0
  113. package/dist/messaging/groups.js +97 -0
  114. package/dist/messaging/groups.js.map +1 -0
  115. package/dist/messaging/identities.d.ts +9 -0
  116. package/dist/messaging/identities.d.ts.map +1 -0
  117. package/dist/messaging/identities.js +21 -0
  118. package/dist/messaging/identities.js.map +1 -0
  119. package/dist/messaging/labels.d.ts +16 -0
  120. package/dist/messaging/labels.d.ts.map +1 -0
  121. package/dist/messaging/labels.js +65 -0
  122. package/dist/messaging/labels.js.map +1 -0
  123. package/dist/messaging/media.d.ts +72 -0
  124. package/dist/messaging/media.d.ts.map +1 -0
  125. package/dist/messaging/media.js +142 -0
  126. package/dist/messaging/media.js.map +1 -0
  127. package/dist/messaging/messages.d.ts +18 -0
  128. package/dist/messaging/messages.d.ts.map +1 -0
  129. package/dist/messaging/messages.js +32 -0
  130. package/dist/messaging/messages.js.map +1 -0
  131. package/dist/messaging/observation-policies.d.ts +10 -0
  132. package/dist/messaging/observation-policies.d.ts.map +1 -0
  133. package/dist/messaging/observation-policies.js +28 -0
  134. package/dist/messaging/observation-policies.js.map +1 -0
  135. package/dist/messaging/onboarding.d.ts +53 -0
  136. package/dist/messaging/onboarding.d.ts.map +1 -0
  137. package/dist/messaging/onboarding.js +69 -0
  138. package/dist/messaging/onboarding.js.map +1 -0
  139. package/dist/messaging/presence.d.ts +12 -0
  140. package/dist/messaging/presence.d.ts.map +1 -0
  141. package/dist/messaging/presence.js +43 -0
  142. package/dist/messaging/presence.js.map +1 -0
  143. package/dist/messaging/privacy.d.ts +11 -0
  144. package/dist/messaging/privacy.d.ts.map +1 -0
  145. package/dist/messaging/privacy.js +34 -0
  146. package/dist/messaging/privacy.js.map +1 -0
  147. package/dist/messaging/profile.d.ts +13 -0
  148. package/dist/messaging/profile.d.ts.map +1 -0
  149. package/dist/messaging/profile.js +49 -0
  150. package/dist/messaging/profile.js.map +1 -0
  151. package/dist/messaging/quick-replies.d.ts +13 -0
  152. package/dist/messaging/quick-replies.d.ts.map +1 -0
  153. package/dist/messaging/quick-replies.js +45 -0
  154. package/dist/messaging/quick-replies.js.map +1 -0
  155. package/dist/messaging/quicklinks.d.ts +69 -0
  156. package/dist/messaging/quicklinks.d.ts.map +1 -0
  157. package/dist/messaging/quicklinks.js +45 -0
  158. package/dist/messaging/quicklinks.js.map +1 -0
  159. package/dist/messaging/session-configuration.d.ts +67 -0
  160. package/dist/messaging/session-configuration.d.ts.map +1 -0
  161. package/dist/messaging/session-configuration.js +2 -0
  162. package/dist/messaging/session-configuration.js.map +1 -0
  163. package/dist/messaging/sessions.d.ts +26 -0
  164. package/dist/messaging/sessions.d.ts.map +1 -0
  165. package/dist/messaging/sessions.js +108 -0
  166. package/dist/messaging/sessions.js.map +1 -0
  167. package/dist/messaging/templates.d.ts +15 -0
  168. package/dist/messaging/templates.d.ts.map +1 -0
  169. package/dist/messaging/templates.js +67 -0
  170. package/dist/messaging/templates.js.map +1 -0
  171. package/dist/messaging/testing-configuration.d.ts +89 -0
  172. package/dist/messaging/testing-configuration.d.ts.map +1 -0
  173. package/dist/messaging/testing-configuration.js +14 -0
  174. package/dist/messaging/testing-configuration.js.map +1 -0
  175. package/dist/messaging/types.d.ts +1793 -0
  176. package/dist/messaging/types.d.ts.map +1 -0
  177. package/dist/messaging/types.js +25 -0
  178. package/dist/messaging/types.js.map +1 -0
  179. package/dist/messaging/users.d.ts +9 -0
  180. package/dist/messaging/users.d.ts.map +1 -0
  181. package/dist/messaging/users.js +15 -0
  182. package/dist/messaging/users.js.map +1 -0
  183. package/dist/messaging/voip.d.ts +51 -0
  184. package/dist/messaging/voip.d.ts.map +1 -0
  185. package/dist/messaging/voip.js +293 -0
  186. package/dist/messaging/voip.js.map +1 -0
  187. package/dist/messaging/webhooks.d.ts +13 -0
  188. package/dist/messaging/webhooks.d.ts.map +1 -0
  189. package/dist/messaging/webhooks.js +48 -0
  190. package/dist/messaging/webhooks.js.map +1 -0
  191. package/dist/node.d.ts +55 -0
  192. package/dist/node.d.ts.map +1 -0
  193. package/dist/node.js +237 -0
  194. package/dist/node.js.map +1 -0
  195. package/dist/pagination.d.ts +24 -0
  196. package/dist/pagination.d.ts.map +1 -0
  197. package/dist/pagination.js +28 -0
  198. package/dist/pagination.js.map +1 -0
  199. package/dist/platform/api-keys.d.ts +10 -0
  200. package/dist/platform/api-keys.d.ts.map +1 -0
  201. package/dist/platform/api-keys.js +22 -0
  202. package/dist/platform/api-keys.js.map +1 -0
  203. package/dist/platform/audiences.d.ts +16 -0
  204. package/dist/platform/audiences.d.ts.map +1 -0
  205. package/dist/platform/audiences.js +46 -0
  206. package/dist/platform/audiences.js.map +1 -0
  207. package/dist/platform/audit-logs.d.ts +9 -0
  208. package/dist/platform/audit-logs.d.ts.map +1 -0
  209. package/dist/platform/audit-logs.js +20 -0
  210. package/dist/platform/audit-logs.js.map +1 -0
  211. package/dist/platform/bansafe.d.ts +24 -0
  212. package/dist/platform/bansafe.d.ts.map +1 -0
  213. package/dist/platform/bansafe.js +70 -0
  214. package/dist/platform/bansafe.js.map +1 -0
  215. package/dist/platform/billing.d.ts +13 -0
  216. package/dist/platform/billing.d.ts.map +1 -0
  217. package/dist/platform/billing.js +27 -0
  218. package/dist/platform/billing.js.map +1 -0
  219. package/dist/platform/campaigns.d.ts +28 -0
  220. package/dist/platform/campaigns.d.ts.map +1 -0
  221. package/dist/platform/campaigns.js +92 -0
  222. package/dist/platform/campaigns.js.map +1 -0
  223. package/dist/platform/customers.d.ts +23 -0
  224. package/dist/platform/customers.d.ts.map +1 -0
  225. package/dist/platform/customers.js +140 -0
  226. package/dist/platform/customers.js.map +1 -0
  227. package/dist/platform/developer-resources.d.ts +101 -0
  228. package/dist/platform/developer-resources.d.ts.map +1 -0
  229. package/dist/platform/developer-resources.js +250 -0
  230. package/dist/platform/developer-resources.js.map +1 -0
  231. package/dist/platform/developer-types.d.ts +378 -0
  232. package/dist/platform/developer-types.d.ts.map +1 -0
  233. package/dist/platform/developer-types.js +2 -0
  234. package/dist/platform/developer-types.js.map +1 -0
  235. package/dist/platform/event-stream.d.ts +114 -0
  236. package/dist/platform/event-stream.d.ts.map +1 -0
  237. package/dist/platform/event-stream.js +308 -0
  238. package/dist/platform/event-stream.js.map +1 -0
  239. package/dist/platform/media.d.ts +13 -0
  240. package/dist/platform/media.d.ts.map +1 -0
  241. package/dist/platform/media.js +33 -0
  242. package/dist/platform/media.js.map +1 -0
  243. package/dist/platform/members.d.ts +9 -0
  244. package/dist/platform/members.d.ts.map +1 -0
  245. package/dist/platform/members.js +15 -0
  246. package/dist/platform/members.js.map +1 -0
  247. package/dist/platform/opt-outs.d.ts +15 -0
  248. package/dist/platform/opt-outs.d.ts.map +1 -0
  249. package/dist/platform/opt-outs.js +36 -0
  250. package/dist/platform/opt-outs.js.map +1 -0
  251. package/dist/platform/organizations.d.ts +9 -0
  252. package/dist/platform/organizations.d.ts.map +1 -0
  253. package/dist/platform/organizations.js +15 -0
  254. package/dist/platform/organizations.js.map +1 -0
  255. package/dist/platform/project-tokens.d.ts +9 -0
  256. package/dist/platform/project-tokens.d.ts.map +1 -0
  257. package/dist/platform/project-tokens.js +16 -0
  258. package/dist/platform/project-tokens.js.map +1 -0
  259. package/dist/platform/projects.d.ts +24 -0
  260. package/dist/platform/projects.d.ts.map +1 -0
  261. package/dist/platform/projects.js +83 -0
  262. package/dist/platform/projects.js.map +1 -0
  263. package/dist/platform/quicklink-settings.d.ts +85 -0
  264. package/dist/platform/quicklink-settings.d.ts.map +1 -0
  265. package/dist/platform/quicklink-settings.js +35 -0
  266. package/dist/platform/quicklink-settings.js.map +1 -0
  267. package/dist/platform/response.d.ts +10 -0
  268. package/dist/platform/response.d.ts.map +1 -0
  269. package/dist/platform/response.js +41 -0
  270. package/dist/platform/response.js.map +1 -0
  271. package/dist/platform/security-incidents.d.ts +10 -0
  272. package/dist/platform/security-incidents.d.ts.map +1 -0
  273. package/dist/platform/security-incidents.js +22 -0
  274. package/dist/platform/security-incidents.js.map +1 -0
  275. package/dist/platform/session-bans.d.ts +13 -0
  276. package/dist/platform/session-bans.d.ts.map +1 -0
  277. package/dist/platform/session-bans.js +21 -0
  278. package/dist/platform/session-bans.js.map +1 -0
  279. package/dist/platform/session-configuration.d.ts +15 -0
  280. package/dist/platform/session-configuration.d.ts.map +1 -0
  281. package/dist/platform/session-configuration.js +36 -0
  282. package/dist/platform/session-configuration.js.map +1 -0
  283. package/dist/platform/sessions.d.ts +26 -0
  284. package/dist/platform/sessions.d.ts.map +1 -0
  285. package/dist/platform/sessions.js +121 -0
  286. package/dist/platform/sessions.js.map +1 -0
  287. package/dist/platform/sip-trunks.d.ts +141 -0
  288. package/dist/platform/sip-trunks.d.ts.map +1 -0
  289. package/dist/platform/sip-trunks.js +140 -0
  290. package/dist/platform/sip-trunks.js.map +1 -0
  291. package/dist/platform/types.d.ts +897 -0
  292. package/dist/platform/types.d.ts.map +1 -0
  293. package/dist/platform/types.js +2 -0
  294. package/dist/platform/types.js.map +1 -0
  295. package/dist/raw.d.ts +26 -0
  296. package/dist/raw.d.ts.map +1 -0
  297. package/dist/raw.js +79 -0
  298. package/dist/raw.js.map +1 -0
  299. package/dist/system.d.ts +37 -0
  300. package/dist/system.d.ts.map +1 -0
  301. package/dist/system.js +45 -0
  302. package/dist/system.js.map +1 -0
  303. package/dist/transport/body.d.ts +6 -0
  304. package/dist/transport/body.d.ts.map +1 -0
  305. package/dist/transport/body.js +33 -0
  306. package/dist/transport/body.js.map +1 -0
  307. package/dist/transport/content-disposition.d.ts +9 -0
  308. package/dist/transport/content-disposition.d.ts.map +1 -0
  309. package/dist/transport/content-disposition.js +107 -0
  310. package/dist/transport/content-disposition.js.map +1 -0
  311. package/dist/transport/http.d.ts +35 -0
  312. package/dist/transport/http.d.ts.map +1 -0
  313. package/dist/transport/http.js +660 -0
  314. package/dist/transport/http.js.map +1 -0
  315. package/dist/transport/idempotency.d.ts +10 -0
  316. package/dist/transport/idempotency.d.ts.map +1 -0
  317. package/dist/transport/idempotency.js +13 -0
  318. package/dist/transport/idempotency.js.map +1 -0
  319. package/dist/transport/retry.d.ts +11 -0
  320. package/dist/transport/retry.d.ts.map +1 -0
  321. package/dist/transport/retry.js +45 -0
  322. package/dist/transport/retry.js.map +1 -0
  323. package/dist/transport/types.d.ts +58 -0
  324. package/dist/transport/types.d.ts.map +1 -0
  325. package/dist/transport/types.js +2 -0
  326. package/dist/transport/types.js.map +1 -0
  327. package/dist/version.d.ts +2 -0
  328. package/dist/version.d.ts.map +1 -0
  329. package/dist/version.js +2 -0
  330. package/dist/version.js.map +1 -0
  331. package/dist/webhooks/events.d.ts +741 -0
  332. package/dist/webhooks/events.d.ts.map +1 -0
  333. package/dist/webhooks/events.js +80 -0
  334. package/dist/webhooks/events.js.map +1 -0
  335. package/dist/webhooks/index.d.ts +4 -0
  336. package/dist/webhooks/index.d.ts.map +1 -0
  337. package/dist/webhooks/index.js +4 -0
  338. package/dist/webhooks/index.js.map +1 -0
  339. package/dist/webhooks/utilities.d.ts +33 -0
  340. package/dist/webhooks/utilities.d.ts.map +1 -0
  341. package/dist/webhooks/utilities.js +67 -0
  342. package/dist/webhooks/utilities.js.map +1 -0
  343. package/dist/webhooks/verify.d.ts +9 -0
  344. package/dist/webhooks/verify.d.ts.map +1 -0
  345. package/dist/webhooks/verify.js +77 -0
  346. package/dist/webhooks/verify.js.map +1 -0
  347. package/package.json +58 -0
package/dist/node.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ import { type WhatsAppMediaCrypto, type WhatsAppMediaDownload, type WhatsAppMediaDownloadOptions, type WhatsAppMediaInput } from "./media/whatsapp.js";
2
+ import type { MessagingMediaResource } from "./messaging/media.js";
3
+ import type { RequestOptions } from "./transport/types.js";
4
+ /**
5
+ * Incremental `node:crypto` backend. It holds back the trailing 10-byte MAC
6
+ * and lets the decipher hold back the final block, so padding is only
7
+ * removed after the MAC and encrypted hash are verified. With
8
+ * `verify: "streaming"` earlier plaintext chunks are emitted before
9
+ * verification completes.
10
+ */
11
+ export declare const nodeMediaCrypto: WhatsAppMediaCrypto;
12
+ export interface WriteToFileOptions {
13
+ readonly signal?: AbortSignal;
14
+ /**
15
+ * Replace an existing file at `path` (default `true`). With `false` the
16
+ * final link fails atomically with `PolymorfaConflictError` when the path
17
+ * exists.
18
+ */
19
+ readonly overwrite?: boolean;
20
+ /** Abort with `media_too_large` once more than this many bytes arrive. */
21
+ readonly maxBytes?: number;
22
+ }
23
+ /**
24
+ * Writes a web stream to `path` through a sibling temporary file, then
25
+ * moves it into place. The temporary file is removed on error or abort, and
26
+ * an existing file at `path` is replaced only on success (and only when
27
+ * `overwrite` is not `false`).
28
+ */
29
+ export declare function writeStreamToFile(body: ReadableStream<Uint8Array>, path: string, options?: WriteToFileOptions): Promise<{
30
+ readonly path: string;
31
+ readonly bytes: number;
32
+ }>;
33
+ /** Downloads Messaging media through the Polymorfa API into a file. */
34
+ export declare function downloadMediaToFile(media: Pick<MessagingMediaResource, "downloadStream">, mediaId: string, path: string, options?: RequestOptions & {
35
+ readonly overwrite?: boolean;
36
+ readonly maxBytes?: number;
37
+ }): Promise<{
38
+ readonly path: string;
39
+ readonly bytes: number;
40
+ readonly contentType?: string;
41
+ readonly filename?: string;
42
+ readonly requestId?: string;
43
+ }>;
44
+ /**
45
+ * Downloads and decrypts WhatsApp media straight from the CDN into a file.
46
+ * Decryption streams (`verify: "streaming"` with `nodeMediaCrypto`) and the
47
+ * file is renamed into place only after the MAC and hashes verify.
48
+ */
49
+ export declare function downloadWhatsAppMediaToFile(input: WhatsAppMediaInput, path: string, options?: WhatsAppMediaDownloadOptions & {
50
+ readonly overwrite?: boolean;
51
+ }): Promise<Omit<WhatsAppMediaDownload, "body" | "arrayBuffer" | "blob"> & {
52
+ readonly path: string;
53
+ readonly bytes: number;
54
+ }>;
55
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAwBA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EAExB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgB3D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,mBA6G5B,CAAC;AAEH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,Q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
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Node.js-only helpers. Import from `@polymorfa/sdk/node`; this module loads
3
+ * `node:crypto` and `node:fs`, so keep it out of browser bundles.
4
+ */
5
+ import { createDecipheriv, createHash, createHmac, randomUUID, timingSafeEqual, } from "node:crypto";
6
+ import { createWriteStream } from "node:fs";
7
+ import { access, link, rename, unlink } from "node:fs/promises";
8
+ import { basename, dirname, join } from "node:path";
9
+ import { Readable, Transform } from "node:stream";
10
+ import { pipeline } from "node:stream/promises";
11
+ import { assertServerRuntime } from "./credentials.js";
12
+ import { PolymorfaCancelledError, PolymorfaConflictError, PolymorfaMediaIntegrityError, } from "./errors.js";
13
+ import { downloadWhatsAppMedia, } from "./media/whatsapp.js";
14
+ const MAC_LENGTH = 10;
15
+ const BLOCK = 16;
16
+ function sameBytes(a, b) {
17
+ return a.length === b.length && timingSafeEqual(a, b);
18
+ }
19
+ function integrity(message, code) {
20
+ return new PolymorfaMediaIntegrityError(message, code);
21
+ }
22
+ /**
23
+ * Incremental `node:crypto` backend. It holds back the trailing 10-byte MAC
24
+ * and lets the decipher hold back the final block, so padding is only
25
+ * removed after the MAC and encrypted hash are verified. With
26
+ * `verify: "streaming"` earlier plaintext chunks are emitted before
27
+ * verification completes.
28
+ */
29
+ export const nodeMediaCrypto = Object.freeze({
30
+ incremental: true,
31
+ decrypt(ciphertext, keys, options) {
32
+ const reader = ciphertext.getReader();
33
+ const decipher = createDecipheriv("aes-256-cbc", keys.cipherKey, keys.iv);
34
+ const mac = createHmac("sha256", keys.macKey).update(keys.iv);
35
+ const encHash = createHash("sha256");
36
+ const plainHash = createHash("sha256");
37
+ let tail = new Uint8Array(0);
38
+ let total = 0;
39
+ const held = [];
40
+ const streaming = options.verify === "streaming";
41
+ const emit = (controller, chunk) => {
42
+ if (chunk.length === 0)
43
+ return;
44
+ plainHash.update(chunk);
45
+ if (streaming)
46
+ controller.enqueue(chunk);
47
+ else
48
+ held.push(chunk);
49
+ };
50
+ const finish = (controller) => {
51
+ if (total <= MAC_LENGTH) {
52
+ throw integrity("The encrypted media is too short.", "media_too_short");
53
+ }
54
+ encHash.update(tail);
55
+ if (options.fileEncSha256 !== undefined &&
56
+ !sameBytes(encHash.digest(), options.fileEncSha256)) {
57
+ throw integrity("The encrypted media hash does not match.", "media_enc_hash_mismatch");
58
+ }
59
+ const expected = mac.digest().subarray(0, MAC_LENGTH);
60
+ if (!sameBytes(expected, tail)) {
61
+ throw integrity("The media MAC does not match.", "media_mac_mismatch");
62
+ }
63
+ const cipherLength = total - MAC_LENGTH;
64
+ if (cipherLength === 0 || cipherLength % BLOCK !== 0) {
65
+ throw integrity("The ciphertext is not a whole number of blocks.", "media_invalid_ciphertext");
66
+ }
67
+ let last;
68
+ try {
69
+ last = decipher.final();
70
+ }
71
+ catch {
72
+ throw integrity("The media padding is invalid.", "media_invalid_padding");
73
+ }
74
+ emit(controller, last);
75
+ if (options.fileSha256 !== undefined &&
76
+ !sameBytes(plainHash.digest(), options.fileSha256)) {
77
+ throw integrity("The decrypted media hash does not match.", "media_hash_mismatch");
78
+ }
79
+ for (const chunk of held.splice(0))
80
+ controller.enqueue(chunk);
81
+ controller.close();
82
+ };
83
+ return new ReadableStream({
84
+ async pull(controller) {
85
+ while (true) {
86
+ const { done, value } = await reader.read();
87
+ if (done) {
88
+ finish(controller);
89
+ return;
90
+ }
91
+ total += value.length;
92
+ const combined = new Uint8Array(tail.length + value.length);
93
+ combined.set(tail, 0);
94
+ combined.set(value, tail.length);
95
+ const releasable = Math.max(combined.length - MAC_LENGTH, 0);
96
+ const release = combined.subarray(0, releasable);
97
+ tail = combined.slice(releasable);
98
+ if (release.length === 0)
99
+ continue;
100
+ mac.update(release);
101
+ encHash.update(release);
102
+ const out = decipher.update(release);
103
+ emit(controller, out);
104
+ if (streaming && out.length > 0)
105
+ return;
106
+ }
107
+ },
108
+ async cancel(reason) {
109
+ held.length = 0;
110
+ await reader.cancel(reason);
111
+ },
112
+ }, { highWaterMark: 0 });
113
+ },
114
+ });
115
+ function fileOptions(options) {
116
+ return {
117
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
118
+ ...(options.overwrite === undefined
119
+ ? {}
120
+ : { overwrite: options.overwrite }),
121
+ ...(options.maxBytes === undefined ? {} : { maxBytes: options.maxBytes }),
122
+ };
123
+ }
124
+ /**
125
+ * Writes a web stream to `path` through a sibling temporary file, then
126
+ * moves it into place. The temporary file is removed on error or abort, and
127
+ * an existing file at `path` is replaced only on success (and only when
128
+ * `overwrite` is not `false`).
129
+ */
130
+ export async function writeStreamToFile(body, path, options = {}) {
131
+ assertServerRuntime();
132
+ const temporary = join(dirname(path), `.${basename(path)}.${randomUUID()}.partial`);
133
+ let bytes = 0;
134
+ const limit = options.maxBytes ?? Number.POSITIVE_INFINITY;
135
+ const counter = new Transform({
136
+ transform(chunk, _encoding, callback) {
137
+ bytes += chunk.length;
138
+ if (bytes > limit) {
139
+ callback(new PolymorfaMediaIntegrityError(`The media exceeds the ${limit} byte limit.`, "media_too_large"));
140
+ return;
141
+ }
142
+ callback(null, chunk);
143
+ },
144
+ });
145
+ try {
146
+ await pipeline(Readable.fromWeb(body), counter, createWriteStream(temporary, { flags: "wx", mode: 0o600 }), ...(options.signal === undefined ? [] : [{ signal: options.signal }]));
147
+ if (options.overwrite === false) {
148
+ try {
149
+ await link(temporary, path);
150
+ }
151
+ catch (error) {
152
+ if (error.code === "EEXIST") {
153
+ throw new PolymorfaConflictError(`${path} already exists.`, {
154
+ code: "file_exists",
155
+ });
156
+ }
157
+ throw error;
158
+ }
159
+ await unlink(temporary);
160
+ }
161
+ else {
162
+ await rename(temporary, path);
163
+ }
164
+ return { path, bytes };
165
+ }
166
+ catch (error) {
167
+ await unlink(temporary).catch(() => undefined);
168
+ await body.cancel().catch(() => undefined);
169
+ if (options.signal?.aborted === true) {
170
+ throw new PolymorfaCancelledError("The request was cancelled by the caller.", { code: "request_cancelled", cause: error });
171
+ }
172
+ throw error;
173
+ }
174
+ }
175
+ /** Downloads Messaging media through the Polymorfa API into a file. */
176
+ export async function downloadMediaToFile(media, mediaId, path, options = {}) {
177
+ const { overwrite, maxBytes, ...request } = options;
178
+ if (overwrite === false && (await exists(path))) {
179
+ throw new PolymorfaConflictError(`${path} already exists.`, {
180
+ code: "file_exists",
181
+ });
182
+ }
183
+ const download = await media.downloadStream(mediaId, request);
184
+ if (maxBytes !== undefined &&
185
+ download.contentLength !== undefined &&
186
+ download.contentLength > maxBytes) {
187
+ await download.body.cancel().catch(() => undefined);
188
+ throw new PolymorfaMediaIntegrityError(`The media is ${download.contentLength} bytes and exceeds the ${maxBytes} byte limit.`, "media_too_large");
189
+ }
190
+ const written = await writeStreamToFile(download.body, path, fileOptions(options));
191
+ return {
192
+ ...written,
193
+ ...(download.contentType === undefined
194
+ ? {}
195
+ : { contentType: download.contentType }),
196
+ ...(download.filename === undefined ? {} : { filename: download.filename }),
197
+ ...(download.requestId === undefined
198
+ ? {}
199
+ : { requestId: download.requestId }),
200
+ };
201
+ }
202
+ /**
203
+ * Downloads and decrypts WhatsApp media straight from the CDN into a file.
204
+ * Decryption streams (`verify: "streaming"` with `nodeMediaCrypto`) and the
205
+ * file is renamed into place only after the MAC and hashes verify.
206
+ */
207
+ export async function downloadWhatsAppMediaToFile(input, path, options = {}) {
208
+ const { overwrite, ...downloadOptions } = options;
209
+ const download = await downloadWhatsAppMedia(input, {
210
+ crypto: nodeMediaCrypto,
211
+ verify: "streaming",
212
+ ...downloadOptions,
213
+ });
214
+ const written = await writeStreamToFile(download.body, path, fileOptions({
215
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
216
+ ...(overwrite === undefined ? {} : { overwrite }),
217
+ }));
218
+ return {
219
+ ...written,
220
+ mediaKind: download.mediaKind,
221
+ mimetype: download.mimetype,
222
+ ...(download.fileName === undefined ? {} : { fileName: download.fileName }),
223
+ ...(download.fileLength === undefined
224
+ ? {}
225
+ : { fileLength: download.fileLength }),
226
+ };
227
+ }
228
+ async function exists(path) {
229
+ try {
230
+ await access(path);
231
+ return true;
232
+ }
233
+ catch {
234
+ return false;
235
+ }
236
+ }
237
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,GAOtB,MAAM,qBAAqB,CAAC;AAI7B,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB,SAAS,SAAS,CAAC,CAAa,EAAE,CAAa;IAC7C,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,SAAS,CAChB,OAAe,EACf,IAA0C;IAE1C,OAAO,IAAI,4BAA4B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwB,MAAM,CAAC,MAAM,CAAC;IAChE,WAAW,EAAE,IAAI;IACjB,OA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CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC3E,GAAG,CAAC,QAAQ,CAAC,UAAU,KAAK,SAAS;YACnC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;KACzC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,IAAY;IAChC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { ApiResponse, ResponseMetadata } from "./transport/types.js";
2
+ export interface PageResult<T> {
3
+ readonly items: readonly T[];
4
+ readonly nextCursor?: string | null;
5
+ }
6
+ export type PageDecoder<T> = (data: unknown, metadata: ResponseMetadata) => PageResult<T>;
7
+ interface CursorPageOptions<T> {
8
+ readonly items: readonly T[];
9
+ readonly nextCursor?: string;
10
+ readonly response: ApiResponse<unknown>;
11
+ readonly loadNext?: () => Promise<CursorPage<T>>;
12
+ }
13
+ export declare class CursorPage<T> implements AsyncIterable<T> {
14
+ #private;
15
+ readonly items: readonly T[];
16
+ readonly nextCursor: string | undefined;
17
+ readonly response: ApiResponse<unknown>;
18
+ constructor(options: CursorPageOptions<T>);
19
+ get hasMore(): boolean;
20
+ nextPage(): Promise<CursorPage<T> | null>;
21
+ [Symbol.asyncIterator](): AsyncIterator<T>;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAC3B,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,gBAAgB,KACvB,UAAU,CAAC,CAAC,CAAC,CAAC;AAEnB,UAAU,iBAAiB,CAAC,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;CAClD;AAED,qBAAa,UAAU,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;gBAG5B,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAOzC,IAAI,OAAO,IAAI,OAAO,CAErB;IAEK,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAIxC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAMlD"}
@@ -0,0 +1,28 @@
1
+ export class CursorPage {
2
+ items;
3
+ nextCursor;
4
+ response;
5
+ #loadNext;
6
+ constructor(options) {
7
+ this.items = Object.freeze([...options.items]);
8
+ this.nextCursor = options.nextCursor;
9
+ this.response = options.response;
10
+ this.#loadNext = options.loadNext;
11
+ }
12
+ get hasMore() {
13
+ return this.nextCursor !== undefined;
14
+ }
15
+ async nextPage() {
16
+ return this.#loadNext === undefined ? null : this.#loadNext();
17
+ }
18
+ async *[Symbol.asyncIterator]() {
19
+ for (const item of this.items)
20
+ yield item;
21
+ const next = await this.nextPage();
22
+ if (next === null)
23
+ return;
24
+ for await (const item of next)
25
+ yield item;
26
+ }
27
+ }
28
+ //# sourceMappingURL=pagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAmBA,MAAM,OAAO,UAAU;IACZ,KAAK,CAAe;IACpB,UAAU,CAAqB;IAC/B,QAAQ,CAAuB;IAC/B,SAAS,CAA6C;IAE/D,YAAY,OAA6B;QACvC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IACpC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,CAAC;QAC1C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACnC,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO;QAC1B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI;YAAE,MAAM,IAAI,CAAC;IAC5C,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { HttpTransport } from "../transport/http.js";
2
+ import type { ApiResponse, RequestOptions } from "../transport/types.js";
3
+ import type { ApiKey, ApiKeyDeactivation, DataEnvelope } from "./types.js";
4
+ export declare class ApiKeysResource {
5
+ private readonly transport;
6
+ constructor(transport: HttpTransport);
7
+ list(options?: RequestOptions): Promise<ApiResponse<DataEnvelope<readonly ApiKey[]>>>;
8
+ deactivate(keyId: string, options?: RequestOptions): Promise<ApiResponse<DataEnvelope<ApiKeyDeactivation>>>;
9
+ }
10
+ //# sourceMappingURL=api-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/platform/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3E,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,aAAa;IAErD,IAAI,CACF,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IAQxD,UAAU,CACR,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC;CAO1D"}
@@ -0,0 +1,22 @@
1
+ import { HttpTransport } from "../transport/http.js";
2
+ export class ApiKeysResource {
3
+ transport;
4
+ constructor(transport) {
5
+ this.transport = transport;
6
+ }
7
+ list(options = {}) {
8
+ return this.transport.request({
9
+ method: "GET",
10
+ path: "/platform/keys",
11
+ ...options,
12
+ });
13
+ }
14
+ deactivate(keyId, options = {}) {
15
+ return this.transport.request({
16
+ method: "DELETE",
17
+ path: `/platform/keys/${encodeURIComponent(keyId)}`,
18
+ ...options,
19
+ });
20
+ }
21
+ }
22
+ //# sourceMappingURL=api-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../../src/platform/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;IAAG,CAAC;IAEzD,IAAI,CACF,UAA0B,EAAE;QAE5B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB;YACtB,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CACR,KAAa,EACb,UAA0B,EAAE;QAE5B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,KAAK,CAAC,EAAE;YACnD,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import { HttpTransport } from "../transport/http.js";
2
+ import type { ApiResponse, RequestOptions } from "../transport/types.js";
3
+ import type { DataEnvelope, PlatformPayload } from "./types.js";
4
+ type AudienceResponse = Promise<ApiResponse<DataEnvelope<PlatformPayload>>>;
5
+ export declare class AudiencesResource {
6
+ private readonly transport;
7
+ constructor(transport: HttpTransport);
8
+ list(options?: RequestOptions): AudienceResponse;
9
+ create(body?: PlatformPayload, options?: RequestOptions): AudienceResponse;
10
+ retrieve(listId: string, options?: RequestOptions): AudienceResponse;
11
+ delete(listId: string, options?: RequestOptions): AudienceResponse;
12
+ createUpload(body?: PlatformPayload, options?: RequestOptions): AudienceResponse;
13
+ private write;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=audiences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audiences.d.ts","sourceRoot":"","sources":["../../src/platform/audiences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEhE,KAAK,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAE5E,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,aAAa;IAErD,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,gBAAgB;IAQpD,MAAM,CACJ,IAAI,CAAC,EAAE,eAAe,EACtB,OAAO,GAAE,cAAmB,GAC3B,gBAAgB;IAInB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,gBAAgB;IAQxE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,gBAAgB;IAQtE,YAAY,CACV,IAAI,CAAC,EAAE,eAAe,EACtB,OAAO,GAAE,cAAmB,GAC3B,gBAAgB;IAInB,OAAO,CAAC,KAAK;CAYd"}
@@ -0,0 +1,46 @@
1
+ import { HttpTransport } from "../transport/http.js";
2
+ export class AudiencesResource {
3
+ transport;
4
+ constructor(transport) {
5
+ this.transport = transport;
6
+ }
7
+ list(options = {}) {
8
+ return this.transport.request({
9
+ method: "GET",
10
+ path: "/platform/audiences",
11
+ ...options,
12
+ });
13
+ }
14
+ create(body, options = {}) {
15
+ return this.write("/platform/audiences", body, options);
16
+ }
17
+ retrieve(listId, options = {}) {
18
+ return this.transport.request({
19
+ method: "GET",
20
+ path: audiencePath(listId),
21
+ ...options,
22
+ });
23
+ }
24
+ delete(listId, options = {}) {
25
+ return this.transport.request({
26
+ method: "DELETE",
27
+ path: audiencePath(listId),
28
+ ...options,
29
+ });
30
+ }
31
+ createUpload(body, options = {}) {
32
+ return this.write("/platform/audiences/uploads", body, options);
33
+ }
34
+ write(path, body, options) {
35
+ return this.transport.request({
36
+ method: "POST",
37
+ path,
38
+ ...(body === undefined ? {} : { body }),
39
+ ...options,
40
+ });
41
+ }
42
+ }
43
+ function audiencePath(listId) {
44
+ return `/platform/audiences/${encodeURIComponent(listId)}`;
45
+ }
46
+ //# sourceMappingURL=audiences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audiences.js","sourceRoot":"","sources":["../../src/platform/audiences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMrD,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;IAAG,CAAC;IAEzD,IAAI,CAAC,UAA0B,EAAE;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,qBAAqB;YAC3B,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CACJ,IAAsB,EACtB,UAA0B,EAAE;QAE5B,OAAO,IAAI,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,QAAQ,CAAC,MAAc,EAAE,UAA0B,EAAE;QACnD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;YAC1B,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,UAA0B,EAAE;QACjD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;YAC1B,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED,YAAY,CACV,IAAsB,EACtB,UAA0B,EAAE;QAE5B,OAAO,IAAI,CAAC,KAAK,CAAC,6BAA6B,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAEO,KAAK,CACX,IAAY,EACZ,IAAiC,EACjC,OAAuB;QAEvB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,MAAM;YACd,IAAI;YACJ,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;YACvC,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF;AAED,SAAS,YAAY,CAAC,MAAc;IAClC,OAAO,uBAAuB,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { HttpTransport } from "../transport/http.js";
2
+ import type { ApiResponse, RequestOptions } from "../transport/types.js";
3
+ import type { AuditLog, DataEnvelope, ListAuditLogsParams } from "./types.js";
4
+ export declare class AuditLogsResource {
5
+ private readonly transport;
6
+ constructor(transport: HttpTransport);
7
+ list(params?: ListAuditLogsParams, options?: RequestOptions): Promise<ApiResponse<DataEnvelope<readonly AuditLog[]>>>;
8
+ }
9
+ //# sourceMappingURL=audit-logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-logs.d.ts","sourceRoot":"","sources":["../../src/platform/audit-logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE9E,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,aAAa;IAErD,IAAI,CACF,MAAM,GAAE,mBAAwB,EAChC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC,CAAC;CAY3D"}
@@ -0,0 +1,20 @@
1
+ import { HttpTransport } from "../transport/http.js";
2
+ export class AuditLogsResource {
3
+ transport;
4
+ constructor(transport) {
5
+ this.transport = transport;
6
+ }
7
+ list(params = {}, options = {}) {
8
+ return this.transport.request({
9
+ method: "GET",
10
+ path: "/platform/audit",
11
+ query: {
12
+ ...(params.action === undefined ? {} : { action: params.action }),
13
+ ...(params.resource === undefined ? {} : { resource: params.resource }),
14
+ ...(params.limit === undefined ? {} : { limit: params.limit }),
15
+ },
16
+ ...options,
17
+ });
18
+ }
19
+ }
20
+ //# sourceMappingURL=audit-logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-logs.js","sourceRoot":"","sources":["../../src/platform/audit-logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,SAAwB;QAAxB,cAAS,GAAT,SAAS,CAAe;IAAG,CAAC;IAEzD,IAAI,CACF,SAA8B,EAAE,EAChC,UAA0B,EAAE;QAE5B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5B,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,iBAAiB;YACvB,KAAK,EAAE;gBACL,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;gBACjE,GAAG,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACvE,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;aAC/D;YACD,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ import { HttpTransport } from "../transport/http.js";
2
+ import type { ApiResponse, RequestOptions } from "../transport/types.js";
3
+ import type { BanSafeClaim, BanSafeClaimsEnvelope, BanSafeCollectionEnvelope, BanSafeEnforcementEnvelope, BanSafeFindingsEnvelope, BanSafeHealthActionsEnvelope, BanSafeHealthEnvelope, BanSafeHealthHistory, BanSafeIncident, BanSafeIncidentReceipt, BanSafeIncidentsEnvelope, BanSafeSignalDefinition, BanSafeNumberDetail, BanSafeTelemetryDetail, BanSafeTelemetryHistoryEnvelope, DataEnvelope, ListBanSafeClaimsParams, ListBanSafeCollectionParams, ListBanSafeEnforcementParams, ListBanSafeFindingsParams, ListBanSafeHealthActionsParams, ListBanSafeHealthHistoryParams, ListBanSafeHealthParams, ListBanSafeIncidentsParams, ListBanSafeTelemetryHistoryParams, ReportBanSafeIncidentRequest } from "./types.js";
4
+ export declare class BanSafeResource {
5
+ private readonly transport;
6
+ constructor(transport: HttpTransport);
7
+ listHealth(params?: ListBanSafeHealthParams, options?: RequestOptions): Promise<ApiResponse<BanSafeHealthEnvelope>>;
8
+ getHealth(session: string, options?: RequestOptions): Promise<ApiResponse<DataEnvelope<BanSafeNumberDetail>>>;
9
+ listHealthHistory(session: string, params?: ListBanSafeHealthHistoryParams, options?: RequestOptions): Promise<ApiResponse<DataEnvelope<BanSafeHealthHistory>>>;
10
+ listSignals(options?: RequestOptions): Promise<ApiResponse<DataEnvelope<readonly BanSafeSignalDefinition[]>>>;
11
+ getTelemetry(session: string, options?: RequestOptions): Promise<ApiResponse<DataEnvelope<BanSafeTelemetryDetail>>>;
12
+ listTelemetryHistory(session: string, params?: ListBanSafeTelemetryHistoryParams, options?: RequestOptions): Promise<ApiResponse<BanSafeTelemetryHistoryEnvelope>>;
13
+ listCollection(params?: ListBanSafeCollectionParams, options?: RequestOptions): Promise<ApiResponse<BanSafeCollectionEnvelope>>;
14
+ listHealthActions(params?: ListBanSafeHealthActionsParams, options?: RequestOptions): Promise<ApiResponse<BanSafeHealthActionsEnvelope>>;
15
+ listFindings(params?: ListBanSafeFindingsParams, options?: RequestOptions): Promise<ApiResponse<BanSafeFindingsEnvelope>>;
16
+ listEnforcement(params?: ListBanSafeEnforcementParams, options?: RequestOptions): Promise<ApiResponse<BanSafeEnforcementEnvelope>>;
17
+ listIncidents(params?: ListBanSafeIncidentsParams, options?: RequestOptions): Promise<ApiResponse<BanSafeIncidentsEnvelope>>;
18
+ createIncident(body: ReportBanSafeIncidentRequest, options: RequestOptions): Promise<ApiResponse<DataEnvelope<BanSafeIncidentReceipt>>>;
19
+ retractIncident(incidentId: string, options?: RequestOptions): Promise<ApiResponse<DataEnvelope<BanSafeIncident>>>;
20
+ listClaims(params?: ListBanSafeClaimsParams, options?: RequestOptions): Promise<ApiResponse<BanSafeClaimsEnvelope>>;
21
+ getClaim(claimId: string, options?: RequestOptions): Promise<ApiResponse<DataEnvelope<BanSafeClaim>>>;
22
+ private get;
23
+ }
24
+ //# sourceMappingURL=bansafe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bansafe.d.ts","sourceRoot":"","sources":["../../src/platform/bansafe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EAEX,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,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port = transport;
6
+ }
7
+ listHealth(params = {}, options = {}) {
8
+ return this.get("/platform/bansafe/health", params, options);
9
+ }
10
+ getHealth(session, options = {}) {
11
+ return this.get(`/platform/bansafe/health/${encodeURIComponent(session)}`, {}, options);
12
+ }
13
+ listHealthHistory(session, params = {}, options = {}) {
14
+ return this.get(`/platform/bansafe/health/${encodeURIComponent(session)}/history`, params, options);
15
+ }
16
+ listSignals(options = {}) {
17
+ return this.get("/platform/bansafe/signals", {}, options);
18
+ }
19
+ getTelemetry(session, options = {}) {
20
+ return this.get(`/platform/bansafe/telemetry/${encodeURIComponent(session)}`, {}, options);
21
+ }
22
+ listTelemetryHistory(session, params = {}, options = {}) {
23
+ return this.get(`/platform/bansafe/telemetry/${encodeURIComponent(session)}/history`, params, options);
24
+ }
25
+ listCollection(params = {}, options = {}) {
26
+ return this.get("/platform/bansafe/collection", params, options);
27
+ }
28
+ listHealthActions(params = {}, options = {}) {
29
+ return this.get("/platform/bansafe/health-actions", params, options);
30
+ }
31
+ listFindings(params = {}, options = {}) {
32
+ return this.get("/platform/bansafe/findings", params, options);
33
+ }
34
+ listEnforcement(params = {}, options = {}) {
35
+ return this.get("/platform/bansafe/enforcement", params, options);
36
+ }
37
+ listIncidents(params = {}, options = {}) {
38
+ return this.get("/platform/bansafe/incidents", params, options);
39
+ }
40
+ createIncident(body, options) {
41
+ return this.transport.request({
42
+ method: "POST",
43
+ path: "/platform/bansafe/incidents",
44
+ body,
45
+ ...options,
46
+ });
47
+ }
48
+ retractIncident(incidentId, options = {}) {
49
+ return this.transport.request({
50
+ method: "POST",
51
+ path: `/platform/bansafe/incidents/${encodeURIComponent(incidentId)}/retract`,
52
+ ...options,
53
+ });
54
+ }
55
+ listClaims(params = {}, options = {}) {
56
+ return this.get("/platform/bansafe/claims", params, options);
57
+ }
58
+ getClaim(claimId, options = {}) {
59
+ return this.get(`/platform/bansafe/claims/${encodeURIComponent(claimId)}`, {}, options);
60
+ }
61
+ get(path, params, options) {
62
+ return this.transport.request({
63
+ method: "GET",
64
+ path,
65
+ query: params,
66
+ ...options,
67
+ });
68
+ }
69
+ }
70
+ //# sourceMappingURL=bansafe.js.map