A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/b3a53c6ab5fd933fc7f8258c155ed31be834393e below:

is-cidr@5.0.3 (#6949) · npm/cli@b3a53c6 · GitHub

File tree Expand file treeCollapse file tree 10 files changed

+88

-109

lines changed

Filter options

Expand file treeCollapse file tree 10 files changed

+88

-109

lines changed Original file line number Diff line number Diff line change

@@ -1,5 +1,4 @@

1 1

const Table = require('cli-table3')

2 -

const { v4: isCidrV4, v6: isCidrV6 } = require('is-cidr')

3 2

const log = require('../utils/log-shim.js')

4 3

const profile = require('npm-profile')

5 4

@@ -137,7 +136,7 @@ class Token extends BaseCommand {

137 136

const readonly = conf.readOnly

138 137 139 138

const password = await readUserInfo.password()

140 -

const validCIDR = this.validateCIDRList(cidr)

139 +

const validCIDR = await this.validateCIDRList(cidr)

141 140

log.info('token', 'creating')

142 141

const result = await pulseTillDone.withPromise(

143 142

otplease(this.npm, conf, c => profile.createToken(password, readonly, validCIDR, c))

@@ -209,7 +208,8 @@ class Token extends BaseCommand {

209 208

return byId

210 209

}

211 210 212 -

validateCIDRList (cidrs) {

211 +

async validateCIDRList (cidrs) {

212 +

const { v4: isCidrV4, v6: isCidrV6 } = await import('is-cidr')

213 213

const maybeList = [].concat(cidrs).filter(Boolean)

214 214

const list = maybeList.length === 1 ? maybeList[0].split(/,\s*/) : maybeList

215 215

for (const cidr of list) {

Original file line number Diff line number Diff line change

@@ -1,18 +1,15 @@

1 -

"use strict";

2 - 3 -

const ipRegex = require("ip-regex");

1 +

import ipRegex from "ip-regex";

4 2 5 3

const defaultOpts = {exact: false};

6 - 7 4

const v4str = `${ipRegex.v4().source}\\/(3[0-2]|[12]?[0-9])`;

8 5

const v6str = `${ipRegex.v6().source}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`;

9 6 10 -

// can not precompile the non-exact regexes because global flag makes the regex object stateful

11 -

// which would require the user to reset .lastIndex on subsequent calls

7 +

// pre-compile only the exact regexes as global flag makes regex objects stateful

12 8

const v4exact = new RegExp(`^${v4str}$`);

13 9

const v6exact = new RegExp(`^${v6str}$`);

14 10

const v46exact = new RegExp(`(?:^${v4str}$)|(?:^${v6str}$)`);

15 11 16 -

module.exports = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g");

17 -

module.exports.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g");

18 -

module.exports.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g");

12 +

const cidrRegex = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g");

13 +

export const v4 = cidrRegex.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g");

14 +

export const v6 = cidrRegex.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g");

15 +

export default cidrRegex;

Original file line number Diff line number Diff line change

@@ -1,42 +1,32 @@

1 1

{

2 2

"name": "cidr-regex",

3 -

"version": "3.1.1",

3 +

"version": "4.0.3",

4 4

"description": "Regular expression for matching IP addresses in CIDR notation",

5 5

"author": "silverwind <me@silverwind.io>",

6 6

"contributors": [

7 7

"Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"

8 8

],

9 9

"repository": "silverwind/cidr-regex",

10 10

"license": "BSD-2-Clause",

11 -

"scripts": {

12 -

"test": "make test"

13 -

},

11 +

"type": "module",

12 +

"exports": "./index.js",

13 +

"sideEffects": false,

14 14

"engines": {

15 -

"node": ">=10"

15 +

"node": ">=14"

16 16

},

17 17

"files": [

18 18

"index.js",

19 19

"index.d.ts"

20 20

],

21 -

"keywords": [

22 -

"cidr",

23 -

"regex",

24 -

"notation",

25 -

"cidr notation",

26 -

"prefix",

27 -

"prefixes",

28 -

"ip",

29 -

"ip address"

30 -

],

31 21

"dependencies": {

32 -

"ip-regex": "^4.1.0"

22 +

"ip-regex": "^5.0.0"

33 23

},

34 24

"devDependencies": {

35 -

"eslint": "7.8.1",

36 -

"eslint-config-silverwind": "18.0.8",

37 -

"jest": "26.4.2",

38 -

"tsd": "0.13.1",

39 -

"updates": "10.3.6",

40 -

"versions": "8.4.3"

25 +

"eslint": "8.37.0",

26 +

"eslint-config-silverwind": "65.1.3",

27 +

"tsd": "0.28.1",

28 +

"updates": "13.2.9",

29 +

"versions": "10.4.2",

30 +

"vitest": "0.29.8"

41 31

}

42 32

}

Original file line number Diff line number Diff line change

@@ -1,23 +1,23 @@

1 -

'use strict';

2 - 3 1

const word = '[a-fA-F\\d:]';

4 -

const b = options => options && options.includeBoundaries ?

5 -

`(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))` :

6 -

'';

2 + 3 +

const boundry = options => options && options.includeBoundaries

4 +

? `(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))`

5 +

: '';

7 6 8 7

const v4 = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}';

9 8 10 -

const v6seg = '[a-fA-F\\d]{1,4}';

9 +

const v6segment = '[a-fA-F\\d]{1,4}';

10 + 11 11

const v6 = `

12 12

(?:

13 -

(?:${v6seg}:){7}(?:${v6seg}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8

14 -

(?:${v6seg}:){6}(?:${v4}|:${v6seg}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4

15 -

(?:${v6seg}:){5}(?::${v4}|(?::${v6seg}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4

16 -

(?:${v6seg}:){4}(?:(?::${v6seg}){0,1}:${v4}|(?::${v6seg}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4

17 -

(?:${v6seg}:){3}(?:(?::${v6seg}){0,2}:${v4}|(?::${v6seg}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4

18 -

(?:${v6seg}:){2}(?:(?::${v6seg}){0,3}:${v4}|(?::${v6seg}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4

19 -

(?:${v6seg}:){1}(?:(?::${v6seg}){0,4}:${v4}|(?::${v6seg}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4

20 -

(?::(?:(?::${v6seg}){0,5}:${v4}|(?::${v6seg}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4

13 +

(?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8

14 +

(?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4

15 +

(?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4

16 +

(?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4

17 +

(?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4

18 +

(?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4

19 +

(?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4

20 +

(?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4

21 21

)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1

22 22

`.replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim();

23 23

@@ -26,11 +26,11 @@ const v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`);

26 26

const v4exact = new RegExp(`^${v4}$`);

27 27

const v6exact = new RegExp(`^${v6}$`);

28 28 29 -

const ip = options => options && options.exact ?

30 -

v46Exact :

31 -

new RegExp(`(?:${b(options)}${v4}${b(options)})|(?:${b(options)}${v6}${b(options)})`, 'g');

29 +

const ipRegex = options => options && options.exact

30 +

? v46Exact

31 +

: new RegExp(`(?:${boundry(options)}${v4}${boundry(options)})|(?:${boundry(options)}${v6}${boundry(options)})`, 'g');

32 32 33 -

ip.v4 = options => options && options.exact ? v4exact : new RegExp(`${b(options)}${v4}${b(options)}`, 'g');

34 -

ip.v6 = options => options && options.exact ? v6exact : new RegExp(`${b(options)}${v6}${b(options)}`, 'g');

33 +

ipRegex.v4 = options => options && options.exact ? v4exact : new RegExp(`${boundry(options)}${v4}${boundry(options)}`, 'g');

34 +

ipRegex.v6 = options => options && options.exact ? v6exact : new RegExp(`${boundry(options)}${v6}${boundry(options)}`, 'g');

35 35 36 -

module.exports = ip;

36 +

export default ipRegex;

Original file line number Diff line number Diff line change

@@ -1,6 +1,6 @@

1 1

MIT License

2 2 3 -

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)

3 +

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

4 4 5 5

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

6 6 Original file line number Diff line number Diff line change

@@ -1,16 +1,19 @@

1 1

{

2 2

"name": "ip-regex",

3 -

"version": "4.3.0",

3 +

"version": "5.0.0",

4 4

"description": "Regular expression for matching IP addresses (IPv4 & IPv6)",

5 5

"license": "MIT",

6 6

"repository": "sindresorhus/ip-regex",

7 +

"funding": "https://github.com/sponsors/sindresorhus",

7 8

"author": {

8 9

"name": "Sindre Sorhus",

9 10

"email": "sindresorhus@gmail.com",

10 11

"url": "sindresorhus.com"

11 12

},

13 +

"type": "module",

14 +

"exports": "./index.js",

12 15

"engines": {

13 -

"node": ">=8"

16 +

"node": "^12.20.0 || ^14.13.1 || >=16.0.0"

14 17

},

15 18

"scripts": {

16 19

"test": "xo && ava && tsd"

@@ -37,8 +40,8 @@

37 40

"validate"

38 41

],

39 42

"devDependencies": {

40 -

"ava": "^1.4.1",

41 -

"tsd": "^0.7.2",

42 -

"xo": "^0.24.0"

43 +

"ava": "^3.15.0",

44 +

"tsd": "^0.19.1",

45 +

"xo": "^0.47.0"

43 46

}

44 47

}

Original file line number Diff line number Diff line change

@@ -1,9 +1,9 @@

1 -

"use strict";

2 -

const {v4, v6} = require("cidr-regex");

1 +

import {v4 as v4Re, v6 as v6Re} from "cidr-regex";

3 2 4 -

const re4 = v4({exact: true});

5 -

const re6 = v6({exact: true});

3 +

const re4 = v4Re({exact: true});

4 +

const re6 = v6Re({exact: true});

6 5 7 -

module.exports = str => re4.test(str) ? 4 : (re6.test(str) ? 6 : 0);

8 -

module.exports.v4 = str => re4.test(str);

9 -

module.exports.v6 = str => re6.test(str);

6 +

const isCidr = str => re4.test(str) ? 4 : (re6.test(str) ? 6 : 0);

7 +

export const v4 = isCidr.v4 = str => re4.test(str);

8 +

export const v6 = isCidr.v6 = str => re6.test(str);

9 +

export default isCidr;

Original file line number Diff line number Diff line change

@@ -1,46 +1,32 @@

1 1

{

2 2

"name": "is-cidr",

3 -

"version": "4.0.2",

3 +

"version": "5.0.3",

4 4

"description": "Check if a string is an IP address in CIDR notation",

5 5

"author": "silverwind <me@silverwind.io>",

6 6

"contributors": [

7 7

"Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"

8 8

],

9 9

"repository": "silverwind/is-cidr",

10 10

"license": "BSD-2-Clause",

11 -

"scripts": {

12 -

"test": "make test"

13 -

},

11 +

"type": "module",

12 +

"exports": "./index.js",

13 +

"sideEffects": false,

14 14

"engines": {

15 -

"node": ">=10"

15 +

"node": ">=14"

16 16

},

17 17

"files": [

18 18

"index.js",

19 19

"index.d.ts"

20 20

],

21 -

"keywords": [

22 -

"cidr",

23 -

"regex",

24 -

"notation",

25 -

"cidr notation",

26 -

"prefix",

27 -

"prefixes",

28 -

"ip",

29 -

"ip address",

30 -

"network"

31 -

],

32 21

"dependencies": {

33 -

"cidr-regex": "^3.1.1"

22 +

"cidr-regex": "4.0.3"

34 23

},

35 24

"devDependencies": {

36 -

"eslint": "7.10.0",

37 -

"eslint-config-silverwind": "18.0.10",

38 -

"jest": "26.4.2",

39 -

"updates": "11.1.5",

40 -

"versions": "8.4.3"

41 -

},

42 -

"jest": {

43 -

"verbose": false,

44 -

"testTimeout": 10000

25 +

"eslint": "8.37.0",

26 +

"eslint-config-silverwind": "65.1.3",

27 +

"tsd": "0.28.1",

28 +

"updates": "13.2.9",

29 +

"versions": "10.4.2",

30 +

"vitest": "0.29.8"

45 31

}

46 32

}

Original file line number Diff line number Diff line change

@@ -113,7 +113,7 @@

113 113

"hosted-git-info": "^7.0.1",

114 114

"ini": "^4.1.1",

115 115

"init-package-json": "^6.0.0",

116 -

"is-cidr": "^4.0.2",

116 +

"is-cidr": "^5.0.3",

117 117

"json-parse-even-better-errors": "^3.0.0",

118 118

"libnpmaccess": "^8.0.1",

119 119

"libnpmdiff": "^6.0.3",

@@ -4919,15 +4919,15 @@

4919 4919

}

4920 4920

},

4921 4921

"node_modules/cidr-regex": {

4922 -

"version": "3.1.1",

4923 -

"resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-3.1.1.tgz",

4924 -

"integrity": "sha512-RBqYd32aDwbCMFJRL6wHOlDNYJsPNTt8vC82ErHF5vKt8QQzxm1FrkW8s/R5pVrXMf17sba09Uoy91PKiddAsw==",

4922 +

"version": "4.0.3",

4923 +

"resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-4.0.3.tgz",

4924 +

"integrity": "sha512-HOwDIy/rhKeMf6uOzxtv7FAbrz8zPjmVKfSpM+U7/bNBXC5rtOyr758jxcptiSx6ZZn5LOhPJT5WWxPAGDV8dw==",

4925 4925

"inBundle": true,

4926 4926

"dependencies": {

4927 -

"ip-regex": "^4.1.0"

4927 +

"ip-regex": "^5.0.0"

4928 4928

},

4929 4929

"engines": {

4930 -

"node": ">=10"

4930 +

"node": ">=14"

4931 4931

}

4932 4932

},

4933 4933

"node_modules/clean-stack": {

@@ -7827,12 +7827,15 @@

7827 7827

"inBundle": true

7828 7828

},

7829 7829

"node_modules/ip-regex": {

7830 -

"version": "4.3.0",

7831 -

"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.3.0.tgz",

7832 -

"integrity": "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==",

7830 +

"version": "5.0.0",

7831 +

"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-5.0.0.tgz",

7832 +

"integrity": "sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==",

7833 7833

"inBundle": true,

7834 7834

"engines": {

7835 -

"node": ">=8"

7835 +

"node": "^12.20.0 || ^14.13.1 || >=16.0.0"

7836 +

},

7837 +

"funding": {

7838 +

"url": "https://github.com/sponsors/sindresorhus"

7836 7839

}

7837 7840

},

7838 7841

"node_modules/is-array-buffer": {

@@ -7935,15 +7938,15 @@

7935 7938

}

7936 7939

},

7937 7940

"node_modules/is-cidr": {

7938 -

"version": "4.0.2",

7939 -

"resolved": "https://registry.npmjs.org/is-cidr/-/is-cidr-4.0.2.tgz",

7940 -

"integrity": "sha512-z4a1ENUajDbEl/Q6/pVBpTR1nBjjEE1X7qb7bmWYanNnPoKAvUCPFKeXV6Fe4mgTkWKBqiHIcwsI3SndiO5FeA==",

7941 +

"version": "5.0.3",

7942 +

"resolved": "https://registry.npmjs.org/is-cidr/-/is-cidr-5.0.3.tgz",

7943 +

"integrity": "sha512-lKkM0tmz07dAxNsr8Ii9MGreExa9ZR34N9j8mTG5op824kcwBqinZPowNjcVWWc7j+jR8XAMMItOmBkniN0jOA==",

7941 7944

"inBundle": true,

7942 7945

"dependencies": {

7943 -

"cidr-regex": "^3.1.1"

7946 +

"cidr-regex": "4.0.3"

7944 7947

},

7945 7948

"engines": {

7946 -

"node": ">=10"

7949 +

"node": ">=14"

7947 7950

}

7948 7951

},

7949 7952

"node_modules/is-core-module": {

Original file line number Diff line number Diff line change

@@ -75,7 +75,7 @@

75 75

"hosted-git-info": "^7.0.1",

76 76

"ini": "^4.1.1",

77 77

"init-package-json": "^6.0.0",

78 -

"is-cidr": "^4.0.2",

78 +

"is-cidr": "^5.0.3",

79 79

"json-parse-even-better-errors": "^3.0.0",

80 80

"libnpmaccess": "^8.0.1",

81 81

"libnpmdiff": "^6.0.3",

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4