@bigbinary/neeto-molecules 4.0.19 → 4.0.29
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
package/dist/IpRestriction.js
CHANGED
|
@@ -27,10 +27,10 @@ import { useQuery } from '@tanstack/react-query';
|
|
|
27
27
|
import axios from 'axios';
|
|
28
28
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
29
29
|
import useMutationWithInvalidation from '@bigbinary/neeto-commons-frontend/react-utils/useMutationWithInvalidation';
|
|
30
|
-
import { n } from './inject-css-
|
|
30
|
+
import { n } from './inject-css-C2dztUxs.js';
|
|
31
31
|
import '@bigbinary/neeto-cist';
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var src = {};
|
|
34
34
|
|
|
35
35
|
var BinaryUtils = {};
|
|
36
36
|
|
|
@@ -43,9 +43,10 @@ var BinaryUtils = {};
|
|
|
43
43
|
* @param num number to parse
|
|
44
44
|
* @returns {string} the binary string representation of number
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
let numberToBinaryString = (num) => {
|
|
47
47
|
return num.toString(2);
|
|
48
48
|
};
|
|
49
|
+
exports.numberToBinaryString = numberToBinaryString;
|
|
49
50
|
/**
|
|
50
51
|
* Converts a decimal number to binary octet (8 bit) string. If needed the octet will be padded with zeros
|
|
51
52
|
* to make it up to 8 bits
|
|
@@ -53,23 +54,25 @@ var BinaryUtils = {};
|
|
|
53
54
|
* @param {number} num to convert to octet string
|
|
54
55
|
* @returns {string} the octet string representation of given number
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
-
let binaryString = exports.numberToBinaryString(num);
|
|
57
|
+
let decimalNumberToOctetString = (num) => {
|
|
58
|
+
let binaryString = (0, exports.numberToBinaryString)(num);
|
|
58
59
|
let length = binaryString.length;
|
|
59
60
|
if (length > 8) {
|
|
60
61
|
throw new Error("Given decimal in binary contains digits greater than an octet");
|
|
61
62
|
}
|
|
62
|
-
return exports.leftPadWithZeroBit(binaryString, 8);
|
|
63
|
+
return (0, exports.leftPadWithZeroBit)(binaryString, 8);
|
|
63
64
|
};
|
|
65
|
+
exports.decimalNumberToOctetString = decimalNumberToOctetString;
|
|
64
66
|
/**
|
|
65
67
|
* Parses number in binary to number in BigInt
|
|
66
68
|
*
|
|
67
69
|
* @param num binary number in string to parse
|
|
68
70
|
* @returns {number} binary number in BigInt
|
|
69
71
|
*/
|
|
70
|
-
|
|
72
|
+
let parseBinaryStringToBigInt = (num) => {
|
|
71
73
|
return BigInt(`0b${num}`);
|
|
72
74
|
};
|
|
75
|
+
exports.parseBinaryStringToBigInt = parseBinaryStringToBigInt;
|
|
73
76
|
/**
|
|
74
77
|
* Given an IPv4 number in dot-decimal notated string, e.g 192.168.0.1 converts it to
|
|
75
78
|
* binary string, e.g. '11000000101010000000000000000001'
|
|
@@ -77,33 +80,35 @@ var BinaryUtils = {};
|
|
|
77
80
|
* @param dottedDecimal IPv4 string in dot-decimal notation
|
|
78
81
|
* @returns {string} the binary value of the given ipv4 number in string
|
|
79
82
|
*/
|
|
80
|
-
|
|
83
|
+
let dottedDecimalNotationToBinaryString = (dottedDecimal) => {
|
|
81
84
|
let stringOctets = dottedDecimal.split(".");
|
|
82
85
|
return stringOctets.reduce((binaryAsString, octet) => {
|
|
83
|
-
return binaryAsString.concat(exports.decimalNumberToOctetString(parseInt(octet)));
|
|
86
|
+
return binaryAsString.concat((0, exports.decimalNumberToOctetString)(parseInt(octet)));
|
|
84
87
|
}, '');
|
|
85
88
|
};
|
|
89
|
+
exports.dottedDecimalNotationToBinaryString = dottedDecimalNotationToBinaryString;
|
|
86
90
|
/**
|
|
87
91
|
* Given a binary string, adds a number of zero to the left until string is as long as the given string length
|
|
88
92
|
* @param {string} binaryString the string to pad
|
|
89
93
|
* @param {number} finalStringLength the final length of string after padding
|
|
90
94
|
* @returns {string}
|
|
91
95
|
*/
|
|
92
|
-
|
|
96
|
+
let leftPadWithZeroBit = (binaryString, finalStringLength) => {
|
|
93
97
|
if (binaryString.length > finalStringLength) {
|
|
94
98
|
throw new Error(`Given string is already longer than given final length after padding: ${finalStringLength}`);
|
|
95
99
|
}
|
|
96
100
|
return "0".repeat(finalStringLength - binaryString.length).concat(binaryString);
|
|
97
101
|
};
|
|
102
|
+
exports.leftPadWithZeroBit = leftPadWithZeroBit;
|
|
98
103
|
/**
|
|
99
104
|
* Given the prefix portion of a cidr notation and the type of IP number, returns the mask in binary string
|
|
100
105
|
*
|
|
101
106
|
* @param {number} cidrPrefix the prefix part of a cidr notation
|
|
102
107
|
* @param {IPNumType.IPv4 | IPNumType.IPv6} ipType the type of the ip number in the range the cidr represents
|
|
103
108
|
*/
|
|
104
|
-
|
|
109
|
+
let cidrPrefixToMaskBinaryString = (cidrPrefix, ipType) => {
|
|
105
110
|
let cidrUpperValue;
|
|
106
|
-
if (ipType == "IPv4" /* IPv4 */) {
|
|
111
|
+
if (ipType == "IPv4" /* IPNumType.IPv4 */) {
|
|
107
112
|
cidrUpperValue = 32;
|
|
108
113
|
}
|
|
109
114
|
else {
|
|
@@ -115,6 +120,7 @@ var BinaryUtils = {};
|
|
|
115
120
|
let offBits = '0'.repeat(cidrUpperValue - cidrPrefix);
|
|
116
121
|
return `${onBits}${offBits}`;
|
|
117
122
|
};
|
|
123
|
+
exports.cidrPrefixToMaskBinaryString = cidrPrefixToMaskBinaryString;
|
|
118
124
|
/**
|
|
119
125
|
* Calculates the log, to base 2 of given number.
|
|
120
126
|
*
|
|
@@ -122,7 +128,7 @@ var BinaryUtils = {};
|
|
|
122
128
|
* @param givenNumber the number to calculate log base 2
|
|
123
129
|
* @return the log base 2 of given number
|
|
124
130
|
*/
|
|
125
|
-
|
|
131
|
+
let intLog2 = (givenNumber) => {
|
|
126
132
|
let result = 0;
|
|
127
133
|
while (givenNumber % 2n === 0n) {
|
|
128
134
|
if (givenNumber === 2n) {
|
|
@@ -141,12 +147,13 @@ var BinaryUtils = {};
|
|
|
141
147
|
}
|
|
142
148
|
return result;
|
|
143
149
|
};
|
|
150
|
+
exports.intLog2 = intLog2;
|
|
144
151
|
/**
|
|
145
152
|
* Starting from the most significant bit (from left) returns the number of first bits from both string that are equal
|
|
146
153
|
* @param firstBinaryString first binary string
|
|
147
154
|
* @param secondBinaryString second binary string
|
|
148
155
|
*/
|
|
149
|
-
|
|
156
|
+
let matchingBitCount = (firstBinaryString, secondBinaryString) => {
|
|
150
157
|
let longerString;
|
|
151
158
|
let otherString;
|
|
152
159
|
if (firstBinaryString.length >= secondBinaryString.length) {
|
|
@@ -166,6 +173,7 @@ var BinaryUtils = {};
|
|
|
166
173
|
}
|
|
167
174
|
return count;
|
|
168
175
|
};
|
|
176
|
+
exports.matchingBitCount = matchingBitCount;
|
|
169
177
|
|
|
170
178
|
} (BinaryUtils));
|
|
171
179
|
|
|
@@ -180,101 +188,158 @@ var hasRequiredIPv6Utils;
|
|
|
180
188
|
function requireIPv6Utils () {
|
|
181
189
|
if (hasRequiredIPv6Utils) return IPv6Utils;
|
|
182
190
|
hasRequiredIPv6Utils = 1;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
191
|
+
(function (exports) {
|
|
192
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
193
|
+
exports.collapseIPv6Number = exports.expandIPv6Number = void 0;
|
|
194
|
+
const BinaryUtils_1 = BinaryUtils;
|
|
195
|
+
const Validator_1 = requireValidator();
|
|
196
|
+
let extractPrefix = (ipv6String) => {
|
|
197
|
+
return ipv6String.includes("/") ? `/${ipv6String.split("/")[1]}` : "";
|
|
198
|
+
};
|
|
199
|
+
let expandIPv6Number = (ipv6String) => {
|
|
200
|
+
let expandWithZero = (hexadecimalArray) => {
|
|
201
|
+
let paddedArray = hexadecimalArray.map((hexadecimal) => {
|
|
202
|
+
return (0, BinaryUtils_1.leftPadWithZeroBit)(hexadecimal, 4);
|
|
203
|
+
});
|
|
204
|
+
return paddedArray.join(":");
|
|
205
|
+
};
|
|
206
|
+
let expandDoubleColon = (gapCount) => {
|
|
207
|
+
let pads = [];
|
|
208
|
+
for (let count = 0; count < gapCount; count++) {
|
|
209
|
+
pads.push("0000");
|
|
210
|
+
}
|
|
211
|
+
return pads.join(":");
|
|
212
|
+
};
|
|
213
|
+
if (/(:){3,}/.test(ipv6String))
|
|
214
|
+
throw "given IPv6 contains consecutive : more than two";
|
|
215
|
+
const prefix = extractPrefix(ipv6String);
|
|
216
|
+
if (ipv6String.includes("/")) {
|
|
217
|
+
ipv6String = ipv6String.split("/")[0];
|
|
218
|
+
}
|
|
219
|
+
let isValid = Validator_1.Validator.IPV6_PATTERN.test(ipv6String);
|
|
220
|
+
if (!isValid) {
|
|
221
|
+
throw Error(Validator_1.Validator.invalidIPv6PatternMessage);
|
|
222
|
+
}
|
|
223
|
+
if (ipv6String.includes("::")) {
|
|
224
|
+
let split = ipv6String.split("::");
|
|
225
|
+
let leftPortion = split[0];
|
|
226
|
+
let rightPortion = split[1];
|
|
227
|
+
let leftPortionSplit = leftPortion.split(":").filter(hexadecimal => { return hexadecimal !== ""; });
|
|
228
|
+
let rightPortionSplit = rightPortion.split(":").filter(hexadecimal => { return hexadecimal !== ""; });
|
|
229
|
+
let doublePortion = expandDoubleColon(8 - (leftPortionSplit.length + rightPortionSplit.length));
|
|
230
|
+
let leftString = expandWithZero(leftPortionSplit);
|
|
231
|
+
if (leftString !== "") {
|
|
232
|
+
leftString += ":";
|
|
233
|
+
}
|
|
234
|
+
let rightString = expandWithZero(rightPortionSplit);
|
|
235
|
+
if (rightString !== "") {
|
|
236
|
+
rightString = ":" + rightString;
|
|
237
|
+
}
|
|
238
|
+
return `${leftString}${doublePortion}${rightString}${prefix}`;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
return `${expandWithZero(ipv6String.split(":"))}${prefix}`;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
exports.expandIPv6Number = expandIPv6Number;
|
|
245
|
+
// Helper function to shorten hexadecatets
|
|
246
|
+
const shortenHexadecatet = (hex) => {
|
|
247
|
+
// Input hex is expected to be like "0000", "0DB8", "001A" from expanded form
|
|
248
|
+
const withoutLeadingZero = hex.replace(/^0+/, '');
|
|
249
|
+
// If hex was "0000", withoutLeadingZero is "", so return "0"
|
|
250
|
+
// Otherwise, return the string without leading zeros.
|
|
251
|
+
return withoutLeadingZero === '' ? '0' : withoutLeadingZero;
|
|
252
|
+
};
|
|
253
|
+
let collapseIPv6Number = (ipv6String) => {
|
|
254
|
+
const originalPrefix = extractPrefix(ipv6String);
|
|
255
|
+
const processedIPv6String = ipv6String.includes("/") ? ipv6String.split("/")[0] : ipv6String;
|
|
256
|
+
let expandedIPv6 = "";
|
|
257
|
+
try {
|
|
258
|
+
// Expand to full 8 segments, no prefix internally for processing
|
|
259
|
+
let tempExpanded = (0, exports.expandIPv6Number)(processedIPv6String);
|
|
260
|
+
if (tempExpanded.includes("/")) {
|
|
261
|
+
expandedIPv6 = tempExpanded.split("/")[0];
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
expandedIPv6 = tempExpanded;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (e) {
|
|
268
|
+
// Propagate error if expansion fails (e.g. invalid IPv6 format)
|
|
269
|
+
throw e;
|
|
270
|
+
}
|
|
271
|
+
let hexadecatets = expandedIPv6.split(":");
|
|
272
|
+
if (hexadecatets.length !== 8) {
|
|
273
|
+
// This case should ideally be prevented by expandIPv6Number's validation or structure.
|
|
274
|
+
// If expandIPv6Number guarantees 8 segments or throws, this might not be strictly needed.
|
|
275
|
+
// However, as a safeguard:
|
|
276
|
+
throw new Error(`Invalid IPv6 structure after expansion: ${expandedIPv6}. Expected 8 segments.`);
|
|
277
|
+
}
|
|
278
|
+
let zeroSequences = [];
|
|
279
|
+
let currentSequenceStart = -1;
|
|
280
|
+
let currentSequenceLength = 0;
|
|
281
|
+
for (let i = 0; i < 8; i++) {
|
|
282
|
+
// Segments from expandIPv6Number are 4-char 0-padded, e.g., "0000"
|
|
283
|
+
if (hexadecatets[i] === "0000") {
|
|
284
|
+
if (currentSequenceStart === -1) {
|
|
285
|
+
currentSequenceStart = i;
|
|
286
|
+
}
|
|
287
|
+
currentSequenceLength++;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
if (currentSequenceLength > 0) {
|
|
291
|
+
zeroSequences.push({ start: currentSequenceStart, length: currentSequenceLength });
|
|
292
|
+
}
|
|
293
|
+
currentSequenceStart = -1;
|
|
294
|
+
currentSequenceLength = 0;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (currentSequenceLength > 0) { // Capture any trailing zero sequence
|
|
298
|
+
zeroSequences.push({ start: currentSequenceStart, length: currentSequenceLength });
|
|
299
|
+
}
|
|
300
|
+
if (zeroSequences.length === 0) {
|
|
301
|
+
// No zero segments at all, just shorten each hexadecatet
|
|
302
|
+
return hexadecatets.map(shortenHexadecatet).join(":") + originalPrefix;
|
|
303
|
+
}
|
|
304
|
+
// Sort sequences: longest first, then earliest start first
|
|
305
|
+
zeroSequences.sort((a, b) => {
|
|
306
|
+
if (b.length !== a.length) {
|
|
307
|
+
return b.length - a.length;
|
|
308
|
+
}
|
|
309
|
+
return a.start - b.start;
|
|
310
|
+
});
|
|
311
|
+
const bestSequence = zeroSequences[0];
|
|
312
|
+
if (bestSequence.length === 8) { // All 8 segments are zero
|
|
313
|
+
return "::" + originalPrefix;
|
|
314
|
+
}
|
|
315
|
+
// RFC 5952: "The symbol "::" MUST NOT be used to shorten just one 16-bit 0 field."
|
|
316
|
+
// So, length must be > 1 for "::" compression.
|
|
317
|
+
if (bestSequence.length < 2) {
|
|
318
|
+
// No "::" compression is applied (e.g. "1:2:0:4:5:6:7:8")
|
|
319
|
+
return hexadecatets.map(shortenHexadecatet).join(":") + originalPrefix;
|
|
320
|
+
}
|
|
321
|
+
// Apply "::" compression using the bestSequence
|
|
322
|
+
let leftPartSegments = hexadecatets.slice(0, bestSequence.start);
|
|
323
|
+
let rightPartSegments = hexadecatets.slice(bestSequence.start + bestSequence.length);
|
|
324
|
+
let leftString = leftPartSegments.map(shortenHexadecatet).join(":");
|
|
325
|
+
let rightString = rightPartSegments.map(shortenHexadecatet).join(":");
|
|
326
|
+
let finalStr = "";
|
|
327
|
+
if (bestSequence.start === 0) { // Compression at the beginning: "::..."
|
|
328
|
+
finalStr = "::" + rightString;
|
|
329
|
+
}
|
|
330
|
+
else if (bestSequence.start + bestSequence.length === 8) { // Compression at the end: "...::"
|
|
331
|
+
// Ensure that if leftString is empty (which shouldn't happen here if start > 0), it's handled.
|
|
332
|
+
// However, if bestSequence.start > 0, leftPartSegments won't be empty unless bestSequence.start is 0.
|
|
333
|
+
finalStr = leftString + "::";
|
|
334
|
+
}
|
|
335
|
+
else { // Compression in the middle: "...::..."
|
|
336
|
+
finalStr = leftString + "::" + rightString;
|
|
337
|
+
}
|
|
338
|
+
return finalStr + originalPrefix;
|
|
339
|
+
};
|
|
340
|
+
exports.collapseIPv6Number = collapseIPv6Number;
|
|
341
|
+
|
|
342
|
+
} (IPv6Utils));
|
|
278
343
|
return IPv6Utils;
|
|
279
344
|
}
|
|
280
345
|
|
|
@@ -295,32 +360,35 @@ function requireHexadecimalUtils () {
|
|
|
295
360
|
* @param num the bigint number
|
|
296
361
|
* @returns {string} the hexadeciaml string
|
|
297
362
|
*/
|
|
298
|
-
|
|
363
|
+
let bigIntToHexadecimalString = (num) => {
|
|
299
364
|
return num.toString(16);
|
|
300
365
|
};
|
|
366
|
+
exports.bigIntToHexadecimalString = bigIntToHexadecimalString;
|
|
301
367
|
/**
|
|
302
368
|
* Converts a number in hexadecimal (base 16) to binary string
|
|
303
369
|
* @param {string} hexadecimalString the number in base 16
|
|
304
370
|
* @returns {string} the number converted to base 2
|
|
305
371
|
*/
|
|
306
|
-
|
|
372
|
+
let hexadecimalStringToBinaryString = (hexadecimalString) => {
|
|
307
373
|
let inDecimal = BigInt(`0x${hexadecimalString}`);
|
|
308
374
|
return inDecimal.toString(2);
|
|
309
375
|
};
|
|
376
|
+
exports.hexadecimalStringToBinaryString = hexadecimalStringToBinaryString;
|
|
310
377
|
/**
|
|
311
378
|
* Converts a number in hexadecimal (base 16) to binary hexadecatet string.
|
|
312
379
|
* This means the bits in the output cannot be more than 16
|
|
313
380
|
*
|
|
314
381
|
* @param hexadecimalString {string} the number converted to binary hexadecatet string
|
|
315
382
|
*/
|
|
316
|
-
|
|
317
|
-
let binaryString = exports.hexadecimalStringToBinaryString(hexadecimalString);
|
|
383
|
+
let hexadecimalStringToHexadecatetString = (hexadecimalString) => {
|
|
384
|
+
let binaryString = (0, exports.hexadecimalStringToBinaryString)(hexadecimalString);
|
|
318
385
|
let length = binaryString.length;
|
|
319
386
|
if (length > 16) {
|
|
320
387
|
throw new Error("Given decimal in binary contains digits greater than an Hexadecatet");
|
|
321
388
|
}
|
|
322
|
-
return BinaryUtils_1.leftPadWithZeroBit(binaryString, 16);
|
|
389
|
+
return (0, BinaryUtils_1.leftPadWithZeroBit)(binaryString, 16);
|
|
323
390
|
};
|
|
391
|
+
exports.hexadecimalStringToHexadecatetString = hexadecimalStringToHexadecatetString;
|
|
324
392
|
/**
|
|
325
393
|
* Given an IPv6 number in hexadecimal notated string, e.g 2001:0db8:0000:0000:0000:0000:0000:0000 converts it to
|
|
326
394
|
* binary string
|
|
@@ -328,35 +396,38 @@ function requireHexadecimalUtils () {
|
|
|
328
396
|
* @param hexadecimalString IPv6 string
|
|
329
397
|
* @returns {string} the binary value of the given ipv6 number in string
|
|
330
398
|
*/
|
|
331
|
-
|
|
332
|
-
let expandedIPv6 = IPv6Utils_1.expandIPv6Number(hexadecimalString);
|
|
399
|
+
let colonHexadecimalNotationToBinaryString = (hexadecimalString) => {
|
|
400
|
+
let expandedIPv6 = (0, IPv6Utils_1.expandIPv6Number)(hexadecimalString);
|
|
333
401
|
let stringHexadecimal = expandedIPv6.split(":");
|
|
334
402
|
return stringHexadecimal.reduce((binaryAsString, hexidecimal) => {
|
|
335
|
-
return binaryAsString.concat(exports.hexadecimalStringToHexadecatetString(hexidecimal));
|
|
403
|
+
return binaryAsString.concat((0, exports.hexadecimalStringToHexadecatetString)(hexidecimal));
|
|
336
404
|
}, '');
|
|
337
405
|
};
|
|
406
|
+
exports.colonHexadecimalNotationToBinaryString = colonHexadecimalNotationToBinaryString;
|
|
338
407
|
/**
|
|
339
408
|
* Converts number in binary string to hexadecimal string
|
|
340
409
|
* @param {string} num in binary string
|
|
341
410
|
* @returns {string} num in hexadecimal string
|
|
342
411
|
*/
|
|
343
|
-
|
|
412
|
+
let binaryStringToHexadecimalString = (num) => {
|
|
344
413
|
// first convert to binary string to decimal (big Integer)
|
|
345
414
|
let inDecimal = BigInt(`0b${num}`);
|
|
346
415
|
return inDecimal.toString(16);
|
|
347
416
|
};
|
|
417
|
+
exports.binaryStringToHexadecimalString = binaryStringToHexadecimalString;
|
|
348
418
|
/**
|
|
349
419
|
* Converts a given IPv6 number expressed in the hexadecimal string notation into a 16 bit binary number in string
|
|
350
420
|
* @param {string} hexadectetString the IPv6 number
|
|
351
421
|
* @returns {string} the IPv6 number converted to binary string
|
|
352
422
|
*/
|
|
353
|
-
|
|
354
|
-
let expand = IPv6Utils_1.expandIPv6Number(hexadectetString);
|
|
423
|
+
let hexadectetNotationToBinaryString = (hexadectetString) => {
|
|
424
|
+
let expand = (0, IPv6Utils_1.expandIPv6Number)(hexadectetString);
|
|
355
425
|
let hexadecimals = expand.split(":");
|
|
356
426
|
return hexadecimals.reduce((hexadecimalAsString, hexavalue) => {
|
|
357
|
-
return hexadecimalAsString.concat(BinaryUtils_1.leftPadWithZeroBit(exports.hexadecimalStringToBinaryString(hexavalue), 16));
|
|
427
|
+
return hexadecimalAsString.concat((0, BinaryUtils_1.leftPadWithZeroBit)((0, exports.hexadecimalStringToBinaryString)(hexavalue), 16));
|
|
358
428
|
}, '');
|
|
359
429
|
};
|
|
430
|
+
exports.hexadectetNotationToBinaryString = hexadectetNotationToBinaryString;
|
|
360
431
|
|
|
361
432
|
} (HexadecimalUtils));
|
|
362
433
|
return HexadecimalUtils;
|
|
@@ -482,7 +553,7 @@ function requireValidator () {
|
|
|
482
553
|
*/
|
|
483
554
|
static isValidIPv6String(ipv6String) {
|
|
484
555
|
try {
|
|
485
|
-
let hexadecimals = IPv6Utils_1.expandIPv6Number(ipv6String).split(":");
|
|
556
|
+
let hexadecimals = (0, IPv6Utils_1.expandIPv6Number)(ipv6String).split(":");
|
|
486
557
|
if (hexadecimals.length != 8) {
|
|
487
558
|
return [false, [Validator.invalidHexadecatetCountMessage]];
|
|
488
559
|
}
|
|
@@ -497,7 +568,7 @@ function requireValidator () {
|
|
|
497
568
|
return [isValid, isValid ? [] : [Validator.invalidIPv6PatternMessage]];
|
|
498
569
|
}
|
|
499
570
|
catch (error) {
|
|
500
|
-
return [false, [error]];
|
|
571
|
+
return [false, [String(error)]];
|
|
501
572
|
}
|
|
502
573
|
}
|
|
503
574
|
/**
|
|
@@ -508,11 +579,11 @@ function requireValidator () {
|
|
|
508
579
|
* @returns {(boolean|string)[]} a tuple representing if valid or not and corresponding message
|
|
509
580
|
*/
|
|
510
581
|
static isValidPrefixValue(prefixValue, ipNumType) {
|
|
511
|
-
if ("IPv4" /* IPv4 */ === ipNumType) {
|
|
582
|
+
if ("IPv4" /* IPNumType.IPv4 */ === ipNumType) {
|
|
512
583
|
let withinRange = Validator.isWithinRange(BigInt(prefixValue), 0n, 32n);
|
|
513
584
|
return [withinRange, withinRange ? [] : [Validator.invalidPrefixValueMessage]];
|
|
514
585
|
}
|
|
515
|
-
if ("IPv6" /* IPv6 */ === ipNumType) {
|
|
586
|
+
if ("IPv6" /* IPNumType.IPv6 */ === ipNumType) {
|
|
516
587
|
let withinRange = Validator.isWithinRange(BigInt(prefixValue), 0n, 128n);
|
|
517
588
|
return [withinRange, withinRange ? [] : [Validator.invalidPrefixValueMessage]];
|
|
518
589
|
}
|
|
@@ -526,7 +597,7 @@ function requireValidator () {
|
|
|
526
597
|
* contains "valid" or an error message when value is invalid
|
|
527
598
|
*/
|
|
528
599
|
static isValidIPv4Mask(ipv4MaskString) {
|
|
529
|
-
let ipv4InBinary = BinaryUtils_1.dottedDecimalNotationToBinaryString(ipv4MaskString);
|
|
600
|
+
let ipv4InBinary = (0, BinaryUtils_1.dottedDecimalNotationToBinaryString)(ipv4MaskString);
|
|
530
601
|
let isValid = Validator.IPV4_CONTIGUOUS_MASK_BIT_PATTERN.test(ipv4InBinary);
|
|
531
602
|
return isValid ? [isValid, []] : [isValid, [Validator.invalidMaskMessage]];
|
|
532
603
|
}
|
|
@@ -538,7 +609,7 @@ function requireValidator () {
|
|
|
538
609
|
* contains "valid" or an error message when value is invalid
|
|
539
610
|
*/
|
|
540
611
|
static isValidIPv6Mask(ipv6MaskString) {
|
|
541
|
-
let ipv6InBinary = HexadecimalUtils_2.hexadectetNotationToBinaryString(ipv6MaskString);
|
|
612
|
+
let ipv6InBinary = (0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(ipv6MaskString);
|
|
542
613
|
let isValid = Validator.IPV6_CONTIGUOUS_MASK_BIT_PATTERN.test(ipv6InBinary);
|
|
543
614
|
return isValid ? [isValid, []] : [isValid, [Validator.invalidMaskMessage]];
|
|
544
615
|
}
|
|
@@ -557,11 +628,14 @@ function requireValidator () {
|
|
|
557
628
|
}
|
|
558
629
|
let ip = cidrComponents[0];
|
|
559
630
|
let range = cidrComponents[1];
|
|
631
|
+
if (!/^\d+$/.test(range)) {
|
|
632
|
+
return [false, [Validator.invalidIPv4CidrNotationMessage]];
|
|
633
|
+
}
|
|
560
634
|
if (isNaN(Number(range))) {
|
|
561
635
|
return [false, [Validator.invalidIPv4CidrNotationMessage]];
|
|
562
636
|
}
|
|
563
637
|
let [validIpv4, invalidIpv4Message] = Validator.isValidIPv4String(ip);
|
|
564
|
-
let [validPrefix, invalidPrefixMessage] = Validator.isValidPrefixValue(BigInt(range), "IPv4" /* IPv4 */);
|
|
638
|
+
let [validPrefix, invalidPrefixMessage] = Validator.isValidPrefixValue(BigInt(range), "IPv4" /* IPNumType.IPv4 */);
|
|
565
639
|
let isValid = validIpv4 && validPrefix;
|
|
566
640
|
let invalidMessage = invalidIpv4Message.concat(invalidPrefixMessage);
|
|
567
641
|
return isValid ? [isValid, []] : [isValid, invalidMessage];
|
|
@@ -576,7 +650,7 @@ function requireValidator () {
|
|
|
576
650
|
* value contains [] or an array of error message when invalid
|
|
577
651
|
*/
|
|
578
652
|
static isValidIPv4CidrRange(ipv4CidrNotation) {
|
|
579
|
-
return Validator.isValidCidrRange(ipv4CidrNotation, Validator.isValidIPv4CidrNotation, BinaryUtils_1.dottedDecimalNotationToBinaryString, (value) => BinaryUtils_2.cidrPrefixToMaskBinaryString(value, "IPv4" /* IPv4 */));
|
|
653
|
+
return Validator.isValidCidrRange(ipv4CidrNotation, Validator.isValidIPv4CidrNotation, BinaryUtils_1.dottedDecimalNotationToBinaryString, (value) => (0, BinaryUtils_2.cidrPrefixToMaskBinaryString)(value, "IPv4" /* IPNumType.IPv4 */));
|
|
580
654
|
}
|
|
581
655
|
/**
|
|
582
656
|
* Checks if the given string is a valid IPv6 range in Cidr notation, with the ip number in the cidr notation
|
|
@@ -588,7 +662,7 @@ function requireValidator () {
|
|
|
588
662
|
* value contains [] or an array of error message when invalid
|
|
589
663
|
*/
|
|
590
664
|
static isValidIPv6CidrRange(ipv6CidrNotation) {
|
|
591
|
-
return Validator.isValidCidrRange(ipv6CidrNotation, Validator.isValidIPv6CidrNotation, HexadecimalUtils_1.colonHexadecimalNotationToBinaryString, (value) => BinaryUtils_2.cidrPrefixToMaskBinaryString(value, "IPv6" /* IPv6 */));
|
|
665
|
+
return Validator.isValidCidrRange(ipv6CidrNotation, Validator.isValidIPv6CidrNotation, HexadecimalUtils_1.colonHexadecimalNotationToBinaryString, (value) => (0, BinaryUtils_2.cidrPrefixToMaskBinaryString)(value, "IPv6" /* IPNumType.IPv6 */));
|
|
592
666
|
}
|
|
593
667
|
static isValidCidrRange(rangeString, cidrNotationValidator, toBinaryStringConverter, prefixFactory) {
|
|
594
668
|
let validationResult = cidrNotationValidator(rangeString);
|
|
@@ -604,13 +678,13 @@ function requireValidator () {
|
|
|
604
678
|
return isValid ? [isValid, []] : [isValid, [Validator.InvalidIPCidrRangeMessage]];
|
|
605
679
|
}
|
|
606
680
|
static isValidIPv4RangeString(ipv4RangeString) {
|
|
607
|
-
let firstLastValidator = (firstIP, lastIP) => BigInt(`0b${BinaryUtils_1.dottedDecimalNotationToBinaryString(firstIP)}`)
|
|
608
|
-
>= BigInt(`0b${BinaryUtils_1.dottedDecimalNotationToBinaryString(lastIP)}`);
|
|
681
|
+
let firstLastValidator = (firstIP, lastIP) => BigInt(`0b${(0, BinaryUtils_1.dottedDecimalNotationToBinaryString)(firstIP)}`)
|
|
682
|
+
>= BigInt(`0b${(0, BinaryUtils_1.dottedDecimalNotationToBinaryString)(lastIP)}`);
|
|
609
683
|
return this.isValidRange(ipv4RangeString, Validator.isValidIPv4String, firstLastValidator);
|
|
610
684
|
}
|
|
611
685
|
static isValidIPv6RangeString(ipv6RangeString) {
|
|
612
|
-
let firstLastValidator = (firstIP, lastIP) => BigInt(`0b${HexadecimalUtils_2.hexadectetNotationToBinaryString(firstIP)}`)
|
|
613
|
-
>= BigInt(`0b${HexadecimalUtils_2.hexadectetNotationToBinaryString(lastIP)}`);
|
|
686
|
+
let firstLastValidator = (firstIP, lastIP) => BigInt(`0b${(0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(firstIP)}`)
|
|
687
|
+
>= BigInt(`0b${(0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(lastIP)}`);
|
|
614
688
|
return this.isValidRange(ipv6RangeString, Validator.isValidIPv6String, firstLastValidator);
|
|
615
689
|
}
|
|
616
690
|
static isValidRange(rangeString, validator, firstLastValidator) {
|
|
@@ -716,27 +790,6 @@ const Validator_1$4 = requireValidator();
|
|
|
716
790
|
* It is used to represents the components of an IPv6 address
|
|
717
791
|
*/
|
|
718
792
|
class Hexadecatet {
|
|
719
|
-
/**
|
|
720
|
-
* Constructor for creating an instance of {@link Hexadecatet}
|
|
721
|
-
*
|
|
722
|
-
* @param {string | number} givenValue a string or numeric value. If given value is a string then it should be a
|
|
723
|
-
* four (base 16) number representation of a 16bit value. If it is a number, then it should be a decimal number
|
|
724
|
-
* representation of a 16 bit value
|
|
725
|
-
*/
|
|
726
|
-
constructor(givenValue) {
|
|
727
|
-
let hexadecatetValue;
|
|
728
|
-
if (typeof givenValue === 'string') {
|
|
729
|
-
hexadecatetValue = parseInt(givenValue, 16);
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
hexadecatetValue = parseInt(String(givenValue), 16);
|
|
733
|
-
}
|
|
734
|
-
let [isValid, message] = Validator_1$4.Validator.isValidIPv6Hexadecatet(BigInt(hexadecatetValue));
|
|
735
|
-
if (!isValid) {
|
|
736
|
-
throw Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
737
|
-
}
|
|
738
|
-
this.value = hexadecatetValue;
|
|
739
|
-
}
|
|
740
793
|
/**
|
|
741
794
|
* A convenience method for constructing an instance of {@link Hexadecatet} from a four (base 16) number
|
|
742
795
|
* representation of a 16bit value.
|
|
@@ -759,6 +812,27 @@ class Hexadecatet {
|
|
|
759
812
|
return new Hexadecatet(rawValue);
|
|
760
813
|
}
|
|
761
814
|
;
|
|
815
|
+
/**
|
|
816
|
+
* Constructor for creating an instance of {@link Hexadecatet}
|
|
817
|
+
*
|
|
818
|
+
* @param {string | number} givenValue a string or numeric value. If given value is a string then it should be a
|
|
819
|
+
* four (base 16) number representation of a 16bit value. If it is a number, then it should be a decimal number
|
|
820
|
+
* representation of a 16 bit value
|
|
821
|
+
*/
|
|
822
|
+
constructor(givenValue) {
|
|
823
|
+
let hexadecatetValue;
|
|
824
|
+
if (typeof givenValue === 'string') {
|
|
825
|
+
hexadecatetValue = parseInt(givenValue, 16);
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
hexadecatetValue = parseInt(String(givenValue), 16);
|
|
829
|
+
}
|
|
830
|
+
let [isValid, message] = Validator_1$4.Validator.isValidIPv6Hexadecatet(BigInt(hexadecatetValue));
|
|
831
|
+
if (!isValid) {
|
|
832
|
+
throw Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
833
|
+
}
|
|
834
|
+
this.value = hexadecatetValue;
|
|
835
|
+
}
|
|
762
836
|
/**
|
|
763
837
|
* Returns the numeric value in base 10 (ie decimal)
|
|
764
838
|
*
|
|
@@ -794,6 +868,26 @@ const Validator_1$3 = requireValidator();
|
|
|
794
868
|
* into 4 octets
|
|
795
869
|
*/
|
|
796
870
|
class Octet {
|
|
871
|
+
/**
|
|
872
|
+
* Convenience method for creating an Octet out of a string value representing the value of the octet
|
|
873
|
+
*
|
|
874
|
+
* @param {string} rawValue the octet value in string
|
|
875
|
+
* @returns {Octet} the Octet instance
|
|
876
|
+
*/
|
|
877
|
+
static fromString(rawValue) {
|
|
878
|
+
return new Octet(rawValue);
|
|
879
|
+
}
|
|
880
|
+
;
|
|
881
|
+
/**
|
|
882
|
+
* Convenience method for creating an Octet out of a numeric value representing the value of the octet
|
|
883
|
+
*
|
|
884
|
+
* @param {number} rawValue the octet value in number
|
|
885
|
+
* @returns {Octet} the Octet instance
|
|
886
|
+
*/
|
|
887
|
+
static fromNumber(rawValue) {
|
|
888
|
+
return new Octet(rawValue);
|
|
889
|
+
}
|
|
890
|
+
;
|
|
797
891
|
/**
|
|
798
892
|
* Constructor for creating an instance of an Octet.
|
|
799
893
|
*
|
|
@@ -818,26 +912,6 @@ class Octet {
|
|
|
818
912
|
}
|
|
819
913
|
this.value = octetValue;
|
|
820
914
|
}
|
|
821
|
-
/**
|
|
822
|
-
* Convenience method for creating an Octet out of a string value representing the value of the octet
|
|
823
|
-
*
|
|
824
|
-
* @param {string} rawValue the octet value in string
|
|
825
|
-
* @returns {Octet} the Octet instance
|
|
826
|
-
*/
|
|
827
|
-
static fromString(rawValue) {
|
|
828
|
-
return new Octet(rawValue);
|
|
829
|
-
}
|
|
830
|
-
;
|
|
831
|
-
/**
|
|
832
|
-
* Convenience method for creating an Octet out of a numeric value representing the value of the octet
|
|
833
|
-
*
|
|
834
|
-
* @param {number} rawValue the octet value in number
|
|
835
|
-
* @returns {Octet} the Octet instance
|
|
836
|
-
*/
|
|
837
|
-
static fromNumber(rawValue) {
|
|
838
|
-
return new Octet(rawValue);
|
|
839
|
-
}
|
|
840
|
-
;
|
|
841
915
|
/**
|
|
842
916
|
* Method to get the numeric value of the octet
|
|
843
917
|
*
|
|
@@ -858,7 +932,8 @@ class Octet {
|
|
|
858
932
|
Octet$1.Octet = Octet;
|
|
859
933
|
|
|
860
934
|
Object.defineProperty(IPNumber, "__esModule", { value: true });
|
|
861
|
-
IPNumber.
|
|
935
|
+
IPNumber.IPv6Mask = IPNumber.IPv4Mask = IPNumber.IPv6 = IPNumber.Asn = IPNumber.IPv4 = IPNumber.AbstractIPNum = void 0;
|
|
936
|
+
IPNumber.isIPv4 = isIPv4;
|
|
862
937
|
const Octet_1 = Octet$1;
|
|
863
938
|
const Validator_1$2 = requireValidator();
|
|
864
939
|
const BinaryUtils_1$2 = BinaryUtils;
|
|
@@ -888,7 +963,7 @@ class AbstractIPNum {
|
|
|
888
963
|
* @returns {string} the string binary representation.
|
|
889
964
|
*/
|
|
890
965
|
toBinaryString() {
|
|
891
|
-
return BinaryUtils_3.leftPadWithZeroBit(this.value.toString(2), this.bitSize);
|
|
966
|
+
return (0, BinaryUtils_3.leftPadWithZeroBit)(this.value.toString(2), this.bitSize);
|
|
892
967
|
}
|
|
893
968
|
/**
|
|
894
969
|
* Checks if an IP number has a value greater than the present value
|
|
@@ -960,50 +1035,6 @@ IPNumber.AbstractIPNum = AbstractIPNum;
|
|
|
960
1035
|
* @see https://www.rfc-editor.org/info/rfc791
|
|
961
1036
|
*/
|
|
962
1037
|
class IPv4 extends AbstractIPNum {
|
|
963
|
-
/**
|
|
964
|
-
* Constructor for an IPv4 number.
|
|
965
|
-
*
|
|
966
|
-
* @param {string | bigint} ipValue value to construct an IPv4 from. The given value can either be
|
|
967
|
-
* numeric or string. If a string is given then it needs to be in dot-decimal notation
|
|
968
|
-
*/
|
|
969
|
-
constructor(ipValue) {
|
|
970
|
-
super();
|
|
971
|
-
/**
|
|
972
|
-
* The number of bits needed to represents the value of the IPv4 number
|
|
973
|
-
*/
|
|
974
|
-
this.bitSize = 32;
|
|
975
|
-
/**
|
|
976
|
-
* The maximum bit size (i.e. binary value) of the IPv4 number in BigInt
|
|
977
|
-
*/
|
|
978
|
-
this.maximumBitSize = Validator_1$2.Validator.THIRTY_TWO_BIT_SIZE;
|
|
979
|
-
/**
|
|
980
|
-
* The type of IP number. Value is one of the values of the {@link IPNumType} enum
|
|
981
|
-
* @type {IPNumType} the type of IP number
|
|
982
|
-
*/
|
|
983
|
-
this.type = "IPv4" /* IPv4 */;
|
|
984
|
-
/**
|
|
985
|
-
* An array of {@link Octet}'s
|
|
986
|
-
*
|
|
987
|
-
* @type {Array} the octets that makes up the IPv4 number
|
|
988
|
-
*/
|
|
989
|
-
this.octets = [];
|
|
990
|
-
/**
|
|
991
|
-
* The string character used to separate the individual octets when the IPv4 is rendered as strings
|
|
992
|
-
*
|
|
993
|
-
* @type {string} The string character used to separate the individual octets when rendered as strings
|
|
994
|
-
*/
|
|
995
|
-
this.separator = ".";
|
|
996
|
-
if (typeof ipValue === "string") {
|
|
997
|
-
let [value, octets] = this.constructFromDecimalDottedString(ipValue);
|
|
998
|
-
this.value = value;
|
|
999
|
-
this.octets = octets;
|
|
1000
|
-
}
|
|
1001
|
-
else {
|
|
1002
|
-
let [value, octets] = this.constructFromBigIntValue(ipValue);
|
|
1003
|
-
this.value = value;
|
|
1004
|
-
this.octets = octets;
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
1038
|
/**
|
|
1008
1039
|
* A convenience method for creating an {@link IPv4} by providing the decimal value of the IP number in BigInt
|
|
1009
1040
|
*
|
|
@@ -1043,12 +1074,56 @@ class IPv4 extends AbstractIPNum {
|
|
|
1043
1074
|
static fromBinaryString(ipBinaryString) {
|
|
1044
1075
|
let validationResult = Validator_1$2.Validator.isValidBinaryString(ipBinaryString);
|
|
1045
1076
|
if (validationResult[0]) {
|
|
1046
|
-
return new IPv4(BinaryUtils_2.parseBinaryStringToBigInt(ipBinaryString));
|
|
1077
|
+
return new IPv4((0, BinaryUtils_2.parseBinaryStringToBigInt)(ipBinaryString));
|
|
1047
1078
|
}
|
|
1048
1079
|
else {
|
|
1049
1080
|
throw Error(validationResult[1].join(','));
|
|
1050
1081
|
}
|
|
1051
1082
|
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Constructor for an IPv4 number.
|
|
1085
|
+
*
|
|
1086
|
+
* @param {string | bigint} ipValue value to construct an IPv4 from. The given value can either be
|
|
1087
|
+
* numeric or string. If a string is given then it needs to be in dot-decimal notation
|
|
1088
|
+
*/
|
|
1089
|
+
constructor(ipValue) {
|
|
1090
|
+
super();
|
|
1091
|
+
/**
|
|
1092
|
+
* The number of bits needed to represents the value of the IPv4 number
|
|
1093
|
+
*/
|
|
1094
|
+
this.bitSize = 32;
|
|
1095
|
+
/**
|
|
1096
|
+
* The maximum bit size (i.e. binary value) of the IPv4 number in BigInt
|
|
1097
|
+
*/
|
|
1098
|
+
this.maximumBitSize = Validator_1$2.Validator.THIRTY_TWO_BIT_SIZE;
|
|
1099
|
+
/**
|
|
1100
|
+
* The type of IP number. Value is one of the values of the {@link IPNumType} enum
|
|
1101
|
+
* @type {IPNumType} the type of IP number
|
|
1102
|
+
*/
|
|
1103
|
+
this.type = "IPv4" /* IPNumType.IPv4 */;
|
|
1104
|
+
/**
|
|
1105
|
+
* An array of {@link Octet}'s
|
|
1106
|
+
*
|
|
1107
|
+
* @type {Array} the octets that makes up the IPv4 number
|
|
1108
|
+
*/
|
|
1109
|
+
this.octets = [];
|
|
1110
|
+
/**
|
|
1111
|
+
* The string character used to separate the individual octets when the IPv4 is rendered as strings
|
|
1112
|
+
*
|
|
1113
|
+
* @type {string} The string character used to separate the individual octets when rendered as strings
|
|
1114
|
+
*/
|
|
1115
|
+
this.separator = ".";
|
|
1116
|
+
if (typeof ipValue === "string") {
|
|
1117
|
+
let [value, octets] = this.constructFromDecimalDottedString(ipValue);
|
|
1118
|
+
this.value = value;
|
|
1119
|
+
this.octets = octets;
|
|
1120
|
+
}
|
|
1121
|
+
else {
|
|
1122
|
+
let [value, octets] = this.constructFromBigIntValue(ipValue);
|
|
1123
|
+
this.value = value;
|
|
1124
|
+
this.octets = octets;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1052
1127
|
/**
|
|
1053
1128
|
* A string representation of the IPv4 number. The string representation is in dot-decimal notation
|
|
1054
1129
|
*
|
|
@@ -1105,7 +1180,7 @@ class IPv4 extends AbstractIPNum {
|
|
|
1105
1180
|
octets = stringOctets.map((rawOctet) => {
|
|
1106
1181
|
return Octet_1.Octet.fromString(rawOctet);
|
|
1107
1182
|
});
|
|
1108
|
-
value = BigInt(`0b${BinaryUtils_1$2.dottedDecimalNotationToBinaryString(ipString)}`);
|
|
1183
|
+
value = BigInt(`0b${(0, BinaryUtils_1$2.dottedDecimalNotationToBinaryString)(ipString)}`);
|
|
1109
1184
|
return [value, octets];
|
|
1110
1185
|
}
|
|
1111
1186
|
constructFromBigIntValue(ipv4Number) {
|
|
@@ -1113,17 +1188,17 @@ class IPv4 extends AbstractIPNum {
|
|
|
1113
1188
|
if (!isValid) {
|
|
1114
1189
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1115
1190
|
}
|
|
1116
|
-
let binaryString = BinaryUtils_4.numberToBinaryString(ipv4Number);
|
|
1191
|
+
let binaryString = (0, BinaryUtils_4.numberToBinaryString)(ipv4Number);
|
|
1117
1192
|
ipv4Number = typeof ipv4Number === "bigint" ? ipv4Number : BigInt(ipv4Number);
|
|
1118
1193
|
return [ipv4Number, this.binaryStringToDecimalOctets(binaryString)];
|
|
1119
1194
|
}
|
|
1120
1195
|
binaryStringToDecimalOctets(ipv4BinaryString) {
|
|
1121
1196
|
if (ipv4BinaryString.length < 32) {
|
|
1122
|
-
ipv4BinaryString = BinaryUtils_3.leftPadWithZeroBit(ipv4BinaryString, 32);
|
|
1197
|
+
ipv4BinaryString = (0, BinaryUtils_3.leftPadWithZeroBit)(ipv4BinaryString, 32);
|
|
1123
1198
|
}
|
|
1124
1199
|
let octets = ipv4BinaryString.match(/.{1,8}/g);
|
|
1125
1200
|
return octets.map((octet) => {
|
|
1126
|
-
return Octet_1.Octet.fromString(BinaryUtils_2.parseBinaryStringToBigInt(octet).toString());
|
|
1201
|
+
return Octet_1.Octet.fromString((0, BinaryUtils_2.parseBinaryStringToBigInt)(octet).toString());
|
|
1127
1202
|
});
|
|
1128
1203
|
}
|
|
1129
1204
|
}
|
|
@@ -1136,43 +1211,6 @@ IPNumber.IPv4 = IPv4;
|
|
|
1136
1211
|
* @see https://tools.ietf.org/html/rfc5396
|
|
1137
1212
|
*/
|
|
1138
1213
|
class Asn extends AbstractIPNum {
|
|
1139
|
-
/**
|
|
1140
|
-
* Constructor for an instance of {@link ASN}
|
|
1141
|
-
*
|
|
1142
|
-
* @param {string | number} rawValue value to construct an ASN from. The given value can either be numeric or
|
|
1143
|
-
* string. If in string then it can be in asplain, asdot or asdot+ string representation format
|
|
1144
|
-
*/
|
|
1145
|
-
constructor(rawValue) {
|
|
1146
|
-
super();
|
|
1147
|
-
/**
|
|
1148
|
-
* The number of bits needed to represents the value of the ASN number
|
|
1149
|
-
*/
|
|
1150
|
-
this.bitSize = 32;
|
|
1151
|
-
/**
|
|
1152
|
-
* The maximum bit size (i.e. binary value) of the ASN number in BigInt
|
|
1153
|
-
*/
|
|
1154
|
-
this.maximumBitSize = Validator_1$2.Validator.THIRTY_TWO_BIT_SIZE;
|
|
1155
|
-
this.type = "ASN" /* ASN */;
|
|
1156
|
-
if (typeof rawValue === 'string') {
|
|
1157
|
-
if (Asn.startWithASPrefix(rawValue)) {
|
|
1158
|
-
this.value = BigInt(parseInt(rawValue.substring(2)));
|
|
1159
|
-
}
|
|
1160
|
-
else if (rawValue.indexOf(".") != -1) {
|
|
1161
|
-
this.value = BigInt(this.parseFromDotNotation(rawValue));
|
|
1162
|
-
}
|
|
1163
|
-
else {
|
|
1164
|
-
this.value = BigInt(parseInt(rawValue));
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
else {
|
|
1168
|
-
let valueAsBigInt = BigInt(rawValue);
|
|
1169
|
-
let [isValid, message] = Validator_1$2.Validator.isValidAsnNumber(valueAsBigInt);
|
|
1170
|
-
if (!isValid) {
|
|
1171
|
-
throw Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1172
|
-
}
|
|
1173
|
-
this.value = valueAsBigInt;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
1214
|
/**
|
|
1177
1215
|
* A convenience method for creating an instance of {@link Asn} from a string
|
|
1178
1216
|
*
|
|
@@ -1212,6 +1250,43 @@ class Asn extends AbstractIPNum {
|
|
|
1212
1250
|
throw Error(validationResult[1].join(','));
|
|
1213
1251
|
}
|
|
1214
1252
|
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Constructor for an instance of {@link ASN}
|
|
1255
|
+
*
|
|
1256
|
+
* @param {string | number} rawValue value to construct an ASN from. The given value can either be numeric or
|
|
1257
|
+
* string. If in string then it can be in asplain, asdot or asdot+ string representation format
|
|
1258
|
+
*/
|
|
1259
|
+
constructor(rawValue) {
|
|
1260
|
+
super();
|
|
1261
|
+
/**
|
|
1262
|
+
* The number of bits needed to represents the value of the ASN number
|
|
1263
|
+
*/
|
|
1264
|
+
this.bitSize = 32;
|
|
1265
|
+
/**
|
|
1266
|
+
* The maximum bit size (i.e. binary value) of the ASN number in BigInt
|
|
1267
|
+
*/
|
|
1268
|
+
this.maximumBitSize = Validator_1$2.Validator.THIRTY_TWO_BIT_SIZE;
|
|
1269
|
+
this.type = "ASN" /* IPNumType.ASN */;
|
|
1270
|
+
if (typeof rawValue === 'string') {
|
|
1271
|
+
if (Asn.startWithASPrefix(rawValue)) {
|
|
1272
|
+
this.value = BigInt(parseInt(rawValue.substring(2)));
|
|
1273
|
+
}
|
|
1274
|
+
else if (rawValue.indexOf(".") != -1) {
|
|
1275
|
+
this.value = BigInt(this.parseFromDotNotation(rawValue));
|
|
1276
|
+
}
|
|
1277
|
+
else {
|
|
1278
|
+
this.value = BigInt(parseInt(rawValue));
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
else {
|
|
1282
|
+
let valueAsBigInt = BigInt(rawValue);
|
|
1283
|
+
let [isValid, message] = Validator_1$2.Validator.isValidAsnNumber(valueAsBigInt);
|
|
1284
|
+
if (!isValid) {
|
|
1285
|
+
throw Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1286
|
+
}
|
|
1287
|
+
this.value = valueAsBigInt;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1215
1290
|
/**
|
|
1216
1291
|
* A string representation where the asn value is prefixed by "ASN". For example "AS65526"
|
|
1217
1292
|
*
|
|
@@ -1262,7 +1337,7 @@ class Asn extends AbstractIPNum {
|
|
|
1262
1337
|
* @returns {string} a binary string representation of the value of the ASN number
|
|
1263
1338
|
*/
|
|
1264
1339
|
toBinaryString() {
|
|
1265
|
-
return BinaryUtils_4.numberToBinaryString(this.value);
|
|
1340
|
+
return (0, BinaryUtils_4.numberToBinaryString)(this.value);
|
|
1266
1341
|
}
|
|
1267
1342
|
/**
|
|
1268
1343
|
* Checks if the ASN value is 16bit
|
|
@@ -1317,51 +1392,6 @@ Asn.AS_PREFIX = "AS";
|
|
|
1317
1392
|
* @see https://www.rfc-editor.org/info/rfc8200
|
|
1318
1393
|
*/
|
|
1319
1394
|
class IPv6 extends AbstractIPNum {
|
|
1320
|
-
/**
|
|
1321
|
-
* Constructor for an IPv6 number.
|
|
1322
|
-
*
|
|
1323
|
-
* @param {string | bigint} ipValue value to construct an IPv6 from. The given value can either be
|
|
1324
|
-
* numeric or string. If a string is given then it needs to be in hexadecatet string notation
|
|
1325
|
-
*/
|
|
1326
|
-
constructor(ipValue) {
|
|
1327
|
-
super();
|
|
1328
|
-
/**
|
|
1329
|
-
* The number of bits needed to represents the value of the IPv6 number
|
|
1330
|
-
*/
|
|
1331
|
-
this.bitSize = 128;
|
|
1332
|
-
/**
|
|
1333
|
-
* The maximum bit size (i.e. binary value) of the IPv6 number in BigInt
|
|
1334
|
-
*/
|
|
1335
|
-
this.maximumBitSize = Validator_1$2.Validator.ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_SIZE;
|
|
1336
|
-
/**
|
|
1337
|
-
* The type of IP number. Value is one of the values of the {@link IPNumType} enum
|
|
1338
|
-
* @type {IPNumType} the type of IP number
|
|
1339
|
-
*/
|
|
1340
|
-
this.type = "IPv6" /* IPv6 */;
|
|
1341
|
-
/**
|
|
1342
|
-
* An array of {@link Hexadecatet}'s
|
|
1343
|
-
*
|
|
1344
|
-
* @type {Array} the hexadecatet that makes up the IPv6 number
|
|
1345
|
-
*/
|
|
1346
|
-
this.hexadecatet = [];
|
|
1347
|
-
/**
|
|
1348
|
-
* The string character used to separate the individual hexadecatet when the IPv6 is rendered as strings
|
|
1349
|
-
*
|
|
1350
|
-
* @type {string} The string character used to separate the individual hexadecatet when rendered as strings
|
|
1351
|
-
*/
|
|
1352
|
-
this.separator = ":";
|
|
1353
|
-
if (typeof ipValue === "string") {
|
|
1354
|
-
let expandedIPv6 = IPv6Utils_1.expandIPv6Number(ipValue);
|
|
1355
|
-
let [value, hexadecatet] = this.constructFromHexadecimalDottedString(expandedIPv6);
|
|
1356
|
-
this.value = value;
|
|
1357
|
-
this.hexadecatet = hexadecatet;
|
|
1358
|
-
}
|
|
1359
|
-
else {
|
|
1360
|
-
let [value, hexadecatet] = this.constructFromBigIntValue(ipValue);
|
|
1361
|
-
this.value = value;
|
|
1362
|
-
this.hexadecatet = hexadecatet;
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
1395
|
/**
|
|
1366
1396
|
* A convenience method for creating an {@link IPv6} by providing the decimal value of the IP number in BigInt
|
|
1367
1397
|
*
|
|
@@ -1401,8 +1431,8 @@ class IPv6 extends AbstractIPNum {
|
|
|
1401
1431
|
static fromBinaryString(ipBinaryString) {
|
|
1402
1432
|
let validationResult = Validator_1$2.Validator.isValidBinaryString(ipBinaryString);
|
|
1403
1433
|
if (validationResult[0]) {
|
|
1404
|
-
let paddedBinaryString = BinaryUtils_3.leftPadWithZeroBit(ipBinaryString, 128);
|
|
1405
|
-
return new IPv6(BinaryUtils_2.parseBinaryStringToBigInt(paddedBinaryString));
|
|
1434
|
+
let paddedBinaryString = (0, BinaryUtils_3.leftPadWithZeroBit)(ipBinaryString, 128);
|
|
1435
|
+
return new IPv6((0, BinaryUtils_2.parseBinaryStringToBigInt)(paddedBinaryString));
|
|
1406
1436
|
}
|
|
1407
1437
|
else {
|
|
1408
1438
|
throw Error(validationResult[1].join(','));
|
|
@@ -1427,6 +1457,51 @@ class IPv6 extends AbstractIPNum {
|
|
|
1427
1457
|
static fromIPv4DotDecimalString(ip4DotDecimalString) {
|
|
1428
1458
|
return new IPv4(ip4DotDecimalString).toIPv4MappedIPv6();
|
|
1429
1459
|
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Constructor for an IPv6 number.
|
|
1462
|
+
*
|
|
1463
|
+
* @param {string | bigint} ipValue value to construct an IPv6 from. The given value can either be
|
|
1464
|
+
* numeric or string. If a string is given then it needs to be in hexadecatet string notation
|
|
1465
|
+
*/
|
|
1466
|
+
constructor(ipValue) {
|
|
1467
|
+
super();
|
|
1468
|
+
/**
|
|
1469
|
+
* The number of bits needed to represents the value of the IPv6 number
|
|
1470
|
+
*/
|
|
1471
|
+
this.bitSize = 128;
|
|
1472
|
+
/**
|
|
1473
|
+
* The maximum bit size (i.e. binary value) of the IPv6 number in BigInt
|
|
1474
|
+
*/
|
|
1475
|
+
this.maximumBitSize = Validator_1$2.Validator.ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_SIZE;
|
|
1476
|
+
/**
|
|
1477
|
+
* The type of IP number. Value is one of the values of the {@link IPNumType} enum
|
|
1478
|
+
* @type {IPNumType} the type of IP number
|
|
1479
|
+
*/
|
|
1480
|
+
this.type = "IPv6" /* IPNumType.IPv6 */;
|
|
1481
|
+
/**
|
|
1482
|
+
* An array of {@link Hexadecatet}'s
|
|
1483
|
+
*
|
|
1484
|
+
* @type {Array} the hexadecatet that makes up the IPv6 number
|
|
1485
|
+
*/
|
|
1486
|
+
this.hexadecatet = [];
|
|
1487
|
+
/**
|
|
1488
|
+
* The string character used to separate the individual hexadecatet when the IPv6 is rendered as strings
|
|
1489
|
+
*
|
|
1490
|
+
* @type {string} The string character used to separate the individual hexadecatet when rendered as strings
|
|
1491
|
+
*/
|
|
1492
|
+
this.separator = ":";
|
|
1493
|
+
if (typeof ipValue === "string") {
|
|
1494
|
+
let expandedIPv6 = (0, IPv6Utils_1.expandIPv6Number)(ipValue);
|
|
1495
|
+
let [value, hexadecatet] = this.constructFromHexadecimalDottedString(expandedIPv6);
|
|
1496
|
+
this.value = value;
|
|
1497
|
+
this.hexadecatet = hexadecatet;
|
|
1498
|
+
}
|
|
1499
|
+
else {
|
|
1500
|
+
let [value, hexadecatet] = this.constructFromBigIntValue(ipValue);
|
|
1501
|
+
this.value = value;
|
|
1502
|
+
this.hexadecatet = hexadecatet;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1430
1505
|
/**
|
|
1431
1506
|
* A string representation of the IPv6 number.
|
|
1432
1507
|
*
|
|
@@ -1471,7 +1546,7 @@ class IPv6 extends AbstractIPNum {
|
|
|
1471
1546
|
if (!isValid) {
|
|
1472
1547
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1473
1548
|
}
|
|
1474
|
-
let binaryString = BinaryUtils_4.numberToBinaryString(ipv6Number);
|
|
1549
|
+
let binaryString = (0, BinaryUtils_4.numberToBinaryString)(ipv6Number);
|
|
1475
1550
|
return [ipv6Number, this.binaryStringToHexadecatets(binaryString)];
|
|
1476
1551
|
}
|
|
1477
1552
|
constructFromHexadecimalDottedString(expandedIPv6) {
|
|
@@ -1483,11 +1558,11 @@ class IPv6 extends AbstractIPNum {
|
|
|
1483
1558
|
let hexadecatet = stringHexadecimals.map((stringHexadecatet) => {
|
|
1484
1559
|
return Hexadecatet_1$1.Hexadecatet.fromString(stringHexadecatet);
|
|
1485
1560
|
});
|
|
1486
|
-
let value = BigInt(`0b${HexadecimalUtils_2.hexadectetNotationToBinaryString(expandedIPv6)}`);
|
|
1561
|
+
let value = BigInt(`0b${(0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(expandedIPv6)}`);
|
|
1487
1562
|
return [value, hexadecatet];
|
|
1488
1563
|
}
|
|
1489
1564
|
binaryStringToHexadecatets(binaryString) {
|
|
1490
|
-
let hexadecimalString = HexadecimalUtils_1$1.binaryStringToHexadecimalString(binaryString);
|
|
1565
|
+
let hexadecimalString = (0, HexadecimalUtils_1$1.binaryStringToHexadecimalString)(binaryString);
|
|
1491
1566
|
while (hexadecimalString.length % 4 != 0) {
|
|
1492
1567
|
hexadecimalString = '0' + hexadecimalString;
|
|
1493
1568
|
}
|
|
@@ -1504,6 +1579,17 @@ IPNumber.IPv6 = IPv6;
|
|
|
1504
1579
|
* to demarcate which bits are used to identify a network, and the ones that are used to identify hosts on the network
|
|
1505
1580
|
*/
|
|
1506
1581
|
class IPv4Mask extends IPv4 {
|
|
1582
|
+
/**
|
|
1583
|
+
* A convenience method for creating an instance of IPv4Mask. The passed strings need to be a valid IPv4
|
|
1584
|
+
* number in dot-decimal notation.
|
|
1585
|
+
*
|
|
1586
|
+
* @param {string} rawValue The passed string in dot-decimal notation
|
|
1587
|
+
* @returns {IPv4Mask} the instance of IPv4Mask
|
|
1588
|
+
*/
|
|
1589
|
+
static fromDecimalDottedString(rawValue) {
|
|
1590
|
+
return new IPv4Mask(rawValue);
|
|
1591
|
+
}
|
|
1592
|
+
;
|
|
1507
1593
|
/**
|
|
1508
1594
|
* Constructor for creating an instance of IPv4Mask.
|
|
1509
1595
|
* The passed strings need to be a valid IPv4 mask number in dot-decimal notation.
|
|
@@ -1524,25 +1610,14 @@ class IPv4Mask extends IPv4 {
|
|
|
1524
1610
|
if (!isValid) {
|
|
1525
1611
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1526
1612
|
}
|
|
1527
|
-
let stringOctets = ipString.split(".");
|
|
1528
|
-
this.octets = stringOctets.map((rawOctet) => {
|
|
1529
|
-
return Octet_1.Octet.fromString(rawOctet);
|
|
1530
|
-
});
|
|
1531
|
-
let binaryString = BinaryUtils_1$2.dottedDecimalNotationToBinaryString(ipString);
|
|
1532
|
-
this.prefix = (binaryString.match(/1/g) || []).length;
|
|
1533
|
-
this.value = BigInt(`0b${binaryString}`);
|
|
1534
|
-
}
|
|
1535
|
-
/**
|
|
1536
|
-
* A convenience method for creating an instance of IPv4Mask. The passed strings need to be a valid IPv4
|
|
1537
|
-
* number in dot-decimal notation.
|
|
1538
|
-
*
|
|
1539
|
-
* @param {string} rawValue The passed string in dot-decimal notation
|
|
1540
|
-
* @returns {IPv4Mask} the instance of IPv4Mask
|
|
1541
|
-
*/
|
|
1542
|
-
static fromDecimalDottedString(rawValue) {
|
|
1543
|
-
return new IPv4Mask(rawValue);
|
|
1613
|
+
let stringOctets = ipString.split(".");
|
|
1614
|
+
this.octets = stringOctets.map((rawOctet) => {
|
|
1615
|
+
return Octet_1.Octet.fromString(rawOctet);
|
|
1616
|
+
});
|
|
1617
|
+
let binaryString = (0, BinaryUtils_1$2.dottedDecimalNotationToBinaryString)(ipString);
|
|
1618
|
+
this.prefix = (binaryString.match(/1/g) || []).length;
|
|
1619
|
+
this.value = BigInt(`0b${binaryString}`);
|
|
1544
1620
|
}
|
|
1545
|
-
;
|
|
1546
1621
|
}
|
|
1547
1622
|
IPNumber.IPv4Mask = IPv4Mask;
|
|
1548
1623
|
/**
|
|
@@ -1552,6 +1627,17 @@ IPNumber.IPv4Mask = IPv4Mask;
|
|
|
1552
1627
|
* on the network
|
|
1553
1628
|
*/
|
|
1554
1629
|
class IPv6Mask extends IPv6 {
|
|
1630
|
+
/**
|
|
1631
|
+
* A convenience method for creating an instance of IPv6Mask.
|
|
1632
|
+
* The passed strings need to be a valid IPv4 mask number in dot-decimal notation.
|
|
1633
|
+
*
|
|
1634
|
+
* @param {string} rawValue The passed string in textual notation
|
|
1635
|
+
* @returns {IPv6Mask} the instance of IPv6Mask
|
|
1636
|
+
*/
|
|
1637
|
+
static fromHexadecatet(rawValue) {
|
|
1638
|
+
return new IPv6Mask(rawValue);
|
|
1639
|
+
}
|
|
1640
|
+
;
|
|
1555
1641
|
/**
|
|
1556
1642
|
* Constructor for creating an instance of IPv6Mask.
|
|
1557
1643
|
* The passed strings need to be a valid IPv6 mask number in dot-decimal notation
|
|
@@ -1568,7 +1654,7 @@ class IPv6Mask extends IPv6 {
|
|
|
1568
1654
|
this.hexadecatet = [];
|
|
1569
1655
|
let isValid;
|
|
1570
1656
|
let message;
|
|
1571
|
-
let expandedIPv6 = IPv6Utils_1.expandIPv6Number(ipString);
|
|
1657
|
+
let expandedIPv6 = (0, IPv6Utils_1.expandIPv6Number)(ipString);
|
|
1572
1658
|
[isValid, message] = Validator_1$2.Validator.isValidIPv6Mask(expandedIPv6);
|
|
1573
1659
|
if (!isValid) {
|
|
1574
1660
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
@@ -1577,22 +1663,11 @@ class IPv6Mask extends IPv6 {
|
|
|
1577
1663
|
this.hexadecatet = stringHexadecimals.map((stringHexadecatet) => {
|
|
1578
1664
|
return Hexadecatet_1$1.Hexadecatet.fromString(stringHexadecatet);
|
|
1579
1665
|
});
|
|
1580
|
-
let binaryString = HexadecimalUtils_2.hexadectetNotationToBinaryString(expandedIPv6);
|
|
1666
|
+
let binaryString = (0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(expandedIPv6);
|
|
1581
1667
|
this.prefix = (binaryString.match(/1/g) || []).length;
|
|
1582
1668
|
this.value = BigInt(`0b${binaryString}`);
|
|
1583
|
-
this.value = BigInt(`0b${HexadecimalUtils_2.hexadectetNotationToBinaryString(expandedIPv6)}`);
|
|
1584
|
-
}
|
|
1585
|
-
/**
|
|
1586
|
-
* A convenience method for creating an instance of IPv6Mask.
|
|
1587
|
-
* The passed strings need to be a valid IPv4 mask number in dot-decimal notation.
|
|
1588
|
-
*
|
|
1589
|
-
* @param {string} rawValue The passed string in textual notation
|
|
1590
|
-
* @returns {IPv6Mask} the instance of IPv6Mask
|
|
1591
|
-
*/
|
|
1592
|
-
static fromHexadecatet(rawValue) {
|
|
1593
|
-
return new IPv6Mask(rawValue);
|
|
1669
|
+
this.value = BigInt(`0b${(0, HexadecimalUtils_2.hexadectetNotationToBinaryString)(expandedIPv6)}`);
|
|
1594
1670
|
}
|
|
1595
|
-
;
|
|
1596
1671
|
}
|
|
1597
1672
|
IPNumber.IPv6Mask = IPv6Mask;
|
|
1598
1673
|
/**
|
|
@@ -1602,7 +1677,6 @@ IPNumber.IPv6Mask = IPv6Mask;
|
|
|
1602
1677
|
function isIPv4(ip) {
|
|
1603
1678
|
return ip.bitSize === 32;
|
|
1604
1679
|
}
|
|
1605
|
-
IPNumber.isIPv4 = isIPv4;
|
|
1606
1680
|
|
|
1607
1681
|
var IPNumType = {};
|
|
1608
1682
|
|
|
@@ -1615,7 +1689,8 @@ var IPRange = {};
|
|
|
1615
1689
|
var Prefix = {};
|
|
1616
1690
|
|
|
1617
1691
|
Object.defineProperty(Prefix, "__esModule", { value: true });
|
|
1618
|
-
Prefix.
|
|
1692
|
+
Prefix.IPv6Prefix = Prefix.IPv4Prefix = void 0;
|
|
1693
|
+
Prefix.isIPv4Prefix = isIPv4Prefix;
|
|
1619
1694
|
const Validator_1$1 = requireValidator();
|
|
1620
1695
|
const IPNumber_1$1 = IPNumber;
|
|
1621
1696
|
const BinaryUtils_1$1 = BinaryUtils;
|
|
@@ -1630,6 +1705,21 @@ const Hexadecatet_1 = Hexadecatet$1;
|
|
|
1630
1705
|
* {@see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing} for more information on CIDR
|
|
1631
1706
|
*/
|
|
1632
1707
|
class IPv4Prefix {
|
|
1708
|
+
/**
|
|
1709
|
+
* Convenience method for constructing an instance of IPv4 prefix from a decimal number
|
|
1710
|
+
*
|
|
1711
|
+
* @param {number} rawValue the decimal value to construct the IPv4 prefix from.
|
|
1712
|
+
* @returns {IPv4Prefix} the instance of an IPv4 prefix
|
|
1713
|
+
*/
|
|
1714
|
+
static fromNumber(rawValue) {
|
|
1715
|
+
return new IPv4Prefix(rawValue);
|
|
1716
|
+
}
|
|
1717
|
+
;
|
|
1718
|
+
static fromRangeSize(rangeSize) {
|
|
1719
|
+
let prefixNumber = rangeSize === (1n) ? 32 : 32 - rangeSizeToPrefix(rangeSize, Validator_1$1.Validator.IPV4_SIZE);
|
|
1720
|
+
return IPv4Prefix.fromNumber(BigInt(prefixNumber));
|
|
1721
|
+
}
|
|
1722
|
+
;
|
|
1633
1723
|
/**
|
|
1634
1724
|
* Constructor for an instance of IPv4 prefix from a decimal number
|
|
1635
1725
|
*
|
|
@@ -1641,27 +1731,12 @@ class IPv4Prefix {
|
|
|
1641
1731
|
this.bitValue = 32n;
|
|
1642
1732
|
let isValid;
|
|
1643
1733
|
let message;
|
|
1644
|
-
[isValid, message] = Validator_1$1.Validator.isValidPrefixValue(rawValue, "IPv4" /* IPv4 */);
|
|
1734
|
+
[isValid, message] = Validator_1$1.Validator.isValidPrefixValue(rawValue, "IPv4" /* IPNumType.IPv4 */);
|
|
1645
1735
|
if (!isValid) {
|
|
1646
1736
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1647
1737
|
}
|
|
1648
1738
|
this.value = rawValue;
|
|
1649
1739
|
}
|
|
1650
|
-
/**
|
|
1651
|
-
* Convenience method for constructing an instance of IPv4 prefix from a decimal number
|
|
1652
|
-
*
|
|
1653
|
-
* @param {number} rawValue the decimal value to construct the IPv4 prefix from.
|
|
1654
|
-
* @returns {IPv4Prefix} the instance of an IPv4 prefix
|
|
1655
|
-
*/
|
|
1656
|
-
static fromNumber(rawValue) {
|
|
1657
|
-
return new IPv4Prefix(rawValue);
|
|
1658
|
-
}
|
|
1659
|
-
;
|
|
1660
|
-
static fromRangeSize(rangeSize) {
|
|
1661
|
-
let prefixNumber = rangeSize === (1n) ? 32 : 32 - rangeSizeToPrefix(rangeSize, Validator_1$1.Validator.IPV4_SIZE);
|
|
1662
|
-
return IPv4Prefix.fromNumber(BigInt(prefixNumber));
|
|
1663
|
-
}
|
|
1664
|
-
;
|
|
1665
1740
|
/**
|
|
1666
1741
|
* Gets the decimal value of the IPv4 prefix
|
|
1667
1742
|
*
|
|
@@ -1718,7 +1793,7 @@ class IPv4Prefix {
|
|
|
1718
1793
|
return new IPv4Prefix(this.value + 1n);
|
|
1719
1794
|
}
|
|
1720
1795
|
toDecimalNotation(bits) {
|
|
1721
|
-
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))}`;
|
|
1796
|
+
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))}`;
|
|
1722
1797
|
}
|
|
1723
1798
|
}
|
|
1724
1799
|
Prefix.IPv4Prefix = IPv4Prefix;
|
|
@@ -1731,6 +1806,20 @@ Prefix.IPv4Prefix = IPv4Prefix;
|
|
|
1731
1806
|
* {@see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing} for more information on CIDR
|
|
1732
1807
|
*/
|
|
1733
1808
|
class IPv6Prefix {
|
|
1809
|
+
/**
|
|
1810
|
+
* Convenience method for constructing an instance of IPv46 prefix from a decimal number
|
|
1811
|
+
*
|
|
1812
|
+
* @param {number} rawValue the decimal value to construct the IPv6 prefix from.
|
|
1813
|
+
* @returns {IPv4Prefix} the instance of an IPv6 prefix
|
|
1814
|
+
*/
|
|
1815
|
+
static fromNumber(rawValue) {
|
|
1816
|
+
return new IPv6Prefix(rawValue);
|
|
1817
|
+
}
|
|
1818
|
+
;
|
|
1819
|
+
static fromRangeSize(rangeSize) {
|
|
1820
|
+
let prefixNumber = rangeSize === (1n) ? 128 : 128 - rangeSizeToPrefix(rangeSize, Validator_1$1.Validator.IPV6_SIZE);
|
|
1821
|
+
return IPv6Prefix.fromNumber(BigInt(prefixNumber));
|
|
1822
|
+
}
|
|
1734
1823
|
/**
|
|
1735
1824
|
* Constructor for an instance of IPv6 prefix from a decimal number
|
|
1736
1825
|
*
|
|
@@ -1742,26 +1831,12 @@ class IPv6Prefix {
|
|
|
1742
1831
|
this.bitValue = 128n;
|
|
1743
1832
|
let isValid;
|
|
1744
1833
|
let message;
|
|
1745
|
-
[isValid, message] = Validator_1$1.Validator.isValidPrefixValue(rawValue, "IPv6" /* IPv6 */);
|
|
1834
|
+
[isValid, message] = Validator_1$1.Validator.isValidPrefixValue(rawValue, "IPv6" /* IPNumType.IPv6 */);
|
|
1746
1835
|
if (!isValid) {
|
|
1747
1836
|
throw new Error(message.filter(msg => { return msg !== ''; }).toString());
|
|
1748
1837
|
}
|
|
1749
1838
|
this.value = rawValue;
|
|
1750
1839
|
}
|
|
1751
|
-
/**
|
|
1752
|
-
* Convenience method for constructing an instance of IPv46 prefix from a decimal number
|
|
1753
|
-
*
|
|
1754
|
-
* @param {number} rawValue the decimal value to construct the IPv6 prefix from.
|
|
1755
|
-
* @returns {IPv4Prefix} the instance of an IPv6 prefix
|
|
1756
|
-
*/
|
|
1757
|
-
static fromNumber(rawValue) {
|
|
1758
|
-
return new IPv6Prefix(rawValue);
|
|
1759
|
-
}
|
|
1760
|
-
;
|
|
1761
|
-
static fromRangeSize(rangeSize) {
|
|
1762
|
-
let prefixNumber = rangeSize === (1n) ? 128 : 128 - rangeSizeToPrefix(rangeSize, Validator_1$1.Validator.IPV6_SIZE);
|
|
1763
|
-
return IPv6Prefix.fromNumber(BigInt(prefixNumber));
|
|
1764
|
-
}
|
|
1765
1840
|
/**
|
|
1766
1841
|
* Gets the decimal value of the IPv6 prefix
|
|
1767
1842
|
*
|
|
@@ -1820,7 +1895,7 @@ class IPv6Prefix {
|
|
|
1820
1895
|
toHexadecatetNotation(bits) {
|
|
1821
1896
|
let binaryStrings = bits.match(/.{1,16}/g);
|
|
1822
1897
|
let hexadecimalStrings = binaryStrings.map((binaryString) => {
|
|
1823
|
-
return Hexadecatet_1.Hexadecatet.fromString(HexadecimalUtils_1.binaryStringToHexadecimalString(binaryString));
|
|
1898
|
+
return Hexadecatet_1.Hexadecatet.fromString((0, HexadecimalUtils_1.binaryStringToHexadecimalString)(binaryString));
|
|
1824
1899
|
});
|
|
1825
1900
|
return hexadecimalStrings.map((value) => { return value.toString(); }).join(":");
|
|
1826
1901
|
}
|
|
@@ -1832,7 +1907,7 @@ function rangeSizeToPrefix(rangeSize, rangeMaxSize) {
|
|
|
1832
1907
|
throw new Error(Validator_1$1.Validator.invalidIPRangeSizeMessage.replace("$iptype", ipType));
|
|
1833
1908
|
}
|
|
1834
1909
|
try {
|
|
1835
|
-
return BinaryUtils_1$1.intLog2(rangeSize);
|
|
1910
|
+
return (0, BinaryUtils_1$1.intLog2)(rangeSize);
|
|
1836
1911
|
}
|
|
1837
1912
|
catch (e) {
|
|
1838
1913
|
throw new Error(Validator_1$1.Validator.invalidIPRangeSizeForCidrMessage);
|
|
@@ -1845,10 +1920,10 @@ function rangeSizeToPrefix(rangeSize, rangeMaxSize) {
|
|
|
1845
1920
|
function isIPv4Prefix(prefix) {
|
|
1846
1921
|
return prefix.type === "IPv4";
|
|
1847
1922
|
}
|
|
1848
|
-
Prefix.isIPv4Prefix = isIPv4Prefix;
|
|
1849
1923
|
|
|
1850
1924
|
Object.defineProperty(IPRange, "__esModule", { value: true });
|
|
1851
|
-
IPRange.
|
|
1925
|
+
IPRange.IPv6CidrRange = IPRange.IPv4CidrRange = IPRange.AbstractIPRange = IPRange.RangedSet = void 0;
|
|
1926
|
+
IPRange.isIPv4CidrRange = isIPv4CidrRange;
|
|
1852
1927
|
const IPNumber_1 = IPNumber;
|
|
1853
1928
|
const Prefix_1$1 = Prefix;
|
|
1854
1929
|
const BinaryUtils_1 = BinaryUtils;
|
|
@@ -1859,24 +1934,6 @@ const Validator_1 = requireValidator();
|
|
|
1859
1934
|
* for allocating IP addresses.
|
|
1860
1935
|
*/
|
|
1861
1936
|
class RangedSet {
|
|
1862
|
-
/**
|
|
1863
|
-
* Constructor for an instance of {@link RangedSet} from an
|
|
1864
|
-
* instance of either {@link IPv4CidrRange} or {@link IPv6CidrRange}
|
|
1865
|
-
*
|
|
1866
|
-
* Throws an exception if first IP number is not less than given last IP number
|
|
1867
|
-
*
|
|
1868
|
-
* @param first the first IP number of the range
|
|
1869
|
-
* @param last the last IP number of the range
|
|
1870
|
-
*/
|
|
1871
|
-
constructor(first, last) {
|
|
1872
|
-
this.first = first;
|
|
1873
|
-
this.last = last;
|
|
1874
|
-
if (first.isGreaterThan(last)) {
|
|
1875
|
-
throw new Error(`${first.toString()} should be lower than ${last.toString()}`);
|
|
1876
|
-
}
|
|
1877
|
-
this.currentValue = first;
|
|
1878
|
-
this.bitValue = BigInt(first.bitSize);
|
|
1879
|
-
}
|
|
1880
1937
|
/**
|
|
1881
1938
|
* Convenience method for constructing an instance of {@link RangedSet} from a
|
|
1882
1939
|
* single IP number.
|
|
@@ -1921,6 +1978,24 @@ class RangedSet {
|
|
|
1921
1978
|
throw new Error("First IP and Last IP should be valid and same type");
|
|
1922
1979
|
}
|
|
1923
1980
|
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Constructor for an instance of {@link RangedSet} from an
|
|
1983
|
+
* instance of either {@link IPv4CidrRange} or {@link IPv6CidrRange}
|
|
1984
|
+
*
|
|
1985
|
+
* Throws an exception if first IP number is not less than given last IP number
|
|
1986
|
+
*
|
|
1987
|
+
* @param first the first IP number of the range
|
|
1988
|
+
* @param last the last IP number of the range
|
|
1989
|
+
*/
|
|
1990
|
+
constructor(first, last) {
|
|
1991
|
+
this.first = first;
|
|
1992
|
+
this.last = last;
|
|
1993
|
+
if (first.isGreaterThan(last)) {
|
|
1994
|
+
throw new Error(`${first.toString()} should be lower than ${last.toString()}`);
|
|
1995
|
+
}
|
|
1996
|
+
this.currentValue = first;
|
|
1997
|
+
this.bitValue = BigInt(first.bitSize);
|
|
1998
|
+
}
|
|
1924
1999
|
/**
|
|
1925
2000
|
* Returns the first IP number in the range
|
|
1926
2001
|
*/
|
|
@@ -2024,7 +2099,11 @@ class RangedSet {
|
|
|
2024
2099
|
let otherLast = otherRange.getLast();
|
|
2025
2100
|
return (thisLast.isGreaterThan(otherFirst) && thisLast.isLessThanOrEquals(otherLast) && thisFirst.isLessThan(otherFirst)
|
|
2026
2101
|
||
|
|
2027
|
-
otherLast.isGreaterThan(thisFirst) && otherLast.isLessThanOrEquals(thisLast) && otherFirst.isLessThan(thisFirst)
|
|
2102
|
+
otherLast.isGreaterThan(thisFirst) && otherLast.isLessThanOrEquals(thisLast) && otherFirst.isLessThan(thisFirst)
|
|
2103
|
+
||
|
|
2104
|
+
this.contains(otherRange)
|
|
2105
|
+
||
|
|
2106
|
+
otherRange.contains(this));
|
|
2028
2107
|
}
|
|
2029
2108
|
/**
|
|
2030
2109
|
* Check if this range can be converted to a CIDR range.
|
|
@@ -2034,8 +2113,8 @@ class RangedSet {
|
|
|
2034
2113
|
return true;
|
|
2035
2114
|
}
|
|
2036
2115
|
try {
|
|
2037
|
-
let prefix = BinaryUtils_1.intLog2(this.getSize());
|
|
2038
|
-
let netmask = BinaryUtils_1.parseBinaryStringToBigInt(BinaryUtils_1.cidrPrefixToMaskBinaryString(prefix, IPNumber_1.isIPv4(this.currentValue) ? "IPv4" /* IPv4 */ : "IPv6" /* IPv6 */));
|
|
2116
|
+
let prefix = (0, BinaryUtils_1.intLog2)(this.getSize());
|
|
2117
|
+
let netmask = (0, BinaryUtils_1.parseBinaryStringToBigInt)((0, BinaryUtils_1.cidrPrefixToMaskBinaryString)(prefix, (0, IPNumber_1.isIPv4)(this.currentValue) ? "IPv4" /* IPNumType.IPv4 */ : "IPv6" /* IPNumType.IPv6 */));
|
|
2039
2118
|
return (this.first.getValue()) === (netmask & (this.first.getValue()));
|
|
2040
2119
|
}
|
|
2041
2120
|
catch (e) {
|
|
@@ -2046,7 +2125,7 @@ class RangedSet {
|
|
|
2046
2125
|
* Converts an instance of range to an instance of CIDR range
|
|
2047
2126
|
*/
|
|
2048
2127
|
toCidrRange() {
|
|
2049
|
-
if (IPNumber_1.isIPv4(this.currentValue)) {
|
|
2128
|
+
if ((0, IPNumber_1.isIPv4)(this.currentValue)) {
|
|
2050
2129
|
return this.toIPv4CidrRange();
|
|
2051
2130
|
}
|
|
2052
2131
|
else {
|
|
@@ -2080,6 +2159,12 @@ class RangedSet {
|
|
|
2080
2159
|
if (this.isEquals(otherRange)) {
|
|
2081
2160
|
return new RangedSet(otherRange.getFirst(), otherRange.getLast());
|
|
2082
2161
|
}
|
|
2162
|
+
if (this.contains(otherRange)) {
|
|
2163
|
+
return new RangedSet(this.getFirst(), this.getLast());
|
|
2164
|
+
}
|
|
2165
|
+
else if (otherRange.contains(this)) {
|
|
2166
|
+
return new RangedSet(otherRange.getFirst(), otherRange.getLast());
|
|
2167
|
+
}
|
|
2083
2168
|
if (this.isOverlapping(otherRange)) {
|
|
2084
2169
|
if (this.getFirst().isLessThan(otherRange.getFirst())) {
|
|
2085
2170
|
return new RangedSet(this.getFirst(), otherRange.getLast());
|
|
@@ -2088,12 +2173,6 @@ class RangedSet {
|
|
|
2088
2173
|
return new RangedSet(otherRange.getFirst(), this.getLast());
|
|
2089
2174
|
}
|
|
2090
2175
|
}
|
|
2091
|
-
if (this.contains(otherRange)) {
|
|
2092
|
-
return new RangedSet(this.getFirst(), this.getLast());
|
|
2093
|
-
}
|
|
2094
|
-
else if (otherRange.contains(this)) {
|
|
2095
|
-
return new RangedSet(otherRange.getFirst(), otherRange.getLast());
|
|
2096
|
-
}
|
|
2097
2176
|
throw new Error("Ranges do not overlap nor are equal");
|
|
2098
2177
|
}
|
|
2099
2178
|
/**
|
|
@@ -2147,10 +2226,10 @@ class RangedSet {
|
|
|
2147
2226
|
throw new Error("Sub range cannot be zero");
|
|
2148
2227
|
}
|
|
2149
2228
|
let valueOfFirstIp = this.getFirst().value + (offset);
|
|
2150
|
-
let firstIp = IPNumber_1.isIPv4(this.getFirst()) ?
|
|
2229
|
+
let firstIp = (0, IPNumber_1.isIPv4)(this.getFirst()) ?
|
|
2151
2230
|
IPNumber_1.IPv4.fromNumber(valueOfFirstIp) : IPNumber_1.IPv6.fromBigInt(valueOfFirstIp);
|
|
2152
2231
|
let valueOfLastIp = firstIp.value + (size - 1n);
|
|
2153
|
-
let lastIp = IPNumber_1.isIPv4(firstIp) ? IPNumber_1.IPv4.fromNumber(valueOfLastIp) : IPNumber_1.IPv6.fromBigInt(valueOfLastIp);
|
|
2232
|
+
let lastIp = (0, IPNumber_1.isIPv4)(firstIp) ? IPNumber_1.IPv4.fromNumber(valueOfLastIp) : IPNumber_1.IPv6.fromBigInt(valueOfLastIp);
|
|
2154
2233
|
return new RangedSet(firstIp, lastIp);
|
|
2155
2234
|
}
|
|
2156
2235
|
/**
|
|
@@ -2228,6 +2307,12 @@ class AbstractIPRange {
|
|
|
2228
2307
|
return this.toRangeSet().inside(otherRange.toRangeSet());
|
|
2229
2308
|
}
|
|
2230
2309
|
contains(otherRange) {
|
|
2310
|
+
if (otherRange instanceof IPNumber_1.AbstractIPNum) {
|
|
2311
|
+
const firstValue = this.getFirst().getValue();
|
|
2312
|
+
const lastValue = this.getLast().getValue();
|
|
2313
|
+
const otherValue = otherRange.getValue();
|
|
2314
|
+
return otherValue >= firstValue && otherValue <= lastValue;
|
|
2315
|
+
}
|
|
2231
2316
|
return this.toRangeSet().contains(otherRange.toRangeSet());
|
|
2232
2317
|
}
|
|
2233
2318
|
toRangeString() {
|
|
@@ -2240,7 +2325,7 @@ class AbstractIPRange {
|
|
|
2240
2325
|
return this.toRangeSet().isConsecutive(otherRange.toRangeSet());
|
|
2241
2326
|
}
|
|
2242
2327
|
isCidrMergeable(otherRange) {
|
|
2243
|
-
const count = BigInt(BinaryUtils_1.matchingBitCount(this.getFirst().toBinaryString(), otherRange.getFirst().toBinaryString()));
|
|
2328
|
+
const count = BigInt((0, BinaryUtils_1.matchingBitCount)(this.getFirst().toBinaryString(), otherRange.getFirst().toBinaryString()));
|
|
2244
2329
|
if (this.getPrefix().value - count !== 1n) {
|
|
2245
2330
|
return false;
|
|
2246
2331
|
}
|
|
@@ -2285,23 +2370,6 @@ IPRange.AbstractIPRange = AbstractIPRange;
|
|
|
2285
2370
|
* @see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
|
|
2286
2371
|
*/
|
|
2287
2372
|
class IPv4CidrRange extends AbstractIPRange {
|
|
2288
|
-
/**
|
|
2289
|
-
* Constructor for creating an instance of an IPv4 range.
|
|
2290
|
-
*
|
|
2291
|
-
* The arguments taken by the constructor is inspired by the CIDR notation which basically consists of the IP
|
|
2292
|
-
* number and the prefix.
|
|
2293
|
-
*
|
|
2294
|
-
* @param {IPv4} ipv4 the IP number used to construct the range. By convention this is the first IP number in
|
|
2295
|
-
* the range, but it could also be any IP number within the range
|
|
2296
|
-
* @param {IPv4Prefix} cidrPrefix the prefix which is a representation of the number of bits used to mask the
|
|
2297
|
-
* given IP number in other to create the range
|
|
2298
|
-
*/
|
|
2299
|
-
constructor(ipv4, cidrPrefix) {
|
|
2300
|
-
super();
|
|
2301
|
-
this.ipv4 = ipv4;
|
|
2302
|
-
this.cidrPrefix = cidrPrefix;
|
|
2303
|
-
this.bitValue = 32n;
|
|
2304
|
-
}
|
|
2305
2373
|
/**
|
|
2306
2374
|
* Convenience method for constructing an instance of an IPv4CidrRange from an IP range represented in CIDR notation
|
|
2307
2375
|
*
|
|
@@ -2319,6 +2387,23 @@ class IPv4CidrRange extends AbstractIPRange {
|
|
|
2319
2387
|
let prefix = BigInt(parseInt(cidrComponents[1]));
|
|
2320
2388
|
return new IPv4CidrRange(IPNumber_1.IPv4.fromDecimalDottedString(ipString), Prefix_1$1.IPv4Prefix.fromNumber(prefix));
|
|
2321
2389
|
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Constructor for creating an instance of an IPv4 range.
|
|
2392
|
+
*
|
|
2393
|
+
* The arguments taken by the constructor is inspired by the CIDR notation which basically consists of the IP
|
|
2394
|
+
* number and the prefix.
|
|
2395
|
+
*
|
|
2396
|
+
* @param {IPv4} ipv4 the IP number used to construct the range. By convention this is the first IP number in
|
|
2397
|
+
* the range, but it could also be any IP number within the range
|
|
2398
|
+
* @param {IPv4Prefix} cidrPrefix the prefix which is a representation of the number of bits used to mask the
|
|
2399
|
+
* given IP number in other to create the range
|
|
2400
|
+
*/
|
|
2401
|
+
constructor(ipv4, cidrPrefix) {
|
|
2402
|
+
super();
|
|
2403
|
+
this.ipv4 = ipv4;
|
|
2404
|
+
this.cidrPrefix = cidrPrefix;
|
|
2405
|
+
this.bitValue = 32n;
|
|
2406
|
+
}
|
|
2322
2407
|
/**
|
|
2323
2408
|
* Gets the size of IPv4 numbers contained within the IPv4 range
|
|
2324
2409
|
*
|
|
@@ -2520,23 +2605,6 @@ IPRange.IPv4CidrRange = IPv4CidrRange;
|
|
|
2520
2605
|
* @see https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
|
|
2521
2606
|
*/
|
|
2522
2607
|
class IPv6CidrRange extends AbstractIPRange {
|
|
2523
|
-
/**
|
|
2524
|
-
* Constructor for creating an instance of an IPv6 range.
|
|
2525
|
-
*
|
|
2526
|
-
* The arguments taken by the constructor is inspired by the CIDR notation which basically consists of the IP
|
|
2527
|
-
* number and the prefix.
|
|
2528
|
-
*
|
|
2529
|
-
* @param {IPv6} ipv6 the IP number used to construct the range. By convention this is the first IP number in
|
|
2530
|
-
* the range, but it could also be any IP number within the range
|
|
2531
|
-
* @param {IPv6Prefix} cidrPrefix the prefix which is a representation of the number of bits used to mask the
|
|
2532
|
-
* given IPv6 number in other to create the range
|
|
2533
|
-
*/
|
|
2534
|
-
constructor(ipv6, cidrPrefix) {
|
|
2535
|
-
super();
|
|
2536
|
-
this.ipv6 = ipv6;
|
|
2537
|
-
this.cidrPrefix = cidrPrefix;
|
|
2538
|
-
this.bitValue = 128n;
|
|
2539
|
-
}
|
|
2540
2608
|
/**
|
|
2541
2609
|
* Convenience method for constructing an instance of an IPV6Range from an IP range represented in CIDR notation
|
|
2542
2610
|
*
|
|
@@ -2554,6 +2622,23 @@ class IPv6CidrRange extends AbstractIPRange {
|
|
|
2554
2622
|
return new IPv6CidrRange(IPNumber_1.IPv6.fromHexadecatet(ipString), Prefix_1$1.IPv6Prefix.fromNumber(prefix));
|
|
2555
2623
|
}
|
|
2556
2624
|
;
|
|
2625
|
+
/**
|
|
2626
|
+
* Constructor for creating an instance of an IPv6 range.
|
|
2627
|
+
*
|
|
2628
|
+
* The arguments taken by the constructor is inspired by the CIDR notation which basically consists of the IP
|
|
2629
|
+
* number and the prefix.
|
|
2630
|
+
*
|
|
2631
|
+
* @param {IPv6} ipv6 the IP number used to construct the range. By convention this is the first IP number in
|
|
2632
|
+
* the range, but it could also be any IP number within the range
|
|
2633
|
+
* @param {IPv6Prefix} cidrPrefix the prefix which is a representation of the number of bits used to mask the
|
|
2634
|
+
* given IPv6 number in other to create the range
|
|
2635
|
+
*/
|
|
2636
|
+
constructor(ipv6, cidrPrefix) {
|
|
2637
|
+
super();
|
|
2638
|
+
this.ipv6 = ipv6;
|
|
2639
|
+
this.cidrPrefix = cidrPrefix;
|
|
2640
|
+
this.bitValue = 128n;
|
|
2641
|
+
}
|
|
2557
2642
|
/**
|
|
2558
2643
|
* Gets the size of IPv6 numbers contained within the IPv6 range
|
|
2559
2644
|
*
|
|
@@ -2750,18 +2835,17 @@ let last = (range, ip) => {
|
|
|
2750
2835
|
let bitValue = Number(range.bitValue.valueOf());
|
|
2751
2836
|
let maskSize = BigInt(`0b${"1".repeat(bitValue)}`);
|
|
2752
2837
|
let maskAsBigInteger = range.cidrPrefix.toMask().getValue();
|
|
2753
|
-
let invertedMask = BinaryUtils_1.leftPadWithZeroBit((maskAsBigInteger ^ (maskSize)).toString(2), bitValue);
|
|
2838
|
+
let invertedMask = (0, BinaryUtils_1.leftPadWithZeroBit)((maskAsBigInteger ^ (maskSize)).toString(2), bitValue);
|
|
2754
2839
|
if (isIPv4CidrRange(range)) {
|
|
2755
|
-
return IPNumber_1.IPv4.fromNumber((ip.getValue()) | (BinaryUtils_1.parseBinaryStringToBigInt(invertedMask)));
|
|
2840
|
+
return IPNumber_1.IPv4.fromNumber((ip.getValue()) | ((0, BinaryUtils_1.parseBinaryStringToBigInt)(invertedMask)));
|
|
2756
2841
|
}
|
|
2757
2842
|
else {
|
|
2758
|
-
return IPNumber_1.IPv6.fromBigInt((ip.getValue()) | (BinaryUtils_1.parseBinaryStringToBigInt(invertedMask)));
|
|
2843
|
+
return IPNumber_1.IPv6.fromBigInt((ip.getValue()) | ((0, BinaryUtils_1.parseBinaryStringToBigInt)(invertedMask)));
|
|
2759
2844
|
}
|
|
2760
2845
|
};
|
|
2761
2846
|
function isIPv4CidrRange(ip) {
|
|
2762
2847
|
return ip.bitValue.valueOf() === 32n;
|
|
2763
2848
|
}
|
|
2764
|
-
IPRange.isIPv4CidrRange = isIPv4CidrRange;
|
|
2765
2849
|
|
|
2766
2850
|
Object.defineProperty(IPPool, "__esModule", { value: true });
|
|
2767
2851
|
IPPool.Pool = void 0;
|
|
@@ -2771,19 +2855,6 @@ const Prefix_1 = Prefix;
|
|
|
2771
2855
|
* Represents a collection of IP {@link RangedSet}'s
|
|
2772
2856
|
*/
|
|
2773
2857
|
class Pool {
|
|
2774
|
-
/**
|
|
2775
|
-
* Constructor for an IP pool.
|
|
2776
|
-
*
|
|
2777
|
-
* Creates a Pool of IP ranges from supplied {@link RangedSet}'s
|
|
2778
|
-
*
|
|
2779
|
-
* @param ranges the array of IP ranges that would make up the pool.
|
|
2780
|
-
*/
|
|
2781
|
-
constructor(ranges) {
|
|
2782
|
-
this.backingSet = new SortedSet();
|
|
2783
|
-
ranges.forEach(range => {
|
|
2784
|
-
this.backingSet.add(range);
|
|
2785
|
-
});
|
|
2786
|
-
}
|
|
2787
2858
|
/**
|
|
2788
2859
|
* Convenient method for creating an instance from arrays of {@link IPv4} or {@link IPv6}
|
|
2789
2860
|
* @param ipNumbers the arrays of {@link IPv4} or {@link IPv6} that will make up the pool.
|
|
@@ -2815,6 +2886,19 @@ class Pool {
|
|
|
2815
2886
|
});
|
|
2816
2887
|
return new Pool(rangeSet);
|
|
2817
2888
|
}
|
|
2889
|
+
/**
|
|
2890
|
+
* Constructor for an IP pool.
|
|
2891
|
+
*
|
|
2892
|
+
* Creates a Pool of IP ranges from supplied {@link RangedSet}'s
|
|
2893
|
+
*
|
|
2894
|
+
* @param ranges the array of IP ranges that would make up the pool.
|
|
2895
|
+
*/
|
|
2896
|
+
constructor(ranges) {
|
|
2897
|
+
this.backingSet = new SortedSet();
|
|
2898
|
+
ranges.forEach(range => {
|
|
2899
|
+
this.backingSet.add(range);
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2818
2902
|
/**
|
|
2819
2903
|
* Returns an array of {@link RangedSet}'s that is contained within the pool
|
|
2820
2904
|
*/
|
|
@@ -2889,7 +2973,7 @@ class Pool {
|
|
|
2889
2973
|
if (e instanceof RangeError) {
|
|
2890
2974
|
continue loop;
|
|
2891
2975
|
}
|
|
2892
|
-
error = e;
|
|
2976
|
+
error = e instanceof Error ? e : new Error(String(e));
|
|
2893
2977
|
}
|
|
2894
2978
|
}
|
|
2895
2979
|
if (selectedCidrRange) {
|
|
@@ -2925,7 +3009,7 @@ class Pool {
|
|
|
2925
3009
|
}
|
|
2926
3010
|
}
|
|
2927
3011
|
catch (e) {
|
|
2928
|
-
let lowerPrefix = Prefix_1.isIPv4Prefix(prefix) ?
|
|
3012
|
+
let lowerPrefix = (0, Prefix_1.isIPv4Prefix)(prefix) ?
|
|
2929
3013
|
Prefix_1.IPv4Prefix.fromNumber(prefix.getValue() + 1n) : Prefix_1.IPv6Prefix.fromNumber(prefix.getValue() + 1n);
|
|
2930
3014
|
return go(reqprefix, lowerPrefix, accummulated);
|
|
2931
3015
|
}
|
|
@@ -2993,14 +3077,6 @@ class Pool {
|
|
|
2993
3077
|
}
|
|
2994
3078
|
IPPool.Pool = Pool;
|
|
2995
3079
|
class SortedSet {
|
|
2996
|
-
constructor(array) {
|
|
2997
|
-
if (array) {
|
|
2998
|
-
this.backingArray = this.sortArray(array);
|
|
2999
|
-
}
|
|
3000
|
-
else {
|
|
3001
|
-
this.backingArray = new Array();
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
3080
|
sortArray(array) {
|
|
3005
3081
|
array.sort((a, b) => {
|
|
3006
3082
|
if (a.isLessThan(b)) {
|
|
@@ -3013,6 +3089,14 @@ class SortedSet {
|
|
|
3013
3089
|
});
|
|
3014
3090
|
return array;
|
|
3015
3091
|
}
|
|
3092
|
+
constructor(array) {
|
|
3093
|
+
if (array) {
|
|
3094
|
+
this.backingArray = this.sortArray(array);
|
|
3095
|
+
}
|
|
3096
|
+
else {
|
|
3097
|
+
this.backingArray = new Array();
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3016
3100
|
asArray() {
|
|
3017
3101
|
return this.backingArray;
|
|
3018
3102
|
}
|
|
@@ -3084,13 +3168,17 @@ class SortedSet {
|
|
|
3084
3168
|
(function (exports) {
|
|
3085
3169
|
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3086
3170
|
if (k2 === undefined) k2 = k;
|
|
3087
|
-
Object.
|
|
3171
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3172
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3173
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
3174
|
+
}
|
|
3175
|
+
Object.defineProperty(o, k2, desc);
|
|
3088
3176
|
}) : (function(o, m, k, k2) {
|
|
3089
3177
|
if (k2 === undefined) k2 = k;
|
|
3090
3178
|
o[k2] = m[k];
|
|
3091
3179
|
}));
|
|
3092
3180
|
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
3093
|
-
for (var p in m) if (p !== "default" && !
|
|
3181
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3094
3182
|
};
|
|
3095
3183
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3096
3184
|
/**
|
|
@@ -3114,7 +3202,7 @@ class SortedSet {
|
|
|
3114
3202
|
__exportStar(Prefix, exports);
|
|
3115
3203
|
__exportStar(requireValidator(), exports);
|
|
3116
3204
|
|
|
3117
|
-
} (
|
|
3205
|
+
} (src));
|
|
3118
3206
|
|
|
3119
3207
|
var toLabelAndValue = function toLabelAndValue(value) {
|
|
3120
3208
|
return {
|
|
@@ -3123,10 +3211,10 @@ var toLabelAndValue = function toLabelAndValue(value) {
|
|
|
3123
3211
|
};
|
|
3124
3212
|
};
|
|
3125
3213
|
var isValidIPv4String = function isValidIPv4String(ip) {
|
|
3126
|
-
return isNotNil(ip) &&
|
|
3214
|
+
return isNotNil(ip) && src.Validator.isValidIPv4String(ip)[0];
|
|
3127
3215
|
};
|
|
3128
3216
|
var isValidIPv6String = function isValidIPv6String(ip) {
|
|
3129
|
-
return isNotNil(ip) &&
|
|
3217
|
+
return isNotNil(ip) && src.Validator.isValidIPv6String(ip)[0];
|
|
3130
3218
|
};
|
|
3131
3219
|
var isValidIpString = function isValidIpString(ip) {
|
|
3132
3220
|
return isValidIPv4String(ip) || isValidIPv6String(ip);
|
|
@@ -3135,13 +3223,13 @@ var areIpAddressesInSameFormat = function areIpAddressesInSameFormat(ipStart, ip
|
|
|
3135
3223
|
return isValidIPv4String(ipStart) && isValidIPv4String(ipEnd) || isValidIPv6String(ipStart) && isValidIPv6String(ipEnd);
|
|
3136
3224
|
};
|
|
3137
3225
|
var isValidIPv4Range = function isValidIPv4Range(ipStart, ipEnd) {
|
|
3138
|
-
var ipStartAddr =
|
|
3139
|
-
var ipEndAddr =
|
|
3226
|
+
var ipStartAddr = src.IPv4.fromDecimalDottedString(ipStart);
|
|
3227
|
+
var ipEndAddr = src.IPv4.fromDecimalDottedString(ipEnd);
|
|
3140
3228
|
return ipStartAddr.isLessThanOrEquals(ipEndAddr);
|
|
3141
3229
|
};
|
|
3142
3230
|
var isValidIPv6Range = function isValidIPv6Range(ipStart, ipEnd) {
|
|
3143
|
-
var ipStartAddr =
|
|
3144
|
-
var ipEndAddr =
|
|
3231
|
+
var ipStartAddr = src.IPv6.fromString(ipStart);
|
|
3232
|
+
var ipEndAddr = src.IPv6.fromString(ipEnd);
|
|
3145
3233
|
return ipStartAddr.isLessThanOrEquals(ipEndAddr);
|
|
3146
3234
|
};
|
|
3147
3235
|
var isValidIPRange = function isValidIPRange(ipStart, ipEnd) {
|
|
@@ -3231,8 +3319,6 @@ var ADDRESS_TYPE_SELECT_OPTIONS = [{
|
|
|
3231
3319
|
value: "ipv6"
|
|
3232
3320
|
}];
|
|
3233
3321
|
({
|
|
3234
|
-
ipStart: "",
|
|
3235
|
-
ipEnd: "",
|
|
3236
3322
|
addressType: ADDRESS_TYPE_SELECT_OPTIONS[0].value
|
|
3237
3323
|
});
|
|
3238
3324
|
var VALIDATION_SCHEMA = yup.object().shape({
|
|
@@ -3440,7 +3526,7 @@ var allowedIpRangesApi = {
|
|
|
3440
3526
|
};
|
|
3441
3527
|
|
|
3442
3528
|
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; }
|
|
3443
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t),
|
|
3529
|
+
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; }
|
|
3444
3530
|
var ALLOWED_IP_RANGES$1 = QUERY_KEYS.ALLOWED_IP_RANGES;
|
|
3445
3531
|
var useFetchAllowedIpRanges = function useFetchAllowedIpRanges(options) {
|
|
3446
3532
|
return useQuery(_objectSpread({
|