@naosystem/cf-workers-status-page 0.0.0-stage → 0.1.2

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 (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/dist/admin.html +17 -0
  4. package/dist/auth-cloudflare-access.js +304 -0
  5. package/dist/auth-cloudflare-access.js.map +1 -0
  6. package/dist/chunks/monitor-B2u42off.js +79 -0
  7. package/dist/chunks/monitor-B2u42off.js.map +1 -0
  8. package/dist/chunks/notifier-DODVuFhr.js +158 -0
  9. package/dist/chunks/notifier-DODVuFhr.js.map +1 -0
  10. package/dist/chunks/page-templates-DPZcMlic.js +71 -0
  11. package/dist/chunks/page-templates-DPZcMlic.js.map +1 -0
  12. package/dist/chunks/run-check-bbo3LqI7.js +235 -0
  13. package/dist/chunks/run-check-bbo3LqI7.js.map +1 -0
  14. package/dist/chunks/timeline-YJXjehRf.js +1081 -0
  15. package/dist/chunks/timeline-YJXjehRf.js.map +1 -0
  16. package/dist/client/_headers +10 -0
  17. package/dist/client/assets/admin-BBJxKTF6.js +1 -0
  18. package/dist/client/assets/admin-Be4X0WFj.css +1 -0
  19. package/dist/client/assets/index-BgOspfsy.js +2 -0
  20. package/dist/client/assets/index-xpKyzvog.css +1 -0
  21. package/dist/client/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  22. package/dist/client/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  23. package/dist/client/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  24. package/dist/client/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  25. package/dist/client/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  26. package/dist/client/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  27. package/dist/client/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  28. package/dist/client/assets/ja-BT5brvxP.js +1 -0
  29. package/dist/client/assets/ja-DSSblLff.js +1 -0
  30. package/dist/client/assets/noto-sans-jp-0-wght-normal-vN5ykBQF.woff2 +0 -0
  31. package/dist/client/assets/noto-sans-jp-1-wght-normal-N_EDDt8j.woff2 +0 -0
  32. package/dist/client/assets/noto-sans-jp-10-wght-normal-ChuiXes4.woff2 +0 -0
  33. package/dist/client/assets/noto-sans-jp-100-wght-normal-CrE4HD6k.woff2 +0 -0
  34. package/dist/client/assets/noto-sans-jp-101-wght-normal-DOqEZFXR.woff2 +0 -0
  35. package/dist/client/assets/noto-sans-jp-102-wght-normal-2gFz4V6e.woff2 +0 -0
  36. package/dist/client/assets/noto-sans-jp-103-wght-normal-D9RhXU-z.woff2 +0 -0
  37. package/dist/client/assets/noto-sans-jp-104-wght-normal-OIyZ9iQD.woff2 +0 -0
  38. package/dist/client/assets/noto-sans-jp-105-wght-normal-CqRQAfnb.woff2 +0 -0
  39. package/dist/client/assets/noto-sans-jp-106-wght-normal-D-PO3jqS.woff2 +0 -0
  40. package/dist/client/assets/noto-sans-jp-107-wght-normal-DrykTIAp.woff2 +0 -0
  41. package/dist/client/assets/noto-sans-jp-108-wght-normal-DijBe27A.woff2 +0 -0
  42. package/dist/client/assets/noto-sans-jp-109-wght-normal-DaJwqT__.woff2 +0 -0
  43. package/dist/client/assets/noto-sans-jp-11-wght-normal-DdkFqF_o.woff2 +0 -0
  44. package/dist/client/assets/noto-sans-jp-110-wght-normal-bhh2FQQH.woff2 +0 -0
  45. package/dist/client/assets/noto-sans-jp-111-wght-normal-CuGzYIdC.woff2 +0 -0
  46. package/dist/client/assets/noto-sans-jp-112-wght-normal-DdhK_1vk.woff2 +0 -0
  47. package/dist/client/assets/noto-sans-jp-113-wght-normal-hxVHS2d4.woff2 +0 -0
  48. package/dist/client/assets/noto-sans-jp-114-wght-normal-DUzjAsrP.woff2 +0 -0
  49. package/dist/client/assets/noto-sans-jp-115-wght-normal-BiZ4-5rz.woff2 +0 -0
  50. package/dist/client/assets/noto-sans-jp-116-wght-normal-DkZAcxAY.woff2 +0 -0
  51. package/dist/client/assets/noto-sans-jp-117-wght-normal-CLJPD2y0.woff2 +0 -0
  52. package/dist/client/assets/noto-sans-jp-118-wght-normal-D8DI_HXJ.woff2 +0 -0
  53. package/dist/client/assets/noto-sans-jp-119-wght-normal-BAB3pFaH.woff2 +0 -0
  54. package/dist/client/assets/noto-sans-jp-12-wght-normal-K36fA5_o.woff2 +0 -0
  55. package/dist/client/assets/noto-sans-jp-13-wght-normal-BnYizWno.woff2 +0 -0
  56. package/dist/client/assets/noto-sans-jp-14-wght-normal-BP4IgVC-.woff2 +0 -0
  57. package/dist/client/assets/noto-sans-jp-15-wght-normal-DyhWcoYF.woff2 +0 -0
  58. package/dist/client/assets/noto-sans-jp-16-wght-normal-CXsQLI2j.woff2 +0 -0
  59. package/dist/client/assets/noto-sans-jp-17-wght-normal-C8FU1ZJ4.woff2 +0 -0
  60. package/dist/client/assets/noto-sans-jp-18-wght-normal-Cl0IKBVh.woff2 +0 -0
  61. package/dist/client/assets/noto-sans-jp-19-wght-normal-D3D3JUJm.woff2 +0 -0
  62. package/dist/client/assets/noto-sans-jp-2-wght-normal-CGu8NhtQ.woff2 +0 -0
  63. package/dist/client/assets/noto-sans-jp-20-wght-normal-DxsoeWSt.woff2 +0 -0
  64. package/dist/client/assets/noto-sans-jp-21-wght-normal-CuNsexW5.woff2 +0 -0
  65. package/dist/client/assets/noto-sans-jp-22-wght-normal-DVX3OFQM.woff2 +0 -0
  66. package/dist/client/assets/noto-sans-jp-23-wght-normal-BPFuo_yH.woff2 +0 -0
  67. package/dist/client/assets/noto-sans-jp-24-wght-normal-D85Fj66x.woff2 +0 -0
  68. package/dist/client/assets/noto-sans-jp-25-wght-normal-DdOOVuSz.woff2 +0 -0
  69. package/dist/client/assets/noto-sans-jp-26-wght-normal-BRB1GnUq.woff2 +0 -0
  70. package/dist/client/assets/noto-sans-jp-27-wght-normal-BxZFF8JU.woff2 +0 -0
  71. package/dist/client/assets/noto-sans-jp-28-wght-normal-VUlviaYI.woff2 +0 -0
  72. package/dist/client/assets/noto-sans-jp-29-wght-normal-CalQqRwB.woff2 +0 -0
  73. package/dist/client/assets/noto-sans-jp-3-wght-normal-cncaCaM8.woff2 +0 -0
  74. package/dist/client/assets/noto-sans-jp-30-wght-normal-CHLg85G9.woff2 +0 -0
  75. package/dist/client/assets/noto-sans-jp-31-wght-normal-BUoF9dl9.woff2 +0 -0
  76. package/dist/client/assets/noto-sans-jp-32-wght-normal-C5ZTiBNw.woff2 +0 -0
  77. package/dist/client/assets/noto-sans-jp-33-wght-normal-C6XNJsfA.woff2 +0 -0
  78. package/dist/client/assets/noto-sans-jp-34-wght-normal-DHkM837w.woff2 +0 -0
  79. package/dist/client/assets/noto-sans-jp-35-wght-normal-QMtEjDIl.woff2 +0 -0
  80. package/dist/client/assets/noto-sans-jp-36-wght-normal-CUyF0GqZ.woff2 +0 -0
  81. package/dist/client/assets/noto-sans-jp-37-wght-normal-EORmNjxA.woff2 +0 -0
  82. package/dist/client/assets/noto-sans-jp-38-wght-normal-C8ERbMNG.woff2 +0 -0
  83. package/dist/client/assets/noto-sans-jp-39-wght-normal-ChUfpJbl.woff2 +0 -0
  84. package/dist/client/assets/noto-sans-jp-4-wght-normal-DtWqs3EP.woff2 +0 -0
  85. package/dist/client/assets/noto-sans-jp-40-wght-normal-MgP8JEEE.woff2 +0 -0
  86. package/dist/client/assets/noto-sans-jp-41-wght-normal-3ctF9abM.woff2 +0 -0
  87. package/dist/client/assets/noto-sans-jp-42-wght-normal-CQtg6UZe.woff2 +0 -0
  88. package/dist/client/assets/noto-sans-jp-43-wght-normal-D1Pmm9aG.woff2 +0 -0
  89. package/dist/client/assets/noto-sans-jp-44-wght-normal-Cp9dHeXI.woff2 +0 -0
  90. package/dist/client/assets/noto-sans-jp-45-wght-normal-D2b1osBj.woff2 +0 -0
  91. package/dist/client/assets/noto-sans-jp-46-wght-normal-CGIA-Vlo.woff2 +0 -0
  92. package/dist/client/assets/noto-sans-jp-47-wght-normal-C4EEGqDS.woff2 +0 -0
  93. package/dist/client/assets/noto-sans-jp-48-wght-normal-D2iBztXa.woff2 +0 -0
  94. package/dist/client/assets/noto-sans-jp-49-wght-normal-DxqRVik_.woff2 +0 -0
  95. package/dist/client/assets/noto-sans-jp-5-wght-normal-CFiyVtll.woff2 +0 -0
  96. package/dist/client/assets/noto-sans-jp-50-wght-normal-CMseszwo.woff2 +0 -0
  97. package/dist/client/assets/noto-sans-jp-51-wght-normal-Cqc-9wfi.woff2 +0 -0
  98. package/dist/client/assets/noto-sans-jp-52-wght-normal-BVLZTbqC.woff2 +0 -0
  99. package/dist/client/assets/noto-sans-jp-53-wght-normal-DTyNOJaY.woff2 +0 -0
  100. package/dist/client/assets/noto-sans-jp-54-wght-normal-_mxGq_et.woff2 +0 -0
  101. package/dist/client/assets/noto-sans-jp-55-wght-normal-Bvndync8.woff2 +0 -0
  102. package/dist/client/assets/noto-sans-jp-56-wght-normal-0MmMqroR.woff2 +0 -0
  103. package/dist/client/assets/noto-sans-jp-57-wght-normal-BdRnjDYs.woff2 +0 -0
  104. package/dist/client/assets/noto-sans-jp-58-wght-normal-BYGgVeN_.woff2 +0 -0
  105. package/dist/client/assets/noto-sans-jp-59-wght-normal-Bdv8mdje.woff2 +0 -0
  106. package/dist/client/assets/noto-sans-jp-6-wght-normal-M-pWkj3J.woff2 +0 -0
  107. package/dist/client/assets/noto-sans-jp-60-wght-normal-DC6FEqsM.woff2 +0 -0
  108. package/dist/client/assets/noto-sans-jp-61-wght-normal-CYIuK5Lr.woff2 +0 -0
  109. package/dist/client/assets/noto-sans-jp-62-wght-normal-DeHy8p7w.woff2 +0 -0
  110. package/dist/client/assets/noto-sans-jp-63-wght-normal-B4M6eMmD.woff2 +0 -0
  111. package/dist/client/assets/noto-sans-jp-64-wght-normal-DLyOXBrC.woff2 +0 -0
  112. package/dist/client/assets/noto-sans-jp-65-wght-normal-X7SsA1bs.woff2 +0 -0
  113. package/dist/client/assets/noto-sans-jp-66-wght-normal-VScDM-_N.woff2 +0 -0
  114. package/dist/client/assets/noto-sans-jp-67-wght-normal-Dg2D3DZB.woff2 +0 -0
  115. package/dist/client/assets/noto-sans-jp-68-wght-normal-BB0AR8UN.woff2 +0 -0
  116. package/dist/client/assets/noto-sans-jp-69-wght-normal-CucwpUnQ.woff2 +0 -0
  117. package/dist/client/assets/noto-sans-jp-7-wght-normal-DzOz8Ryd.woff2 +0 -0
  118. package/dist/client/assets/noto-sans-jp-70-wght-normal-BZId6-Tb.woff2 +0 -0
  119. package/dist/client/assets/noto-sans-jp-71-wght-normal-CzPU0NF7.woff2 +0 -0
  120. package/dist/client/assets/noto-sans-jp-72-wght-normal-DrNRYXnT.woff2 +0 -0
  121. package/dist/client/assets/noto-sans-jp-73-wght-normal-DF2BdR6a.woff2 +0 -0
  122. package/dist/client/assets/noto-sans-jp-74-wght-normal-BMlOw_5y.woff2 +0 -0
  123. package/dist/client/assets/noto-sans-jp-75-wght-normal-DKq84hLG.woff2 +0 -0
  124. package/dist/client/assets/noto-sans-jp-76-wght-normal-CTb-2MFr.woff2 +0 -0
  125. package/dist/client/assets/noto-sans-jp-77-wght-normal-DfIVi-wf.woff2 +0 -0
  126. package/dist/client/assets/noto-sans-jp-78-wght-normal-_-z1Vrir.woff2 +0 -0
  127. package/dist/client/assets/noto-sans-jp-79-wght-normal-D8kGlXda.woff2 +0 -0
  128. package/dist/client/assets/noto-sans-jp-8-wght-normal-BfWoBb3q.woff2 +0 -0
  129. package/dist/client/assets/noto-sans-jp-80-wght-normal-BOEztZwY.woff2 +0 -0
  130. package/dist/client/assets/noto-sans-jp-81-wght-normal-h5VC8QpU.woff2 +0 -0
  131. package/dist/client/assets/noto-sans-jp-82-wght-normal-DJ4QkvX0.woff2 +0 -0
  132. package/dist/client/assets/noto-sans-jp-83-wght-normal-DANtuAZG.woff2 +0 -0
  133. package/dist/client/assets/noto-sans-jp-84-wght-normal-DjZ8Sp6m.woff2 +0 -0
  134. package/dist/client/assets/noto-sans-jp-85-wght-normal-kpU7kbMF.woff2 +0 -0
  135. package/dist/client/assets/noto-sans-jp-86-wght-normal-DRPTa-bf.woff2 +0 -0
  136. package/dist/client/assets/noto-sans-jp-87-wght-normal-CFM472wD.woff2 +0 -0
  137. package/dist/client/assets/noto-sans-jp-88-wght-normal-2rLLwelj.woff2 +0 -0
  138. package/dist/client/assets/noto-sans-jp-89-wght-normal-DUIF9ybW.woff2 +0 -0
  139. package/dist/client/assets/noto-sans-jp-9-wght-normal-WLs1HgG6.woff2 +0 -0
  140. package/dist/client/assets/noto-sans-jp-90-wght-normal-B0n_tL-y.woff2 +0 -0
  141. package/dist/client/assets/noto-sans-jp-91-wght-normal-BishDeFy.woff2 +0 -0
  142. package/dist/client/assets/noto-sans-jp-92-wght-normal-DoIdukLp.woff2 +0 -0
  143. package/dist/client/assets/noto-sans-jp-93-wght-normal-DMCycan_.woff2 +0 -0
  144. package/dist/client/assets/noto-sans-jp-94-wght-normal-DlyoTk-A.woff2 +0 -0
  145. package/dist/client/assets/noto-sans-jp-95-wght-normal-D0L1aiGf.woff2 +0 -0
  146. package/dist/client/assets/noto-sans-jp-96-wght-normal-CjJ0kYkQ.woff2 +0 -0
  147. package/dist/client/assets/noto-sans-jp-97-wght-normal-CJ8uP04H.woff2 +0 -0
  148. package/dist/client/assets/noto-sans-jp-98-wght-normal-CjEDrQIY.woff2 +0 -0
  149. package/dist/client/assets/noto-sans-jp-99-wght-normal-DaQ3GEVf.woff2 +0 -0
  150. package/dist/client/assets/noto-sans-jp-cyrillic-wght-normal-BbS1Q_ZO.woff2 +0 -0
  151. package/dist/client/assets/noto-sans-jp-latin-ext-wght-normal-IaSo_s9d.woff2 +0 -0
  152. package/dist/client/assets/noto-sans-jp-latin-wght-normal-Bnnzbixe.woff2 +0 -0
  153. package/dist/client/assets/noto-sans-jp-vietnamese-wght-normal-CjvP4Ahz.woff2 +0 -0
  154. package/dist/client/assets/src-BDi4qpij.js +9 -0
  155. package/dist/client/assets/src-C6ZFz-Gu.css +1 -0
  156. package/dist/client/assets/views-CSeX_2-u.css +1 -0
  157. package/dist/client/assets/views-DHTTEaNV.js +1 -0
  158. package/dist/client/index.html +15 -0
  159. package/dist/client/licenses/fonts.txt +104 -0
  160. package/dist/client/licenses/third-party.txt +349 -0
  161. package/dist/index.js +18 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/notifier-discord.js +153 -0
  164. package/dist/notifier-discord.js.map +1 -0
  165. package/dist/notifier-slack.js +98 -0
  166. package/dist/notifier-slack.js.map +1 -0
  167. package/dist/notifier-webhook.js +215 -0
  168. package/dist/notifier-webhook.js.map +1 -0
  169. package/dist/provider-http.js +177 -0
  170. package/dist/provider-http.js.map +1 -0
  171. package/dist/vite.js +224 -0
  172. package/dist/vite.js.map +1 -0
  173. package/dist/worker.js +8616 -0
  174. package/dist/worker.js.map +1 -0
  175. package/package.json +58 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifier-slack.js","names":[],"sources":["../../notifier-slack/src/messages.ts","../../notifier-slack/src/index.ts"],"sourcesContent":["import type { NotifierMessages } from \"@naosystem/cf-workers-status-page-core\";\n\n/** Texts of the admin UI's form for Slack targets (English is also the schema's `title`/`description`). */\nexport const messages = {\n\ten: {\n\t\t$kind: \"Slack\",\n\t\t\"url.title\": \"Webhook URL\",\n\t\t\"url.description\": \"The incoming webhook's URL, https://hooks.slack.com/services/… (from the Slack app's Incoming Webhooks).\",\n\t},\n\tja: {\n\t\t$kind: \"Slack\",\n\t\t\"url.title\": \"Webhook の URL\",\n\t\t\"url.description\": \"Incoming Webhook の URL(https://hooks.slack.com/services/…)。Slack アプリの Incoming Webhooks で発行します。\",\n\t},\n} as const satisfies NotifierMessages;\n","/**\n * Slack notifications through an incoming webhook.\n *\n * Create an incoming webhook for a Slack app (Slack: \"Sending messages using incoming\n * webhooks\") and enter its URL, `https://hooks.slack.com/services/T…/B…/…`, as the target's\n * `url`. The URL is the credential, so it is a secret option: encrypted at rest and never shown\n * again.\n *\n * Each notification is one POST of `{ \"text\": … }` as JSON, formatted with Slack's `mrkdwn`:\n * the title in bold after an emoji for its severity, the text (which says when it happened)\n * and the links. `&`, `<` and `>` in the hub's text are escaped, as Slack requires, so that\n * names cannot turn into mentions or links. The message is kept under {@link MAX_TEXT_CHARS}\n * characters (Slack truncates long messages).\n *\n * Slack answers `200 ok`, or an error status with a short code in the body (such as\n * `400 invalid_payload`, `404 no_service`, `410 channel_is_archived`); 429 (rate limited)\n * and 5xx are retried by the hub, other errors are recorded as failed at once.\n */\nimport {\n\tdefineNotifier,\n\texpectSuccess,\n\ttype Notification,\n\ttype NotificationSeverity,\n} from \"@naosystem/cf-workers-status-page-core\";\nimport * as z from \"zod\";\nimport { messages } from \"./messages\";\n\nexport { messages };\n\n/** Slack recommends keeping a message's text under 4,000 characters. */\nexport const MAX_TEXT_CHARS = 3_500;\n\nconst SLACK_HOSTS: ReadonlySet<string> = new Set([\"hooks.slack.com\", \"hooks.slack-gov.com\"]);\nconst WEBHOOK_PATH = /^\\/services\\/[A-Za-z0-9]+\\/[A-Za-z0-9]+\\/[A-Za-z0-9]+$/;\n\nexport const slackOptions = z.strictObject({\n\t/** The incoming webhook's URL. Secret. */\n\turl: z\n\t\t.url({ protocol: /^https$/, error: \"must be an https URL\" })\n\t\t.refine((value) => {\n\t\t\tconst url = new URL(value);\n\t\t\treturn SLACK_HOSTS.has(url.hostname) && WEBHOOK_PATH.test(url.pathname) && url.search === \"\";\n\t\t}, \"must be a Slack incoming webhook URL, https://hooks.slack.com/services/…\")\n\t\t.meta({ title: messages.en[\"url.title\"], description: messages.en[\"url.description\"] }),\n});\nexport type SlackOptions = z.infer<typeof slackOptions>;\n\nconst EMOJI: Readonly<Record<NotificationSeverity, string>> = {\n\tcritical: \":red_circle:\",\n\twarning: \":large_yellow_circle:\",\n\tok: \":large_green_circle:\",\n\tinfo: \":information_source:\",\n};\n\n/** Escapes the three characters Slack's `mrkdwn` reserves for mentions and links. */\nexport function escapeSlack(text: string): string {\n\treturn text.replaceAll(\"&\", \"&amp;\").replaceAll(\"<\", \"&lt;\").replaceAll(\">\", \"&gt;\");\n}\n\nfunction truncate(text: string, max: number): string {\n\treturn text.length <= max ? text : `${text.slice(0, max - 1)}…`;\n}\n\n/** The JSON body sent to Slack for `notification`. */\nexport function slackPayload(notification: Notification): { text: string } {\n\tconst links = notification.links.map((link) => {\n\t\t// In <url|label>, `|` and `>` would end the URL early; they are percent-encoded in a valid URL anyway.\n\t\tconst url = link.url.replaceAll(\"|\", \"%7C\").replaceAll(\">\", \"%3E\");\n\t\treturn `<${url}|${escapeSlack(link.label)}>`;\n\t});\n\tconst head = `${EMOJI[notification.severity]} *${escapeSlack(truncate(notification.title, 200))}*`;\n\tconst tail = links.length === 0 ? \"\" : `\\n${links.join(\" \")}`;\n\tconst room = MAX_TEXT_CHARS - head.length - tail.length - 1;\n\treturn { text: `${head}\\n${truncate(escapeSlack(notification.text), Math.max(0, room))}${tail}` };\n}\n\nconst kind = defineNotifier({\n\ttype: \"slack\",\n\tname: \"Slack\",\n\toptions: slackOptions,\n\tsecretOptions: [\"url\"],\n\tmessages,\n\tasync send(notification, options, ctx) {\n\t\tconst response = await ctx.fetch(options.url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\tbody: JSON.stringify(slackPayload(notification)),\n\t\t\tredirect: \"manual\",\n\t\t\tsignal: ctx.signal,\n\t\t});\n\t\tawait expectSuccess(response, \"Slack\");\n\t},\n});\n\n/** The Slack notifier kind, for `notifiers` in status.config.ts. */\nexport function slack() {\n\treturn kind;\n}\n"],"mappings":";;;;AAGA,IAAa,WAAW;CACvB,IAAI;EACH,OAAO;EACP,aAAa;EACb,mBAAmB;CACpB;CACA,IAAI;EACH,OAAO;EACP,aAAa;EACb,mBAAmB;CACpB;AACD;;;;;;;;;;;;;;;;;;;;;ACgBA,IAAa,iBAAiB;AAE9B,IAAM,8BAAmC,IAAI,IAAI,CA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AI,OAAO;AACjG;AAEA,IAAM,OAAO,eAAe;CAC3B,MAAM;CACN,MAAM;CACN,SAAS;CACT,eAAe,CAAC,KAAK;CACrB;CACA,MAAM,KAAK,cAAc,SAAS,KAAK;EACtC,MAAM,WAAW,MAAM,IAAI,MAAM,QAAQ,KAAK;GAC7C,QAAQ;GACR,SAAS,EAAE,gBAAgB,mBAAmB;GAC9C,MAAM,KAAK,UAAU,aAAa,YAAY,CAAC;GAC/C,UAAU;GACV,QAAQ,IAAI;EACb,CAAC;EACD,MAAM,cAAc,UAAU,OAAO;CACtC;AACD,CAAC;;AAGD,SAAgB,QAAQ;CACvB,OAAO;AACR"}
@@ -0,0 +1,215 @@
1
+ import { a as expectSuccess, o as isPublicHostname, r as defineNotifier } from "./chunks/notifier-DODVuFhr.js";
2
+ import * as z from "zod";
3
+ // ../notifier-webhook/src/messages.ts
4
+ /** Texts of the admin UI's form for webhook targets (English is also the schema's `title`/`description`). */
5
+ var messages = {
6
+ en: {
7
+ $kind: "Webhook",
8
+ "url.title": "URL",
9
+ "url.description": "Where to POST each notification as JSON (https).",
10
+ "signingSecret.title": "Signing secret",
11
+ "signingSecret.description": "At least 16 characters. Each request is then signed (X-CF-Workers-Status-Page-Signature), so that the receiver can check that it comes from here.",
12
+ "headers.title": "Headers",
13
+ "headers.description": "Extra request headers, such as Authorization."
14
+ },
15
+ ja: {
16
+ $kind: "Webhook",
17
+ "url.title": "URL",
18
+ "url.description": "通知を JSON で POST する送り先(https)。",
19
+ "signingSecret.title": "署名用のシークレット",
20
+ "signingSecret.description": "16文字以上。各リクエストに署名(X-CF-Workers-Status-Page-Signature)を付け、受信側で送信元を確かめられるようにします。",
21
+ "headers.title": "ヘッダー",
22
+ "headers.description": "Authorization など、追加するリクエストヘッダー。"
23
+ }
24
+ };
25
+ // ../notifier-webhook/src/index.ts
26
+ /**
27
+ * Notifications as JSON POSTed to any URL, optionally signed.
28
+ *
29
+ * ## Request
30
+ *
31
+ * `POST <url>` (https only) with `Content-Type: application/json` and the body {@link WebhookPayload}:
32
+ *
33
+ * ```json
34
+ * {
35
+ * "type": "cf-workers-status-page.notification",
36
+ * "version": 1,
37
+ * "id": "api:4102444800000",
38
+ * "event": "down",
39
+ * "severity": "critical",
40
+ * "title": "API is down",
41
+ * "text": "API has been down since Jan 1, 2100, 12:00:00 AM UTC.\nLast check: HTTP 503",
42
+ * "occurredAt": "2100-01-01T00:00:00.000Z",
43
+ * "monitor": { "id": "api", "name": "API" },
44
+ * "state": "down",
45
+ * "previousState": "up",
46
+ * "links": [{ "label": "Create an incident", "url": "https://status.example.com/admin/…" }],
47
+ * "locale": "en"
48
+ * }
49
+ * ```
50
+ *
51
+ * `event` is `down`, `recovered`, `degraded`, `degraded_recovered`, `unknown` or `test`. `id`
52
+ * is the same for every retry and duplicate delivery of a notification: deliveries are at
53
+ * least once, so drop an `id` you have already handled. Deliveries may also arrive out of
54
+ * order; `occurredAt` says when it happened. Fields may be added in later versions of the
55
+ * same `version`.
56
+ *
57
+ * The receiver must answer 2xx within the hub's timeout. 408, 429 (with `Retry-After`) and 5xx
58
+ * are retried with backoff; other answers, including redirects (they are not followed), are
59
+ * recorded as failed at once.
60
+ *
61
+ * ## Signature
62
+ *
63
+ * With `signingSecret`, every request also has
64
+ *
65
+ * - `X-CF-Workers-Status-Page-Timestamp`: the time of sending, in Unix seconds;
66
+ * - `X-CF-Workers-Status-Page-Signature`: `v1=` and the hex HMAC-SHA256 of
67
+ * `<timestamp>.<raw body>` with the secret as the key.
68
+ *
69
+ * To verify, compute the same HMAC over the raw body as received, compare it in constant time
70
+ * ({@link verifySignature} does this), and reject timestamps older than a few minutes, so that
71
+ * a captured request cannot be replayed later. Each retry is signed afresh.
72
+ *
73
+ * `url`, `signingSecret` and `headers` (for example `Authorization` for the receiver) are
74
+ * secret options: encrypted at rest and never shown again. `url` must name a public host (no IP
75
+ * address or internal name). `signingSecret` and `headers` are bound to the origin of `url`:
76
+ * moving the target to another origin requires entering them again (or clearing them).
77
+ */
78
+ var TIMESTAMP_HEADER = "X-CF-Workers-Status-Page-Timestamp";
79
+ var SIGNATURE_HEADER = "X-CF-Workers-Status-Page-Signature";
80
+ /** The notification's `id`, also as a header, for receivers that deduplicate before parsing. */
81
+ var ID_HEADER = "X-CF-Workers-Status-Page-Notification-Id";
82
+ var SIGNATURE_VERSION = "v1";
83
+ /** Headers the hub sets itself, which `headers` cannot override. */
84
+ var RESERVED_HEADERS = new Set([
85
+ "content-type",
86
+ "content-length",
87
+ "host",
88
+ TIMESTAMP_HEADER,
89
+ SIGNATURE_HEADER,
90
+ ID_HEADER
91
+ ].map((name) => name.toLowerCase()));
92
+ function isHeaderName(name) {
93
+ try {
94
+ new Headers([[name, "x"]]);
95
+ return true;
96
+ } catch {
97
+ return false;
98
+ }
99
+ }
100
+ var webhookOptions = z.strictObject({
101
+ /** Where to POST: https only, since the body and headers may matter. Secret, since URLs often carry a token. */
102
+ url: z.url({
103
+ protocol: /^https$/,
104
+ error: "must be an https URL"
105
+ }).refine((value) => {
106
+ const url = new URL(value);
107
+ return url.username === "" && url.password === "";
108
+ }, "must not contain credentials; send them in headers").refine((value) => isPublicHostname(new URL(value).hostname), "must name a public host: IP addresses and internal names such as localhost or *.internal are not allowed").meta({
109
+ title: messages.en["url.title"],
110
+ description: messages.en["url.description"]
111
+ }),
112
+ /** Signs every request (see the module documentation). At least 16 characters; 32 random bytes are best. Secret. */
113
+ signingSecret: z.string().min(16, "must be at least 16 characters").max(256).meta({
114
+ title: messages.en["signingSecret.title"],
115
+ description: messages.en["signingSecret.description"]
116
+ }).optional(),
117
+ /** Extra request headers, such as `Authorization`. Secret. */
118
+ headers: z.record(z.string(), z.string().max(4096).refine((value) => !/[\r\n\0]/.test(value), "must not contain line breaks")).superRefine((headers, ctx) => {
119
+ for (const name of Object.keys(headers)) if (!isHeaderName(name)) ctx.addIssue({
120
+ code: "custom",
121
+ message: `"${name}" is not a header name`,
122
+ path: [name]
123
+ });
124
+ else if (RESERVED_HEADERS.has(name.toLowerCase())) ctx.addIssue({
125
+ code: "custom",
126
+ message: `"${name}" is set by the hub`,
127
+ path: [name]
128
+ });
129
+ }).meta({
130
+ title: messages.en["headers.title"],
131
+ description: messages.en["headers.description"]
132
+ }).optional()
133
+ });
134
+ function webhookPayload(notification) {
135
+ return {
136
+ type: "cf-workers-status-page.notification",
137
+ version: 1,
138
+ id: notification.id,
139
+ event: notification.event,
140
+ severity: notification.severity,
141
+ title: notification.title,
142
+ text: notification.text,
143
+ occurredAt: new Date(notification.occurredAt).toISOString(),
144
+ monitor: notification.monitor,
145
+ state: notification.state,
146
+ previousState: notification.previousState,
147
+ links: notification.links,
148
+ locale: notification.locale
149
+ };
150
+ }
151
+ var encoder = new TextEncoder();
152
+ function hex(bytes) {
153
+ return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
154
+ }
155
+ function hmacKey(secret, usage) {
156
+ return crypto.subtle.importKey("raw", encoder.encode(secret), {
157
+ name: "HMAC",
158
+ hash: "SHA-256"
159
+ }, false, [usage]);
160
+ }
161
+ /** The `X-CF-Workers-Status-Page-Signature` value for `body` sent at `timestamp` (Unix seconds). */
162
+ async function sign(secret, timestamp, body) {
163
+ return `${SIGNATURE_VERSION}=${hex(await crypto.subtle.sign("HMAC", await hmacKey(secret, "sign"), encoder.encode(`${timestamp}.${body}`)))}`;
164
+ }
165
+ /**
166
+ * For receivers: whether `signature` is valid for `body` and `timestamp`, and the timestamp
167
+ * is within `toleranceSeconds` of `now`. Compares in constant time (`crypto.subtle.verify`).
168
+ */
169
+ async function verifySignature(secret, request, now = Date.now(), toleranceSeconds = 300) {
170
+ const timestamp = Number(request.timestamp);
171
+ if (!Number.isInteger(timestamp) || Math.abs(now / 1e3 - timestamp) > toleranceSeconds) return false;
172
+ const prefix = `${SIGNATURE_VERSION}=`;
173
+ if (!request.signature.startsWith(prefix)) return false;
174
+ const digits = request.signature.slice(prefix.length);
175
+ if (!/^[0-9a-f]{64}$/.test(digits)) return false;
176
+ const mac = new Uint8Array(digits.match(/../g)?.map((pair) => Number.parseInt(pair, 16)) ?? []);
177
+ return crypto.subtle.verify("HMAC", await hmacKey(secret, "verify"), mac, encoder.encode(`${timestamp}.${request.body}`));
178
+ }
179
+ var kind = defineNotifier({
180
+ type: "webhook",
181
+ name: "Webhook",
182
+ options: webhookOptions,
183
+ secretOptions: [
184
+ "url",
185
+ "signingSecret",
186
+ "headers"
187
+ ],
188
+ messages,
189
+ async send(notification, options, ctx) {
190
+ const body = JSON.stringify(webhookPayload(notification));
191
+ const headers = new Headers(options.headers ?? {});
192
+ headers.set("Content-Type", "application/json");
193
+ headers.set(ID_HEADER, notification.id);
194
+ if (options.signingSecret !== void 0) {
195
+ const timestamp = Math.floor(Date.now() / 1e3);
196
+ headers.set(TIMESTAMP_HEADER, String(timestamp));
197
+ headers.set(SIGNATURE_HEADER, await sign(options.signingSecret, timestamp, body));
198
+ }
199
+ const response = await ctx.fetch(options.url, {
200
+ method: "POST",
201
+ headers,
202
+ body,
203
+ redirect: "manual",
204
+ signal: ctx.signal
205
+ });
206
+ await expectSuccess(response, "The webhook");
207
+ }
208
+ });
209
+ /** The generic webhook notifier kind, for `notifiers` in status.config.ts. */
210
+ function webhook() {
211
+ return kind;
212
+ }
213
+ export { ID_HEADER, SIGNATURE_HEADER, TIMESTAMP_HEADER, messages, sign, verifySignature, webhook, webhookOptions, webhookPayload };
214
+
215
+ //# sourceMappingURL=notifier-webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifier-webhook.js","names":[],"sources":["../../notifier-webhook/src/messages.ts","../../notifier-webhook/src/index.ts"],"sourcesContent":["import type { NotifierMessages } from \"@naosystem/cf-workers-status-page-core\";\n\n/** Texts of the admin UI's form for webhook targets (English is also the schema's `title`/`description`). */\nexport const messages = {\n\ten: {\n\t\t$kind: \"Webhook\",\n\t\t\"url.title\": \"URL\",\n\t\t\"url.description\": \"Where to POST each notification as JSON (https).\",\n\t\t\"signingSecret.title\": \"Signing secret\",\n\t\t\"signingSecret.description\":\n\t\t\t\"At least 16 characters. Each request is then signed (X-CF-Workers-Status-Page-Signature), so that the receiver can check that it comes from here.\",\n\t\t\"headers.title\": \"Headers\",\n\t\t\"headers.description\": \"Extra request headers, such as Authorization.\",\n\t},\n\tja: {\n\t\t$kind: \"Webhook\",\n\t\t\"url.title\": \"URL\",\n\t\t\"url.description\": \"通知を JSON で POST する送り先(https)。\",\n\t\t\"signingSecret.title\": \"署名用のシークレット\",\n\t\t\"signingSecret.description\": \"16文字以上。各リクエストに署名(X-CF-Workers-Status-Page-Signature)を付け、受信側で送信元を確かめられるようにします。\",\n\t\t\"headers.title\": \"ヘッダー\",\n\t\t\"headers.description\": \"Authorization など、追加するリクエストヘッダー。\",\n\t},\n} as const satisfies NotifierMessages;\n","/**\n * Notifications as JSON POSTed to any URL, optionally signed.\n *\n * ## Request\n *\n * `POST <url>` (https only) with `Content-Type: application/json` and the body {@link WebhookPayload}:\n *\n * ```json\n * {\n * \"type\": \"cf-workers-status-page.notification\",\n * \"version\": 1,\n * \"id\": \"api:4102444800000\",\n * \"event\": \"down\",\n * \"severity\": \"critical\",\n * \"title\": \"API is down\",\n * \"text\": \"API has been down since Jan 1, 2100, 12:00:00 AM UTC.\\nLast check: HTTP 503\",\n * \"occurredAt\": \"2100-01-01T00:00:00.000Z\",\n * \"monitor\": { \"id\": \"api\", \"name\": \"API\" },\n * \"state\": \"down\",\n * \"previousState\": \"up\",\n * \"links\": [{ \"label\": \"Create an incident\", \"url\": \"https://status.example.com/admin/…\" }],\n * \"locale\": \"en\"\n * }\n * ```\n *\n * `event` is `down`, `recovered`, `degraded`, `degraded_recovered`, `unknown` or `test`. `id`\n * is the same for every retry and duplicate delivery of a notification: deliveries are at\n * least once, so drop an `id` you have already handled. Deliveries may also arrive out of\n * order; `occurredAt` says when it happened. Fields may be added in later versions of the\n * same `version`.\n *\n * The receiver must answer 2xx within the hub's timeout. 408, 429 (with `Retry-After`) and 5xx\n * are retried with backoff; other answers, including redirects (they are not followed), are\n * recorded as failed at once.\n *\n * ## Signature\n *\n * With `signingSecret`, every request also has\n *\n * - `X-CF-Workers-Status-Page-Timestamp`: the time of sending, in Unix seconds;\n * - `X-CF-Workers-Status-Page-Signature`: `v1=` and the hex HMAC-SHA256 of\n * `<timestamp>.<raw body>` with the secret as the key.\n *\n * To verify, compute the same HMAC over the raw body as received, compare it in constant time\n * ({@link verifySignature} does this), and reject timestamps older than a few minutes, so that\n * a captured request cannot be replayed later. Each retry is signed afresh.\n *\n * `url`, `signingSecret` and `headers` (for example `Authorization` for the receiver) are\n * secret options: encrypted at rest and never shown again. `url` must name a public host (no IP\n * address or internal name). `signingSecret` and `headers` are bound to the origin of `url`:\n * moving the target to another origin requires entering them again (or clearing them).\n */\nimport {\n\tdefineNotifier,\n\texpectSuccess,\n\tisPublicHostname,\n\ttype Notification,\n} from \"@naosystem/cf-workers-status-page-core\";\nimport * as z from \"zod\";\nimport { messages } from \"./messages\";\n\nexport { messages };\n\nexport const TIMESTAMP_HEADER = \"X-CF-Workers-Status-Page-Timestamp\";\nexport const SIGNATURE_HEADER = \"X-CF-Workers-Status-Page-Signature\";\n/** The notification's `id`, also as a header, for receivers that deduplicate before parsing. */\nexport const ID_HEADER = \"X-CF-Workers-Status-Page-Notification-Id\";\nconst SIGNATURE_VERSION = \"v1\";\n\n/** Headers the hub sets itself, which `headers` cannot override. */\nconst RESERVED_HEADERS: ReadonlySet<string> = new Set(\n\t[\"content-type\", \"content-length\", \"host\", TIMESTAMP_HEADER, SIGNATURE_HEADER, ID_HEADER].map((name) =>\n\t\tname.toLowerCase(),\n\t),\n);\n\nfunction isHeaderName(name: string): boolean {\n\ttry {\n\t\tnew Headers([[name, \"x\"]]);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport const webhookOptions = z.strictObject({\n\t/** Where to POST: https only, since the body and headers may matter. Secret, since URLs often carry a token. */\n\turl: z\n\t\t.url({ protocol: /^https$/, error: \"must be an https URL\" })\n\t\t.refine((value) => {\n\t\t\tconst url = new URL(value);\n\t\t\treturn url.username === \"\" && url.password === \"\";\n\t\t}, \"must not contain credentials; send them in headers\")\n\t\t.refine(\n\t\t\t(value) => isPublicHostname(new URL(value).hostname),\n\t\t\t\"must name a public host: IP addresses and internal names such as localhost or *.internal are not allowed\",\n\t\t)\n\t\t.meta({ title: messages.en[\"url.title\"], description: messages.en[\"url.description\"] }),\n\t/** Signs every request (see the module documentation). At least 16 characters; 32 random bytes are best. Secret. */\n\tsigningSecret: z\n\t\t.string()\n\t\t.min(16, \"must be at least 16 characters\")\n\t\t.max(256)\n\t\t.meta({ title: messages.en[\"signingSecret.title\"], description: messages.en[\"signingSecret.description\"] })\n\t\t.optional(),\n\t/** Extra request headers, such as `Authorization`. Secret. */\n\theaders: z\n\t\t.record(z.string(), z.string().max(4_096).refine((value) => !/[\\r\\n\\0]/.test(value), \"must not contain line breaks\"))\n\t\t.superRefine((headers, ctx) => {\n\t\t\tfor (const name of Object.keys(headers)) {\n\t\t\t\tif (!isHeaderName(name)) ctx.addIssue({ code: \"custom\", message: `\"${name}\" is not a header name`, path: [name] });\n\t\t\t\telse if (RESERVED_HEADERS.has(name.toLowerCase())) {\n\t\t\t\t\tctx.addIssue({ code: \"custom\", message: `\"${name}\" is set by the hub`, path: [name] });\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.meta({ title: messages.en[\"headers.title\"], description: messages.en[\"headers.description\"] })\n\t\t.optional(),\n});\nexport type WebhookOptions = z.infer<typeof webhookOptions>;\n\n/** The JSON body of every request (see the module documentation). */\nexport interface WebhookPayload {\n\treadonly type: \"cf-workers-status-page.notification\";\n\treadonly version: 1;\n\treadonly id: string;\n\treadonly event: Notification[\"event\"];\n\treadonly severity: Notification[\"severity\"];\n\treadonly title: string;\n\treadonly text: string;\n\t/** ISO 8601, UTC. */\n\treadonly occurredAt: string;\n\treadonly monitor: Notification[\"monitor\"];\n\treadonly state: Notification[\"state\"];\n\treadonly previousState: Notification[\"previousState\"];\n\treadonly links: Notification[\"links\"];\n\treadonly locale: string;\n}\n\nexport function webhookPayload(notification: Notification): WebhookPayload {\n\treturn {\n\t\ttype: \"cf-workers-status-page.notification\",\n\t\tversion: 1,\n\t\tid: notification.id,\n\t\tevent: notification.event,\n\t\tseverity: notification.severity,\n\t\ttitle: notification.title,\n\t\ttext: notification.text,\n\t\toccurredAt: new Date(notification.occurredAt).toISOString(),\n\t\tmonitor: notification.monitor,\n\t\tstate: notification.state,\n\t\tpreviousState: notification.previousState,\n\t\tlinks: notification.links,\n\t\tlocale: notification.locale,\n\t};\n}\n\nconst encoder = new TextEncoder();\n\nfunction hex(bytes: ArrayBuffer): string {\n\treturn [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nfunction hmacKey(secret: string, usage: \"sign\" | \"verify\"): Promise<CryptoKey> {\n\treturn crypto.subtle.importKey(\"raw\", encoder.encode(secret), { name: \"HMAC\", hash: \"SHA-256\" }, false, [usage]);\n}\n\n/** The `X-CF-Workers-Status-Page-Signature` value for `body` sent at `timestamp` (Unix seconds). */\nexport async function sign(secret: string, timestamp: number, body: string): Promise<string> {\n\tconst mac = await crypto.subtle.sign(\"HMAC\", await hmacKey(secret, \"sign\"), encoder.encode(`${timestamp}.${body}`));\n\treturn `${SIGNATURE_VERSION}=${hex(mac)}`;\n}\n\n/**\n * For receivers: whether `signature` is valid for `body` and `timestamp`, and the timestamp\n * is within `toleranceSeconds` of `now`. Compares in constant time (`crypto.subtle.verify`).\n */\nexport async function verifySignature(\n\tsecret: string,\n\trequest: { readonly timestamp: string; readonly signature: string; readonly body: string },\n\tnow = Date.now(),\n\ttoleranceSeconds = 300,\n): Promise<boolean> {\n\tconst timestamp = Number(request.timestamp);\n\tif (!Number.isInteger(timestamp) || Math.abs(now / 1_000 - timestamp) > toleranceSeconds) return false;\n\tconst prefix = `${SIGNATURE_VERSION}=`;\n\tif (!request.signature.startsWith(prefix)) return false;\n\tconst digits = request.signature.slice(prefix.length);\n\tif (!/^[0-9a-f]{64}$/.test(digits)) return false;\n\tconst mac = new Uint8Array(digits.match(/../g)?.map((pair) => Number.parseInt(pair, 16)) ?? []);\n\treturn crypto.subtle.verify(\"HMAC\", await hmacKey(secret, \"verify\"), mac, encoder.encode(`${timestamp}.${request.body}`));\n}\n\nconst kind = defineNotifier({\n\ttype: \"webhook\",\n\tname: \"Webhook\",\n\toptions: webhookOptions,\n\tsecretOptions: [\"url\", \"signingSecret\", \"headers\"],\n\tmessages,\n\tasync send(notification, options, ctx) {\n\t\tconst body = JSON.stringify(webhookPayload(notification));\n\t\tconst headers = new Headers(options.headers ?? {});\n\t\theaders.set(\"Content-Type\", \"application/json\");\n\t\theaders.set(ID_HEADER, notification.id);\n\t\tif (options.signingSecret !== undefined) {\n\t\t\tconst timestamp = Math.floor(Date.now() / 1_000);\n\t\t\theaders.set(TIMESTAMP_HEADER, String(timestamp));\n\t\t\theaders.set(SIGNATURE_HEADER, await sign(options.signingSecret, timestamp, body));\n\t\t}\n\t\tconst response = await ctx.fetch(options.url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders,\n\t\t\tbody,\n\t\t\tredirect: \"manual\",\n\t\t\tsignal: ctx.signal,\n\t\t});\n\t\tawait expectSuccess(response, \"The webhook\");\n\t},\n});\n\n/** The generic webhook notifier kind, for `notifiers` in status.config.ts. */\nexport function webhook() {\n\treturn kind;\n}\n"],"mappings":";;;;AAGA,IAAa,WAAW;CACvB,IAAI;EACH,OAAO;EACP,aAAa;EACb,mBAAmB;EACnB,uBAAuB;EACvB,6BACC;EACD,iBAAiB;EACjB,uBAAuB;CACxB;CACA,IAAI;EACH,OAAO;EACP,aAAa;EACb,mBAAmB;EACnB,uBAAuB;EACvB,6BAA6B;EAC7B,iBAAiB;EACjB,uBAAuB;CACxB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACwCA,IAAa,mBAAmB;AAChC,IAAa,mBAAmB;;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D,CAAC;;AAGD,SAAgB,UAAU;CACzB,OAAO;AACR"}
@@ -0,0 +1,177 @@
1
+ import { i as defineProvider } from "./chunks/monitor-B2u42off.js";
2
+ import { d as secretOr, i as withheldRedirect, o as isSecretRef } from "./chunks/run-check-bbo3LqI7.js";
3
+ import * as z from "zod";
4
+ // ../provider-http/src/index.ts
5
+ /**
6
+ * Built-in HTTP check.
7
+ *
8
+ * Sends one request through the runner's `ctx.fetch` and reports `up` when the response
9
+ * status is expected, `down` otherwise (including network errors). The monitor's `timeout`
10
+ * setting bounds the request; `runCheck` reports a timeout as `down`. It never reports
11
+ * `degraded`: a latency threshold for that is still undecided.
12
+ *
13
+ * Options and defaults:
14
+ * - `url` (required): http or https URL, without credentials (`https://user:pass@…` is rejected).
15
+ * - `method`: `"GET"`.
16
+ * - `headers`: none. A value may be `secret("NAME")`, which the runner fills in at check time.
17
+ * `Authorization`, `Proxy-Authorization` and `Cookie` must use `secret()`: literal values are
18
+ * rejected because `status.config.ts` is deployed with the Worker and may be public.
19
+ * With any `secret()` header, `url` must be https, and redirects are followed only within its
20
+ * origin over https: a redirect elsewhere is not followed and is judged as the response (its
21
+ * status against `expectedStatus`), so that the secret never reaches another host.
22
+ * - `body`: none. Not allowed with GET or HEAD.
23
+ * - `expectedStatus`: `"2xx"`. Exact codes (`204`), classes (`"3xx"`) or a list of them.
24
+ * - `followRedirects`: `true`. When `false`, a redirect response is judged as is.
25
+ *
26
+ * `latencyMs` is the time until the response headers arrive, including any redirects
27
+ * followed. The response body is not read.
28
+ */
29
+ var statusMatcher = z.union([z.int().min(100).max(599), z.enum([
30
+ "1xx",
31
+ "2xx",
32
+ "3xx",
33
+ "4xx",
34
+ "5xx"
35
+ ])]);
36
+ /** Headers whose values are credentials: only `secret()` references are accepted for them. */
37
+ var CREDENTIAL_HEADERS = /* @__PURE__ */ new Set([
38
+ "authorization",
39
+ "proxy-authorization",
40
+ "cookie"
41
+ ]);
42
+ var httpOptions = z.strictObject({
43
+ url: z.url({
44
+ protocol: /^https?$/,
45
+ error: "must be an http or https URL"
46
+ }),
47
+ method: z.enum([
48
+ "GET",
49
+ "HEAD",
50
+ "POST",
51
+ "PUT",
52
+ "PATCH",
53
+ "DELETE",
54
+ "OPTIONS"
55
+ ]).default("GET"),
56
+ headers: z.record(z.string(), secretOr(z.string())).default({}),
57
+ body: z.string().optional(),
58
+ expectedStatus: z.union([statusMatcher, z.array(statusMatcher).min(1)]).transform((value) => Array.isArray(value) ? value : [value]).prefault("2xx"),
59
+ followRedirects: z.boolean().default(true)
60
+ }).superRefine((options, ctx) => {
61
+ const url = new URL(options.url);
62
+ if (url.protocol !== "https:" && Object.values(options.headers).some(isSecretRef)) ctx.addIssue({
63
+ code: "custom",
64
+ path: ["url"],
65
+ message: "must be https when a header uses secret(): secrets are never sent over plain http",
66
+ input: void 0
67
+ });
68
+ if (url.username !== "" || url.password !== "") ctx.addIssue({
69
+ code: "custom",
70
+ path: ["url"],
71
+ message: "must not contain credentials; send them in a header with secret(\"NAME\")",
72
+ input: void 0
73
+ });
74
+ if (options.body !== void 0 && (options.method === "GET" || options.method === "HEAD")) ctx.addIssue({
75
+ code: "custom",
76
+ path: ["body"],
77
+ message: `a ${options.method} request cannot have a body`,
78
+ input: void 0
79
+ });
80
+ for (const [name, value] of Object.entries(options.headers)) {
81
+ if (isSecretRef(value)) {
82
+ try {
83
+ new Headers([[name, "x"]]);
84
+ } catch {
85
+ ctx.addIssue({
86
+ code: "custom",
87
+ path: ["headers", name],
88
+ message: "is not a valid HTTP header name",
89
+ input: void 0
90
+ });
91
+ }
92
+ continue;
93
+ }
94
+ if (CREDENTIAL_HEADERS.has(name.toLowerCase())) {
95
+ ctx.addIssue({
96
+ code: "custom",
97
+ path: ["headers", name],
98
+ message: "must be secret(\"NAME\"), not a literal value: status.config.ts may be public",
99
+ input: void 0
100
+ });
101
+ continue;
102
+ }
103
+ try {
104
+ new Headers([[name, value]]);
105
+ } catch {
106
+ ctx.addIssue({
107
+ code: "custom",
108
+ path: ["headers", name],
109
+ message: "is not a valid HTTP header",
110
+ input: void 0
111
+ });
112
+ }
113
+ }
114
+ });
115
+ function matchesStatus(status, matcher) {
116
+ return typeof matcher === "number" ? status === matcher : Math.floor(status / 100) === Number(matcher[0]);
117
+ }
118
+ async function checkHttp(options, ctx) {
119
+ const started = performance.now();
120
+ let response;
121
+ try {
122
+ response = await ctx.fetch(options.url, {
123
+ method: options.method,
124
+ headers: options.headers,
125
+ body: options.body,
126
+ redirect: options.followRedirects ? "follow" : "manual",
127
+ signal: ctx.signal
128
+ });
129
+ } catch (error) {
130
+ if (ctx.signal.aborted) throw ctx.signal.reason;
131
+ return {
132
+ state: "down",
133
+ message: error instanceof Error ? error.message : String(error),
134
+ details: { error: "network" }
135
+ };
136
+ }
137
+ const latencyMs = Math.round(performance.now() - started);
138
+ response.body?.cancel().catch(() => {});
139
+ const { status } = response;
140
+ const up = options.expectedStatus.some((matcher) => matchesStatus(status, matcher));
141
+ const expectation = up ? "" : `, expected ${options.expectedStatus.join(" or ")}`;
142
+ const redirect = withheldRedirect(response);
143
+ if (redirect !== void 0) {
144
+ const where = new URL(redirect.location);
145
+ const why = redirect.reason === "cross-origin" ? `another origin (${where.origin}) must not receive this monitor's secret() headers` : redirect.reason === "insecure" ? `secret() headers are never sent over plain http (${where.origin})` : "the request body cannot be sent again";
146
+ return {
147
+ state: up ? "up" : "down",
148
+ latencyMs,
149
+ message: `HTTP ${status}${expectation}; redirect not followed: ${why}`,
150
+ details: {
151
+ status,
152
+ redirect: redirect.reason,
153
+ redirectOrigin: where.origin
154
+ }
155
+ };
156
+ }
157
+ return {
158
+ state: up ? "up" : "down",
159
+ latencyMs,
160
+ message: `HTTP ${status}${expectation}`,
161
+ details: { status }
162
+ };
163
+ }
164
+ /**
165
+ * Creates an HTTP monitor:
166
+ * `http({ id: "api", interval: "1m", url: "https://api.example.com/health" })`.
167
+ * The provider itself is `http.provider`.
168
+ */
169
+ var http = defineProvider({
170
+ type: "http",
171
+ options: httpOptions,
172
+ requires: ["fetch"],
173
+ check: checkHttp
174
+ });
175
+ export { http, httpOptions };
176
+
177
+ //# sourceMappingURL=provider-http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-http.js","names":[],"sources":["../../provider-http/src/index.ts"],"sourcesContent":["/**\n * Built-in HTTP check.\n *\n * Sends one request through the runner's `ctx.fetch` and reports `up` when the response\n * status is expected, `down` otherwise (including network errors). The monitor's `timeout`\n * setting bounds the request; `runCheck` reports a timeout as `down`. It never reports\n * `degraded`: a latency threshold for that is still undecided.\n *\n * Options and defaults:\n * - `url` (required): http or https URL, without credentials (`https://user:pass@…` is rejected).\n * - `method`: `\"GET\"`.\n * - `headers`: none. A value may be `secret(\"NAME\")`, which the runner fills in at check time.\n * `Authorization`, `Proxy-Authorization` and `Cookie` must use `secret()`: literal values are\n * rejected because `status.config.ts` is deployed with the Worker and may be public.\n * With any `secret()` header, `url` must be https, and redirects are followed only within its\n * origin over https: a redirect elsewhere is not followed and is judged as the response (its\n * status against `expectedStatus`), so that the secret never reaches another host.\n * - `body`: none. Not allowed with GET or HEAD.\n * - `expectedStatus`: `\"2xx\"`. Exact codes (`204`), classes (`\"3xx\"`) or a list of them.\n * - `followRedirects`: `true`. When `false`, a redirect response is judged as is.\n *\n * `latencyMs` is the time until the response headers arrive, including any redirects\n * followed. The response body is not read.\n */\nimport {\n\ttype CheckContext,\n\ttype CheckResult,\n\tdefineProvider,\n\tisSecretRef,\n\twithheldRedirect,\n\ttype SecretsResolved,\n\tsecretOr,\n} from \"@naosystem/cf-workers-status-page-core\";\nimport * as z from \"zod\";\n\nconst STATUS_CLASSES = [\"1xx\", \"2xx\", \"3xx\", \"4xx\", \"5xx\"] as const;\n\n/** An exact status code such as `204`, or a class such as `\"2xx\"`. */\nexport type StatusMatcher = number | (typeof STATUS_CLASSES)[number];\n\nconst statusMatcher = z.union([z.int().min(100).max(599), z.enum(STATUS_CLASSES)]);\n\n/** Headers whose values are credentials: only `secret()` references are accepted for them. */\nconst CREDENTIAL_HEADERS: ReadonlySet<string> = new Set([\n\t\"authorization\",\n\t\"proxy-authorization\",\n\t\"cookie\",\n]);\n\nexport const httpOptions = z\n\t.strictObject({\n\t\turl: z.url({ protocol: /^https?$/, error: \"must be an http or https URL\" }),\n\t\tmethod: z.enum([\"GET\", \"HEAD\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\", \"OPTIONS\"]).default(\"GET\"),\n\t\theaders: z.record(z.string(), secretOr(z.string())).default({}),\n\t\tbody: z.string().optional(),\n\t\texpectedStatus: z\n\t\t\t.union([statusMatcher, z.array(statusMatcher).min(1)])\n\t\t\t.transform((value): StatusMatcher[] => (Array.isArray(value) ? value : [value]))\n\t\t\t.prefault(\"2xx\"),\n\t\tfollowRedirects: z.boolean().default(true),\n\t})\n\t.superRefine((options, ctx) => {\n\t\t// Never include the URL itself in the message: it holds the credentials.\n\t\tconst url = new URL(options.url);\n\t\tif (url.protocol !== \"https:\" && Object.values(options.headers).some(isSecretRef)) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"url\"],\n\t\t\t\tmessage: 'must be https when a header uses secret(): secrets are never sent over plain http',\n\t\t\t\tinput: undefined,\n\t\t\t});\n\t\t}\n\t\tif (url.username !== \"\" || url.password !== \"\") {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"url\"],\n\t\t\t\tmessage: 'must not contain credentials; send them in a header with secret(\"NAME\")',\n\t\t\t\tinput: undefined,\n\t\t\t});\n\t\t}\n\t\tif (options.body !== undefined && (options.method === \"GET\" || options.method === \"HEAD\")) {\n\t\t\tctx.addIssue({\n\t\t\t\tcode: \"custom\",\n\t\t\t\tpath: [\"body\"],\n\t\t\t\tmessage: `a ${options.method} request cannot have a body`,\n\t\t\t\tinput: undefined,\n\t\t\t});\n\t\t}\n\t\tfor (const [name, value] of Object.entries(options.headers)) {\n\t\t\tif (isSecretRef(value)) {\n\t\t\t\ttry {\n\t\t\t\t\tnew Headers([[name, \"x\"]]);\n\t\t\t\t} catch {\n\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\t\tpath: [\"headers\", name],\n\t\t\t\t\t\tmessage: \"is not a valid HTTP header name\",\n\t\t\t\t\t\tinput: undefined,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (CREDENTIAL_HEADERS.has(name.toLowerCase())) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tpath: [\"headers\", name],\n\t\t\t\t\tmessage: 'must be secret(\"NAME\"), not a literal value: status.config.ts may be public',\n\t\t\t\t\tinput: undefined,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tnew Headers([[name, value]]);\n\t\t\t} catch {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tpath: [\"headers\", name],\n\t\t\t\t\tmessage: \"is not a valid HTTP header\",\n\t\t\t\t\tinput: undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n/** Options as passed to `check`: defaults applied and secrets resolved. */\nexport type HttpOptions = SecretsResolved<z.output<typeof httpOptions>>;\n/** Options as written in `status.config.ts`. */\nexport type HttpOptionsInput = z.input<typeof httpOptions>;\n\nfunction matchesStatus(status: number, matcher: StatusMatcher): boolean {\n\treturn typeof matcher === \"number\"\n\t\t? status === matcher\n\t\t: Math.floor(status / 100) === Number(matcher[0]);\n}\n\nasync function checkHttp(options: HttpOptions, ctx: CheckContext): Promise<CheckResult> {\n\tconst started = performance.now();\n\tlet response: Response;\n\ttry {\n\t\tresponse = await ctx.fetch(options.url, {\n\t\t\tmethod: options.method,\n\t\t\theaders: options.headers,\n\t\t\tbody: options.body,\n\t\t\tredirect: options.followRedirects ? \"follow\" : \"manual\",\n\t\t\tsignal: ctx.signal,\n\t\t});\n\t} catch (error) {\n\t\t// Timed out or cancelled by the runner: runCheck decides what to record.\n\t\tif (ctx.signal.aborted) throw ctx.signal.reason;\n\t\treturn {\n\t\t\tstate: \"down\",\n\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\tdetails: { error: \"network\" },\n\t\t};\n\t}\n\tconst latencyMs = Math.round(performance.now() - started);\n\t// Only the status matters. Release the body without downloading it.\n\tresponse.body?.cancel().catch(() => {});\n\n\tconst { status } = response;\n\tconst up = options.expectedStatus.some((matcher) => matchesStatus(status, matcher));\n\tconst expectation = up ? \"\" : `, expected ${options.expectedStatus.join(\" or \")}`;\n\tconst redirect = withheldRedirect(response);\n\tif (redirect !== undefined) {\n\t\t// Not followed because the request has secret() headers (see the module documentation).\n\t\tconst where = new URL(redirect.location);\n\t\tconst why =\n\t\t\tredirect.reason === \"cross-origin\"\n\t\t\t\t? `another origin (${where.origin}) must not receive this monitor's secret() headers`\n\t\t\t\t: redirect.reason === \"insecure\"\n\t\t\t\t\t? `secret() headers are never sent over plain http (${where.origin})`\n\t\t\t\t\t: \"the request body cannot be sent again\";\n\t\treturn {\n\t\t\tstate: up ? \"up\" : \"down\",\n\t\t\tlatencyMs,\n\t\t\tmessage: `HTTP ${status}${expectation}; redirect not followed: ${why}`,\n\t\t\tdetails: { status, redirect: redirect.reason, redirectOrigin: where.origin },\n\t\t};\n\t}\n\treturn {\n\t\tstate: up ? \"up\" : \"down\",\n\t\tlatencyMs,\n\t\tmessage: `HTTP ${status}${expectation}`,\n\t\tdetails: { status },\n\t};\n}\n\n/**\n * Creates an HTTP monitor:\n * `http({ id: \"api\", interval: \"1m\", url: \"https://api.example.com/health\" })`.\n * The provider itself is `http.provider`.\n */\nexport const http = defineProvider({\n\ttype: \"http\",\n\toptions: httpOptions,\n\trequires: [\"fetch\"],\n\tcheck: checkHttp,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,gBAAgB,EAAE,MAAM,CAAC,EAAE,IAAI,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