@oneuptime/common 12.0.12 → 12.0.14

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 (596) hide show
  1. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.ts +32 -5
  2. package/Models/DatabaseModels/NetworkDevice.ts +64 -0
  3. package/Models/DatabaseModels/OnCallDutyPolicySchedule.ts +14 -0
  4. package/Models/DatabaseModels/StatusPage.ts +59 -0
  5. package/Models/DatabaseModels/StatusPageOidc.ts +2 -0
  6. package/Models/DatabaseModels/UserCall.ts +94 -3
  7. package/Models/DatabaseModels/UserEmail.ts +94 -3
  8. package/Models/DatabaseModels/UserIncomingCallNumber.ts +94 -3
  9. package/Models/DatabaseModels/UserPush.ts +37 -0
  10. package/Models/DatabaseModels/UserSMS.ts +94 -3
  11. package/Models/DatabaseModels/UserWhatsApp.ts +93 -2
  12. package/Models/DatabaseModels/WorkspaceProjectAuthToken.ts +19 -2
  13. package/Server/API/AIChatAPI.ts +55 -56
  14. package/Server/API/BaseAPI.ts +79 -14
  15. package/Server/API/CommonAPI.ts +89 -0
  16. package/Server/API/MicrosoftTeamsAPI.ts +20 -9
  17. package/Server/API/SlackAPI.ts +13 -10
  18. package/Server/API/StatusPageAPI.ts +2197 -2128
  19. package/Server/API/TelemetryAPI.ts +72 -3
  20. package/Server/API/UserCallAPI.ts +53 -45
  21. package/Server/API/UserEmailAPI.ts +53 -44
  22. package/Server/API/UserIncomingCallNumberAPI.ts +48 -38
  23. package/Server/API/UserNotificationMethodAdminAPI.ts +481 -0
  24. package/Server/API/UserPushAPI.ts +126 -2
  25. package/Server/API/UserSmsAPI.ts +53 -44
  26. package/Server/API/UserWhatsAppAPI.ts +53 -50
  27. package/Server/Infrastructure/Postgres/SchemaMigrations/1787142779538-MigrationName.ts +154 -0
  28. package/Server/Infrastructure/Postgres/SchemaMigrations/1787156982416-MigrationName.ts +17 -0
  29. package/Server/Infrastructure/Postgres/SchemaMigrations/1787500000000-AddEnableSearchEngineIndexingToStatusPage.ts +30 -0
  30. package/Server/Infrastructure/Postgres/SchemaMigrations/1787600000000-AddNetworkDeviceReachabilityColumns.ts +47 -0
  31. package/Server/Infrastructure/Postgres/SchemaMigrations/1787700000000-FixTotpOtpUrlAlgorithm.ts +45 -0
  32. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +10 -0
  33. package/Server/Middleware/UserAuthorization.ts +11 -2
  34. package/Server/Middleware/VerificationCodeRateLimit.ts +586 -0
  35. package/Server/Services/AnalyticsDatabaseService.ts +169 -0
  36. package/Server/Services/ApiKeyPermissionService.ts +116 -2
  37. package/Server/Services/DatabaseService.ts +118 -6
  38. package/Server/Services/LogAggregationService.ts +39 -0
  39. package/Server/Services/LogService.ts +21 -0
  40. package/Server/Services/NetworkSiteService.ts +12 -0
  41. package/Server/Services/PushNotificationService.ts +127 -12
  42. package/Server/Services/SpanService.ts +21 -0
  43. package/Server/Services/TeamMemberService.ts +53 -13
  44. package/Server/Services/TraceAggregationService.ts +15 -0
  45. package/Server/Services/UserCallService.ts +55 -24
  46. package/Server/Services/UserEmailService.ts +83 -17
  47. package/Server/Services/UserIncomingCallNumberService.ts +49 -85
  48. package/Server/Services/UserNotificationMethodAdminService.ts +1527 -0
  49. package/Server/Services/UserNotificationRuleService.ts +26 -0
  50. package/Server/Services/UserPushService.ts +89 -0
  51. package/Server/Services/UserSmsService.ts +50 -17
  52. package/Server/Services/UserWhatsAppService.ts +48 -15
  53. package/Server/Services/WorkspaceNotificationRuleService.ts +172 -220
  54. package/Server/Types/AnalyticsDatabase/ModelPermission.ts +9 -0
  55. package/Server/Types/Database/Permissions/AccessControlPermission.ts +47 -16
  56. package/Server/Types/Database/QueryHelper.ts +30 -0
  57. package/Server/Utils/APIKey/AccessPermission.ts +16 -40
  58. package/Server/Utils/AnalyticsDatabase/QuerySettingsHelper.ts +59 -0
  59. package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +144 -0
  60. package/Server/Utils/ChannelVerification.ts +510 -0
  61. package/Server/Utils/LogRedaction.ts +576 -0
  62. package/Server/Utils/Logger.ts +123 -46
  63. package/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.ts +13 -16
  64. package/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.ts +94 -23
  65. package/Server/Utils/Monitor/MonitorAlert.ts +24 -21
  66. package/Server/Utils/Monitor/MonitorIncident.ts +21 -18
  67. package/Server/Utils/Monitor/MonitorResource.ts +29 -9
  68. package/Server/Utils/Monitor/MonitorResourceContext.ts +107 -0
  69. package/Server/Utils/Monitor/MonitorStepResourceIdentity.ts +442 -0
  70. package/Server/Utils/Monitor/NetworkInventoryUtil.ts +28 -7
  71. package/Server/Utils/Monitor/SeriesResourceLabels.ts +3 -3
  72. package/Server/Utils/Monitor/SeriesResourceLinker.ts +96 -28
  73. package/Server/Utils/SessionReplay/SessionReplayGateCacheStore.ts +56 -10
  74. package/Server/Utils/StartServer.ts +30 -9
  75. package/Server/Utils/StatusPageSearchEngineIndexing.ts +33 -0
  76. package/Server/Utils/Telemetry/ResourceEntityFilter.ts +441 -0
  77. package/Server/Utils/TotpAuth.ts +137 -9
  78. package/Server/Utils/UserRegistrationToken.ts +182 -0
  79. package/Server/Utils/VerificationCode.ts +134 -0
  80. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +488 -46
  81. package/Tests/App/Dashboard/AdminNotificationRulesPage.test.tsx +173 -94
  82. package/Tests/App/Dashboard/AdminUserNotificationMethodsPage.test.tsx +1151 -0
  83. package/Tests/App/Dashboard/AdminUserOnCallPages.test.tsx +905 -0
  84. package/Tests/App/Dashboard/DashboardCommandPalette.test.tsx +338 -0
  85. package/Tests/App/Dashboard/InvestigationPanel.test.tsx +1 -1
  86. package/Tests/App/Dashboard/MonitorTypePicker.test.tsx +328 -0
  87. package/Tests/App/StatusPage/StatusPageIndexPageRobotsMeta.test.ts +130 -0
  88. package/Tests/Models/DatabaseModels/DatabaseBaseModelToJSONObjectCache.test.ts +180 -0
  89. package/Tests/Models/StatusPageEnableSearchEngineIndexing.test.ts +157 -0
  90. package/Tests/Models/UserPushCriticalAlertColumn.test.ts +172 -0
  91. package/Tests/Server/API/AIChatCancelAndFeedback.test.ts +23 -1
  92. package/Tests/Server/API/AIChatRouteAuthorization.test.ts +785 -0
  93. package/Tests/Server/API/BaseAPIApiKeyAuth.test.ts +21 -8
  94. package/Tests/Server/API/BaseAPIGetListParallel.test.ts +519 -0
  95. package/Tests/Server/API/CommonAPIAuthGuard.test.ts +290 -0
  96. package/Tests/Server/API/MicrosoftTeamsManifest.test.ts +7 -1
  97. package/Tests/Server/API/NotificationChannelVerificationAPI.test.ts +543 -0
  98. package/Tests/Server/API/StatusPageOverviewCache.test.ts +474 -0
  99. package/Tests/Server/API/StatusPageSeoSearchEngineIndexing.test.ts +189 -0
  100. package/Tests/Server/API/UserIncomingCallNumberApi.test.ts +108 -18
  101. package/Tests/Server/API/UserNotificationMethodAdminAPI.test.ts +963 -0
  102. package/Tests/Server/API/UserPushCriticalAlertsApi.test.ts +114 -0
  103. package/Tests/Server/API/UserSmsApi.test.ts +107 -14
  104. package/Tests/Server/API/UserTotpAuthAPI.test.ts +427 -0
  105. package/Tests/Server/Infrastructure/InMemoryTTLCache.test.ts +158 -0
  106. package/Tests/Server/Infrastructure/Postgres/DeviceRoleAndDeclaredLinkParentMigration.test.ts +9 -60
  107. package/Tests/Server/Infrastructure/Postgres/FixTotpOtpUrlAlgorithmMigration.test.ts +315 -0
  108. package/Tests/Server/Middleware/ProjectAuthorizationApiKeyMiddleware.test.ts +24 -15
  109. package/Tests/Server/Middleware/UserAuthorization.test.ts +79 -0
  110. package/Tests/Server/Middleware/VerificationCodeRateLimit.test.ts +775 -0
  111. package/Tests/Server/Services/AddNetworkDeviceReachabilityColumnsMigration.test.ts +280 -0
  112. package/Tests/Server/Services/AnalyticsDatabasePaginationStability.test.ts +33 -13
  113. package/Tests/Server/Services/AnalyticsDatabaseSortKeyBoundary.test.ts +658 -0
  114. package/Tests/Server/Services/ApiKeyPermissionService.test.ts +347 -0
  115. package/Tests/Server/Services/CriticalOnCallAlertDelivery.test.ts +458 -0
  116. package/Tests/Server/Services/CriticalPushAlertPayload.test.ts +301 -0
  117. package/Tests/Server/Services/DatabaseServiceAtomicIncrement.test.ts +143 -0
  118. package/Tests/Server/Services/DatabaseServiceUpdateDebugLogging.test.ts +282 -0
  119. package/Tests/Server/Services/DeliverNotificationForRuleExtraction.test.ts +1 -0
  120. package/Tests/Server/Services/LogAggregationScanMemory.test.ts +421 -0
  121. package/Tests/Server/Services/LogAggregationService.test.ts +2 -2
  122. package/Tests/Server/Services/NetworkSiteService.test.ts +56 -2
  123. package/Tests/Server/Services/NotificationChannelCodeIssuance.test.ts +401 -0
  124. package/Tests/Server/Services/PushNotificationDeliveryOptions.test.ts +204 -0
  125. package/Tests/Server/Services/TeamMemberAutoAcceptInvitation.test.ts +21 -1
  126. package/Tests/Server/Services/TeamMemberInviteRegistrationToken.test.ts +290 -0
  127. package/Tests/Server/Services/TelemetryResourceFacetFilters.test.ts +267 -0
  128. package/Tests/Server/Services/UserNotificationMethodAdminService.test.ts +948 -0
  129. package/Tests/Server/Services/UserNotificationRuleExecuteItem.test.ts +1 -0
  130. package/Tests/Server/Services/UserPushCriticalAlertToggle.test.ts +255 -0
  131. package/Tests/Server/Services/UserTotpAuthEnrolment.test.ts +218 -0
  132. package/Tests/Server/Services/WorkspaceNotificationRuleTestRuleChannels.test.ts +702 -0
  133. package/Tests/Server/TestingUtils/AuthenticatorApp.ts +248 -0
  134. package/Tests/Server/Types/Database/Permissions/AccessControlPermission.test.ts +165 -0
  135. package/Tests/Server/Types/Database/Permissions/NotificationChannelVerificationColumns.test.ts +135 -0
  136. package/Tests/Server/Types/Database/Permissions/OnCallScheduleRelationSelect.test.ts +504 -0
  137. package/Tests/Server/Types/Database/QueryHelperFindWithSameTextAnyOf.test.ts +91 -0
  138. package/Tests/Server/Types/Workflow/Components/JsonToText.test.ts +384 -0
  139. package/Tests/Server/Types/Workflow/Components/MergeJson.test.ts +403 -0
  140. package/Tests/Server/Utils/APIKey/AccessPermission.test.ts +48 -36
  141. package/Tests/Server/Utils/AnalyticsDatabase/StatementGenerator.test.ts +213 -0
  142. package/Tests/Server/Utils/Browser.test.ts +162 -0
  143. package/Tests/Server/Utils/ChannelVerification.test.ts +689 -0
  144. package/Tests/Server/Utils/Express.test.ts +371 -0
  145. package/Tests/Server/Utils/LogRedaction.test.ts +415 -0
  146. package/Tests/Server/Utils/LoggerCredentialLeak.test.ts +245 -0
  147. package/Tests/Server/Utils/Monitor/Criteria/CustomCodeMonitorCriteria.test.ts +707 -0
  148. package/Tests/Server/Utils/Monitor/Criteria/DnsMonitorCriteria.test.ts +698 -0
  149. package/Tests/Server/Utils/Monitor/Criteria/IncomingEmailBodyCriteria.test.ts +243 -0
  150. package/Tests/Server/Utils/Monitor/Criteria/IncomingRequestBodyCriteria.test.ts +278 -0
  151. package/Tests/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.test.ts +374 -4
  152. package/Tests/Server/Utils/Monitor/MonitorAlertResourceLinking.test.ts +160 -20
  153. package/Tests/Server/Utils/Monitor/MonitorDependencySuppressionCreatorSkip.test.ts +13 -8
  154. package/Tests/Server/Utils/Monitor/MonitorIncidentResourceLinking.test.ts +162 -18
  155. package/Tests/Server/Utils/Monitor/MonitorResourceContext.test.ts +349 -0
  156. package/Tests/Server/Utils/Monitor/MonitorResourceIngestedStepSelection.test.ts +455 -0
  157. package/Tests/Server/Utils/Monitor/MonitorStepResourceIdentity.test.ts +690 -0
  158. package/Tests/Server/Utils/Monitor/MonitorSummaryPersistence.test.ts +7 -2
  159. package/Tests/Server/Utils/Monitor/NetworkDeviceReachabilityRoundTrip.test.ts +369 -0
  160. package/Tests/Server/Utils/Monitor/NetworkInventoryUtil.test.ts +86 -8
  161. package/Tests/Server/Utils/Monitor/SeriesResourceLinker.test.ts +92 -18
  162. package/Tests/Server/Utils/PrivacyFilterUtil.test.ts +64 -0
  163. package/Tests/Server/Utils/PushNotificationUtilCreators.test.ts +267 -0
  164. package/Tests/Server/Utils/SessionReplay/SessionReplayGateCacheStore.test.ts +207 -0
  165. package/Tests/Server/Utils/StartServerBodyVerify.test.ts +335 -0
  166. package/Tests/Server/Utils/StatusPageSearchEngineIndexing.test.ts +60 -0
  167. package/Tests/Server/Utils/Telemetry/OneuptimeLabel.test.ts +439 -0
  168. package/Tests/Server/Utils/Telemetry/ResourceEntityFilter.test.ts +435 -0
  169. package/Tests/Server/Utils/TotpAuth.test.ts +719 -0
  170. package/Tests/Server/Utils/UserRegistrationToken.test.ts +322 -0
  171. package/Tests/Server/Utils/VerificationCode.test.ts +296 -0
  172. package/Tests/Server/Utils/Workspace/MicrosoftTeamsChannelSend.test.ts +607 -62
  173. package/Tests/Server/Utils/Workspace/MicrosoftTeamsInstalledTeamIdSpace.test.ts +778 -0
  174. package/Tests/Server/Utils/Workspace/MicrosoftTeamsTeamInstalls.test.ts +44 -10
  175. package/Tests/Types/API/HostnameFromAuthority.test.ts +164 -0
  176. package/Tests/Types/AutoRemediation/AutoRemediationSuggestionStatus.test.ts +192 -0
  177. package/Tests/Types/Call/CallRequest.test.ts +189 -0
  178. package/Tests/Types/Dashboard/DashboardSize.test.ts +226 -0
  179. package/Tests/Types/Database/AccessControl/ColumnAccessControlCache.test.ts +344 -0
  180. package/Tests/Types/Database/DatabasePropertyFindOperator.test.ts +518 -0
  181. package/Tests/Types/Database/TableColumnMetadataCache.test.ts +286 -0
  182. package/Tests/Types/Incident/IncidentSlaStatus.test.ts +191 -0
  183. package/Tests/Types/Metrics/MetricDashboardMetricType.test.ts +278 -0
  184. package/Tests/Types/Metrics/MetricPipelineRuleType.test.ts +517 -0
  185. package/Tests/Types/Monitor/IncomingMonitorDefaultCriteria.test.ts +470 -0
  186. package/Tests/Types/Monitor/MonitorCriteriaInstance.test.ts +6 -4
  187. package/Tests/Types/Monitor/MonitorStep.test.ts +100 -0
  188. package/Tests/Types/Monitor/MonitorTypeKeywords.test.ts +360 -0
  189. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCatalog.test.ts +262 -5
  190. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationCoverage.test.ts +1 -1
  191. package/Tests/Types/Monitor/Recommendation/MonitorRecommendationNotificationMode.test.ts +1 -1
  192. package/Tests/Types/Monitor/ServiceAlertTemplates.test.ts +905 -0
  193. package/Tests/Types/Service/ServiceLanguage.test.ts +255 -0
  194. package/Tests/Types/StatusPage/SearchEngineIndexing.test.ts +86 -0
  195. package/Tests/Types/Telemetry/ResourceEntityFacet.test.ts +254 -0
  196. package/Tests/Types/TextRandomGeneration.test.ts +211 -0
  197. package/Tests/UI/Components/Button.test.tsx +175 -1
  198. package/Tests/UI/Components/CardSelect.test.tsx +1021 -0
  199. package/Tests/UI/Components/CodeBlockLanguages.test.tsx +236 -0
  200. package/Tests/UI/Components/CommandPalette/CommandPalette.test.tsx +568 -0
  201. package/Tests/UI/Components/CommandPalette/CommandPaletteKeyboard.test.tsx +239 -0
  202. package/Tests/UI/Components/CommandPalette/CommandPaletteProviders.test.tsx +400 -0
  203. package/Tests/UI/Components/CommandPalette/PaletteFilter.test.ts +234 -0
  204. package/Tests/UI/Components/CommandPalette/RecentCommands.test.ts +97 -0
  205. package/Tests/UI/Components/CountModelSideMenuItemGuard.test.tsx +198 -0
  206. package/Tests/UI/Components/FeedItemSafeMode.test.tsx +1 -1
  207. package/Tests/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.test.ts +267 -0
  208. package/Tests/UI/Components/List.test.tsx +9 -2
  209. package/Tests/UI/Components/ListLoadingStates.test.tsx +173 -0
  210. package/Tests/UI/Components/MarkdownLazy.test.tsx +113 -0
  211. package/Tests/UI/Components/MarkdownMermaidRetry.test.tsx +110 -0
  212. package/Tests/UI/Components/MasterPage.test.tsx +36 -1
  213. package/Tests/UI/Components/ModelTable/useCustomFieldColumns.test.tsx +8 -0
  214. package/Tests/UI/Components/MonitorTemplateVariables/TemplateVariablesCatalog.test.ts +692 -0
  215. package/Tests/UI/Components/MoreMenuMotion.test.tsx +118 -0
  216. package/Tests/UI/Components/NavBarCommandKGating.test.tsx +178 -0
  217. package/Tests/UI/Components/OrderedStatesList.test.tsx +19 -2
  218. package/Tests/UI/Components/SideOverMotion.test.tsx +109 -0
  219. package/Tests/UI/Components/Skeleton.test.tsx +71 -0
  220. package/Tests/UI/Components/TableLoadingStates.test.tsx +279 -0
  221. package/Tests/UI/Components/Tabs.test.tsx +24 -0
  222. package/Tests/UI/Components/Toast.test.tsx +130 -7
  223. package/Tests/UI/Components/ToastStacking.test.tsx +198 -0
  224. package/Tests/UI/Utils/Dropdown.test.ts +423 -0
  225. package/Tests/UI/Utils/ModelAPITenantHeader.test.ts +122 -0
  226. package/Tests/UI/Utils/ModelListCache.test.ts +338 -0
  227. package/Tests/UI/Utils/ProjectListCacheInvalidation.test.ts +225 -0
  228. package/Tests/Utils/API.test.ts +16 -2
  229. package/Tests/Utils/Dashboard/Components/DashboardKubernetesResourceListShared.test.ts +347 -0
  230. package/Tests/Utils/Dashboard/Components/DashboardListSharedArgs.test.ts +259 -0
  231. package/Tests/Utils/Dashboard/Components/DashboardMonitorListComponent.test.ts +466 -0
  232. package/Tests/Utils/Monitor/MonitorMetricType.test.ts +66 -1
  233. package/Tests/Utils/Monitor/NetworkTopologyUtil.test.ts +115 -6
  234. package/Tests/Utils/NetworkDevice/DeviceReachabilityUtil.test.ts +610 -0
  235. package/Tests/Utils/NetworkSite/SiteStatusRollupUtil.test.ts +114 -45
  236. package/Tests/Utils/Rum/UrlScrubberSegments.test.ts +362 -0
  237. package/Types/API/Hostname.ts +79 -0
  238. package/Types/Database/AccessControl/ColumnAccessControl.ts +33 -11
  239. package/Types/Database/AccessControl/ColumnBillingAccessControl.ts +33 -11
  240. package/Types/Database/DatabaseProperty.ts +38 -0
  241. package/Types/Database/TableColumn.ts +34 -7
  242. package/Types/Email/EmailTemplateType.ts +1 -0
  243. package/Types/Events/Recurring.ts +16 -1
  244. package/Types/Monitor/MonitorCriteriaInstance.ts +41 -20
  245. package/Types/Monitor/MonitorStep.ts +13 -1
  246. package/Types/Monitor/MonitorType.ts +345 -40
  247. package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.ts +131 -8
  248. package/Types/Monitor/Recommendation/MonitorRecommendationTypes.ts +48 -8
  249. package/Types/Monitor/SSLMonitor/SslMonitorResponse.ts +43 -0
  250. package/Types/Monitor/ServiceAlertTemplates.ts +1352 -0
  251. package/Types/Permission.ts +35 -0
  252. package/Types/PushNotification/AndroidNotificationChannel.ts +26 -0
  253. package/Types/PushNotification/PushNotificationMessage.ts +15 -0
  254. package/Types/PushNotification/PushNotificationRequest.ts +8 -16
  255. package/Types/Service/ServiceLanguage.ts +144 -0
  256. package/Types/StatusPage/SearchEngineIndexing.ts +61 -0
  257. package/Types/Telemetry/ResourceEntityFacet.ts +211 -0
  258. package/Types/Text.ts +111 -19
  259. package/UI/Components/Button/Button.tsx +27 -14
  260. package/UI/Components/CardSelect/CardSelect.tsx +714 -105
  261. package/UI/Components/CodeBlock/CodeBlock.tsx +54 -7
  262. package/UI/Components/CodeBlock/LanguageRegistry.ts +103 -0
  263. package/UI/Components/CommandPalette/CommandPalette.tsx +790 -0
  264. package/UI/Components/CommandPalette/PaletteFilter.ts +196 -0
  265. package/UI/Components/CommandPalette/PaletteRow.tsx +173 -0
  266. package/UI/Components/CommandPalette/RecentCommands.ts +57 -0
  267. package/UI/Components/CommandPalette/Types.ts +49 -0
  268. package/UI/Components/CommandPalette/UseProviderSearch.ts +129 -0
  269. package/UI/Components/Dropdown/Dropdown.tsx +6 -1
  270. package/UI/Components/EmptyState/EmptyState.tsx +8 -1
  271. package/UI/Components/Feed/FeedItem.tsx +1 -1
  272. package/UI/Components/Footer/Footer.tsx +32 -6
  273. package/UI/Components/Forms/Fields/FormField.tsx +3 -0
  274. package/UI/Components/Forms/Types/Field.ts +8 -0
  275. package/UI/Components/List/List.tsx +37 -5
  276. package/UI/Components/List/ListSkeleton.tsx +54 -0
  277. package/UI/Components/Loader/PageLoader.tsx +29 -8
  278. package/UI/Components/LogsViewer/components/LogsAnalyticsView.tsx +26 -4
  279. package/UI/Components/Markdown.tsx/LazyMarkdownViewer.tsx +23 -2
  280. package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +71 -26
  281. package/UI/Components/MasterPage/MasterPage.tsx +24 -11
  282. package/UI/Components/Modal/Modal.tsx +2 -2
  283. package/UI/Components/ModelTable/BaseModelTable.tsx +1 -1
  284. package/UI/Components/ModelTable/useCustomFieldColumns.ts +11 -5
  285. package/UI/Components/MoreMenu/MoreMenu.tsx +39 -1
  286. package/UI/Components/Navbar/NavBar.tsx +14 -1
  287. package/UI/Components/OrderedStatesList/OrderedStatesList.tsx +50 -5
  288. package/UI/Components/SideMenu/CountModelSideMenuItem.tsx +40 -1
  289. package/UI/Components/SideOver/SideOver.tsx +37 -2
  290. package/UI/Components/Skeleton/Skeleton.tsx +53 -0
  291. package/UI/Components/Table/Table.tsx +74 -44
  292. package/UI/Components/Table/TableSkeletonRows.tsx +141 -0
  293. package/UI/Components/Tabs/Tab.tsx +1 -1
  294. package/UI/Components/Toast/Toast.tsx +118 -53
  295. package/UI/Components/Toast/ToastInit.tsx +82 -32
  296. package/UI/Styles/Theme.css +40 -0
  297. package/UI/Utils/ModelAPI/ModelAPI.ts +20 -10
  298. package/UI/Utils/ModelListCache.ts +188 -0
  299. package/UI/Utils/Project.ts +29 -0
  300. package/Utils/API.ts +6 -1
  301. package/Utils/Monitor/MonitorMetricType.ts +16 -1
  302. package/Utils/Monitor/NetworkTopologyUtil.ts +60 -8
  303. package/Utils/NetworkDevice/DeviceReachabilityUtil.ts +262 -0
  304. package/Utils/NetworkSite/SiteStatusRollupUtil.ts +41 -24
  305. package/Utils/Telemetry/CrossSignalScope.ts +75 -4
  306. package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js +20 -4
  307. package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js.map +1 -1
  308. package/build/dist/Models/DatabaseModels/NetworkDevice.js +66 -0
  309. package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
  310. package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js +14 -0
  311. package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js.map +1 -1
  312. package/build/dist/Models/DatabaseModels/StatusPage.js +60 -0
  313. package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
  314. package/build/dist/Models/DatabaseModels/StatusPageOidc.js +2 -0
  315. package/build/dist/Models/DatabaseModels/StatusPageOidc.js.map +1 -1
  316. package/build/dist/Models/DatabaseModels/UserCall.js +101 -3
  317. package/build/dist/Models/DatabaseModels/UserCall.js.map +1 -1
  318. package/build/dist/Models/DatabaseModels/UserEmail.js +101 -3
  319. package/build/dist/Models/DatabaseModels/UserEmail.js.map +1 -1
  320. package/build/dist/Models/DatabaseModels/UserIncomingCallNumber.js +101 -3
  321. package/build/dist/Models/DatabaseModels/UserIncomingCallNumber.js.map +1 -1
  322. package/build/dist/Models/DatabaseModels/UserPush.js +38 -0
  323. package/build/dist/Models/DatabaseModels/UserPush.js.map +1 -1
  324. package/build/dist/Models/DatabaseModels/UserSMS.js +101 -3
  325. package/build/dist/Models/DatabaseModels/UserSMS.js.map +1 -1
  326. package/build/dist/Models/DatabaseModels/UserWhatsApp.js +100 -2
  327. package/build/dist/Models/DatabaseModels/UserWhatsApp.js.map +1 -1
  328. package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js.map +1 -1
  329. package/build/dist/Server/API/AIChatAPI.js +48 -35
  330. package/build/dist/Server/API/AIChatAPI.js.map +1 -1
  331. package/build/dist/Server/API/BaseAPI.js +69 -13
  332. package/build/dist/Server/API/BaseAPI.js.map +1 -1
  333. package/build/dist/Server/API/CommonAPI.js +59 -0
  334. package/build/dist/Server/API/CommonAPI.js.map +1 -1
  335. package/build/dist/Server/API/MicrosoftTeamsAPI.js +20 -6
  336. package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
  337. package/build/dist/Server/API/SlackAPI.js +13 -10
  338. package/build/dist/Server/API/SlackAPI.js.map +1 -1
  339. package/build/dist/Server/API/StatusPageAPI.js +745 -673
  340. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  341. package/build/dist/Server/API/TelemetryAPI.js +34 -3
  342. package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
  343. package/build/dist/Server/API/UserCallAPI.js +42 -38
  344. package/build/dist/Server/API/UserCallAPI.js.map +1 -1
  345. package/build/dist/Server/API/UserEmailAPI.js +42 -38
  346. package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
  347. package/build/dist/Server/API/UserIncomingCallNumberAPI.js +37 -32
  348. package/build/dist/Server/API/UserIncomingCallNumberAPI.js.map +1 -1
  349. package/build/dist/Server/API/UserNotificationMethodAdminAPI.js +341 -0
  350. package/build/dist/Server/API/UserNotificationMethodAdminAPI.js.map +1 -0
  351. package/build/dist/Server/API/UserPushAPI.js +95 -2
  352. package/build/dist/Server/API/UserPushAPI.js.map +1 -1
  353. package/build/dist/Server/API/UserSmsAPI.js +42 -38
  354. package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
  355. package/build/dist/Server/API/UserWhatsAppAPI.js +42 -40
  356. package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -1
  357. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787142779538-MigrationName.js +89 -0
  358. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787142779538-MigrationName.js.map +1 -0
  359. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787156982416-MigrationName.js +12 -0
  360. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787156982416-MigrationName.js.map +1 -0
  361. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787500000000-AddEnableSearchEngineIndexingToStatusPage.js +23 -0
  362. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787500000000-AddEnableSearchEngineIndexingToStatusPage.js.map +1 -0
  363. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787600000000-AddNetworkDeviceReachabilityColumns.js +34 -0
  364. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787600000000-AddNetworkDeviceReachabilityColumns.js.map +1 -0
  365. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787700000000-FixTotpOtpUrlAlgorithm.js +40 -0
  366. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787700000000-FixTotpOtpUrlAlgorithm.js.map +1 -0
  367. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +10 -0
  368. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  369. package/build/dist/Server/Middleware/UserAuthorization.js +6 -2
  370. package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
  371. package/build/dist/Server/Middleware/VerificationCodeRateLimit.js +393 -0
  372. package/build/dist/Server/Middleware/VerificationCodeRateLimit.js.map +1 -0
  373. package/build/dist/Server/Services/AnalyticsDatabaseService.js +136 -0
  374. package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
  375. package/build/dist/Server/Services/ApiKeyPermissionService.js +90 -1
  376. package/build/dist/Server/Services/ApiKeyPermissionService.js.map +1 -1
  377. package/build/dist/Server/Services/DatabaseService.js +89 -6
  378. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  379. package/build/dist/Server/Services/LogAggregationService.js +7 -0
  380. package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
  381. package/build/dist/Server/Services/LogService.js +16 -0
  382. package/build/dist/Server/Services/LogService.js.map +1 -1
  383. package/build/dist/Server/Services/NetworkSiteService.js +12 -0
  384. package/build/dist/Server/Services/NetworkSiteService.js.map +1 -1
  385. package/build/dist/Server/Services/PushNotificationService.js +69 -30
  386. package/build/dist/Server/Services/PushNotificationService.js.map +1 -1
  387. package/build/dist/Server/Services/SpanService.js +16 -0
  388. package/build/dist/Server/Services/SpanService.js.map +1 -1
  389. package/build/dist/Server/Services/TeamMemberService.js +43 -7
  390. package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
  391. package/build/dist/Server/Services/TraceAggregationService.js +2 -0
  392. package/build/dist/Server/Services/TraceAggregationService.js.map +1 -1
  393. package/build/dist/Server/Services/UserCallService.js +54 -22
  394. package/build/dist/Server/Services/UserCallService.js.map +1 -1
  395. package/build/dist/Server/Services/UserEmailService.js +78 -17
  396. package/build/dist/Server/Services/UserEmailService.js.map +1 -1
  397. package/build/dist/Server/Services/UserIncomingCallNumberService.js +45 -74
  398. package/build/dist/Server/Services/UserIncomingCallNumberService.js.map +1 -1
  399. package/build/dist/Server/Services/UserNotificationMethodAdminService.js +1117 -0
  400. package/build/dist/Server/Services/UserNotificationMethodAdminService.js.map +1 -0
  401. package/build/dist/Server/Services/UserNotificationRuleService.js +20 -0
  402. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  403. package/build/dist/Server/Services/UserPushService.js +77 -0
  404. package/build/dist/Server/Services/UserPushService.js.map +1 -1
  405. package/build/dist/Server/Services/UserSmsService.js +50 -17
  406. package/build/dist/Server/Services/UserSmsService.js.map +1 -1
  407. package/build/dist/Server/Services/UserWhatsAppService.js +48 -15
  408. package/build/dist/Server/Services/UserWhatsAppService.js.map +1 -1
  409. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +137 -164
  410. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
  411. package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js +9 -0
  412. package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js.map +1 -1
  413. package/build/dist/Server/Types/Database/Permissions/AccessControlPermission.js +21 -13
  414. package/build/dist/Server/Types/Database/Permissions/AccessControlPermission.js.map +1 -1
  415. package/build/dist/Server/Types/Database/QueryHelper.js +27 -0
  416. package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
  417. package/build/dist/Server/Utils/APIKey/AccessPermission.js +9 -32
  418. package/build/dist/Server/Utils/APIKey/AccessPermission.js.map +1 -1
  419. package/build/dist/Server/Utils/AnalyticsDatabase/QuerySettingsHelper.js +46 -0
  420. package/build/dist/Server/Utils/AnalyticsDatabase/QuerySettingsHelper.js.map +1 -1
  421. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +87 -0
  422. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
  423. package/build/dist/Server/Utils/ChannelVerification.js +348 -0
  424. package/build/dist/Server/Utils/ChannelVerification.js.map +1 -0
  425. package/build/dist/Server/Utils/LogRedaction.js +449 -0
  426. package/build/dist/Server/Utils/LogRedaction.js.map +1 -0
  427. package/build/dist/Server/Utils/Logger.js +98 -45
  428. package/build/dist/Server/Utils/Logger.js.map +1 -1
  429. package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js +13 -12
  430. package/build/dist/Server/Utils/Monitor/Criteria/IncomingRequestCriteria.js.map +1 -1
  431. package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js +65 -13
  432. package/build/dist/Server/Utils/Monitor/Criteria/SSLMonitorCriteria.js.map +1 -1
  433. package/build/dist/Server/Utils/Monitor/MonitorAlert.js +20 -17
  434. package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
  435. package/build/dist/Server/Utils/Monitor/MonitorIncident.js +17 -14
  436. package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
  437. package/build/dist/Server/Utils/Monitor/MonitorResource.js +20 -3
  438. package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
  439. package/build/dist/Server/Utils/Monitor/MonitorResourceContext.js +95 -0
  440. package/build/dist/Server/Utils/Monitor/MonitorResourceContext.js.map +1 -0
  441. package/build/dist/Server/Utils/Monitor/MonitorStepResourceIdentity.js +313 -0
  442. package/build/dist/Server/Utils/Monitor/MonitorStepResourceIdentity.js.map +1 -0
  443. package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js +27 -7
  444. package/build/dist/Server/Utils/Monitor/NetworkInventoryUtil.js.map +1 -1
  445. package/build/dist/Server/Utils/Monitor/SeriesResourceLabels.js +3 -3
  446. package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js +67 -26
  447. package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js.map +1 -1
  448. package/build/dist/Server/Utils/SessionReplay/SessionReplayGateCacheStore.js +29 -10
  449. package/build/dist/Server/Utils/SessionReplay/SessionReplayGateCacheStore.js.map +1 -1
  450. package/build/dist/Server/Utils/StartServer.js +10 -7
  451. package/build/dist/Server/Utils/StartServer.js.map +1 -1
  452. package/build/dist/Server/Utils/StatusPageSearchEngineIndexing.js +24 -0
  453. package/build/dist/Server/Utils/StatusPageSearchEngineIndexing.js.map +1 -0
  454. package/build/dist/Server/Utils/Telemetry/ResourceEntityFilter.js +311 -0
  455. package/build/dist/Server/Utils/Telemetry/ResourceEntityFilter.js.map +1 -0
  456. package/build/dist/Server/Utils/TotpAuth.js +127 -8
  457. package/build/dist/Server/Utils/TotpAuth.js.map +1 -1
  458. package/build/dist/Server/Utils/UserRegistrationToken.js +170 -0
  459. package/build/dist/Server/Utils/UserRegistrationToken.js.map +1 -0
  460. package/build/dist/Server/Utils/VerificationCode.js +120 -0
  461. package/build/dist/Server/Utils/VerificationCode.js.map +1 -0
  462. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +366 -37
  463. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  464. package/build/dist/Types/API/Hostname.js +63 -0
  465. package/build/dist/Types/API/Hostname.js.map +1 -1
  466. package/build/dist/Types/Database/AccessControl/ColumnAccessControl.js +20 -6
  467. package/build/dist/Types/Database/AccessControl/ColumnAccessControl.js.map +1 -1
  468. package/build/dist/Types/Database/AccessControl/ColumnBillingAccessControl.js +20 -6
  469. package/build/dist/Types/Database/AccessControl/ColumnBillingAccessControl.js.map +1 -1
  470. package/build/dist/Types/Database/DatabaseProperty.js +38 -0
  471. package/build/dist/Types/Database/DatabaseProperty.js.map +1 -1
  472. package/build/dist/Types/Database/TableColumn.js +24 -6
  473. package/build/dist/Types/Database/TableColumn.js.map +1 -1
  474. package/build/dist/Types/Email/EmailTemplateType.js +1 -0
  475. package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
  476. package/build/dist/Types/Events/Recurring.js +13 -1
  477. package/build/dist/Types/Events/Recurring.js.map +1 -1
  478. package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +42 -21
  479. package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
  480. package/build/dist/Types/Monitor/MonitorStep.js +9 -1
  481. package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
  482. package/build/dist/Types/Monitor/MonitorType.js +330 -31
  483. package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
  484. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +77 -5
  485. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js.map +1 -1
  486. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js +18 -6
  487. package/build/dist/Types/Monitor/Recommendation/MonitorRecommendationTypes.js.map +1 -1
  488. package/build/dist/Types/Monitor/ServiceAlertTemplates.js +1028 -0
  489. package/build/dist/Types/Monitor/ServiceAlertTemplates.js.map +1 -0
  490. package/build/dist/Types/Permission.js +33 -0
  491. package/build/dist/Types/Permission.js.map +1 -1
  492. package/build/dist/Types/PushNotification/AndroidNotificationChannel.js +27 -0
  493. package/build/dist/Types/PushNotification/AndroidNotificationChannel.js.map +1 -0
  494. package/build/dist/Types/Service/ServiceLanguage.js +96 -0
  495. package/build/dist/Types/Service/ServiceLanguage.js.map +1 -0
  496. package/build/dist/Types/StatusPage/SearchEngineIndexing.js +55 -0
  497. package/build/dist/Types/StatusPage/SearchEngineIndexing.js.map +1 -0
  498. package/build/dist/Types/Telemetry/ResourceEntityFacet.js +156 -0
  499. package/build/dist/Types/Telemetry/ResourceEntityFacet.js.map +1 -0
  500. package/build/dist/Types/Text.js +82 -17
  501. package/build/dist/Types/Text.js.map +1 -1
  502. package/build/dist/UI/Components/Button/Button.js +22 -14
  503. package/build/dist/UI/Components/Button/Button.js.map +1 -1
  504. package/build/dist/UI/Components/CardSelect/CardSelect.js +360 -40
  505. package/build/dist/UI/Components/CardSelect/CardSelect.js.map +1 -1
  506. package/build/dist/UI/Components/CodeBlock/CodeBlock.js +35 -3
  507. package/build/dist/UI/Components/CodeBlock/CodeBlock.js.map +1 -1
  508. package/build/dist/UI/Components/CodeBlock/LanguageRegistry.js +57 -0
  509. package/build/dist/UI/Components/CodeBlock/LanguageRegistry.js.map +1 -0
  510. package/build/dist/UI/Components/CommandPalette/CommandPalette.js +439 -0
  511. package/build/dist/UI/Components/CommandPalette/CommandPalette.js.map +1 -0
  512. package/build/dist/UI/Components/CommandPalette/PaletteFilter.js +135 -0
  513. package/build/dist/UI/Components/CommandPalette/PaletteFilter.js.map +1 -0
  514. package/build/dist/UI/Components/CommandPalette/PaletteRow.js +83 -0
  515. package/build/dist/UI/Components/CommandPalette/PaletteRow.js.map +1 -0
  516. package/build/dist/UI/Components/CommandPalette/RecentCommands.js +47 -0
  517. package/build/dist/UI/Components/CommandPalette/RecentCommands.js.map +1 -0
  518. package/build/dist/UI/Components/CommandPalette/Types.js +2 -0
  519. package/build/dist/UI/Components/CommandPalette/Types.js.map +1 -0
  520. package/build/dist/UI/Components/CommandPalette/UseProviderSearch.js +88 -0
  521. package/build/dist/UI/Components/CommandPalette/UseProviderSearch.js.map +1 -0
  522. package/build/dist/UI/Components/Dropdown/Dropdown.js +6 -1
  523. package/build/dist/UI/Components/Dropdown/Dropdown.js.map +1 -1
  524. package/build/dist/UI/Components/EmptyState/EmptyState.js +1 -1
  525. package/build/dist/UI/Components/EmptyState/EmptyState.js.map +1 -1
  526. package/build/dist/UI/Components/Feed/FeedItem.js +1 -1
  527. package/build/dist/UI/Components/Feed/FeedItem.js.map +1 -1
  528. package/build/dist/UI/Components/Footer/Footer.js +7 -4
  529. package/build/dist/UI/Components/Footer/Footer.js.map +1 -1
  530. package/build/dist/UI/Components/Forms/Fields/FormField.js +1 -1
  531. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  532. package/build/dist/UI/Components/List/List.js +19 -5
  533. package/build/dist/UI/Components/List/List.js.map +1 -1
  534. package/build/dist/UI/Components/List/ListSkeleton.js +21 -0
  535. package/build/dist/UI/Components/List/ListSkeleton.js.map +1 -0
  536. package/build/dist/UI/Components/Loader/PageLoader.js +15 -5
  537. package/build/dist/UI/Components/Loader/PageLoader.js.map +1 -1
  538. package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js +16 -3
  539. package/build/dist/UI/Components/LogsViewer/components/LogsAnalyticsView.js.map +1 -1
  540. package/build/dist/UI/Components/Markdown.tsx/LazyMarkdownViewer.js +13 -1
  541. package/build/dist/UI/Components/Markdown.tsx/LazyMarkdownViewer.js.map +1 -1
  542. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +52 -25
  543. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
  544. package/build/dist/UI/Components/MasterPage/MasterPage.js +10 -2
  545. package/build/dist/UI/Components/MasterPage/MasterPage.js.map +1 -1
  546. package/build/dist/UI/Components/Modal/Modal.js +2 -2
  547. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +1 -1
  548. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  549. package/build/dist/UI/Components/ModelTable/useCustomFieldColumns.js +9 -2
  550. package/build/dist/UI/Components/ModelTable/useCustomFieldColumns.js.map +1 -1
  551. package/build/dist/UI/Components/MoreMenu/MoreMenu.js +32 -1
  552. package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
  553. package/build/dist/UI/Components/Navbar/NavBar.js +5 -1
  554. package/build/dist/UI/Components/Navbar/NavBar.js.map +1 -1
  555. package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js +29 -5
  556. package/build/dist/UI/Components/OrderedStatesList/OrderedStatesList.js.map +1 -1
  557. package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js +23 -1
  558. package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js.map +1 -1
  559. package/build/dist/UI/Components/SideOver/SideOver.js +23 -2
  560. package/build/dist/UI/Components/SideOver/SideOver.js.map +1 -1
  561. package/build/dist/UI/Components/Skeleton/Skeleton.js +23 -0
  562. package/build/dist/UI/Components/Skeleton/Skeleton.js.map +1 -0
  563. package/build/dist/UI/Components/Table/Table.js +35 -24
  564. package/build/dist/UI/Components/Table/Table.js.map +1 -1
  565. package/build/dist/UI/Components/Table/TableSkeletonRows.js +52 -0
  566. package/build/dist/UI/Components/Table/TableSkeletonRows.js.map +1 -0
  567. package/build/dist/UI/Components/Tabs/Tab.js +1 -1
  568. package/build/dist/UI/Components/Tabs/Tab.js.map +1 -1
  569. package/build/dist/UI/Components/Toast/Toast.js +77 -23
  570. package/build/dist/UI/Components/Toast/Toast.js.map +1 -1
  571. package/build/dist/UI/Components/Toast/ToastInit.js +37 -15
  572. package/build/dist/UI/Components/Toast/ToastInit.js.map +1 -1
  573. package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +18 -9
  574. package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
  575. package/build/dist/UI/Utils/ModelListCache.js +126 -0
  576. package/build/dist/UI/Utils/ModelListCache.js.map +1 -0
  577. package/build/dist/UI/Utils/Project.js +24 -1
  578. package/build/dist/UI/Utils/Project.js.map +1 -1
  579. package/build/dist/Utils/API.js +6 -1
  580. package/build/dist/Utils/API.js.map +1 -1
  581. package/build/dist/Utils/Monitor/MonitorMetricType.js +13 -1
  582. package/build/dist/Utils/Monitor/MonitorMetricType.js.map +1 -1
  583. package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +34 -7
  584. package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -1
  585. package/build/dist/Utils/NetworkDevice/DeviceReachabilityUtil.js +177 -0
  586. package/build/dist/Utils/NetworkDevice/DeviceReachabilityUtil.js.map +1 -0
  587. package/build/dist/Utils/NetworkSite/SiteStatusRollupUtil.js +23 -27
  588. package/build/dist/Utils/NetworkSite/SiteStatusRollupUtil.js.map +1 -1
  589. package/build/dist/Utils/Telemetry/CrossSignalScope.js +44 -4
  590. package/build/dist/Utils/Telemetry/CrossSignalScope.js.map +1 -1
  591. package/jest.config.json +1 -1
  592. package/package.json +2 -3
  593. package/Server/Utils/Monitor/MonitorClusterContext.ts +0 -182
  594. package/Tests/__mocks__/otpauth.js +0 -30
  595. package/build/dist/Server/Utils/Monitor/MonitorClusterContext.js +0 -141
  596. package/build/dist/Server/Utils/Monitor/MonitorClusterContext.js.map +0 -1
@@ -0,0 +1,341 @@
1
+ import UserMiddleware from "../Middleware/UserAuthorization";
2
+ import UserNotificationMethodAdminService from "../Services/UserNotificationMethodAdminService";
3
+ import TeamMemberService from "../Services/TeamMemberService";
4
+ import Express from "../Utils/Express";
5
+ import Response from "../Utils/Response";
6
+ import CommonAPI from "./CommonAPI";
7
+ import DatabaseCommonInteractionPropsUtil, { PermissionType, } from "../../Types/BaseDatabase/DatabaseCommonInteractionPropsUtil";
8
+ import BadDataException from "../../Types/Exception/BadDataException";
9
+ import NotAuthorizedException from "../../Types/Exception/NotAuthorizedException";
10
+ import ObjectID from "../../Types/ObjectID";
11
+ import Permission from "../../Types/Permission";
12
+ /*
13
+ * Managing another project member's notification methods over HTTP.
14
+ *
15
+ * Everything this router does is done by UserNotificationMethodAdminService,
16
+ * which holds the whole of the reasoning about masking, verification and the
17
+ * owner's mail. This file is transport and AUTHORISATION, and the authorisation
18
+ * is the part worth reading, because the usual reasoning does not apply here.
19
+ *
20
+ * The seven notification method models are scoped to the person who owns the
21
+ * device, and they stay that way — see the essay at the top of UserEmail.ts.
22
+ * The service therefore does its reads and writes with `isRoot: true`, which
23
+ * means the model's own TableAccessControl never runs on this path AND THESE
24
+ * HANDLERS ARE THE ONLY GATE UNDERNEATH. UserMiddleware.getUserMiddleware is
25
+ * not that gate: it admits anonymous callers as UserType.Public and calls
26
+ * next(), and the tenant id it attaches comes straight off the caller-supplied
27
+ * `tenantid` header before any authorisation runs.
28
+ *
29
+ * So every route below asserts, itself, in this order:
30
+ *
31
+ * 1. the caller is a signed-in member of the project they named
32
+ * (CommonAPI.assertAuthenticatedProjectMember, which checks the caller
33
+ * against that same header);
34
+ * 2. the caller holds a permission that lets them act on other people's
35
+ * accounts in it (assertCanManageUserNotificationMethods below), EXCEPT on
36
+ * the read, which additionally lets a person read their own; and
37
+ * 3. the user named in the path is a member of that same project — enforced
38
+ * again inside the service, on purpose, so the service is safe for any
39
+ * caller and not only for this router.
40
+ *
41
+ * WHY THE READ IS SEPARATELY GATED FROM THE WRITES. Reading the masked list is
42
+ * a disclosure ("this person has an unverified SMS"), and the readiness surface
43
+ * already discloses exactly that to every project member. Writing is an ACTION
44
+ * on somebody else's account. Those are different questions and the router does
45
+ * not answer them with one permission.
46
+ */
47
+ const router = Express.getRouter();
48
+ /*
49
+ * Who may LOOK at another member's notification methods.
50
+ *
51
+ * The same triple the admin rules page uses, and for the same reason: existing
52
+ * project teams are seeded with ROLES, never with individual granular
53
+ * permissions, so a permission introduced in this release is held by nobody at
54
+ * all until an administrator explicitly grants it. A gate naming only the
55
+ * granular permission would ship a feature that is dead on arrival for every
56
+ * project that already exists — the owner of a project would open the page and
57
+ * be told they may not look at it.
58
+ */
59
+ const READ_PERMISSIONS = [
60
+ Permission.ProjectOwner,
61
+ Permission.ProjectAdmin,
62
+ Permission.ReadProjectUserNotificationRule,
63
+ ];
64
+ /*
65
+ * Who may ADD or REMOVE one.
66
+ *
67
+ * Deliberately NOT EditProjectUserNotificationRule. Repairing somebody's rules
68
+ * and putting a new address on their account are different powers with
69
+ * different blast radii: the first re-points pages between devices that person
70
+ * has already proved they hold, the second introduces a device nobody has
71
+ * proved anything about. An installation that wants to hand out the first
72
+ * without the second must be able to, so this is its own permission.
73
+ */
74
+ const MANAGE_PERMISSIONS = [
75
+ Permission.ProjectOwner,
76
+ Permission.ProjectAdmin,
77
+ Permission.ManageProjectUserNotificationMethod,
78
+ ];
79
+ /*
80
+ * The permission check, read the way the rest of the API reads permissions.
81
+ *
82
+ * getUserPermissions(Allow) rather than indexing userTenantAccessPermission
83
+ * directly, and that is not a stylistic preference. That dictionary's entries
84
+ * hold GRANTS AND DENIALS in one array, discriminated only by
85
+ * `isBlockPermission`, so mapping it raw would count a team's explicit BLOCK of
86
+ * ProjectAdmin as a grant of it — the admin action that restricts a team would
87
+ * be the thing that handed it this endpoint.
88
+ *
89
+ * Every refusal in this file reuses one sentence, so an under-privileged member
90
+ * cannot tell "you may not do this" apart from "you are not in this project"
91
+ * and use the difference to probe.
92
+ */
93
+ function assertHasAnyPermission(databaseProps, allowed) {
94
+ if (databaseProps.isMasterAdmin) {
95
+ return;
96
+ }
97
+ const permissions = DatabaseCommonInteractionPropsUtil.getUserPermissions(databaseProps, PermissionType.Allow).map((userPermission) => {
98
+ return userPermission.permission;
99
+ });
100
+ const isAllowed = permissions.some((permission) => {
101
+ return allowed.includes(permission);
102
+ });
103
+ if (!isAllowed) {
104
+ throw new NotAuthorizedException("You are not authorized to access this project's data.");
105
+ }
106
+ }
107
+ /*
108
+ * Project membership for the user NAMED IN THE PATH, not the caller.
109
+ *
110
+ * Without it these routes are a cross-project probe: the service's reads are
111
+ * projectId-scoped and would come back empty for a stranger, but a write path
112
+ * that skipped this would let somebody holding ProjectAdmin on one throwaway
113
+ * project act on a user id belonging to any other.
114
+ *
115
+ * The rejection reuses the router's single refusal sentence so a caller cannot
116
+ * tell "this user exists but is in another project" apart from "this user does
117
+ * not exist", and therefore cannot enumerate users through it. The service
118
+ * repeats the check with its own wording once the caller is past this point.
119
+ */
120
+ async function assertUserBelongsToProject(userId, projectId) {
121
+ const memberships = await TeamMemberService.findBy({
122
+ query: {
123
+ userId: userId,
124
+ projectId: projectId,
125
+ },
126
+ select: {
127
+ _id: true,
128
+ },
129
+ limit: 1,
130
+ skip: 0,
131
+ props: {
132
+ isRoot: true,
133
+ },
134
+ });
135
+ if (memberships.length === 0) {
136
+ throw new NotAuthorizedException("You are not authorized to access this project's data.");
137
+ }
138
+ }
139
+ /*
140
+ * ObjectID's constructor accepts any string, so an unvalidated path segment
141
+ * would travel all the way to a query that matches nothing and read as "this
142
+ * user has no notification methods" rather than as "you sent nonsense".
143
+ */
144
+ function readObjectIdParam(req, name) {
145
+ const raw = req.params[name] || "";
146
+ ObjectID.validateUUID(raw);
147
+ return new ObjectID(raw);
148
+ }
149
+ function readStringFromBody(req, name) {
150
+ const body = (req.body || {});
151
+ const raw = body[name];
152
+ if (typeof raw !== "string" || !raw.trim()) {
153
+ throw new BadDataException(`${name} is required.`);
154
+ }
155
+ return raw.trim();
156
+ }
157
+ /*
158
+ * ObjectID.toJSON() serialises to `{ _type: "ObjectID", value: "..." }`, which
159
+ * is right for model payloads the client parses back through JSONFunctions but
160
+ * wrong for a hand-rolled response body. Ids are flattened to plain strings, the
161
+ * same way OnCallReadinessAPI does it, so the browser can read `methodId`
162
+ * without knowing about ObjectID at all.
163
+ *
164
+ * `maskedIdentifier` is copied and nothing else is: there is no raw field on
165
+ * the service's view type to leak, which is deliberate — a future change would
166
+ * have to widen that contract in the open rather than slip a phone number
167
+ * through a boolean flag here.
168
+ */
169
+ function serializeMethod(method) {
170
+ return {
171
+ methodId: method.methodId.toString(),
172
+ methodType: method.methodType,
173
+ maskedIdentifier: method.maskedIdentifier,
174
+ isVerified: method.isVerified,
175
+ isAdminAddable: method.isAdminAddable,
176
+ createdAt: method.createdAt ? method.createdAt.toISOString() : undefined,
177
+ };
178
+ }
179
+ /*
180
+ * Every notification method this user has, masked.
181
+ *
182
+ * A member reading their OWN row is allowed through without the admin
183
+ * permission. The page behind this is reachable from the project's user list,
184
+ * and a person looking at themselves there is reading rows the self-serve
185
+ * settings pages already show them in full.
186
+ */
187
+ router.get("/user-notification-method-admin/user/:userId", UserMiddleware.getUserMiddleware, async (req, res, next) => {
188
+ try {
189
+ const databaseProps = await CommonAPI.getDatabaseCommonInteractionProps(req);
190
+ const projectId = CommonAPI.assertAuthenticatedProjectMember(databaseProps);
191
+ const userId = readObjectIdParam(req, "userId");
192
+ const isSelf = Boolean(databaseProps.userId) &&
193
+ databaseProps.userId.toString() === userId.toString();
194
+ if (!isSelf) {
195
+ assertHasAnyPermission(databaseProps, READ_PERMISSIONS);
196
+ }
197
+ await assertUserBelongsToProject(userId, projectId);
198
+ const methods = await UserNotificationMethodAdminService.listMethodsForUser({
199
+ projectId: projectId,
200
+ userId: userId,
201
+ });
202
+ return Response.sendJsonObjectResponse(req, res, {
203
+ methods: methods.map(serializeMethod),
204
+ });
205
+ }
206
+ catch (err) {
207
+ next(err);
208
+ }
209
+ });
210
+ /*
211
+ * Add a notification method to this user's account.
212
+ *
213
+ * The row lands UNVERIFIED and a verification code goes to the address itself,
214
+ * which is what keeps this from being a way to redirect somebody's pages: the
215
+ * verify endpoints refuse anybody but the row's owner, so the administrator who
216
+ * just typed the value in cannot complete it. See the service header.
217
+ */
218
+ router.post("/user-notification-method-admin/user/:userId", UserMiddleware.getUserMiddleware, async (req, res, next) => {
219
+ try {
220
+ const databaseProps = await CommonAPI.getDatabaseCommonInteractionProps(req);
221
+ const projectId = CommonAPI.assertAuthenticatedProjectMember(databaseProps);
222
+ /*
223
+ * Both gates run before the body is read. A route that validates a
224
+ * payload for a caller it is about to refuse has told that caller
225
+ * something about the payload format.
226
+ */
227
+ assertHasAnyPermission(databaseProps, MANAGE_PERMISSIONS);
228
+ const userId = readObjectIdParam(req, "userId");
229
+ await assertUserBelongsToProject(userId, projectId);
230
+ const methodType = readStringFromBody(req, "methodType");
231
+ const value = readStringFromBody(req, "value");
232
+ const created = await UserNotificationMethodAdminService.addMethodForUser({
233
+ projectId: projectId,
234
+ targetUserId: userId,
235
+ /*
236
+ * The actor the SERVER resolved, never anything from the body. This
237
+ * value names somebody in an audit entry and in a mail to the account
238
+ * holder, so a body-supplied one would let a caller sign their own
239
+ * change with a colleague's name.
240
+ */
241
+ actorUserId: databaseProps.userId,
242
+ methodType: methodType,
243
+ value: value,
244
+ props: databaseProps,
245
+ });
246
+ return Response.sendJsonObjectResponse(req, res, serializeMethod(created));
247
+ }
248
+ catch (err) {
249
+ next(err);
250
+ }
251
+ });
252
+ /*
253
+ * What removing this method would cost, before anybody confirms it.
254
+ *
255
+ * Read-only, and gated as a WRITE rather than as a read: the numbers it returns
256
+ * are about this user's rule coverage, and the only reason to ask for them is
257
+ * that you are about to delete something.
258
+ */
259
+ router.get("/user-notification-method-admin/user/:userId/:methodType/:methodId/deletion-impact", UserMiddleware.getUserMiddleware, async (req, res, next) => {
260
+ try {
261
+ const databaseProps = await CommonAPI.getDatabaseCommonInteractionProps(req);
262
+ const projectId = CommonAPI.assertAuthenticatedProjectMember(databaseProps);
263
+ assertHasAnyPermission(databaseProps, MANAGE_PERMISSIONS);
264
+ const userId = readObjectIdParam(req, "userId");
265
+ await assertUserBelongsToProject(userId, projectId);
266
+ const methodId = readObjectIdParam(req, "methodId");
267
+ const preview = await UserNotificationMethodAdminService.getDeletionPreview({
268
+ projectId: projectId,
269
+ targetUserId: userId,
270
+ methodType: req.params["methodType"] || "",
271
+ methodId: methodId,
272
+ });
273
+ return Response.sendJsonObjectResponse(req, res, preview);
274
+ }
275
+ catch (err) {
276
+ next(err);
277
+ }
278
+ });
279
+ /*
280
+ * Send the verification code again, to the device.
281
+ *
282
+ * Discloses nothing — the code goes to the address on the row, which is the one
283
+ * thing on it the administrator cannot read — and it is the lever that makes
284
+ * adding a method on somebody's behalf actually finish: "I added your work
285
+ * mobile, here is another code" rather than re-typing the number.
286
+ */
287
+ router.post("/user-notification-method-admin/user/:userId/:methodType/:methodId/resend-verification-code", UserMiddleware.getUserMiddleware, async (req, res, next) => {
288
+ try {
289
+ const databaseProps = await CommonAPI.getDatabaseCommonInteractionProps(req);
290
+ const projectId = CommonAPI.assertAuthenticatedProjectMember(databaseProps);
291
+ assertHasAnyPermission(databaseProps, MANAGE_PERMISSIONS);
292
+ const userId = readObjectIdParam(req, "userId");
293
+ await assertUserBelongsToProject(userId, projectId);
294
+ const methodId = readObjectIdParam(req, "methodId");
295
+ await UserNotificationMethodAdminService.resendVerificationCodeForUser({
296
+ projectId: projectId,
297
+ targetUserId: userId,
298
+ methodType: req.params["methodType"] || "",
299
+ methodId: methodId,
300
+ });
301
+ return Response.sendEmptySuccessResponse(req, res);
302
+ }
303
+ catch (err) {
304
+ next(err);
305
+ }
306
+ });
307
+ /*
308
+ * Remove one of this user's notification methods.
309
+ *
310
+ * DELETE rather than a POST to a /delete path, because it is one, and because
311
+ * the id it names is the only thing that identifies the row — there is no body
312
+ * to get out of step with the URL.
313
+ *
314
+ * Every rule pointing at this method goes with it (the foreign keys are all
315
+ * onDelete: "CASCADE"), which is why the preview route above exists and why the
316
+ * owner is always mailed about this one.
317
+ */
318
+ router.delete("/user-notification-method-admin/user/:userId/:methodType/:methodId", UserMiddleware.getUserMiddleware, async (req, res, next) => {
319
+ try {
320
+ const databaseProps = await CommonAPI.getDatabaseCommonInteractionProps(req);
321
+ const projectId = CommonAPI.assertAuthenticatedProjectMember(databaseProps);
322
+ assertHasAnyPermission(databaseProps, MANAGE_PERMISSIONS);
323
+ const userId = readObjectIdParam(req, "userId");
324
+ await assertUserBelongsToProject(userId, projectId);
325
+ const methodId = readObjectIdParam(req, "methodId");
326
+ await UserNotificationMethodAdminService.deleteMethodForUser({
327
+ projectId: projectId,
328
+ targetUserId: userId,
329
+ actorUserId: databaseProps.userId,
330
+ methodType: req.params["methodType"] || "",
331
+ methodId: methodId,
332
+ props: databaseProps,
333
+ });
334
+ return Response.sendEmptySuccessResponse(req, res);
335
+ }
336
+ catch (err) {
337
+ next(err);
338
+ }
339
+ });
340
+ export default router;
341
+ //# sourceMappingURL=UserNotificationMethodAdminAPI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserNotificationMethodAdminAPI.js","sourceRoot":"","sources":["../../../../Server/API/UserNotificationMethodAdminAPI.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAC7D,OAAO,kCAGN,MAAM,gDAAgD,CAAC;AACxD,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,OAKN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,kCAAkC,EAAE,EACzC,cAAc,GACf,MAAM,6DAA6D,CAAC;AACrE,OAAO,gBAAgB,MAAM,wCAAwC,CAAC;AACtE,OAAO,sBAAsB,MAAM,8CAA8C,CAAC;AAElF,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,UAA8B,MAAM,wBAAwB,CAAC;AAGpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,MAAM,GAAkB,OAAO,CAAC,SAAS,EAAE,CAAC;AAElD;;;;;;;;;;GAUG;AACH,MAAM,gBAAgB,GAAsB;IAC1C,UAAU,CAAC,YAAY;IACvB,UAAU,CAAC,YAAY;IACvB,UAAU,CAAC,+BAA+B;CAC3C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,kBAAkB,GAAsB;IAC5C,UAAU,CAAC,YAAY;IACvB,UAAU,CAAC,YAAY;IACvB,UAAU,CAAC,mCAAmC;CAC/C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAS,sBAAsB,CAC7B,aAA6C,EAC7C,OAA0B;IAE1B,IAAI,aAAa,CAAC,aAAa,EAAE,CAAC;QAChC,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GACf,kCAAkC,CAAC,kBAAkB,CACnD,aAAa,EACb,cAAc,CAAC,KAAK,CACrB,CAAC,GAAG,CAAC,CAAC,cAA8B,EAAc,EAAE;QACnD,OAAO,cAAc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AAS,CAAC,gCAAgC,CAAC,aAAa,CAAC,CAAC;QAE5D,sBAAsB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;QAE1D,MAAM,MAAM,GAAa,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAE1D,MAAM,0BAA0B,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAEpD,MAAM,QAAQ,GAAa,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAE9D,MAAM,kCAAkC,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE,SAAS;YACpB,YAAY,EAAE,MAAM;YACpB,WAAW,EAAE,aAAa,CAAC,MAAM;YACjC,UAAU,EAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAY,IAAI,EAAE;YACtD,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,aAAa;SACrB,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,CAAC;AACH,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -11,6 +11,31 @@ import NotAuthenticatedException from "../../Types/Exception/NotAuthenticatedExc
11
11
  import ObjectID from "../../Types/ObjectID";
12
12
  import PushDeviceType from "../../Types/PushNotification/PushDeviceType";
13
13
  import UserPush from "../../Models/DatabaseModels/UserPush";
14
+ /*
15
+ * Booleans arrive from the mobile client as JSON booleans, but the same routes
16
+ * get called by hand and from form posts where "true" is a string.
17
+ *
18
+ * On REGISTRATION, absence is the normal case and means off: overriding a
19
+ * silenced phone is never something a device registration turns on by itself.
20
+ */
21
+ export function parseCriticalAlertFlag(raw) {
22
+ return raw === true || raw === "true";
23
+ }
24
+ /*
25
+ * On the toggle route the caller is stating an intent, so an unrecognised
26
+ * value is refused rather than read as false. Quietly storing "off" for a
27
+ * client that meant "on" leaves a responder believing their phone will ring
28
+ * while it will not, and nothing surfaces the mistake until a missed page.
29
+ */
30
+ export function parseCriticalAlertFlagStrict(raw) {
31
+ if (raw === true || raw === "true") {
32
+ return true;
33
+ }
34
+ if (raw === false || raw === "false") {
35
+ return false;
36
+ }
37
+ throw new BadDataException("isEnabled must be either true or false.");
38
+ }
14
39
  function getAuthenticatedUserId(req) {
15
40
  var _a;
16
41
  const userId = (_a = req
@@ -63,6 +88,14 @@ export default class UserPushAPI extends BaseAPI {
63
88
  userPush.deviceType = req.body.deviceType;
64
89
  userPush.deviceName = req.body.deviceName || "Unknown Device";
65
90
  userPush.isVerified = true; // Web, iOS, and Android devices are verified immediately
91
+ /*
92
+ * The mobile app sends this when the responder already had critical
93
+ * alerts on and the device is re-registering (a reinstall, a new push
94
+ * token, a second project). Absent, it stays off: overriding a
95
+ * silenced phone is never something a registration turns on by
96
+ * itself.
97
+ */
98
+ userPush.isCriticalAlertEnabled = parseCriticalAlertFlag(req.body.isCriticalAlertEnabled);
66
99
  const savedDevice = await this.service.create({
67
100
  data: userPush,
68
101
  props: {
@@ -139,6 +172,7 @@ export default class UserPushAPI extends BaseAPI {
139
172
  deviceType: true,
140
173
  isVerified: true,
141
174
  projectId: true,
175
+ isCriticalAlertEnabled: true,
142
176
  },
143
177
  });
144
178
  if (!device) {
@@ -153,13 +187,27 @@ export default class UserPushAPI extends BaseAPI {
153
187
  }
154
188
  try {
155
189
  // Send test notification
190
+ const isCriticalAlert = Boolean(device.isCriticalAlertEnabled);
191
+ /*
192
+ * A test that behaves unlike the real page is not a test of
193
+ * anything. Critical alerts are the one setting whose effect a
194
+ * responder cannot check by reasoning about it - they have to
195
+ * silence the phone and hear it ring - so a device with the option
196
+ * on gets a test that overrides silent mode exactly as a 3am page
197
+ * would.
198
+ */
156
199
  const testMessage = PushNotificationUtil.createGenericNotification({
157
- title: "Test Notification from OneUptime",
158
- body: "This is a test notification to verify your device is working correctly.",
200
+ title: isCriticalAlert
201
+ ? "Test Critical Alert from OneUptime"
202
+ : "Test Notification from OneUptime",
203
+ body: isCriticalAlert
204
+ ? "This is a test critical alert. If your device is silenced or in Do Not Disturb and you heard this, on-call pages will reach you."
205
+ : "This is a test notification to verify your device is working correctly.",
159
206
  clickAction: "/dashboard",
160
207
  tag: "test-notification",
161
208
  requireInteraction: false,
162
209
  });
210
+ testMessage.isCriticalAlert = isCriticalAlert;
163
211
  await PushNotificationService.sendPushNotification({
164
212
  devices: [
165
213
  Object.assign({ token: device.deviceToken }, (device.deviceName && {
@@ -186,6 +234,51 @@ export default class UserPushAPI extends BaseAPI {
186
234
  return next(error);
187
235
  }
188
236
  });
237
+ /*
238
+ * Turn "ring me through silent mode" on or off for this handset.
239
+ *
240
+ * A dedicated route rather than the generic CRUD update, for the same
241
+ * reason verify/unverify are: UserPush grants no update permission to
242
+ * anybody, so every write to it passes an explicit ownership check first
243
+ * and then runs as root. That keeps the set of things that can change a
244
+ * responder's paging configuration short and readable.
245
+ *
246
+ * Keyed on the device token, like unregister and unlike verify: the mobile
247
+ * app knows its own push token and holds no row ids, and one phone has a
248
+ * row per project it is registered against.
249
+ */
250
+ this.router.post(`/user-push/critical-alerts`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
251
+ try {
252
+ req = req;
253
+ const userId = getAuthenticatedUserId(req);
254
+ if (!req.body.deviceToken) {
255
+ return Response.sendErrorResponse(req, res, new BadDataException("Device token is required"));
256
+ }
257
+ /*
258
+ * Required rather than defaulted. A request that forgot the field
259
+ * would otherwise silently turn the setting OFF, and a responder
260
+ * whose pages stopped overriding Do Not Disturb has no way to notice
261
+ * until the page they missed.
262
+ */
263
+ if (req.body.isEnabled === undefined || req.body.isEnabled === null) {
264
+ return Response.sendErrorResponse(req, res, new BadDataException("isEnabled is required"));
265
+ }
266
+ const isEnabled = parseCriticalAlertFlagStrict(req.body.isEnabled);
267
+ const updatedCount = await this.service.setCriticalAlertEnabledForDeviceToken({
268
+ userId: userId,
269
+ deviceToken: req.body.deviceToken,
270
+ isEnabled: isEnabled,
271
+ });
272
+ return Response.sendJsonObjectResponse(req, res, {
273
+ success: true,
274
+ isCriticalAlertEnabled: isEnabled,
275
+ devicesUpdated: updatedCount,
276
+ });
277
+ }
278
+ catch (error) {
279
+ return next(error);
280
+ }
281
+ });
189
282
  this.router.post(`/user-push/:deviceId/verify`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
190
283
  var _a;
191
284
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"UserPushAPI.js","sourceRoot":"","sources":["../../../../Server/API/UserPushAPI.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAC7D,OAAO,eAEN,MAAM,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,MAAM,yCAAyC,CAAC;AAClF,OAAO,uBAAuB,MAAM,qCAAqC,CAAC;AAC1E,OAAO,oBAAoB,MAAM,+BAA+B,CAAC;AACjE,OAAO,MAAM,EAAE,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAOtE,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,gBAAgB,MAAM,wCAAwC,CAAC;AACtE,OAAO,yBAAyB,MAAM,iDAAiD,CAAC;AACxF,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,cAAc,MAAM,6CAA6C,CAAC;AACzE,OAAO,QAAQ,MAAM,sCAAsC,CAAC;AAG5D,SAAS,sBAAsB,CAAC,GAAmB;;IACjD,MAAM,MAAM,GAAyB,MAAC,GAAwB;SAC3D,iBAAiB,0CAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,yBAAyB,CACjC,+CAA+C,CAChD,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAGxC;IACC;QACE,KAAK,CAAC,QAA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,OAAO,QAAQ,CAAC,iBAAiB,CAC/B,GAAG,EACH,GAAG,EACH,IAAI,gBAAgB,CAAC,uBAAuB,CAAC,CAC9C,CAAC;gBACJ,CAAC;gBAED,MAAM,MAAM,GAAoB,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;oBAC7D,EAAE,EAAE,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;oBACxC,KAAK,EAAE;wBACL,MAAM,EAAE,IAAI;qBACb;oBACD,MAAM,EAAE;wBACN,MAAM,EAAE,IAAI;qBACb;iBACF,CAAC,CAAC;gBAEH,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,OAAO,QAAQ,CAAC,iBAAiB,CAC/B,GAAG,EACH,GAAG,EACH,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,CACzC,CAAC;gBACJ,CAAC;gBAED,kDAAkD;gBAClD,IAAI,CAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,QAAQ,EAAE,MAAK,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;oBACpD,OAAO,QAAQ,CAAC,iBAAiB,CAC/B,GAAG,EACH,GAAG,EACH,IAAI,gBAAgB,CAAC,+BAA+B,CAAC,CACtD,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,GAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAE1D,OAAO,QAAQ,CAAC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -1,17 +1,35 @@
1
1
  import UserMiddleware from "../Middleware/UserAuthorization";
2
+ import VerificationCodeRateLimit, { VerificationCodeRateLimitBucket, } from "../Middleware/VerificationCodeRateLimit";
2
3
  import UserSMSService from "../Services/UserSmsService";
3
- import UserNotificationRuleService from "../Services/UserNotificationRuleService";
4
+ import ChannelVerification, { ChannelVerificationOutcome, } from "../Utils/ChannelVerification";
4
5
  import Response from "../Utils/Response";
5
- import logger, { getLogAttributesFromRequest } from "../Utils/Logger";
6
6
  import BaseAPI from "./BaseAPI";
7
7
  import BadDataException from "../../Types/Exception/BadDataException";
8
8
  import ObjectID from "../../Types/ObjectID";
9
9
  import UserSMS from "../../Models/DatabaseModels/UserSMS";
10
+ import UserNotificationRuleService from "../Services/UserNotificationRuleService";
11
+ import logger, { getLogAttributesFromRequest } from "../Utils/Logger";
12
+ /*
13
+ * The verify and resend routes for this notification channel.
14
+ *
15
+ * Neither the checking of a submitted code nor the issuing of a new one lives
16
+ * here, on purpose. The state machine is shared by all five channels
17
+ * (Common/Server/Utils/ChannelVerification.ts) so that a control added for one
18
+ * of them cannot quietly go missing on another — which is exactly what went
19
+ * wrong before: five hand-written copies of "compare the column, set
20
+ * isVerified", none of which expired the code, counted attempts, or refused a
21
+ * caller running the comparison a million times against somebody else's phone
22
+ * number.
23
+ *
24
+ * What is left here is the HTTP shape: reject malformed bodies, run the rate
25
+ * limiter before anything costs a database read, and turn the outcome into a
26
+ * response.
27
+ */
10
28
  export default class UserSMSAPI extends BaseAPI {
11
29
  constructor() {
12
30
  super(UserSMS, UserSMSService);
13
- this.router.post(`/user-sms/verify`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
14
- var _a, _b, _c;
31
+ this.router.post(`/user-sms/verify`, UserMiddleware.getUserMiddleware, VerificationCodeRateLimit.getMiddleware(VerificationCodeRateLimitBucket.Verify), async (req, res, next) => {
32
+ var _a;
15
33
  try {
16
34
  req = req;
17
35
  if (!req.body.itemId) {
@@ -20,45 +38,26 @@ export default class UserSMSAPI extends BaseAPI {
20
38
  if (!req.body.code) {
21
39
  return Response.sendErrorResponse(req, res, new BadDataException("Invalid code"));
22
40
  }
23
- // Check if the code matches and verify the phone number.
24
- const item = await this.service.findOneById({
25
- id: req.body["itemId"],
26
- props: {
27
- isRoot: true,
28
- },
29
- select: {
30
- userId: true,
31
- projectId: true,
32
- verificationCode: true,
33
- },
34
- });
35
- if (!item) {
36
- return Response.sendErrorResponse(req, res, new BadDataException("Item not found"));
37
- }
38
- //check user id
39
- if (((_a = item.userId) === null || _a === void 0 ? void 0 : _a.toString()) !==
40
- ((_c = (_b = req === null || req === void 0 ? void 0 : req.userAuthorization) === null || _b === void 0 ? void 0 : _b.userId) === null || _c === void 0 ? void 0 : _c.toString())) {
41
+ const userId = (_a = req === null || req === void 0 ? void 0 : req.userAuthorization) === null || _a === void 0 ? void 0 : _a.userId;
42
+ if (!userId) {
41
43
  return Response.sendErrorResponse(req, res, new BadDataException("Invalid user ID"));
42
44
  }
43
- if (item.verificationCode !== req.body["code"]) {
44
- return Response.sendErrorResponse(req, res, new BadDataException("Invalid code"));
45
- }
46
- await this.service.updateOneById({
47
- id: item.id,
48
- props: {
49
- isRoot: true,
50
- },
51
- data: {
52
- isVerified: true,
53
- },
45
+ const result = await ChannelVerification.verifyCode({
46
+ service: this.service,
47
+ itemId: new ObjectID(req.body["itemId"].toString()),
48
+ userId: userId,
49
+ code: req.body["code"].toString(),
54
50
  });
55
- // Create default notification rules for this verified SMS
51
+ if (result.outcome !== ChannelVerificationOutcome.Verified) {
52
+ return Response.sendErrorResponse(req, res, ChannelVerification.getFailureException(result.outcome));
53
+ }
54
+ /* Create default notification rules for this verified SMS number */
56
55
  try {
57
56
  await UserNotificationRuleService.addDefaultNotificationRulesForVerifiedMethod({
58
- projectId: new ObjectID(item.projectId.toString()),
59
- userId: new ObjectID(item.userId.toString()),
57
+ projectId: new ObjectID(result.projectId.toString()),
58
+ userId: new ObjectID(result.userId.toString()),
60
59
  notificationMethod: {
61
- userSmsId: item.id,
60
+ userSmsId: result.itemId,
62
61
  },
63
62
  });
64
63
  }
@@ -71,7 +70,7 @@ export default class UserSMSAPI extends BaseAPI {
71
70
  return next(err);
72
71
  }
73
72
  });
74
- this.router.post(`/user-sms/resend-verification-code`, UserMiddleware.getUserMiddleware, async (req, res, next) => {
73
+ this.router.post(`/user-sms/resend-verification-code`, UserMiddleware.getUserMiddleware, VerificationCodeRateLimit.getMiddleware(VerificationCodeRateLimitBucket.Resend), async (req, res, next) => {
75
74
  var _a, _b, _c;
76
75
  try {
77
76
  req = req;
@@ -90,6 +89,11 @@ export default class UserSMSAPI extends BaseAPI {
90
89
  if (!item) {
91
90
  return Response.sendErrorResponse(req, res, new BadDataException("Item not found"));
92
91
  }
92
+ /*
93
+ * A caller may only ask for a code to be sent to a row they own.
94
+ * Without this the resend route is a way to make somebody else's
95
+ * device ring on demand.
96
+ */
93
97
  if (((_a = item.userId) === null || _a === void 0 ? void 0 : _a.toString()) !==
94
98
  ((_c = (_b = req === null || req === void 0 ? void 0 : req.userAuthorization) === null || _b === void 0 ? void 0 : _b.userId) === null || _c === void 0 ? void 0 : _c.toString())) {
95
99
  return Response.sendErrorResponse(req, res, new BadDataException("Invalid user ID"));