sendwend 0.0.0-stage → 12.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (680) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2082 -2
  3. package/dist/_virtual/_rolldown/runtime.cjs +22 -0
  4. package/dist/apns-relay.cjs +91 -0
  5. package/dist/apns-relay.cjs.map +1 -0
  6. package/dist/apns-relay.d.cts +26 -0
  7. package/dist/apns-relay.d.cts.map +1 -0
  8. package/dist/apns-relay.d.mts +26 -0
  9. package/dist/apns-relay.d.mts.map +1 -0
  10. package/dist/apns-relay.mjs +90 -0
  11. package/dist/apns-relay.mjs.map +1 -0
  12. package/dist/apns.cjs +215 -0
  13. package/dist/apns.cjs.map +1 -0
  14. package/dist/apns.d.cts +110 -0
  15. package/dist/apns.d.cts.map +1 -0
  16. package/dist/apns.d.mts +110 -0
  17. package/dist/apns.d.mts.map +1 -0
  18. package/dist/apns.mjs +207 -0
  19. package/dist/apns.mjs.map +1 -0
  20. package/dist/aws/engine-step.cjs +105 -0
  21. package/dist/aws/engine-step.cjs.map +1 -0
  22. package/dist/aws/engine-step.d.cts +42 -0
  23. package/dist/aws/engine-step.d.cts.map +1 -0
  24. package/dist/aws/engine-step.d.mts +42 -0
  25. package/dist/aws/engine-step.d.mts.map +1 -0
  26. package/dist/aws/engine-step.mjs +103 -0
  27. package/dist/aws/engine-step.mjs.map +1 -0
  28. package/dist/aws/function-url.cjs +53 -0
  29. package/dist/aws/function-url.cjs.map +1 -0
  30. package/dist/aws/function-url.d.cts +36 -0
  31. package/dist/aws/function-url.d.cts.map +1 -0
  32. package/dist/aws/function-url.d.mts +36 -0
  33. package/dist/aws/function-url.d.mts.map +1 -0
  34. package/dist/aws/function-url.mjs +50 -0
  35. package/dist/aws/function-url.mjs.map +1 -0
  36. package/dist/aws/index.cjs +232 -0
  37. package/dist/aws/index.cjs.map +1 -0
  38. package/dist/aws/index.d.cts +73 -0
  39. package/dist/aws/index.d.cts.map +1 -0
  40. package/dist/aws/index.d.mts +73 -0
  41. package/dist/aws/index.d.mts.map +1 -0
  42. package/dist/aws/index.mjs +218 -0
  43. package/dist/aws/index.mjs.map +1 -0
  44. package/dist/aws/instances.cjs +218 -0
  45. package/dist/aws/instances.cjs.map +1 -0
  46. package/dist/aws/instances.d.cts +102 -0
  47. package/dist/aws/instances.d.cts.map +1 -0
  48. package/dist/aws/instances.d.mts +102 -0
  49. package/dist/aws/instances.d.mts.map +1 -0
  50. package/dist/aws/instances.mjs +214 -0
  51. package/dist/aws/instances.mjs.map +1 -0
  52. package/dist/aws/lambda-api.cjs +86 -0
  53. package/dist/aws/lambda-api.cjs.map +1 -0
  54. package/dist/aws/lambda-api.d.cts +41 -0
  55. package/dist/aws/lambda-api.d.cts.map +1 -0
  56. package/dist/aws/lambda-api.d.mts +41 -0
  57. package/dist/aws/lambda-api.d.mts.map +1 -0
  58. package/dist/aws/lambda-api.mjs +85 -0
  59. package/dist/aws/lambda-api.mjs.map +1 -0
  60. package/dist/client.cjs +216 -0
  61. package/dist/client.cjs.map +1 -0
  62. package/dist/client.d.cts +193 -0
  63. package/dist/client.d.cts.map +1 -0
  64. package/dist/client.d.mts +193 -0
  65. package/dist/client.d.mts.map +1 -0
  66. package/dist/client.mjs +212 -0
  67. package/dist/client.mjs.map +1 -0
  68. package/dist/cloudflare/bindings.cjs +49 -0
  69. package/dist/cloudflare/bindings.cjs.map +1 -0
  70. package/dist/cloudflare/bindings.d.cts +31 -0
  71. package/dist/cloudflare/bindings.d.cts.map +1 -0
  72. package/dist/cloudflare/bindings.d.mts +31 -0
  73. package/dist/cloudflare/bindings.d.mts.map +1 -0
  74. package/dist/cloudflare/bindings.mjs +46 -0
  75. package/dist/cloudflare/bindings.mjs.map +1 -0
  76. package/dist/cloudflare/index.cjs +73 -0
  77. package/dist/cloudflare/index.d.cts +25 -0
  78. package/dist/cloudflare/index.d.mts +25 -0
  79. package/dist/cloudflare/index.mjs +20 -0
  80. package/dist/cloudflare/runner.cjs +200 -0
  81. package/dist/cloudflare/runner.cjs.map +1 -0
  82. package/dist/cloudflare/runner.d.cts +83 -0
  83. package/dist/cloudflare/runner.d.cts.map +1 -0
  84. package/dist/cloudflare/runner.d.mts +83 -0
  85. package/dist/cloudflare/runner.d.mts.map +1 -0
  86. package/dist/cloudflare/runner.mjs +199 -0
  87. package/dist/cloudflare/runner.mjs.map +1 -0
  88. package/dist/cloudflare/worker.cjs +106 -0
  89. package/dist/cloudflare/worker.cjs.map +1 -0
  90. package/dist/cloudflare/worker.d.cts +52 -0
  91. package/dist/cloudflare/worker.d.cts.map +1 -0
  92. package/dist/cloudflare/worker.d.mts +52 -0
  93. package/dist/cloudflare/worker.d.mts.map +1 -0
  94. package/dist/cloudflare/worker.mjs +104 -0
  95. package/dist/cloudflare/worker.mjs.map +1 -0
  96. package/dist/cloudflare/workers.d.cjs +0 -0
  97. package/dist/cloudflare/workers.d.cts +42 -0
  98. package/dist/cloudflare/workers.d.cts.map +1 -0
  99. package/dist/cloudflare/workers.d.mts +42 -0
  100. package/dist/cloudflare/workers.d.mts.map +1 -0
  101. package/dist/config.cjs +257 -0
  102. package/dist/config.cjs.map +1 -0
  103. package/dist/config.d.cts +184 -0
  104. package/dist/config.d.cts.map +1 -0
  105. package/dist/config.d.mts +184 -0
  106. package/dist/config.d.mts.map +1 -0
  107. package/dist/config.mjs +246 -0
  108. package/dist/config.mjs.map +1 -0
  109. package/dist/contract.cjs +222 -0
  110. package/dist/contract.cjs.map +1 -0
  111. package/dist/contract.d.cts +110 -0
  112. package/dist/contract.d.cts.map +1 -0
  113. package/dist/contract.d.mts +110 -0
  114. package/dist/contract.d.mts.map +1 -0
  115. package/dist/contract.mjs +216 -0
  116. package/dist/contract.mjs.map +1 -0
  117. package/dist/date-time.cjs +22 -0
  118. package/dist/date-time.cjs.map +1 -0
  119. package/dist/date-time.d.cts +10 -0
  120. package/dist/date-time.d.cts.map +1 -0
  121. package/dist/date-time.d.mts +10 -0
  122. package/dist/date-time.d.mts.map +1 -0
  123. package/dist/date-time.mjs +21 -0
  124. package/dist/date-time.mjs.map +1 -0
  125. package/dist/dsl/action.cjs +25 -0
  126. package/dist/dsl/action.cjs.map +1 -0
  127. package/dist/dsl/action.d.cts +63 -0
  128. package/dist/dsl/action.d.cts.map +1 -0
  129. package/dist/dsl/action.d.mts +63 -0
  130. package/dist/dsl/action.d.mts.map +1 -0
  131. package/dist/dsl/action.mjs +24 -0
  132. package/dist/dsl/action.mjs.map +1 -0
  133. package/dist/dsl/base.cjs +33 -0
  134. package/dist/dsl/base.cjs.map +1 -0
  135. package/dist/dsl/base.d.cts +43 -0
  136. package/dist/dsl/base.d.cts.map +1 -0
  137. package/dist/dsl/base.d.mts +43 -0
  138. package/dist/dsl/base.d.mts.map +1 -0
  139. package/dist/dsl/base.mjs +29 -0
  140. package/dist/dsl/base.mjs.map +1 -0
  141. package/dist/dsl/bundle.cjs +287 -0
  142. package/dist/dsl/bundle.cjs.map +1 -0
  143. package/dist/dsl/bundle.d.cts +33 -0
  144. package/dist/dsl/bundle.d.cts.map +1 -0
  145. package/dist/dsl/bundle.d.mts +33 -0
  146. package/dist/dsl/bundle.d.mts.map +1 -0
  147. package/dist/dsl/bundle.mjs +284 -0
  148. package/dist/dsl/bundle.mjs.map +1 -0
  149. package/dist/dsl/condition.cjs +200 -0
  150. package/dist/dsl/condition.cjs.map +1 -0
  151. package/dist/dsl/condition.d.cts +151 -0
  152. package/dist/dsl/condition.d.cts.map +1 -0
  153. package/dist/dsl/condition.d.mts +151 -0
  154. package/dist/dsl/condition.d.mts.map +1 -0
  155. package/dist/dsl/condition.mjs +178 -0
  156. package/dist/dsl/condition.mjs.map +1 -0
  157. package/dist/dsl/flow.cjs +335 -0
  158. package/dist/dsl/flow.cjs.map +1 -0
  159. package/dist/dsl/flow.d.cts +278 -0
  160. package/dist/dsl/flow.d.cts.map +1 -0
  161. package/dist/dsl/flow.d.mts +278 -0
  162. package/dist/dsl/flow.d.mts.map +1 -0
  163. package/dist/dsl/flow.mjs +331 -0
  164. package/dist/dsl/flow.mjs.map +1 -0
  165. package/dist/dsl/index.cjs +37 -0
  166. package/dist/dsl/index.d.cts +34 -0
  167. package/dist/dsl/index.d.mts +34 -0
  168. package/dist/dsl/index.mjs +9 -0
  169. package/dist/dsl/refs.cjs +101 -0
  170. package/dist/dsl/refs.cjs.map +1 -0
  171. package/dist/dsl/refs.d.cts +127 -0
  172. package/dist/dsl/refs.d.cts.map +1 -0
  173. package/dist/dsl/refs.d.mts +127 -0
  174. package/dist/dsl/refs.d.mts.map +1 -0
  175. package/dist/dsl/refs.mjs +93 -0
  176. package/dist/dsl/refs.mjs.map +1 -0
  177. package/dist/dsl/template.cjs +19 -0
  178. package/dist/dsl/template.cjs.map +1 -0
  179. package/dist/dsl/template.d.cts +30 -0
  180. package/dist/dsl/template.d.cts.map +1 -0
  181. package/dist/dsl/template.d.mts +30 -0
  182. package/dist/dsl/template.d.mts.map +1 -0
  183. package/dist/dsl/template.mjs +18 -0
  184. package/dist/dsl/template.mjs.map +1 -0
  185. package/dist/dsl/trigger.cjs +53 -0
  186. package/dist/dsl/trigger.cjs.map +1 -0
  187. package/dist/dsl/trigger.d.cts +112 -0
  188. package/dist/dsl/trigger.d.cts.map +1 -0
  189. package/dist/dsl/trigger.d.mts +112 -0
  190. package/dist/dsl/trigger.d.mts.map +1 -0
  191. package/dist/dsl/trigger.mjs +52 -0
  192. package/dist/dsl/trigger.mjs.map +1 -0
  193. package/dist/dsl/workflow.cjs +143 -0
  194. package/dist/dsl/workflow.cjs.map +1 -0
  195. package/dist/dsl/workflow.d.cts +88 -0
  196. package/dist/dsl/workflow.d.cts.map +1 -0
  197. package/dist/dsl/workflow.d.mts +88 -0
  198. package/dist/dsl/workflow.d.mts.map +1 -0
  199. package/dist/dsl/workflow.mjs +142 -0
  200. package/dist/dsl/workflow.mjs.map +1 -0
  201. package/dist/email-context.cjs +28 -0
  202. package/dist/email-context.cjs.map +1 -0
  203. package/dist/email-context.d.cts +9 -0
  204. package/dist/email-context.d.cts.map +1 -0
  205. package/dist/email-context.d.mts +9 -0
  206. package/dist/email-context.d.mts.map +1 -0
  207. package/dist/email-context.mjs +26 -0
  208. package/dist/email-context.mjs.map +1 -0
  209. package/dist/email-sender.cjs +93 -0
  210. package/dist/email-sender.cjs.map +1 -0
  211. package/dist/email-sender.d.cts +88 -0
  212. package/dist/email-sender.d.cts.map +1 -0
  213. package/dist/email-sender.d.mts +88 -0
  214. package/dist/email-sender.d.mts.map +1 -0
  215. package/dist/email-sender.mjs +90 -0
  216. package/dist/email-sender.mjs.map +1 -0
  217. package/dist/email.cjs +73 -0
  218. package/dist/email.cjs.map +1 -0
  219. package/dist/email.d.cts +59 -0
  220. package/dist/email.d.cts.map +1 -0
  221. package/dist/email.d.mts +59 -0
  222. package/dist/email.d.mts.map +1 -0
  223. package/dist/email.mjs +68 -0
  224. package/dist/email.mjs.map +1 -0
  225. package/dist/engine/actions.cjs +19 -0
  226. package/dist/engine/actions.cjs.map +1 -0
  227. package/dist/engine/actions.d.cts +27 -0
  228. package/dist/engine/actions.d.cts.map +1 -0
  229. package/dist/engine/actions.d.mts +27 -0
  230. package/dist/engine/actions.d.mts.map +1 -0
  231. package/dist/engine/actions.mjs +18 -0
  232. package/dist/engine/actions.mjs.map +1 -0
  233. package/dist/engine/bucket.cjs +71 -0
  234. package/dist/engine/bucket.cjs.map +1 -0
  235. package/dist/engine/bucket.d.cts +30 -0
  236. package/dist/engine/bucket.d.cts.map +1 -0
  237. package/dist/engine/bucket.d.mts +30 -0
  238. package/dist/engine/bucket.d.mts.map +1 -0
  239. package/dist/engine/bucket.mjs +68 -0
  240. package/dist/engine/bucket.mjs.map +1 -0
  241. package/dist/engine/condition.cjs +199 -0
  242. package/dist/engine/condition.cjs.map +1 -0
  243. package/dist/engine/condition.d.cts +76 -0
  244. package/dist/engine/condition.d.cts.map +1 -0
  245. package/dist/engine/condition.d.mts +76 -0
  246. package/dist/engine/condition.d.mts.map +1 -0
  247. package/dist/engine/condition.mjs +192 -0
  248. package/dist/engine/condition.mjs.map +1 -0
  249. package/dist/engine/duration.cjs +33 -0
  250. package/dist/engine/duration.cjs.map +1 -0
  251. package/dist/engine/duration.d.cts +3 -0
  252. package/dist/engine/duration.d.cts.map +1 -0
  253. package/dist/engine/duration.d.mts +3 -0
  254. package/dist/engine/duration.d.mts.map +1 -0
  255. package/dist/engine/duration.mjs +32 -0
  256. package/dist/engine/duration.mjs.map +1 -0
  257. package/dist/engine/index.cjs +33 -0
  258. package/dist/engine/index.d.cts +10 -0
  259. package/dist/engine/index.d.mts +10 -0
  260. package/dist/engine/index.mjs +9 -0
  261. package/dist/engine/interpreter.cjs +613 -0
  262. package/dist/engine/interpreter.cjs.map +1 -0
  263. package/dist/engine/interpreter.d.cts +4 -0
  264. package/dist/engine/interpreter.d.cts.map +1 -0
  265. package/dist/engine/interpreter.d.mts +4 -0
  266. package/dist/engine/interpreter.d.mts.map +1 -0
  267. package/dist/engine/interpreter.mjs +612 -0
  268. package/dist/engine/interpreter.mjs.map +1 -0
  269. package/dist/engine/ports.cjs +0 -0
  270. package/dist/engine/ports.d.cts +373 -0
  271. package/dist/engine/ports.d.cts.map +1 -0
  272. package/dist/engine/ports.d.mts +373 -0
  273. package/dist/engine/ports.d.mts.map +1 -0
  274. package/dist/engine/ports.mjs +1 -0
  275. package/dist/engine/recipient.cjs +22 -0
  276. package/dist/engine/recipient.cjs.map +1 -0
  277. package/dist/engine/recipient.d.cts +11 -0
  278. package/dist/engine/recipient.d.cts.map +1 -0
  279. package/dist/engine/recipient.d.mts +11 -0
  280. package/dist/engine/recipient.d.mts.map +1 -0
  281. package/dist/engine/recipient.mjs +21 -0
  282. package/dist/engine/recipient.mjs.map +1 -0
  283. package/dist/engine/retry.cjs +106 -0
  284. package/dist/engine/retry.cjs.map +1 -0
  285. package/dist/engine/retry.d.cts +73 -0
  286. package/dist/engine/retry.d.cts.map +1 -0
  287. package/dist/engine/retry.d.mts +73 -0
  288. package/dist/engine/retry.d.mts.map +1 -0
  289. package/dist/engine/retry.mjs +98 -0
  290. package/dist/engine/retry.mjs.map +1 -0
  291. package/dist/engine/time-scale.cjs +153 -0
  292. package/dist/engine/time-scale.cjs.map +1 -0
  293. package/dist/engine/time-scale.d.cts +41 -0
  294. package/dist/engine/time-scale.d.cts.map +1 -0
  295. package/dist/engine/time-scale.d.mts +41 -0
  296. package/dist/engine/time-scale.d.mts.map +1 -0
  297. package/dist/engine/time-scale.mjs +150 -0
  298. package/dist/engine/time-scale.mjs.map +1 -0
  299. package/dist/engine/time-window.cjs +148 -0
  300. package/dist/engine/time-window.cjs.map +1 -0
  301. package/dist/engine/time-window.d.cts +20 -0
  302. package/dist/engine/time-window.d.cts.map +1 -0
  303. package/dist/engine/time-window.d.mts +20 -0
  304. package/dist/engine/time-window.d.mts.map +1 -0
  305. package/dist/engine/time-window.mjs +146 -0
  306. package/dist/engine/time-window.mjs.map +1 -0
  307. package/dist/fcm.cjs +208 -0
  308. package/dist/fcm.cjs.map +1 -0
  309. package/dist/fcm.d.cts +89 -0
  310. package/dist/fcm.d.cts.map +1 -0
  311. package/dist/fcm.d.mts +89 -0
  312. package/dist/fcm.d.mts.map +1 -0
  313. package/dist/fcm.mjs +202 -0
  314. package/dist/fcm.mjs.map +1 -0
  315. package/dist/hash.cjs +244 -0
  316. package/dist/hash.cjs.map +1 -0
  317. package/dist/hash.d.cts +28 -0
  318. package/dist/hash.d.cts.map +1 -0
  319. package/dist/hash.d.mts +28 -0
  320. package/dist/hash.d.mts.map +1 -0
  321. package/dist/hash.mjs +238 -0
  322. package/dist/hash.mjs.map +1 -0
  323. package/dist/host/auth.cjs +48 -0
  324. package/dist/host/auth.cjs.map +1 -0
  325. package/dist/host/auth.d.cts +33 -0
  326. package/dist/host/auth.d.cts.map +1 -0
  327. package/dist/host/auth.d.mts +33 -0
  328. package/dist/host/auth.d.mts.map +1 -0
  329. package/dist/host/auth.mjs +45 -0
  330. package/dist/host/auth.mjs.map +1 -0
  331. package/dist/host/batch.cjs +178 -0
  332. package/dist/host/batch.cjs.map +1 -0
  333. package/dist/host/batch.d.cts +92 -0
  334. package/dist/host/batch.d.cts.map +1 -0
  335. package/dist/host/batch.d.mts +92 -0
  336. package/dist/host/batch.d.mts.map +1 -0
  337. package/dist/host/batch.mjs +169 -0
  338. package/dist/host/batch.mjs.map +1 -0
  339. package/dist/host/channels.cjs +256 -0
  340. package/dist/host/channels.cjs.map +1 -0
  341. package/dist/host/channels.d.cts +66 -0
  342. package/dist/host/channels.d.cts.map +1 -0
  343. package/dist/host/channels.d.mts +66 -0
  344. package/dist/host/channels.d.mts.map +1 -0
  345. package/dist/host/channels.mjs +252 -0
  346. package/dist/host/channels.mjs.map +1 -0
  347. package/dist/host/execute.cjs +102 -0
  348. package/dist/host/execute.cjs.map +1 -0
  349. package/dist/host/execute.d.cts +38 -0
  350. package/dist/host/execute.d.cts.map +1 -0
  351. package/dist/host/execute.d.mts +38 -0
  352. package/dist/host/execute.d.mts.map +1 -0
  353. package/dist/host/execute.mjs +101 -0
  354. package/dist/host/execute.mjs.map +1 -0
  355. package/dist/host/fresh-read.cjs +29 -0
  356. package/dist/host/fresh-read.cjs.map +1 -0
  357. package/dist/host/fresh-read.d.cts +16 -0
  358. package/dist/host/fresh-read.d.cts.map +1 -0
  359. package/dist/host/fresh-read.d.mts +16 -0
  360. package/dist/host/fresh-read.d.mts.map +1 -0
  361. package/dist/host/fresh-read.mjs +28 -0
  362. package/dist/host/fresh-read.mjs.map +1 -0
  363. package/dist/host/http.cjs +393 -0
  364. package/dist/host/http.cjs.map +1 -0
  365. package/dist/host/http.d.cts +61 -0
  366. package/dist/host/http.d.cts.map +1 -0
  367. package/dist/host/http.d.mts +61 -0
  368. package/dist/host/http.d.mts.map +1 -0
  369. package/dist/host/http.mjs +389 -0
  370. package/dist/host/http.mjs.map +1 -0
  371. package/dist/host/ingest.cjs +1210 -0
  372. package/dist/host/ingest.cjs.map +1 -0
  373. package/dist/host/ingest.d.cts +497 -0
  374. package/dist/host/ingest.d.cts.map +1 -0
  375. package/dist/host/ingest.d.mts +497 -0
  376. package/dist/host/ingest.d.mts.map +1 -0
  377. package/dist/host/ingest.mjs +1172 -0
  378. package/dist/host/ingest.mjs.map +1 -0
  379. package/dist/host/journey-host.cjs +223 -0
  380. package/dist/host/journey-host.cjs.map +1 -0
  381. package/dist/host/journey-host.d.cts +118 -0
  382. package/dist/host/journey-host.d.cts.map +1 -0
  383. package/dist/host/journey-host.d.mts +118 -0
  384. package/dist/host/journey-host.d.mts.map +1 -0
  385. package/dist/host/journey-host.mjs +219 -0
  386. package/dist/host/journey-host.mjs.map +1 -0
  387. package/dist/host/platform.cjs +20 -0
  388. package/dist/host/platform.cjs.map +1 -0
  389. package/dist/host/platform.d.cts +120 -0
  390. package/dist/host/platform.d.cts.map +1 -0
  391. package/dist/host/platform.d.mts +120 -0
  392. package/dist/host/platform.d.mts.map +1 -0
  393. package/dist/host/platform.mjs +18 -0
  394. package/dist/host/platform.mjs.map +1 -0
  395. package/dist/host/senders.cjs +71 -0
  396. package/dist/host/senders.cjs.map +1 -0
  397. package/dist/host/senders.d.cts +34 -0
  398. package/dist/host/senders.d.cts.map +1 -0
  399. package/dist/host/senders.d.mts +34 -0
  400. package/dist/host/senders.d.mts.map +1 -0
  401. package/dist/host/senders.mjs +67 -0
  402. package/dist/host/senders.mjs.map +1 -0
  403. package/dist/host/workflow-cache.cjs +47 -0
  404. package/dist/host/workflow-cache.cjs.map +1 -0
  405. package/dist/host/workflow-cache.d.cts +21 -0
  406. package/dist/host/workflow-cache.d.cts.map +1 -0
  407. package/dist/host/workflow-cache.d.mts +21 -0
  408. package/dist/host/workflow-cache.d.mts.map +1 -0
  409. package/dist/host/workflow-cache.mjs +46 -0
  410. package/dist/host/workflow-cache.mjs.map +1 -0
  411. package/dist/http2-client.cjs +89 -0
  412. package/dist/http2-client.cjs.map +1 -0
  413. package/dist/http2-client.d.cts +45 -0
  414. package/dist/http2-client.d.cts.map +1 -0
  415. package/dist/http2-client.d.mts +45 -0
  416. package/dist/http2-client.d.mts.map +1 -0
  417. package/dist/http2-client.mjs +87 -0
  418. package/dist/http2-client.mjs.map +1 -0
  419. package/dist/index.cjs +130 -0
  420. package/dist/index.d.cts +21 -0
  421. package/dist/index.d.mts +21 -0
  422. package/dist/index.mjs +20 -0
  423. package/dist/inflight.cjs +116 -0
  424. package/dist/inflight.cjs.map +1 -0
  425. package/dist/inflight.d.cts +49 -0
  426. package/dist/inflight.d.cts.map +1 -0
  427. package/dist/inflight.d.mts +49 -0
  428. package/dist/inflight.d.mts.map +1 -0
  429. package/dist/inflight.mjs +113 -0
  430. package/dist/inflight.mjs.map +1 -0
  431. package/dist/ir.cjs +429 -0
  432. package/dist/ir.cjs.map +1 -0
  433. package/dist/ir.d.cts +593 -0
  434. package/dist/ir.d.cts.map +1 -0
  435. package/dist/ir.d.mts +593 -0
  436. package/dist/ir.d.mts.map +1 -0
  437. package/dist/ir.mjs +404 -0
  438. package/dist/ir.mjs.map +1 -0
  439. package/dist/jwt.cjs +17 -0
  440. package/dist/jwt.cjs.map +1 -0
  441. package/dist/jwt.d.cts +7 -0
  442. package/dist/jwt.d.cts.map +1 -0
  443. package/dist/jwt.d.mts +7 -0
  444. package/dist/jwt.d.mts.map +1 -0
  445. package/dist/jwt.mjs +15 -0
  446. package/dist/jwt.mjs.map +1 -0
  447. package/dist/node/index.cjs +231 -0
  448. package/dist/node/index.cjs.map +1 -0
  449. package/dist/node/index.d.cts +59 -0
  450. package/dist/node/index.d.cts.map +1 -0
  451. package/dist/node/index.d.mts +59 -0
  452. package/dist/node/index.d.mts.map +1 -0
  453. package/dist/node/index.mjs +225 -0
  454. package/dist/node/index.mjs.map +1 -0
  455. package/dist/node/runs.cjs +222 -0
  456. package/dist/node/runs.cjs.map +1 -0
  457. package/dist/node/runs.d.cts +93 -0
  458. package/dist/node/runs.d.cts.map +1 -0
  459. package/dist/node/runs.d.mts +93 -0
  460. package/dist/node/runs.d.mts.map +1 -0
  461. package/dist/node/runs.mjs +221 -0
  462. package/dist/node/runs.mjs.map +1 -0
  463. package/dist/node/runtime.cjs +351 -0
  464. package/dist/node/runtime.cjs.map +1 -0
  465. package/dist/node/runtime.d.cts +96 -0
  466. package/dist/node/runtime.d.cts.map +1 -0
  467. package/dist/node/runtime.d.mts +96 -0
  468. package/dist/node/runtime.d.mts.map +1 -0
  469. package/dist/node/runtime.mjs +348 -0
  470. package/dist/node/runtime.mjs.map +1 -0
  471. package/dist/plan.cjs +221 -0
  472. package/dist/plan.cjs.map +1 -0
  473. package/dist/plan.d.cts +68 -0
  474. package/dist/plan.d.cts.map +1 -0
  475. package/dist/plan.d.mts +68 -0
  476. package/dist/plan.d.mts.map +1 -0
  477. package/dist/plan.mjs +218 -0
  478. package/dist/plan.mjs.map +1 -0
  479. package/dist/postgres-js.cjs +51 -0
  480. package/dist/postgres-js.cjs.map +1 -0
  481. package/dist/postgres-js.d.cts +32 -0
  482. package/dist/postgres-js.d.cts.map +1 -0
  483. package/dist/postgres-js.d.mts +32 -0
  484. package/dist/postgres-js.d.mts.map +1 -0
  485. package/dist/postgres-js.mjs +46 -0
  486. package/dist/postgres-js.mjs.map +1 -0
  487. package/dist/provenance.cjs +66 -0
  488. package/dist/provenance.cjs.map +1 -0
  489. package/dist/provenance.d.cts +40 -0
  490. package/dist/provenance.d.cts.map +1 -0
  491. package/dist/provenance.d.mts +40 -0
  492. package/dist/provenance.d.mts.map +1 -0
  493. package/dist/provenance.mjs +64 -0
  494. package/dist/provenance.mjs.map +1 -0
  495. package/dist/push.cjs +11 -0
  496. package/dist/push.cjs.map +1 -0
  497. package/dist/push.d.cts +14 -0
  498. package/dist/push.d.cts.map +1 -0
  499. package/dist/push.d.mts +14 -0
  500. package/dist/push.d.mts.map +1 -0
  501. package/dist/push.mjs +10 -0
  502. package/dist/push.mjs.map +1 -0
  503. package/dist/react-email.cjs +56 -0
  504. package/dist/react-email.cjs.map +1 -0
  505. package/dist/react-email.d.cts +5 -0
  506. package/dist/react-email.d.cts.map +1 -0
  507. package/dist/react-email.d.mts +5 -0
  508. package/dist/react-email.d.mts.map +1 -0
  509. package/dist/react-email.mjs +55 -0
  510. package/dist/react-email.mjs.map +1 -0
  511. package/dist/reporting/classify.cjs +46 -0
  512. package/dist/reporting/classify.cjs.map +1 -0
  513. package/dist/reporting/classify.d.cts +65 -0
  514. package/dist/reporting/classify.d.cts.map +1 -0
  515. package/dist/reporting/classify.d.mts +65 -0
  516. package/dist/reporting/classify.d.mts.map +1 -0
  517. package/dist/reporting/classify.mjs +42 -0
  518. package/dist/reporting/classify.mjs.map +1 -0
  519. package/dist/reporting/observer.cjs +137 -0
  520. package/dist/reporting/observer.cjs.map +1 -0
  521. package/dist/reporting/observer.d.cts +31 -0
  522. package/dist/reporting/observer.d.cts.map +1 -0
  523. package/dist/reporting/observer.d.mts +31 -0
  524. package/dist/reporting/observer.d.mts.map +1 -0
  525. package/dist/reporting/observer.mjs +134 -0
  526. package/dist/reporting/observer.mjs.map +1 -0
  527. package/dist/reporting/tracking.cjs +185 -0
  528. package/dist/reporting/tracking.cjs.map +1 -0
  529. package/dist/reporting/tracking.d.cts +63 -0
  530. package/dist/reporting/tracking.d.cts.map +1 -0
  531. package/dist/reporting/tracking.d.mts +63 -0
  532. package/dist/reporting/tracking.d.mts.map +1 -0
  533. package/dist/reporting/tracking.mjs +182 -0
  534. package/dist/reporting/tracking.mjs.map +1 -0
  535. package/dist/runtime.cjs +18 -0
  536. package/dist/runtime.cjs.map +1 -0
  537. package/dist/runtime.d.cts +44 -0
  538. package/dist/runtime.d.cts.map +1 -0
  539. package/dist/runtime.d.mts +44 -0
  540. package/dist/runtime.d.mts.map +1 -0
  541. package/dist/runtime.mjs +17 -0
  542. package/dist/runtime.mjs.map +1 -0
  543. package/dist/store/condition-sql.cjs +145 -0
  544. package/dist/store/condition-sql.cjs.map +1 -0
  545. package/dist/store/condition-sql.d.cts +38 -0
  546. package/dist/store/condition-sql.d.cts.map +1 -0
  547. package/dist/store/condition-sql.d.mts +38 -0
  548. package/dist/store/condition-sql.d.mts.map +1 -0
  549. package/dist/store/condition-sql.mjs +144 -0
  550. package/dist/store/condition-sql.mjs.map +1 -0
  551. package/dist/store/erasure.cjs +21 -0
  552. package/dist/store/erasure.cjs.map +1 -0
  553. package/dist/store/erasure.d.cts +16 -0
  554. package/dist/store/erasure.d.cts.map +1 -0
  555. package/dist/store/erasure.d.mts +16 -0
  556. package/dist/store/erasure.d.mts.map +1 -0
  557. package/dist/store/erasure.mjs +20 -0
  558. package/dist/store/erasure.mjs.map +1 -0
  559. package/dist/store/facts.cjs +79 -0
  560. package/dist/store/facts.cjs.map +1 -0
  561. package/dist/store/facts.d.cts +41 -0
  562. package/dist/store/facts.d.cts.map +1 -0
  563. package/dist/store/facts.d.mts +41 -0
  564. package/dist/store/facts.d.mts.map +1 -0
  565. package/dist/store/facts.mjs +77 -0
  566. package/dist/store/facts.mjs.map +1 -0
  567. package/dist/store/identity.cjs +34 -0
  568. package/dist/store/identity.cjs.map +1 -0
  569. package/dist/store/identity.d.cts +13 -0
  570. package/dist/store/identity.d.cts.map +1 -0
  571. package/dist/store/identity.d.mts +13 -0
  572. package/dist/store/identity.d.mts.map +1 -0
  573. package/dist/store/identity.mjs +30 -0
  574. package/dist/store/identity.mjs.map +1 -0
  575. package/dist/store/index.cjs +35 -0
  576. package/dist/store/index.cjs.map +1 -0
  577. package/dist/store/index.d.cts +766 -0
  578. package/dist/store/index.d.cts.map +1 -0
  579. package/dist/store/index.d.mts +766 -0
  580. package/dist/store/index.d.mts.map +1 -0
  581. package/dist/store/index.mjs +22 -0
  582. package/dist/store/index.mjs.map +1 -0
  583. package/dist/store/postgres-reporting.cjs +327 -0
  584. package/dist/store/postgres-reporting.cjs.map +1 -0
  585. package/dist/store/postgres-reporting.d.cts +95 -0
  586. package/dist/store/postgres-reporting.d.cts.map +1 -0
  587. package/dist/store/postgres-reporting.d.mts +95 -0
  588. package/dist/store/postgres-reporting.d.mts.map +1 -0
  589. package/dist/store/postgres-reporting.mjs +326 -0
  590. package/dist/store/postgres-reporting.mjs.map +1 -0
  591. package/dist/store/postgres.cjs +1173 -0
  592. package/dist/store/postgres.cjs.map +1 -0
  593. package/dist/store/postgres.d.cts +199 -0
  594. package/dist/store/postgres.d.cts.map +1 -0
  595. package/dist/store/postgres.d.mts +199 -0
  596. package/dist/store/postgres.d.mts.map +1 -0
  597. package/dist/store/postgres.mjs +1170 -0
  598. package/dist/store/postgres.mjs.map +1 -0
  599. package/dist/store/sql.cjs +24 -0
  600. package/dist/store/sql.cjs.map +1 -0
  601. package/dist/store/sql.d.cts +26 -0
  602. package/dist/store/sql.d.cts.map +1 -0
  603. package/dist/store/sql.d.mts +26 -0
  604. package/dist/store/sql.d.mts.map +1 -0
  605. package/dist/store/sql.mjs +23 -0
  606. package/dist/store/sql.mjs.map +1 -0
  607. package/dist/store/tables.cjs +660 -0
  608. package/dist/store/tables.cjs.map +1 -0
  609. package/dist/store/tables.d.cts +103 -0
  610. package/dist/store/tables.d.cts.map +1 -0
  611. package/dist/store/tables.d.mts +103 -0
  612. package/dist/store/tables.d.mts.map +1 -0
  613. package/dist/store/tables.mjs +653 -0
  614. package/dist/store/tables.mjs.map +1 -0
  615. package/dist/store/user-lock.cjs +42 -0
  616. package/dist/store/user-lock.cjs.map +1 -0
  617. package/dist/store/user-lock.d.cts +30 -0
  618. package/dist/store/user-lock.d.cts.map +1 -0
  619. package/dist/store/user-lock.d.mts +30 -0
  620. package/dist/store/user-lock.d.mts.map +1 -0
  621. package/dist/store/user-lock.mjs +39 -0
  622. package/dist/store/user-lock.mjs.map +1 -0
  623. package/dist/template-rules.cjs +94 -0
  624. package/dist/template-rules.cjs.map +1 -0
  625. package/dist/template-rules.d.cts +80 -0
  626. package/dist/template-rules.d.cts.map +1 -0
  627. package/dist/template-rules.d.mts +80 -0
  628. package/dist/template-rules.d.mts.map +1 -0
  629. package/dist/template-rules.mjs +86 -0
  630. package/dist/template-rules.mjs.map +1 -0
  631. package/dist/templates.cjs +375 -0
  632. package/dist/templates.cjs.map +1 -0
  633. package/dist/templates.d.cts +358 -0
  634. package/dist/templates.d.cts.map +1 -0
  635. package/dist/templates.d.mts +358 -0
  636. package/dist/templates.d.mts.map +1 -0
  637. package/dist/templates.mjs +353 -0
  638. package/dist/templates.mjs.map +1 -0
  639. package/dist/transports/cloudflare-email.cjs +69 -0
  640. package/dist/transports/cloudflare-email.cjs.map +1 -0
  641. package/dist/transports/cloudflare-email.d.cts +63 -0
  642. package/dist/transports/cloudflare-email.d.cts.map +1 -0
  643. package/dist/transports/cloudflare-email.d.mts +63 -0
  644. package/dist/transports/cloudflare-email.d.mts.map +1 -0
  645. package/dist/transports/cloudflare-email.mjs +67 -0
  646. package/dist/transports/cloudflare-email.mjs.map +1 -0
  647. package/dist/transports/ses.cjs +142 -0
  648. package/dist/transports/ses.cjs.map +1 -0
  649. package/dist/transports/ses.d.cts +49 -0
  650. package/dist/transports/ses.d.cts.map +1 -0
  651. package/dist/transports/ses.d.mts +49 -0
  652. package/dist/transports/ses.d.mts.map +1 -0
  653. package/dist/transports/ses.mjs +139 -0
  654. package/dist/transports/ses.mjs.map +1 -0
  655. package/dist/transports/sigv4.cjs +86 -0
  656. package/dist/transports/sigv4.cjs.map +1 -0
  657. package/dist/transports/sigv4.d.cts +25 -0
  658. package/dist/transports/sigv4.d.cts.map +1 -0
  659. package/dist/transports/sigv4.d.mts +25 -0
  660. package/dist/transports/sigv4.d.mts.map +1 -0
  661. package/dist/transports/sigv4.mjs +85 -0
  662. package/dist/transports/sigv4.mjs.map +1 -0
  663. package/dist/webhooks.cjs +97 -0
  664. package/dist/webhooks.cjs.map +1 -0
  665. package/dist/webhooks.d.cts +23 -0
  666. package/dist/webhooks.d.cts.map +1 -0
  667. package/dist/webhooks.d.mts +23 -0
  668. package/dist/webhooks.d.mts.map +1 -0
  669. package/dist/webhooks.mjs +95 -0
  670. package/dist/webhooks.mjs.map +1 -0
  671. package/dist/webpush.cjs +361 -0
  672. package/dist/webpush.cjs.map +1 -0
  673. package/dist/webpush.d.cts +135 -0
  674. package/dist/webpush.d.cts.map +1 -0
  675. package/dist/webpush.d.mts +135 -0
  676. package/dist/webpush.d.mts.map +1 -0
  677. package/dist/webpush.mjs +350 -0
  678. package/dist/webpush.mjs.map +1 -0
  679. package/package.json +279 -3
  680. package/src/cloudflare/workers.d.ts +44 -0
@@ -0,0 +1,135 @@
1
+ import { MessageSender, OutboundMessage, SendResult } from "./engine/ports.mjs";
2
+ import "./engine/index.mjs";
3
+ import { PushRenderer } from "./push.mjs";
4
+ /**
5
+ * `sendwend/webpush` — browser push through the standard Web Push protocol: VAPID
6
+ * (RFC 8292) identifies the sender, the payload is encrypted for the subscription (RFC 8291,
7
+ * `aes128gcm`, RFC 8188). One sender reaches Chrome, Edge, Firefox and Safari 16+ — each
8
+ * browser's push service accepts the same request, over HTTP/1.1 — with nothing but WebCrypto.
9
+ *
10
+ * The recipient is a browser's `PushSubscription` as JSON (`JSON.stringify(subscription)`),
11
+ * registered like an app token (`registerDevice({ userId, token, platform: 'web' })`). The
12
+ * service worker receives `{ title, body, image?, url?, template, …tracking data }` as the push
13
+ * event's JSON.
14
+ */
15
+ /** A VAPID key pair: the uncompressed P-256 public key and the private scalar, base64url. */
16
+ export interface VapidKeys {
17
+ publicKey: string;
18
+ privateKey: string;
19
+ }
20
+ export interface VapidSignerOptions extends VapidKeys {
21
+ /** Who to contact about this sender: `mailto:` or an `https:` URL (RFC 8292). */
22
+ subject: string;
23
+ }
24
+ export interface WebPushOptions {
25
+ /** The VAPID signer the requests are authorized with — shared by every sender on the same key pair. */
26
+ credentials: VapidSigner;
27
+ render: PushRenderer;
28
+ /** Seconds the push service keeps an undelivered message; a day by default. */
29
+ ttl?: number;
30
+ /** Push service hosts accepted besides the browsers' own (`PUSH_SERVICE_HOSTS`): the config's `webPush.pushServices`. */
31
+ pushServices?: readonly string[] | undefined;
32
+ /** Fetch implementation (defaults to the global one). */
33
+ fetch?: typeof fetch;
34
+ }
35
+ /**
36
+ * How a push service's answer is classified (RFC 8030 §7 and §8.1, with the browsers' services
37
+ * answering as documented there):
38
+ *
39
+ * - dead subscription: 404 and 410 — the browser unsubscribed or the subscription expired
40
+ * (RFC 8030 §7.3: 410 Gone for an expired subscription) — and a subscription the sender
41
+ * cannot parse (`InvalidSubscription`). The copy settles undelivered and the host forgets it.
42
+ * - an https endpoint that is no known push service's (`UnlistedPushService`, see
43
+ * `isPushServiceEndpoint`): settled undelivered without a request, and the device is kept.
44
+ * - transient: 429 Too Many Requests (§8.4) and 5xx.
45
+ * - undelivered, device kept: any other 4xx — 400 (a bad header or body), 401 / 403 (the VAPID
46
+ * key pair or subject, §8.2 of RFC 8292: also what a subscription made under another key
47
+ * answers, after a key was rotated), 413 (the payload, RFC 8030 §7.2). A push service names
48
+ * no finer reason, so one subscription's refusal cannot be told from the sender's; the copy
49
+ * settles as `Refused<status>` and is logged as an error, and the user's other devices and
50
+ * the rest of the journey go on.
51
+ */
52
+ export declare const DEAD_TOKEN_REASONS: ReadonlySet<string>;
53
+ /**
54
+ * The push services browsers hand out subscription endpoints on. The hosts are those of
55
+ * Pushpad's `known-push-services` list, which it derives from the endpoints of some 200M real
56
+ * subscriptions, checked against Chromium's `push_messaging_constants.cc` and Apple's and
57
+ * Microsoft's own guidance. `*.` covers every subdomain.
58
+ *
59
+ * - `fcm.googleapis.com`: Chrome and the Chromium browsers that use Google's service (Opera,
60
+ * Brave and others; the list above holds no host of their own). `android.googleapis.com` is its GCM predecessor and
61
+ * `jmt17.google.com` the staging service of Chromium's source; both still turn up in stored
62
+ * subscriptions, and both are Google's own.
63
+ * - `updates.push.services.mozilla.com`: Firefox (autopush). The two `mozaws.net` hosts are its
64
+ * stage and dev deployments.
65
+ * - `*.notify.windows.com`: Edge, on a regional WNS host (`sg2p.notify.windows.com`). Microsoft
66
+ * tells senders to push to no channel outside this domain.
67
+ * - `*.push.apple.com`: Safari (`web.push.apple.com`). Apple's guidance is to allow every
68
+ * subdomain.
69
+ *
70
+ * A service not listed here (KaiOS's, a self-hosted one) is named in `webPush.pushServices`.
71
+ */
72
+ export declare const PUSH_SERVICE_HOSTS: readonly string[];
73
+ /**
74
+ * Whether `endpoint` is a URL a push is sent to: https, on the default port, without
75
+ * credentials, and on a known push service's host (`PUSH_SERVICE_HOSTS`, plus `extra` — the
76
+ * config's `webPush.pushServices`). The endpoint is whatever the registering client says it is,
77
+ * and the sender POSTs to it from inside the host's network: without the list, a subscription
78
+ * naming `https://localhost`, an address literal or an internal service's name would have the
79
+ * host send requests there. A list of names, not a refusal of private addresses: a name
80
+ * resolves where its owner says, and the sender never sees the address.
81
+ */
82
+ export declare function isPushServiceEndpoint(endpoint: unknown, extra?: readonly string[]): boolean;
83
+ /**
84
+ * The endpoint of a browser subscription as it is registered (`JSON.stringify(subscription)`),
85
+ * or undefined when the token is not one.
86
+ */
87
+ export declare function subscriptionEndpoint(token: string): string | undefined;
88
+ /** A fresh VAPID key pair (once per project; the private key is a secret). */
89
+ export declare function generateVapidKeys(): Promise<VapidKeys>;
90
+ /**
91
+ * The largest plaintext one record carries. A push message body is at most 4096 octets (RFC 8030
92
+ * §7.2); the aes128gcm header takes 86 of them (16 salt + 4 rs + 1 idlen + 65 key), the record its
93
+ * 16-octet tag and the 1-octet delimiter — 3993 octets of plaintext (RFC 8291 §4). Anything past
94
+ * that is either an invalid record or a 413 from the push service.
95
+ */
96
+ export declare const MAX_PLAINTEXT_BYTES = 3993;
97
+ /** Bytes WebCrypto accepts (backed by a plain ArrayBuffer). */
98
+ type Bytes = Uint8Array<ArrayBuffer>;
99
+ export declare function fromBase64url(text: string): Bytes;
100
+ /**
101
+ * The `aes128gcm` body for one subscription (RFC 8291 §3.4): salt, record size, the sender's
102
+ * ephemeral public key, then the payload sealed under a key both sides derive from ECDH and the
103
+ * subscription's auth secret.
104
+ */
105
+ export declare function encryptPayload(payload: Bytes, p256dh: Bytes, authSecret: Bytes, salt?: Bytes): Promise<Bytes>;
106
+ /**
107
+ * The VAPID `Authorization` header (RFC 8292 §3) for one key pair. The private key is imported
108
+ * once; the JWT is signed per push service (its `aud` is the service's origin) and reused for
109
+ * `VAPID_TTL_MS`. Concurrent callers for one origin share the one signing in flight, and a signing
110
+ * that failed is not kept. One instance serves every sender built on the pair — a host keeps it
111
+ * across runs, and builds the senders per run.
112
+ */
113
+ export declare class VapidSigner {
114
+ private readonly options;
115
+ private key;
116
+ private readonly signed;
117
+ private readonly signing;
118
+ constructor(options: VapidSignerOptions);
119
+ /** The header value for the push service at `audience` — its origin, or any URL on it. */
120
+ authorization(audience: string, now?: number): Promise<string>;
121
+ private privateKey;
122
+ private sign;
123
+ }
124
+ export declare class WebPushSender implements MessageSender {
125
+ private readonly options;
126
+ constructor(options: WebPushOptions);
127
+ send(message: OutboundMessage): Promise<void | SendResult>;
128
+ }
129
+ /**
130
+ * The `Topic` header for one copy: RFC 8030 §5.4 allows at most 32 characters of the URL-safe
131
+ * base64 alphabet, so the idempotency key goes through SHA-256 and is cut to size.
132
+ */
133
+ export declare function webPushTopic(idempotencyKey: string): Promise<string>;
134
+ export {};
135
+ //# sourceMappingURL=webpush.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpush.d.mts","names":[],"sources":["../src/webpush.ts"],"mappings":";;;;;;;;;;;;;;;iBAmBiB;EACf;EACA;;iBAGe,2BAA2B;;EAE1C;;iBAGe;;EAEf,aAAa;EACb,QAAQ;;EAER;;EAEA;;EAEA,eAAe;;;;;;;;;;;;;;;;;;;qBAoBJ,oBAAoB;;;;;;;;;;;;;;;;;;;;qBA8BpB;;;;;;;;;;wBA0BG,sBAAsB,mBAAmB;;;;;wBAoBzC,qBAAqB;;wBAUf,qBAAqB,QAAQ;;;;;;;qBAkBtC;;KAER,QAAQ,WAAW;wBAIR,cAAc,eAAe;;;;;;wBAmBvB,eACpB,SAAS,OACT,QAAQ,OACR,YAAY,OACZ,OAAM,QACL,QAAQ;;;;;;;;qBAwDE;mBAKkB;UAJrB;mBACS;mBACA;EAEjB,YAA6B,SAAS;;EAGhC,cAAc,kBAAkB,eAAmB;UAmBjD;UA0BM;;qBAiDH,yBAAyB;mBACP;EAA7B,YAA6B,SAAS;EAEhC,KAAK,SAAS,kBAAkB,eAAe;;;;;;wBAsFjC,aAAa,yBAAyB"}
@@ -0,0 +1,350 @@
1
+ import { Buffer } from "node:buffer";
2
+ import { PermanentError, isRetryableStatus } from "./engine/retry.mjs";
3
+ import { base64url } from "./jwt.mjs";
4
+ // src/webpush.ts
5
+ /**
6
+ * How a push service's answer is classified (RFC 8030 §7 and §8.1, with the browsers' services
7
+ * answering as documented there):
8
+ *
9
+ * - dead subscription: 404 and 410 — the browser unsubscribed or the subscription expired
10
+ * (RFC 8030 §7.3: 410 Gone for an expired subscription) — and a subscription the sender
11
+ * cannot parse (`InvalidSubscription`). The copy settles undelivered and the host forgets it.
12
+ * - an https endpoint that is no known push service's (`UnlistedPushService`, see
13
+ * `isPushServiceEndpoint`): settled undelivered without a request, and the device is kept.
14
+ * - transient: 429 Too Many Requests (§8.4) and 5xx.
15
+ * - undelivered, device kept: any other 4xx — 400 (a bad header or body), 401 / 403 (the VAPID
16
+ * key pair or subject, §8.2 of RFC 8292: also what a subscription made under another key
17
+ * answers, after a key was rotated), 413 (the payload, RFC 8030 §7.2). A push service names
18
+ * no finer reason, so one subscription's refusal cannot be told from the sender's; the copy
19
+ * settles as `Refused<status>` and is logged as an error, and the user's other devices and
20
+ * the rest of the journey go on.
21
+ */
22
+ const DEAD_TOKEN_REASONS = /* @__PURE__ */ new Set([
23
+ "Gone",
24
+ "NotFound",
25
+ "InvalidSubscription"
26
+ ]);
27
+ /**
28
+ * The push services browsers hand out subscription endpoints on. The hosts are those of
29
+ * Pushpad's `known-push-services` list, which it derives from the endpoints of some 200M real
30
+ * subscriptions, checked against Chromium's `push_messaging_constants.cc` and Apple's and
31
+ * Microsoft's own guidance. `*.` covers every subdomain.
32
+ *
33
+ * - `fcm.googleapis.com`: Chrome and the Chromium browsers that use Google's service (Opera,
34
+ * Brave and others; the list above holds no host of their own). `android.googleapis.com` is its GCM predecessor and
35
+ * `jmt17.google.com` the staging service of Chromium's source; both still turn up in stored
36
+ * subscriptions, and both are Google's own.
37
+ * - `updates.push.services.mozilla.com`: Firefox (autopush). The two `mozaws.net` hosts are its
38
+ * stage and dev deployments.
39
+ * - `*.notify.windows.com`: Edge, on a regional WNS host (`sg2p.notify.windows.com`). Microsoft
40
+ * tells senders to push to no channel outside this domain.
41
+ * - `*.push.apple.com`: Safari (`web.push.apple.com`). Apple's guidance is to allow every
42
+ * subdomain.
43
+ *
44
+ * A service not listed here (KaiOS's, a self-hosted one) is named in `webPush.pushServices`.
45
+ */
46
+ const PUSH_SERVICE_HOSTS = [
47
+ "fcm.googleapis.com",
48
+ "android.googleapis.com",
49
+ "jmt17.google.com",
50
+ "*.push.services.mozilla.com",
51
+ "updates-autopush.stage.mozaws.net",
52
+ "updates-autopush.dev.mozaws.net",
53
+ "*.notify.windows.com",
54
+ "*.push.apple.com"
55
+ ];
56
+ const matchesHost = (hostname, pattern) => {
57
+ const wanted = pattern.trim().toLowerCase();
58
+ if (wanted === "") return false;
59
+ return wanted.startsWith("*.") ? hostname.endsWith(wanted.slice(1)) : hostname === wanted;
60
+ };
61
+ /**
62
+ * Whether `endpoint` is a URL a push is sent to: https, on the default port, without
63
+ * credentials, and on a known push service's host (`PUSH_SERVICE_HOSTS`, plus `extra` — the
64
+ * config's `webPush.pushServices`). The endpoint is whatever the registering client says it is,
65
+ * and the sender POSTs to it from inside the host's network: without the list, a subscription
66
+ * naming `https://localhost`, an address literal or an internal service's name would have the
67
+ * host send requests there. A list of names, not a refusal of private addresses: a name
68
+ * resolves where its owner says, and the sender never sees the address.
69
+ */
70
+ function isPushServiceEndpoint(endpoint, extra = []) {
71
+ if (typeof endpoint !== "string") return false;
72
+ let url;
73
+ try {
74
+ url = new URL(endpoint);
75
+ } catch {
76
+ return false;
77
+ }
78
+ if (url.protocol !== "https:" || url.port !== "" || url.username !== "" || url.password !== "") return false;
79
+ const hostname = url.hostname.replace(/\.$/, "");
80
+ return [...PUSH_SERVICE_HOSTS, ...extra].some((pattern) => matchesHost(hostname, pattern));
81
+ }
82
+ /**
83
+ * The endpoint of a browser subscription as it is registered (`JSON.stringify(subscription)`),
84
+ * or undefined when the token is not one.
85
+ */
86
+ function subscriptionEndpoint(token) {
87
+ try {
88
+ const value = JSON.parse(token);
89
+ return typeof value?.endpoint === "string" ? value.endpoint : void 0;
90
+ } catch {
91
+ return;
92
+ }
93
+ }
94
+ /** A fresh VAPID key pair (once per project; the private key is a secret). */
95
+ async function generateVapidKeys() {
96
+ const pair = await crypto.subtle.generateKey({
97
+ name: "ECDSA",
98
+ namedCurve: "P-256"
99
+ }, true, ["sign", "verify"]);
100
+ const raw = new Uint8Array(await crypto.subtle.exportKey("raw", pair.publicKey));
101
+ const jwk = await crypto.subtle.exportKey("jwk", pair.privateKey);
102
+ return {
103
+ publicKey: base64url(raw),
104
+ privateKey: jwk.d ?? ""
105
+ };
106
+ }
107
+ /** The record size the header announces: RFC 8291 §4 fixes it at 4096 and one record per push. */
108
+ const RECORD_SIZE = 4096;
109
+ /**
110
+ * The largest plaintext one record carries. A push message body is at most 4096 octets (RFC 8030
111
+ * §7.2); the aes128gcm header takes 86 of them (16 salt + 4 rs + 1 idlen + 65 key), the record its
112
+ * 16-octet tag and the 1-octet delimiter — 3993 octets of plaintext (RFC 8291 §4). Anything past
113
+ * that is either an invalid record or a 413 from the push service.
114
+ */
115
+ const MAX_PLAINTEXT_BYTES = 3993;
116
+ const encoder = new TextEncoder();
117
+ const utf8 = (text) => encoder.encode(text);
118
+ function fromBase64url(text) {
119
+ return new Uint8Array(Buffer.from(text, "base64url"));
120
+ }
121
+ const concat = (...parts) => new Uint8Array(Buffer.concat(parts));
122
+ /** HKDF-SHA256 (RFC 5869), as WebCrypto provides it. */
123
+ async function hkdf(salt, ikm, info, length) {
124
+ const key = await crypto.subtle.importKey("raw", ikm, "HKDF", false, ["deriveBits"]);
125
+ return new Uint8Array(await crypto.subtle.deriveBits({
126
+ name: "HKDF",
127
+ hash: "SHA-256",
128
+ salt,
129
+ info
130
+ }, key, length * 8));
131
+ }
132
+ /**
133
+ * The `aes128gcm` body for one subscription (RFC 8291 §3.4): salt, record size, the sender's
134
+ * ephemeral public key, then the payload sealed under a key both sides derive from ECDH and the
135
+ * subscription's auth secret.
136
+ */
137
+ async function encryptPayload(payload, p256dh, authSecret, salt = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16))) {
138
+ const ephemeral = await crypto.subtle.generateKey({
139
+ name: "ECDH",
140
+ namedCurve: "P-256"
141
+ }, true, ["deriveBits"]);
142
+ const senderPublic = new Uint8Array(await crypto.subtle.exportKey("raw", ephemeral.publicKey));
143
+ const receiver = await crypto.subtle.importKey("raw", p256dh, {
144
+ name: "ECDH",
145
+ namedCurve: "P-256"
146
+ }, false, []);
147
+ const ikm = await hkdf(authSecret, new Uint8Array(await crypto.subtle.deriveBits({
148
+ name: "ECDH",
149
+ public: receiver
150
+ }, ephemeral.privateKey, 256)), concat(utf8("WebPush: info\0"), p256dh, senderPublic), 32);
151
+ const cek = await hkdf(salt, ikm, utf8("Content-Encoding: aes128gcm\0"), 16);
152
+ const nonce = await hkdf(salt, ikm, utf8("Content-Encoding: nonce\0"), 12);
153
+ const key = await crypto.subtle.importKey("raw", cek, "AES-GCM", false, ["encrypt"]);
154
+ const sealed = new Uint8Array(await crypto.subtle.encrypt({
155
+ name: "AES-GCM",
156
+ iv: nonce
157
+ }, key, concat(payload, new Uint8Array([2]))));
158
+ const header = /* @__PURE__ */ new Uint8Array(21);
159
+ header.set(salt, 0);
160
+ new DataView(header.buffer).setUint32(16, RECORD_SIZE);
161
+ header[20] = senderPublic.length;
162
+ return concat(header, senderPublic, sealed);
163
+ }
164
+ /**
165
+ * How long a VAPID token is good for. RFC 8292 §2 allows at most 24 hours, counted on the push
166
+ * service's clock: at exactly 24 a host whose clock runs a little fast signs an `exp` the
167
+ * service sees as more than a day away and refuses. 18 hours leaves six for a fast clock, and
168
+ * six past the 12 the token is reused for a slow one.
169
+ */
170
+ const VAPID_EXP_S = 64800;
171
+ /** How long a signed token is reused: half its life, so it is never sent near expiry. */
172
+ const VAPID_TTL_MS = 432e5;
173
+ /**
174
+ * The VAPID `Authorization` header (RFC 8292 §3) for one key pair. The private key is imported
175
+ * once; the JWT is signed per push service (its `aud` is the service's origin) and reused for
176
+ * `VAPID_TTL_MS`. Concurrent callers for one origin share the one signing in flight, and a signing
177
+ * that failed is not kept. One instance serves every sender built on the pair — a host keeps it
178
+ * across runs, and builds the senders per run.
179
+ */
180
+ var VapidSigner = class {
181
+ options;
182
+ key;
183
+ signed = /* @__PURE__ */ new Map();
184
+ signing = /* @__PURE__ */ new Map();
185
+ constructor(options) {
186
+ this.options = options;
187
+ }
188
+ /** The header value for the push service at `audience` — its origin, or any URL on it. */
189
+ async authorization(audience, now = Date.now()) {
190
+ const origin = new URL(audience).origin;
191
+ const current = this.signed.get(origin);
192
+ if (current !== void 0 && now - current.issuedAt < VAPID_TTL_MS) return current.value;
193
+ let pending = this.signing.get(origin);
194
+ if (pending === void 0) {
195
+ pending = this.sign(origin, now).then((value) => {
196
+ this.signed.set(origin, {
197
+ value,
198
+ issuedAt: now
199
+ });
200
+ return value;
201
+ }).finally(() => {
202
+ this.signing.delete(origin);
203
+ });
204
+ this.signing.set(origin, pending);
205
+ }
206
+ return pending;
207
+ }
208
+ privateKey() {
209
+ if (this.key === void 0) {
210
+ const publicKey = fromBase64url(this.options.publicKey);
211
+ this.key = crypto.subtle.importKey("jwk", {
212
+ kty: "EC",
213
+ crv: "P-256",
214
+ d: this.options.privateKey,
215
+ x: base64url(publicKey.slice(1, 33)),
216
+ y: base64url(publicKey.slice(33, 65)),
217
+ ext: true
218
+ }, {
219
+ name: "ECDSA",
220
+ namedCurve: "P-256"
221
+ }, false, ["sign"]).catch((error) => {
222
+ this.key = void 0;
223
+ throw error;
224
+ });
225
+ }
226
+ return this.key;
227
+ }
228
+ async sign(origin, now) {
229
+ const key = await this.privateKey();
230
+ const header = base64url(JSON.stringify({
231
+ typ: "JWT",
232
+ alg: "ES256"
233
+ }));
234
+ const claims = base64url(JSON.stringify({
235
+ aud: origin,
236
+ exp: Math.floor(now / 1e3) + VAPID_EXP_S,
237
+ sub: this.options.subject
238
+ }));
239
+ const signature = new Uint8Array(await crypto.subtle.sign({
240
+ name: "ECDSA",
241
+ hash: "SHA-256"
242
+ }, key, utf8(`${header}.${claims}`)));
243
+ return `vapid t=${header}.${claims}.${base64url(signature)}, k=${this.options.publicKey}`;
244
+ }
245
+ };
246
+ /**
247
+ * A browser subscription as a sender can use it: an endpoint on a push service
248
+ * (`isPushServiceEndpoint`), a 65-byte uncompressed P-256 key and a 16-byte auth secret. Anything
249
+ * else — not JSON, missing keys, a key of the wrong size, an endpoint that is not https or not a
250
+ * push service's — is undefined.
251
+ */
252
+ function parseSubscription(token, pushServices) {
253
+ try {
254
+ const value = JSON.parse(token);
255
+ if (typeof value.endpoint !== "string") return void 0;
256
+ if (!isPushServiceEndpoint(value.endpoint, pushServices)) return void 0;
257
+ const p256dh = fromBase64url(value.keys?.p256dh ?? "");
258
+ const auth = fromBase64url(value.keys?.auth ?? "");
259
+ if (p256dh.length !== 65 || p256dh[0] !== 4 || auth.length !== 16) return void 0;
260
+ return {
261
+ endpoint: value.endpoint,
262
+ p256dh,
263
+ auth
264
+ };
265
+ } catch {
266
+ return;
267
+ }
268
+ }
269
+ /** The endpoint's host for a log line — never the URL, whose path is the subscription's capability. */
270
+ function hostOf(endpoint) {
271
+ try {
272
+ return new URL(endpoint).host;
273
+ } catch {
274
+ return "not a URL";
275
+ }
276
+ }
277
+ var WebPushSender = class {
278
+ options;
279
+ constructor(options) {
280
+ this.options = options;
281
+ }
282
+ async send(message) {
283
+ if (message.channel !== "push") throw new Error(`WebPushSender: unsupported channel '${message.channel}'`);
284
+ if (message.recipient === void 0) throw new Error(`WebPushSender: no subscription for user '${message.userId}'`);
285
+ const subscription = parseSubscription(message.recipient, this.options.pushServices);
286
+ if (subscription === void 0) {
287
+ const endpoint = subscriptionEndpoint(message.recipient);
288
+ if (endpoint?.startsWith("https://") === true && !isPushServiceEndpoint(endpoint, this.options.pushServices)) {
289
+ console.warn(`[webpush] subscription for user ${message.userId} not sent to: its endpoint is not a known push service's (${hostOf(endpoint)}); see webPush.pushServices`);
290
+ return {
291
+ delivered: false,
292
+ reason: "UnlistedPushService"
293
+ };
294
+ }
295
+ return {
296
+ delivered: false,
297
+ reason: "InvalidSubscription"
298
+ };
299
+ }
300
+ const content = await this.options.render(message.template, message.props);
301
+ const payload = utf8(JSON.stringify({
302
+ ...content,
303
+ template: message.template,
304
+ idempotencyKey: message.idempotencyKey,
305
+ ...message.tracking?.data
306
+ }));
307
+ if (payload.length > 3993) throw new PermanentError(`[webpush] payload for template '${message.template}' is ${payload.length} bytes; a push message carries at most ${MAX_PLAINTEXT_BYTES}`, { reason: "PayloadTooLarge" });
308
+ const body = await encryptPayload(payload, subscription.p256dh, subscription.auth);
309
+ const response = await (this.options.fetch ?? fetch)(subscription.endpoint, {
310
+ method: "POST",
311
+ headers: {
312
+ authorization: await this.options.credentials.authorization(subscription.endpoint),
313
+ "content-encoding": "aes128gcm",
314
+ "content-type": "application/octet-stream",
315
+ ttl: String(this.options.ttl ?? 86400),
316
+ urgency: "normal",
317
+ topic: await webPushTopic(message.idempotencyKey)
318
+ },
319
+ body
320
+ });
321
+ if (response.ok) return;
322
+ const { status } = response;
323
+ if (status === 404 || status === 410) {
324
+ console.warn(`[webpush] subscription gone for user ${message.userId}: ${status}`);
325
+ return {
326
+ delivered: false,
327
+ reason: status === 410 ? "Gone" : "NotFound"
328
+ };
329
+ }
330
+ const text = await response.text();
331
+ if (isRetryableStatus(status)) throw new Error(`[webpush] ${status}: ${text}`);
332
+ if (status < 400) throw new PermanentError(`[webpush] unexpected answer from the push service: ${status}`, { reason: `Unexpected${status}` });
333
+ console.error(`[webpush] push service refused the request for user ${message.userId}: ${status} ${text}`);
334
+ return {
335
+ delivered: false,
336
+ reason: `Refused${status}`
337
+ };
338
+ }
339
+ };
340
+ /**
341
+ * The `Topic` header for one copy: RFC 8030 §5.4 allows at most 32 characters of the URL-safe
342
+ * base64 alphabet, so the idempotency key goes through SHA-256 and is cut to size.
343
+ */
344
+ async function webPushTopic(idempotencyKey) {
345
+ const digest = await crypto.subtle.digest("SHA-256", utf8(idempotencyKey));
346
+ return base64url(new Uint8Array(digest)).slice(0, 32);
347
+ }
348
+ export { DEAD_TOKEN_REASONS, MAX_PLAINTEXT_BYTES, PUSH_SERVICE_HOSTS, VapidSigner, WebPushSender, encryptPayload, fromBase64url, generateVapidKeys, isPushServiceEndpoint, subscriptionEndpoint, webPushTopic };
349
+
350
+ //# sourceMappingURL=webpush.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpush.mjs","names":[],"sources":["../src/webpush.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport type { MessageSender, OutboundMessage, SendResult } from './engine';\nimport { PermanentError, isRetryableStatus } from './engine/retry';\nimport { base64url } from './jwt';\nimport type { PushRenderer } from './push';\n\n/**\n * `sendwend/webpush` — browser push through the standard Web Push protocol: VAPID\n * (RFC 8292) identifies the sender, the payload is encrypted for the subscription (RFC 8291,\n * `aes128gcm`, RFC 8188). One sender reaches Chrome, Edge, Firefox and Safari 16+ — each\n * browser's push service accepts the same request, over HTTP/1.1 — with nothing but WebCrypto.\n *\n * The recipient is a browser's `PushSubscription` as JSON (`JSON.stringify(subscription)`),\n * registered like an app token (`registerDevice({ userId, token, platform: 'web' })`). The\n * service worker receives `{ title, body, image?, url?, template, …tracking data }` as the push\n * event's JSON.\n */\n\n/** A VAPID key pair: the uncompressed P-256 public key and the private scalar, base64url. */\nexport interface VapidKeys {\n publicKey: string;\n privateKey: string;\n}\n\nexport interface VapidSignerOptions extends VapidKeys {\n /** Who to contact about this sender: `mailto:` or an `https:` URL (RFC 8292). */\n subject: string;\n}\n\nexport interface WebPushOptions {\n /** The VAPID signer the requests are authorized with — shared by every sender on the same key pair. */\n credentials: VapidSigner;\n render: PushRenderer;\n /** Seconds the push service keeps an undelivered message; a day by default. */\n ttl?: number;\n /** Push service hosts accepted besides the browsers' own (`PUSH_SERVICE_HOSTS`): the config's `webPush.pushServices`. */\n pushServices?: readonly string[] | undefined;\n /** Fetch implementation (defaults to the global one). */\n fetch?: typeof fetch;\n}\n\n/**\n * How a push service's answer is classified (RFC 8030 §7 and §8.1, with the browsers' services\n * answering as documented there):\n *\n * - dead subscription: 404 and 410 — the browser unsubscribed or the subscription expired\n * (RFC 8030 §7.3: 410 Gone for an expired subscription) — and a subscription the sender\n * cannot parse (`InvalidSubscription`). The copy settles undelivered and the host forgets it.\n * - an https endpoint that is no known push service's (`UnlistedPushService`, see\n * `isPushServiceEndpoint`): settled undelivered without a request, and the device is kept.\n * - transient: 429 Too Many Requests (§8.4) and 5xx.\n * - undelivered, device kept: any other 4xx — 400 (a bad header or body), 401 / 403 (the VAPID\n * key pair or subject, §8.2 of RFC 8292: also what a subscription made under another key\n * answers, after a key was rotated), 413 (the payload, RFC 8030 §7.2). A push service names\n * no finer reason, so one subscription's refusal cannot be told from the sender's; the copy\n * settles as `Refused<status>` and is logged as an error, and the user's other devices and\n * the rest of the journey go on.\n */\nexport const DEAD_TOKEN_REASONS: ReadonlySet<string> = new Set([\n 'Gone',\n 'NotFound',\n 'InvalidSubscription',\n]);\n\ninterface Subscription {\n endpoint: string;\n keys: { p256dh: string; auth: string };\n}\n\n/**\n * The push services browsers hand out subscription endpoints on. The hosts are those of\n * Pushpad's `known-push-services` list, which it derives from the endpoints of some 200M real\n * subscriptions, checked against Chromium's `push_messaging_constants.cc` and Apple's and\n * Microsoft's own guidance. `*.` covers every subdomain.\n *\n * - `fcm.googleapis.com`: Chrome and the Chromium browsers that use Google's service (Opera,\n * Brave and others; the list above holds no host of their own). `android.googleapis.com` is its GCM predecessor and\n * `jmt17.google.com` the staging service of Chromium's source; both still turn up in stored\n * subscriptions, and both are Google's own.\n * - `updates.push.services.mozilla.com`: Firefox (autopush). The two `mozaws.net` hosts are its\n * stage and dev deployments.\n * - `*.notify.windows.com`: Edge, on a regional WNS host (`sg2p.notify.windows.com`). Microsoft\n * tells senders to push to no channel outside this domain.\n * - `*.push.apple.com`: Safari (`web.push.apple.com`). Apple's guidance is to allow every\n * subdomain.\n *\n * A service not listed here (KaiOS's, a self-hosted one) is named in `webPush.pushServices`.\n */\nexport const PUSH_SERVICE_HOSTS: readonly string[] = [\n 'fcm.googleapis.com',\n 'android.googleapis.com',\n 'jmt17.google.com',\n '*.push.services.mozilla.com',\n 'updates-autopush.stage.mozaws.net',\n 'updates-autopush.dev.mozaws.net',\n '*.notify.windows.com',\n '*.push.apple.com',\n];\n\nconst matchesHost = (hostname: string, pattern: string): boolean => {\n const wanted = pattern.trim().toLowerCase();\n if (wanted === '') return false;\n return wanted.startsWith('*.') ? hostname.endsWith(wanted.slice(1)) : hostname === wanted;\n};\n\n/**\n * Whether `endpoint` is a URL a push is sent to: https, on the default port, without\n * credentials, and on a known push service's host (`PUSH_SERVICE_HOSTS`, plus `extra` — the\n * config's `webPush.pushServices`). The endpoint is whatever the registering client says it is,\n * and the sender POSTs to it from inside the host's network: without the list, a subscription\n * naming `https://localhost`, an address literal or an internal service's name would have the\n * host send requests there. A list of names, not a refusal of private addresses: a name\n * resolves where its owner says, and the sender never sees the address.\n */\nexport function isPushServiceEndpoint(endpoint: unknown, extra: readonly string[] = []): boolean {\n if (typeof endpoint !== 'string') return false;\n let url: URL;\n try {\n url = new URL(endpoint);\n } catch {\n return false;\n }\n if (url.protocol !== 'https:' || url.port !== '' || url.username !== '' || url.password !== '') {\n return false;\n }\n // A fully qualified name (`fcm.googleapis.com.`) is the same host\n const hostname = url.hostname.replace(/\\.$/, '');\n return [...PUSH_SERVICE_HOSTS, ...extra].some((pattern) => matchesHost(hostname, pattern));\n}\n\n/**\n * The endpoint of a browser subscription as it is registered (`JSON.stringify(subscription)`),\n * or undefined when the token is not one.\n */\nexport function subscriptionEndpoint(token: string): string | undefined {\n try {\n const value = JSON.parse(token) as Partial<Subscription> | null;\n return typeof value?.endpoint === 'string' ? value.endpoint : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** A fresh VAPID key pair (once per project; the private key is a secret). */\nexport async function generateVapidKeys(): Promise<VapidKeys> {\n const pair = await crypto.subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, [\n 'sign',\n 'verify',\n ]);\n const raw = new Uint8Array(await crypto.subtle.exportKey('raw', pair.publicKey));\n const jwk = await crypto.subtle.exportKey('jwk', pair.privateKey);\n return { publicKey: base64url(raw), privateKey: jwk.d ?? '' };\n}\n\n/** The record size the header announces: RFC 8291 §4 fixes it at 4096 and one record per push. */\nconst RECORD_SIZE = 4096;\n/**\n * The largest plaintext one record carries. A push message body is at most 4096 octets (RFC 8030\n * §7.2); the aes128gcm header takes 86 of them (16 salt + 4 rs + 1 idlen + 65 key), the record its\n * 16-octet tag and the 1-octet delimiter — 3993 octets of plaintext (RFC 8291 §4). Anything past\n * that is either an invalid record or a 413 from the push service.\n */\nexport const MAX_PLAINTEXT_BYTES = 3993;\n/** Bytes WebCrypto accepts (backed by a plain ArrayBuffer). */\ntype Bytes = Uint8Array<ArrayBuffer>;\nconst encoder = new TextEncoder();\nconst utf8 = (text: string): Bytes => encoder.encode(text);\n\nexport function fromBase64url(text: string): Bytes {\n return new Uint8Array(Buffer.from(text, 'base64url'));\n}\n\nconst concat = (...parts: Uint8Array[]): Bytes => new Uint8Array(Buffer.concat(parts));\n\n/** HKDF-SHA256 (RFC 5869), as WebCrypto provides it. */\nasync function hkdf(salt: Bytes, ikm: Bytes, info: Bytes, length: number): Promise<Bytes> {\n const key = await crypto.subtle.importKey('raw', ikm, 'HKDF', false, ['deriveBits']);\n return new Uint8Array(\n await crypto.subtle.deriveBits({ name: 'HKDF', hash: 'SHA-256', salt, info }, key, length * 8)\n );\n}\n\n/**\n * The `aes128gcm` body for one subscription (RFC 8291 §3.4): salt, record size, the sender's\n * ephemeral public key, then the payload sealed under a key both sides derive from ECDH and the\n * subscription's auth secret.\n */\nexport async function encryptPayload(\n payload: Bytes,\n p256dh: Bytes,\n authSecret: Bytes,\n salt: Bytes = crypto.getRandomValues(new Uint8Array(16))\n): Promise<Bytes> {\n const ephemeral = await crypto.subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, true, [\n 'deriveBits',\n ]);\n const senderPublic = new Uint8Array(await crypto.subtle.exportKey('raw', ephemeral.publicKey));\n const receiver = await crypto.subtle.importKey(\n 'raw',\n p256dh,\n { name: 'ECDH', namedCurve: 'P-256' },\n false,\n []\n );\n const shared = new Uint8Array(\n await crypto.subtle.deriveBits({ name: 'ECDH', public: receiver }, ephemeral.privateKey, 256)\n );\n const ikm = await hkdf(\n authSecret,\n shared,\n concat(utf8('WebPush: info\\0'), p256dh, senderPublic),\n 32\n );\n const cek = await hkdf(salt, ikm, utf8('Content-Encoding: aes128gcm\\0'), 16);\n const nonce = await hkdf(salt, ikm, utf8('Content-Encoding: nonce\\0'), 12);\n const key = await crypto.subtle.importKey('raw', cek, 'AES-GCM', false, ['encrypt']);\n // The single, last record: the payload and the 0x02 delimiter, no padding\n const sealed = new Uint8Array(\n await crypto.subtle.encrypt(\n { name: 'AES-GCM', iv: nonce },\n key,\n concat(payload, new Uint8Array([2]))\n )\n );\n const header = new Uint8Array(16 + 4 + 1);\n header.set(salt, 0);\n new DataView(header.buffer).setUint32(16, RECORD_SIZE);\n header[20] = senderPublic.length;\n return concat(header, senderPublic, sealed);\n}\n\n/**\n * How long a VAPID token is good for. RFC 8292 §2 allows at most 24 hours, counted on the push\n * service's clock: at exactly 24 a host whose clock runs a little fast signs an `exp` the\n * service sees as more than a day away and refuses. 18 hours leaves six for a fast clock, and\n * six past the 12 the token is reused for a slow one.\n */\nconst VAPID_EXP_S = 18 * 3600;\n/** How long a signed token is reused: half its life, so it is never sent near expiry. */\nconst VAPID_TTL_MS = 12 * 3600_000;\n\n/**\n * The VAPID `Authorization` header (RFC 8292 §3) for one key pair. The private key is imported\n * once; the JWT is signed per push service (its `aud` is the service's origin) and reused for\n * `VAPID_TTL_MS`. Concurrent callers for one origin share the one signing in flight, and a signing\n * that failed is not kept. One instance serves every sender built on the pair — a host keeps it\n * across runs, and builds the senders per run.\n */\nexport class VapidSigner {\n private key: Promise<CryptoKey> | undefined;\n private readonly signed = new Map<string, { value: string; issuedAt: number }>();\n private readonly signing = new Map<string, Promise<string>>();\n\n constructor(private readonly options: VapidSignerOptions) {}\n\n /** The header value for the push service at `audience` — its origin, or any URL on it. */\n async authorization(audience: string, now = Date.now()): Promise<string> {\n const origin = new URL(audience).origin;\n const current = this.signed.get(origin);\n if (current !== undefined && now - current.issuedAt < VAPID_TTL_MS) return current.value;\n let pending = this.signing.get(origin);\n if (pending === undefined) {\n pending = this.sign(origin, now)\n .then((value) => {\n this.signed.set(origin, { value, issuedAt: now });\n return value;\n })\n .finally(() => {\n this.signing.delete(origin);\n });\n this.signing.set(origin, pending);\n }\n return pending;\n }\n\n private privateKey(): Promise<CryptoKey> {\n if (this.key === undefined) {\n const publicKey = fromBase64url(this.options.publicKey);\n this.key = crypto.subtle\n .importKey(\n 'jwk',\n {\n kty: 'EC',\n crv: 'P-256',\n d: this.options.privateKey,\n x: base64url(publicKey.slice(1, 33)),\n y: base64url(publicKey.slice(33, 65)),\n ext: true,\n },\n { name: 'ECDSA', namedCurve: 'P-256' },\n false,\n ['sign']\n )\n .catch((error: unknown) => {\n this.key = undefined;\n throw error;\n });\n }\n return this.key;\n }\n\n private async sign(origin: string, now: number): Promise<string> {\n const key = await this.privateKey();\n const header = base64url(JSON.stringify({ typ: 'JWT', alg: 'ES256' }));\n const claims = base64url(\n JSON.stringify({\n aud: origin,\n exp: Math.floor(now / 1000) + VAPID_EXP_S,\n sub: this.options.subject,\n })\n );\n const signature = new Uint8Array(\n await crypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, key, utf8(`${header}.${claims}`))\n );\n return `vapid t=${header}.${claims}.${base64url(signature)}, k=${this.options.publicKey}`;\n }\n}\n\n/**\n * A browser subscription as a sender can use it: an endpoint on a push service\n * (`isPushServiceEndpoint`), a 65-byte uncompressed P-256 key and a 16-byte auth secret. Anything\n * else — not JSON, missing keys, a key of the wrong size, an endpoint that is not https or not a\n * push service's — is undefined.\n */\nfunction parseSubscription(\n token: string,\n pushServices: readonly string[] | undefined\n): { endpoint: string; p256dh: Bytes; auth: Bytes } | undefined {\n try {\n const value = JSON.parse(token) as Partial<Subscription>;\n if (typeof value.endpoint !== 'string') return undefined;\n if (!isPushServiceEndpoint(value.endpoint, pushServices)) return undefined;\n const p256dh = fromBase64url(value.keys?.p256dh ?? '');\n const auth = fromBase64url(value.keys?.auth ?? '');\n if (p256dh.length !== 65 || p256dh[0] !== 4 || auth.length !== 16) return undefined;\n return { endpoint: value.endpoint, p256dh, auth };\n } catch {\n return undefined;\n }\n}\n\n/** The endpoint's host for a log line — never the URL, whose path is the subscription's capability. */\nfunction hostOf(endpoint: string): string {\n try {\n return new URL(endpoint).host;\n } catch {\n return 'not a URL';\n }\n}\n\nexport class WebPushSender implements MessageSender {\n constructor(private readonly options: WebPushOptions) {}\n\n async send(message: OutboundMessage): Promise<void | SendResult> {\n if (message.channel !== 'push') {\n throw new Error(`WebPushSender: unsupported channel '${message.channel}'`);\n }\n if (message.recipient === undefined) {\n throw new Error(`WebPushSender: no subscription for user '${message.userId}'`);\n }\n const subscription = parseSubscription(message.recipient, this.options.pushServices);\n if (subscription === undefined) {\n // An https endpoint off the push services' hosts is never fetched, and the copy settles\n // undelivered — but the device is kept (the reason is not a dead token's): it may be a\n // real push service this list does not know, and naming it in `webPush.pushServices`\n // has to bring its devices back rather than find them deleted\n const endpoint = subscriptionEndpoint(message.recipient);\n if (\n endpoint?.startsWith('https://') === true &&\n !isPushServiceEndpoint(endpoint, this.options.pushServices)\n ) {\n console.warn(\n `[webpush] subscription for user ${message.userId} not sent to: its endpoint is not a known push service's (${hostOf(endpoint)}); see webPush.pushServices`\n );\n return { delivered: false, reason: 'UnlistedPushService' };\n }\n // Not a usable subscription: nothing will ever deliver to it, so do not retry into it\n return { delivered: false, reason: 'InvalidSubscription' };\n }\n const content = await this.options.render(message.template, message.props);\n const payload = utf8(\n JSON.stringify({\n ...content,\n template: message.template,\n idempotencyKey: message.idempotencyKey,\n ...message.tracking?.data,\n })\n );\n if (payload.length > MAX_PLAINTEXT_BYTES) {\n // The same template renders the same size on every attempt: settle it before encrypting\n throw new PermanentError(\n `[webpush] payload for template '${message.template}' is ${payload.length} bytes; a push message carries at most ${MAX_PLAINTEXT_BYTES}`,\n { reason: 'PayloadTooLarge' }\n );\n }\n const body = await encryptPayload(payload, subscription.p256dh, subscription.auth);\n const doFetch = this.options.fetch ?? fetch;\n const response = await doFetch(subscription.endpoint, {\n method: 'POST',\n headers: {\n authorization: await this.options.credentials.authorization(subscription.endpoint),\n 'content-encoding': 'aes128gcm',\n 'content-type': 'application/octet-stream',\n ttl: String(this.options.ttl ?? 86_400),\n urgency: 'normal',\n // A resend of the same copy replaces the first one while it is still queued (RFC 8030\n // §5.4), so an at-least-once retry does not show the notification twice\n topic: await webPushTopic(message.idempotencyKey),\n },\n body,\n });\n if (response.ok) return;\n const { status } = response;\n if (status === 404 || status === 410) {\n // The browser unsubscribed or the subscription expired: it will never deliver again\n console.warn(`[webpush] subscription gone for user ${message.userId}: ${status}`);\n return { delivered: false, reason: status === 410 ? 'Gone' : 'NotFound' };\n }\n const text = await response.text();\n if (isRetryableStatus(status)) throw new Error(`[webpush] ${status}: ${text}`);\n // Not a refusal at all (a redirect the fetch did not follow): nothing a device can explain\n if (status < 400) {\n throw new PermanentError(`[webpush] unexpected answer from the push service: ${status}`, {\n reason: `Unexpected${status}`,\n });\n }\n // This subscription, or this sender: the answer does not say. Settled with the device kept,\n // and loud — if it is the VAPID key, every subscription answers so\n console.error(\n `[webpush] push service refused the request for user ${message.userId}: ${status} ${text}`\n );\n return { delivered: false, reason: `Refused${status}` };\n }\n}\n\n/**\n * The `Topic` header for one copy: RFC 8030 §5.4 allows at most 32 characters of the URL-safe\n * base64 alphabet, so the idempotency key goes through SHA-256 and is cut to size.\n */\nexport async function webPushTopic(idempotencyKey: string): Promise<string> {\n const digest = await crypto.subtle.digest('SHA-256', utf8(idempotencyKey));\n return base64url(new Uint8Array(digest)).slice(0, 32);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0DA,MAAa,qCAA0C,IAAI,IAAI;CAC7D;CACA;CACA;AACF,CAAC;;;;;;;;;;;;;;;;;;;;AA0BD,MAAa,qBAAwC;CACnD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,eAAe,UAAkB,YAA6B;CAClE,MAAM,SAAS,QAAQ,KAAK,CAAC,CAAC,YAAY;CAC1C,IAAI,WAAW,IAAI,OAAO;CAC1B,OAAO,OAAO,WAAW,IAAI,IAAI,SAAS,SAAS,OAAO,MAAM,CAAC,CAAC,IAAI,aAAa;AACrF;;;;;;;;;;AAWA,SAAgB,sBAAsB,UAAmB,QAA2B,CAAC,GAAY;CAC/F,IAAI,OAAO,aAAa,UAAU,OAAO;CACzC,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,QAAQ;CACxB,QAAQ;EACN,OAAO;CACT;CACA,IAAI,IAAI,aAAa,YAAY,IAAI,SAAS,MAAM,IAAI,aAAa,MAAM,IAAI,aAAa,IAC1F,OAAO;CAGT,MAAM,WAAW,IAAI,SAAS,QAAQ,OAAO,EAAE;CAC/C,OAAO,CAAC,GAAG,oBAAoB,GAAG,KAAK,CAAC,CAAC,MAAM,YAAY,YAAY,UAAU,OAAO,CAAC;AAC3F;;;;;AAMA,SAAgB,qBAAqB,OAAmC;CACtE,IAAI;EACF,MAAM,QAAQ,KAAK,MAAM,KAAK;EAC9B,OAAO,OAAO,OAAO,aAAa,WAAW,MAAM,WAAW,KAAA;CAChE,QAAQ;EACN;CACF;AAC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