@bigbinary/neeto-molecules 4.0.19 → 4.0.30
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.
- package/dist/AuditLogs.js +5 -5
- package/dist/AuditLogs.js.map +1 -1
- package/dist/BoardView.js +6 -6
- package/dist/BoardView.js.map +1 -1
- package/dist/Breadcrumbs.js +1 -1
- package/dist/Breadcrumbs.js.map +1 -1
- package/dist/BrowserPreview.js +1 -1
- package/dist/BrowserPreview.js.map +1 -1
- package/dist/BrowserSupport.js +2 -2
- package/dist/BrowserSupport.js.map +1 -1
- package/dist/Builder.js +7 -7
- package/dist/Builder.js.map +1 -1
- package/dist/ButtonGroup.js +2 -2
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/CalendarView.js +4 -4
- package/dist/CalendarView.js.map +1 -1
- package/dist/CardLayout.js.map +1 -1
- package/dist/{Chevron-DEQtNhrI.js → Chevron-BFX_mIg6.js} +5 -5
- package/dist/{Chevron-DEQtNhrI.js.map → Chevron-BFX_mIg6.js.map} +1 -1
- package/dist/Codeblock.js +2 -2
- package/dist/Codeblock.js.map +1 -1
- package/dist/{Columns-CwbG5wLv.js → Columns-xoAs08GC.js} +6 -6
- package/dist/{Columns-CwbG5wLv.js.map → Columns-xoAs08GC.js.map} +1 -1
- package/dist/Columns.js +2 -2
- package/dist/ConfigurePageSidebar.js +2 -2
- package/dist/ConfigurePageSidebar.js.map +1 -1
- package/dist/ConfirmationModal.js.map +1 -1
- package/dist/Container.js +1 -1
- package/dist/Container.js.map +1 -1
- package/dist/CopyToClipboardButton.js +2 -2
- package/dist/CopyToClipboardButton.js.map +1 -1
- package/dist/Currency.js +2 -2
- package/dist/Currency.js.map +1 -1
- package/dist/DateFormat.js +1 -1
- package/dist/DateFormat.js.map +1 -1
- package/dist/DateRangeFilter.js +1 -1
- package/dist/DateRangeFilter.js.map +1 -1
- package/dist/DeleteArchiveModal.js.map +1 -1
- package/dist/DeviceIncompatibilityMessage.js.map +1 -1
- package/dist/DocumentEditor.js +2 -2
- package/dist/DocumentEditor.js.map +1 -1
- package/dist/DownloadMobileAppCallout.js.map +1 -1
- package/dist/DynamicVariables.js +2 -2
- package/dist/DynamicVariables.js.map +1 -1
- package/dist/EmailForm.js +5 -5
- package/dist/EmailForm.js.map +1 -1
- package/dist/EmailPreview.js.map +1 -1
- package/dist/EmojiPicker.js +1 -1
- package/dist/EmojiPicker.js.map +1 -1
- package/dist/EmojiReactions.js.map +1 -1
- package/dist/Engagements.js +2 -2
- package/dist/Engagements.js.map +1 -1
- package/dist/ErrorPage.js +369 -657
- package/dist/ErrorPage.js.map +1 -1
- package/dist/FileUpload.js +14 -14
- package/dist/FileUpload.js.map +1 -1
- package/dist/FinderModal.js +3 -3
- package/dist/FinderModal.js.map +1 -1
- package/dist/FloatingActionMenu.js +7 -7
- package/dist/FloatingActionMenu.js.map +1 -1
- package/dist/GoogleFontPicker.js +21 -21
- package/dist/GoogleFontPicker.js.map +1 -1
- package/dist/Header.js +2 -2
- package/dist/Header.js.map +1 -1
- package/dist/HelpPopover.js +1 -1
- package/dist/HelpPopover.js.map +1 -1
- package/dist/IconPicker.js +2 -2
- package/dist/IconPicker.js.map +1 -1
- package/dist/ImageWithFallback.js +2 -2
- package/dist/ImageWithFallback.js.map +1 -1
- package/dist/InlineInput.js +17 -17
- package/dist/InlineInput.js.map +1 -1
- package/dist/Insights.js +2 -8
- package/dist/Insights.js.map +1 -1
- package/dist/IntegrationCard.js +3 -3
- package/dist/IntegrationCard.js.map +1 -1
- package/dist/IpRestriction.js +574 -488
- package/dist/IpRestriction.js.map +1 -1
- package/dist/KeyboardShortcuts.js +2 -4
- package/dist/KeyboardShortcuts.js.map +1 -1
- package/dist/LoginPage.js +23 -24
- package/dist/LoginPage.js.map +1 -1
- package/dist/MadeWith.js +2 -2
- package/dist/MadeWith.js.map +1 -1
- package/dist/MenuBar.js +6 -6
- package/dist/MenuBar.js.map +1 -1
- package/dist/Metadata.js +1 -1
- package/dist/Metadata.js.map +1 -1
- package/dist/MobilePreviewHeader.js.map +1 -1
- package/dist/MoreDropdown.js +4 -4
- package/dist/MoreDropdown.js.map +1 -1
- package/dist/NavigationHeader.js +4 -4
- package/dist/NavigationHeader.js.map +1 -1
- package/dist/NeetoWidget.js +5 -5
- package/dist/NeetoWidget.js.map +1 -1
- package/dist/Onboarding.js +4 -4
- package/dist/Onboarding.js.map +1 -1
- package/dist/OptionFields.js +7 -7
- package/dist/OptionFields.js.map +1 -1
- package/dist/PageLoader.js +2 -2
- package/dist/PageLoader.js.map +1 -1
- package/dist/PhoneNumber.js +5 -6
- package/dist/PhoneNumber.js.map +1 -1
- package/dist/ProductEmbed.js +6 -6
- package/dist/ProductEmbed.js.map +1 -1
- package/dist/PublishBlock.js +3 -3
- package/dist/PublishBlock.js.map +1 -1
- package/dist/PublishYourItem.js.map +1 -1
- package/dist/Rename.js +5 -5
- package/dist/Rename.js.map +1 -1
- package/dist/ResponsiveDevicePicker.js +2 -2
- package/dist/ResponsiveDevicePicker.js.map +1 -1
- package/dist/Schedule.js +3 -3
- package/dist/Schedule.js.map +1 -1
- package/dist/Scrollable.js +2 -2
- package/dist/Scrollable.js.map +1 -1
- package/dist/Search.js +2 -2
- package/dist/Search.js.map +1 -1
- package/dist/SendToFields.js +93 -70
- package/dist/SendToFields.js.map +1 -1
- package/dist/SessionEnvironment.js +3 -4
- package/dist/SessionEnvironment.js.map +1 -1
- package/dist/Settings.js +6 -6
- package/dist/Settings.js.map +1 -1
- package/dist/ShareRecordingPane.js +2 -2
- package/dist/ShareRecordingPane.js.map +1 -1
- package/dist/ShareViaEmail.js +3 -3
- package/dist/ShareViaEmail.js.map +1 -1
- package/dist/ShareViaLink.js +30 -30
- package/dist/ShareViaLink.js.map +1 -1
- package/dist/Sidebar.js +6 -6
- package/dist/Sidebar.js.map +1 -1
- package/dist/StatusDropdown.js +2 -2
- package/dist/StatusDropdown.js.map +1 -1
- package/dist/StickyRibbonsContainer.js +10 -12
- package/dist/StickyRibbonsContainer.js.map +1 -1
- package/dist/SubHeader.js +5 -5
- package/dist/SubHeader.js.map +1 -1
- package/dist/SubscriptionNotificationsContainer.js +1 -1
- package/dist/SubscriptionNotificationsContainer.js.map +1 -1
- package/dist/SuffixedInput.js +2 -2
- package/dist/SuffixedInput.js.map +1 -1
- package/dist/TableWrapper.js +1 -1
- package/dist/TableWrapper.js.map +1 -1
- package/dist/Taxonomy.js +16 -16
- package/dist/Taxonomy.js.map +1 -1
- package/dist/TimeFormat.js.map +1 -1
- package/dist/TimezoneMismatchModal.js.map +1 -1
- package/dist/ToggleFeatureCard.js +3 -3
- package/dist/ToggleFeatureCard.js.map +1 -1
- package/dist/VersionHistory.js +3 -3
- package/dist/VersionHistory.js.map +1 -1
- package/dist/cjs/AuditLogs.js +5 -5
- package/dist/cjs/AuditLogs.js.map +1 -1
- package/dist/cjs/BoardView.js +6 -6
- package/dist/cjs/BoardView.js.map +1 -1
- package/dist/cjs/Breadcrumbs.js +1 -1
- package/dist/cjs/Breadcrumbs.js.map +1 -1
- package/dist/cjs/BrowserPreview.js +1 -1
- package/dist/cjs/BrowserPreview.js.map +1 -1
- package/dist/cjs/BrowserSupport.js +2 -2
- package/dist/cjs/BrowserSupport.js.map +1 -1
- package/dist/cjs/Builder.js +6 -6
- package/dist/cjs/Builder.js.map +1 -1
- package/dist/cjs/ButtonGroup.js +2 -2
- package/dist/cjs/ButtonGroup.js.map +1 -1
- package/dist/cjs/CalendarView.js +4 -4
- package/dist/cjs/CalendarView.js.map +1 -1
- package/dist/cjs/CardLayout.js.map +1 -1
- package/dist/cjs/{Chevron-u-rD2gAf.js → Chevron-ClvaNo3d.js} +5 -5
- package/dist/cjs/{Chevron-u-rD2gAf.js.map → Chevron-ClvaNo3d.js.map} +1 -1
- package/dist/cjs/Codeblock.js +2 -2
- package/dist/cjs/Codeblock.js.map +1 -1
- package/dist/cjs/{Columns-CZDLxh70.js → Columns-C95kM2yL.js} +6 -6
- package/dist/cjs/{Columns-CZDLxh70.js.map → Columns-C95kM2yL.js.map} +1 -1
- package/dist/cjs/Columns.js +2 -2
- package/dist/cjs/ConfigurePageSidebar.js +2 -2
- package/dist/cjs/ConfigurePageSidebar.js.map +1 -1
- package/dist/cjs/ConfirmationModal.js.map +1 -1
- package/dist/cjs/Container.js +1 -1
- package/dist/cjs/Container.js.map +1 -1
- package/dist/cjs/CopyToClipboardButton.js +2 -2
- package/dist/cjs/CopyToClipboardButton.js.map +1 -1
- package/dist/cjs/Currency.js +2 -2
- package/dist/cjs/Currency.js.map +1 -1
- package/dist/cjs/DateFormat.js +1 -1
- package/dist/cjs/DateFormat.js.map +1 -1
- package/dist/cjs/DateRangeFilter.js +1 -1
- package/dist/cjs/DateRangeFilter.js.map +1 -1
- package/dist/cjs/DeleteArchiveModal.js.map +1 -1
- package/dist/cjs/DeviceIncompatibilityMessage.js.map +1 -1
- package/dist/cjs/DocumentEditor.js +2 -2
- package/dist/cjs/DocumentEditor.js.map +1 -1
- package/dist/cjs/DownloadMobileAppCallout.js.map +1 -1
- package/dist/cjs/DynamicVariables.js +2 -2
- package/dist/cjs/DynamicVariables.js.map +1 -1
- package/dist/cjs/EmailForm.js +5 -5
- package/dist/cjs/EmailForm.js.map +1 -1
- package/dist/cjs/EmailPreview.js.map +1 -1
- package/dist/cjs/EmojiPicker.js +1 -1
- package/dist/cjs/EmojiPicker.js.map +1 -1
- package/dist/cjs/EmojiReactions.js.map +1 -1
- package/dist/cjs/Engagements.js +2 -2
- package/dist/cjs/Engagements.js.map +1 -1
- package/dist/cjs/ErrorPage.js +369 -657
- package/dist/cjs/ErrorPage.js.map +1 -1
- package/dist/cjs/FileUpload.js +14 -14
- package/dist/cjs/FileUpload.js.map +1 -1
- package/dist/cjs/FinderModal.js +3 -3
- package/dist/cjs/FinderModal.js.map +1 -1
- package/dist/cjs/FloatingActionMenu.js +6 -6
- package/dist/cjs/FloatingActionMenu.js.map +1 -1
- package/dist/cjs/GoogleFontPicker.js +21 -21
- package/dist/cjs/GoogleFontPicker.js.map +1 -1
- package/dist/cjs/Header.js +2 -2
- package/dist/cjs/Header.js.map +1 -1
- package/dist/cjs/HelpPopover.js +1 -1
- package/dist/cjs/HelpPopover.js.map +1 -1
- package/dist/cjs/IconPicker.js +2 -2
- package/dist/cjs/IconPicker.js.map +1 -1
- package/dist/cjs/ImageWithFallback.js +2 -2
- package/dist/cjs/ImageWithFallback.js.map +1 -1
- package/dist/cjs/InlineInput.js +17 -17
- package/dist/cjs/InlineInput.js.map +1 -1
- package/dist/cjs/Insights.js +2 -8
- package/dist/cjs/Insights.js.map +1 -1
- package/dist/cjs/IntegrationCard.js +3 -3
- package/dist/cjs/IntegrationCard.js.map +1 -1
- package/dist/cjs/IpRestriction.js +574 -488
- package/dist/cjs/IpRestriction.js.map +1 -1
- package/dist/cjs/KeyboardShortcuts.js +2 -4
- package/dist/cjs/KeyboardShortcuts.js.map +1 -1
- package/dist/cjs/LoginPage.js +23 -24
- package/dist/cjs/LoginPage.js.map +1 -1
- package/dist/cjs/MadeWith.js +2 -2
- package/dist/cjs/MadeWith.js.map +1 -1
- package/dist/cjs/MenuBar.js +6 -6
- package/dist/cjs/MenuBar.js.map +1 -1
- package/dist/cjs/Metadata.js +1 -1
- package/dist/cjs/Metadata.js.map +1 -1
- package/dist/cjs/MobilePreviewHeader.js.map +1 -1
- package/dist/cjs/MoreDropdown.js +4 -4
- package/dist/cjs/MoreDropdown.js.map +1 -1
- package/dist/cjs/NavigationHeader.js +4 -4
- package/dist/cjs/NavigationHeader.js.map +1 -1
- package/dist/cjs/NeetoWidget.js +5 -5
- package/dist/cjs/NeetoWidget.js.map +1 -1
- package/dist/cjs/Onboarding.js +3 -3
- package/dist/cjs/Onboarding.js.map +1 -1
- package/dist/cjs/OptionFields.js +6 -6
- package/dist/cjs/OptionFields.js.map +1 -1
- package/dist/cjs/PageLoader.js +2 -2
- package/dist/cjs/PageLoader.js.map +1 -1
- package/dist/cjs/PhoneNumber.js +4 -5
- package/dist/cjs/PhoneNumber.js.map +1 -1
- package/dist/cjs/ProductEmbed.js +5 -5
- package/dist/cjs/ProductEmbed.js.map +1 -1
- package/dist/cjs/PublishBlock.js +3 -3
- package/dist/cjs/PublishBlock.js.map +1 -1
- package/dist/cjs/PublishYourItem.js.map +1 -1
- package/dist/cjs/Rename.js +5 -5
- package/dist/cjs/Rename.js.map +1 -1
- package/dist/cjs/ResponsiveDevicePicker.js +2 -2
- package/dist/cjs/ResponsiveDevicePicker.js.map +1 -1
- package/dist/cjs/Schedule.js +3 -3
- package/dist/cjs/Schedule.js.map +1 -1
- package/dist/cjs/Scrollable.js +2 -2
- package/dist/cjs/Scrollable.js.map +1 -1
- package/dist/cjs/Search.js +2 -2
- package/dist/cjs/Search.js.map +1 -1
- package/dist/cjs/SendToFields.js +93 -70
- package/dist/cjs/SendToFields.js.map +1 -1
- package/dist/cjs/SessionEnvironment.js +3 -4
- package/dist/cjs/SessionEnvironment.js.map +1 -1
- package/dist/cjs/Settings.js +6 -6
- package/dist/cjs/Settings.js.map +1 -1
- package/dist/cjs/ShareRecordingPane.js +2 -2
- package/dist/cjs/ShareRecordingPane.js.map +1 -1
- package/dist/cjs/ShareViaEmail.js +3 -3
- package/dist/cjs/ShareViaEmail.js.map +1 -1
- package/dist/cjs/ShareViaLink.js +24 -24
- package/dist/cjs/ShareViaLink.js.map +1 -1
- package/dist/cjs/Sidebar.js +5 -5
- package/dist/cjs/Sidebar.js.map +1 -1
- package/dist/cjs/StatusDropdown.js +2 -2
- package/dist/cjs/StatusDropdown.js.map +1 -1
- package/dist/cjs/StickyRibbonsContainer.js +10 -12
- package/dist/cjs/StickyRibbonsContainer.js.map +1 -1
- package/dist/cjs/SubHeader.js +5 -5
- package/dist/cjs/SubHeader.js.map +1 -1
- package/dist/cjs/SubscriptionNotificationsContainer.js +1 -1
- package/dist/cjs/SubscriptionNotificationsContainer.js.map +1 -1
- package/dist/cjs/SuffixedInput.js +2 -2
- package/dist/cjs/SuffixedInput.js.map +1 -1
- package/dist/cjs/TableWrapper.js +1 -1
- package/dist/cjs/TableWrapper.js.map +1 -1
- package/dist/cjs/Taxonomy.js +16 -16
- package/dist/cjs/Taxonomy.js.map +1 -1
- package/dist/cjs/TimeFormat.js.map +1 -1
- package/dist/cjs/TimezoneMismatchModal.js.map +1 -1
- package/dist/cjs/ToggleFeatureCard.js +3 -3
- package/dist/cjs/ToggleFeatureCard.js.map +1 -1
- package/dist/cjs/VersionHistory.js +3 -3
- package/dist/cjs/VersionHistory.js.map +1 -1
- package/dist/cjs/index-JY2zVpnv.js.map +1 -1
- package/dist/cjs/inject-css-B6qYtOJe.js +6 -0
- package/dist/cjs/inject-css-B6qYtOJe.js.map +1 -0
- package/dist/cjs/{phone-number-C93qn93_.js → phone-number-1EDAr56u.js} +34 -24
- package/dist/cjs/phone-number-1EDAr56u.js.map +1 -0
- package/dist/cjs/platform-BUcCb8Jx.js.map +1 -1
- package/dist/cjs/useKeyboardShortcutsPaneState-YnXpWOcs.js.map +1 -1
- package/dist/index-DAYCJu79.js.map +1 -1
- package/dist/inject-css-C2dztUxs.js +4 -0
- package/dist/inject-css-C2dztUxs.js.map +1 -0
- package/dist/{phone-number-CSXPpNBP.js → phone-number-BDkpXCIq.js} +36 -26
- package/dist/phone-number-BDkpXCIq.js.map +1 -0
- package/dist/platform-F44zJ4Xh.js.map +1 -1
- package/dist/useKeyboardShortcutsPaneState-C_eLceJQ.js.map +1 -1
- package/package.json +12 -14
- package/types/ButtonGroup.d.ts +2 -1
- package/types/CopyToClipboardButton.d.ts +2 -1
- package/types/EmailPreview.d.ts +2 -1
- package/types/FileUpload.d.ts +2 -1
- package/types/Header.d.ts +2 -1
- package/types/HelpPopover.d.ts +2 -1
- package/types/InlineInput.d.ts +2 -1
- package/types/IntegrationCard.d.ts +2 -1
- package/types/MoreDropdown.d.ts +1 -1
- package/types/PhoneNumber.d.ts +2 -1
- package/types/PublishBlock.d.ts +1 -1
- package/types/SubHeader.d.ts +1 -1
- package/types/ToggleFeatureCard.d.ts +1 -1
- package/dist/cjs/inject-css-vQvjPR2x.js +0 -6
- package/dist/cjs/inject-css-vQvjPR2x.js.map +0 -1
- package/dist/cjs/phone-number-C93qn93_.js.map +0 -1
- package/dist/inject-css-DmrvuTKK.js +0 -4
- package/dist/inject-css-DmrvuTKK.js.map +0 -1
- package/dist/phone-number-CSXPpNBP.js.map +0 -1
- package/src/translations/ar.json +0 -867
- package/src/translations/bg.json +0 -275
- package/src/translations/ca.json +0 -867
- package/src/translations/cs.json +0 -867
- package/src/translations/da.json +0 -867
- package/src/translations/de.json +0 -867
- package/src/translations/en.json +0 -867
- package/src/translations/es-MX.json +0 -867
- package/src/translations/es.json +0 -867
- package/src/translations/et.json +0 -867
- package/src/translations/fi.json +0 -867
- package/src/translations/fil.json +0 -867
- package/src/translations/fr.json +0 -867
- package/src/translations/hi.json +0 -275
- package/src/translations/hr.json +0 -867
- package/src/translations/id.json +0 -867
- package/src/translations/it.json +0 -867
- package/src/translations/ja.json +0 -867
- package/src/translations/ko.json +0 -867
- package/src/translations/nl.json +0 -867
- package/src/translations/pl.json +0 -867
- package/src/translations/pt-BR.json +0 -867
- package/src/translations/pt.json +0 -867
- package/src/translations/ro.json +0 -867
- package/src/translations/ru.json +0 -867
- package/src/translations/sk.json +0 -867
- package/src/translations/sl.json +0 -867
- package/src/translations/sv.json +0 -867
- package/src/translations/th.json +0 -867
- package/src/translations/tr.json +0 -867
- package/src/translations/uk.json +0 -867
- package/src/translations/vi.json +0 -867
- package/src/translations/zh-CN.json +0 -867
- package/src/translations/zh-TW.json +0 -867
|
@@ -29,7 +29,7 @@ var reactQuery = require('@tanstack/react-query');
|
|
|
29
29
|
var axios = require('axios');
|
|
30
30
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
31
31
|
var useMutationWithInvalidation = require('@bigbinary/neeto-commons-frontend/react-utils/useMutationWithInvalidation');
|
|
32
|
-
var injectCss = require('./inject-css-
|
|
32
|
+
var injectCss = require('./inject-css-B6qYtOJe.js');
|
|
33
33
|
require('@bigbinary/neeto-cist');
|
|
34
34
|
|
|
35
35
|
function _interopNamespaceDefault(e) {
|
|
@@ -51,7 +51,7 @@ function _interopNamespaceDefault(e) {
|
|
|
51
51
|
|
|
52
52
|
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
|
|
53
53
|
|
|
54
|
-
var
|
|
54
|
+
var src = {};
|
|
55
55
|
|
|
56
56
|
var BinaryUtils = {};
|
|
57
57
|
|
|
@@ -64,9 +64,10 @@ var BinaryUtils = {};
|
|
|
64
64
|
* @param num number to parse
|
|
65
65
|
* @returns {string} the binary string representation of number
|
|
66
66
|
*/
|
|
67
|
-
|
|
67
|
+
let numberToBinaryString = (num) => {
|
|
68
68
|
return num.toString(2);
|
|
69
69
|
};
|
|
70
|
+
exports.numberToBinaryString = numberToBinaryString;
|
|
70
71
|
/**
|
|
71
72
|
* Converts a decimal number to binary octet (8 bit) string. If needed the octet will be padded with zeros
|
|
72
73
|
* to make it up to 8 bits
|
|
@@ -74,23 +75,25 @@ var BinaryUtils = {};
|
|
|
74
75
|
* @param {number} num to convert to octet string
|
|
75
76
|
* @returns {string} the octet string representation of given number
|
|
76
77
|
*/
|
|
77
|
-
|
|
78
|
-
let binaryString = exports.numberToBinaryString(num);
|
|
78
|
+
let decimalNumberToOctetString = (num) => {
|
|
79
|
+
let binaryString = (0, exports.numberToBinaryString)(num);
|
|
79
80
|
let length = binaryString.length;
|
|
80
81
|
if (length > 8) {
|
|
81
82
|
throw new Error("Given decimal in binary contains digits greater than an octet");
|
|
82
83
|
}
|
|
83
|
-
return exports.leftPadWithZeroBit(binaryString, 8);
|
|
84
|
+
return (0, exports.leftPadWithZeroBit)(binaryString, 8);
|
|
84
85
|
};
|
|
86
|
+
exports.decimalNumberToOctetString = decimalNumberToOctetString;
|
|
85
87
|
/**
|
|
86
88
|
* Parses number in binary to number in BigInt
|
|
87
89
|
*
|
|
88
90
|
* @param num binary number in string to parse
|
|
89
91
|
* @returns {number} binary number in BigInt
|
|
90
92
|
*/
|
|
91
|
-
|
|
93
|
+
let parseBinaryStringToBigInt = (num) => {
|
|
92
94
|
return BigInt(`0b${num}`);
|
|
93
95
|
};
|
|
96
|
+
exports.parseBinaryStringToBigInt = parseBinaryStringToBigInt;
|
|
94
97
|
/**
|
|
95
98
|
* Given an IPv4 number in dot-decimal notated string, e.g 192.168.0.1 converts it to
|
|
96
99
|
* binary string, e.g. '11000000101010000000000000000001'
|
|
@@ -98,33 +101,35 @@ var BinaryUtils = {};
|
|
|
98
101
|
* @param dottedDecimal IPv4 string in dot-decimal notation
|
|
99
102
|
* @returns {string} the binary value of the given ipv4 number in string
|
|
100
103
|
*/
|
|
101
|
-
|
|
104
|
+
let dottedDecimalNotationToBinaryString = (dottedDecimal) => {
|
|
102
105
|
let stringOctets = dottedDecimal.split(".");
|
|
103
106
|
return stringOctets.reduce((binaryAsString, octet) => {
|
|
104
|
-
return binaryAsString.concat(exports.decimalNumberToOctetString(parseInt(octet)));
|
|
107
|
+
return binaryAsString.concat((0, exports.decimalNumberToOctetString)(parseInt(octet)));
|
|
105
108
|
}, '');
|
|
106
109
|
};
|
|
110
|
+
exports.dottedDecimalNotationToBinaryString = dottedDecimalNotationToBinaryString;
|
|
107
111
|
/**
|
|
108
112
|
* Given a binary string, adds a number of zero to the left until string is as long as the given string length
|
|
109
113
|
* @param {string} binaryString the string to pad
|
|
110
114
|
* @param {number} finalStringLength the final length of string after padding
|
|
111
115
|
* @returns {string}
|
|
112
116
|
*/
|
|
113
|
-
|
|
117
|
+
let leftPadWithZeroBit = (binaryString, finalStringLength) => {
|
|
114
118
|
if (binaryString.length > finalStringLength) {
|
|
115
119
|
throw new Error(`Given string is already longer than given final length after padding: ${finalStringLength}`);
|
|
116
120
|
}
|
|
117
121
|
return "0".repeat(finalStringLength - binaryString.length).concat(binaryString);
|
|
118
122
|
};
|
|
123
|
+
exports.leftPadWithZeroBit = leftPadWithZeroBit;
|
|
119
124
|
/**
|
|
120
125
|
* Given the prefix portion of a cidr notation and the type of IP number, returns the mask in binary string
|
|
121
126
|
*
|
|
122
127
|
* @param {number} cidrPrefix the prefix part of a cidr notation
|
|
123
128
|
* @param {IPNumType.IPv4 | IPNumType.IPv6} ipType the type of the ip number in the range the cidr represents
|
|
124
129
|
*/
|
|
125
|
-
|
|
130
|
+
let cidrPrefixToMaskBinaryString = (cidrPrefix, ipType) => {
|
|
126
131
|
let cidrUpperValue;
|
|
127
|
-
if (ipType == "IPv4" /* IPv4 */) {
|
|
132
|
+
if (ipType == "IPv4" /* IPNumType.IPv4 */) {
|
|
128
133
|
cidrUpperValue = 32;
|
|
129
134
|
}
|
|
130
135
|
else {
|
|
@@ -136,6 +141,7 @@ var BinaryUtils = {};
|
|
|
136
141
|
let offBits = '0'.repeat(cidrUpperValue - cidrPrefix);
|
|
137
142
|
return `${onBits}${offBits}`;
|
|
138
143
|
};
|
|
144
|
+
exports.cidrPrefixToMaskBinaryString = cidrPrefixToMaskBinaryString;
|
|
139
145
|
/**
|
|
140
146
|
* Calculates the log, to base 2 of given number.
|
|
141
147
|
*
|
|
@@ -143,7 +149,7 @@ var BinaryUtils = {};
|
|
|
143
149
|
* @param givenNumber the number to calculate log base 2
|
|
144
150
|
* @return the log base 2 of given number
|
|
145
151
|
*/
|
|
146
|
-
|
|
152
|
+
let intLog2 = (givenNumber) => {
|
|
147
153
|
let result = 0;
|
|
148
154
|
while (givenNumber % 2n === 0n) {
|
|
149
155
|
if (givenNumber === 2n) {
|
|
@@ -162,12 +168,13 @@ var BinaryUtils = {};
|
|
|
162
168
|
}
|
|
163
169
|
return result;
|
|
164
170
|
};
|
|
171
|
+
exports.intLog2 = intLog2;
|
|
165
172
|
/**
|
|
166
173
|
* Starting from the most significant bit (from left) returns the number of first bits from both string that are equal
|
|
167
174
|
* @param firstBinaryString first binary string
|
|
168
175
|
* @param secondBinaryString second binary string
|
|
169
176
|
*/
|
|
170
|
-
|
|
177
|
+
let matchingBitCount = (firstBinaryString, secondBinaryString) => {
|
|
171
178
|
let longerString;
|
|
172
179
|
let otherString;
|
|
173
180
|
if (firstBinaryString.length >= secondBinaryString.length) {
|
|
@@ -187,6 +194,7 @@ var BinaryUtils = {};
|
|
|
187
194
|
}
|
|
188
195
|
return count;
|
|
189
196
|
};
|
|
197
|
+
exports.matchingBitCount = matchingBitCount;
|
|
190
198
|
|
|
191
199
|
} (BinaryUtils));
|
|
192
200
|
|
|
@@ -201,101 +209,158 @@ var hasRequiredIPv6Utils;
|
|
|
201
209
|
function requireIPv6Utils () {
|
|
202
210
|
if (hasRequiredIPv6Utils) return IPv6Utils;
|
|
203
211
|
hasRequiredIPv6Utils = 1;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
212
|
+
(function (exports) {
|
|
213
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
214
|
+
exports.collapseIPv6Number = exports.expandIPv6Number = void 0;
|
|
215
|
+
const BinaryUtils_1 = BinaryUtils;
|
|
216
|
+
const Validator_1 = requireValidator();
|
|
217
|
+
let extractPrefix = (ipv6String) => {
|
|
218
|
+
return ipv6String.includes("/") ? `/${ipv6String.split("/")[1]}` : "";
|
|
219
|
+
};
|
|
220
|
+
let expandIPv6Number = (ipv6String) => {
|
|
221
|
+
let expandWithZero = (hexadecimalArray) => {
|
|
222
|
+
let paddedArray = hexadecimalArray.map((hexadecimal) => {
|
|
223
|
+
return (0, BinaryUtils_1.leftPadWithZeroBit)(hexadecimal, 4);
|
|
224
|
+
});
|
|
225
|
+
return paddedArray.join(":");
|
|
226
|
+
};
|
|
227
|
+
let expandDoubleColon = (gapCount) => {
|
|
228
|
+
let pads = [];
|
|
229
|
+
for (let count = 0; count < gapCount; count++) {
|
|
230
|
+
pads.push("0000");
|
|
231
|
+
}
|
|
232
|
+
return pads.join(":");
|
|
233
|
+
};
|
|
234
|
+
if (/(:){3,}/.test(ipv6String))
|
|
235
|
+
throw "given IPv6 contains consecutive : more than two";
|
|
236
|
+
const prefix = extractPrefix(ipv6String);
|
|
237
|
+
if (ipv6String.includes("/")) {
|
|
238
|
+
ipv6String = ipv6String.split("/")[0];
|
|
239
|
+
}
|
|
240
|
+
let isValid = Validator_1.Validator.IPV6_PATTERN.test(ipv6String);
|
|
241
|
+
if (!isValid) {
|
|
242
|
+
throw Error(Validator_1.Validator.invalidIPv6PatternMessage);
|
|
243
|
+
}
|
|
244
|
+
if (ipv6String.includes("::")) {
|
|
245
|
+
let split = ipv6String.split("::");
|
|
246
|
+
let leftPortion = split[0];
|
|
247
|
+
let rightPortion = split[1];
|
|
248
|
+
let leftPortionSplit = leftPortion.split(":").filter(hexadecimal => { return hexadecimal !== ""; });
|
|
249
|
+
let rightPortionSplit = rightPortion.split(":").filter(hexadecimal => { return hexadecimal !== ""; });
|
|
250
|
+
let doublePortion = expandDoubleColon(8 - (leftPortionSplit.length + rightPortionSplit.length));
|
|
251
|
+
let leftString = expandWithZero(leftPortionSplit);
|
|
252
|
+
if (leftString !== "") {
|
|
253
|
+
leftString += ":";
|
|
254
|
+
}
|
|
255
|
+
let rightString = expandWithZero(rightPortionSplit);
|
|
256
|
+
if (rightString !== "") {
|
|
257
|
+
rightString = ":" + rightString;
|
|
258
|
+
}
|
|
259
|
+
return `${leftString}${doublePortion}${rightString}${prefix}`;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
return `${expandWithZero(ipv6String.split(":"))}${prefix}`;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
exports.expandIPv6Number = expandIPv6Number;
|
|
266
|
+
// Helper function to shorten hexadecatets
|
|
267
|
+
const shortenHexadecatet = (hex) => {
|
|
268
|
+
// Input hex is expected to be like "0000", "0DB8", "001A" from expanded form
|
|
269
|
+
const withoutLeadingZero = hex.replace(/^0+/, '');
|
|
270
|
+
// If hex was "0000", withoutLeadingZero is "", so return "0"
|
|
271
|
+
// Otherwise, return the string without leading zeros.
|
|
272
|
+
return withoutLeadingZero === '' ? '0' : withoutLeadingZero;
|
|
273
|
+
};
|
|
274
|
+
let collapseIPv6Number = (ipv6String) => {
|
|
275
|
+
const originalPrefix = extractPrefix(ipv6String);
|
|
276
|
+
const processedIPv6String = ipv6String.includes("/") ? ipv6String.split("/")[0] : ipv6String;
|
|
277
|
+
let expandedIPv6 = "";
|
|
278
|
+
try {
|
|
279
|
+
// Expand to full 8 segments, no prefix internally for processing
|
|
280
|
+
let tempExpanded = (0, exports.expandIPv6Number)(processedIPv6String);
|
|
281
|
+
if (tempExpanded.includes("/")) {
|
|
282
|
+
expandedIPv6 = tempExpanded.split("/")[0];
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
expandedIPv6 = tempExpanded;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
// Propagate error if expansion fails (e.g. invalid IPv6 format)
|
|
290
|
+
throw e;
|
|
291
|
+
}
|
|
292
|
+
let hexadecatets = expandedIPv6.split(":");
|
|
293
|
+
if (hexadecatets.length !== 8) {
|
|
294
|
+
// This case should ideally be prevented by expandIPv6Number's validation or structure.
|
|
295
|
+
// If expandIPv6Number guarantees 8 segments or throws, this might not be strictly needed.
|
|
296
|
+
// However, as a safeguard:
|
|
297
|
+
throw new Error(`Invalid IPv6 structure after expansion: ${expandedIPv6}. Expected 8 segments.`);
|
|
298
|
+
}
|
|
299
|
+
let zeroSequences = [];
|
|
300
|
+
let currentSequenceStart = -1;
|
|
301
|
+
let currentSequenceLength = 0;
|
|
302
|
+
for (let i = 0; i < 8; i++) {
|
|
303
|
+
// Segments from expandIPv6Number are 4-char 0-padded, e.g., "0000"
|
|
304
|
+
if (hexadecatets[i] === "0000") {
|
|
305
|
+
if (currentSequenceStart === -1) {
|
|
306
|
+
currentSequenceStart = i;
|
|
307
|
+
}
|
|
308
|
+
currentSequenceLength++;
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
if (currentSequenceLength > 0) {
|
|
312
|
+
zeroSequences.push({ start: currentSequenceStart, length: currentSequenceLength });
|
|
313
|
+
}
|
|
314
|
+
currentSequenceStart = -1;
|
|
315
|
+
currentSequenceLength = 0;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (currentSequenceLength > 0) { // Capture any trailing zero sequence
|
|
319
|
+
zeroSequences.push({ start: currentSequenceStart, length: currentSequenceLength });
|
|
320
|
+
}
|
|
321
|
+
if (zeroSequences.length === 0) {
|
|
322
|
+
// No zero segments at all, just shorten each hexadecatet
|
|
323
|
+
return hexadecatets.map(shortenHexadecatet).join(":") + originalPrefix;
|
|
324
|
+
}
|
|
325
|
+
// Sort sequences: longest first, then earliest start first
|
|
326
|
+
zeroSequences.sort((a, b) => {
|
|
327
|
+
if (b.length !== a.length) {
|
|
328
|
+
return b.length - a.length;
|
|
329
|
+
}
|
|
330
|
+
return a.start - b.start;
|
|
331
|
+
});
|
|
332
|
+
const bestSequence = zeroSequences[0];
|
|
333
|
+
if (bestSequence.length === 8) { // All 8 segments are zero
|
|
334
|
+
return "::" + originalPrefix;
|
|
335
|
+
}
|
|
336
|
+
// RFC 5952: "The symbol "::" MUST NOT be used to shorten just one 16-bit 0 field."
|
|
337
|
+
// So, length must be > 1 for "::" compression.
|
|
338
|
+
if (bestSequence.length < 2) {
|
|
339
|
+
// No "::" compression is applied (e.g. "1:2:0:4:5:6:7:8")
|
|
340
|
+
return hexadecatets.map(shortenHexadecatet).join(":") + originalPrefix;
|
|
341
|
+
}
|
|
342
|
+
// Apply "::" compression using the bestSequence
|
|
343
|
+
let leftPartSegments = hexadecatets.slice(0, bestSequence.start);
|
|
344
|
+
let rightPartSegments = hexadecatets.slice(bestSequence.start + bestSequence.length);
|
|
345
|
+
let leftString = leftPartSegments.map(shortenHexadecatet).join(":");
|
|
346
|
+
let rightString = rightPartSegments.map(shortenHexadecatet).join(":");
|
|
347
|
+
let finalStr = "";
|
|
348
|
+
if (bestSequence.start === 0) { // Compression at the beginning: "::..."
|
|
349
|
+
finalStr = "::" + rightString;
|
|
350
|
+
}
|
|
351
|
+
else if (bestSequence.start + bestSequence.length === 8) { // Compression at the end: "...::"
|
|
352
|
+
// Ensure that if leftString is empty (which shouldn't happen here if start > 0), it's handled.
|
|
353
|
+
// However, if bestSequence.start > 0, leftPartSegments won't be empty unless bestSequence.start is 0.
|
|
354
|
+
finalStr = leftString + "::";
|
|
355
|
+
}
|
|
356
|
+
else { // Compression in the middle: "...::..."
|
|
357
|
+
finalStr = leftString + "::" + rightString;
|
|
358
|
+
}
|
|
359
|
+
return finalStr + originalPrefix;
|
|
360
|
+
};
|
|
361
|
+
exports.collapseIPv6Number = collapseIPv6Number;
|
|
362
|
+
|
|
363
|
+
} (IPv6Utils));
|
|
299
364
|
return IPv6Utils;
|
|
300
365
|
}
|
|
301
366
|
|
|
@@ -316,32 +381,35 @@ function requireHexadecimalUtils () {
|
|
|
316
381
|
* @param num the bigint number
|
|
317
382
|
* @returns {string} the hexadeciaml string
|
|
318
383
|
*/
|
|
319
|
-
|
|
384
|
+
let bigIntToHexadecimalString = (num) => {
|
|
320
385
|
return num.toString(16);
|
|
321
386
|
};
|
|
387
|
+
exports.bigIntToHexadecimalString = bigIntToHexadecimalString;
|
|
322
388
|
/**
|
|
323
389
|
* Converts a number in hexadecimal (base 16) to binary string
|
|
324
390
|
* @param {string} hexadecimalString the number in base 16
|
|
325
391
|
* @returns {string} the number converted to base 2
|
|
326
392
|
*/
|
|
327
|
-
|
|
393
|
+
let hexadecimalStringToBinaryString = (hexadecimalString) => {
|
|
328
394
|
let inDecimal = BigInt(`0x${hexadecimalString}`);
|
|
329
395
|
return inDecimal.toString(2);
|
|
330
396
|
};
|
|
397
|
+
exports.hexadecimalStringToBinaryString = hexadecimalStringToBinaryString;
|
|
331
398
|
/**
|
|
332
399
|
* Converts a number in hexadecimal (base 16) to binary hexadecatet string.
|
|
333
400
|
* This means the bits in the output cannot be more than 16
|
|
334
401
|
*
|
|
335
402
|
* @param hexadecimalString {string} the number converted to binary hexadecatet string
|
|
336
403
|
*/
|
|
337
|
-
|
|
338
|
-
let binaryString = exports.hexadecimalStringToBinaryString(hexadecimalString);
|
|
404
|
+
let hexadecimalStringToHexadecatetString = (hexadecimalString) => {
|
|
405
|
+
let binaryString = (0, exports.hexadecimalStringToBinaryString)(hexadecimalString);
|
|
339
406
|
let length = binaryString.length;
|
|
340
407
|
if (length > 16) {
|
|
341
408
|
throw new Error("Given decimal in binary contains digits greater than an Hexadecatet");
|
|
342
409
|
}
|
|
343
|
-
return BinaryUtils_1.leftPadWithZeroBit(binaryString, 16);
|
|
410
|
+
return (0, BinaryUtils_1.leftPadWithZeroBit)(binaryString, 16);
|
|
344
411
|
};
|
|
412
|
+
exports.hexadecimalStringToHexadecatetString = hexadecimalStringToHexadecatetString;
|
|
345
413
|
/**
|
|
346
414
|
* Given an IPv6 number in hexadecimal notated string, e.g 2001:0db8:0000:0000:0000:0000:0000:0000 converts it to
|
|
347
415
|
* binary string
|
|
@@ -349,35 +417,38 @@ function requireHexadecimalUtils () {
|
|
|
349
417
|
* @param hexadecimalString IPv6 string
|
|
350
418
|
* @returns {string} the binary value of the given ipv6 number in string
|
|
351
419
|
*/
|
|
352
|
-
|
|
353
|
-
let expandedIPv6 = IPv6Utils_1.expandIPv6Number(hexadecimalString);
|
|
420
|
+
let colonHexadecimalNotationToBinaryString = (hexadecimalString) => {
|
|
421
|
+
let expandedIPv6 = (0, IPv6Utils_1.expandIPv6Number)(hexadecimalString);
|
|
354
422
|
let stringHexadecimal = expandedIPv6.split(":");
|
|
355
423
|
return stringHexadecimal.reduce((binaryAsString, hexidecimal) => {
|
|
356
|
-
return binaryAsString.concat(exports.hexadecimalStringToHexadecatetString(hexidecimal));
|
|
424
|
+
return binaryAsString.concat((0, exports.hexadecimalStringToHexadecatetString)(hexidecimal));
|
|
357
425
|
}, '');
|
|
358
426
|
};
|
|
427
|
+
exports.colonHexadecimalNotationToBinaryString = colonHexadecimalNotationToBinaryString;
|
|
359
428
|
/**
|
|
360
429
|
* Converts number in binary string to hexadecimal string
|
|
361
430
|
* @param {string} num in binary string
|
|
362
431
|
* @returns {string} num in hexadecimal string
|
|
363
432
|
*/
|
|
364
|
-
|
|
433
|
+
let binaryStringToHexadecimalString = (num) => {
|
|
365
434
|
// first convert to binary string to decimal (big Integer)
|
|
366
435
|
let inDecimal = BigInt(`0b${num}`);
|
|
367
436
|
return inDecimal.toString(16);
|
|
368
437
|
};
|
|
438
|
+
exports.binaryStringToHexadecimalString = binaryStringToHexadecimalString;
|
|
369
439
|
/**
|
|
370
440
|
* Converts a given IPv6 number expressed in the hexadecimal string notation into a 16 bit binary number in string
|
|
371
441
|
* @param {string} hexadectetString the IPv6 number
|
|
372
442
|
* @returns {string} the IPv6 number converted to binary string
|
|
373
443
|
*/
|
|
374
|
-
|
|
375
|
-
let expand = IPv6Utils_1.expandIPv6Number(hexadectetString);
|
|
444
|
+
let hexadectetNotationToBinaryString = (hexadectetString) => {
|
|
445
|
+
let expand = (0, IPv6Utils_1.expandIPv6Number)(hexadectetString);
|
|
376
446
|
let hexadecimals = expand.split(":");
|
|
377
447
|
return hexadecimals.reduce((hexadecimalAsString, hexavalue) => {
|
|
378
|
-
return hexadecimalAsString.concat(BinaryUtils_1.leftPadWithZeroBit(exports.hexadecimalStringToBinaryString(hexavalue), 16));
|
|
448
|
+
return hexadecimalAsString.concat((0, BinaryUtils_1.leftPadWithZeroBit)((0, exports.hexadecimalStringToBinaryString)(hexavalue), 16));
|
|
379
449
|
}, '');
|
|
380
450
|
};
|
|
451
|
+
exports.hexadectetNotationToBinaryString = hexadectetNotationToBinaryString;
|
|
381
452
|
|
|
382
453
|
} (HexadecimalUtils));
|
|
383
454
|
return HexadecimalUtils;
|
|
@@ -503,7 +574,7 @@ function requireValidator () {
|
|
|
503
574
|
*/
|
|
504
575
|
static isValidIPv6String(ipv6String) {
|
|
505
576
|
try {
|
|
506
|
-
let hexadecimals = IPv6Utils_1.expandIPv6Number(ipv6String).split(":");
|
|
577
|
+
let hexadecimals = (0, IPv6Utils_1.expandIPv6Number)(ipv6String).split(":");
|
|
507
578
|
if (hexadecimals.length != 8) {
|
|
508
579
|
return [false, [Validator.invalidHexadecatetCountMessage]];
|
|
509
580
|
}
|
|
@@ -518,7 +589,7 @@ function requireValidator () {
|
|
|
518
589
|
return [isValid, isValid ? [] : [Validator.invalidIPv6PatternMessage]];
|
|
519
590
|
}
|
|
520
591
|
catch (error) {
|
|
521
|
-
return [false, [error]];
|
|
592
|
+
return [false, [String(error)]];
|
|
522
593
|
}
|
|
523
594
|
}
|
|
524
595
|
/**
|
|
@@ -529,11 +600,11 @@ function requireValidator () {
|
|
|
529
600
|
* @returns {(boolean|string)[]} a tuple representing if valid or not and corresponding message
|
|
530
601
|
*/
|
|
531
602
|
static isValidPrefixValue(prefixValue, ipNumType) {
|
|
532
|
-
if ("IPv4" /* IPv4 */ === ipNumType) {
|
|
603
|
+
if ("IPv4" /* IPNumType.IPv4 */ === ipNumType) {
|
|
533
604
|
let withinRange = Validator.isWithinRange(BigInt(prefixValue), 0n, 32n);
|
|
534
605
|
return [withinRange, withinRange ? [] : [Validator.invalidPrefixValueMessage]];
|
|
535
606
|
}
|
|
536
|
-
if ("IPv6" /* IPv6 */ === ipNumType) {
|
|
607
|
+
if ("IPv6" /* IPNumType.IPv6 */ === ipNumType) {
|
|
537
608
|
let withinRange = Validator.isWithinRange(BigInt(prefixValue), 0n, 128n);
|
|
538
609
|
return [withinRange, withinRange ? [] : [Validator.invalidPrefixValueMessage]];
|
|
539
610
|
}
|
|
@@ -547,7 +618,7 @@ function requireValidator () {
|
|
|
547
618
|
* contains "valid" or an error message when value is invalid
|
|
548
619
|
*/
|
|
549
620
|
static isValidIPv4Mask(ipv4MaskString) {
|
|
550
|
-
let ipv4InBinary = BinaryUtils_1.dottedDecimalNotationToBinaryString(ipv4MaskString);
|
|
621
|
+
let ipv4InBinary = (0, BinaryUtils_1.dottedDecimalNotationToBinaryString)(ipv4MaskString);
|
|
551
622
|
let isValid = Validator.IPV4_CONTIGUOUS_MASK_BIT_PATTERN.test(ipv4InBinary);
|
|
552
623
|
return isValid ? [isValid, []] : [isValid, [Validator.invalidMaskMessage]];
|
|
553
624
|
}
|
|
@@ -559,7 +630,7 @@ function requireValidator () {
|
|
|
559
630
|
* contains "valid" or an error message when value is invalid
|
|
560
631
|
*/
|
|
561
632
|
static isValidIPv6Mask(ipv6MaskString) {
|
|
562
|
-
let ipv6InBinary = HexadecimalUtils_2.hexadectetNotationToBinaryString(ipv6MaskString);
|
|
633
|
+
let ipv6InBinary = (0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(ipv6MaskString);
|
|
563
634
|
let isValid = Validator.IPV6_CONTIGUOUS_MASK_BIT_PATTERN.test(ipv6InBinary);
|
|
564
635
|
return isValid ? [isValid, []] : [isValid, [Validator.invalidMaskMessage]];
|
|
565
636
|
}
|
|
@@ -578,11 +649,14 @@ function requireValidator () {
|
|
|
578
649
|
}
|
|
579
650
|
let ip = cidrComponents[0];
|
|
580
651
|
let range = cidrComponents[1];
|
|
652
|
+
if (!/^\d+$/.test(range)) {
|
|
653
|
+
return [false, [Validator.invalidIPv4CidrNotationMessage]];
|
|
654
|
+
}
|
|
581
655
|
if (isNaN(Number(range))) {
|
|
582
656
|
return [false, [Validator.invalidIPv4CidrNotationMessage]];
|
|
583
657
|
}
|
|
584
658
|
let [validIpv4, invalidIpv4Message] = Validator.isValidIPv4String(ip);
|
|
585
|
-
let [validPrefix, invalidPrefixMessage] = Validator.isValidPrefixValue(BigInt(range), "IPv4" /* IPv4 */);
|
|
659
|
+
let [validPrefix, invalidPrefixMessage] = Validator.isValidPrefixValue(BigInt(range), "IPv4" /* IPNumType.IPv4 */);
|
|
586
660
|
let isValid = validIpv4 && validPrefix;
|
|
587
661
|
let invalidMessage = invalidIpv4Message.concat(invalidPrefixMessage);
|
|
588
662
|
return isValid ? [isValid, []] : [isValid, invalidMessage];
|
|
@@ -597,7 +671,7 @@ function requireValidator () {
|
|
|
597
671
|
* value contains [] or an array of error message when invalid
|
|
598
672
|
*/
|
|
599
673
|
static isValidIPv4CidrRange(ipv4CidrNotation) {
|
|
600
|
-
return Validator.isValidCidrRange(ipv4CidrNotation, Validator.isValidIPv4CidrNotation, BinaryUtils_1.dottedDecimalNotationToBinaryString, (value) => BinaryUtils_2.cidrPrefixToMaskBinaryString(value, "IPv4" /* IPv4 */));
|
|
674
|
+
return Validator.isValidCidrRange(ipv4CidrNotation, Validator.isValidIPv4CidrNotation, BinaryUtils_1.dottedDecimalNotationToBinaryString, (value) => (0, BinaryUtils_2.cidrPrefixToMaskBinaryString)(value, "IPv4" /* IPNumType.IPv4 */));
|
|
601
675
|
}
|
|
602
676
|
/**
|
|
603
677
|
* Checks if the given string is a valid IPv6 range in Cidr notation, with the ip number in the cidr notation
|
|
@@ -609,7 +683,7 @@ function requireValidator () {
|
|
|
609
683
|
* value contains [] or an array of error message when invalid
|
|
610
684
|
*/
|
|
611
685
|
static isValidIPv6CidrRange(ipv6CidrNotation) {
|
|
612
|
-
return Validator.isValidCidrRange(ipv6CidrNotation, Validator.isValidIPv6CidrNotation, HexadecimalUtils_1.colonHexadecimalNotationToBinaryString, (value) => BinaryUtils_2.cidrPrefixToMaskBinaryString(value, "IPv6" /* IPv6 */));
|
|
686
|
+
return Validator.isValidCidrRange(ipv6CidrNotation, Validator.isValidIPv6CidrNotation, HexadecimalUtils_1.colonHexadecimalNotationToBinaryString, (value) => (0, BinaryUtils_2.cidrPrefixToMaskBinaryString)(value, "IPv6" /* IPNumType.IPv6 */));
|
|
613
687
|
}
|
|
614
688
|
static isValidCidrRange(rangeString, cidrNotationValidator, toBinaryStringConverter, prefixFactory) {
|
|
615
689
|
let validationResult = cidrNotationValidator(rangeString);
|
|
@@ -625,13 +699,13 @@ function requireValidator () {
|
|
|
625
699
|
return isValid ? [isValid, []] : [isValid, [Validator.InvalidIPCidrRangeMessage]];
|
|
626
700
|
}
|
|
627
701
|
static isValidIPv4RangeString(ipv4RangeString) {
|
|
628
|
-
let firstLastValidator = (firstIP, lastIP) => BigInt(`0b${BinaryUtils_1.dottedDecimalNotationToBinaryString(firstIP)}`)
|
|
629
|
-
>= BigInt(`0b${BinaryUtils_1.dottedDecimalNotationToBinaryString(lastIP)}`);
|
|
702
|
+
let firstLastValidator = (firstIP, lastIP) => BigInt(`0b${(0, BinaryUtils_1.dottedDecimalNotationToBinaryString)(firstIP)}`)
|
|
703
|
+
>= BigInt(`0b${(0, BinaryUtils_1.dottedDecimalNotationToBinaryString)(lastIP)}`);
|
|
630
704
|
return this.isValidRange(ipv4RangeString, Validator.isValidIPv4String, firstLastValidator);
|
|
631
705
|
}
|
|
632
706
|
static isValidIPv6RangeString(ipv6RangeString) {
|
|
633
|
-
let firstLastValidator = (firstIP, lastIP) => BigInt(`0b${HexadecimalUtils_2.hexadectetNotationToBinaryString(firstIP)}`)
|
|
634
|
-
>= BigInt(`0b${HexadecimalUtils_2.hexadectetNotationToBinaryString(lastIP)}`);
|
|
707
|
+
let firstLastValidator = (firstIP, lastIP) => BigInt(`0b${(0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(firstIP)}`)
|
|
708
|
+
>= BigInt(`0b${(0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(lastIP)}`);
|
|
635
709
|
return this.isValidRange(ipv6RangeString, Validator.isValidIPv6String, firstLastValidator);
|
|
636
710
|
}
|
|
637
711
|
static isValidRange(rangeString, validator, firstLastValidator) {
|
|
@@ -737,27 +811,6 @@ const Validator_1$4 = requireValidator();
|
|
|
737
811
|
* It is used to represents the components of an IPv6 address
|
|
738
812
|
*/
|
|
739
813
|
class Hexadecatet {
|
|
740
|
-
/**
|
|
741
|
-
* Constructor for creating an instance of {@link Hexadecatet}
|
|
742
|
-
*
|
|
743
|
-
* @param {string | number} givenValue a string or numeric value. If given value is a string then it should be a
|
|
744
|
-
* four (base 16) number representation of a 16bit value. If it is a number, then it should be a decimal number
|
|
745
|
-
* representation of a 16 bit value
|
|
746
|
-
*/
|
|
747
|
-
constructor(givenValue) {
|
|
748
|
-
let hexadecatetValue;
|
|
749
|
-
if (typeof givenValue === 'string') {
|
|
750
|
-
hexadecatetValue = parseInt(givenValue, 16);
|
|
751
|
-
}
|
|
752
|
-
else {
|
|
753
|
-
hexadecatetValue = parseInt(String(givenValue), 16);
|
|
754
|
-
}
|
|
755
|
-
let [isValid, message] = Validator_1$4.Validator.isValidIPv6Hexadecatet(BigInt(hexadecatetValue));
|
|
756
|
-
if (!isValid) {
|
|
757
|
-
throw Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
758
|
-
}
|
|
759
|
-
this.value = hexadecatetValue;
|
|
760
|
-
}
|
|
761
814
|
/**
|
|
762
815
|
* A convenience method for constructing an instance of {@link Hexadecatet} from a four (base 16) number
|
|
763
816
|
* representation of a 16bit value.
|
|
@@ -780,6 +833,27 @@ class Hexadecatet {
|
|
|
780
833
|
return new Hexadecatet(rawValue);
|
|
781
834
|
}
|
|
782
835
|
;
|
|
836
|
+
/**
|
|
837
|
+
* Constructor for creating an instance of {@link Hexadecatet}
|
|
838
|
+
*
|
|
839
|
+
* @param {string | number} givenValue a string or numeric value. If given value is a string then it should be a
|
|
840
|
+
* four (base 16) number representation of a 16bit value. If it is a number, then it should be a decimal number
|
|
841
|
+
* representation of a 16 bit value
|
|
842
|
+
*/
|
|
843
|
+
constructor(givenValue) {
|
|
844
|
+
let hexadecatetValue;
|
|
845
|
+
if (typeof givenValue === 'string') {
|
|
846
|
+
hexadecatetValue = parseInt(givenValue, 16);
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
hexadecatetValue = parseInt(String(givenValue), 16);
|
|
850
|
+
}
|
|
851
|
+
let [isValid, message] = Validator_1$4.Validator.isValidIPv6Hexadecatet(BigInt(hexadecatetValue));
|
|
852
|
+
if (!isValid) {
|
|
853
|
+
throw Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
854
|
+
}
|
|
855
|
+
this.value = hexadecatetValue;
|
|
856
|
+
}
|
|
783
857
|
/**
|
|
784
858
|
* Returns the numeric value in base 10 (ie decimal)
|
|
785
859
|
*
|
|
@@ -815,6 +889,26 @@ const Validator_1$3 = requireValidator();
|
|
|
815
889
|
* into 4 octets
|
|
816
890
|
*/
|
|
817
891
|
class Octet {
|
|
892
|
+
/**
|
|
893
|
+
* Convenience method for creating an Octet out of a string value representing the value of the octet
|
|
894
|
+
*
|
|
895
|
+
* @param {string} rawValue the octet value in string
|
|
896
|
+
* @returns {Octet} the Octet instance
|
|
897
|
+
*/
|
|
898
|
+
static fromString(rawValue) {
|
|
899
|
+
return new Octet(rawValue);
|
|
900
|
+
}
|
|
901
|
+
;
|
|
902
|
+
/**
|
|
903
|
+
* Convenience method for creating an Octet out of a numeric value representing the value of the octet
|
|
904
|
+
*
|
|
905
|
+
* @param {number} rawValue the octet value in number
|
|
906
|
+
* @returns {Octet} the Octet instance
|
|
907
|
+
*/
|
|
908
|
+
static fromNumber(rawValue) {
|
|
909
|
+
return new Octet(rawValue);
|
|
910
|
+
}
|
|
911
|
+
;
|
|
818
912
|
/**
|
|
819
913
|
* Constructor for creating an instance of an Octet.
|
|
820
914
|
*
|
|
@@ -839,26 +933,6 @@ class Octet {
|
|
|
839
933
|
}
|
|
840
934
|
this.value = octetValue;
|
|
841
935
|
}
|
|
842
|
-
/**
|
|
843
|
-
* Convenience method for creating an Octet out of a string value representing the value of the octet
|
|
844
|
-
*
|
|
845
|
-
* @param {string} rawValue the octet value in string
|
|
846
|
-
* @returns {Octet} the Octet instance
|
|
847
|
-
*/
|
|
848
|
-
static fromString(rawValue) {
|
|
849
|
-
return new Octet(rawValue);
|
|
850
|
-
}
|
|
851
|
-
;
|
|
852
|
-
/**
|
|
853
|
-
* Convenience method for creating an Octet out of a numeric value representing the value of the octet
|
|
854
|
-
*
|
|
855
|
-
* @param {number} rawValue the octet value in number
|
|
856
|
-
* @returns {Octet} the Octet instance
|
|
857
|
-
*/
|
|
858
|
-
static fromNumber(rawValue) {
|
|
859
|
-
return new Octet(rawValue);
|
|
860
|
-
}
|
|
861
|
-
;
|
|
862
936
|
/**
|
|
863
937
|
* Method to get the numeric value of the octet
|
|
864
938
|
*
|
|
@@ -879,7 +953,8 @@ class Octet {
|
|
|
879
953
|
Octet$1.Octet = Octet;
|
|
880
954
|
|
|
881
955
|
Object.defineProperty(IPNumber, "__esModule", { value: true });
|
|
882
|
-
IPNumber.
|
|
956
|
+
IPNumber.IPv6Mask = IPNumber.IPv4Mask = IPNumber.IPv6 = IPNumber.Asn = IPNumber.IPv4 = IPNumber.AbstractIPNum = void 0;
|
|
957
|
+
IPNumber.isIPv4 = isIPv4;
|
|
883
958
|
const Octet_1 = Octet$1;
|
|
884
959
|
const Validator_1$2 = requireValidator();
|
|
885
960
|
const BinaryUtils_1$2 = BinaryUtils;
|
|
@@ -909,7 +984,7 @@ class AbstractIPNum {
|
|
|
909
984
|
* @returns {string} the string binary representation.
|
|
910
985
|
*/
|
|
911
986
|
toBinaryString() {
|
|
912
|
-
return BinaryUtils_3.leftPadWithZeroBit(this.value.toString(2), this.bitSize);
|
|
987
|
+
return (0, BinaryUtils_3.leftPadWithZeroBit)(this.value.toString(2), this.bitSize);
|
|
913
988
|
}
|
|
914
989
|
/**
|
|
915
990
|
* Checks if an IP number has a value greater than the present value
|
|
@@ -981,50 +1056,6 @@ IPNumber.AbstractIPNum = AbstractIPNum;
|
|
|
981
1056
|
* @see https://www.rfc-editor.org/info/rfc791
|
|
982
1057
|
*/
|
|
983
1058
|
class IPv4 extends AbstractIPNum {
|
|
984
|
-
/**
|
|
985
|
-
* Constructor for an IPv4 number.
|
|
986
|
-
*
|
|
987
|
-
* @param {string | bigint} ipValue value to construct an IPv4 from. The given value can either be
|
|
988
|
-
* numeric or string. If a string is given then it needs to be in dot-decimal notation
|
|
989
|
-
*/
|
|
990
|
-
constructor(ipValue) {
|
|
991
|
-
super();
|
|
992
|
-
/**
|
|
993
|
-
* The number of bits needed to represents the value of the IPv4 number
|
|
994
|
-
*/
|
|
995
|
-
this.bitSize = 32;
|
|
996
|
-
/**
|
|
997
|
-
* The maximum bit size (i.e. binary value) of the IPv4 number in BigInt
|
|
998
|
-
*/
|
|
999
|
-
this.maximumBitSize = Validator_1$2.Validator.THIRTY_TWO_BIT_SIZE;
|
|
1000
|
-
/**
|
|
1001
|
-
* The type of IP number. Value is one of the values of the {@link IPNumType} enum
|
|
1002
|
-
* @type {IPNumType} the type of IP number
|
|
1003
|
-
*/
|
|
1004
|
-
this.type = "IPv4" /* IPv4 */;
|
|
1005
|
-
/**
|
|
1006
|
-
* An array of {@link Octet}'s
|
|
1007
|
-
*
|
|
1008
|
-
* @type {Array} the octets that makes up the IPv4 number
|
|
1009
|
-
*/
|
|
1010
|
-
this.octets = [];
|
|
1011
|
-
/**
|
|
1012
|
-
* The string character used to separate the individual octets when the IPv4 is rendered as strings
|
|
1013
|
-
*
|
|
1014
|
-
* @type {string} The string character used to separate the individual octets when rendered as strings
|
|
1015
|
-
*/
|
|
1016
|
-
this.separator = ".";
|
|
1017
|
-
if (typeof ipValue === "string") {
|
|
1018
|
-
let [value, octets] = this.constructFromDecimalDottedString(ipValue);
|
|
1019
|
-
this.value = value;
|
|
1020
|
-
this.octets = octets;
|
|
1021
|
-
}
|
|
1022
|
-
else {
|
|
1023
|
-
let [value, octets] = this.constructFromBigIntValue(ipValue);
|
|
1024
|
-
this.value = value;
|
|
1025
|
-
this.octets = octets;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
1059
|
/**
|
|
1029
1060
|
* A convenience method for creating an {@link IPv4} by providing the decimal value of the IP number in BigInt
|
|
1030
1061
|
*
|
|
@@ -1064,12 +1095,56 @@ class IPv4 extends AbstractIPNum {
|
|
|
1064
1095
|
static fromBinaryString(ipBinaryString) {
|
|
1065
1096
|
let validationResult = Validator_1$2.Validator.isValidBinaryString(ipBinaryString);
|
|
1066
1097
|
if (validationResult[0]) {
|
|
1067
|
-
return new IPv4(BinaryUtils_2.parseBinaryStringToBigInt(ipBinaryString));
|
|
1098
|
+
return new IPv4((0, BinaryUtils_2.parseBinaryStringToBigInt)(ipBinaryString));
|
|
1068
1099
|
}
|
|
1069
1100
|
else {
|
|
1070
1101
|
throw Error(validationResult[1].join(','));
|
|
1071
1102
|
}
|
|
1072
1103
|
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Constructor for an IPv4 number.
|
|
1106
|
+
*
|
|
1107
|
+
* @param {string | bigint} ipValue value to construct an IPv4 from. The given value can either be
|
|
1108
|
+
* numeric or string. If a string is given then it needs to be in dot-decimal notation
|
|
1109
|
+
*/
|
|
1110
|
+
constructor(ipValue) {
|
|
1111
|
+
super();
|
|
1112
|
+
/**
|
|
1113
|
+
* The number of bits needed to represents the value of the IPv4 number
|
|
1114
|
+
*/
|
|
1115
|
+
this.bitSize = 32;
|
|
1116
|
+
/**
|
|
1117
|
+
* The maximum bit size (i.e. binary value) of the IPv4 number in BigInt
|
|
1118
|
+
*/
|
|
1119
|
+
this.maximumBitSize = Validator_1$2.Validator.THIRTY_TWO_BIT_SIZE;
|
|
1120
|
+
/**
|
|
1121
|
+
* The type of IP number. Value is one of the values of the {@link IPNumType} enum
|
|
1122
|
+
* @type {IPNumType} the type of IP number
|
|
1123
|
+
*/
|
|
1124
|
+
this.type = "IPv4" /* IPNumType.IPv4 */;
|
|
1125
|
+
/**
|
|
1126
|
+
* An array of {@link Octet}'s
|
|
1127
|
+
*
|
|
1128
|
+
* @type {Array} the octets that makes up the IPv4 number
|
|
1129
|
+
*/
|
|
1130
|
+
this.octets = [];
|
|
1131
|
+
/**
|
|
1132
|
+
* The string character used to separate the individual octets when the IPv4 is rendered as strings
|
|
1133
|
+
*
|
|
1134
|
+
* @type {string} The string character used to separate the individual octets when rendered as strings
|
|
1135
|
+
*/
|
|
1136
|
+
this.separator = ".";
|
|
1137
|
+
if (typeof ipValue === "string") {
|
|
1138
|
+
let [value, octets] = this.constructFromDecimalDottedString(ipValue);
|
|
1139
|
+
this.value = value;
|
|
1140
|
+
this.octets = octets;
|
|
1141
|
+
}
|
|
1142
|
+
else {
|
|
1143
|
+
let [value, octets] = this.constructFromBigIntValue(ipValue);
|
|
1144
|
+
this.value = value;
|
|
1145
|
+
this.octets = octets;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1073
1148
|
/**
|
|
1074
1149
|
* A string representation of the IPv4 number. The string representation is in dot-decimal notation
|
|
1075
1150
|
*
|
|
@@ -1126,7 +1201,7 @@ class IPv4 extends AbstractIPNum {
|
|
|
1126
1201
|
octets = stringOctets.map((rawOctet) => {
|
|
1127
1202
|
return Octet_1.Octet.fromString(rawOctet);
|
|
1128
1203
|
});
|
|
1129
|
-
value = BigInt(`0b${BinaryUtils_1$2.dottedDecimalNotationToBinaryString(ipString)}`);
|
|
1204
|
+
value = BigInt(`0b${(0, BinaryUtils_1$2.dottedDecimalNotationToBinaryString)(ipString)}`);
|
|
1130
1205
|
return [value, octets];
|
|
1131
1206
|
}
|
|
1132
1207
|
constructFromBigIntValue(ipv4Number) {
|
|
@@ -1134,17 +1209,17 @@ class IPv4 extends AbstractIPNum {
|
|
|
1134
1209
|
if (!isValid) {
|
|
1135
1210
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1136
1211
|
}
|
|
1137
|
-
let binaryString = BinaryUtils_4.numberToBinaryString(ipv4Number);
|
|
1212
|
+
let binaryString = (0, BinaryUtils_4.numberToBinaryString)(ipv4Number);
|
|
1138
1213
|
ipv4Number = typeof ipv4Number === "bigint" ? ipv4Number : BigInt(ipv4Number);
|
|
1139
1214
|
return [ipv4Number, this.binaryStringToDecimalOctets(binaryString)];
|
|
1140
1215
|
}
|
|
1141
1216
|
binaryStringToDecimalOctets(ipv4BinaryString) {
|
|
1142
1217
|
if (ipv4BinaryString.length < 32) {
|
|
1143
|
-
ipv4BinaryString = BinaryUtils_3.leftPadWithZeroBit(ipv4BinaryString, 32);
|
|
1218
|
+
ipv4BinaryString = (0, BinaryUtils_3.leftPadWithZeroBit)(ipv4BinaryString, 32);
|
|
1144
1219
|
}
|
|
1145
1220
|
let octets = ipv4BinaryString.match(/.{1,8}/g);
|
|
1146
1221
|
return octets.map((octet) => {
|
|
1147
|
-
return Octet_1.Octet.fromString(BinaryUtils_2.parseBinaryStringToBigInt(octet).toString());
|
|
1222
|
+
return Octet_1.Octet.fromString((0, BinaryUtils_2.parseBinaryStringToBigInt)(octet).toString());
|
|
1148
1223
|
});
|
|
1149
1224
|
}
|
|
1150
1225
|
}
|
|
@@ -1157,43 +1232,6 @@ IPNumber.IPv4 = IPv4;
|
|
|
1157
1232
|
* @see https://tools.ietf.org/html/rfc5396
|
|
1158
1233
|
*/
|
|
1159
1234
|
class Asn extends AbstractIPNum {
|
|
1160
|
-
/**
|
|
1161
|
-
* Constructor for an instance of {@link ASN}
|
|
1162
|
-
*
|
|
1163
|
-
* @param {string | number} rawValue value to construct an ASN from. The given value can either be numeric or
|
|
1164
|
-
* string. If in string then it can be in asplain, asdot or asdot+ string representation format
|
|
1165
|
-
*/
|
|
1166
|
-
constructor(rawValue) {
|
|
1167
|
-
super();
|
|
1168
|
-
/**
|
|
1169
|
-
* The number of bits needed to represents the value of the ASN number
|
|
1170
|
-
*/
|
|
1171
|
-
this.bitSize = 32;
|
|
1172
|
-
/**
|
|
1173
|
-
* The maximum bit size (i.e. binary value) of the ASN number in BigInt
|
|
1174
|
-
*/
|
|
1175
|
-
this.maximumBitSize = Validator_1$2.Validator.THIRTY_TWO_BIT_SIZE;
|
|
1176
|
-
this.type = "ASN" /* ASN */;
|
|
1177
|
-
if (typeof rawValue === 'string') {
|
|
1178
|
-
if (Asn.startWithASPrefix(rawValue)) {
|
|
1179
|
-
this.value = BigInt(parseInt(rawValue.substring(2)));
|
|
1180
|
-
}
|
|
1181
|
-
else if (rawValue.indexOf(".") != -1) {
|
|
1182
|
-
this.value = BigInt(this.parseFromDotNotation(rawValue));
|
|
1183
|
-
}
|
|
1184
|
-
else {
|
|
1185
|
-
this.value = BigInt(parseInt(rawValue));
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
else {
|
|
1189
|
-
let valueAsBigInt = BigInt(rawValue);
|
|
1190
|
-
let [isValid, message] = Validator_1$2.Validator.isValidAsnNumber(valueAsBigInt);
|
|
1191
|
-
if (!isValid) {
|
|
1192
|
-
throw Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1193
|
-
}
|
|
1194
|
-
this.value = valueAsBigInt;
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
1235
|
/**
|
|
1198
1236
|
* A convenience method for creating an instance of {@link Asn} from a string
|
|
1199
1237
|
*
|
|
@@ -1233,6 +1271,43 @@ class Asn extends AbstractIPNum {
|
|
|
1233
1271
|
throw Error(validationResult[1].join(','));
|
|
1234
1272
|
}
|
|
1235
1273
|
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Constructor for an instance of {@link ASN}
|
|
1276
|
+
*
|
|
1277
|
+
* @param {string | number} rawValue value to construct an ASN from. The given value can either be numeric or
|
|
1278
|
+
* string. If in string then it can be in asplain, asdot or asdot+ string representation format
|
|
1279
|
+
*/
|
|
1280
|
+
constructor(rawValue) {
|
|
1281
|
+
super();
|
|
1282
|
+
/**
|
|
1283
|
+
* The number of bits needed to represents the value of the ASN number
|
|
1284
|
+
*/
|
|
1285
|
+
this.bitSize = 32;
|
|
1286
|
+
/**
|
|
1287
|
+
* The maximum bit size (i.e. binary value) of the ASN number in BigInt
|
|
1288
|
+
*/
|
|
1289
|
+
this.maximumBitSize = Validator_1$2.Validator.THIRTY_TWO_BIT_SIZE;
|
|
1290
|
+
this.type = "ASN" /* IPNumType.ASN */;
|
|
1291
|
+
if (typeof rawValue === 'string') {
|
|
1292
|
+
if (Asn.startWithASPrefix(rawValue)) {
|
|
1293
|
+
this.value = BigInt(parseInt(rawValue.substring(2)));
|
|
1294
|
+
}
|
|
1295
|
+
else if (rawValue.indexOf(".") != -1) {
|
|
1296
|
+
this.value = BigInt(this.parseFromDotNotation(rawValue));
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
this.value = BigInt(parseInt(rawValue));
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
else {
|
|
1303
|
+
let valueAsBigInt = BigInt(rawValue);
|
|
1304
|
+
let [isValid, message] = Validator_1$2.Validator.isValidAsnNumber(valueAsBigInt);
|
|
1305
|
+
if (!isValid) {
|
|
1306
|
+
throw Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1307
|
+
}
|
|
1308
|
+
this.value = valueAsBigInt;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1236
1311
|
/**
|
|
1237
1312
|
* A string representation where the asn value is prefixed by "ASN". For example "AS65526"
|
|
1238
1313
|
*
|
|
@@ -1283,7 +1358,7 @@ class Asn extends AbstractIPNum {
|
|
|
1283
1358
|
* @returns {string} a binary string representation of the value of the ASN number
|
|
1284
1359
|
*/
|
|
1285
1360
|
toBinaryString() {
|
|
1286
|
-
return BinaryUtils_4.numberToBinaryString(this.value);
|
|
1361
|
+
return (0, BinaryUtils_4.numberToBinaryString)(this.value);
|
|
1287
1362
|
}
|
|
1288
1363
|
/**
|
|
1289
1364
|
* Checks if the ASN value is 16bit
|
|
@@ -1338,51 +1413,6 @@ Asn.AS_PREFIX = "AS";
|
|
|
1338
1413
|
* @see https://www.rfc-editor.org/info/rfc8200
|
|
1339
1414
|
*/
|
|
1340
1415
|
class IPv6 extends AbstractIPNum {
|
|
1341
|
-
/**
|
|
1342
|
-
* Constructor for an IPv6 number.
|
|
1343
|
-
*
|
|
1344
|
-
* @param {string | bigint} ipValue value to construct an IPv6 from. The given value can either be
|
|
1345
|
-
* numeric or string. If a string is given then it needs to be in hexadecatet string notation
|
|
1346
|
-
*/
|
|
1347
|
-
constructor(ipValue) {
|
|
1348
|
-
super();
|
|
1349
|
-
/**
|
|
1350
|
-
* The number of bits needed to represents the value of the IPv6 number
|
|
1351
|
-
*/
|
|
1352
|
-
this.bitSize = 128;
|
|
1353
|
-
/**
|
|
1354
|
-
* The maximum bit size (i.e. binary value) of the IPv6 number in BigInt
|
|
1355
|
-
*/
|
|
1356
|
-
this.maximumBitSize = Validator_1$2.Validator.ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_SIZE;
|
|
1357
|
-
/**
|
|
1358
|
-
* The type of IP number. Value is one of the values of the {@link IPNumType} enum
|
|
1359
|
-
* @type {IPNumType} the type of IP number
|
|
1360
|
-
*/
|
|
1361
|
-
this.type = "IPv6" /* IPv6 */;
|
|
1362
|
-
/**
|
|
1363
|
-
* An array of {@link Hexadecatet}'s
|
|
1364
|
-
*
|
|
1365
|
-
* @type {Array} the hexadecatet that makes up the IPv6 number
|
|
1366
|
-
*/
|
|
1367
|
-
this.hexadecatet = [];
|
|
1368
|
-
/**
|
|
1369
|
-
* The string character used to separate the individual hexadecatet when the IPv6 is rendered as strings
|
|
1370
|
-
*
|
|
1371
|
-
* @type {string} The string character used to separate the individual hexadecatet when rendered as strings
|
|
1372
|
-
*/
|
|
1373
|
-
this.separator = ":";
|
|
1374
|
-
if (typeof ipValue === "string") {
|
|
1375
|
-
let expandedIPv6 = IPv6Utils_1.expandIPv6Number(ipValue);
|
|
1376
|
-
let [value, hexadecatet] = this.constructFromHexadecimalDottedString(expandedIPv6);
|
|
1377
|
-
this.value = value;
|
|
1378
|
-
this.hexadecatet = hexadecatet;
|
|
1379
|
-
}
|
|
1380
|
-
else {
|
|
1381
|
-
let [value, hexadecatet] = this.constructFromBigIntValue(ipValue);
|
|
1382
|
-
this.value = value;
|
|
1383
|
-
this.hexadecatet = hexadecatet;
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
1416
|
/**
|
|
1387
1417
|
* A convenience method for creating an {@link IPv6} by providing the decimal value of the IP number in BigInt
|
|
1388
1418
|
*
|
|
@@ -1422,8 +1452,8 @@ class IPv6 extends AbstractIPNum {
|
|
|
1422
1452
|
static fromBinaryString(ipBinaryString) {
|
|
1423
1453
|
let validationResult = Validator_1$2.Validator.isValidBinaryString(ipBinaryString);
|
|
1424
1454
|
if (validationResult[0]) {
|
|
1425
|
-
let paddedBinaryString = BinaryUtils_3.leftPadWithZeroBit(ipBinaryString, 128);
|
|
1426
|
-
return new IPv6(BinaryUtils_2.parseBinaryStringToBigInt(paddedBinaryString));
|
|
1455
|
+
let paddedBinaryString = (0, BinaryUtils_3.leftPadWithZeroBit)(ipBinaryString, 128);
|
|
1456
|
+
return new IPv6((0, BinaryUtils_2.parseBinaryStringToBigInt)(paddedBinaryString));
|
|
1427
1457
|
}
|
|
1428
1458
|
else {
|
|
1429
1459
|
throw Error(validationResult[1].join(','));
|
|
@@ -1448,6 +1478,51 @@ class IPv6 extends AbstractIPNum {
|
|
|
1448
1478
|
static fromIPv4DotDecimalString(ip4DotDecimalString) {
|
|
1449
1479
|
return new IPv4(ip4DotDecimalString).toIPv4MappedIPv6();
|
|
1450
1480
|
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Constructor for an IPv6 number.
|
|
1483
|
+
*
|
|
1484
|
+
* @param {string | bigint} ipValue value to construct an IPv6 from. The given value can either be
|
|
1485
|
+
* numeric or string. If a string is given then it needs to be in hexadecatet string notation
|
|
1486
|
+
*/
|
|
1487
|
+
constructor(ipValue) {
|
|
1488
|
+
super();
|
|
1489
|
+
/**
|
|
1490
|
+
* The number of bits needed to represents the value of the IPv6 number
|
|
1491
|
+
*/
|
|
1492
|
+
this.bitSize = 128;
|
|
1493
|
+
/**
|
|
1494
|
+
* The maximum bit size (i.e. binary value) of the IPv6 number in BigInt
|
|
1495
|
+
*/
|
|
1496
|
+
this.maximumBitSize = Validator_1$2.Validator.ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_SIZE;
|
|
1497
|
+
/**
|
|
1498
|
+
* The type of IP number. Value is one of the values of the {@link IPNumType} enum
|
|
1499
|
+
* @type {IPNumType} the type of IP number
|
|
1500
|
+
*/
|
|
1501
|
+
this.type = "IPv6" /* IPNumType.IPv6 */;
|
|
1502
|
+
/**
|
|
1503
|
+
* An array of {@link Hexadecatet}'s
|
|
1504
|
+
*
|
|
1505
|
+
* @type {Array} the hexadecatet that makes up the IPv6 number
|
|
1506
|
+
*/
|
|
1507
|
+
this.hexadecatet = [];
|
|
1508
|
+
/**
|
|
1509
|
+
* The string character used to separate the individual hexadecatet when the IPv6 is rendered as strings
|
|
1510
|
+
*
|
|
1511
|
+
* @type {string} The string character used to separate the individual hexadecatet when rendered as strings
|
|
1512
|
+
*/
|
|
1513
|
+
this.separator = ":";
|
|
1514
|
+
if (typeof ipValue === "string") {
|
|
1515
|
+
let expandedIPv6 = (0, IPv6Utils_1.expandIPv6Number)(ipValue);
|
|
1516
|
+
let [value, hexadecatet] = this.constructFromHexadecimalDottedString(expandedIPv6);
|
|
1517
|
+
this.value = value;
|
|
1518
|
+
this.hexadecatet = hexadecatet;
|
|
1519
|
+
}
|
|
1520
|
+
else {
|
|
1521
|
+
let [value, hexadecatet] = this.constructFromBigIntValue(ipValue);
|
|
1522
|
+
this.value = value;
|
|
1523
|
+
this.hexadecatet = hexadecatet;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1451
1526
|
/**
|
|
1452
1527
|
* A string representation of the IPv6 number.
|
|
1453
1528
|
*
|
|
@@ -1492,7 +1567,7 @@ class IPv6 extends AbstractIPNum {
|
|
|
1492
1567
|
if (!isValid) {
|
|
1493
1568
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1494
1569
|
}
|
|
1495
|
-
let binaryString = BinaryUtils_4.numberToBinaryString(ipv6Number);
|
|
1570
|
+
let binaryString = (0, BinaryUtils_4.numberToBinaryString)(ipv6Number);
|
|
1496
1571
|
return [ipv6Number, this.binaryStringToHexadecatets(binaryString)];
|
|
1497
1572
|
}
|
|
1498
1573
|
constructFromHexadecimalDottedString(expandedIPv6) {
|
|
@@ -1504,11 +1579,11 @@ class IPv6 extends AbstractIPNum {
|
|
|
1504
1579
|
let hexadecatet = stringHexadecimals.map((stringHexadecatet) => {
|
|
1505
1580
|
return Hexadecatet_1$1.Hexadecatet.fromString(stringHexadecatet);
|
|
1506
1581
|
});
|
|
1507
|
-
let value = BigInt(`0b${HexadecimalUtils_2.hexadectetNotationToBinaryString(expandedIPv6)}`);
|
|
1582
|
+
let value = BigInt(`0b${(0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(expandedIPv6)}`);
|
|
1508
1583
|
return [value, hexadecatet];
|
|
1509
1584
|
}
|
|
1510
1585
|
binaryStringToHexadecatets(binaryString) {
|
|
1511
|
-
let hexadecimalString = HexadecimalUtils_1$1.binaryStringToHexadecimalString(binaryString);
|
|
1586
|
+
let hexadecimalString = (0, HexadecimalUtils_1$1.binaryStringToHexadecimalString)(binaryString);
|
|
1512
1587
|
while (hexadecimalString.length % 4 != 0) {
|
|
1513
1588
|
hexadecimalString = '0' + hexadecimalString;
|
|
1514
1589
|
}
|
|
@@ -1525,6 +1600,17 @@ IPNumber.IPv6 = IPv6;
|
|
|
1525
1600
|
* to demarcate which bits are used to identify a network, and the ones that are used to identify hosts on the network
|
|
1526
1601
|
*/
|
|
1527
1602
|
class IPv4Mask extends IPv4 {
|
|
1603
|
+
/**
|
|
1604
|
+
* A convenience method for creating an instance of IPv4Mask. The passed strings need to be a valid IPv4
|
|
1605
|
+
* number in dot-decimal notation.
|
|
1606
|
+
*
|
|
1607
|
+
* @param {string} rawValue The passed string in dot-decimal notation
|
|
1608
|
+
* @returns {IPv4Mask} the instance of IPv4Mask
|
|
1609
|
+
*/
|
|
1610
|
+
static fromDecimalDottedString(rawValue) {
|
|
1611
|
+
return new IPv4Mask(rawValue);
|
|
1612
|
+
}
|
|
1613
|
+
;
|
|
1528
1614
|
/**
|
|
1529
1615
|
* Constructor for creating an instance of IPv4Mask.
|
|
1530
1616
|
* The passed strings need to be a valid IPv4 mask number in dot-decimal notation.
|
|
@@ -1545,25 +1631,14 @@ class IPv4Mask extends IPv4 {
|
|
|
1545
1631
|
if (!isValid) {
|
|
1546
1632
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1547
1633
|
}
|
|
1548
|
-
let stringOctets = ipString.split(".");
|
|
1549
|
-
this.octets = stringOctets.map((rawOctet) => {
|
|
1550
|
-
return Octet_1.Octet.fromString(rawOctet);
|
|
1551
|
-
});
|
|
1552
|
-
let binaryString = BinaryUtils_1$2.dottedDecimalNotationToBinaryString(ipString);
|
|
1553
|
-
this.prefix = (binaryString.match(/1/g) || []).length;
|
|
1554
|
-
this.value = BigInt(`0b${binaryString}`);
|
|
1555
|
-
}
|
|
1556
|
-
/**
|
|
1557
|
-
* A convenience method for creating an instance of IPv4Mask. The passed strings need to be a valid IPv4
|
|
1558
|
-
* number in dot-decimal notation.
|
|
1559
|
-
*
|
|
1560
|
-
* @param {string} rawValue The passed string in dot-decimal notation
|
|
1561
|
-
* @returns {IPv4Mask} the instance of IPv4Mask
|
|
1562
|
-
*/
|
|
1563
|
-
static fromDecimalDottedString(rawValue) {
|
|
1564
|
-
return new IPv4Mask(rawValue);
|
|
1634
|
+
let stringOctets = ipString.split(".");
|
|
1635
|
+
this.octets = stringOctets.map((rawOctet) => {
|
|
1636
|
+
return Octet_1.Octet.fromString(rawOctet);
|
|
1637
|
+
});
|
|
1638
|
+
let binaryString = (0, BinaryUtils_1$2.dottedDecimalNotationToBinaryString)(ipString);
|
|
1639
|
+
this.prefix = (binaryString.match(/1/g) || []).length;
|
|
1640
|
+
this.value = BigInt(`0b${binaryString}`);
|
|
1565
1641
|
}
|
|
1566
|
-
;
|
|
1567
1642
|
}
|
|
1568
1643
|
IPNumber.IPv4Mask = IPv4Mask;
|
|
1569
1644
|
/**
|
|
@@ -1573,6 +1648,17 @@ IPNumber.IPv4Mask = IPv4Mask;
|
|
|
1573
1648
|
* on the network
|
|
1574
1649
|
*/
|
|
1575
1650
|
class IPv6Mask extends IPv6 {
|
|
1651
|
+
/**
|
|
1652
|
+
* A convenience method for creating an instance of IPv6Mask.
|
|
1653
|
+
* The passed strings need to be a valid IPv4 mask number in dot-decimal notation.
|
|
1654
|
+
*
|
|
1655
|
+
* @param {string} rawValue The passed string in textual notation
|
|
1656
|
+
* @returns {IPv6Mask} the instance of IPv6Mask
|
|
1657
|
+
*/
|
|
1658
|
+
static fromHexadecatet(rawValue) {
|
|
1659
|
+
return new IPv6Mask(rawValue);
|
|
1660
|
+
}
|
|
1661
|
+
;
|
|
1576
1662
|
/**
|
|
1577
1663
|
* Constructor for creating an instance of IPv6Mask.
|
|
1578
1664
|
* The passed strings need to be a valid IPv6 mask number in dot-decimal notation
|
|
@@ -1589,7 +1675,7 @@ class IPv6Mask extends IPv6 {
|
|
|
1589
1675
|
this.hexadecatet = [];
|
|
1590
1676
|
let isValid;
|
|
1591
1677
|
let message;
|
|
1592
|
-
let expandedIPv6 = IPv6Utils_1.expandIPv6Number(ipString);
|
|
1678
|
+
let expandedIPv6 = (0, IPv6Utils_1.expandIPv6Number)(ipString);
|
|
1593
1679
|
[isValid, message] = Validator_1$2.Validator.isValidIPv6Mask(expandedIPv6);
|
|
1594
1680
|
if (!isValid) {
|
|
1595
1681
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
@@ -1598,22 +1684,11 @@ class IPv6Mask extends IPv6 {
|
|
|
1598
1684
|
this.hexadecatet = stringHexadecimals.map((stringHexadecatet) => {
|
|
1599
1685
|
return Hexadecatet_1$1.Hexadecatet.fromString(stringHexadecatet);
|
|
1600
1686
|
});
|
|
1601
|
-
let binaryString = HexadecimalUtils_2.hexadectetNotationToBinaryString(expandedIPv6);
|
|
1687
|
+
let binaryString = (0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(expandedIPv6);
|
|
1602
1688
|
this.prefix = (binaryString.match(/1/g) || []).length;
|
|
1603
1689
|
this.value = BigInt(`0b${binaryString}`);
|
|
1604
|
-
this.value = BigInt(`0b${HexadecimalUtils_2.hexadectetNotationToBinaryString(expandedIPv6)}`);
|
|
1605
|
-
}
|
|
1606
|
-
/**
|
|
1607
|
-
* A convenience method for creating an instance of IPv6Mask.
|
|
1608
|
-
* The passed strings need to be a valid IPv4 mask number in dot-decimal notation.
|
|
1609
|
-
*
|
|
1610
|
-
* @param {string} rawValue The passed string in textual notation
|
|
1611
|
-
* @returns {IPv6Mask} the instance of IPv6Mask
|
|
1612
|
-
*/
|
|
1613
|
-
static fromHexadecatet(rawValue) {
|
|
1614
|
-
return new IPv6Mask(rawValue);
|
|
1690
|
+
this.value = BigInt(`0b${(0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(expandedIPv6)}`);
|
|
1615
1691
|
}
|
|
1616
|
-
;
|
|
1617
1692
|
}
|
|
1618
1693
|
IPNumber.IPv6Mask = IPv6Mask;
|
|
1619
1694
|
/**
|
|
@@ -1623,7 +1698,6 @@ IPNumber.IPv6Mask = IPv6Mask;
|
|
|
1623
1698
|
function isIPv4(ip) {
|
|
1624
1699
|
return ip.bitSize === 32;
|
|
1625
1700
|
}
|
|
1626
|
-
IPNumber.isIPv4 = isIPv4;
|
|
1627
1701
|
|
|
1628
1702
|
var IPNumType = {};
|
|
1629
1703
|
|
|
@@ -1636,7 +1710,8 @@ var IPRange = {};
|
|
|
1636
1710
|
var Prefix = {};
|
|
1637
1711
|
|
|
1638
1712
|
Object.defineProperty(Prefix, "__esModule", { value: true });
|
|
1639
|
-
Prefix.
|
|
1713
|
+
Prefix.IPv6Prefix = Prefix.IPv4Prefix = void 0;
|
|
1714
|
+
Prefix.isIPv4Prefix = isIPv4Prefix;
|
|
1640
1715
|
const Validator_1$1 = requireValidator();
|
|
1641
1716
|
const IPNumber_1$1 = IPNumber;
|
|
1642
1717
|
const BinaryUtils_1$1 = BinaryUtils;
|
|
@@ -1651,6 +1726,21 @@ const Hexadecatet_1 = Hexadecatet$1;
|
|
|
1651
1726
|
* {@see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing} for more information on CIDR
|
|
1652
1727
|
*/
|
|
1653
1728
|
class IPv4Prefix {
|
|
1729
|
+
/**
|
|
1730
|
+
* Convenience method for constructing an instance of IPv4 prefix from a decimal number
|
|
1731
|
+
*
|
|
1732
|
+
* @param {number} rawValue the decimal value to construct the IPv4 prefix from.
|
|
1733
|
+
* @returns {IPv4Prefix} the instance of an IPv4 prefix
|
|
1734
|
+
*/
|
|
1735
|
+
static fromNumber(rawValue) {
|
|
1736
|
+
return new IPv4Prefix(rawValue);
|
|
1737
|
+
}
|
|
1738
|
+
;
|
|
1739
|
+
static fromRangeSize(rangeSize) {
|
|
1740
|
+
let prefixNumber = rangeSize === (1n) ? 32 : 32 - rangeSizeToPrefix(rangeSize, Validator_1$1.Validator.IPV4_SIZE);
|
|
1741
|
+
return IPv4Prefix.fromNumber(BigInt(prefixNumber));
|
|
1742
|
+
}
|
|
1743
|
+
;
|
|
1654
1744
|
/**
|
|
1655
1745
|
* Constructor for an instance of IPv4 prefix from a decimal number
|
|
1656
1746
|
*
|
|
@@ -1662,27 +1752,12 @@ class IPv4Prefix {
|
|
|
1662
1752
|
this.bitValue = 32n;
|
|
1663
1753
|
let isValid;
|
|
1664
1754
|
let message;
|
|
1665
|
-
[isValid, message] = Validator_1$1.Validator.isValidPrefixValue(rawValue, "IPv4" /* IPv4 */);
|
|
1755
|
+
[isValid, message] = Validator_1$1.Validator.isValidPrefixValue(rawValue, "IPv4" /* IPNumType.IPv4 */);
|
|
1666
1756
|
if (!isValid) {
|
|
1667
1757
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1668
1758
|
}
|
|
1669
1759
|
this.value = rawValue;
|
|
1670
1760
|
}
|
|
1671
|
-
/**
|
|
1672
|
-
* Convenience method for constructing an instance of IPv4 prefix from a decimal number
|
|
1673
|
-
*
|
|
1674
|
-
* @param {number} rawValue the decimal value to construct the IPv4 prefix from.
|
|
1675
|
-
* @returns {IPv4Prefix} the instance of an IPv4 prefix
|
|
1676
|
-
*/
|
|
1677
|
-
static fromNumber(rawValue) {
|
|
1678
|
-
return new IPv4Prefix(rawValue);
|
|
1679
|
-
}
|
|
1680
|
-
;
|
|
1681
|
-
static fromRangeSize(rangeSize) {
|
|
1682
|
-
let prefixNumber = rangeSize === (1n) ? 32 : 32 - rangeSizeToPrefix(rangeSize, Validator_1$1.Validator.IPV4_SIZE);
|
|
1683
|
-
return IPv4Prefix.fromNumber(BigInt(prefixNumber));
|
|
1684
|
-
}
|
|
1685
|
-
;
|
|
1686
1761
|
/**
|
|
1687
1762
|
* Gets the decimal value of the IPv4 prefix
|
|
1688
1763
|
*
|
|
@@ -1739,7 +1814,7 @@ class IPv4Prefix {
|
|
|
1739
1814
|
return new IPv4Prefix(this.value + 1n);
|
|
1740
1815
|
}
|
|
1741
1816
|
toDecimalNotation(bits) {
|
|
1742
|
-
return `${BinaryUtils_1$1.parseBinaryStringToBigInt(bits.substr(0, 8))}.${BinaryUtils_1$1.parseBinaryStringToBigInt(bits.substr(8, 8))}.${BinaryUtils_1$1.parseBinaryStringToBigInt(bits.substr(16, 8))}.${BinaryUtils_1$1.parseBinaryStringToBigInt(bits.substr(24, 8))}`;
|
|
1817
|
+
return `${(0, BinaryUtils_1$1.parseBinaryStringToBigInt)(bits.substr(0, 8))}.${(0, BinaryUtils_1$1.parseBinaryStringToBigInt)(bits.substr(8, 8))}.${(0, BinaryUtils_1$1.parseBinaryStringToBigInt)(bits.substr(16, 8))}.${(0, BinaryUtils_1$1.parseBinaryStringToBigInt)(bits.substr(24, 8))}`;
|
|
1743
1818
|
}
|
|
1744
1819
|
}
|
|
1745
1820
|
Prefix.IPv4Prefix = IPv4Prefix;
|
|
@@ -1752,6 +1827,20 @@ Prefix.IPv4Prefix = IPv4Prefix;
|
|
|
1752
1827
|
* {@see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing} for more information on CIDR
|
|
1753
1828
|
*/
|
|
1754
1829
|
class IPv6Prefix {
|
|
1830
|
+
/**
|
|
1831
|
+
* Convenience method for constructing an instance of IPv46 prefix from a decimal number
|
|
1832
|
+
*
|
|
1833
|
+
* @param {number} rawValue the decimal value to construct the IPv6 prefix from.
|
|
1834
|
+
* @returns {IPv4Prefix} the instance of an IPv6 prefix
|
|
1835
|
+
*/
|
|
1836
|
+
static fromNumber(rawValue) {
|
|
1837
|
+
return new IPv6Prefix(rawValue);
|
|
1838
|
+
}
|
|
1839
|
+
;
|
|
1840
|
+
static fromRangeSize(rangeSize) {
|
|
1841
|
+
let prefixNumber = rangeSize === (1n) ? 128 : 128 - rangeSizeToPrefix(rangeSize, Validator_1$1.Validator.IPV6_SIZE);
|
|
1842
|
+
return IPv6Prefix.fromNumber(BigInt(prefixNumber));
|
|
1843
|
+
}
|
|
1755
1844
|
/**
|
|
1756
1845
|
* Constructor for an instance of IPv6 prefix from a decimal number
|
|
1757
1846
|
*
|
|
@@ -1763,26 +1852,12 @@ class IPv6Prefix {
|
|
|
1763
1852
|
this.bitValue = 128n;
|
|
1764
1853
|
let isValid;
|
|
1765
1854
|
let message;
|
|
1766
|
-
[isValid, message] = Validator_1$1.Validator.isValidPrefixValue(rawValue, "IPv6" /* IPv6 */);
|
|
1855
|
+
[isValid, message] = Validator_1$1.Validator.isValidPrefixValue(rawValue, "IPv6" /* IPNumType.IPv6 */);
|
|
1767
1856
|
if (!isValid) {
|
|
1768
1857
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1769
1858
|
}
|
|
1770
1859
|
this.value = rawValue;
|
|
1771
1860
|
}
|
|
1772
|
-
/**
|
|
1773
|
-
* Convenience method for constructing an instance of IPv46 prefix from a decimal number
|
|
1774
|
-
*
|
|
1775
|
-
* @param {number} rawValue the decimal value to construct the IPv6 prefix from.
|
|
1776
|
-
* @returns {IPv4Prefix} the instance of an IPv6 prefix
|
|
1777
|
-
*/
|
|
1778
|
-
static fromNumber(rawValue) {
|
|
1779
|
-
return new IPv6Prefix(rawValue);
|
|
1780
|
-
}
|
|
1781
|
-
;
|
|
1782
|
-
static fromRangeSize(rangeSize) {
|
|
1783
|
-
let prefixNumber = rangeSize === (1n) ? 128 : 128 - rangeSizeToPrefix(rangeSize, Validator_1$1.Validator.IPV6_SIZE);
|
|
1784
|
-
return IPv6Prefix.fromNumber(BigInt(prefixNumber));
|
|
1785
|
-
}
|
|
1786
1861
|
/**
|
|
1787
1862
|
* Gets the decimal value of the IPv6 prefix
|
|
1788
1863
|
*
|
|
@@ -1841,7 +1916,7 @@ class IPv6Prefix {
|
|
|
1841
1916
|
toHexadecatetNotation(bits) {
|
|
1842
1917
|
let binaryStrings = bits.match(/.{1,16}/g);
|
|
1843
1918
|
let hexadecimalStrings = binaryStrings.map((binaryString) => {
|
|
1844
|
-
return Hexadecatet_1.Hexadecatet.fromString(HexadecimalUtils_1.binaryStringToHexadecimalString(binaryString));
|
|
1919
|
+
return Hexadecatet_1.Hexadecatet.fromString((0, HexadecimalUtils_1.binaryStringToHexadecimalString)(binaryString));
|
|
1845
1920
|
});
|
|
1846
1921
|
return hexadecimalStrings.map((value) => { return value.toString(); }).join(":");
|
|
1847
1922
|
}
|
|
@@ -1853,7 +1928,7 @@ function rangeSizeToPrefix(rangeSize, rangeMaxSize) {
|
|
|
1853
1928
|
throw new Error(Validator_1$1.Validator.invalidIPRangeSizeMessage.replace("$iptype", ipType));
|
|
1854
1929
|
}
|
|
1855
1930
|
try {
|
|
1856
|
-
return BinaryUtils_1$1.intLog2(rangeSize);
|
|
1931
|
+
return (0, BinaryUtils_1$1.intLog2)(rangeSize);
|
|
1857
1932
|
}
|
|
1858
1933
|
catch (e) {
|
|
1859
1934
|
throw new Error(Validator_1$1.Validator.invalidIPRangeSizeForCidrMessage);
|
|
@@ -1866,10 +1941,10 @@ function rangeSizeToPrefix(rangeSize, rangeMaxSize) {
|
|
|
1866
1941
|
function isIPv4Prefix(prefix) {
|
|
1867
1942
|
return prefix.type === "IPv4";
|
|
1868
1943
|
}
|
|
1869
|
-
Prefix.isIPv4Prefix = isIPv4Prefix;
|
|
1870
1944
|
|
|
1871
1945
|
Object.defineProperty(IPRange, "__esModule", { value: true });
|
|
1872
|
-
IPRange.
|
|
1946
|
+
IPRange.IPv6CidrRange = IPRange.IPv4CidrRange = IPRange.AbstractIPRange = IPRange.RangedSet = void 0;
|
|
1947
|
+
IPRange.isIPv4CidrRange = isIPv4CidrRange;
|
|
1873
1948
|
const IPNumber_1 = IPNumber;
|
|
1874
1949
|
const Prefix_1$1 = Prefix;
|
|
1875
1950
|
const BinaryUtils_1 = BinaryUtils;
|
|
@@ -1880,24 +1955,6 @@ const Validator_1 = requireValidator();
|
|
|
1880
1955
|
* for allocating IP addresses.
|
|
1881
1956
|
*/
|
|
1882
1957
|
class RangedSet {
|
|
1883
|
-
/**
|
|
1884
|
-
* Constructor for an instance of {@link RangedSet} from an
|
|
1885
|
-
* instance of either {@link IPv4CidrRange} or {@link IPv6CidrRange}
|
|
1886
|
-
*
|
|
1887
|
-
* Throws an exception if first IP number is not less than given last IP number
|
|
1888
|
-
*
|
|
1889
|
-
* @param first the first IP number of the range
|
|
1890
|
-
* @param last the last IP number of the range
|
|
1891
|
-
*/
|
|
1892
|
-
constructor(first, last) {
|
|
1893
|
-
this.first = first;
|
|
1894
|
-
this.last = last;
|
|
1895
|
-
if (first.isGreaterThan(last)) {
|
|
1896
|
-
throw new Error(`${first.toString()} should be lower than ${last.toString()}`);
|
|
1897
|
-
}
|
|
1898
|
-
this.currentValue = first;
|
|
1899
|
-
this.bitValue = BigInt(first.bitSize);
|
|
1900
|
-
}
|
|
1901
1958
|
/**
|
|
1902
1959
|
* Convenience method for constructing an instance of {@link RangedSet} from a
|
|
1903
1960
|
* single IP number.
|
|
@@ -1942,6 +1999,24 @@ class RangedSet {
|
|
|
1942
1999
|
throw new Error("First IP and Last IP should be valid and same type");
|
|
1943
2000
|
}
|
|
1944
2001
|
}
|
|
2002
|
+
/**
|
|
2003
|
+
* Constructor for an instance of {@link RangedSet} from an
|
|
2004
|
+
* instance of either {@link IPv4CidrRange} or {@link IPv6CidrRange}
|
|
2005
|
+
*
|
|
2006
|
+
* Throws an exception if first IP number is not less than given last IP number
|
|
2007
|
+
*
|
|
2008
|
+
* @param first the first IP number of the range
|
|
2009
|
+
* @param last the last IP number of the range
|
|
2010
|
+
*/
|
|
2011
|
+
constructor(first, last) {
|
|
2012
|
+
this.first = first;
|
|
2013
|
+
this.last = last;
|
|
2014
|
+
if (first.isGreaterThan(last)) {
|
|
2015
|
+
throw new Error(`${first.toString()} should be lower than ${last.toString()}`);
|
|
2016
|
+
}
|
|
2017
|
+
this.currentValue = first;
|
|
2018
|
+
this.bitValue = BigInt(first.bitSize);
|
|
2019
|
+
}
|
|
1945
2020
|
/**
|
|
1946
2021
|
* Returns the first IP number in the range
|
|
1947
2022
|
*/
|
|
@@ -2045,7 +2120,11 @@ class RangedSet {
|
|
|
2045
2120
|
let otherLast = otherRange.getLast();
|
|
2046
2121
|
return (thisLast.isGreaterThan(otherFirst) && thisLast.isLessThanOrEquals(otherLast) && thisFirst.isLessThan(otherFirst)
|
|
2047
2122
|
||
|
|
2048
|
-
otherLast.isGreaterThan(thisFirst) && otherLast.isLessThanOrEquals(thisLast) && otherFirst.isLessThan(thisFirst)
|
|
2123
|
+
otherLast.isGreaterThan(thisFirst) && otherLast.isLessThanOrEquals(thisLast) && otherFirst.isLessThan(thisFirst)
|
|
2124
|
+
||
|
|
2125
|
+
this.contains(otherRange)
|
|
2126
|
+
||
|
|
2127
|
+
otherRange.contains(this));
|
|
2049
2128
|
}
|
|
2050
2129
|
/**
|
|
2051
2130
|
* Check if this range can be converted to a CIDR range.
|
|
@@ -2055,8 +2134,8 @@ class RangedSet {
|
|
|
2055
2134
|
return true;
|
|
2056
2135
|
}
|
|
2057
2136
|
try {
|
|
2058
|
-
let prefix = BinaryUtils_1.intLog2(this.getSize());
|
|
2059
|
-
let netmask = BinaryUtils_1.parseBinaryStringToBigInt(BinaryUtils_1.cidrPrefixToMaskBinaryString(prefix, IPNumber_1.isIPv4(this.currentValue) ? "IPv4" /* IPv4 */ : "IPv6" /* IPv6 */));
|
|
2137
|
+
let prefix = (0, BinaryUtils_1.intLog2)(this.getSize());
|
|
2138
|
+
let netmask = (0, BinaryUtils_1.parseBinaryStringToBigInt)((0, BinaryUtils_1.cidrPrefixToMaskBinaryString)(prefix, (0, IPNumber_1.isIPv4)(this.currentValue) ? "IPv4" /* IPNumType.IPv4 */ : "IPv6" /* IPNumType.IPv6 */));
|
|
2060
2139
|
return (this.first.getValue()) === (netmask & (this.first.getValue()));
|
|
2061
2140
|
}
|
|
2062
2141
|
catch (e) {
|
|
@@ -2067,7 +2146,7 @@ class RangedSet {
|
|
|
2067
2146
|
* Converts an instance of range to an instance of CIDR range
|
|
2068
2147
|
*/
|
|
2069
2148
|
toCidrRange() {
|
|
2070
|
-
if (IPNumber_1.isIPv4(this.currentValue)) {
|
|
2149
|
+
if ((0, IPNumber_1.isIPv4)(this.currentValue)) {
|
|
2071
2150
|
return this.toIPv4CidrRange();
|
|
2072
2151
|
}
|
|
2073
2152
|
else {
|
|
@@ -2101,6 +2180,12 @@ class RangedSet {
|
|
|
2101
2180
|
if (this.isEquals(otherRange)) {
|
|
2102
2181
|
return new RangedSet(otherRange.getFirst(), otherRange.getLast());
|
|
2103
2182
|
}
|
|
2183
|
+
if (this.contains(otherRange)) {
|
|
2184
|
+
return new RangedSet(this.getFirst(), this.getLast());
|
|
2185
|
+
}
|
|
2186
|
+
else if (otherRange.contains(this)) {
|
|
2187
|
+
return new RangedSet(otherRange.getFirst(), otherRange.getLast());
|
|
2188
|
+
}
|
|
2104
2189
|
if (this.isOverlapping(otherRange)) {
|
|
2105
2190
|
if (this.getFirst().isLessThan(otherRange.getFirst())) {
|
|
2106
2191
|
return new RangedSet(this.getFirst(), otherRange.getLast());
|
|
@@ -2109,12 +2194,6 @@ class RangedSet {
|
|
|
2109
2194
|
return new RangedSet(otherRange.getFirst(), this.getLast());
|
|
2110
2195
|
}
|
|
2111
2196
|
}
|
|
2112
|
-
if (this.contains(otherRange)) {
|
|
2113
|
-
return new RangedSet(this.getFirst(), this.getLast());
|
|
2114
|
-
}
|
|
2115
|
-
else if (otherRange.contains(this)) {
|
|
2116
|
-
return new RangedSet(otherRange.getFirst(), otherRange.getLast());
|
|
2117
|
-
}
|
|
2118
2197
|
throw new Error("Ranges do not overlap nor are equal");
|
|
2119
2198
|
}
|
|
2120
2199
|
/**
|
|
@@ -2168,10 +2247,10 @@ class RangedSet {
|
|
|
2168
2247
|
throw new Error("Sub range cannot be zero");
|
|
2169
2248
|
}
|
|
2170
2249
|
let valueOfFirstIp = this.getFirst().value + (offset);
|
|
2171
|
-
let firstIp = IPNumber_1.isIPv4(this.getFirst()) ?
|
|
2250
|
+
let firstIp = (0, IPNumber_1.isIPv4)(this.getFirst()) ?
|
|
2172
2251
|
IPNumber_1.IPv4.fromNumber(valueOfFirstIp) : IPNumber_1.IPv6.fromBigInt(valueOfFirstIp);
|
|
2173
2252
|
let valueOfLastIp = firstIp.value + (size - 1n);
|
|
2174
|
-
let lastIp = IPNumber_1.isIPv4(firstIp) ? IPNumber_1.IPv4.fromNumber(valueOfLastIp) : IPNumber_1.IPv6.fromBigInt(valueOfLastIp);
|
|
2253
|
+
let lastIp = (0, IPNumber_1.isIPv4)(firstIp) ? IPNumber_1.IPv4.fromNumber(valueOfLastIp) : IPNumber_1.IPv6.fromBigInt(valueOfLastIp);
|
|
2175
2254
|
return new RangedSet(firstIp, lastIp);
|
|
2176
2255
|
}
|
|
2177
2256
|
/**
|
|
@@ -2249,6 +2328,12 @@ class AbstractIPRange {
|
|
|
2249
2328
|
return this.toRangeSet().inside(otherRange.toRangeSet());
|
|
2250
2329
|
}
|
|
2251
2330
|
contains(otherRange) {
|
|
2331
|
+
if (otherRange instanceof IPNumber_1.AbstractIPNum) {
|
|
2332
|
+
const firstValue = this.getFirst().getValue();
|
|
2333
|
+
const lastValue = this.getLast().getValue();
|
|
2334
|
+
const otherValue = otherRange.getValue();
|
|
2335
|
+
return otherValue >= firstValue && otherValue <= lastValue;
|
|
2336
|
+
}
|
|
2252
2337
|
return this.toRangeSet().contains(otherRange.toRangeSet());
|
|
2253
2338
|
}
|
|
2254
2339
|
toRangeString() {
|
|
@@ -2261,7 +2346,7 @@ class AbstractIPRange {
|
|
|
2261
2346
|
return this.toRangeSet().isConsecutive(otherRange.toRangeSet());
|
|
2262
2347
|
}
|
|
2263
2348
|
isCidrMergeable(otherRange) {
|
|
2264
|
-
const count = BigInt(BinaryUtils_1.matchingBitCount(this.getFirst().toBinaryString(), otherRange.getFirst().toBinaryString()));
|
|
2349
|
+
const count = BigInt((0, BinaryUtils_1.matchingBitCount)(this.getFirst().toBinaryString(), otherRange.getFirst().toBinaryString()));
|
|
2265
2350
|
if (this.getPrefix().value - count !== 1n) {
|
|
2266
2351
|
return false;
|
|
2267
2352
|
}
|
|
@@ -2306,23 +2391,6 @@ IPRange.AbstractIPRange = AbstractIPRange;
|
|
|
2306
2391
|
* @see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
|
|
2307
2392
|
*/
|
|
2308
2393
|
class IPv4CidrRange extends AbstractIPRange {
|
|
2309
|
-
/**
|
|
2310
|
-
* Constructor for creating an instance of an IPv4 range.
|
|
2311
|
-
*
|
|
2312
|
-
* The arguments taken by the constructor is inspired by the CIDR notation which basically consists of the IP
|
|
2313
|
-
* number and the prefix.
|
|
2314
|
-
*
|
|
2315
|
-
* @param {IPv4} ipv4 the IP number used to construct the range. By convention this is the first IP number in
|
|
2316
|
-
* the range, but it could also be any IP number within the range
|
|
2317
|
-
* @param {IPv4Prefix} cidrPrefix the prefix which is a representation of the number of bits used to mask the
|
|
2318
|
-
* given IP number in other to create the range
|
|
2319
|
-
*/
|
|
2320
|
-
constructor(ipv4, cidrPrefix) {
|
|
2321
|
-
super();
|
|
2322
|
-
this.ipv4 = ipv4;
|
|
2323
|
-
this.cidrPrefix = cidrPrefix;
|
|
2324
|
-
this.bitValue = 32n;
|
|
2325
|
-
}
|
|
2326
2394
|
/**
|
|
2327
2395
|
* Convenience method for constructing an instance of an IPv4CidrRange from an IP range represented in CIDR notation
|
|
2328
2396
|
*
|
|
@@ -2340,6 +2408,23 @@ class IPv4CidrRange extends AbstractIPRange {
|
|
|
2340
2408
|
let prefix = BigInt(parseInt(cidrComponents[1]));
|
|
2341
2409
|
return new IPv4CidrRange(IPNumber_1.IPv4.fromDecimalDottedString(ipString), Prefix_1$1.IPv4Prefix.fromNumber(prefix));
|
|
2342
2410
|
}
|
|
2411
|
+
/**
|
|
2412
|
+
* Constructor for creating an instance of an IPv4 range.
|
|
2413
|
+
*
|
|
2414
|
+
* The arguments taken by the constructor is inspired by the CIDR notation which basically consists of the IP
|
|
2415
|
+
* number and the prefix.
|
|
2416
|
+
*
|
|
2417
|
+
* @param {IPv4} ipv4 the IP number used to construct the range. By convention this is the first IP number in
|
|
2418
|
+
* the range, but it could also be any IP number within the range
|
|
2419
|
+
* @param {IPv4Prefix} cidrPrefix the prefix which is a representation of the number of bits used to mask the
|
|
2420
|
+
* given IP number in other to create the range
|
|
2421
|
+
*/
|
|
2422
|
+
constructor(ipv4, cidrPrefix) {
|
|
2423
|
+
super();
|
|
2424
|
+
this.ipv4 = ipv4;
|
|
2425
|
+
this.cidrPrefix = cidrPrefix;
|
|
2426
|
+
this.bitValue = 32n;
|
|
2427
|
+
}
|
|
2343
2428
|
/**
|
|
2344
2429
|
* Gets the size of IPv4 numbers contained within the IPv4 range
|
|
2345
2430
|
*
|
|
@@ -2541,23 +2626,6 @@ IPRange.IPv4CidrRange = IPv4CidrRange;
|
|
|
2541
2626
|
* @see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
|
|
2542
2627
|
*/
|
|
2543
2628
|
class IPv6CidrRange extends AbstractIPRange {
|
|
2544
|
-
/**
|
|
2545
|
-
* Constructor for creating an instance of an IPv6 range.
|
|
2546
|
-
*
|
|
2547
|
-
* The arguments taken by the constructor is inspired by the CIDR notation which basically consists of the IP
|
|
2548
|
-
* number and the prefix.
|
|
2549
|
-
*
|
|
2550
|
-
* @param {IPv6} ipv6 the IP number used to construct the range. By convention this is the first IP number in
|
|
2551
|
-
* the range, but it could also be any IP number within the range
|
|
2552
|
-
* @param {IPv6Prefix} cidrPrefix the prefix which is a representation of the number of bits used to mask the
|
|
2553
|
-
* given IPv6 number in other to create the range
|
|
2554
|
-
*/
|
|
2555
|
-
constructor(ipv6, cidrPrefix) {
|
|
2556
|
-
super();
|
|
2557
|
-
this.ipv6 = ipv6;
|
|
2558
|
-
this.cidrPrefix = cidrPrefix;
|
|
2559
|
-
this.bitValue = 128n;
|
|
2560
|
-
}
|
|
2561
2629
|
/**
|
|
2562
2630
|
* Convenience method for constructing an instance of an IPV6Range from an IP range represented in CIDR notation
|
|
2563
2631
|
*
|
|
@@ -2575,6 +2643,23 @@ class IPv6CidrRange extends AbstractIPRange {
|
|
|
2575
2643
|
return new IPv6CidrRange(IPNumber_1.IPv6.fromHexadecatet(ipString), Prefix_1$1.IPv6Prefix.fromNumber(prefix));
|
|
2576
2644
|
}
|
|
2577
2645
|
;
|
|
2646
|
+
/**
|
|
2647
|
+
* Constructor for creating an instance of an IPv6 range.
|
|
2648
|
+
*
|
|
2649
|
+
* The arguments taken by the constructor is inspired by the CIDR notation which basically consists of the IP
|
|
2650
|
+
* number and the prefix.
|
|
2651
|
+
*
|
|
2652
|
+
* @param {IPv6} ipv6 the IP number used to construct the range. By convention this is the first IP number in
|
|
2653
|
+
* the range, but it could also be any IP number within the range
|
|
2654
|
+
* @param {IPv6Prefix} cidrPrefix the prefix which is a representation of the number of bits used to mask the
|
|
2655
|
+
* given IPv6 number in other to create the range
|
|
2656
|
+
*/
|
|
2657
|
+
constructor(ipv6, cidrPrefix) {
|
|
2658
|
+
super();
|
|
2659
|
+
this.ipv6 = ipv6;
|
|
2660
|
+
this.cidrPrefix = cidrPrefix;
|
|
2661
|
+
this.bitValue = 128n;
|
|
2662
|
+
}
|
|
2578
2663
|
/**
|
|
2579
2664
|
* Gets the size of IPv6 numbers contained within the IPv6 range
|
|
2580
2665
|
*
|
|
@@ -2771,18 +2856,17 @@ let last = (range, ip) => {
|
|
|
2771
2856
|
let bitValue = Number(range.bitValue.valueOf());
|
|
2772
2857
|
let maskSize = BigInt(`0b${"1".repeat(bitValue)}`);
|
|
2773
2858
|
let maskAsBigInteger = range.cidrPrefix.toMask().getValue();
|
|
2774
|
-
let invertedMask = BinaryUtils_1.leftPadWithZeroBit((maskAsBigInteger ^ (maskSize)).toString(2), bitValue);
|
|
2859
|
+
let invertedMask = (0, BinaryUtils_1.leftPadWithZeroBit)((maskAsBigInteger ^ (maskSize)).toString(2), bitValue);
|
|
2775
2860
|
if (isIPv4CidrRange(range)) {
|
|
2776
|
-
return IPNumber_1.IPv4.fromNumber((ip.getValue()) | (BinaryUtils_1.parseBinaryStringToBigInt(invertedMask)));
|
|
2861
|
+
return IPNumber_1.IPv4.fromNumber((ip.getValue()) | ((0, BinaryUtils_1.parseBinaryStringToBigInt)(invertedMask)));
|
|
2777
2862
|
}
|
|
2778
2863
|
else {
|
|
2779
|
-
return IPNumber_1.IPv6.fromBigInt((ip.getValue()) | (BinaryUtils_1.parseBinaryStringToBigInt(invertedMask)));
|
|
2864
|
+
return IPNumber_1.IPv6.fromBigInt((ip.getValue()) | ((0, BinaryUtils_1.parseBinaryStringToBigInt)(invertedMask)));
|
|
2780
2865
|
}
|
|
2781
2866
|
};
|
|
2782
2867
|
function isIPv4CidrRange(ip) {
|
|
2783
2868
|
return ip.bitValue.valueOf() === 32n;
|
|
2784
2869
|
}
|
|
2785
|
-
IPRange.isIPv4CidrRange = isIPv4CidrRange;
|
|
2786
2870
|
|
|
2787
2871
|
Object.defineProperty(IPPool, "__esModule", { value: true });
|
|
2788
2872
|
IPPool.Pool = void 0;
|
|
@@ -2792,19 +2876,6 @@ const Prefix_1 = Prefix;
|
|
|
2792
2876
|
* Represents a collection of IP {@link RangedSet}'s
|
|
2793
2877
|
*/
|
|
2794
2878
|
class Pool {
|
|
2795
|
-
/**
|
|
2796
|
-
* Constructor for an IP pool.
|
|
2797
|
-
*
|
|
2798
|
-
* Creates a Pool of IP ranges from supplied {@link RangedSet}'s
|
|
2799
|
-
*
|
|
2800
|
-
* @param ranges the array of IP ranges that would make up the pool.
|
|
2801
|
-
*/
|
|
2802
|
-
constructor(ranges) {
|
|
2803
|
-
this.backingSet = new SortedSet();
|
|
2804
|
-
ranges.forEach(range => {
|
|
2805
|
-
this.backingSet.add(range);
|
|
2806
|
-
});
|
|
2807
|
-
}
|
|
2808
2879
|
/**
|
|
2809
2880
|
* Convenient method for creating an instance from arrays of {@link IPv4} or {@link IPv6}
|
|
2810
2881
|
* @param ipNumbers the arrays of {@link IPv4} or {@link IPv6} that will make up the pool.
|
|
@@ -2836,6 +2907,19 @@ class Pool {
|
|
|
2836
2907
|
});
|
|
2837
2908
|
return new Pool(rangeSet);
|
|
2838
2909
|
}
|
|
2910
|
+
/**
|
|
2911
|
+
* Constructor for an IP pool.
|
|
2912
|
+
*
|
|
2913
|
+
* Creates a Pool of IP ranges from supplied {@link RangedSet}'s
|
|
2914
|
+
*
|
|
2915
|
+
* @param ranges the array of IP ranges that would make up the pool.
|
|
2916
|
+
*/
|
|
2917
|
+
constructor(ranges) {
|
|
2918
|
+
this.backingSet = new SortedSet();
|
|
2919
|
+
ranges.forEach(range => {
|
|
2920
|
+
this.backingSet.add(range);
|
|
2921
|
+
});
|
|
2922
|
+
}
|
|
2839
2923
|
/**
|
|
2840
2924
|
* Returns an array of {@link RangedSet}'s that is contained within the pool
|
|
2841
2925
|
*/
|
|
@@ -2910,7 +2994,7 @@ class Pool {
|
|
|
2910
2994
|
if (e instanceof RangeError) {
|
|
2911
2995
|
continue loop;
|
|
2912
2996
|
}
|
|
2913
|
-
error = e;
|
|
2997
|
+
error = e instanceof Error ? e : new Error(String(e));
|
|
2914
2998
|
}
|
|
2915
2999
|
}
|
|
2916
3000
|
if (selectedCidrRange) {
|
|
@@ -2946,7 +3030,7 @@ class Pool {
|
|
|
2946
3030
|
}
|
|
2947
3031
|
}
|
|
2948
3032
|
catch (e) {
|
|
2949
|
-
let lowerPrefix = Prefix_1.isIPv4Prefix(prefix) ?
|
|
3033
|
+
let lowerPrefix = (0, Prefix_1.isIPv4Prefix)(prefix) ?
|
|
2950
3034
|
Prefix_1.IPv4Prefix.fromNumber(prefix.getValue() + 1n) : Prefix_1.IPv6Prefix.fromNumber(prefix.getValue() + 1n);
|
|
2951
3035
|
return go(reqprefix, lowerPrefix, accummulated);
|
|
2952
3036
|
}
|
|
@@ -3014,14 +3098,6 @@ class Pool {
|
|
|
3014
3098
|
}
|
|
3015
3099
|
IPPool.Pool = Pool;
|
|
3016
3100
|
class SortedSet {
|
|
3017
|
-
constructor(array) {
|
|
3018
|
-
if (array) {
|
|
3019
|
-
this.backingArray = this.sortArray(array);
|
|
3020
|
-
}
|
|
3021
|
-
else {
|
|
3022
|
-
this.backingArray = new Array();
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
3101
|
sortArray(array) {
|
|
3026
3102
|
array.sort((a, b) => {
|
|
3027
3103
|
if (a.isLessThan(b)) {
|
|
@@ -3034,6 +3110,14 @@ class SortedSet {
|
|
|
3034
3110
|
});
|
|
3035
3111
|
return array;
|
|
3036
3112
|
}
|
|
3113
|
+
constructor(array) {
|
|
3114
|
+
if (array) {
|
|
3115
|
+
this.backingArray = this.sortArray(array);
|
|
3116
|
+
}
|
|
3117
|
+
else {
|
|
3118
|
+
this.backingArray = new Array();
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3037
3121
|
asArray() {
|
|
3038
3122
|
return this.backingArray;
|
|
3039
3123
|
}
|
|
@@ -3105,13 +3189,17 @@ class SortedSet {
|
|
|
3105
3189
|
(function (exports) {
|
|
3106
3190
|
var __createBinding = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3107
3191
|
if (k2 === undefined) k2 = k;
|
|
3108
|
-
Object.
|
|
3192
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3193
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3194
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
3195
|
+
}
|
|
3196
|
+
Object.defineProperty(o, k2, desc);
|
|
3109
3197
|
}) : (function(o, m, k, k2) {
|
|
3110
3198
|
if (k2 === undefined) k2 = k;
|
|
3111
3199
|
o[k2] = m[k];
|
|
3112
3200
|
}));
|
|
3113
3201
|
var __exportStar = (_commonjsHelpers.commonjsGlobal && _commonjsHelpers.commonjsGlobal.__exportStar) || function(m, exports) {
|
|
3114
|
-
for (var p in m) if (p !== "default" && !
|
|
3202
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3115
3203
|
};
|
|
3116
3204
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3117
3205
|
/**
|
|
@@ -3135,7 +3223,7 @@ class SortedSet {
|
|
|
3135
3223
|
__exportStar(Prefix, exports);
|
|
3136
3224
|
__exportStar(requireValidator(), exports);
|
|
3137
3225
|
|
|
3138
|
-
} (
|
|
3226
|
+
} (src));
|
|
3139
3227
|
|
|
3140
3228
|
var toLabelAndValue = function toLabelAndValue(value) {
|
|
3141
3229
|
return {
|
|
@@ -3144,10 +3232,10 @@ var toLabelAndValue = function toLabelAndValue(value) {
|
|
|
3144
3232
|
};
|
|
3145
3233
|
};
|
|
3146
3234
|
var isValidIPv4String = function isValidIPv4String(ip) {
|
|
3147
|
-
return ramda.isNotNil(ip) &&
|
|
3235
|
+
return ramda.isNotNil(ip) && src.Validator.isValidIPv4String(ip)[0];
|
|
3148
3236
|
};
|
|
3149
3237
|
var isValidIPv6String = function isValidIPv6String(ip) {
|
|
3150
|
-
return ramda.isNotNil(ip) &&
|
|
3238
|
+
return ramda.isNotNil(ip) && src.Validator.isValidIPv6String(ip)[0];
|
|
3151
3239
|
};
|
|
3152
3240
|
var isValidIpString = function isValidIpString(ip) {
|
|
3153
3241
|
return isValidIPv4String(ip) || isValidIPv6String(ip);
|
|
@@ -3156,13 +3244,13 @@ var areIpAddressesInSameFormat = function areIpAddressesInSameFormat(ipStart, ip
|
|
|
3156
3244
|
return isValidIPv4String(ipStart) && isValidIPv4String(ipEnd) || isValidIPv6String(ipStart) && isValidIPv6String(ipEnd);
|
|
3157
3245
|
};
|
|
3158
3246
|
var isValidIPv4Range = function isValidIPv4Range(ipStart, ipEnd) {
|
|
3159
|
-
var ipStartAddr =
|
|
3160
|
-
var ipEndAddr =
|
|
3247
|
+
var ipStartAddr = src.IPv4.fromDecimalDottedString(ipStart);
|
|
3248
|
+
var ipEndAddr = src.IPv4.fromDecimalDottedString(ipEnd);
|
|
3161
3249
|
return ipStartAddr.isLessThanOrEquals(ipEndAddr);
|
|
3162
3250
|
};
|
|
3163
3251
|
var isValidIPv6Range = function isValidIPv6Range(ipStart, ipEnd) {
|
|
3164
|
-
var ipStartAddr =
|
|
3165
|
-
var ipEndAddr =
|
|
3252
|
+
var ipStartAddr = src.IPv6.fromString(ipStart);
|
|
3253
|
+
var ipEndAddr = src.IPv6.fromString(ipEnd);
|
|
3166
3254
|
return ipStartAddr.isLessThanOrEquals(ipEndAddr);
|
|
3167
3255
|
};
|
|
3168
3256
|
var isValidIPRange = function isValidIPRange(ipStart, ipEnd) {
|
|
@@ -3252,8 +3340,6 @@ var ADDRESS_TYPE_SELECT_OPTIONS = [{
|
|
|
3252
3340
|
value: "ipv6"
|
|
3253
3341
|
}];
|
|
3254
3342
|
({
|
|
3255
|
-
ipStart: "",
|
|
3256
|
-
ipEnd: "",
|
|
3257
3343
|
addressType: ADDRESS_TYPE_SELECT_OPTIONS[0].value
|
|
3258
3344
|
});
|
|
3259
3345
|
var VALIDATION_SCHEMA = yup__namespace.object().shape({
|
|
@@ -3461,7 +3547,7 @@ var allowedIpRangesApi = {
|
|
|
3461
3547
|
};
|
|
3462
3548
|
|
|
3463
3549
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3464
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t),
|
|
3550
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3465
3551
|
var ALLOWED_IP_RANGES$1 = QUERY_KEYS.ALLOWED_IP_RANGES;
|
|
3466
3552
|
var useFetchAllowedIpRanges = function useFetchAllowedIpRanges(options) {
|
|
3467
3553
|
return reactQuery.useQuery(_objectSpread({
|