@xyo-network/shared 5.3.5 → 5.3.6

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.
@@ -1,4 +1,2 @@
1
- export * from './dump.ts';
2
- export * from './is-ip/index.ts';
3
1
  export * from './Job/index.ts';
4
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -1,63 +1 @@
1
- // src/dump.ts
2
- var dump = (object) => {
3
- const cache = [];
4
- return JSON.stringify(
5
- object,
6
- (key, value) => {
7
- if (typeof value === "object" && value !== null) {
8
- if (cache.includes(value)) {
9
- return "[circular]";
10
- }
11
- cache.push(value);
12
- }
13
- return value;
14
- },
15
- 2
16
- );
17
- };
18
-
19
- // src/is-ip/ip-regex.ts
20
- var word = String.raw`[a-fA-F\d:]`;
21
- var boundary = (options) => options.includeBoundaries ? String.raw`(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))` : "";
22
- var v4 = String.raw`(?: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}`;
23
- var v6segment = String.raw`[a-fA-F\d]{1,4}`;
24
- var v6 = `
25
- (?:
26
- (?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
27
- (?:${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
28
- (?:${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
29
- (?:${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
30
- (?:${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
31
- (?:${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
32
- (?:${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
33
- (?::(?:(?::${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
34
- )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
35
- `.replaceAll(/\s*\/\/.*$/gm, "").replaceAll("\n", "").trim();
36
- var v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`);
37
- var v4exact = new RegExp(`^${v4}$`);
38
- var v6exact = new RegExp(`^${v6}$`);
39
- var ipRegex = (options) => options.exact ? v46Exact : new RegExp(`(?:${boundary(options)}${v4}${boundary(options)})|(?:${boundary(options)}${v6}${boundary(options)})`, "g");
40
- ipRegex.v4 = (options) => options.exact ? v4exact : new RegExp(`${boundary(options)}${v4}${boundary(options)}`, "g");
41
- ipRegex.v6 = (options) => options.exact ? v6exact : new RegExp(`${boundary(options)}${v6}${boundary(options)}`, "g");
42
-
43
- // src/is-ip/is-ip.ts
44
- function isIP(value) {
45
- return ipRegex({ exact: true }).test(value);
46
- }
47
- function isIPv6(value) {
48
- return ipRegex.v6({ exact: true }).test(value);
49
- }
50
- function isIPv4(value) {
51
- return ipRegex.v4({ exact: true }).test(value);
52
- }
53
- function ipVersion(value) {
54
- return isIP(value) ? isIPv6(value) ? 6 : 4 : void 0;
55
- }
56
- export {
57
- dump,
58
- ipVersion,
59
- isIP,
60
- isIPv4,
61
- isIPv6
62
- };
63
1
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/dump.ts","../../src/is-ip/ip-regex.ts","../../src/is-ip/is-ip.ts"],"sourcesContent":["export const dump = (object: unknown): string => {\n const cache: unknown[] = []\n return JSON.stringify(\n object,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n // Duplicate reference found, discard key\n if (cache.includes(value)) {\n return '[circular]'\n }\n\n // Store value in our collection\n cache.push(value)\n }\n return value\n },\n 2,\n )\n}\n","const word = String.raw`[a-fA-F\\d:]`\n\nexport interface Options {\n readonly exact?: boolean\n readonly includeBoundaries?: boolean\n}\n\nconst boundary = (options: Options) => (options.includeBoundaries ? String.raw`(?:(?<=\\\\s|^)(?=${word})|(?<=${word})(?=\\\\s|$))` : '')\n\nconst v4 = String.raw`(?: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}`\n\nconst v6segment = String.raw`[a-fA-F\\d]{1,4}`\n\nconst v6 = `\n(?:\n(?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${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\n(?:${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\n(?:${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\n(?:${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\n(?:${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\n(?:${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\n(?::(?:(?::${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\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`\n .replaceAll(/\\s*\\/\\/.*$/gm, '')\n .replaceAll('\\n', '')\n .trim()\n\n// Pre-compile only the exact regexes because adding a global flag make regexes stateful\nconst v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`)\nconst v4exact = new RegExp(`^${v4}$`)\nconst v6exact = new RegExp(`^${v6}$`)\n\nexport const ipRegex = (options: Options) =>\n options.exact\n ? v46Exact\n : new RegExp(`(?:${boundary(options)}${v4}${boundary(options)})|(?:${boundary(options)}${v6}${boundary(options)})`, 'g')\n\nipRegex.v4 = (options: Options) => (options.exact ? v4exact : new RegExp(`${boundary(options)}${v4}${boundary(options)}`, 'g'))\nipRegex.v6 = (options: Options) => (options.exact ? v6exact : new RegExp(`${boundary(options)}${v6}${boundary(options)}`, 'g'))\n","import { ipRegex } from './ip-regex.ts'\n\nexport function isIP(value: string): boolean {\n return ipRegex({ exact: true }).test(value)\n}\n\nexport function isIPv6(value: string): boolean {\n return ipRegex.v6({ exact: true }).test(value)\n}\n\nexport function isIPv4(value: string): boolean {\n return ipRegex.v4({ exact: true }).test(value)\n}\n\nexport function ipVersion(value: string): 6 | 4 | undefined {\n return (\n isIP(value)\n ? isIPv6(value)\n ? 6\n : 4\n : undefined\n )\n}\n"],"mappings":";AAAO,IAAM,OAAO,CAAC,WAA4B;AAC/C,QAAM,QAAmB,CAAC;AAC1B,SAAO,KAAK;AAAA,IACV;AAAA,IACA,CAAC,KAAK,UAAU;AACd,UAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAE/C,YAAI,MAAM,SAAS,KAAK,GAAG;AACzB,iBAAO;AAAA,QACT;AAGA,cAAM,KAAK,KAAK;AAAA,MAClB;AACA,aAAO;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;;;AClBA,IAAM,OAAO,OAAO;AAOpB,IAAM,WAAW,CAAC,YAAsB,QAAQ,oBAAoB,OAAO,sBAAsB,IAAI,SAAS,IAAI,gBAAgB;AAElI,IAAM,KAAK,OAAO;AAElB,IAAM,YAAY,OAAO;AAEzB,IAAM,KAAK;AAAA;AAAA,KAEN,SAAS,WAAW,SAAS;AAAA,KAC7B,SAAS,WAAW,EAAE,KAAK,SAAS;AAAA,KACpC,SAAS,YAAY,EAAE,QAAQ,SAAS;AAAA,KACxC,SAAS,eAAe,SAAS,UAAU,EAAE,QAAQ,SAAS;AAAA,KAC9D,SAAS,eAAe,SAAS,UAAU,EAAE,QAAQ,SAAS;AAAA,KAC9D,SAAS,eAAe,SAAS,UAAU,EAAE,QAAQ,SAAS;AAAA,KAC9D,SAAS,eAAe,SAAS,UAAU,EAAE,QAAQ,SAAS;AAAA,aACtD,SAAS,UAAU,EAAE,QAAQ,SAAS;AAAA;AAAA,EAGhD,WAAW,gBAAgB,EAAE,EAC7B,WAAW,MAAM,EAAE,EACnB,KAAK;AAGR,IAAM,WAAW,IAAI,OAAO,OAAO,EAAE,UAAU,EAAE,IAAI;AACrD,IAAM,UAAU,IAAI,OAAO,IAAI,EAAE,GAAG;AACpC,IAAM,UAAU,IAAI,OAAO,IAAI,EAAE,GAAG;AAE7B,IAAM,UAAU,CAAC,YACtB,QAAQ,QACJ,WACA,IAAI,OAAO,MAAM,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,SAAS,OAAO,CAAC,QAAQ,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,SAAS,OAAO,CAAC,KAAK,GAAG;AAE3H,QAAQ,KAAK,CAAC,YAAsB,QAAQ,QAAQ,UAAU,IAAI,OAAO,GAAG,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,SAAS,OAAO,CAAC,IAAI,GAAG;AAC7H,QAAQ,KAAK,CAAC,YAAsB,QAAQ,QAAQ,UAAU,IAAI,OAAO,GAAG,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,SAAS,OAAO,CAAC,IAAI,GAAG;;;ACtCtH,SAAS,KAAK,OAAwB;AAC3C,SAAO,QAAQ,EAAE,OAAO,KAAK,CAAC,EAAE,KAAK,KAAK;AAC5C;AAEO,SAAS,OAAO,OAAwB;AAC7C,SAAO,QAAQ,GAAG,EAAE,OAAO,KAAK,CAAC,EAAE,KAAK,KAAK;AAC/C;AAEO,SAAS,OAAO,OAAwB;AAC7C,SAAO,QAAQ,GAAG,EAAE,OAAO,KAAK,CAAC,EAAE,KAAK,KAAK;AAC/C;AAEO,SAAS,UAAU,OAAkC;AAC1D,SACE,KAAK,KAAK,IACN,OAAO,KAAK,IACV,IACA,IACF;AAER;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/shared",
3
- "version": "5.3.5",
3
+ "version": "5.3.6",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
package/src/index.ts CHANGED
@@ -1,3 +1 @@
1
- export * from './dump.ts'
2
- export * from './is-ip/index.ts'
3
1
  export * from './Job/index.ts'
@@ -1,2 +0,0 @@
1
- export declare const dump: (object: unknown) => string;
2
- //# sourceMappingURL=dump.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dump.d.ts","sourceRoot":"","sources":["../../src/dump.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,GAAI,QAAQ,OAAO,KAAG,MAkBtC,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './is-ip.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/is-ip/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
@@ -1,10 +0,0 @@
1
- export interface Options {
2
- readonly exact?: boolean;
3
- readonly includeBoundaries?: boolean;
4
- }
5
- export declare const ipRegex: {
6
- (options: Options): RegExp;
7
- v4(options: Options): RegExp;
8
- v6(options: Options): RegExp;
9
- };
10
- //# sourceMappingURL=ip-regex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ip-regex.d.ts","sourceRoot":"","sources":["../../../src/is-ip/ip-regex.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CACrC;AA6BD,eAAO,MAAM,OAAO;cAAa,OAAO;gBAKjB,OAAO;gBACP,OAAO;CAH8F,CAAA"}
@@ -1,5 +0,0 @@
1
- export declare function isIP(value: string): boolean;
2
- export declare function isIPv6(value: string): boolean;
3
- export declare function isIPv4(value: string): boolean;
4
- export declare function ipVersion(value: string): 6 | 4 | undefined;
5
- //# sourceMappingURL=is-ip.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-ip.d.ts","sourceRoot":"","sources":["../../../src/is-ip/is-ip.ts"],"names":[],"mappings":"AAEA,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE3C;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,CAQ1D"}
package/src/dump.ts DELETED
@@ -1,19 +0,0 @@
1
- export const dump = (object: unknown): string => {
2
- const cache: unknown[] = []
3
- return JSON.stringify(
4
- object,
5
- (key, value) => {
6
- if (typeof value === 'object' && value !== null) {
7
- // Duplicate reference found, discard key
8
- if (cache.includes(value)) {
9
- return '[circular]'
10
- }
11
-
12
- // Store value in our collection
13
- cache.push(value)
14
- }
15
- return value
16
- },
17
- 2,
18
- )
19
- }
@@ -1 +0,0 @@
1
- export * from './is-ip.ts'
@@ -1,41 +0,0 @@
1
- const word = String.raw`[a-fA-F\d:]`
2
-
3
- export interface Options {
4
- readonly exact?: boolean
5
- readonly includeBoundaries?: boolean
6
- }
7
-
8
- const boundary = (options: Options) => (options.includeBoundaries ? String.raw`(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))` : '')
9
-
10
- const v4 = String.raw`(?: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}`
11
-
12
- const v6segment = String.raw`[a-fA-F\d]{1,4}`
13
-
14
- const v6 = `
15
- (?:
16
- (?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
17
- (?:${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
18
- (?:${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
19
- (?:${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
20
- (?:${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
21
- (?:${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
22
- (?:${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
23
- (?::(?:(?::${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
24
- )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
25
- `
26
- .replaceAll(/\s*\/\/.*$/gm, '')
27
- .replaceAll('\n', '')
28
- .trim()
29
-
30
- // Pre-compile only the exact regexes because adding a global flag make regexes stateful
31
- const v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`)
32
- const v4exact = new RegExp(`^${v4}$`)
33
- const v6exact = new RegExp(`^${v6}$`)
34
-
35
- export const ipRegex = (options: Options) =>
36
- options.exact
37
- ? v46Exact
38
- : new RegExp(`(?:${boundary(options)}${v4}${boundary(options)})|(?:${boundary(options)}${v6}${boundary(options)})`, 'g')
39
-
40
- ipRegex.v4 = (options: Options) => (options.exact ? v4exact : new RegExp(`${boundary(options)}${v4}${boundary(options)}`, 'g'))
41
- ipRegex.v6 = (options: Options) => (options.exact ? v6exact : new RegExp(`${boundary(options)}${v6}${boundary(options)}`, 'g'))
@@ -1,23 +0,0 @@
1
- import { ipRegex } from './ip-regex.ts'
2
-
3
- export function isIP(value: string): boolean {
4
- return ipRegex({ exact: true }).test(value)
5
- }
6
-
7
- export function isIPv6(value: string): boolean {
8
- return ipRegex.v6({ exact: true }).test(value)
9
- }
10
-
11
- export function isIPv4(value: string): boolean {
12
- return ipRegex.v4({ exact: true }).test(value)
13
- }
14
-
15
- export function ipVersion(value: string): 6 | 4 | undefined {
16
- return (
17
- isIP(value)
18
- ? isIPv6(value)
19
- ? 6
20
- : 4
21
- : undefined
22
- )
23
- }