mybase 1.1.45 → 1.1.47

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/ip6addr.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare module 'ip6addr' {
1
+ declare module '@7c/node-ip6addr' {
2
2
  export interface ToStringOpts {
3
3
  format?: "auto" | "v4" | "v4-mapped" | "v6" | undefined;
4
4
  zeroElide?: boolean | undefined;
package/mybase.js CHANGED
@@ -9,7 +9,7 @@ const chalk = require('chalk')
9
9
  const _validURL = require('@7c/validurl')
10
10
  const validator = require('validator')
11
11
  const sha512 = require('js-sha512')
12
- const ip6addr = require('ip6addr')
12
+ const ip6addr = require('@7c/node-ip6addr')
13
13
 
14
14
  const private_network_cidrs = [ip6addr.createCIDR('10.0.0.0/8')
15
15
  ,ip6addr.createCIDR('172.16.0.0/12')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mybase",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "description": "",
5
5
  "main": "mybase.js",
6
6
  "scripts": {
@@ -9,6 +9,7 @@
9
9
  "author": "",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
+ "@7c/node-ip6addr": "https://github.com/7c/node-ip6addr.git",
12
13
  "@7c/validurl": "0.0.3",
13
14
  "@types/debug": "^4.1.12",
14
15
  "@types/ip6addr": "^0.2.6",
@@ -21,7 +22,6 @@
21
22
  "debug": "^4.3.4",
22
23
  "ip-range-check": "^0.2.0",
23
24
  "ip6": "=0.2.7",
24
- "ip6addr": "github:7c/node-ip6addr#db6d558af1f314bcb0a733fd61611fa85e1a3eff",
25
25
  "js-sha512": "^0.8.0",
26
26
  "knex": "^3.1.0",
27
27
  "mysql": "^2.18.1",
@@ -33,11 +33,11 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@jest/globals": "^29.7.0",
36
- "@types/jest": "^29.5.11",
36
+ "@types/jest": "^29.5.14",
37
37
  "chai": "^4.2.0",
38
38
  "jest": "^29.7.0",
39
- "mocha": "^8.2.1",
39
+ "mocha": "^11.1.0",
40
40
  "should": "^13.2.3",
41
- "ts-jest": "^29.1.1"
41
+ "ts-jest": "^29.2.5"
42
42
  }
43
43
  }
@@ -1,3 +1,3 @@
1
- import ip6addr from 'ip6addr';
1
+ import ip6addr from '@7c/node-ip6addr';
2
2
  export declare const private_network_cidrs: ip6addr.CIDR[];
3
3
  export declare function isLANIp(ip: string): boolean;
@@ -5,14 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.private_network_cidrs = void 0;
7
7
  exports.isLANIp = isLANIp;
8
- const ip6addr_1 = __importDefault(require("ip6addr"));
8
+ const node_ip6addr_1 = __importDefault(require("@7c/node-ip6addr"));
9
9
  const net_1 = __importDefault(require("net"));
10
10
  exports.private_network_cidrs = [
11
- ip6addr_1.default.createCIDR('10.0.0.0/8'),
12
- ip6addr_1.default.createCIDR('172.16.0.0/12'),
13
- ip6addr_1.default.createCIDR('192.168.0.0/16'),
14
- ip6addr_1.default.createCIDR('fd00::/8'), // Reserved by IETF for future use, but not currently in active use.
15
- ip6addr_1.default.createCIDR('fc00::/8'), // The range currently in use for local communications within a site or organization.
11
+ node_ip6addr_1.default.createCIDR('10.0.0.0/8'),
12
+ node_ip6addr_1.default.createCIDR('172.16.0.0/12'),
13
+ node_ip6addr_1.default.createCIDR('192.168.0.0/16'),
14
+ node_ip6addr_1.default.createCIDR('fd00::/8'), // Reserved by IETF for future use, but not currently in active use.
15
+ node_ip6addr_1.default.createCIDR('fc00::/8'), // The range currently in use for local communications within a site or organization.
16
16
  ];
17
17
  function isLANIp(ip) {
18
18
  ip = normalizeIp(ip);
@@ -1,4 +1,4 @@
1
- import ip6addr from 'ip6addr'
1
+ import ip6addr from '@7c/node-ip6addr'
2
2
  import net from 'net'
3
3
 
4
4
  export const private_network_cidrs = [
@@ -1,3 +1,3 @@
1
- import ip6addr from 'ip6addr';
1
+ import ip6addr from '@7c/node-ip6addr';
2
2
  export declare const local_network_cidrs: ip6addr.CIDR[];
3
3
  export declare function isLoopbackIP(ip: string): boolean;
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.local_network_cidrs = void 0;
7
7
  exports.isLoopbackIP = isLoopbackIP;
8
- const ip6addr_1 = __importDefault(require("ip6addr"));
8
+ const node_ip6addr_1 = __importDefault(require("@7c/node-ip6addr"));
9
9
  const net_1 = __importDefault(require("net"));
10
10
  exports.local_network_cidrs = [
11
- ip6addr_1.default.createCIDR('127.0.0.0/8'),
12
- ip6addr_1.default.createCIDR('::1/128')
11
+ node_ip6addr_1.default.createCIDR('127.0.0.0/8'),
12
+ node_ip6addr_1.default.createCIDR('::1/128')
13
13
  ];
14
14
  function isLoopbackIP(ip) {
15
15
  ip = normalizeIp(ip);
@@ -1,4 +1,4 @@
1
- import ip6addr from 'ip6addr'
1
+ import ip6addr from '@7c/node-ip6addr'
2
2
  import net from 'net'
3
3
 
4
4
  export const local_network_cidrs = [
@@ -7,7 +7,7 @@ exports.vaultRead = vaultRead;
7
7
  const debug_1 = require("debug");
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_1 = __importDefault(require("fs"));
10
- const node_fs_1 = require("node:fs");
10
+ const fs_2 = require("fs");
11
11
  const fileCacheIsValid_1 = require("./fileCacheIsValid");
12
12
  const global_1 = require("../global");
13
13
  const hash_sha512_1 = require("./hash_sha512");
@@ -18,7 +18,7 @@ function vaultRead(vaultInstance, vaultKey, cache_in_minutes = 10) {
18
18
  return new Promise((resolve, reject) => {
19
19
  let cache_file = path_1.default.join(global_1.vault_cache_folder, (0, hash_sha512_1.hash_sha512)(`${vaultInstance.endpoint}/${vaultKey}`));
20
20
  if (cache_in_minutes > 0 && (0, fileCacheIsValid_1.fileCacheIsValid)(cache_file, cache_in_minutes))
21
- return resolve(JSON.parse((0, node_fs_1.readFileSync)(cache_file).toString()));
21
+ return resolve(JSON.parse((0, fs_2.readFileSync)(cache_file).toString()));
22
22
  vaultInstance.read(vaultKey).then((r) => {
23
23
  if (r.data) {
24
24
  dbg(`vault ${vaultKey} - success`);
@@ -2,7 +2,7 @@ import { debug } from "debug"
2
2
  import nodeVault from "node-vault";
3
3
  import path from "path";
4
4
  import fs from "fs";
5
- import { readFileSync } from 'node:fs';
5
+ import { readFileSync } from 'fs';
6
6
  import { fileCacheIsValid } from "./fileCacheIsValid";
7
7
  import { vault_cache_folder } from "../global";
8
8
  import { hash_sha512 } from "./hash_sha512";
@@ -1,4 +1,4 @@
1
- import ip6addr, { ToStringOpts } from 'ip6addr';
1
+ import ip6addr, { ToStringOpts } from '@7c/node-ip6addr';
2
2
  export declare class IPAddress {
3
3
  private _ip;
4
4
  static loopback_cidrs4: ip6addr.CIDR[];
@@ -7,7 +7,7 @@ exports.IPAddress = void 0;
7
7
  /// <reference path="./../../ip6addr.d.ts" />
8
8
  const debug_1 = __importDefault(require("debug"));
9
9
  const __1 = require("./../");
10
- const ip6addr_1 = __importDefault(require("ip6addr"));
10
+ const node_ip6addr_1 = __importDefault(require("@7c/node-ip6addr"));
11
11
  const net_1 = __importDefault(require("net"));
12
12
  const ip6 = require('ip6'); // "url": "https://github.com/elgs/ip6"
13
13
  const dbg = (0, debug_1.default)('_IPAddress');
@@ -18,10 +18,10 @@ class IPAddress {
18
18
  if (ip === '-')
19
19
  ip = '0.0.0.0'; // is this really required?
20
20
  try {
21
- this._ip = ip6addr_1.default.parse(ip);
21
+ this._ip = node_ip6addr_1.default.parse(ip);
22
22
  if (this._ip._attrs.ipv4Mapped) {
23
23
  // we wany to convert it to ipv4
24
- this._ip = ip6addr_1.default.parse(this._ip.toString({ format: 'v4' }));
24
+ this._ip = node_ip6addr_1.default.parse(this._ip.toString({ format: 'v4' }));
25
25
  }
26
26
  }
27
27
  catch (err) {
@@ -157,7 +157,7 @@ class IPAddress {
157
157
  const randomBigInt = BigInt(Math.floor(Math.random() * (Number(range) + 1))) + start;
158
158
  // dbg('randomBigInt', randomBigInt)
159
159
  // Convert the BigInt back to an IP address
160
- const randomIp = ip6addr_1.default.parse(randomBigInt);
160
+ const randomIp = node_ip6addr_1.default.parse(randomBigInt);
161
161
  // dbg('randomCIDRIp', randomIp.toString())
162
162
  return new IPAddress(randomIp.toString());
163
163
  }
@@ -233,20 +233,20 @@ class IPAddress {
233
233
  }
234
234
  exports.IPAddress = IPAddress;
235
235
  IPAddress.loopback_cidrs4 = [
236
- ip6addr_1.default.createCIDR('127.0.0.0/8'),
236
+ node_ip6addr_1.default.createCIDR('127.0.0.0/8'),
237
237
  ];
238
238
  IPAddress.loopback_cidrs6 = [
239
- ip6addr_1.default.createCIDR('::1/128') // yes ipv6 has single address
239
+ node_ip6addr_1.default.createCIDR('::1/128') // yes ipv6 has single address
240
240
  ];
241
241
  IPAddress.loopback_cidrs = IPAddress.loopback_cidrs4.concat(IPAddress.loopback_cidrs6);
242
242
  IPAddress.lan_cidrs4 = [
243
- ip6addr_1.default.createCIDR('10.0.0.0/8'),
244
- ip6addr_1.default.createCIDR('172.16.0.0/12'),
245
- ip6addr_1.default.createCIDR('192.168.0.0/16'),
243
+ node_ip6addr_1.default.createCIDR('10.0.0.0/8'),
244
+ node_ip6addr_1.default.createCIDR('172.16.0.0/12'),
245
+ node_ip6addr_1.default.createCIDR('192.168.0.0/16'),
246
246
  ];
247
247
  IPAddress.lan_cidrs6 = [
248
- ip6addr_1.default.createCIDR('fd00::/8'), // Reserved by IETF for future use, but not currently in active use.
249
- ip6addr_1.default.createCIDR('fc00::/8'), // The range currently in use for local communications within a site or organization.
248
+ node_ip6addr_1.default.createCIDR('fd00::/8'), // Reserved by IETF for future use, but not currently in active use.
249
+ node_ip6addr_1.default.createCIDR('fc00::/8'), // The range currently in use for local communications within a site or organization.
250
250
  ];
251
251
  IPAddress.lan_cidrs = IPAddress.lan_cidrs4.concat(IPAddress.lan_cidrs6);
252
252
  IPAddress.local_cidrs = IPAddress.loopback_cidrs.concat(IPAddress.lan_cidrs);
@@ -1,4 +1,4 @@
1
- import ip6addr from 'ip6addr'
1
+ import ip6addr from '@7c/node-ip6addr'
2
2
  import { IPAddress } from './IPAddress'
3
3
  import { randomIP, randomIP6 } from '../'
4
4
 
@@ -1,7 +1,7 @@
1
1
  /// <reference path="./../../ip6addr.d.ts" />
2
2
  import debug from 'debug'
3
3
  import { randomIP, randomIP6, } from "./../"
4
- import ip6addr, { Addr, ToStringOpts } from 'ip6addr'
4
+ import ip6addr, { Addr, ToStringOpts } from '@7c/node-ip6addr'
5
5
  import net from 'net'
6
6
  const ip6 = require('ip6') // "url": "https://github.com/elgs/ip6"
7
7
  const dbg = debug('_IPAddress')
@@ -9,7 +9,7 @@ describe('OTPGenerator', () => {
9
9
  const otp = otpGenerator.generateOTP();
10
10
  // length should be 5 + 13
11
11
  expect(otp.length).toBe(18);
12
- console.log(otp);
12
+ // console.log(otp);
13
13
  })
14
14
 
15
15
  it('should generate different OTPs in milliseconds', async () => {
@@ -1 +0,0 @@
1
- {"root":["./ip6addr.d.ts","./ts/global.ts","./ts/index.ts","./ts/types.ts","./ts/funcs/geoip2paths.ts","./ts/funcs/maxruntimehours.ts","./ts/funcs/asjson.ts","./ts/funcs/ensurefolder.ts","./ts/funcs/filecacheisvalid.ts","./ts/funcs/getmysql1.ts","./ts/funcs/getmysql2.ts","./ts/funcs/getweeknumber.ts","./ts/funcs/hash_sha512.ts","./ts/funcs/initmysql2pool.ts","./ts/funcs/int2ip.ts","./ts/funcs/ip2int.ts","./ts/funcs/islanip.ts","./ts/funcs/islocal.ts","./ts/funcs/isloopbackip.ts","./ts/funcs/knexconnection.ts","./ts/funcs/promisetimeout.ts","./ts/funcs/randomip.ts","./ts/funcs/randomip6.ts","./ts/funcs/randomstring.ts","./ts/funcs/randomtcpport.ts","./ts/funcs/randomutfstring.ts","./ts/funcs/utcnow.ts","./ts/funcs/validemail.ts","./ts/funcs/validip.ts","./ts/funcs/vaultfill.ts","./ts/funcs/vaultread.ts","./ts/funcs/wait.ts","./ts/models/ipaddress.ts","./ts/models/interfaces.ts","./ts/models/otpgenerator.ts","./ts/models/timespan.ts","./ts/models/unixtime.ts"],"version":"5.7.2"}