@northern.tech/store 0.30.2 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/dist/actions.d.cts +16 -7
  2. package/dist/actions.d.ts +16 -7
  3. package/dist/api/general-api.cjs +2 -2
  4. package/dist/api/general-api.cjs.map +1 -1
  5. package/dist/api/general-api.js.map +1 -1
  6. package/dist/api/users-api.cjs +1 -1
  7. package/dist/api/users-api.cjs.map +1 -1
  8. package/dist/api/users-api.js.map +1 -1
  9. package/dist/appSlice/constants.cjs +6 -1
  10. package/dist/appSlice/constants.cjs.map +1 -1
  11. package/dist/appSlice/constants.d.cts +1 -1
  12. package/dist/appSlice/constants.d.ts +1 -1
  13. package/dist/appSlice/constants.js +7 -2
  14. package/dist/appSlice/constants.js.map +1 -1
  15. package/dist/appSlice/index.cjs.map +1 -1
  16. package/dist/appSlice/index.d.cts +1 -1
  17. package/dist/appSlice/index.d.ts +1 -1
  18. package/dist/appSlice/index.js.map +1 -1
  19. package/dist/appSlice/mocks.d.cts +1 -1
  20. package/dist/appSlice/mocks.d.ts +1 -1
  21. package/dist/appSlice/selectors.d.cts +7 -7
  22. package/dist/appSlice/selectors.d.ts +7 -7
  23. package/dist/appSlice/thunks.d.cts +2 -2
  24. package/dist/appSlice/thunks.d.ts +2 -2
  25. package/dist/auth.cjs +1 -1
  26. package/dist/auth.cjs.map +1 -1
  27. package/dist/auth.d.cts +1 -1
  28. package/dist/auth.d.ts +1 -1
  29. package/dist/auth.js.map +1 -1
  30. package/dist/commonConstants.d.cts +1 -1
  31. package/dist/commonConstants.d.ts +1 -1
  32. package/dist/commonSelectors.cjs +1 -1
  33. package/dist/commonSelectors.cjs.map +1 -1
  34. package/dist/commonSelectors.d.cts +10 -10
  35. package/dist/commonSelectors.d.ts +10 -10
  36. package/dist/commonSelectors.js.map +1 -1
  37. package/dist/{constants-DPLHhjVN.d.cts → constants-BFTS6mge.d.cts} +6 -1
  38. package/dist/{constants-C5AU0mCY.d.ts → constants-BIIEMVoG.d.ts} +6 -1
  39. package/dist/{constants-MPLfugsi.d.cts → constants-BrGIx40B.d.cts} +3 -3
  40. package/dist/{constants-DrwXHsJ1.d.ts → constants-CjO3_FOH.d.ts} +3 -3
  41. package/dist/constants.cjs +1 -0
  42. package/dist/constants.cjs.map +1 -1
  43. package/dist/constants.d.cts +3 -3
  44. package/dist/constants.d.ts +3 -3
  45. package/dist/constants.js +2 -2
  46. package/dist/constants.js.map +1 -1
  47. package/dist/deploymentsSlice/index.cjs.map +1 -1
  48. package/dist/deploymentsSlice/index.js.map +1 -1
  49. package/dist/deploymentsSlice/selectors.cjs.map +1 -1
  50. package/dist/deploymentsSlice/selectors.d.cts +7 -7
  51. package/dist/deploymentsSlice/selectors.d.ts +7 -7
  52. package/dist/deploymentsSlice/selectors.js.map +1 -1
  53. package/dist/deploymentsSlice/thunks.d.cts +4 -4
  54. package/dist/deploymentsSlice/thunks.d.ts +4 -4
  55. package/dist/devicesSlice/constants.d.cts +1 -1
  56. package/dist/devicesSlice/constants.d.ts +1 -1
  57. package/dist/devicesSlice/index.cjs.map +1 -1
  58. package/dist/devicesSlice/index.d.cts +1 -1
  59. package/dist/devicesSlice/index.d.ts +1 -1
  60. package/dist/devicesSlice/index.js.map +1 -1
  61. package/dist/devicesSlice/selectors.cjs.map +1 -1
  62. package/dist/devicesSlice/selectors.d.cts +7 -7
  63. package/dist/devicesSlice/selectors.d.ts +7 -7
  64. package/dist/devicesSlice/selectors.js.map +1 -1
  65. package/dist/devicesSlice/thunks.d.cts +4 -4
  66. package/dist/devicesSlice/thunks.d.ts +4 -4
  67. package/dist/{index-Lz5JsJ6O.d.cts → index-B64X5ozM.d.cts} +2 -2
  68. package/dist/{index-4eaLEXy_.d.cts → index-BFlHWzjv.d.cts} +2 -2
  69. package/dist/{index-DqyY6oZ3.d.ts → index-BI9O8JWe.d.ts} +2 -2
  70. package/dist/{index-Bwx9jEiL.d.cts → index-BbaS7MzW.d.cts} +2 -2
  71. package/dist/{index-Dv3Hfxk_.d.ts → index-Bp1WpATs.d.ts} +2 -2
  72. package/dist/{index-FyYBBeN-.d.cts → index-C-q632wO.d.cts} +41 -8
  73. package/dist/{index-DJSlDPRX.d.ts → index-C6wNUfiV.d.ts} +2 -2
  74. package/dist/{index-BEVkIiNa.d.cts → index-CT5hgXm9.d.cts} +2 -2
  75. package/dist/{index-Cvkvcz4r.d.ts → index-CyokFK2e.d.ts} +41 -8
  76. package/dist/{index-CO-py5d4.d.ts → index-DUvrw_Ed.d.ts} +2 -2
  77. package/dist/{index-CTt-eIY8.d.cts → index-DwACbyUg.d.cts} +2 -2
  78. package/dist/{index-DtePEQPT.d.ts → index-ez3oxfRo.d.ts} +2 -2
  79. package/dist/liststatehook.cjs +5 -3
  80. package/dist/liststatehook.cjs.map +1 -1
  81. package/dist/liststatehook.js +5 -3
  82. package/dist/liststatehook.js.map +1 -1
  83. package/dist/locationutils.cjs +3 -0
  84. package/dist/locationutils.cjs.map +1 -1
  85. package/dist/locationutils.d.cts +3 -2
  86. package/dist/locationutils.d.ts +3 -2
  87. package/dist/locationutils.js +3 -0
  88. package/dist/locationutils.js.map +1 -1
  89. package/dist/monitorSlice/constants.d.cts +1 -1
  90. package/dist/monitorSlice/constants.d.ts +1 -1
  91. package/dist/monitorSlice/index.cjs.map +1 -1
  92. package/dist/monitorSlice/index.d.cts +1 -1
  93. package/dist/monitorSlice/index.d.ts +1 -1
  94. package/dist/monitorSlice/index.js.map +1 -1
  95. package/dist/monitorSlice/mocks.cjs.map +1 -1
  96. package/dist/monitorSlice/mocks.d.cts +1 -1
  97. package/dist/monitorSlice/mocks.d.ts +1 -1
  98. package/dist/monitorSlice/mocks.js.map +1 -1
  99. package/dist/monitorSlice/selectors.d.cts +1 -1
  100. package/dist/monitorSlice/selectors.d.ts +1 -1
  101. package/dist/monitorSlice/thunks.cjs.map +1 -1
  102. package/dist/monitorSlice/thunks.d.cts +4 -4
  103. package/dist/monitorSlice/thunks.d.ts +4 -4
  104. package/dist/monitorSlice/thunks.js.map +1 -1
  105. package/dist/onboardingSlice/index.cjs.map +1 -1
  106. package/dist/onboardingSlice/index.js.map +1 -1
  107. package/dist/onboardingSlice/mocks.cjs.map +1 -1
  108. package/dist/onboardingSlice/selectors.d.cts +1 -1
  109. package/dist/onboardingSlice/selectors.d.ts +1 -1
  110. package/dist/onboardingSlice/thunks.d.cts +2 -2
  111. package/dist/onboardingSlice/thunks.d.ts +2 -2
  112. package/dist/organizationSlice/index.cjs.map +1 -1
  113. package/dist/organizationSlice/index.d.cts +1 -1
  114. package/dist/organizationSlice/index.d.ts +1 -1
  115. package/dist/organizationSlice/index.js.map +1 -1
  116. package/dist/organizationSlice/mocks.d.cts +2 -2
  117. package/dist/organizationSlice/mocks.d.ts +2 -2
  118. package/dist/organizationSlice/selectors.cjs.map +1 -1
  119. package/dist/organizationSlice/selectors.d.cts +8 -8
  120. package/dist/organizationSlice/selectors.d.ts +8 -8
  121. package/dist/organizationSlice/selectors.js.map +1 -1
  122. package/dist/organizationSlice/thunks.d.cts +5 -5
  123. package/dist/organizationSlice/thunks.d.ts +5 -5
  124. package/dist/organizationSlice/types.d.cts +1 -1
  125. package/dist/organizationSlice/types.d.ts +1 -1
  126. package/dist/releasesSlice/index.cjs +63 -2
  127. package/dist/releasesSlice/index.cjs.map +1 -1
  128. package/dist/releasesSlice/index.d.cts +2 -2
  129. package/dist/releasesSlice/index.d.ts +2 -2
  130. package/dist/releasesSlice/index.js +63 -2
  131. package/dist/releasesSlice/index.js.map +1 -1
  132. package/dist/releasesSlice/mocks.cjs +34 -0
  133. package/dist/releasesSlice/mocks.cjs.map +1 -1
  134. package/dist/releasesSlice/mocks.d.cts +44 -1
  135. package/dist/releasesSlice/mocks.d.ts +44 -1
  136. package/dist/releasesSlice/mocks.js +34 -0
  137. package/dist/releasesSlice/mocks.js.map +1 -1
  138. package/dist/releasesSlice/selectors.cjs +37 -5
  139. package/dist/releasesSlice/selectors.cjs.map +1 -1
  140. package/dist/releasesSlice/selectors.d.cts +403 -15
  141. package/dist/releasesSlice/selectors.d.ts +403 -15
  142. package/dist/releasesSlice/selectors.js +27 -6
  143. package/dist/releasesSlice/selectors.js.map +1 -1
  144. package/dist/releasesSlice/thunks.cjs +210 -2
  145. package/dist/releasesSlice/thunks.cjs.map +1 -1
  146. package/dist/releasesSlice/thunks.d.cts +144 -10
  147. package/dist/releasesSlice/thunks.d.ts +144 -10
  148. package/dist/releasesSlice/thunks.js +201 -4
  149. package/dist/releasesSlice/thunks.js.map +1 -1
  150. package/dist/selectors.cjs +11 -0
  151. package/dist/selectors.d.cts +2 -2
  152. package/dist/selectors.d.ts +2 -2
  153. package/dist/selectors.js +2 -2
  154. package/dist/sockethook.cjs +2 -2
  155. package/dist/sockethook.cjs.map +1 -1
  156. package/dist/sockethook.js.map +1 -1
  157. package/dist/{store-BQxOSRC1.d.ts → store-D-xvZXiY.d.ts} +7 -7
  158. package/dist/{store-BiIA0r0A.d.cts → store-b5cF2WB5.d.cts} +7 -7
  159. package/dist/store.cjs.map +1 -1
  160. package/dist/store.d.cts +2 -2
  161. package/dist/store.d.ts +2 -2
  162. package/dist/store.js.map +1 -1
  163. package/dist/storehooks.cjs +3 -3
  164. package/dist/storehooks.cjs.map +1 -1
  165. package/dist/storehooks.d.cts +2 -2
  166. package/dist/storehooks.d.ts +2 -2
  167. package/dist/storehooks.js.map +1 -1
  168. package/dist/thunks.cjs +22 -10
  169. package/dist/thunks.cjs.map +1 -1
  170. package/dist/thunks.d.cts +2 -2
  171. package/dist/thunks.d.ts +2 -2
  172. package/dist/thunks.js +8 -6
  173. package/dist/thunks.js.map +1 -1
  174. package/dist/{types-B2NRQLFw.d.ts → types-BPyM8Inu.d.ts} +3 -3
  175. package/dist/{types-ClEfo0dK.d.cts → types-COdPU2QQ.d.cts} +3 -3
  176. package/dist/useDeploymentDevice.cjs +1 -1
  177. package/dist/useDeploymentDevice.cjs.map +1 -1
  178. package/dist/useDeploymentDevice.js.map +1 -1
  179. package/dist/usersSlice/index.cjs.map +1 -1
  180. package/dist/usersSlice/index.d.cts +1 -1
  181. package/dist/usersSlice/index.d.ts +1 -1
  182. package/dist/usersSlice/index.js.map +1 -1
  183. package/dist/usersSlice/mocks.d.cts +1 -1
  184. package/dist/usersSlice/mocks.d.ts +1 -1
  185. package/dist/usersSlice/selectors.cjs.map +1 -1
  186. package/dist/usersSlice/selectors.d.cts +7 -7
  187. package/dist/usersSlice/selectors.d.ts +7 -7
  188. package/dist/usersSlice/selectors.js.map +1 -1
  189. package/dist/usersSlice/thunks.d.cts +4 -4
  190. package/dist/usersSlice/thunks.d.ts +4 -4
  191. package/dist/{utils-CO_CpGFP.d.ts → utils-CHBWS_tH.d.ts} +4 -4
  192. package/dist/{utils-CpPfqW0Q.d.cts → utils-Do9z5TL1.d.cts} +4 -4
  193. package/dist/utils.cjs.map +1 -1
  194. package/dist/utils.d.cts +1 -1
  195. package/dist/utils.d.ts +1 -1
  196. package/dist/utils.js.map +1 -1
  197. package/package.json +7 -7
@@ -10,6 +10,7 @@ const require_usersSlice_selectors = require("./usersSlice/selectors.cjs");
10
10
  const require_commonSelectors = require("./commonSelectors.cjs");
11
11
  exports.DEPLOYMENT_CUTOFF = require_deploymentsSlice_selectors.DEPLOYMENT_CUTOFF;
12
12
  exports.getAcceptedDevices = require_devicesSlice_selectors.getAcceptedDevices;
13
+ exports.getActiveTab = require_releasesSlice_selectors.getActiveTab;
13
14
  exports.getAppInitDone = require_appSlice_selectors.getAppInitDone;
14
15
  exports.getAttributesList = require_devicesSlice_selectors.getAttributesList;
15
16
  exports.getAuditLog = require_organizationSlice_selectors.getAuditLog;
@@ -64,6 +65,7 @@ exports.getGroups = require_devicesSlice_selectors.getGroups;
64
65
  exports.getGroupsById = require_devicesSlice_selectors.getGroupsById;
65
66
  exports.getGroupsByIdWithoutUngrouped = require_devicesSlice_selectors.getGroupsByIdWithoutUngrouped;
66
67
  exports.getHas2FA = require_usersSlice_selectors.getHas2FA;
68
+ exports.getHasManifests = require_releasesSlice_selectors.getHasManifests;
67
69
  exports.getHasReleases = require_releasesSlice_selectors.getHasReleases;
68
70
  exports.getHostAddress = require_appSlice_selectors.getHostAddress;
69
71
  exports.getHostedAnnouncement = require_appSlice_selectors.getHostedAnnouncement;
@@ -77,6 +79,11 @@ exports.getIsUploading = require_appSlice_selectors.getIsUploading;
77
79
  exports.getIssueCountsByType = require_monitorSlice_selectors.getIssueCountsByType;
78
80
  exports.getLimitMaxed = require_devicesSlice_selectors.getLimitMaxed;
79
81
  exports.getListedDevices = require_devicesSlice_selectors.getListedDevices;
82
+ exports.getManifestTags = require_releasesSlice_selectors.getManifestTags;
83
+ exports.getManifestTagsById = require_releasesSlice_selectors.getManifestTagsById;
84
+ exports.getManifestsById = require_releasesSlice_selectors.getManifestsById;
85
+ exports.getManifestsList = require_releasesSlice_selectors.getManifestsList;
86
+ exports.getManifestsListState = require_releasesSlice_selectors.getManifestsListState;
80
87
  exports.getMappedDeploymentSelection = require_deploymentsSlice_selectors.getMappedDeploymentSelection;
81
88
  exports.getMappedDevicesList = require_commonSelectors.getMappedDevicesList;
82
89
  exports.getOfflineThresholdSettings = require_usersSlice_selectors.getOfflineThresholdSettings;
@@ -105,11 +112,15 @@ exports.getSelectedDeviceAttribute = require_usersSlice_selectors.getSelectedDev
105
112
  exports.getSelectedGroup = require_devicesSlice_selectors.getSelectedGroup;
106
113
  exports.getSelectedGroupInfo = require_devicesSlice_selectors.getSelectedGroupInfo;
107
114
  exports.getSelectedJob = require_releasesSlice_selectors.getSelectedJob;
115
+ exports.getSelectedManifest = require_releasesSlice_selectors.getSelectedManifest;
116
+ exports.getSelectedManifests = require_releasesSlice_selectors.getSelectedManifests;
108
117
  exports.getSelectedRelease = require_releasesSlice_selectors.getSelectedRelease;
109
118
  exports.getSelectedReleases = require_releasesSlice_selectors.getSelectedReleases;
110
119
  exports.getSentryConfig = require_appSlice_selectors.getSentryConfig;
111
120
  exports.getShowSecurityAlert = require_commonSelectors.getShowSecurityAlert;
112
121
  exports.getSnackbar = require_appSlice_selectors.getSnackbar;
122
+ exports.getSoftwareTags = require_releasesSlice_selectors.getSoftwareTags;
123
+ exports.getSoftwareTagsById = require_releasesSlice_selectors.getSoftwareTagsById;
113
124
  exports.getSortedFilteringAttributes = require_devicesSlice_selectors.getSortedFilteringAttributes;
114
125
  exports.getSpLimits = require_organizationSlice_selectors.getSpLimits;
115
126
  exports.getSsoConfig = require_organizationSlice_selectors.getSsoConfig;
@@ -5,6 +5,6 @@ import { getAcceptedDevices, getAttributesList, getCombinedLimit, getDeviceById,
5
5
  import { getIssueCountsByType } from "./monitorSlice/selectors.cjs";
6
6
  import { getOnboarding } from "./onboardingSlice/selectors.cjs";
7
7
  import { getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogState, getBillingProfile, getCard, getDeviceTwinIntegrations, getDisabledTiers, getExternalIntegrations, getIsServiceProvider, getOrganization, getProducts, getSpLimits, getSsoConfig, getSubscription, getTenantListWithLimits, getTenantsList, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks } from "./organizationSlice/selectors.cjs";
8
- import { getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getHasReleases, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getSelectedJob, getSelectedRelease, getSelectedReleases, getUpdateTypes } from "./releasesSlice/selectors.cjs";
8
+ import { getActiveTab, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getHasManifests, getHasReleases, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSoftwareTags, getSoftwareTagsById, getUpdateTypes } from "./releasesSlice/selectors.cjs";
9
9
  import { getCurrentSession, getCurrentUser, getGlobalSettings, getGlobalSettingsInitialized, getHas2FA, getIdAttribute, getIsDarkMode, getOfflineThresholdSettings, getReadAllHelptips, getRolesById, getRolesInitialized, getRolesList, getSecurityAlertDismissedTimestamp, getSelectedDeviceAttribute, getTooltipsById, getTooltipsState, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList } from "./usersSlice/selectors.cjs";
10
- export { DEPLOYMENT_CUTOFF, getAcceptedDevices, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getFullVersionInformation, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasReleases, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks };
10
+ export { DEPLOYMENT_CUTOFF, getAcceptedDevices, getActiveTab, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getFullVersionInformation, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasManifests, getHasReleases, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSoftwareTags, getSoftwareTagsById, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks };
@@ -5,6 +5,6 @@ import { getAcceptedDevices, getAttributesList, getCombinedLimit, getDeviceById,
5
5
  import { getIssueCountsByType } from "./monitorSlice/selectors.js";
6
6
  import { getOnboarding } from "./onboardingSlice/selectors.js";
7
7
  import { getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogState, getBillingProfile, getCard, getDeviceTwinIntegrations, getDisabledTiers, getExternalIntegrations, getIsServiceProvider, getOrganization, getProducts, getSpLimits, getSsoConfig, getSubscription, getTenantListWithLimits, getTenantsList, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks } from "./organizationSlice/selectors.js";
8
- import { getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getHasReleases, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getSelectedJob, getSelectedRelease, getSelectedReleases, getUpdateTypes } from "./releasesSlice/selectors.js";
8
+ import { getActiveTab, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getHasManifests, getHasReleases, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSoftwareTags, getSoftwareTagsById, getUpdateTypes } from "./releasesSlice/selectors.js";
9
9
  import { getCurrentSession, getCurrentUser, getGlobalSettings, getGlobalSettingsInitialized, getHas2FA, getIdAttribute, getIsDarkMode, getOfflineThresholdSettings, getReadAllHelptips, getRolesById, getRolesInitialized, getRolesList, getSecurityAlertDismissedTimestamp, getSelectedDeviceAttribute, getTooltipsById, getTooltipsState, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList } from "./usersSlice/selectors.js";
10
- export { DEPLOYMENT_CUTOFF, getAcceptedDevices, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getFullVersionInformation, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasReleases, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks };
10
+ export { DEPLOYMENT_CUTOFF, getAcceptedDevices, getActiveTab, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getFullVersionInformation, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasManifests, getHasReleases, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSoftwareTags, getSoftwareTagsById, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks };
package/dist/selectors.js CHANGED
@@ -4,7 +4,7 @@ import { getAcceptedDevices, getAttributesList, getCombinedLimit, getDeviceById,
4
4
  import { getIssueCountsByType } from "./monitorSlice/selectors.js";
5
5
  import { getOnboarding } from "./onboardingSlice/selectors.js";
6
6
  import { getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogState, getBillingProfile, getCard, getDeviceTwinIntegrations, getDisabledTiers, getExternalIntegrations, getIsServiceProvider, getOrganization, getProducts, getSpLimits, getSsoConfig, getSubscription, getTenantListWithLimits, getTenantsList, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks } from "./organizationSlice/selectors.js";
7
- import { getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getHasReleases, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getSelectedJob, getSelectedRelease, getSelectedReleases, getUpdateTypes } from "./releasesSlice/selectors.js";
7
+ import { getActiveTab, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getHasManifests, getHasReleases, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSoftwareTags, getSoftwareTagsById, getUpdateTypes } from "./releasesSlice/selectors.js";
8
8
  import { getCurrentSession, getCurrentUser, getGlobalSettings, getGlobalSettingsInitialized, getHas2FA, getIdAttribute, getIsDarkMode, getOfflineThresholdSettings, getReadAllHelptips, getRolesById, getRolesInitialized, getRolesList, getSecurityAlertDismissedTimestamp, getSelectedDeviceAttribute, getTooltipsById, getTooltipsState, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList } from "./usersSlice/selectors.js";
9
9
  import { getAuditlogDevice, getAvailableIssueOptionsByType, getDemoDeviceAddress, getDeploymentRelease, getDeviceConfigDeployment, getDeviceReportsForUser, getFilterAttributes, getGroupNames, getIsEnterprise, getMappedDevicesList, getOnboardingState, getRelevantRoles, getSelectedDeploymentData, getShowSecurityAlert, getTenantCapabilities, getUserCapabilities, getUserRoles } from "./commonSelectors.js";
10
- export { DEPLOYMENT_CUTOFF, getAcceptedDevices, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getFullVersionInformation, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasReleases, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks };
10
+ export { DEPLOYMENT_CUTOFF, getAcceptedDevices, getActiveTab, getAppInitDone, getAttributesList, getAuditLog, getAuditLogEntry, getAuditLogSelectionState, getAuditlogDevice, getAuditlogState, getAvailableIssueOptionsByType, getBillingProfile, getCard, getCombinedLimit, getCommit, getCurrentSession, getCurrentUser, getDeltaJobById, getDeltaJobsById, getDeltaJobsListState, getDemoDeviceAddress, getDeploymentById, getDeploymentRelease, getDeploymentsById, getDeploymentsByStatus, getDeploymentsSelectionState, getDeviceById, getDeviceConfigDeployment, getDeviceCountsByStatus, getDeviceFilters, getDeviceIdentityAttributes, getDeviceLimitStats, getDeviceLimits, getDeviceListState, getDeviceReports, getDeviceReportsForUser, getDeviceTwinIntegrations, getDeviceTypes, getDevicesById, getDevicesByStatus, getDisabledTiers, getDocsVersion, getEnabledTiers, getExternalIntegrations, getFeatures, getFeedbackProbability, getFilterAttributes, getFilteringAttributes, getFullVersionInformation, getGlobalSettings, getGlobalSettingsInitialized, getGroupData, getGroupNames, getGroups, getGroupsById, getGroupsByIdWithoutUngrouped, getHas2FA, getHasManifests, getHasReleases, getHostAddress, getHostedAnnouncement, getIdAttribute, getIsDarkMode, getIsEnterprise, getIsFirstLogin, getIsPreview, getIsServiceProvider, getIsUploading, getIssueCountsByType, getLimitMaxed, getListedDevices, getManifestTags, getManifestTagsById, getManifestsById, getManifestsList, getManifestsListState, getMappedDeploymentSelection, getMappedDevicesList, getOfflineThresholdSettings, getOnboarding, getOnboardingState, getOrganization, getProducts, getReadAllHelptips, getRecaptchaKey, getRecentDeployments, getReleaseListState, getReleaseTags, getReleaseTagsById, getReleasesById, getReleasesList, getRelevantRoles, getRolesById, getRolesInitialized, getRolesList, getSearchState, getSearchedDevices, getSecurityAlertDismissedTimestamp, getSelectedDeploymentData, getSelectedDeploymentDeviceIds, getSelectedDeviceAttribute, getSelectedGroup, getSelectedGroupInfo, getSelectedJob, getSelectedManifest, getSelectedManifests, getSelectedRelease, getSelectedReleases, getSentryConfig, getShowSecurityAlert, getSnackbar, getSoftwareTags, getSoftwareTagsById, getSortedFilteringAttributes, getSpLimits, getSsoConfig, getStripeKey, getSubscription, getTenantCapabilities, getTenantListWithLimits, getTenantsList, getTooltipsById, getTooltipsState, getTrackerCode, getUpdateTypes, getUploads, getUserCapabilities, getUserRoles, getUserSettings, getUserSettingsInitialized, getUsersById, getUsersList, getVersionInformation, getWebhookEventInfo, getWebhookEventTotal, getWebhookEvents, getWebhooks };
@@ -3,10 +3,10 @@ const require_chunk = require("./chunk-CKQMccvm.cjs");
3
3
  const require_constants = require("./constants.cjs");
4
4
  let _northern_tech_utils_helpers = require("@northern.tech/utils/helpers");
5
5
  let universal_cookie = require("universal-cookie");
6
- universal_cookie = require_chunk.__toESM(universal_cookie);
6
+ universal_cookie = require_chunk.__toESM(universal_cookie, 1);
7
7
  let react = require("react");
8
8
  let msgpack5 = require("msgpack5");
9
- msgpack5 = require_chunk.__toESM(msgpack5);
9
+ msgpack5 = require_chunk.__toESM(msgpack5, 1);
10
10
  let _northern_tech_utils_constants = require("@northern.tech/utils/constants");
11
11
  //#region src/sockethook.ts
12
12
  const cookies = new universal_cookie.default();
@@ -1 +1 @@
1
- {"version":3,"file":"sockethook.cjs","names":["Cookies","MessageProtocols","MessageTypes","TIMEOUTS","apiUrl"],"sources":["../src/sockethook.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { blobToString, byteArrayToString } from '@northern.tech/utils/helpers';\nimport msgpack5 from 'msgpack5';\nimport Cookies from 'universal-cookie';\n\nimport { DEVICE_MESSAGE_PROTOCOLS as MessageProtocols, DEVICE_MESSAGE_TYPES as MessageTypes, TIMEOUTS, apiUrl } from './constants';\n\nconst cookies = new Cookies();\n\nconst MessagePack = msgpack5();\n\ntype UseSessionProps = {\n onClose: (event: CloseEvent) => void;\n onHealthCheckFailed: () => void;\n onMessageReceived: (body: Uint8Array) => void;\n onNotify: (message: string) => void;\n onOpen: (isOpen: boolean) => void;\n token: string;\n};\n\ntype MessageProps = {\n body?: Uint8Array;\n props: Record<string, string | number>;\n typ: string;\n};\n\ntype SessionWebSocket = WebSocket & { sessionId?: string };\n\ntype UseSessionReturn = [\n connect: (deviceId: string) => void,\n sendMessage: (message: MessageProps) => void,\n close: () => void,\n readyState: number,\n sessionId: string | undefined\n];\n\nexport const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify, onOpen, token }: UseSessionProps): UseSessionReturn => {\n const [sessionId, setSessionId] = useState<string | undefined>();\n const healthcheckTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const socketRef = useRef<SessionWebSocket | undefined>(undefined);\n const sendMessage = useCallback(({ typ, body, props }: MessageProps): void => {\n if (!socketRef.current) {\n return;\n }\n const proto_header = { proto: MessageProtocols.Shell, typ, sid: socketRef.current.sessionId, props };\n const encodedData = MessagePack.encode({ hdr: proto_header, body });\n socketRef.current.send(encodedData);\n }, []);\n\n const close = useCallback((): void => {\n if (!socketRef.current || socketRef.current?.readyState !== WebSocket.OPEN) {\n return;\n }\n sendMessage({ typ: MessageTypes.Stop, props: {} });\n socketRef.current.close();\n setSessionId(undefined);\n }, [sendMessage]);\n\n const healthcheckFailed = useCallback((): void => {\n onHealthCheckFailed();\n close();\n }, [close, onHealthCheckFailed]);\n\n const onSocketMessage = useCallback(\n (event: MessageEvent): Promise<void> =>\n blobToString(event.data).then((data: unknown) => {\n const {\n hdr: { props = {} as Record<string, string | number>, proto, sid, typ },\n body\n } = MessagePack.decode(data as Buffer) as {\n body: Uint8Array;\n hdr: { props: Record<string, string | number>; proto: number; sid: string; typ: string };\n };\n if (proto !== MessageProtocols.Shell) {\n return;\n }\n switch (typ) {\n case MessageTypes.New: {\n if (props.status == WebSocket.CLOSING) {\n onNotify(`Error: ${byteArrayToString(body as unknown as Buffer)}`);\n setSessionId(undefined);\n return close();\n } else {\n clearTimeout(healthcheckTimeout.current);\n healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * TIMEOUTS.oneSecond);\n if (socketRef.current) {\n socketRef.current.sessionId = sid;\n }\n return setSessionId(sid);\n }\n }\n case MessageTypes.Shell:\n return onMessageReceived(body);\n case MessageTypes.Stop:\n return close();\n case MessageTypes.Ping: {\n if (healthcheckTimeout.current) {\n clearTimeout(healthcheckTimeout.current);\n }\n sendMessage({ typ: MessageTypes.Pong, props: {} });\n const timeout = parseInt(props.timeout as string);\n if (timeout > 0) {\n healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * TIMEOUTS.oneSecond);\n }\n return;\n }\n default:\n break;\n }\n }),\n [close, healthcheckFailed, onMessageReceived, onNotify, sendMessage]\n );\n\n const onSocketError = useCallback(\n (error: Event): void => {\n onNotify(`WebSocket error: ${(error as ErrorEvent).message || 'Unknown error'}`);\n close();\n clearTimeout(healthcheckTimeout.current);\n },\n [close, onNotify]\n );\n\n const onSocketOpen = useCallback((): void => {\n sendMessage({ typ: MessageTypes.New, props: {} });\n onOpen(true);\n }, [onOpen, sendMessage]);\n\n const onSocketClose = useCallback(\n (e: CloseEvent): void => {\n console.log('closing');\n onClose(e);\n close();\n },\n [close, onClose]\n );\n\n const connect = useCallback(\n (deviceId: string): void => {\n const uri = `wss://${window.location.host}${apiUrl.v1}/deviceconnect/devices/${deviceId}/connect`;\n setSessionId(undefined);\n cookies.set('JWT', token, { path: '/', secure: true, sameSite: 'strict', maxAge: 5 });\n try {\n socketRef.current = new WebSocket(uri);\n } catch (error) {\n console.log(error);\n }\n },\n [token]\n );\n\n useEffect(() => {\n const currentSocket = socketRef.current;\n if (!currentSocket) {\n return;\n }\n\n currentSocket.addEventListener('close', onSocketClose);\n currentSocket.addEventListener('error', onSocketError);\n currentSocket.addEventListener('message', onSocketMessage);\n currentSocket.addEventListener('open', onSocketOpen);\n\n return () => {\n currentSocket.removeEventListener('close', onSocketClose);\n currentSocket.removeEventListener('error', onSocketError);\n currentSocket.removeEventListener('message', onSocketMessage);\n currentSocket.removeEventListener('open', onSocketOpen);\n };\n // eslint-disable-next-line react-hooks/refs\n }, [onSocketClose, onSocketError, onSocketMessage, onSocketOpen, socketRef.current?.readyState]);\n\n // eslint-disable-next-line react-hooks/refs\n return [connect, sendMessage, close, socketRef.current?.readyState ?? WebSocket.CLOSED, sessionId];\n};\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,UAAU,IAAIA,iBAAAA,SAAS;AAE7B,MAAM,eAAA,GAAA,SAAA,UAAwB;AA2B9B,MAAa,cAAc,EAAE,SAAS,qBAAqB,mBAAmB,UAAU,QAAQ,YAA+C;CAC7I,MAAM,CAAC,WAAW,iBAAA,GAAA,MAAA,WAA8C;CAChE,MAAM,sBAAA,GAAA,MAAA,QAAuE,KAAA,EAAU;CACvF,MAAM,aAAA,GAAA,MAAA,QAAiD,KAAA,EAAU;CACjE,MAAM,eAAA,GAAA,MAAA,cAA2B,EAAE,KAAK,MAAM,YAAgC;AAC5E,MAAI,CAAC,UAAU,QACb;EAEF,MAAM,eAAe;GAAE,OAAOC,kBAAAA,yBAAiB;GAAO;GAAK,KAAK,UAAU,QAAQ;GAAW;GAAO;EACpG,MAAM,cAAc,YAAY,OAAO;GAAE,KAAK;GAAc;GAAM,CAAC;AACnE,YAAU,QAAQ,KAAK,YAAY;IAClC,EAAE,CAAC;CAEN,MAAM,SAAA,GAAA,MAAA,mBAAgC;AACpC,MAAI,CAAC,UAAU,WAAW,UAAU,SAAS,eAAe,UAAU,KACpE;AAEF,cAAY;GAAE,KAAKC,kBAAAA,qBAAa;GAAM,OAAO,EAAE;GAAE,CAAC;AAClD,YAAU,QAAQ,OAAO;AACzB,eAAa,KAAA,EAAU;IACtB,CAAC,YAAY,CAAC;CAEjB,MAAM,qBAAA,GAAA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OUTS","apiUrl"],"sources":["../src/sockethook.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { blobToString, byteArrayToString } from '@northern.tech/utils/helpers';\nimport msgpack5 from 'msgpack5';\nimport Cookies from 'universal-cookie';\n\nimport { DEVICE_MESSAGE_PROTOCOLS as MessageProtocols, DEVICE_MESSAGE_TYPES as MessageTypes, TIMEOUTS, apiUrl } from './constants';\n\nconst cookies = new Cookies();\n\nconst MessagePack = msgpack5();\n\ntype UseSessionProps = {\n onClose: (event: CloseEvent) => void;\n onHealthCheckFailed: () => void;\n onMessageReceived: (body: Uint8Array) => void;\n onNotify: (message: string) => void;\n onOpen: (isOpen: boolean) => void;\n token: string;\n};\n\ntype MessageProps = {\n body?: Uint8Array;\n props: Record<string, string | number>;\n typ: string;\n};\n\ntype SessionWebSocket = WebSocket & { sessionId?: string };\n\ntype UseSessionReturn = [\n connect: (deviceId: string) => void,\n sendMessage: (message: MessageProps) => void,\n close: () => void,\n readyState: number,\n sessionId: string | undefined\n];\n\nexport const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify, onOpen, token }: UseSessionProps): UseSessionReturn => {\n const [sessionId, setSessionId] = useState<string | undefined>();\n const healthcheckTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const socketRef = useRef<SessionWebSocket | undefined>(undefined);\n const sendMessage = useCallback(({ typ, body, props }: MessageProps): void => {\n if (!socketRef.current) {\n return;\n }\n const proto_header = { proto: MessageProtocols.Shell, typ, sid: socketRef.current.sessionId, props };\n const encodedData = MessagePack.encode({ hdr: proto_header, body });\n socketRef.current.send(encodedData);\n }, []);\n\n const close = useCallback((): void => {\n if (!socketRef.current || socketRef.current?.readyState !== WebSocket.OPEN) {\n return;\n }\n sendMessage({ typ: MessageTypes.Stop, props: {} });\n socketRef.current.close();\n setSessionId(undefined);\n }, [sendMessage]);\n\n const healthcheckFailed = useCallback((): void => {\n onHealthCheckFailed();\n close();\n }, [close, onHealthCheckFailed]);\n\n const onSocketMessage = useCallback(\n (event: MessageEvent): Promise<void> =>\n blobToString(event.data).then((data: unknown) => {\n const {\n hdr: { props = {} as Record<string, string | number>, proto, sid, typ },\n body\n } = MessagePack.decode(data as Buffer) as {\n body: Uint8Array;\n hdr: { props: Record<string, string | number>; proto: number; sid: string; typ: string };\n };\n if (proto !== MessageProtocols.Shell) {\n return;\n }\n switch (typ) {\n case MessageTypes.New: {\n if (props.status == WebSocket.CLOSING) {\n onNotify(`Error: ${byteArrayToString(body as unknown as Buffer)}`);\n setSessionId(undefined);\n return close();\n } else {\n clearTimeout(healthcheckTimeout.current);\n healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * TIMEOUTS.oneSecond);\n if (socketRef.current) {\n socketRef.current.sessionId = sid;\n }\n return setSessionId(sid);\n }\n }\n case MessageTypes.Shell:\n return onMessageReceived(body);\n case MessageTypes.Stop:\n return close();\n case MessageTypes.Ping: {\n if (healthcheckTimeout.current) {\n clearTimeout(healthcheckTimeout.current);\n }\n sendMessage({ typ: MessageTypes.Pong, props: {} });\n const timeout = parseInt(props.timeout as string);\n if (timeout > 0) {\n healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * TIMEOUTS.oneSecond);\n }\n return;\n }\n default:\n break;\n }\n }),\n [close, healthcheckFailed, onMessageReceived, onNotify, sendMessage]\n );\n\n const onSocketError = useCallback(\n (error: Event): void => {\n onNotify(`WebSocket error: ${(error as ErrorEvent).message || 'Unknown error'}`);\n close();\n clearTimeout(healthcheckTimeout.current);\n },\n [close, onNotify]\n );\n\n const onSocketOpen = useCallback((): void => {\n sendMessage({ typ: MessageTypes.New, props: {} });\n onOpen(true);\n }, [onOpen, sendMessage]);\n\n const onSocketClose = useCallback(\n (e: CloseEvent): void => {\n console.log('closing');\n onClose(e);\n close();\n },\n [close, onClose]\n );\n\n const connect = useCallback(\n (deviceId: string): void => {\n const uri = `wss://${window.location.host}${apiUrl.v1}/deviceconnect/devices/${deviceId}/connect`;\n setSessionId(undefined);\n cookies.set('JWT', token, { path: '/', secure: true, sameSite: 'strict', maxAge: 5 });\n try {\n socketRef.current = new WebSocket(uri);\n } catch (error) {\n console.log(error);\n }\n },\n [token]\n );\n\n useEffect(() => {\n const currentSocket = socketRef.current;\n if (!currentSocket) {\n return;\n }\n\n currentSocket.addEventListener('close', onSocketClose);\n currentSocket.addEventListener('error', onSocketError);\n currentSocket.addEventListener('message', onSocketMessage);\n currentSocket.addEventListener('open', onSocketOpen);\n\n return () => {\n currentSocket.removeEventListener('close', onSocketClose);\n currentSocket.removeEventListener('error', onSocketError);\n currentSocket.removeEventListener('message', onSocketMessage);\n currentSocket.removeEventListener('open', onSocketOpen);\n };\n // eslint-disable-next-line react-hooks/refs\n }, [onSocketClose, onSocketError, onSocketMessage, onSocketOpen, socketRef.current?.readyState]);\n\n // eslint-disable-next-line react-hooks/refs\n return [connect, sendMessage, close, socketRef.current?.readyState ?? WebSocket.CLOSED, sessionId];\n};\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,UAAU,IAAIA,iBAAAA,SAAS;AAE7B,MAAM,eAAA,GAAA,SAAA,UAAwB;AA2B9B,MAAa,cAAc,EAAE,SAAS,qBAAqB,mBAAmB,UAAU,QAAQ,YAA+C;CAC7I,MAAM,CAAC,WAAW,iBAAA,GAAA,MAAA,WAA8C;CAChE,MAAM,sBAAA,GAAA,MAAA,QAAuE,KAAA,EAAU;CACvF,MAAM,aAAA,GAAA,MAAA,QAAiD,KAAA,EAAU;CACjE,MAAM,eAAA,GAAA,MAAA,cAA2B,E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AAU;EAChC,IAAI,CAAC,eACH;EAGF,cAAc,iBAAiB,SAAS,cAAc;EACtD,cAAc,iBAAiB,SAAS,cAAc;EACtD,cAAc,iBAAiB,WAAW,gBAAgB;EAC1D,cAAc,iBAAiB,QAAQ,aAAa;EAEpD,aAAa;GACX,cAAc,oBAAoB,SAAS,cAAc;GACzD,cAAc,oBAAoB,SAAS,cAAc;GACzD,cAAc,oBAAoB,WAAW,gBAAgB;GAC7D,cAAc,oBAAoB,QAAQ,aAAa;;IAGxD;EAAC;EAAe;EAAe;EAAiB;EAAc,UAAU,SAAS;EAAW,CAAC;CAGhG,OAAO;EAAC;EAAS;EAAa;EAAO,UAAU,SAAS,cAAc,UAAU;EAAQ;EAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"sockethook.js","names":["MessageProtocols","MessageTypes"],"sources":["../src/sockethook.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { blobToString, byteArrayToString } from '@northern.tech/utils/helpers';\nimport msgpack5 from 'msgpack5';\nimport Cookies from 'universal-cookie';\n\nimport { DEVICE_MESSAGE_PROTOCOLS as MessageProtocols, DEVICE_MESSAGE_TYPES as MessageTypes, TIMEOUTS, apiUrl } from './constants';\n\nconst cookies = new Cookies();\n\nconst MessagePack = msgpack5();\n\ntype UseSessionProps = {\n onClose: (event: CloseEvent) => void;\n onHealthCheckFailed: () => void;\n onMessageReceived: (body: Uint8Array) => void;\n onNotify: (message: string) => void;\n onOpen: (isOpen: boolean) => void;\n token: string;\n};\n\ntype MessageProps = {\n body?: Uint8Array;\n props: Record<string, string | number>;\n typ: string;\n};\n\ntype SessionWebSocket = WebSocket & { sessionId?: string };\n\ntype UseSessionReturn = [\n connect: (deviceId: string) => void,\n sendMessage: (message: MessageProps) => void,\n close: () => void,\n readyState: number,\n sessionId: string | undefined\n];\n\nexport const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify, onOpen, token }: UseSessionProps): UseSessionReturn => {\n const [sessionId, setSessionId] = useState<string | undefined>();\n const healthcheckTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const socketRef = useRef<SessionWebSocket | undefined>(undefined);\n const sendMessage = useCallback(({ typ, body, props }: MessageProps): void => {\n if (!socketRef.current) {\n return;\n }\n const proto_header = { proto: MessageProtocols.Shell, typ, sid: socketRef.current.sessionId, props };\n const encodedData = MessagePack.encode({ hdr: proto_header, body });\n socketRef.current.send(encodedData);\n }, []);\n\n const close = useCallback((): void => {\n if (!socketRef.current || socketRef.current?.readyState !== WebSocket.OPEN) {\n return;\n }\n sendMessage({ typ: MessageTypes.Stop, props: {} });\n socketRef.current.close();\n setSessionId(undefined);\n }, [sendMessage]);\n\n const healthcheckFailed = useCallback((): void => {\n onHealthCheckFailed();\n close();\n }, [close, onHealthCheckFailed]);\n\n const onSocketMessage = useCallback(\n (event: MessageEvent): Promise<void> =>\n blobToString(event.data).then((data: unknown) => {\n const {\n hdr: { props = {} as Record<string, string | number>, proto, sid, typ },\n body\n } = MessagePack.decode(data as Buffer) as {\n body: Uint8Array;\n hdr: { props: Record<string, string | number>; proto: number; sid: string; typ: string };\n };\n if (proto !== MessageProtocols.Shell) {\n return;\n }\n switch (typ) {\n case MessageTypes.New: {\n if (props.status == WebSocket.CLOSING) {\n onNotify(`Error: ${byteArrayToString(body as unknown as Buffer)}`);\n setSessionId(undefined);\n return close();\n } else {\n clearTimeout(healthcheckTimeout.current);\n healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * TIMEOUTS.oneSecond);\n if (socketRef.current) {\n socketRef.current.sessionId = sid;\n }\n return setSessionId(sid);\n }\n }\n case MessageTypes.Shell:\n return onMessageReceived(body);\n case MessageTypes.Stop:\n return close();\n case MessageTypes.Ping: {\n if (healthcheckTimeout.current) {\n clearTimeout(healthcheckTimeout.current);\n }\n sendMessage({ typ: MessageTypes.Pong, props: {} });\n const timeout = parseInt(props.timeout as string);\n if (timeout > 0) {\n healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * TIMEOUTS.oneSecond);\n }\n return;\n }\n default:\n break;\n }\n }),\n [close, healthcheckFailed, onMessageReceived, onNotify, sendMessage]\n );\n\n const onSocketError = useCallback(\n (error: Event): void => {\n onNotify(`WebSocket error: ${(error as ErrorEvent).message || 'Unknown error'}`);\n close();\n clearTimeout(healthcheckTimeout.current);\n },\n [close, onNotify]\n );\n\n const onSocketOpen = useCallback((): void => {\n sendMessage({ typ: MessageTypes.New, props: {} });\n onOpen(true);\n }, [onOpen, sendMessage]);\n\n const onSocketClose = useCallback(\n (e: CloseEvent): void => {\n console.log('closing');\n onClose(e);\n close();\n },\n [close, onClose]\n );\n\n const connect = useCallback(\n (deviceId: string): void => {\n const uri = `wss://${window.location.host}${apiUrl.v1}/deviceconnect/devices/${deviceId}/connect`;\n setSessionId(undefined);\n cookies.set('JWT', token, { path: '/', secure: true, sameSite: 'strict', maxAge: 5 });\n try {\n socketRef.current = new WebSocket(uri);\n } catch (error) {\n console.log(error);\n }\n },\n [token]\n );\n\n useEffect(() => {\n const currentSocket = socketRef.current;\n if (!currentSocket) {\n return;\n }\n\n currentSocket.addEventListener('close', onSocketClose);\n currentSocket.addEventListener('error', onSocketError);\n currentSocket.addEventListener('message', onSocketMessage);\n currentSocket.addEventListener('open', onSocketOpen);\n\n return () => {\n currentSocket.removeEventListener('close', onSocketClose);\n currentSocket.removeEventListener('error', onSocketError);\n currentSocket.removeEventListener('message', onSocketMessage);\n currentSocket.removeEventListener('open', onSocketOpen);\n };\n // eslint-disable-next-line react-hooks/refs\n }, [onSocketClose, onSocketError, onSocketMessage, onSocketOpen, socketRef.current?.readyState]);\n\n // eslint-disable-next-line react-hooks/refs\n return [connect, sendMessage, close, socketRef.current?.readyState ?? WebSocket.CLOSED, sessionId];\n};\n"],"mappings":";;;;;;AAqBA,MAAM,UAAU,IAAI,SAAS;AAE7B,MAAM,cAAc,UAAU;AA2B9B,MAAa,cAAc,EAAE,SAAS,qBAAqB,mBAAmB,UAAU,QAAQ,YAA+C;CAC7I,MAAM,CAAC,WAAW,gBAAgB,UAA8B;CAChE,MAAM,qBAAqB,OAAkD,KAAA,EAAU;CACvF,MAAM,YAAY,OAAqC,KAAA,EAAU;CACjE,MAAM,cAAc,aAAa,EAAE,KAAK,MAAM,YAAgC;AAC5E,MAAI,CAAC,UAAU,QACb;EAEF,MAAM,eAAe;GAAE,OAAOA,yBAAiB;GAAO;GAAK,KAAK,UAAU,QAAQ;GAAW;GAAO;EACpG,MAAM,cAAc,YAAY,OAAO;GAAE,KAAK;GAAc;GAAM,CAAC;AACnE,YAAU,QAAQ,KAAK,YAAY;IAClC,EAAE,CAAC;CAEN,MAAM,QAAQ,kBAAwB;AACpC,MAAI,CAAC,UAAU,WAAW,UAAU,SAAS,eAAe,UAAU,KACpE;AAEF,cAAY;GAAE,KAAKC,qBAAa;GAAM,OAAO,EAAE;GAAE,CAAC;AAClD,YAAU,QAAQ,OAAO;AACzB,eAAa,KAAA,EAAU;IACtB,CAAC,YAAY,CAAC;CAEjB,MAAM,oBAAoB,kBAAwB;AAChD,uBAAqB;AACrB,SAAO;IACN,CAAC,OAAO,oBAAoB,CAAC;CAEhC,MAAM,kBAAkB,aACrB,UACC,aAAa,MAAM,KAAK,CAAC,MAAM,SAAkB;EAC/C,MAAM,EACJ,KAAK,EAAE,QAAQ,EAAE,EAAqC,OAAO,KAAK,OAClE,SACE,YAAY,OAAO,KAAe;AAItC,MAAI,UAAUD,yBAAiB,MAC7B;AAEF,UAAQ,KAAR;GACE,KAAKC,qBAAa,IAChB,KAAI,MAAM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MAAM;GAAK,QAAQ;GAAM,UAAU;GAAU,QAAQ;GAAG,CAAC;AACrF,MAAI;AACF,aAAU,UAAU,IAAI,UAAU,IAAI;WAC/B,OAAO;AACd,WAAQ,IAAI,MAAM;;IAGtB,CAAC,MAAM,CACR;AAED,iBAAgB;EACd,MAAM,gBAAgB,UAAU;AAChC,MAAI,CAAC,cACH;AAGF,gBAAc,iBAAiB,SAAS,cAAc;AACtD,gBAAc,iBAAiB,SAAS,cAAc;AACtD,gBAAc,iBAAiB,WAAW,gBAAgB;AAC1D,gBAAc,iBAAiB,QAAQ,aAAa;AAEpD,eAAa;AACX,iBAAc,oBAAoB,SAAS,cAAc;AACzD,iBAAc,oBAAoB,SAAS,cAAc;AACzD,iBAAc,oBAAoB,WAAW,gBAAgB;AAC7D,iBAAc,oBAAoB,QAAQ,aAAa;;IAGxD;EAAC;EAAe;EAAe;EAAiB;EAAc,UAAU,SAAS;EAAW,CAAC;AAGhG,QAAO;EAAC;EAAS;EAAa;EAAO,UAAU,SAAS,cAAc,UAAU;EAAQ;EAAU"}
1
+ {"version":3,"file":"sockethook.js","names":["MessageProtocols","MessageTypes"],"sources":["../src/sockethook.ts"],"sourcesContent":["// Copyright 2022 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { blobToString, byteArrayToString } from '@northern.tech/utils/helpers';\nimport msgpack5 from 'msgpack5';\nimport Cookies from 'universal-cookie';\n\nimport { DEVICE_MESSAGE_PROTOCOLS as MessageProtocols, DEVICE_MESSAGE_TYPES as MessageTypes, TIMEOUTS, apiUrl } from './constants';\n\nconst cookies = new Cookies();\n\nconst MessagePack = msgpack5();\n\ntype UseSessionProps = {\n onClose: (event: CloseEvent) => void;\n onHealthCheckFailed: () => void;\n onMessageReceived: (body: Uint8Array) => void;\n onNotify: (message: string) => void;\n onOpen: (isOpen: boolean) => void;\n token: string;\n};\n\ntype MessageProps = {\n body?: Uint8Array;\n props: Record<string, string | number>;\n typ: string;\n};\n\ntype SessionWebSocket = WebSocket & { sessionId?: string };\n\ntype UseSessionReturn = [\n connect: (deviceId: string) => void,\n sendMessage: (message: MessageProps) => void,\n close: () => void,\n readyState: number,\n sessionId: string | undefined\n];\n\nexport const useSession = ({ onClose, onHealthCheckFailed, onMessageReceived, onNotify, onOpen, token }: UseSessionProps): UseSessionReturn => {\n const [sessionId, setSessionId] = useState<string | undefined>();\n const healthcheckTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const socketRef = useRef<SessionWebSocket | undefined>(undefined);\n const sendMessage = useCallback(({ typ, body, props }: MessageProps): void => {\n if (!socketRef.current) {\n return;\n }\n const proto_header = { proto: MessageProtocols.Shell, typ, sid: socketRef.current.sessionId, props };\n const encodedData = MessagePack.encode({ hdr: proto_header, body });\n socketRef.current.send(encodedData);\n }, []);\n\n const close = useCallback((): void => {\n if (!socketRef.current || socketRef.current?.readyState !== WebSocket.OPEN) {\n return;\n }\n sendMessage({ typ: MessageTypes.Stop, props: {} });\n socketRef.current.close();\n setSessionId(undefined);\n }, [sendMessage]);\n\n const healthcheckFailed = useCallback((): void => {\n onHealthCheckFailed();\n close();\n }, [close, onHealthCheckFailed]);\n\n const onSocketMessage = useCallback(\n (event: MessageEvent): Promise<void> =>\n blobToString(event.data).then((data: unknown) => {\n const {\n hdr: { props = {} as Record<string, string | number>, proto, sid, typ },\n body\n } = MessagePack.decode(data as Buffer) as {\n body: Uint8Array;\n hdr: { props: Record<string, string | number>; proto: number; sid: string; typ: string };\n };\n if (proto !== MessageProtocols.Shell) {\n return;\n }\n switch (typ) {\n case MessageTypes.New: {\n if (props.status == WebSocket.CLOSING) {\n onNotify(`Error: ${byteArrayToString(body as unknown as Buffer)}`);\n setSessionId(undefined);\n return close();\n } else {\n clearTimeout(healthcheckTimeout.current);\n healthcheckTimeout.current = setTimeout(healthcheckFailed, 65 * TIMEOUTS.oneSecond);\n if (socketRef.current) {\n socketRef.current.sessionId = sid;\n }\n return setSessionId(sid);\n }\n }\n case MessageTypes.Shell:\n return onMessageReceived(body);\n case MessageTypes.Stop:\n return close();\n case MessageTypes.Ping: {\n if (healthcheckTimeout.current) {\n clearTimeout(healthcheckTimeout.current);\n }\n sendMessage({ typ: MessageTypes.Pong, props: {} });\n const timeout = parseInt(props.timeout as string);\n if (timeout > 0) {\n healthcheckTimeout.current = setTimeout(healthcheckFailed, timeout * TIMEOUTS.oneSecond);\n }\n return;\n }\n default:\n break;\n }\n }),\n [close, healthcheckFailed, onMessageReceived, onNotify, sendMessage]\n );\n\n const onSocketError = useCallback(\n (error: Event): void => {\n onNotify(`WebSocket error: ${(error as ErrorEvent).message || 'Unknown error'}`);\n close();\n clearTimeout(healthcheckTimeout.current);\n },\n [close, onNotify]\n );\n\n const onSocketOpen = useCallback((): void => {\n sendMessage({ typ: MessageTypes.New, props: {} });\n onOpen(true);\n }, [onOpen, sendMessage]);\n\n const onSocketClose = useCallback(\n (e: CloseEvent): void => {\n console.log('closing');\n onClose(e);\n close();\n },\n [close, onClose]\n );\n\n const connect = useCallback(\n (deviceId: string): void => {\n const uri = `wss://${window.location.host}${apiUrl.v1}/deviceconnect/devices/${deviceId}/connect`;\n setSessionId(undefined);\n cookies.set('JWT', token, { path: '/', secure: true, sameSite: 'strict', maxAge: 5 });\n try {\n socketRef.current = new WebSocket(uri);\n } catch (error) {\n console.log(error);\n }\n },\n [token]\n );\n\n useEffect(() => {\n const currentSocket = socketRef.current;\n if (!currentSocket) {\n return;\n }\n\n currentSocket.addEventListener('close', onSocketClose);\n currentSocket.addEventListener('error', onSocketError);\n currentSocket.addEventListener('message', onSocketMessage);\n currentSocket.addEventListener('open', onSocketOpen);\n\n return () => {\n currentSocket.removeEventListener('close', onSocketClose);\n currentSocket.removeEventListener('error', onSocketError);\n currentSocket.removeEventListener('message', onSocketMessage);\n currentSocket.removeEventListener('open', onSocketOpen);\n };\n // eslint-disable-next-line react-hooks/refs\n }, [onSocketClose, onSocketError, onSocketMessage, onSocketOpen, socketRef.current?.readyState]);\n\n // eslint-disable-next-line react-hooks/refs\n return [connect, sendMessage, close, socketRef.current?.readyState ?? WebSocket.CLOSED, sessionId];\n};\n"],"mappings":";;;;;;AAqBA,MAAM,UAAU,IAAI,SAAS;AAE7B,MAAM,cAAc,UAAU;AA2B9B,MAAa,cAAc,EAAE,SAAS,qBAAqB,mBAAmB,UAAU,QAAQ,YAA+C;CAC7I,MAAM,CAAC,WAAW,gBAAgB,UAA8B;CAChE,MAAM,qBAAqB,OAAkD,KAAA,EAAU;CACvF,MAAM,YAAY,OAAqC,KAAA,EAAU;CACjE,MAAM,cAAc,aAAa,EAAE,KAAK,MAAM,YAAgC;EAC5E,IAAI,CAAC,UAAU,SACb;EAEF,MAAM,eAAe;GAAE,OAAOA,yBAAiB;GAAO;GAAK,KAAK,UAAU,QAAQ;GAAW;GAAO;EACpG,MAAM,cAAc,YAAY,OAAO;GAAE,KAAK;GAAc;GAAM,CAAC;EACnE,UAAU,QAAQ,KAAK,YAAY;IAClC,EAAE,CAAC;CAEN,MAAM,QAAQ,kBAAwB;EACpC,IAAI,CAAC,UAAU,WAAW,UAAU,SAAS,eAAe,UAAU,MACpE;EAEF,YAAY;GAAE,KAAKC,qBAAa;GAAM,OAAO,EAAE;GAAE,CAAC;EAClD,UAAU,QAAQ,OAAO;EACzB,aAAa,KAAA,EAAU;IACtB,CAAC,YAAY,CAAC;CAEjB,MAAM,oBAAoB,kBAAwB;EAChD,qBAAqB;EACrB,OAAO;IACN,CAAC,OAAO,oBAAoB,CAAC;CAEhC,MAAM,kBAAkB,aACrB,UACC,aAAa,MAAM,KAAK,CAAC,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O;IAET,CAAC,OAAO,QAAQ,CACjB;CAED,MAAM,UAAU,aACb,aAA2B;EAC1B,MAAM,MAAM,SAAS,OAAO,SAAS,OAAO,OAAO,GAAG,yBAAyB,SAAS;EACxF,aAAa,KAAA,EAAU;EACvB,QAAQ,IAAI,OAAO,OAAO;GAAE,MAAM;GAAK,QAAQ;GAAM,UAAU;GAAU,QAAQ;GAAG,CAAC;EACrF,IAAI;GACF,UAAU,UAAU,IAAI,UAAU,IAAI;WAC/B,OAAO;GACd,QAAQ,IAAI,MAAM;;IAGtB,CAAC,MAAM,CACR;CAED,gBAAgB;EACd,MAAM,gBAAgB,UAAU;EAChC,IAAI,CAAC,eACH;EAGF,cAAc,iBAAiB,SAAS,cAAc;EACtD,cAAc,iBAAiB,SAAS,cAAc;EACtD,cAAc,iBAAiB,WAAW,gBAAgB;EAC1D,cAAc,iBAAiB,QAAQ,aAAa;EAEpD,aAAa;GACX,cAAc,oBAAoB,SAAS,cAAc;GACzD,cAAc,oBAAoB,SAAS,cAAc;GACzD,cAAc,oBAAoB,WAAW,gBAAgB;GAC7D,cAAc,oBAAoB,QAAQ,aAAa;;IAGxD;EAAC;EAAe;EAAe;EAAiB;EAAc,UAAU,SAAS;EAAW,CAAC;CAGhG,OAAO;EAAC;EAAS;EAAa;EAAO,UAAU,SAAS,cAAc,UAAU;EAAQ;EAAU"}
@@ -1,11 +1,11 @@
1
- import { o as UserSliceType } from "./index-DtePEQPT.js";
2
- import { r as ReleaseSliceType } from "./index-Cvkvcz4r.js";
1
+ import { o as UserSliceType } from "./index-ez3oxfRo.js";
2
+ import { i as ReleaseSliceType } from "./index-CyokFK2e.js";
3
3
  import { n as OnboardingSliceType } from "./index-CJkrL0oA.js";
4
4
  import { o as DeploymentsSliceType } from "./index-CkwVnIqd.js";
5
- import { s as DeviceSliceType } from "./index-DqyY6oZ3.js";
6
- import { t as AppSliceType } from "./index-Dv3Hfxk_.js";
7
- import { t as MonitorSliceType } from "./index-CO-py5d4.js";
8
- import { t as OrganizationSliceType } from "./index-DJSlDPRX.js";
5
+ import { s as DeviceSliceType } from "./index-BI9O8JWe.js";
6
+ import { t as AppSliceType } from "./index-Bp1WpATs.js";
7
+ import { t as MonitorSliceType } from "./index-DUvrw_Ed.js";
8
+ import { t as OrganizationSliceType } from "./index-C6wNUfiV.js";
9
9
  import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
10
10
  import { Reducer, UnknownAction } from "@reduxjs/toolkit";
11
11
  import { TypedUseSelectorHook } from "react-redux";
@@ -231,4 +231,4 @@ declare const createAppAsyncThunk: _$_reduxjs_toolkit0.CreateAsyncThunkFunction<
231
231
  };
232
232
  //#endregion
233
233
  export { commonErrorHandler as a, sessionReducer as c, useAppSelector as d, commonErrorFallback as i, store as l, MenderEnvironment as n, createAppAsyncThunk as o, RootState as r, getConfiguredStore as s, AppDispatch as t, useAppDispatch as u };
234
- //# sourceMappingURL=store-BQxOSRC1.d.ts.map
234
+ //# sourceMappingURL=store-D-xvZXiY.d.ts.map
@@ -1,11 +1,11 @@
1
- import { o as UserSliceType } from "./index-4eaLEXy_.cjs";
2
- import { r as ReleaseSliceType } from "./index-FyYBBeN-.cjs";
1
+ import { o as UserSliceType } from "./index-BFlHWzjv.cjs";
2
+ import { i as ReleaseSliceType } from "./index-C-q632wO.cjs";
3
3
  import { n as OnboardingSliceType } from "./index-UPc3wvVd.cjs";
4
4
  import { o as DeploymentsSliceType } from "./index-BP0uAq36.cjs";
5
- import { s as DeviceSliceType } from "./index-Lz5JsJ6O.cjs";
6
- import { t as AppSliceType } from "./index-CTt-eIY8.cjs";
7
- import { t as MonitorSliceType } from "./index-BEVkIiNa.cjs";
8
- import { t as OrganizationSliceType } from "./index-Bwx9jEiL.cjs";
5
+ import { s as DeviceSliceType } from "./index-B64X5ozM.cjs";
6
+ import { t as AppSliceType } from "./index-DwACbyUg.cjs";
7
+ import { t as MonitorSliceType } from "./index-CT5hgXm9.cjs";
8
+ import { t as OrganizationSliceType } from "./index-BbaS7MzW.cjs";
9
9
  import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
10
10
  import { Reducer, UnknownAction } from "@reduxjs/toolkit";
11
11
  import * as _$redux from "redux";
@@ -231,4 +231,4 @@ declare const createAppAsyncThunk: _$_reduxjs_toolkit0.CreateAsyncThunkFunction<
231
231
  };
232
232
  //#endregion
233
233
  export { commonErrorHandler as a, sessionReducer as c, useAppSelector as d, commonErrorFallback as i, store as l, MenderEnvironment as n, createAppAsyncThunk as o, RootState as r, getConfiguredStore as s, AppDispatch as t, useAppDispatch as u };
234
- //# sourceMappingURL=store-BiIA0r0A.d.cts.map
234
+ //# sourceMappingURL=store-b5cF2WB5.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.cjs","names":["actions","settingsKeys","getToken","appSlice","deviceSlice","deploymentSlice","monitorSlice","onboardingSlice","organizationSlice","releaseSlice","userSlice","userActions","organizationActions","useDispatch","useSelector","createAsyncThunk"],"sources":["../src/store.ts"],"sourcesContent":["// Copyright 2019 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useDispatch, useSelector } from 'react-redux';\nimport type { TypedUseSelectorHook } from 'react-redux';\n\nimport { extractErrorMessage, preformatWithRequestID } from '@northern.tech/utils/helpers';\nimport type { Middleware, Reducer, UnknownAction } from '@reduxjs/toolkit';\nimport { combineReducers, configureStore, createAsyncThunk, isRejected } from '@reduxjs/toolkit';\nimport { createReduxEnhancer } from '@sentry/react';\n\nimport actions from './actions';\nimport appSlice from './appSlice';\nimport { getToken } from './auth';\nimport { USER_LOGOUT, settingsKeys } from './constants';\nimport deploymentSlice from './deploymentsSlice';\nimport deviceSlice from './devicesSlice';\nimport monitorSlice from './monitorSlice';\nimport onboardingSlice from './onboardingSlice';\nimport organizationSlice, { actions as organizationActions } from './organizationSlice';\nimport releaseSlice from './releasesSlice';\nimport userSlice, { actions as userActions } from './usersSlice';\n\nconst { setSnackbar, uploadProgress } = actions;\n\n// exclude 'pendings-redirect' since this is expected to persist refreshes - the rest should be better to be redone\nconst keys = ['sessionDeploymentChecker', settingsKeys.initialized];\nconst resetEnvironment = (): void => keys.forEach(key => window.sessionStorage.removeItem(key));\n\nresetEnvironment();\n\nexport type { ErrorWithResponse } from './utils';\n\nexport type MenderEnvironment = {\n [key: string]: unknown;\n demoArtifactPort?: string | number;\n disableOnboarding?: string;\n features: Record<string, string>;\n integrationVersion: string;\n menderArtifactVersion: string;\n metaMenderVersion: string;\n sentry?: { isReduxEnabled?: string | boolean };\n};\n\ndeclare global {\n interface Window {\n mender_environment?: MenderEnvironment;\n }\n}\n\nexport const commonErrorFallback = 'Please check your connection.';\nexport const commonErrorHandler = (\n err: { message?: string; response?: { data?: unknown } },\n errorContext: string,\n dispatch: AppDispatch,\n fallback?: string,\n mightBeAuthRelated = false\n): Promise<never> => {\n const errMsg = extractErrorMessage(err, fallback);\n if (mightBeAuthRelated || getToken()) {\n dispatch(setSnackbar({ message: preformatWithRequestID(err.response, `${errorContext} ${errMsg}`), action: 'Copy to clipboard' }));\n }\n return Promise.reject(err);\n};\n\nconst rootReducer = combineReducers({\n app: appSlice,\n devices: deviceSlice,\n deployments: deploymentSlice,\n monitor: monitorSlice,\n onboarding: onboardingSlice,\n organization: organizationSlice,\n releases: releaseSlice,\n users: userSlice\n});\n\ntype RootReducerState = ReturnType<typeof rootReducer>;\n\nconst sessionReducerImpl: Reducer<RootReducerState | undefined, UnknownAction> = (state, action) => {\n if (action.type === USER_LOGOUT) {\n state = undefined;\n }\n return rootReducer(state, action);\n};\n// Export for testing; cast to RootReducerState since undefined always falls through to initial slice states\nexport const sessionReducer = sessionReducerImpl as Reducer<RootReducerState>;\n\nconst rejectionLoggerMiddleware: Middleware = () => next => action => {\n if (isRejected(action)) {\n console.error('Rejection in action:', action);\n if (action.error) {\n console.error(action.error.stack);\n }\n }\n return next(action);\n};\n\nconst tracingActionIgnoreList = [userActions.successfullyLoggedIn.type, 'users/loginUser/pending', 'users/loginUser/fulfilled', 'users/loginUser/rejected'];\n\nconst sentryReduxEnhancer = createReduxEnhancer({\n actionTransformer: (action: UnknownAction) => {\n if (tracingActionIgnoreList.includes(action.type as string)) {\n return null;\n }\n return action;\n },\n // Transform the state to remove sensitive information\n stateTransformer: (state: RootState) => {\n const transformedState = {\n ...state,\n users: { ...state.users, currentSession: null },\n organization: {\n ...state.organization,\n organization: {\n ...state.organization.organization,\n tenant_token: null\n }\n }\n };\n return transformedState;\n }\n});\n\nexport const getConfiguredStore = (options: { [key: string]: unknown; preloadedState?: Partial<RootReducerState> } = {}) => {\n const { preloadedState, ...config } = options;\n return configureStore({\n ...config,\n preloadedState: preloadedState as RootReducerState,\n enhancers: getDefaultEnhancers => {\n // rely on the plain injected env object, as we're initializing the store only here\n if (window.mender_environment?.sentry?.isReduxEnabled) {\n return getDefaultEnhancers().concat(sentryReduxEnhancer);\n }\n return getDefaultEnhancers();\n },\n reducer: sessionReducer,\n // @ts-expect-error - GetDefaultMiddleware type mismatch between @reduxjs/toolkit and @sentry/react\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware({\n immutableCheck: {\n ignoredPaths: ['app.uploadsById']\n },\n serializableCheck: {\n ignoredActions: [organizationActions.receiveExternalDeviceIntegrations.type, uploadProgress.type],\n ignoredActionPaths: ['uploads', /payload\\..*$/, 'meta.arg.file', 'meta.arg.integration.configHint'],\n ignoredPaths: ['app.uploadsById', 'organization.externalDeviceIntegrations']\n }\n }).concat(rejectionLoggerMiddleware)\n });\n};\nexport const store = getConfiguredStore({\n preloadedState: {}\n});\nexport type AppDispatch = typeof store.dispatch;\nexport type RootState = ReturnType<typeof rootReducer>;\nexport const useAppDispatch: () => AppDispatch = useDispatch;\nexport const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;\n\nexport const createAppAsyncThunk = createAsyncThunk.withTypes<{\n dispatch: AppDispatch;\n state: RootState;\n}>();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiCA,MAAM,EAAE,aAAa,mBAAmBA;AAGxC,MAAM,OAAO,CAAC,4BAA4BC,kBAAAA,aAAa,YAAY;AACnE,MAAM,yBAA+B,KAAK,SAAQ,QAAO,OAAO,eAAe,WAAW,IAAI,CAAC;AAE/F,kBAAkB;AAqBlB,MAAa,sBAAsB;AACnC,MAAa,sBACX,KACA,cACA,UACA,UACA,qBAAqB,UACF;CACnB,MAAM,UAAA,GAAA,6BAAA,qBAA6B,KAAK,SAAS;AACjD,KAAI,sBAAsBC,aAAAA,UAAU,CAClC,UAAS,YAAY;EAAE,UAAA,GAAA,6BAAA,wBAAgC,IAAI,UAAU,GAAG,aAAa,GAAG,SAAS;EAAE,QAAQ;EAAqB,CAAC,CAAC;AAEpI,QAAO,QAAQ,OAAO,IAAI;;AAG5B,MAAM,eAAA,GAAA,iBAAA,iBAA8B;CAClC,KAAKC,uBAAAA;CACL,SAASC,2BAAAA;CACT,aAAaC,+BAAAA;CACb,SAASC,2BAAAA;CACT,YAAYC,8BAAAA;CACZ,cAAcC,gCAAAA;CACd,UAAUC,4BAAAA;CACV,OAAOC,yBAAAA;CACR,CAAC;AAIF,MAAM,sBAA4E,OAAO,WAAW;AAClG,KAAI,OAAO,SAAA,cACT,SAAQ,KAAA;AAEV,QAAO,YAAY,OAAO,OAAO;;AAGnC,MAAa,iBAAiB;AAE9B,MAAM,mCAA8C,UAAQ,WAAU;AACpE,MAAA,GAAA,iBAAA,YAAe,OAAO,EAAE;AACtB,UAAQ,MAAM,wBAAwB,OAAO;AAC7C,MAAI,OAAO,MACT,SAAQ,MAAM,OAAO,MAAM,MAAM;;AAGrC,QAAO,KAAK,OAAO;;AAGrB,MAAM,0BAA0B;CAACC,yBAAAA,QAAY,qBAAqB;CAAM;CAA2B;CAA6B;CAA2B;AAE3J,MAAM,uBAAA,GAAA,cAAA,qBAA0C;CAC9C,oBAAoB,WAA0B;AAC5C,MAAI,wBAAwB,SAAS,OAAO,KAAe,CACzD,QAAO;AAET,SAAO;;CAGT,mBAAmB,UAAqB;AAYtC,SAXyB;GACvB,GAAG;GACH,OAAO;IAAE,GAAG,MAAM;IAAO,gBAAgB;IAAM;GAC/C,cAAc;IACZ,GAAG,MAAM;IACT,cAAc;KACZ,GAAG,MAAM,aAAa;KACtB,cAAc;KACf;IACF;GACF;;CAGJ,CAAC;AAEF,MAAa,sBAAsB,UAAkF,EAAE,KAAK;CAC1H,MAAM,EAAE,gBAAgB,GAAG,WAAW;AACtC,SAAA,GAAA,iBAAA,gBAAsB;EACpB,GAAG;EACa;EAChB,YAAW,wBAAuB;AAEhC,OAAI,OAAO,oBAAoB,QAAQ,eACrC,QAAO,qBAAqB,CAAC,OAAO,oBAAoB;AAE1D,UAAO,qBAAqB;;EAE9B,SAAS;EAET,aAAY,yBACV,qBAAqB;GACnB,gBAAgB,EACd,cAAc,CAAC,kBAAkB,EAClC;GACD,mBAAmB;IACjB,gBAAgB,CAACC,gCAAAA,QAAoB,kCAAkC,MAAM,eAAe,KAAK;IACjG,oBAAoB;KAAC;KAAW;KAAgB;KAAiB;KAAkC;IACnG,cAAc,CAAC,mBAAmB,0CAA0C;IAC7E;GACF,CAAC,CAAC,OAAO,0BAA0B;EACvC,CAAC;;AAEJ,MAAa,QAAQ,mBAAmB,EACtC,gBAAgB,EAAE,EACnB,CAAC;AAGF,MAAa,iBAAoCC,YAAAA;AACjD,MAAa,iBAAkDC,YAAAA;AAE/D,MAAa,sBAAsBC,iBAAAA,iBAAiB,WAGhD"}
1
+ {"version":3,"file":"store.cjs","names":["actions","settingsKeys","getToken","appSlice","deviceSlice","deploymentSlice","monitorSlice","onboardingSlice","organizationSlice","releaseSlice","userSlice","userActions","organizationActions","useDispatch","useSelector","createAsyncThunk"],"sources":["../src/store.ts"],"sourcesContent":["// Copyright 2019 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useDispatch, useSelector } from 'react-redux';\nimport type { TypedUseSelectorHook } from 'react-redux';\n\nimport { extractErrorMessage, preformatWithRequestID } from '@northern.tech/utils/helpers';\nimport type { Middleware, Reducer, UnknownAction } from '@reduxjs/toolkit';\nimport { combineReducers, configureStore, createAsyncThunk, isRejected } from '@reduxjs/toolkit';\nimport { createReduxEnhancer } from '@sentry/react';\n\nimport actions from './actions';\nimport appSlice from './appSlice';\nimport { getToken } from './auth';\nimport { USER_LOGOUT, settingsKeys } from './constants';\nimport deploymentSlice from './deploymentsSlice';\nimport deviceSlice from './devicesSlice';\nimport monitorSlice from './monitorSlice';\nimport onboardingSlice from './onboardingSlice';\nimport organizationSlice, { actions as organizationActions } from './organizationSlice';\nimport releaseSlice from './releasesSlice';\nimport userSlice, { actions as userActions } from './usersSlice';\n\nconst { setSnackbar, uploadProgress } = actions;\n\n// exclude 'pendings-redirect' since this is expected to persist refreshes - the rest should be better to be redone\nconst keys = ['sessionDeploymentChecker', settingsKeys.initialized];\nconst resetEnvironment = (): void => keys.forEach(key => window.sessionStorage.removeItem(key));\n\nresetEnvironment();\n\nexport type { ErrorWithResponse } from './utils';\n\nexport type MenderEnvironment = {\n [key: string]: unknown;\n demoArtifactPort?: string | number;\n disableOnboarding?: string;\n features: Record<string, string>;\n integrationVersion: string;\n menderArtifactVersion: string;\n metaMenderVersion: string;\n sentry?: { isReduxEnabled?: string | boolean };\n};\n\ndeclare global {\n interface Window {\n mender_environment?: MenderEnvironment;\n }\n}\n\nexport const commonErrorFallback = 'Please check your connection.';\nexport const commonErrorHandler = (\n err: { message?: string; response?: { data?: unknown } },\n errorContext: string,\n dispatch: AppDispatch,\n fallback?: string,\n mightBeAuthRelated = false\n): Promise<never> => {\n const errMsg = extractErrorMessage(err, fallback);\n if (mightBeAuthRelated || getToken()) {\n dispatch(setSnackbar({ message: preformatWithRequestID(err.response, `${errorContext} ${errMsg}`), action: 'Copy to clipboard' }));\n }\n return Promise.reject(err);\n};\n\nconst rootReducer = combineReducers({\n app: appSlice,\n devices: deviceSlice,\n deployments: deploymentSlice,\n monitor: monitorSlice,\n onboarding: onboardingSlice,\n organization: organizationSlice,\n releases: releaseSlice,\n users: userSlice\n});\n\ntype RootReducerState = ReturnType<typeof rootReducer>;\n\nconst sessionReducerImpl: Reducer<RootReducerState | undefined, UnknownAction> = (state, action) => {\n if (action.type === USER_LOGOUT) {\n state = undefined;\n }\n return rootReducer(state, action);\n};\n// Export for testing; cast to RootReducerState since undefined always falls through to initial slice states\nexport const sessionReducer = sessionReducerImpl as Reducer<RootReducerState>;\n\nconst rejectionLoggerMiddleware: Middleware = () => next => action => {\n if (isRejected(action)) {\n console.error('Rejection in action:', action);\n if (action.error) {\n console.error(action.error.stack);\n }\n }\n return next(action);\n};\n\nconst tracingActionIgnoreList = [userActions.successfullyLoggedIn.type, 'users/loginUser/pending', 'users/loginUser/fulfilled', 'users/loginUser/rejected'];\n\nconst sentryReduxEnhancer = createReduxEnhancer({\n actionTransformer: (action: UnknownAction) => {\n if (tracingActionIgnoreList.includes(action.type as string)) {\n return null;\n }\n return action;\n },\n // Transform the state to remove sensitive information\n stateTransformer: (state: RootState) => {\n const transformedState = {\n ...state,\n users: { ...state.users, currentSession: null },\n organization: {\n ...state.organization,\n organization: {\n ...state.organization.organization,\n tenant_token: null\n }\n }\n };\n return transformedState;\n }\n});\n\nexport const getConfiguredStore = (options: { [key: string]: unknown; preloadedState?: Partial<RootReducerState> } = {}) => {\n const { preloadedState, ...config } = options;\n return configureStore({\n ...config,\n preloadedState: preloadedState as RootReducerState,\n enhancers: getDefaultEnhancers => {\n // rely on the plain injected env object, as we're initializing the store only here\n if (window.mender_environment?.sentry?.isReduxEnabled) {\n return getDefaultEnhancers().concat(sentryReduxEnhancer);\n }\n return getDefaultEnhancers();\n },\n reducer: sessionReducer,\n // @ts-expect-error - GetDefaultMiddleware type mismatch between @reduxjs/toolkit and @sentry/react\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware({\n immutableCheck: {\n ignoredPaths: ['app.uploadsById']\n },\n serializableCheck: {\n ignoredActions: [organizationActions.receiveExternalDeviceIntegrations.type, uploadProgress.type],\n ignoredActionPaths: ['uploads', /payload\\..*$/, 'meta.arg.file', 'meta.arg.integration.configHint'],\n ignoredPaths: ['app.uploadsById', 'organization.externalDeviceIntegrations']\n }\n }).concat(rejectionLoggerMiddleware)\n });\n};\nexport const store = getConfiguredStore({\n preloadedState: {}\n});\nexport type AppDispatch = typeof store.dispatch;\nexport type RootState = ReturnType<typeof rootReducer>;\nexport const useAppDispatch: () => AppDispatch = useDispatch;\nexport const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;\n\nexport const createAppAsyncThunk = createAsyncThunk.withTypes<{\n dispatch: AppDispatch;\n state: RootState;\n}>();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiCA,MAAM,EAAE,aAAa,mBAAmBA;AAGxC,MAAM,OAAO,CAAC,4BAA4BC,kBAAAA,aAAa,YAAY;AACnE,MAAM,yBAA+B,KAAK,SAAQ,QAAO,OAAO,eAAe,WAAW,IAAI,CAAC;AAE/F,kBAAkB;AAqBlB,MAAa,sBAAsB;AACnC,MAAa,sBACX,KACA,cACA,UACA,UACA,qBAAqB,UACF;CACnB,MAAM,UAAA,GAAA,6BAAA,qBAA6B,KAAK,SAAS;CACjD,IAAI,sBAAsBC,aAAAA,UAAU,EAClC,SAAS,YAAY;EAAE,UAAA,GAAA,6BAAA,wBAAgC,IAAI,UAAU,GAAG,aAAa,GAAG,SAAS;E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,oBAAoB;GAE1D,OAAO,qBAAqB;;EAE9B,SAAS;EAET,aAAY,yBACV,qBAAqB;GACnB,gBAAgB,EACd,cAAc,CAAC,kBAAkB,EAClC;GACD,mBAAmB;IACjB,gBAAgB,CAACC,gCAAAA,QAAoB,kCAAkC,MAAM,eAAe,KAAK;IACjG,oBAAoB;KAAC;KAAW;KAAgB;KAAiB;KAAkC;IACnG,cAAc,CAAC,mBAAmB,0CAA0C;IAC7E;GACF,CAAC,CAAC,OAAO,0BAA0B;EACvC,CAAC;;AAEJ,MAAa,QAAQ,mBAAmB,EACtC,gBAAgB,EAAE,EACnB,CAAC;AAGF,MAAa,iBAAoCC,YAAAA;AACjD,MAAa,iBAAkDC,YAAAA;AAE/D,MAAa,sBAAsBC,iBAAAA,iBAAiB,WAGhD"}
package/dist/store.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { n as ErrorWithResponse } from "./utils-CpPfqW0Q.cjs";
2
- import { a as commonErrorHandler, c as sessionReducer, d as useAppSelector, i as commonErrorFallback, l as store, n as MenderEnvironment, o as createAppAsyncThunk, r as RootState, s as getConfiguredStore, t as AppDispatch, u as useAppDispatch } from "./store-BiIA0r0A.cjs";
1
+ import { n as ErrorWithResponse } from "./utils-Do9z5TL1.cjs";
2
+ import { a as commonErrorHandler, c as sessionReducer, d as useAppSelector, i as commonErrorFallback, l as store, n as MenderEnvironment, o as createAppAsyncThunk, r as RootState, s as getConfiguredStore, t as AppDispatch, u as useAppDispatch } from "./store-b5cF2WB5.cjs";
3
3
  export { AppDispatch, ErrorWithResponse, MenderEnvironment, RootState, commonErrorFallback, commonErrorHandler, createAppAsyncThunk, getConfiguredStore, sessionReducer, store, useAppDispatch, useAppSelector };
package/dist/store.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { n as ErrorWithResponse } from "./utils-CO_CpGFP.js";
2
- import { a as commonErrorHandler, c as sessionReducer, d as useAppSelector, i as commonErrorFallback, l as store, n as MenderEnvironment, o as createAppAsyncThunk, r as RootState, s as getConfiguredStore, t as AppDispatch, u as useAppDispatch } from "./store-BQxOSRC1.js";
1
+ import { n as ErrorWithResponse } from "./utils-CHBWS_tH.js";
2
+ import { a as commonErrorHandler, c as sessionReducer, d as useAppSelector, i as commonErrorFallback, l as store, n as MenderEnvironment, o as createAppAsyncThunk, r as RootState, s as getConfiguredStore, t as AppDispatch, u as useAppDispatch } from "./store-D-xvZXiY.js";
3
3
  export { AppDispatch, ErrorWithResponse, MenderEnvironment, RootState, commonErrorFallback, commonErrorHandler, createAppAsyncThunk, getConfiguredStore, sessionReducer, store, useAppDispatch, useAppSelector };
package/dist/store.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","names":["actions","appSlice","deviceSlice","deploymentSlice","monitorSlice","onboardingSlice","organizationSlice","releaseSlice","userSlice","userActions","organizationActions"],"sources":["../src/store.ts"],"sourcesContent":["// Copyright 2019 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useDispatch, useSelector } from 'react-redux';\nimport type { TypedUseSelectorHook } from 'react-redux';\n\nimport { extractErrorMessage, preformatWithRequestID } from '@northern.tech/utils/helpers';\nimport type { Middleware, Reducer, UnknownAction } from '@reduxjs/toolkit';\nimport { combineReducers, configureStore, createAsyncThunk, isRejected } from '@reduxjs/toolkit';\nimport { createReduxEnhancer } from '@sentry/react';\n\nimport actions from './actions';\nimport appSlice from './appSlice';\nimport { getToken } from './auth';\nimport { USER_LOGOUT, settingsKeys } from './constants';\nimport deploymentSlice from './deploymentsSlice';\nimport deviceSlice from './devicesSlice';\nimport monitorSlice from './monitorSlice';\nimport onboardingSlice from './onboardingSlice';\nimport organizationSlice, { actions as organizationActions } from './organizationSlice';\nimport releaseSlice from './releasesSlice';\nimport userSlice, { actions as userActions } from './usersSlice';\n\nconst { setSnackbar, uploadProgress } = actions;\n\n// exclude 'pendings-redirect' since this is expected to persist refreshes - the rest should be better to be redone\nconst keys = ['sessionDeploymentChecker', settingsKeys.initialized];\nconst resetEnvironment = (): void => keys.forEach(key => window.sessionStorage.removeItem(key));\n\nresetEnvironment();\n\nexport type { ErrorWithResponse } from './utils';\n\nexport type MenderEnvironment = {\n [key: string]: unknown;\n demoArtifactPort?: string | number;\n disableOnboarding?: string;\n features: Record<string, string>;\n integrationVersion: string;\n menderArtifactVersion: string;\n metaMenderVersion: string;\n sentry?: { isReduxEnabled?: string | boolean };\n};\n\ndeclare global {\n interface Window {\n mender_environment?: MenderEnvironment;\n }\n}\n\nexport const commonErrorFallback = 'Please check your connection.';\nexport const commonErrorHandler = (\n err: { message?: string; response?: { data?: unknown } },\n errorContext: string,\n dispatch: AppDispatch,\n fallback?: string,\n mightBeAuthRelated = false\n): Promise<never> => {\n const errMsg = extractErrorMessage(err, fallback);\n if (mightBeAuthRelated || getToken()) {\n dispatch(setSnackbar({ message: preformatWithRequestID(err.response, `${errorContext} ${errMsg}`), action: 'Copy to clipboard' }));\n }\n return Promise.reject(err);\n};\n\nconst rootReducer = combineReducers({\n app: appSlice,\n devices: deviceSlice,\n deployments: deploymentSlice,\n monitor: monitorSlice,\n onboarding: onboardingSlice,\n organization: organizationSlice,\n releases: releaseSlice,\n users: userSlice\n});\n\ntype RootReducerState = ReturnType<typeof rootReducer>;\n\nconst sessionReducerImpl: Reducer<RootReducerState | undefined, UnknownAction> = (state, action) => {\n if (action.type === USER_LOGOUT) {\n state = undefined;\n }\n return rootReducer(state, action);\n};\n// Export for testing; cast to RootReducerState since undefined always falls through to initial slice states\nexport const sessionReducer = sessionReducerImpl as Reducer<RootReducerState>;\n\nconst rejectionLoggerMiddleware: Middleware = () => next => action => {\n if (isRejected(action)) {\n console.error('Rejection in action:', action);\n if (action.error) {\n console.error(action.error.stack);\n }\n }\n return next(action);\n};\n\nconst tracingActionIgnoreList = [userActions.successfullyLoggedIn.type, 'users/loginUser/pending', 'users/loginUser/fulfilled', 'users/loginUser/rejected'];\n\nconst sentryReduxEnhancer = createReduxEnhancer({\n actionTransformer: (action: UnknownAction) => {\n if (tracingActionIgnoreList.includes(action.type as string)) {\n return null;\n }\n return action;\n },\n // Transform the state to remove sensitive information\n stateTransformer: (state: RootState) => {\n const transformedState = {\n ...state,\n users: { ...state.users, currentSession: null },\n organization: {\n ...state.organization,\n organization: {\n ...state.organization.organization,\n tenant_token: null\n }\n }\n };\n return transformedState;\n }\n});\n\nexport const getConfiguredStore = (options: { [key: string]: unknown; preloadedState?: Partial<RootReducerState> } = {}) => {\n const { preloadedState, ...config } = options;\n return configureStore({\n ...config,\n preloadedState: preloadedState as RootReducerState,\n enhancers: getDefaultEnhancers => {\n // rely on the plain injected env object, as we're initializing the store only here\n if (window.mender_environment?.sentry?.isReduxEnabled) {\n return getDefaultEnhancers().concat(sentryReduxEnhancer);\n }\n return getDefaultEnhancers();\n },\n reducer: sessionReducer,\n // @ts-expect-error - GetDefaultMiddleware type mismatch between @reduxjs/toolkit and @sentry/react\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware({\n immutableCheck: {\n ignoredPaths: ['app.uploadsById']\n },\n serializableCheck: {\n ignoredActions: [organizationActions.receiveExternalDeviceIntegrations.type, uploadProgress.type],\n ignoredActionPaths: ['uploads', /payload\\..*$/, 'meta.arg.file', 'meta.arg.integration.configHint'],\n ignoredPaths: ['app.uploadsById', 'organization.externalDeviceIntegrations']\n }\n }).concat(rejectionLoggerMiddleware)\n });\n};\nexport const store = getConfiguredStore({\n preloadedState: {}\n});\nexport type AppDispatch = typeof store.dispatch;\nexport type RootState = ReturnType<typeof rootReducer>;\nexport const useAppDispatch: () => AppDispatch = useDispatch;\nexport const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;\n\nexport const createApp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AAG,MAAM;IAAO,gBAAgB;IAAM;GAC/C,cAAc;IACZ,GAAG,MAAM;IACT,cAAc;KACZ,GAAG,MAAM,aAAa;KACtB,cAAc;KACf;IACF;GACF;;CAGJ,CAAC;AAEF,MAAa,sBAAsB,UAAkF,EAAE,KAAK;CAC1H,MAAM,EAAE,gBAAgB,GAAG,WAAW;AACtC,QAAO,eAAe;EACpB,GAAG;EACa;EAChB,YAAW,wBAAuB;AAEhC,OAAI,OAAO,oBAAoB,QAAQ,eACrC,QAAO,qBAAqB,CAAC,OAAO,oBAAoB;AAE1D,UAAO,qBAAqB;;EAE9B,SAAS;EAET,aAAY,yBACV,qBAAqB;GACnB,gBAAgB,EACd,cAAc,CAAC,kBAAkB,EAClC;GACD,mBAAmB;IACjB,gBAAgB,CAACC,QAAoB,kCAAkC,MAAM,eAAe,KAAK;IACjG,oBAAoB;KAAC;KAAW;KAAgB;KAAiB;KAAkC;IACnG,cAAc,CAAC,mBAAmB,0CAA0C;IAC7E;GACF,CAAC,CAAC,OAAO,0BAA0B;EACvC,CAAC;;AAEJ,MAAa,QAAQ,mBAAmB,EACtC,gBAAgB,EAAE,EACnB,CAAC;AAGF,MAAa,iBAAoC;AACjD,MAAa,iBAAkD;AAE/D,MAAa,sBAAsB,iBAAiB,WAGhD"}
1
+ {"version":3,"file":"store.js","names":["actions","appSlice","deviceSlice","deploymentSlice","monitorSlice","onboardingSlice","organizationSlice","releaseSlice","userSlice","userActions","organizationActions"],"sources":["../src/store.ts"],"sourcesContent":["// Copyright 2019 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useDispatch, useSelector } from 'react-redux';\nimport type { TypedUseSelectorHook } from 'react-redux';\n\nimport { extractErrorMessage, preformatWithRequestID } from '@northern.tech/utils/helpers';\nimport type { Middleware, Reducer, UnknownAction } from '@reduxjs/toolkit';\nimport { combineReducers, configureStore, createAsyncThunk, isRejected } from '@reduxjs/toolkit';\nimport { createReduxEnhancer } from '@sentry/react';\n\nimport actions from './actions';\nimport appSlice from './appSlice';\nimport { getToken } from './auth';\nimport { USER_LOGOUT, settingsKeys } from './constants';\nimport deploymentSlice from './deploymentsSlice';\nimport deviceSlice from './devicesSlice';\nimport monitorSlice from './monitorSlice';\nimport onboardingSlice from './onboardingSlice';\nimport organizationSlice, { actions as organizationActions } from './organizationSlice';\nimport releaseSlice from './releasesSlice';\nimport userSlice, { actions as userActions } from './usersSlice';\n\nconst { setSnackbar, uploadProgress } = actions;\n\n// exclude 'pendings-redirect' since this is expected to persist refreshes - the rest should be better to be redone\nconst keys = ['sessionDeploymentChecker', settingsKeys.initialized];\nconst resetEnvironment = (): void => keys.forEach(key => window.sessionStorage.removeItem(key));\n\nresetEnvironment();\n\nexport type { ErrorWithResponse } from './utils';\n\nexport type MenderEnvironment = {\n [key: string]: unknown;\n demoArtifactPort?: string | number;\n disableOnboarding?: string;\n features: Record<string, string>;\n integrationVersion: string;\n menderArtifactVersion: string;\n metaMenderVersion: string;\n sentry?: { isReduxEnabled?: string | boolean };\n};\n\ndeclare global {\n interface Window {\n mender_environment?: MenderEnvironment;\n }\n}\n\nexport const commonErrorFallback = 'Please check your connection.';\nexport const commonErrorHandler = (\n err: { message?: string; response?: { data?: unknown } },\n errorContext: string,\n dispatch: AppDispatch,\n fallback?: string,\n mightBeAuthRelated = false\n): Promise<never> => {\n const errMsg = extractErrorMessage(err, fallback);\n if (mightBeAuthRelated || getToken()) {\n dispatch(setSnackbar({ message: preformatWithRequestID(err.response, `${errorContext} ${errMsg}`), action: 'Copy to clipboard' }));\n }\n return Promise.reject(err);\n};\n\nconst rootReducer = combineReducers({\n app: appSlice,\n devices: deviceSlice,\n deployments: deploymentSlice,\n monitor: monitorSlice,\n onboarding: onboardingSlice,\n organization: organizationSlice,\n releases: releaseSlice,\n users: userSlice\n});\n\ntype RootReducerState = ReturnType<typeof rootReducer>;\n\nconst sessionReducerImpl: Reducer<RootReducerState | undefined, UnknownAction> = (state, action) => {\n if (action.type === USER_LOGOUT) {\n state = undefined;\n }\n return rootReducer(state, action);\n};\n// Export for testing; cast to RootReducerState since undefined always falls through to initial slice states\nexport const sessionReducer = sessionReducerImpl as Reducer<RootReducerState>;\n\nconst rejectionLoggerMiddleware: Middleware = () => next => action => {\n if (isRejected(action)) {\n console.error('Rejection in action:', action);\n if (action.error) {\n console.error(action.error.stack);\n }\n }\n return next(action);\n};\n\nconst tracingActionIgnoreList = [userActions.successfullyLoggedIn.type, 'users/loginUser/pending', 'users/loginUser/fulfilled', 'users/loginUser/rejected'];\n\nconst sentryReduxEnhancer = createReduxEnhancer({\n actionTransformer: (action: UnknownAction) => {\n if (tracingActionIgnoreList.includes(action.type as string)) {\n return null;\n }\n return action;\n },\n // Transform the state to remove sensitive information\n stateTransformer: (state: RootState) => {\n const transformedState = {\n ...state,\n users: { ...state.users, currentSession: null },\n organization: {\n ...state.organization,\n organization: {\n ...state.organization.organization,\n tenant_token: null\n }\n }\n };\n return transformedState;\n }\n});\n\nexport const getConfiguredStore = (options: { [key: string]: unknown; preloadedState?: Partial<RootReducerState> } = {}) => {\n const { preloadedState, ...config } = options;\n return configureStore({\n ...config,\n preloadedState: preloadedState as RootReducerState,\n enhancers: getDefaultEnhancers => {\n // rely on the plain injected env object, as we're initializing the store only here\n if (window.mender_environment?.sentry?.isReduxEnabled) {\n return getDefaultEnhancers().concat(sentryReduxEnhancer);\n }\n return getDefaultEnhancers();\n },\n reducer: sessionReducer,\n // @ts-expect-error - GetDefaultMiddleware type mismatch between @reduxjs/toolkit and @sentry/react\n middleware: getDefaultMiddleware =>\n getDefaultMiddleware({\n immutableCheck: {\n ignoredPaths: ['app.uploadsById']\n },\n serializableCheck: {\n ignoredActions: [organizationActions.receiveExternalDeviceIntegrations.type, uploadProgress.type],\n ignoredActionPaths: ['uploads', /payload\\..*$/, 'meta.arg.file', 'meta.arg.integration.configHint'],\n ignoredPaths: ['app.uploadsById', 'organization.externalDeviceIntegrations']\n }\n }).concat(rejectionLoggerMiddleware)\n });\n};\nexport const store = getConfiguredStore({\n preloadedState: {}\n});\nexport type AppDispatch = typeof store.dispatch;\nexport type RootState = ReturnType<typeof rootReducer>;\nexport const useAppDispatch: () => AppDispatch = useDispatch;\nexport const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;\n\nexport const createAppAsyncThunk = createAsyncThunk.withTypes<{\n dispatch: AppDispatch;\n state: RootState;\n}>();\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,MAAM,EAAE,aAAa,mBAAmBA;AAGxC,MAAM,OAAO,CAAC,4BAA4B,aAAa,YAAY;AACnE,MAAM,yBAA+B,KAAK,SAAQ,QAAO,OAAO,eAAe,WAAW,IAAI,CAAC;AAE/F,kBAAkB;AAqBlB,MAAa,sBAAsB;AACnC,MAAa,sBACX,KACA,cACA,UACA,UACA,qBAAqB,UACF;CACnB,MAAM,SAAS,oBAAoB,KAAK,SAAS;CACjD,IAAI,sBAAsB,UAAU,EAClC,SAAS,YAAY;EAAE,SAAS,uBAAuB,IAAI,UAAU,GAAG,aAAa,GAAG,SAAS;EAAE,QAAQ;EAAqB,CAAC,CAAC;CAEpI,OAAO,QAAQ,OAAO,IAAI;;AAG5B,MAAM,cAAc,gBAAgB;CAClC,KAAKC;CACL,SAASC;CACT,aAAaC;CACb,SAASC;CACT,YAAYC;CACZ,cAAcC;CACd,UAAUC;CACV,OAAOC;CACR,CAAC;AAIF,MAAM,sBAA4E,OAAO,WAAW;CAClG,IAAI,OAAO,SAAA,eACT,QAAQ,KAAA;CAEV,OAAO,YAAY,OAAO,OAAO;;AAGnC,MAAa,iBAAiB;AAE9B,MAAM,mCAA8C,UAAQ,WAAU;CACpE,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require("./releasesSlice/thunks.cjs");
14
14
  const require_thunks = require("./thunks.cjs");
15
15
  let _northern_tech_utils_helpers = require("@northern.tech/utils/helpers");
16
16
  let universal_cookie = require("universal-cookie");
17
- universal_cookie = require_chunk.__toESM(universal_cookie);
17
+ universal_cookie = require_chunk.__toESM(universal_cookie, 1);
18
18
  let dayjs = require("dayjs");
19
- dayjs = require_chunk.__toESM(dayjs);
19
+ dayjs = require_chunk.__toESM(dayjs, 1);
20
20
  let react = require("react");
21
21
  let dayjs_plugin_duration_js = require("dayjs/plugin/duration.js");
22
- dayjs_plugin_duration_js = require_chunk.__toESM(dayjs_plugin_duration_js);
22
+ dayjs_plugin_duration_js = require_chunk.__toESM(dayjs_plugin_duration_js, 1);
23
23
  let _northern_tech_utils_constants = require("@northern.tech/utils/constants");
24
24
  //#region src/storehooks.ts
25
25
  const cookies = new universal_cookie.default();
@@ -1 +1 @@
1
- {"version":3,"file":"storehooks.cjs","names":["Cookies","durationDayJs","storeActions","createAppAsyncThunk","getOnboardingStateSelector","stringToBoolean","getComparisonCompatibleVersion","getSessionInfo","getLatestReleaseInfo","DEVICE_STATES","getDeviceById","useAppDispatch","useAppSelector","getIsEnterprise","getFeatures","getDevicesByStatusSelector","getUserSettingsSelector","getUserCapabilities","getOfflineThresholdSettings","getGlobalSettingsSelector","getSortedFilteringAttributes","getIsServiceProvider","getUserSettings","getGlobalSettings","getUserOrganization","getRoles","getDeviceAttributes","getDeploymentsByStatus","DEPLOYMENT_STATES","getDevicesByStatus","getDynamicGroups","getGroups","getIntegrations","getReleases","getAllDeviceCounts","getDeviceLimits","saveUserSettings","timeUnits","TIMEOUTS","saveGlobalSettings","getOnboardingState"],"sources":["../src/storehooks.ts"],"sourcesContent":["// Copyright 2024 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { extractErrorMessage } from '@northern.tech/utils/helpers';\nimport dayjs from 'dayjs';\nimport durationDayJs from 'dayjs/plugin/duration.js';\nimport Cookies from 'universal-cookie';\n\nimport storeActions from './actions';\nimport { getSessionInfo } from './auth';\nimport { DEPLOYMENT_STATES, DEVICE_STATES, TIMEOUTS, timeUnits } from './constants';\nimport type { DeviceSliceType } from './devicesSlice';\nimport {\n getDevicesByStatus as getDevicesByStatusSelector,\n getFeatures,\n getGlobalSettings as getGlobalSettingsSelector,\n getIsEnterprise,\n getIsServiceProvider,\n getOfflineThresholdSettings,\n getOnboardingState as getOnboardingStateSelector,\n getSortedFilteringAttributes,\n getUserCapabilities,\n getUserSettings as getUserSettingsSelector\n} from './selectors';\nimport { createAppAsyncThunk, useAppDispatch, useAppSelector } from './store';\nimport type { AppDispatch } from './store';\nimport {\n getAllDeviceCounts,\n getDeploymentsByStatus,\n getDeviceAttributes,\n getDeviceById,\n getDeviceLimits,\n getDevicesByStatus,\n getDynamicGroups,\n getGlobalSettings,\n getGroups,\n getIntegrations,\n getLatestReleaseInfo,\n getOnboardingState,\n getReleases,\n getRoles,\n getUserOrganization,\n getUserSettings,\n saveGlobalSettings,\n saveUserSettings\n} from './thunks';\nimport type { UserSettings, UserSliceType } from './usersSlice';\nimport { getComparisonCompatibleVersion, stringToBoolean } from './utils';\n\nconst cookies = new Cookies();\ndayjs.extend(durationDayJs);\n\nconst { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = storeActions;\n\nconst featureFlags = [\n 'hasAiEnabled',\n 'hasAuditlogs',\n 'hasMultitenancy',\n 'hasDeltaProgress',\n 'hasDeviceConfig',\n 'hasDeviceConnect',\n 'hasFeedbackEnabled',\n 'hasManifestsEnabled',\n 'hasMonitor',\n 'hasMCUEnabled',\n 'isEnterprise'\n] as const;\n\nconst environmentDatas = [\n 'commit',\n 'feedbackProbability',\n 'hostAddress',\n 'hostedAnnouncement',\n 'recaptchaSiteKey',\n 'sentry',\n 'stripeAPIKey',\n 'trackerCode'\n] as const;\n\ntype VersionInfo = {\n docs?: string;\n remainder?: Record<string, string>;\n};\n\ntype FeatureFlagsState = Record<string, boolean>;\n\nexport const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_, { dispatch, getState }) => {\n const state = getState();\n let onboardingComplete = getOnboardingStateSelector(state).complete || !!JSON.parse(window.localStorage.getItem('onboardingComplete') ?? 'false');\n let demoArtifactPort = 85;\n let environmentData: Record<string, unknown> = {};\n let environmentFeatures: FeatureFlagsState = {};\n let versionInfo: VersionInfo = {};\n const mender_environment = window.mender_environment;\n if (mender_environment) {\n const { features = {}, demoArtifactPort: port, disableOnboarding, integrationVersion, menderArtifactVersion, metaMenderVersion } = mender_environment;\n demoArtifactPort = Number(port) || demoArtifactPort;\n const appState = state.app;\n environmentData = environmentDatas.reduce((accu, flag) => ({ ...accu, [flag]: mender_environment[flag] || appState[flag as keyof typeof appState] }), {});\n environmentFeatures = {\n ...featureFlags.reduce<FeatureFlagsState>((accu, flag) => ({ ...accu, [flag]: stringToBoolean(features[flag]) }), {}),\n isHosted: stringToBoolean(features.isHosted) || window.location.hostname.includes('hosted.mender.io')\n };\n onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;\n versionInfo = {\n docs: isNaN(parseInt(integrationVersion.charAt(0))) ? '' : integrationVersion.split('.').slice(0, 2).join('.'),\n remainder: {\n Integration: getComparisonCompatibleVersion(integrationVersion),\n 'Mender-Artifact': menderArtifactVersion,\n 'Meta-Mender': metaMenderVersion\n }\n };\n }\n return Promise.all([\n dispatch(storeActions.successfullyLoggedIn(getSessionInfo())),\n dispatch(storeActions.setOnboardingComplete(onboardingComplete)),\n dispatch(storeActions.setDemoArtifactPort(demoArtifactPort)),\n dispatch(storeActions.setFeatures(environmentFeatures)),\n dispatch(storeActions.setVersionInformation({ ...(versionInfo.remainder ?? {}), docsVersion: versionInfo.docs })),\n dispatch(storeActions.setEnvironmentData(environmentData)),\n dispatch(getLatestReleaseInfo())\n ]);\n});\n\ntype OnboardingState = {\n complete?: boolean;\n showTips?: boolean | null;\n};\n\ntype MaybeAddOnboardingTasksParams = {\n devicesByStatus: DeviceSliceType['byStatus'];\n dispatch: AppDispatch;\n onboardingState: OnboardingState;\n tasks: Promise<unknown>[];\n};\n\nconst maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }: MaybeAddOnboardingTasksParams): Promise<unknown>[] => {\n if (!onboardingState.showTips || onboardingState.complete) {\n return tasks;\n }\n // try to retrieve full device details for onboarding devices to ensure ips etc. are available\n // we only load the first few/ 20 devices, as it is possible the onboarding is left dangling\n // and a lot of devices are present and we don't want to flood the backend for this\n return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce<Promise<unknown>[]>((accu, id) => {\n accu.push(dispatch(getDeviceById(id)));\n return accu;\n }, tasks);\n};\n\nexport const useAppInit = (userId: string | undefined): { coreInitDone: boolean } => {\n const dispatch = useAppDispatch();\n const [coreInitDone, setCoreInitDone] = useState(false);\n const isEnterprise = useAppSelector(getIsEnterprise);\n const { hasMultitenancy, isHosted } = useAppSelector(getFeatures);\n const devicesByStatus = useAppSelector(getDevicesByStatusSelector);\n const onboardingState = useAppSelector(getOnboardingStateSelector);\n const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettingsSelector);\n const { canManageUsers } = useAppSelector(getUserCapabilities);\n const { interval, intervalUnit } = useAppSelector(getOfflineThresholdSettings);\n const { id_attribute } = useAppSelector(getGlobalSettingsSelector);\n const { identityAttributes } = useAppSelector(getSortedFilteringAttributes);\n const isServiceProvider = useAppSelector(getIsServiceProvider);\n const coreInitRunning = useRef(false);\n const fullInitRunning = useRef(false);\n\n const retrieveCoreData = useCallback((): Promise<unknown[]> => {\n const tasks: Promise<unknown>[] = [\n dispatch(parseEnvironmentInfo()).unwrap(),\n dispatch(getUserSettings()).unwrap(),\n dispatch(getGlobalSettings()).unwrap(),\n Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get('firstLoginAfterSignup')))))\n ];\n const multitenancy = hasMultitenancy || isHosted || isEnterprise;\n if (multitenancy) {\n tasks.push(dispatch(getUserOrganization()).unwrap());\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isHosted, isEnterprise]);\n\n const retrieveAppData = useCallback((): Promise<unknown[] | unknown> => {\n if (isServiceProvider) {\n return Promise.resolve(dispatch(getRoles()));\n }\n const tasks: Promise<unknown>[] = [\n dispatch(getDeviceAttributes()),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.finished, shouldSelect: false })),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.inprogress })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.accepted })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.pending })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.preauth })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.rejected })),\n dispatch(getDynamicGroups()),\n dispatch(getGroups()),\n dispatch(getIntegrations()),\n dispatch(getReleases()),\n dispatch(getAllDeviceCounts()).unwrap()\n ];\n if (hasMultitenancy) {\n tasks.push(dispatch(getDeviceLimits()));\n tasks.push(dispatch(getRoles()));\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isServiceProvider]);\n\n const interpretAppData = useCallback((): Promise<unknown[]> => {\n const settings: Partial<UserSettings> = {};\n if (cookies.get('_ga') && typeof hasTrackingEnabled === 'undefined') {\n settings.trackingConsentGiven = true;\n }\n let tasks: Promise<unknown>[] = [\n Promise.resolve(dispatch(setDeviceListState({ selectedAttributes: columnSelection.map(column => ({ attribute: column.key, scope: column.scope })) }))),\n Promise.resolve(dispatch(setTooltipsState(tooltips as UserSliceType['tooltips']['byId']))), // tooltips read state is primarily trusted from the redux store, except on app init - here user settings are the reference\n dispatch(saveUserSettings(settings)).unwrap()\n ];\n // checks if user id is set and if cookie for helptips exists for that user\n tasks = maybeAddOnboardingTasks({ devicesByStatus, dispatch, tasks, onboardingState });\n\n if (canManageUsers && intervalUnit && intervalUnit !== timeUnits.days) {\n const duration = dayjs.duration(interval, intervalUnit as keyof typeof timeUnits);\n const days = duration.asDays();\n if (days < 1) {\n tasks.push(Promise.resolve(setTimeout(() => dispatch(setShowStartupNotification(true)), TIMEOUTS.fiveSeconds)));\n } else {\n const roundedDays = Math.max(1, Math.round(days));\n tasks.push(dispatch(saveGlobalSettings({ offlineThreshold: { interval: roundedDays, intervalUnit: timeUnits.days } })));\n }\n }\n\n // the following is used as a migration and initialization of the stored identity attribute\n // changing the default device attribute to the first non-deviceId attribute, unless a stored\n // id attribute setting exists\n const identityOptions = identityAttributes.filter(attribute => !['id', 'Device ID', 'status'].includes(attribute));\n if (!id_attribute && identityOptions.length) {\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute: identityOptions[0], scope: 'identity' } })));\n } else if (typeof id_attribute === 'string') {\n // Legacy migration path: id_attribute used to be a plain string\n let attribute: string = id_attribute;\n if (attribute === 'Device ID') {\n attribute = 'id';\n }\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute, scope: 'identity' } })));\n }\n tasks.push(Promise.resolve(dispatch(storeActions.setAppInitDone())));\n return Promise.all(tasks);\n }, [\n columnSelection,\n dispatch,\n identityAttributes,\n hasTrackingEnabled,\n canManageUsers,\n devicesByStatus,\n id_attribute,\n interval,\n intervalUnit,\n onboardingState,\n tooltips\n ]);\n\n const initializeAppData = useCallback(\n (): Promise<unknown> =>\n retrieveAppData()\n .then(interpretAppData)\n // this is allowed to fail if no user information are available\n .catch(err => console.log(extractErrorMessage(err)))\n .then(() => dispatch(getOnboardingState())),\n [dispatch, retrieveAppData, interpretAppData]\n );\n\n useEffect(() => {\n if (!userId || coreInitRunning.current) {\n return;\n }\n coreInitRunning.current = true;\n retrieveCoreData().then(() => setCoreInitDone(true));\n }, [userId, retrieveCoreData]);\n\n useEffect(() => {\n if (fullInitRunning.current || !coreInitDone) {\n return;\n }\n fullInitRunning.current = true;\n initializeAppData();\n }, [initializeAppData, coreInitDone]);\n\n return { coreInitDone };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,UAAU,IAAIA,iBAAAA,SAAS;AAC7B,MAAA,QAAM,OAAOC,yBAAAA,QAAc;AAE3B,MAAM,EAAE,oBAAoB,0BAA0B,kBAAkB,+BAA+BC;AAEvG,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AASD,MAAa,uBAAuBC,cAAAA,oBAAoB,6BAA6B,GAAG,EAAE,UAAU,eAAe;CACjH,MAAM,QAAQ,UAAU;CACxB,IAAI,qBAAqBC,wBAAAA,mBAA2B,MAAM,CAAC,YAAY,CAAC,CAAC,KAAK,MAAM,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;CACjJ,IAAI,mBAAmB;CACvB,IAAI,kBAA2C,EAAE;CACjD,IAAI,sBAAyC,EAAE;CAC/C,IAAI,cAA2B,EAAE;CACjC,MAAM,qBAAqB,OAAO;AAClC,KAAI,oBAAoB;EACtB,MAAM,EAAE,WAAW,EAAE,EAAE,kBAAkB,MAAM,mBAAmB,oBAAoB,uBAAuB,sBAAsB;AACnI,qBAAmB,OAAO,KAAK,IAAI;EACnC,MAAM,WAAW,MAAM;AACvB,oBAAkB,iBAAiB,QAAQ,MAAM,UAAU;GAAE,GAAG;IAAO,OAAO,mBAAmB,SAAS,SAAS;GAAgC,GAAG,EAAE,CAAC;AACzJ,wBAAsB;GACpB,GAAG,aAAa,QAA2B,MAAM,UAAU;IAAE,G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EACA;EACD,CAAC;CAEF,MAAM,qBAAA,GAAA,MAAA,mBAEF,iBAAiB,CACd,KAAK,iBAAiB,CAEtB,OAAM,QAAO,QAAQ,KAAA,GAAA,6BAAA,qBAAwB,IAAI,CAAC,CAAC,CACnD,WAAW,SAASsC,eAAAA,oBAAoB,CAAC,CAAC,EAC/C;EAAC;EAAU;EAAiB;EAAiB,CAC9C;AAED,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAI,CAAC,UAAU,gBAAgB,QAC7B;AAEF,kBAAgB,UAAU;AAC1B,oBAAkB,CAAC,WAAW,gBAAgB,KAAK,CAAC;IACnD,CAAC,QAAQ,iBAAiB,CAAC;AAE9B,EAAA,GAAA,MAAA,iBAAgB;AACd,MAAI,gBAAgB,WAAW,CAAC,aAC9B;AAEF,kBAAgB,UAAU;AAC1B,qBAAmB;IAClB,CAAC,mBAAmB,aAAa,CAAC;AAErC,QAAO,EAAE,cAAc"}
1
+ {"version":3,"file":"storehooks.cjs","names":["Cookies","durationDayJs","storeActions","createAppAsyncThunk","getOnboardingStateSelector","stringToBoolean","getComparisonCompatibleVersion","getSessionInfo","getLatestReleaseInfo","DEVICE_STATES","getDeviceById","useAppDispatch","useAppSelector","getIsEnterprise","getFeatures","getDevicesByStatusSelector","getUserSettingsSelector","getUserCapabilities","getOfflineThresholdSettings","getGlobalSettingsSelector","getSortedFilteringAttributes","getIsServiceProvider","getUserSettings","getGlobalSettings","getUserOrganization","getRoles","getDeviceAttributes","getDeploymentsByStatus","DEPLOYMENT_STATES","getDevicesByStatus","getDynamicGroups","getGroups","getIntegrations","getReleases","getAllDeviceCounts","getDeviceLimits","saveUserSettings","timeUnits","TIMEOUTS","saveGlobalSettings","getOnboardingState"],"sources":["../src/storehooks.ts"],"sourcesContent":["// Copyright 2024 Northern.tech AS\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { extractErrorMessage } from '@northern.tech/utils/helpers';\nimport dayjs from 'dayjs';\nimport durationDayJs from 'dayjs/plugin/duration.js';\nimport Cookies from 'universal-cookie';\n\nimport storeActions from './actions';\nimport { getSessionInfo } from './auth';\nimport { DEPLOYMENT_STATES, DEVICE_STATES, TIMEOUTS, timeUnits } from './constants';\nimport type { DeviceSliceType } from './devicesSlice';\nimport {\n getDevicesByStatus as getDevicesByStatusSelector,\n getFeatures,\n getGlobalSettings as getGlobalSettingsSelector,\n getIsEnterprise,\n getIsServiceProvider,\n getOfflineThresholdSettings,\n getOnboardingState as getOnboardingStateSelector,\n getSortedFilteringAttributes,\n getUserCapabilities,\n getUserSettings as getUserSettingsSelector\n} from './selectors';\nimport { createAppAsyncThunk, useAppDispatch, useAppSelector } from './store';\nimport type { AppDispatch } from './store';\nimport {\n getAllDeviceCounts,\n getDeploymentsByStatus,\n getDeviceAttributes,\n getDeviceById,\n getDeviceLimits,\n getDevicesByStatus,\n getDynamicGroups,\n getGlobalSettings,\n getGroups,\n getIntegrations,\n getLatestReleaseInfo,\n getOnboardingState,\n getReleases,\n getRoles,\n getUserOrganization,\n getUserSettings,\n saveGlobalSettings,\n saveUserSettings\n} from './thunks';\nimport type { UserSettings, UserSliceType } from './usersSlice';\nimport { getComparisonCompatibleVersion, stringToBoolean } from './utils';\n\nconst cookies = new Cookies();\ndayjs.extend(durationDayJs);\n\nconst { setDeviceListState, setFirstLoginAfterSignup, setTooltipsState, setShowStartupNotification } = storeActions;\n\nconst featureFlags = [\n 'hasAiEnabled',\n 'hasAuditlogs',\n 'hasMultitenancy',\n 'hasDeltaProgress',\n 'hasDeviceConfig',\n 'hasDeviceConnect',\n 'hasFeedbackEnabled',\n 'hasManifestsEnabled',\n 'hasMonitor',\n 'hasMCUEnabled',\n 'isEnterprise'\n] as const;\n\nconst environmentDatas = [\n 'commit',\n 'feedbackProbability',\n 'hostAddress',\n 'hostedAnnouncement',\n 'recaptchaSiteKey',\n 'sentry',\n 'stripeAPIKey',\n 'trackerCode'\n] as const;\n\ntype VersionInfo = {\n docs?: string;\n remainder?: Record<string, string>;\n};\n\ntype FeatureFlagsState = Record<string, boolean>;\n\nexport const parseEnvironmentInfo = createAppAsyncThunk(`app/parseEnvironmentInfo`, (_, { dispatch, getState }) => {\n const state = getState();\n let onboardingComplete = getOnboardingStateSelector(state).complete || !!JSON.parse(window.localStorage.getItem('onboardingComplete') ?? 'false');\n let demoArtifactPort = 85;\n let environmentData: Record<string, unknown> = {};\n let environmentFeatures: FeatureFlagsState = {};\n let versionInfo: VersionInfo = {};\n const mender_environment = window.mender_environment;\n if (mender_environment) {\n const { features = {}, demoArtifactPort: port, disableOnboarding, integrationVersion, menderArtifactVersion, metaMenderVersion } = mender_environment;\n demoArtifactPort = Number(port) || demoArtifactPort;\n const appState = state.app;\n environmentData = environmentDatas.reduce((accu, flag) => ({ ...accu, [flag]: mender_environment[flag] || appState[flag as keyof typeof appState] }), {});\n environmentFeatures = {\n ...featureFlags.reduce<FeatureFlagsState>((accu, flag) => ({ ...accu, [flag]: stringToBoolean(features[flag]) }), {}),\n isHosted: stringToBoolean(features.isHosted) || window.location.hostname.includes('hosted.mender.io')\n };\n onboardingComplete = !environmentFeatures.isHosted || stringToBoolean(disableOnboarding) || onboardingComplete;\n versionInfo = {\n docs: isNaN(parseInt(integrationVersion.charAt(0))) ? '' : integrationVersion.split('.').slice(0, 2).join('.'),\n remainder: {\n Integration: getComparisonCompatibleVersion(integrationVersion),\n 'Mender-Artifact': menderArtifactVersion,\n 'Meta-Mender': metaMenderVersion\n }\n };\n }\n return Promise.all([\n dispatch(storeActions.successfullyLoggedIn(getSessionInfo())),\n dispatch(storeActions.setOnboardingComplete(onboardingComplete)),\n dispatch(storeActions.setDemoArtifactPort(demoArtifactPort)),\n dispatch(storeActions.setFeatures(environmentFeatures)),\n dispatch(storeActions.setVersionInformation({ ...(versionInfo.remainder ?? {}), docsVersion: versionInfo.docs })),\n dispatch(storeActions.setEnvironmentData(environmentData)),\n dispatch(getLatestReleaseInfo())\n ]);\n});\n\ntype OnboardingState = {\n complete?: boolean;\n showTips?: boolean | null;\n};\n\ntype MaybeAddOnboardingTasksParams = {\n devicesByStatus: DeviceSliceType['byStatus'];\n dispatch: AppDispatch;\n onboardingState: OnboardingState;\n tasks: Promise<unknown>[];\n};\n\nconst maybeAddOnboardingTasks = ({ devicesByStatus, dispatch, onboardingState, tasks }: MaybeAddOnboardingTasksParams): Promise<unknown>[] => {\n if (!onboardingState.showTips || onboardingState.complete) {\n return tasks;\n }\n // try to retrieve full device details for onboarding devices to ensure ips etc. are available\n // we only load the first few/ 20 devices, as it is possible the onboarding is left dangling\n // and a lot of devices are present and we don't want to flood the backend for this\n return devicesByStatus[DEVICE_STATES.accepted].deviceIds.reduce<Promise<unknown>[]>((accu, id) => {\n accu.push(dispatch(getDeviceById(id)));\n return accu;\n }, tasks);\n};\n\nexport const useAppInit = (userId: string | undefined): { coreInitDone: boolean } => {\n const dispatch = useAppDispatch();\n const [coreInitDone, setCoreInitDone] = useState(false);\n const isEnterprise = useAppSelector(getIsEnterprise);\n const { hasMultitenancy, isHosted } = useAppSelector(getFeatures);\n const devicesByStatus = useAppSelector(getDevicesByStatusSelector);\n const onboardingState = useAppSelector(getOnboardingStateSelector);\n const { columnSelection = [], trackingConsentGiven: hasTrackingEnabled, tooltips = {} } = useAppSelector(getUserSettingsSelector);\n const { canManageUsers } = useAppSelector(getUserCapabilities);\n const { interval, intervalUnit } = useAppSelector(getOfflineThresholdSettings);\n const { id_attribute } = useAppSelector(getGlobalSettingsSelector);\n const { identityAttributes } = useAppSelector(getSortedFilteringAttributes);\n const isServiceProvider = useAppSelector(getIsServiceProvider);\n const coreInitRunning = useRef(false);\n const fullInitRunning = useRef(false);\n\n const retrieveCoreData = useCallback((): Promise<unknown[]> => {\n const tasks: Promise<unknown>[] = [\n dispatch(parseEnvironmentInfo()).unwrap(),\n dispatch(getUserSettings()).unwrap(),\n dispatch(getGlobalSettings()).unwrap(),\n Promise.resolve(dispatch(setFirstLoginAfterSignup(stringToBoolean(cookies.get('firstLoginAfterSignup')))))\n ];\n const multitenancy = hasMultitenancy || isHosted || isEnterprise;\n if (multitenancy) {\n tasks.push(dispatch(getUserOrganization()).unwrap());\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isHosted, isEnterprise]);\n\n const retrieveAppData = useCallback((): Promise<unknown[] | unknown> => {\n if (isServiceProvider) {\n return Promise.resolve(dispatch(getRoles()));\n }\n const tasks: Promise<unknown>[] = [\n dispatch(getDeviceAttributes()),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.finished, shouldSelect: false })),\n dispatch(getDeploymentsByStatus({ status: DEPLOYMENT_STATES.inprogress })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.accepted })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.pending })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.preauth })),\n dispatch(getDevicesByStatus({ status: DEVICE_STATES.rejected })),\n dispatch(getDynamicGroups()),\n dispatch(getGroups()),\n dispatch(getIntegrations()),\n dispatch(getReleases()),\n dispatch(getAllDeviceCounts()).unwrap()\n ];\n if (hasMultitenancy) {\n tasks.push(dispatch(getDeviceLimits()));\n tasks.push(dispatch(getRoles()));\n }\n return Promise.all(tasks);\n }, [dispatch, hasMultitenancy, isServiceProvider]);\n\n const interpretAppData = useCallback((): Promise<unknown[]> => {\n const settings: Partial<UserSettings> = {};\n if (cookies.get('_ga') && typeof hasTrackingEnabled === 'undefined') {\n settings.trackingConsentGiven = true;\n }\n let tasks: Promise<unknown>[] = [\n Promise.resolve(dispatch(setDeviceListState({ selectedAttributes: columnSelection.map(column => ({ attribute: column.key, scope: column.scope })) }))),\n Promise.resolve(dispatch(setTooltipsState(tooltips as UserSliceType['tooltips']['byId']))), // tooltips read state is primarily trusted from the redux store, except on app init - here user settings are the reference\n dispatch(saveUserSettings(settings)).unwrap()\n ];\n // checks if user id is set and if cookie for helptips exists for that user\n tasks = maybeAddOnboardingTasks({ devicesByStatus, dispatch, tasks, onboardingState });\n\n if (canManageUsers && intervalUnit && intervalUnit !== timeUnits.days) {\n const duration = dayjs.duration(interval, intervalUnit as keyof typeof timeUnits);\n const days = duration.asDays();\n if (days < 1) {\n tasks.push(Promise.resolve(setTimeout(() => dispatch(setShowStartupNotification(true)), TIMEOUTS.fiveSeconds)));\n } else {\n const roundedDays = Math.max(1, Math.round(days));\n tasks.push(dispatch(saveGlobalSettings({ offlineThreshold: { interval: roundedDays, intervalUnit: timeUnits.days } })));\n }\n }\n\n // the following is used as a migration and initialization of the stored identity attribute\n // changing the default device attribute to the first non-deviceId attribute, unless a stored\n // id attribute setting exists\n const identityOptions = identityAttributes.filter(attribute => !['id', 'Device ID', 'status'].includes(attribute));\n if (!id_attribute && identityOptions.length) {\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute: identityOptions[0], scope: 'identity' } })));\n } else if (typeof id_attribute === 'string') {\n // Legacy migration path: id_attribute used to be a plain string\n let attribute: string = id_attribute;\n if (attribute === 'Device ID') {\n attribute = 'id';\n }\n tasks.push(dispatch(saveGlobalSettings({ id_attribute: { attribute, scope: 'identity' } })));\n }\n tasks.push(Promise.resolve(dispatch(storeActions.setAppInitDone())));\n return Promise.all(tasks);\n }, [\n columnSelection,\n dispatch,\n identityAttributes,\n hasTrackingEnabled,\n canManageUsers,\n devicesByStatus,\n id_attribute,\n interval,\n intervalUnit,\n onboardingState,\n tooltips\n ]);\n\n const initializeAppData = useCallback(\n (): Promise<unknown> =>\n retrieveAppData()\n .then(interpretAppData)\n // this is allowed to fail if no user information are available\n .catch(err => console.log(extractErrorMessage(err)))\n .then(() => dispatch(getOnboardingState())),\n [dispatch, retrieveAppData, interpretAppData]\n );\n\n useEffect(() => {\n if (!userId || coreInitRunning.current) {\n return;\n }\n coreInitRunning.current = true;\n retrieveCoreData().then(() => setCoreInitDone(true));\n }, [userId, retrieveCoreData]);\n\n useEffect(() => {\n if (fullInitRunning.current || !coreInitDone) {\n return;\n }\n fullInitRunning.current = true;\n initializeAppData();\n }, [initializeAppData, coreInitDone]);\n\n return { coreInitDone };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,UAAU,IAAIA,iBAAAA,SAAS;AAC7B,MAAA,QAAM,OAAOC,yBAAAA,QAAc;AAE3B,MAAM,EAAE,oBAAoB,0BAA0B,kBAAkB,+BAA+BC;AAEvG,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AASD,MAAa,uBAAuBC,cAAAA,oBAAoB,6BAA6B,GAAG,EAAE,UAAU,eAAe;CACjH,MAAM,QAAQ,UAAU;CACxB,IAAI,qBAAqBC,wBAAAA,mBAA2B,MAAM,CAAC,YAAY,CAAC,CAAC,KAAK,MAAM,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;CACjJ,IAAI,mBAAmB;CACvB,IAAI,kBAA2C,EAAE;CACjD,IAAI,sBAAyC,EAAE;CAC/C,IAAI,cAA2B,EAAE;CACjC,MAAM,qBAAqB,OAAO;CAClC,IAAI,oBAAoB;EACtB,MAAM,EAAE,WAAW,EAAE,EAAE,kBAAkB,MAAM,mBAAmB,oBAAoB,uBAAuB,sBAAsB;EACnI,mBAAmB,OAAO,KAAK,IAAI;EACnC,MAAM,WAAW,MAAM;EACvB,kBAAkB,iBAAiB,QAAQ,MAAM,UAAU;GAAE,GAAG;IAAO,OAAO,mBAAmB,SAAS,SAAS;GAAgC,GAAG,EAAE,CAAC;EACzJ,sBAAsB;GACpB,GAAG,aAAa,QA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ACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,qBAAA,GAAA,MAAA,mBAEF,iBAAiB,CACd,KAAK,iBAAiB,CAEtB,OAAM,QAAO,QAAQ,KAAA,GAAA,6BAAA,qBAAwB,IAAI,CAAC,CAAC,CACnD,WAAW,SAASsC,eAAAA,oBAAoB,CAAC,CAAC,EAC/C;EAAC;EAAU;EAAiB;EAAiB,CAC9C;CAED,CAAA,GAAA,MAAA,iBAAgB;EACd,IAAI,CAAC,UAAU,gBAAgB,SAC7B;EAEF,gBAAgB,UAAU;EAC1B,kBAAkB,CAAC,WAAW,gBAAgB,KAAK,CAAC;IACnD,CAAC,QAAQ,iBAAiB,CAAC;CAE9B,CAAA,GAAA,MAAA,iBAAgB;EACd,IAAI,gBAAgB,WAAW,CAAC,cAC9B;EAEF,gBAAgB,UAAU;EAC1B,mBAAmB;IAClB,CAAC,mBAAmB,aAAa,CAAC;CAErC,OAAO,EAAE,cAAc"}
@@ -1,5 +1,5 @@
1
- import { i as UserSession } from "./index-4eaLEXy_.cjs";
2
- import { r as RootState, t as AppDispatch } from "./store-BiIA0r0A.cjs";
1
+ import { i as UserSession } from "./index-BFlHWzjv.cjs";
2
+ import { r as RootState, t as AppDispatch } from "./store-b5cF2WB5.cjs";
3
3
  import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
4
4
 
5
5
  //#region src/storehooks.d.ts
@@ -1,5 +1,5 @@
1
- import { i as UserSession } from "./index-DtePEQPT.js";
2
- import { r as RootState, t as AppDispatch } from "./store-BQxOSRC1.js";
1
+ import { i as UserSession } from "./index-ez3oxfRo.js";
2
+ import { r as RootState, t as AppDispatch } from "./store-D-xvZXiY.js";
3
3
  import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
4
4
 
5
5
  //#region src/storehooks.d.ts