From 0d9ce8b4e5894b50916af228404726e913ab42ac Mon Sep 17 00:00:00 2001 From: Tony Walmsley Date: Mon, 5 Dec 2022 10:27:49 +0000 Subject: [PATCH 1/5] Remove schema validation, rename methods, fix tests and examples. --- README.md | 153 +++--- package-lock.json | 767 ++++++++++++++++------------- package.json | 11 +- src/client.ts | 261 +--------- src/context.ts | 12 - src/dnsclient.ts | 2 +- src/exceptions.ts | 4 - src/hashutils.ts | 2 +- src/resourceloader.ts | 2 +- test/DefaultLocale.test.ts | 48 -- test/TransformationMapFile.test.ts | 38 -- test/index.html | 161 +++--- 12 files changed, 610 insertions(+), 851 deletions(-) delete mode 100644 test/DefaultLocale.test.ts delete mode 100644 test/TransformationMapFile.test.ts diff --git a/README.md b/README.md index 065a6c8..e425646 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,6 @@ const lookup = async () => { const numUri = parseNumUri('num.uk:1'); // Parse the NUM URI const client = createClient(); // Create a NumClient const ctx = client.createContext(numUri); // Set the lookup context - ctx.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) const result = await client.retrieveNumRecord(ctx); // Use the context to retrieve a NUM record console.log(result); // Handle the result } @@ -83,8 +82,6 @@ const lookup = async () => { const ctx1 = client.createContext(numUri1); const ctx2 = client.createContext(numUri2); - ctx1.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) - ctx2.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) const result1 = client.retrieveNumRecord(ctx1); const result2 = client.retrieveNumRecord(ctx2); @@ -116,10 +113,6 @@ const lookup = async () => { const numUri = parseNumUri('num.uk:1'); // Parse the NUM URI const client = createClient(); // Create a NumClient const ctx = client.createContext(numUri); // Set the lookup context - ctx.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) - - ctx.setUserVariable('_L', 'en'); // Set the user's language - ctx.setUserVariable('_C', 'gb'); // Set the user's country const result = await client.retrieveNumRecord(ctx); // Use the context to retrieve a NUM record console.log(result) // Handle the result @@ -132,7 +125,6 @@ const lookup = async () => { const numUri = parseNumUri('num.uk:1'); // Parse the NUM URI const client = createClient(); // Create a NumClient const ctx = client.createContext(numUri); // Set the lookup context - ctx.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) const handler: CallbackHandler = { setLocation: (l: NumLocation): void => { @@ -181,14 +173,6 @@ function lookup(uri1, uri2) { const ctx1 = client.createContext(numUri1); const ctx2 = client.createContext(numUri2); - ctx1.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) - ctx2.setTargetExpandedSchemaVersion('2'); // Set the required expanded schema version (specific to each module but defaults to 1) - - ctx1.setUserVariable('_L', 'en'); // Set the user's language - ctx1.setUserVariable('_C', 'gb'); // Set the user's country - - ctx2.setUserVariable('_L', 'en'); // Set the user's language - ctx2.setUserVariable('_C', 'us'); // Set the user's country const handler = { // Provide a custom CallbackHandler setLocation: (l) => { @@ -218,57 +202,102 @@ This simple example can be modified as necessary by following the previous examp ```html - - - - NUM Protocol Example - - - - -

NUM Protocol Example

-
- NUM URI = - -
-
-

-  
- +

NUM Protocol Example

+
+ NUM URI = + +
+
+ + + +
+
+ + + +
+
+

+    
+ - + function setResultType() { + type = document.getElementById('recType').value; + reloadRecord(); + } + function setEnvironment() { + const e = document.getElementById('env').value; + client.setDnsEnv(e); + client.setModuleEnv(e); + client.setenv(e); + reloadRecord(); + } + + + ``` diff --git a/package-lock.json b/package-lock.json index 284d0a5..fde2dcb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,19 @@ { "name": "num-client", - "version": "3.0.5", + "version": "4.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "num-client", - "version": "3.0.5", + "version": "4.0.0", "license": "Apache-2.0", "dependencies": { - "ajv": "^8.0.3", - "ajv-formats": "^2.1.1", "any-base": "^1.1.0", - "axios": "0.21.1", + "axios": "^0.21.4", "delay": "^4.4.0", "modl-interpreter": "0.0.20", - "object-unpacker": "1.0.2", + "num-easy-log": "^0.0.2", "process": "^0.11.10", "punycode": "^2.1.1", "sha1": "^1.1.1", @@ -26,6 +24,7 @@ "@types/chai": "^4.2.11", "@types/mocha": "^7.0.2", "@types/node": "^14.0.13", + "@types/sha1": "^1.1.3", "@typescript-eslint/eslint-plugin": "^4.7.0", "@typescript-eslint/eslint-plugin-tslint": "^4.7.0", "@typescript-eslint/parser": "^4.7.0", @@ -38,7 +37,7 @@ "eslint-plugin-prefer-arrow": "^1.2.2", "eslint-plugin-prettier": "^3.1.4", "imports-loader": "^2.0.0", - "mocha": "^8.1.3", + "mocha": "^10.1.0", "prettier": "^2.1.2", "ts-loader": "^7.0.5", "ts-node": "^8.10.2", @@ -182,6 +181,64 @@ "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", "dev": true }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", + "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", @@ -279,6 +336,15 @@ "integrity": "sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==", "dev": true }, + "node_modules/@types/sha1": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@types/sha1/-/sha1-1.1.3.tgz", + "integrity": "sha512-bXfx/6xrPu1l6pLItGRMPX00lhnJavpj2qiQeLHflXvL2Ix97aC8FTF2/pQoqukRzcCwKyN3csZvOLzamIoaSA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.7.0.tgz", @@ -420,12 +486,6 @@ "node": "^8.10.0 || ^10.13.0 || >=11.10.1" } }, - "node_modules/@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true - }, "node_modules/@webassemblyjs/ast": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz", @@ -654,6 +714,7 @@ "version": "8.0.3", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.0.3.tgz", "integrity": "sha512-Df6NAivu9KpZw+q8ySijAgLvr1mUA5ihkRvCLCxpdYR21ann5yIuN+PpFxmweSj7i3yjJ0x5LN5KVs0RRzskAQ==", + "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -661,22 +722,6 @@ "uri-js": "^4.2.2" } }, - "node_modules/ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", - "dependencies": { - "ajv": "^8.0.0" - }, - "peerDependencies": { - "ajv": "^8.0.0" - }, - "peerDependenciesMeta": { - "ajv": { - "optional": true - } - } - }, "node_modules/ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", @@ -692,15 +737,6 @@ "node": ">=6" } }, - "node_modules/ansi-regex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", - "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -719,9 +755,9 @@ "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==" }, "node_modules/anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", "dev": true, "dependencies": { "normalize-path": "^3.0.0", @@ -782,11 +818,11 @@ } }, "node_modules/axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", "dependencies": { - "follow-redirects": "^1.10.0" + "follow-redirects": "^1.14.0" } }, "node_modules/balanced-match": { @@ -1006,24 +1042,30 @@ } }, "node_modules/chokidar": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", - "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], "dependencies": { - "anymatch": "~3.1.1", + "anymatch": "~3.1.2", "braces": "~3.0.2", - "glob-parent": "~5.1.0", + "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", - "readdirp": "~3.5.0" + "readdirp": "~3.6.0" }, "engines": { "node": ">= 8.10.0" }, "optionalDependencies": { - "fsevents": "~2.3.1" + "fsevents": "~2.3.2" } }, "node_modules/chrome-trace-event": { @@ -1175,9 +1217,9 @@ } }, "node_modules/debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -1758,7 +1800,8 @@ "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "node_modules/fast-diff": { "version": "1.2.0", @@ -1796,9 +1839,9 @@ "dev": true }, "node_modules/fast-redact": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.1.0.tgz", - "integrity": "sha512-dir8LOnvialLxiXDPESMDHGp82CHi6ZEYTVkcvdn5d7psdv9ZkkButXrOeXST4aqreIRR+N7CYlsrwFuorurVg==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.1.2.tgz", + "integrity": "sha512-+0em+Iya9fKGfEQGcd62Yv6onjBmmhV1uh86XVfOU8VwAe6kaFdQCWI9s0/Nnugx5Vd9tdbZ7e6gE2tR9dzXdw==", "engines": { "node": ">=6" } @@ -1968,9 +2011,9 @@ } }, "node_modules/glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", @@ -1982,6 +2025,9 @@ }, "engines": { "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/glob-parent": { @@ -2049,15 +2095,6 @@ "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true }, - "node_modules/growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true, - "engines": { - "node": ">=4.x" - } - }, "node_modules/gzip-size": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz", @@ -2195,9 +2232,9 @@ } }, "node_modules/imports-loader/node_modules/loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", "dev": true, "dependencies": { "big.js": "^5.2.2", @@ -2262,15 +2299,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/is-glob": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", @@ -2322,6 +2350,18 @@ "node": ">=8" } }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -2397,7 +2437,8 @@ "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -2449,9 +2490,9 @@ } }, "node_modules/loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz", + "integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==", "dev": true, "dependencies": { "big.js": "^5.2.2", @@ -2499,15 +2540,19 @@ "dev": true }, "node_modules/log-symbols": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", - "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, "dependencies": { - "chalk": "^4.0.0" + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" }, "engines": { "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/make-error": { @@ -2588,9 +2633,9 @@ } }, "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -2618,43 +2663,39 @@ } }, "node_modules/mocha": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz", - "integrity": "sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", + "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", "dev": true, "dependencies": { - "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.1", - "debug": "4.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.1.6", - "growl": "1.10.5", + "glob": "7.2.0", "he": "1.2.0", - "js-yaml": "4.0.0", - "log-symbols": "4.0.0", - "minimatch": "3.0.4", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.1.20", - "serialize-javascript": "5.0.1", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", - "which": "2.0.2", - "wide-align": "1.1.3", - "workerpool": "6.1.0", + "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" }, "bin": { "_mocha": "bin/_mocha", - "mocha": "bin/mocha" + "mocha": "bin/mocha.js" }, "engines": { - "node": ">= 10.12.0" + "node": ">= 14.0.0" }, "funding": { "type": "opencollective", @@ -2667,6 +2708,15 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/mocha/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/mocha/node_modules/diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -2686,9 +2736,9 @@ } }, "node_modules/mocha/node_modules/js-yaml": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", - "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "dependencies": { "argparse": "^2.0.1" @@ -2697,12 +2747,33 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/mocha/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/mocha/node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, "node_modules/mocha/node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -2747,9 +2818,9 @@ "dev": true }, "node_modules/nanoid": { - "version": "3.1.20", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", - "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", "dev": true, "bin": { "nanoid": "bin/nanoid.cjs" @@ -2805,14 +2876,6 @@ "pino": "^7.6.5" } }, - "node_modules/object-unpacker": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/object-unpacker/-/object-unpacker-1.0.2.tgz", - "integrity": "sha512-ESE0RJKiNO7D/T4vU+r9wT06Z8fP6Tc99vmZ+G6pZ88gJzJyDNr1Y3/XHvGAnw81Jk6DmmPgHdjTokVqCoO+8w==", - "dependencies": { - "num-easy-log": "^0.0.2" - } - }, "node_modules/on-exit-leak-free": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz", @@ -2973,10 +3036,11 @@ } }, "node_modules/pino": { - "version": "7.6.5", - "resolved": "https://registry.npmjs.org/pino/-/pino-7.6.5.tgz", - "integrity": "sha512-38tAwlJ7HevMENHD5FZE+yxSlAH5Wg3FoOjbB3MX2j3/kgpOEkmDHhTVKkecR57qxD5doHo2yi9nac94gqqbiQ==", + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-7.11.0.tgz", + "integrity": "sha512-dMACeu63HtRLmCG8VKdy4cShCPKaYDR4youZqoSWLxl5Gu99HUw8bw75thbPv9Nip+H+QYX8o3ZJbTdVZZ2TVg==", "dependencies": { + "atomic-sleep": "^1.0.0", "fast-redact": "^3.0.0", "on-exit-leak-free": "^0.2.0", "pino-abstract-transport": "v0.5.0", @@ -2986,7 +3050,7 @@ "real-require": "^0.1.0", "safe-stable-stringify": "^2.1.0", "sonic-boom": "^2.2.1", - "thread-stream": "^0.13.0" + "thread-stream": "^0.15.1" }, "bin": { "pino": "bin.js" @@ -3184,9 +3248,9 @@ } }, "node_modules/readdirp": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", - "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "dev": true, "dependencies": { "picomatch": "^2.2.1" @@ -3246,6 +3310,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -3326,9 +3391,9 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/safe-stable-stringify": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz", - "integrity": "sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.1.tgz", + "integrity": "sha512-dVHE6bMtS/bnL2mwualjc6IxEv1F+OCUpA46pKUj6F8uDbUM0jCCulPqRNPSnWwGNKx5etqMjZYdXtrm5KJZGA==", "engines": { "node": ">=10" } @@ -3526,9 +3591,9 @@ } }, "node_modules/sonic-boom": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.6.0.tgz", - "integrity": "sha512-6xYZFRmDEtxGqfOKcDQ4cPLrNa0SPEDI+wlzDAHowXE6YV42NeXqg9mP2KkiM8JVu3lHfZ2iQKYlGOz+kTpphg==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.8.0.tgz", + "integrity": "sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==", "dependencies": { "atomic-sleep": "^1.0.0" } @@ -3549,9 +3614,9 @@ } }, "node_modules/source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, "dependencies": { "buffer-from": "^1.0.0", @@ -3607,31 +3672,6 @@ "safe-buffer": "~5.1.0" } }, - "node_modules/string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "dependencies": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "dependencies": { - "ansi-regex": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/strip-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-comments/-/strip-comments-2.0.1.tgz", @@ -3745,14 +3785,15 @@ } }, "node_modules/terser": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.6.1.tgz", - "integrity": "sha512-yv9YLFQQ+3ZqgWCUk+pvNJwgUTdlIxUk1WTN+RnaFJe2L7ipG2csPT0ra2XRm7Cs8cxN7QXmK1rFzEwYEQkzXw==", + "version": "5.16.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.1.tgz", + "integrity": "sha512-xvQfyfA1ayT0qdK47zskQgRZeWLoOQ8JQ6mIgRGVNwZKdQMU+5FkCBjmv4QjcrTzyZquRw2FVtlJSRUmMKQslw==", "dev": true, "dependencies": { + "@jridgewell/source-map": "^0.3.2", + "acorn": "^8.5.0", "commander": "^2.20.0", - "source-map": "~0.7.2", - "source-map-support": "~0.5.19" + "source-map-support": "~0.5.20" }, "bin": { "terser": "bin/terser" @@ -3790,13 +3831,16 @@ "node": ">=10" } }, - "node_modules/terser/node_modules/source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "node_modules/terser/node_modules/acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true, + "bin": { + "acorn": "bin/acorn" + }, "engines": { - "node": ">= 8" + "node": ">=0.4.0" } }, "node_modules/text-table": { @@ -3806,9 +3850,9 @@ "dev": true }, "node_modules/thread-stream": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.13.1.tgz", - "integrity": "sha512-+KNCqNxOSwYfXLtCIRDKQq29x9jvqnOFjYCPdB38sf4pT3QanPSNc8vRqMj+Q3z4tYIctb5opNZrMK/GwmgsAQ==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", + "integrity": "sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA==", "dependencies": { "real-require": "^0.1.0" } @@ -4136,6 +4180,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "dependencies": { "punycode": "^2.1.0" } @@ -4393,15 +4438,6 @@ "node": ">= 8" } }, - "node_modules/wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "dev": true, - "dependencies": { - "string-width": "^1.0.2 || 2" - } - }, "node_modules/wildcard": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.0.tgz", @@ -4418,9 +4454,9 @@ } }, "node_modules/workerpool": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz", - "integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "node_modules/wrap-ansi": { @@ -4772,6 +4808,55 @@ "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", "dev": true }, + "@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true + }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true + }, + "@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", + "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" + } + }, "@nodelib/fs.scandir": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", @@ -4860,6 +4945,15 @@ "integrity": "sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==", "dev": true }, + "@types/sha1": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@types/sha1/-/sha1-1.1.3.tgz", + "integrity": "sha512-bXfx/6xrPu1l6pLItGRMPX00lhnJavpj2qiQeLHflXvL2Ix97aC8FTF2/pQoqukRzcCwKyN3csZvOLzamIoaSA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@typescript-eslint/eslint-plugin": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.7.0.tgz", @@ -4969,12 +5063,6 @@ "eslint-visitor-keys": "^2.0.0" } }, - "@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true - }, "@webassemblyjs/ast": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.0.tgz", @@ -5179,6 +5267,7 @@ "version": "8.0.3", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.0.3.tgz", "integrity": "sha512-Df6NAivu9KpZw+q8ySijAgLvr1mUA5ihkRvCLCxpdYR21ann5yIuN+PpFxmweSj7i3yjJ0x5LN5KVs0RRzskAQ==", + "dev": true, "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -5186,14 +5275,6 @@ "uri-js": "^4.2.2" } }, - "ajv-formats": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz", - "integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==", - "requires": { - "ajv": "^8.0.0" - } - }, "ajv-keywords": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", @@ -5206,12 +5287,6 @@ "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", "dev": true }, - "ansi-regex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", - "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true - }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -5227,9 +5302,9 @@ "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==" }, "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", "dev": true, "requires": { "normalize-path": "^3.0.0", @@ -5275,11 +5350,11 @@ "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==" }, "axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", "requires": { - "follow-redirects": "^1.10.0" + "follow-redirects": "^1.14.0" } }, "balanced-match": { @@ -5441,19 +5516,19 @@ "dev": true }, "chokidar": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", - "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", "dev": true, "requires": { - "anymatch": "~3.1.1", + "anymatch": "~3.1.2", "braces": "~3.0.2", - "fsevents": "~2.3.1", - "glob-parent": "~5.1.0", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", - "readdirp": "~3.5.0" + "readdirp": "~3.6.0" } }, "chrome-trace-event": { @@ -5580,9 +5655,9 @@ "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=" }, "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -6024,7 +6099,8 @@ "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true }, "fast-diff": { "version": "1.2.0", @@ -6059,9 +6135,9 @@ "dev": true }, "fast-redact": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.1.0.tgz", - "integrity": "sha512-dir8LOnvialLxiXDPESMDHGp82CHi6ZEYTVkcvdn5d7psdv9ZkkButXrOeXST4aqreIRR+N7CYlsrwFuorurVg==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.1.2.tgz", + "integrity": "sha512-+0em+Iya9fKGfEQGcd62Yv6onjBmmhV1uh86XVfOU8VwAe6kaFdQCWI9s0/Nnugx5Vd9tdbZ7e6gE2tR9dzXdw==" }, "fastest-levenshtein": { "version": "1.0.12", @@ -6177,9 +6253,9 @@ "dev": true }, "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -6242,12 +6318,6 @@ "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, "gzip-size": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz", @@ -6339,9 +6409,9 @@ } }, "loader-utils": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", - "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", "dev": true, "requires": { "big.js": "^5.2.2", @@ -6393,12 +6463,6 @@ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, "is-glob": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", @@ -6435,6 +6499,12 @@ "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", "dev": true }, + "is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -6495,7 +6565,8 @@ "json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -6535,9 +6606,9 @@ "dev": true }, "loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz", + "integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==", "dev": true, "requires": { "big.js": "^5.2.2", @@ -6579,12 +6650,13 @@ "dev": true }, "log-symbols": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", - "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, "requires": { - "chalk": "^4.0.0" + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" } }, "make-error": { @@ -6647,9 +6719,9 @@ "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" @@ -6671,33 +6743,29 @@ } }, "mocha": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz", - "integrity": "sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", + "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", "dev": true, "requires": { - "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.1", - "debug": "4.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.1.6", - "growl": "1.10.5", + "glob": "7.2.0", "he": "1.2.0", - "js-yaml": "4.0.0", - "log-symbols": "4.0.0", - "minimatch": "3.0.4", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.1.20", - "serialize-javascript": "5.0.1", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", - "which": "2.0.2", - "wide-align": "1.1.3", - "workerpool": "6.1.0", + "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" @@ -6709,6 +6777,15 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, "diff": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", @@ -6722,20 +6799,38 @@ "dev": true }, "js-yaml": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", - "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "requires": { "argparse": "^2.0.1" } }, + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, "ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -6773,9 +6868,9 @@ "dev": true }, "nanoid": { - "version": "3.1.20", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", - "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", "dev": true }, "natural-compare": { @@ -6819,14 +6914,6 @@ "pino": "^7.6.5" } }, - "object-unpacker": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/object-unpacker/-/object-unpacker-1.0.2.tgz", - "integrity": "sha512-ESE0RJKiNO7D/T4vU+r9wT06Z8fP6Tc99vmZ+G6pZ88gJzJyDNr1Y3/XHvGAnw81Jk6DmmPgHdjTokVqCoO+8w==", - "requires": { - "num-easy-log": "^0.0.2" - } - }, "on-exit-leak-free": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz", @@ -6945,10 +7032,11 @@ "dev": true }, "pino": { - "version": "7.6.5", - "resolved": "https://registry.npmjs.org/pino/-/pino-7.6.5.tgz", - "integrity": "sha512-38tAwlJ7HevMENHD5FZE+yxSlAH5Wg3FoOjbB3MX2j3/kgpOEkmDHhTVKkecR57qxD5doHo2yi9nac94gqqbiQ==", + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-7.11.0.tgz", + "integrity": "sha512-dMACeu63HtRLmCG8VKdy4cShCPKaYDR4youZqoSWLxl5Gu99HUw8bw75thbPv9Nip+H+QYX8o3ZJbTdVZZ2TVg==", "requires": { + "atomic-sleep": "^1.0.0", "fast-redact": "^3.0.0", "on-exit-leak-free": "^0.2.0", "pino-abstract-transport": "v0.5.0", @@ -6958,7 +7046,7 @@ "real-require": "^0.1.0", "safe-stable-stringify": "^2.1.0", "sonic-boom": "^2.2.1", - "thread-stream": "^0.13.0" + "thread-stream": "^0.15.1" } }, "pino-abstract-transport": { @@ -7112,9 +7200,9 @@ } }, "readdirp": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", - "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", "dev": true, "requires": { "picomatch": "^2.2.1" @@ -7155,7 +7243,8 @@ "require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true }, "resolve": { "version": "1.17.0", @@ -7216,9 +7305,9 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "safe-stable-stringify": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz", - "integrity": "sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg==" + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.1.tgz", + "integrity": "sha512-dVHE6bMtS/bnL2mwualjc6IxEv1F+OCUpA46pKUj6F8uDbUM0jCCulPqRNPSnWwGNKx5etqMjZYdXtrm5KJZGA==" }, "sanitize-filename": { "version": "1.6.3", @@ -7375,9 +7464,9 @@ } }, "sonic-boom": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.6.0.tgz", - "integrity": "sha512-6xYZFRmDEtxGqfOKcDQ4cPLrNa0SPEDI+wlzDAHowXE6YV42NeXqg9mP2KkiM8JVu3lHfZ2iQKYlGOz+kTpphg==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.8.0.tgz", + "integrity": "sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==", "requires": { "atomic-sleep": "^1.0.0" } @@ -7395,9 +7484,9 @@ "dev": true }, "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -7450,25 +7539,6 @@ "safe-buffer": "~5.1.0" } }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - }, "strip-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-comments/-/strip-comments-2.0.1.tgz", @@ -7551,20 +7621,21 @@ "dev": true }, "terser": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.6.1.tgz", - "integrity": "sha512-yv9YLFQQ+3ZqgWCUk+pvNJwgUTdlIxUk1WTN+RnaFJe2L7ipG2csPT0ra2XRm7Cs8cxN7QXmK1rFzEwYEQkzXw==", + "version": "5.16.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.1.tgz", + "integrity": "sha512-xvQfyfA1ayT0qdK47zskQgRZeWLoOQ8JQ6mIgRGVNwZKdQMU+5FkCBjmv4QjcrTzyZquRw2FVtlJSRUmMKQslw==", "dev": true, "requires": { + "@jridgewell/source-map": "^0.3.2", + "acorn": "^8.5.0", "commander": "^2.20.0", - "source-map": "~0.7.2", - "source-map-support": "~0.5.19" + "source-map-support": "~0.5.20" }, "dependencies": { - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true } } @@ -7601,9 +7672,9 @@ "dev": true }, "thread-stream": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.13.1.tgz", - "integrity": "sha512-+KNCqNxOSwYfXLtCIRDKQq29x9jvqnOFjYCPdB38sf4pT3QanPSNc8vRqMj+Q3z4tYIctb5opNZrMK/GwmgsAQ==", + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", + "integrity": "sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA==", "requires": { "real-require": "^0.1.0" } @@ -7849,6 +7920,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "requires": { "punycode": "^2.1.0" } @@ -8040,15 +8112,6 @@ "isexe": "^2.0.0" } }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "dev": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, "wildcard": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.0.tgz", @@ -8062,9 +8125,9 @@ "dev": true }, "workerpool": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz", - "integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "wrap-ansi": { diff --git a/package.json b/package.json index 329db7a..94d8cbb 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,15 @@ { "name": "num-client", - "version": "3.0.5", + "version": "4.0.0", "description": "A NUM Protocol Client in TypeScript", "main": "dist/index.js", "types": "dist/index.d.ts", "dependencies": { - "ajv": "^8.0.3", - "ajv-formats": "^2.1.1", "any-base": "^1.1.0", - "axios": "0.21.1", + "axios": "^0.21.4", "delay": "^4.4.0", "modl-interpreter": "0.0.20", - "object-unpacker": "1.0.2", + "num-easy-log": "^0.0.2", "process": "^0.11.10", "punycode": "^2.1.1", "sha1": "^1.1.1", @@ -22,6 +20,7 @@ "@types/chai": "^4.2.11", "@types/mocha": "^7.0.2", "@types/node": "^14.0.13", + "@types/sha1": "^1.1.3", "@typescript-eslint/eslint-plugin": "^4.7.0", "@typescript-eslint/eslint-plugin-tslint": "^4.7.0", "@typescript-eslint/parser": "^4.7.0", @@ -34,7 +33,7 @@ "eslint-plugin-prefer-arrow": "^1.2.2", "eslint-plugin-prettier": "^3.1.4", "imports-loader": "^2.0.0", - "mocha": "^8.1.3", + "mocha": "^10.1.0", "prettier": "^2.1.2", "ts-loader": "^7.0.5", "ts-node": "^8.10.2", diff --git a/src/client.ts b/src/client.ts index 651b8e9..e92e2b1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Ajv from 'ajv'; -import addFormats from 'ajv-formats'; -import { mapper } from 'object-unpacker'; -import { Context, NumLocation, UserVariable } from './context'; +import { Context, NumLocation } from './context'; import { DoHResolver } from './dnsclient'; import { createDnsServices, DnsServices } from './dnsservices'; import { @@ -23,17 +20,14 @@ import { NumLookupEmptyResult, NumLookupRedirect, NumMaximumRedirectsExceededException, - NumNotImplementedException, NumProtocolErrorCode, NumProtocolException, } from './exceptions'; import { setenvDomainLookups } from './lookupgenerators'; import { createLookupLocationStateMachine } from './lookupstatemachine'; import { createModlServices, ModlServices } from './modlservices'; -import { createModuleConfigProvider, ModuleConfig, ModuleConfigProvider, SubstitutionsType } from './moduleconfig'; -import { NumUri, parseNumUri, PositiveInteger } from './numuri'; +import { NumUri, parseNumUri } from './numuri'; import { createResourceLoader, ResourceLoader } from './resourceloader'; -import { AxiosResponse } from 'axios'; import { log } from 'num-easy-log'; //------------------------------------------------------------------------------------------------------------------------ @@ -55,7 +49,7 @@ export const lookup = (uri: string): Promise => { const client: NumClient = createClient(); const ctx = client.createContext(numUri); - return client.retrieveNumRecord(ctx); + return client.retrieveNumRecordJson(ctx); }; /** @@ -76,7 +70,7 @@ export interface NumClient { * @param handler * @returns num record */ - retrieveNumRecord(ctx: Context, handler?: CallbackHandler): Promise; + retrieveNumRecordJson(ctx: Context, handler?: CallbackHandler): Promise; /** * Returns the raw MODL record, after redirection if appropriate @@ -85,7 +79,7 @@ export interface NumClient { * @param handler * @returns MODL record */ - retrieveModlRecord(ctx: Context, handler?: CallbackHandler): Promise; + retrieveNumRecord(ctx: Context, handler?: CallbackHandler): Promise; /** * @@ -100,7 +94,7 @@ export interface NumClient { * @param userVariables a Map of user-supplied values such as 'C' and 'L' for country and language respectively. * @param targetExpandedVersion the version number of the required expanded schema, as a string value. */ - interpret(modl: string, moduleNumber: PositiveInteger, userVariables: Map, targetExpandedVersion: string): Promise; + interpret(modl: string): string | null; /** * Set the execution environment. @@ -133,11 +127,6 @@ export interface NumClient { * @param t the DoH request timeout in milliseconds */ setTimeoutMillis(t: number): void; - - /** - * Required by chrome browser extensions. - */ - disableSchemaValidation(): void; } /** @@ -175,19 +164,8 @@ export const createDefaultCallbackHandler = (): CallbackHandler => new DefaultCa // Internals //------------------------------------------------------------------------------------------------------------------------ -const DEFAULT_BASE_URL = 'https://modules.numprotocol.com/'; -const DEFAULT_LANGUAGE = 'en'; -const DEFAULT_COUNTRY = 'us'; -const DEFAULT_LOCALE_FILE_NAME = 'en-us.json'; const DNS_REQUEST_TIMEOUT_MS = 500; -const expandedSchemaPathComponent = 'expanded'; -const compactSchemaPathComponent = 'compact'; - -const ajv = new Ajv({ strict: false }); -// eslint-disable-next-line @typescript-eslint/no-unsafe-call -addFormats(ajv); - const DEFAULT_RESOLVERS = [new DoHResolver('Cloudflare', 'https://cloudflare-dns.com/dns-query'), new DoHResolver('Google', 'https://dns.google.com/resolve')]; //------------------------------------------------------------------------------------------------------------------------ @@ -261,9 +239,7 @@ export class DefaultCallbackHandler implements CallbackHandler { class NumClientImpl implements NumClient { readonly dnsServices: DnsServices; readonly modlServices: ModlServices; - private configProvider: ModuleConfigProvider; private resourceLoader: ResourceLoader; - private schemaValidationIsDisabled: boolean; /** * Creates an instance of num client impl. @@ -271,20 +247,11 @@ class NumClientImpl implements NumClient { * @param [dnsClient] */ constructor(resolvers?: Array) { - this.schemaValidationIsDisabled = false; this.dnsServices = resolvers && resolvers.length > 0 ? createDnsServices(DNS_REQUEST_TIMEOUT_MS, resolvers) : createDnsServices(DNS_REQUEST_TIMEOUT_MS, DEFAULT_RESOLVERS); this.modlServices = createModlServices(); this.resourceLoader = createResourceLoader(); - this.configProvider = createModuleConfigProvider(this.resourceLoader); - } - - /** - * Required by chrome browser extensions. - */ - disableSchemaValidation(): void { - this.schemaValidationIsDisabled = true; } /** @@ -293,7 +260,6 @@ class NumClientImpl implements NumClient { */ setResourceLoader(loader: ResourceLoader): void { this.resourceLoader = loader; - this.configProvider = createModuleConfigProvider(this.resourceLoader); } /** @@ -348,12 +314,12 @@ class NumClientImpl implements NumClient { * @param handler * @returns num record */ - async retrieveNumRecord(ctx: Context, handler?: CallbackHandler): Promise { + async retrieveNumRecordJson(ctx: Context, handler?: CallbackHandler): Promise { while (true) { try { const modl = await this.retrieveModlRecordInternal(ctx); if (modl) { - const json = await this.interpret(modl, ctx.numAddress.port, ctx.userVariables, ctx.targetExpandedSchemaVersion); + const json = this.interpret(modl); if (json) { log.debug(`json = ${json}`); if (handler) { @@ -409,7 +375,7 @@ class NumClientImpl implements NumClient { * @param handler * @returns modl record */ - async retrieveModlRecord(ctx: Context, handler?: CallbackHandler): Promise { + async retrieveNumRecord(ctx: Context, handler?: CallbackHandler): Promise { while (true) { try { const modl = await this.retrieveModlRecordInternal(ctx); @@ -493,80 +459,14 @@ class NumClientImpl implements NumClient { * Interprets a MODL record for the given module * * @param modl - * @param moduleNumber - * @param userVariables - * @returns interpret + * @returns json */ // eslint-disable-next-line complexity - public async interpret( - modl: string, - moduleNumber: PositiveInteger, - userVariables: Map, - targetExpandedVersion: string - ): Promise { + public interpret(modl: string): string | null { // Interpret the MODL - let jsonResult = this.modlServices.interpretNumRecord(modl); + const jsonResult = this.modlServices.interpretNumRecord(modl); log.debug(`Interpreter raw JSON result: ${JSON.stringify(jsonResult)}`); - if (moduleNumber.n !== 0) { - // Process the resulting JSON according to the config.json file - const moduleConfig = await this.configProvider.getConfig(moduleNumber); - if (moduleConfig) { - const compactVersion: string = jsonResult['@v'] ? `${jsonResult['@v'] as number}` : '1'; - - // Validate the compact schema if there is one and if the config says we should - if (moduleConfig.compactSchema && !this.schemaValidationIsDisabled) { - // load the schema and use it to validate jsonResult - if (!(await this.validateSchema(moduleNumber.n, compactSchemaPathComponent, compactVersion, jsonResult))) { - throw new NumProtocolException(NumProtocolErrorCode.compactSchemaError, 'The record does not match the compact schema'); - } - } else { - log.info('Not configured to validate against the compact schema.'); - } - - let substitutionsData: Record | null = {}; - // Apply the schema mapping and Resolve references if one is defined - if (moduleConfig.substitutions) { - // Attempt to load a substitutions file. - substitutionsData = await this.loadSubstitutionsFile(moduleConfig, userVariables); - if (!substitutionsData) { - throw new NumProtocolException( - NumProtocolErrorCode.substitutionsFileNotFoundError, - `Unable to locate a substitutions file using ${JSON.stringify(userVariables)}` - ); - } - } - - const schemaMapUrl = await this.generateSchemaMapUrl(moduleConfig, compactVersion, targetExpandedVersion); - const schemaMapResponse = await this.resourceLoader.load(schemaMapUrl); - - if (schemaMapResponse && schemaMapResponse.data) { - jsonResult = mapper.convert(substitutionsData, jsonResult as any, schemaMapResponse.data) as Record; - log.debug(`Object Unpacker JSON result: ${JSON.stringify(jsonResult)}`); - } else { - // No schema map - log.error(`Unable to load schema map defined in ${JSON.stringify(moduleConfig)}`); - throw new NumProtocolException(NumProtocolErrorCode.noUnpackerConfigFileFound, `Could not load the configured Unpacker config file: ${schemaMapUrl}`); - } - - // Validate the expanded schema if there is one and if the config says we should - if (moduleConfig.expandedSchema && !this.schemaValidationIsDisabled) { - if (!jsonResult['@version']) { - throw new NumProtocolException(NumProtocolErrorCode.missingExpandedSchemaVersion, JSON.stringify(jsonResult)); - } - const expandedVersion = `${jsonResult['@version'] as number}`; - // load the schema and use it to validate the expanded JSON - if (!(await this.validateSchema(moduleNumber.n, expandedSchemaPathComponent, expandedVersion, jsonResult))) { - throw new NumProtocolException(NumProtocolErrorCode.expandedSchemaError, 'The record does not match the expanded schema'); - } - } else { - log.info('Not configured to validate against the expanded schema.'); - } - } else { - log.error('No module config file available.'); - throw new NumProtocolException(NumProtocolErrorCode.moduleConfigFileNotFound, `Unable to load the module config file for module ${moduleNumber.n} `); - } - } return JSON.stringify(jsonResult); } @@ -611,145 +511,10 @@ class NumClientImpl implements NumClient { } else if (result.includes('error_')) { return false; } else { - ctx.result = await this.interpret(result, ctx.numAddress.port, ctx.userVariables, ctx.targetExpandedSchemaVersion); + ctx.result = this.interpret(result); return true; } } return false; } - - private async validateSchema(moduleNumber: number, schemaType: string, version: string, json: Record): Promise { - const schemaUrl = `${DEFAULT_BASE_URL}${moduleNumber}/${schemaType}/v${version}/schema.json`; - let existingSchema = ajv.getSchema(schemaUrl); - if (!existingSchema) { - const schema = await this.resourceLoader.load(schemaUrl); - - // Validate the schema if there is one - if (schema && schema.data) { - existingSchema = ajv.getSchema(schemaUrl) ? ajv.getSchema(schemaUrl) : ajv.compile(schema.data); - } else { - const msg = `Unable to load the JSON schema from : ${schemaUrl}`; - log.error(msg); - throw new NumProtocolException(NumProtocolErrorCode.schemaNotFound, msg); - } - } - if (!existingSchema) { - const msg = `Cannot find the JSON schema at ${schemaUrl}`; - log.error(msg); - throw new NumProtocolException(NumProtocolErrorCode.schemaNotFound, msg); - } - if (existingSchema(json)) { - log.info(`JSON matches the schema at ${schemaUrl}`); - return true; - } else { - log.error(`Fails to match the JSON schema at ${schemaUrl} - data: ${JSON.stringify(json)}`); - } - return false; - } - - private async loadSubstitutionsFile(moduleConfig: ModuleConfig, userVariables: Map): Promise | null> { - // Attempt to load a substitutions file. - let subsFileName = ''; - let subsFileResponse: AxiosResponse | null = null; - - if (moduleConfig.substitutionsType === SubstitutionsType.locale) { - let country = userVariables.get('_C')?.toString(); - let language = userVariables.get('_L')?.toString(); - if (!language) { - language = DEFAULT_LANGUAGE; - } - if (!country) { - country = DEFAULT_COUNTRY; - } - const localeFilename = `${language}-${country}.json`; - subsFileName = `${DEFAULT_BASE_URL}${moduleConfig.moduleId.n}/locales/${localeFilename}`; - - // Try loading the substitutions file and fallback to the default if we can't find one. - subsFileResponse = await this.resourceLoader.load(subsFileName); - - if (!subsFileResponse || !subsFileResponse.data) { - if (localeFilename === DEFAULT_LOCALE_FILE_NAME) { - log.debug(`Unable to load substitutions file: ${subsFileName}`); - return null; - } else { - const fallbackLocale = await this.generateFallbackLocaleFileName(moduleConfig, language); - subsFileResponse = await this.resourceLoader.load(fallbackLocale); - if (!subsFileResponse || !subsFileResponse.data) { - log.debug(`Unable to load substitutions file: ${fallbackLocale}`); - return null; - } - } - } - } else if (moduleConfig.substitutionsType === SubstitutionsType.standard) { - subsFileName = `${DEFAULT_BASE_URL}${moduleConfig.moduleId.n}/substitutions.json`; - - subsFileResponse = await this.resourceLoader.load(subsFileName); - - if (!subsFileResponse || !subsFileResponse.data) { - log.debug(`Unable to load substitutions file: ${subsFileName}`); - return null; - } - } else { - throw new NumNotImplementedException(`Unknown substitutionsType value: ${JSON.stringify(moduleConfig.substitutionsType)}`); - } - return subsFileResponse.data as Record; - } - - private async generateSchemaMapUrl(moduleConfig: ModuleConfig, compactVersion: string, targetExpandedVersion: string): Promise { - const mapJsonUrl = `${DEFAULT_BASE_URL}${moduleConfig.moduleId.n}/transformation/map.json`; - const mapJson = await this.resourceLoader.load(mapJsonUrl); - if (!mapJson || !mapJson.data) { - throw new NumProtocolException(NumProtocolErrorCode.missingTransformationsMap, `No map.json available at ${mapJsonUrl}`); - } - - return mapJsonToTransformationFileName(moduleConfig.moduleId.n, mapJson.data as Record, compactVersion, targetExpandedVersion); - } - - private async generateFallbackLocaleFileName(moduleConfig: ModuleConfig, lang: string): Promise { - const listJsonUrl = `${DEFAULT_BASE_URL}${moduleConfig.moduleId.n}/locales/list.json`; - const listJson = await this.resourceLoader.load(listJsonUrl); - - if (listJson && listJson.data) { - return findFirstWithSameLanguage(listJson.data as Array, lang, moduleConfig); - } else { - throw new NumProtocolException( - NumProtocolErrorCode.missingLocalesList, - `No list.json file found for module ${moduleConfig.moduleId.n} at ${listJsonUrl}` - ); - } - } } - -export const mapJsonToTransformationFileName = ( - module: number, - mapJson: Record, - compactVersion: string, - targetExpandedVersion: string -): string => { - const c = mapJson[`compact-v${compactVersion}`] as Record>; - const e = c[`expanded-v${targetExpandedVersion}`]; - if (e) { - const transformationFileName: string = e['transformation-file']; - if (transformationFileName) { - return `${DEFAULT_BASE_URL}${module}/transformation/${transformationFileName}`; - } else { - throw new NumProtocolException( - NumProtocolErrorCode.invalidTargetExpandedSchemaForModule, - `Module: ${module} has no target expanded schema v${targetExpandedVersion} configured for compact schema version v${compactVersion}` - ); - } - } else { - throw new NumProtocolException( - NumProtocolErrorCode.invalidTargetExpandedSchemaForModule, - `Module: ${module} has no target expanded schema v${targetExpandedVersion} configured for compact schema version v${compactVersion}` - ); - } -}; - -export const findFirstWithSameLanguage = (listJson: string[], lang: string, moduleConfig: ModuleConfig): string => { - let found = listJson.find((v) => v.startsWith(lang)); - if (!found) { - found = 'en-us'; - } - return `${DEFAULT_BASE_URL}${moduleConfig.moduleId.n}/locales/${found}.json`; -}; diff --git a/src/context.ts b/src/context.ts index d78eaa4..30272e7 100644 --- a/src/context.ts +++ b/src/context.ts @@ -46,7 +46,6 @@ export class Context { public targetExpandedSchemaVersion: string; _queries: ModuleDnsQueries; redirectCount = 0; - userVariables: Map; /** * Dnssec is checked if this is `true` - NOT YET IMPLEMENTED */ @@ -60,7 +59,6 @@ export class Context { constructor(numAddress: NumUri) { this.numAddress = numAddress; this._queries = createModuleDnsQueries(numAddress.port, numAddress); - this.userVariables = new Map(); this.targetExpandedSchemaVersion = '1'; } @@ -72,16 +70,6 @@ export class Context { setTargetExpandedSchemaVersion(v: string): void { this.targetExpandedSchemaVersion = v; } - /** - * Sets user variable - * - * @param name - * @param value - */ - setUserVariable(name: string, value: UserVariable): void { - this.userVariables.set(name, value); - } - /** * Count redirects and return the current number of redirects. * diff --git a/src/dnsclient.ts b/src/dnsclient.ts index acc62e1..5dc1986 100755 --- a/src/dnsclient.ts +++ b/src/dnsclient.ts @@ -70,7 +70,7 @@ export interface DnsClient { * * @param t the timeout */ - setTimeout(t: number); + setTimeout(t: number): void; /** * diff --git a/src/exceptions.ts b/src/exceptions.ts index 60a6f8b..50c8f2e 100644 --- a/src/exceptions.ts +++ b/src/exceptions.ts @@ -200,10 +200,6 @@ export enum NumProtocolErrorCode { noModlRecordFound = 'NUM_RECORD_NOT_FOUND', schemaNotFound = 'SCHEMA_NOT_FOUND', badDoHResponse = 'DOH_SERVICE_ERROR', - missingExpandedSchemaVersion = 'EXPANDED_SCHEMA_VERSION_KEY_NOT_FOUND', - invalidTargetExpandedSchemaForModule = 'INVALID_TARGET_EXPANDED_SCHEMA_FOR_MODULE', - missingTransformationsMap = 'TRANSFORMATIONS_MAP_NOT_FOUND', - missingLocalesList = 'LOCALES_LIST_NOT_FOUND', } /** diff --git a/src/hashutils.ts b/src/hashutils.ts index c8e68cd..3058ec8 100644 --- a/src/hashutils.ts +++ b/src/hashutils.ts @@ -16,7 +16,7 @@ import sha1 from 'sha1'; // eslint-disable-next-line @typescript-eslint/no-var-requires -const anyBase = require('any-base'); +import anyBase from 'any-base'; type AnyBase = (s: string) => string; diff --git a/src/resourceloader.ts b/src/resourceloader.ts index 2ab7a39..becaffb 100644 --- a/src/resourceloader.ts +++ b/src/resourceloader.ts @@ -7,7 +7,7 @@ import { log } from 'num-easy-log'; //------------------------------------------------------------------------------------------------------------------------ export interface ResourceLoader { - setenv(env: string); + setenv(env: string): void; load(url: string): Promise | null>; } diff --git a/test/DefaultLocale.test.ts b/test/DefaultLocale.test.ts deleted file mode 100644 index 213ccc0..0000000 --- a/test/DefaultLocale.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { expect } from 'chai'; -import { createResourceLoader } from '../src/resourceloader'; -import { findFirstWithSameLanguage } from '../src/client'; -import { toModuleConfig } from '../src/moduleconfig'; -// Copyright 2020 NUM Technology Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -const loader = createResourceLoader(); - -describe('TransformationMapFile', () => { - it('should be able to generate a valid file path from a valid map.json', async () => { - const l = [ - "en-gb", - "en-us", - "fr-fr", - "fr-ca" - ]; - - const config = { - "module_id": 2, - "module_name": "Contacts", - "compact_schema": true, - "expanded_schema": true, - "substitutions": true, - "substitutions_type": "locale", - "track": "draft" - }; - - const mc = toModuleConfig(config); - expect(mc).not.null; - if (mc) { - expect(findFirstWithSameLanguage(l, 'en', mc)).equal('https://modules.numprotocol.com/2/locales/en-gb.json'); - expect(findFirstWithSameLanguage(l, 'xx', mc)).equal('https://modules.numprotocol.com/2/locales/en-us.json'); - expect(findFirstWithSameLanguage(l, 'fr', mc)).equal('https://modules.numprotocol.com/2/locales/fr-fr.json'); - } - }); -}); diff --git a/test/TransformationMapFile.test.ts b/test/TransformationMapFile.test.ts deleted file mode 100644 index 1908636..0000000 --- a/test/TransformationMapFile.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { expect } from 'chai'; -import { createResourceLoader } from '../src/resourceloader'; -import { mapJsonToTransformationFileName } from '../src/client'; -// Copyright 2020 NUM Technology Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -const loader = createResourceLoader(); - -describe('TransformationMapFile', () => { - it('should be able to generate a valid file path from a valid map.json', async () => { - const m = { - "compact-v1": { - "expanded-v1": { - "transformation-file": "c1-e1.json", - "unpacker-version": "0.0.18" - }, - "expanded-v2": { - "transformation-file": "c1-e2.json", - "unpacker-version": "0.0.18" - } - } - }; - - expect(mapJsonToTransformationFileName(1, m, '1', '1')).equal('https://modules.numprotocol.com/1/transformation/c1-e1.json'); - expect(mapJsonToTransformationFileName(2, m, '1', '2')).equal('https://modules.numprotocol.com/2/transformation/c1-e2.json'); - }); -}); diff --git a/test/index.html b/test/index.html index dfc9555..508c546 100644 --- a/test/index.html +++ b/test/index.html @@ -1,95 +1,100 @@ + + + NUM Protocol Example + - - - NUM Protocol Example - + + +

NUM Protocol Example

+
+ NUM URI = + +
+
+ - - -

NUM Protocol Example

-
- NUM URI = - -
-
- - -
-
- + +
+
+ - -
-
-

-  
- - + function setEnvironment() { + const e = document.getElementById('env').value; + client.setDnsEnv(e); + client.setModuleEnv(e); + client.setenv(e); + reloadRecord(); + } + + + - \ No newline at end of file From 7a530c97fc3234e5c58a53f56e5e650ba8f55564 Mon Sep 17 00:00:00 2001 From: Tony Walmsley Date: Mon, 5 Dec 2022 10:32:35 +0000 Subject: [PATCH 2/5] Removed TNUM code --- src/index.ts | 2 - src/lookupgenerators.ts | 177 +------------------------------ src/modulednsqueries.ts | 12 +-- test/TNUMLookupGenerator.test.ts | 76 ------------- 4 files changed, 3 insertions(+), 264 deletions(-) delete mode 100644 test/TNUMLookupGenerator.test.ts diff --git a/src/index.ts b/src/index.ts index 61b339b..fadc22d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,6 @@ import { NumProtocolErrorCode } from './exceptions'; import { createDomainLookupGenerator, createEmailLookupGenerator, - createTNUMLookupGenerator, createUrlLookupGenerator, normaliseDomainName, normalisePath, @@ -58,7 +57,6 @@ export { ModuleDnsQueries, transformBranch, normaliseDomainName, - createTNUMLookupGenerator, createDomainLookupGenerator, createEmailLookupGenerator, createUrlLookupGenerator, diff --git a/src/lookupgenerators.ts b/src/lookupgenerators.ts index 0f6c020..78e65fb 100644 --- a/src/lookupgenerators.ts +++ b/src/lookupgenerators.ts @@ -16,7 +16,7 @@ import punycode from 'punycode'; import { URL } from 'url'; import { NumBadUrlException, NumException, NumInvalidParameterException } from './exceptions'; import { hashByDepth } from './hashutils'; -import { Hostname, MODULE_0, NO_USER_INFO, NumUri, PositiveInteger, UrlUserInfo } from './numuri'; +import { Hostname, NO_USER_INFO, NumUri, PositiveInteger, UrlUserInfo } from './numuri'; import { log } from 'num-easy-log'; const _NUM = '._num.'; @@ -92,14 +92,6 @@ export const createEmailLookupGenerator = (numUri: NumUri): EmailLookupGenerator */ export const createUrlLookupGenerator = (numUri: NumUri): LookupGenerator => new UrlLookupGenerator(numUri); -/** - * Creates a TNUM lookup generator - * - * @param numId - * @returns TNUM lookup generator - */ -export const createTNUMLookupGenerator = (numUri: NumUri): LookupGenerator => new TNUMLookupGenerator(numUri); - //------------------------------------------------------------------------------------------------------------------------ // Internals //------------------------------------------------------------------------------------------------------------------------ @@ -487,170 +479,3 @@ class UrlLookupGenerator extends BaseLookupGenerator implements LookupGenerator } } } - -const NO_COUNTRY_CODE_MSG = 'No Country code defined for '; -/** - * TNUM lookup generator - */ -class TNUMLookupGenerator extends BaseLookupGenerator implements LookupGenerator { - constructor(numUri: NumUri) { - super(numUri); - - const branch = transformBranch(normalisePath(numUri.path.s)); - this._branch = branch !== '' ? punycode.toASCII(branch) : branch; - - if (this._branch !== branch) { - log.debug(`Query ${this._branch} punycode ${branch}`); - } - - this._numUri = this._numUri.withHost(new Hostname(normaliseDomainName(numUri.host.s))); - if (!Hostname.isValidTNUM(this._numUri.host.s)) { - throw new NumInvalidParameterException('Domain name is invalid for TNUM'); - } - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - getPopulatorLocation(_moduleNumber: PositiveInteger): string | null { - return null; - } - - getIndependentLocation(moduleNumber: PositiveInteger): string { - const result: string = this.getRootIndependentLocation(moduleNumber); - if (this._branch.length > 0) { - return this._branch + '.' + result; - } - return result; - } - - getHostedLocation(moduleNumber: PositiveInteger): string { - const result: string = this.getRootHostedLocation(moduleNumber); - if (this._branch.length > 0) { - return this._branch + '.' + result; - } - return result; - } - - getRootIndependentLocation(moduleNumber: PositiveInteger): string { - const countryCode: CountryCode | undefined = this.findCountryCode(this._numUri.host.s); - if (!countryCode) { - throw new NumInvalidParameterException(NO_COUNTRY_CODE_MSG + this._numUri.host.s); - } - return `${moduleNumber.n}${_NUM}${this.formatIndependentTNumDomain(countryCode, this._numUri.host.s)}.${countryCode.dnsRoot}.`; - } - - getRootHostedLocation(moduleNumber: PositiveInteger): string { - const countryCode: CountryCode | undefined = this.findCountryCode(this._numUri.host.s); - if (!countryCode) { - throw new NumInvalidParameterException(NO_COUNTRY_CODE_MSG + this._numUri.host.s); - } - - if (MappingPattern.sds === countryCode.mappingPattern) { - return `${moduleNumber.n}.${DNPREFIX}${this.formatHostedTNumDomain(countryCode, this._numUri.host.s)}.${countryCode.dnsRoot}.`; - } else { - return `${moduleNumber.n}.${DNPREFIX}${this.formatHostedTNumDomain(countryCode, this._numUri.host.s)}._t.${TLZ}.`; - } - } - - getRootIndependentLocationNoModuleNumber(addTrailingDot: boolean): string { - const countryCode: CountryCode | undefined = this.findCountryCode(this._numUri.host.s); - if (!countryCode) { - throw new NumInvalidParameterException(NO_COUNTRY_CODE_MSG + this._numUri.host.s); - } - - const result = `_num.${this.formatIndependentTNumDomain(countryCode, this._numUri.host.s)}.${countryCode.dnsRoot}`; - - if (addTrailingDot) { - return result + '.'; - } - return result; - } - - getRootHostedLocationNoModuleNumber(addTrailingDot: boolean): string { - const result = this.getRootHostedLocation(MODULE_0).substr(2); - if (addTrailingDot) { - return result; - } - return result.substr(0, result.length - 1); - } - - formatIndependentTNumDomain(code: CountryCode, domain: string): string { - const noIntlPrefix = domain.substr(code.code.length); - let result = ''; - switch (code.mappingPattern) { - case MappingPattern.bds: - result = this.mapBDS(noIntlPrefix); - result = reverse(result); - break; - case MappingPattern.sds: - result = this.mapSDS(noIntlPrefix); - break; - default: - throw new NumInvalidParameterException(`Bad enum value: ${code.mappingPattern as string}`); - } - return result; - } - - formatHostedTNumDomain(code: CountryCode, domain: string): string { - const noIntlPrefix = domain.substr(code.code.length); - let result = ''; - switch (code.mappingPattern) { - case MappingPattern.bds: - result = this.mapBDS(noIntlPrefix); - result = reverse(result) + '.' + reverse(code.code.substr(1)); - break; - case MappingPattern.sds: - result = this.mapSDS(noIntlPrefix); - break; - default: - throw new NumInvalidParameterException(`Bad enum value: ${code.mappingPattern as string}`); - } - return result; - } - - mapBDS(noIntlPrefix: string): string { - let result = ''; - let count = 0; - let threes = 1; - let insertions = 0; - while (count < noIntlPrefix.length) { - result += noIntlPrefix.charAt(count); - if (threes % 3 === 0 && insertions < 2) { - result += '.'; - insertions++; - } - count++; - threes++; - } - return result; - } - - mapSDS(noIntlPrefix: string): string { - return this.intersperseDots(reverse(noIntlPrefix)); - } - - intersperseDots(s: string): string { - return s.split('').join('.'); - } - - findCountryCode(domain: string): CountryCode | undefined { - return codes.find((cc: CountryCode) => domain.startsWith(cc.code)); - } -} - -const reverse = (s: string): string => s.split('').reverse().join(''); - -class CountryCode { - constructor(readonly code: string, readonly mappingPattern: MappingPattern, readonly dnsRoot: string) {} -} - -enum MappingPattern { - bds, - sds, -} - -// NOTE: The order IS important -const codes = [ - new CountryCode('+9999', MappingPattern.sds, '9.9.9.9.e164.arpa'), - new CountryCode('+44', MappingPattern.bds, '44.tnum.net'), - new CountryCode('+1', MappingPattern.bds, '44.tnum.net'), -]; diff --git a/src/modulednsqueries.ts b/src/modulednsqueries.ts index 241dfc1..37c644c 100755 --- a/src/modulednsqueries.ts +++ b/src/modulednsqueries.ts @@ -14,14 +14,8 @@ // import { NumInvalidDnsQueryException, NumInvalidRedirectException } from './exceptions'; -import { - createDomainLookupGenerator, - createEmailLookupGenerator, - createTNUMLookupGenerator, - createUrlLookupGenerator, - LookupGenerator, -} from './lookupgenerators'; -import { Hostname, NO_USER_INFO, NumUri, PositiveInteger } from './numuri'; +import { createDomainLookupGenerator, createEmailLookupGenerator, createUrlLookupGenerator, LookupGenerator } from './lookupgenerators'; +import { NO_USER_INFO, NumUri, PositiveInteger } from './numuri'; import { log } from 'num-easy-log'; //------------------------------------------------------------------------------------------------------------------------ @@ -80,8 +74,6 @@ class ModuleDnsQueriesImpl implements ModuleDnsQueries { lookupGenerator = createEmailLookupGenerator(this.numUri); } else if (this.numUri.protocol.startsWith('http')) { lookupGenerator = createUrlLookupGenerator(this.numUri); - } else if (Hostname.isValidTNUM(this.numUri.host.s)) { - lookupGenerator = createTNUMLookupGenerator(this.numUri); } else { lookupGenerator = createDomainLookupGenerator(this.numUri); } diff --git a/test/TNUMLookupGenerator.test.ts b/test/TNUMLookupGenerator.test.ts deleted file mode 100644 index 331c288..0000000 --- a/test/TNUMLookupGenerator.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { expect } from 'chai'; -// Copyright 2020 NUM Technology Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -import { createTNUMLookupGenerator } from '../src/lookupgenerators'; -import { MODULE_1, parseNumUri } from '../src/numuri'; - -describe('TNUMLookupGenerator', () => { - it('testBDSNoBranches', () => { - const gen = createTNUMLookupGenerator(parseNumUri('num://+442030957100')); - expect("1._0017.590.302.44._t.num.net.").to.equal(gen.getHostedLocation(MODULE_1)); - expect("1._num.0017.590.302.44.tnum.net.").to.equal(gen.getIndependentLocation(MODULE_1)); - expect("1._0017.590.302.44._t.num.net.").to.equal(gen.getRootHostedLocation(MODULE_1)); - expect("_0017.590.302.44._t.num.net.").to.equal(gen.getRootHostedLocationNoModuleNumber(true)); - expect("1._num.0017.590.302.44.tnum.net.").to.equal(gen.getRootIndependentLocation(MODULE_1)); - expect("_num.0017.590.302.44.tnum.net.").to.equal(gen.getRootIndependentLocationNoModuleNumber(true)); - }); - - it('testBDSNoBranchesNoProtocol', () => { - const gen = createTNUMLookupGenerator(parseNumUri('+442030957100')); - expect("1._0017.590.302.44._t.num.net.").to.equal(gen.getHostedLocation(MODULE_1)); - expect("1._num.0017.590.302.44.tnum.net.").to.equal(gen.getIndependentLocation(MODULE_1)); - expect("1._0017.590.302.44._t.num.net.").to.equal(gen.getRootHostedLocation(MODULE_1)); - expect("_0017.590.302.44._t.num.net.").to.equal(gen.getRootHostedLocationNoModuleNumber(true)); - expect("1._num.0017.590.302.44.tnum.net.").to.equal(gen.getRootIndependentLocation(MODULE_1)); - expect("_num.0017.590.302.44.tnum.net.").to.equal(gen.getRootIndependentLocationNoModuleNumber(true)); - }); - - it('testBDSNoBranchesNoTrailingDot', () => { - const gen = createTNUMLookupGenerator(parseNumUri('+442030957100')); - expect("_0017.590.302.44._t.num.net").to.equal(gen.getRootHostedLocationNoModuleNumber(false)); - expect("_num.0017.590.302.44.tnum.net").to.equal(gen.getRootIndependentLocationNoModuleNumber(false)); - }); - - it('testSDSNoBranches', () => { - const gen = createTNUMLookupGenerator(parseNumUri('+99991865332244')); - expect("1._4.4.2.2.3.3.5.6.8.1.9.9.9.9.e164.arpa.").to.equal(gen.getHostedLocation(MODULE_1)); - expect("1._num.4.4.2.2.3.3.5.6.8.1.9.9.9.9.e164.arpa.").to.equal(gen.getIndependentLocation(MODULE_1)); - expect("1._4.4.2.2.3.3.5.6.8.1.9.9.9.9.e164.arpa.").to.equal(gen.getRootHostedLocation(MODULE_1)); - expect("_4.4.2.2.3.3.5.6.8.1.9.9.9.9.e164.arpa.").to.equal(gen.getRootHostedLocationNoModuleNumber(true)); - expect("1._num.4.4.2.2.3.3.5.6.8.1.9.9.9.9.e164.arpa.").to.equal(gen.getRootIndependentLocation(MODULE_1)); - expect("_num.4.4.2.2.3.3.5.6.8.1.9.9.9.9.e164.arpa.").to.equal(gen.getRootIndependentLocationNoModuleNumber(true)); - }); - - it('testBDSBranches', () => { - const gen = createTNUMLookupGenerator(parseNumUri('+442030957100/foo/bar')); - expect("bar.foo.1._0017.590.302.44._t.num.net.").to.equal(gen.getHostedLocation(MODULE_1)); - expect("bar.foo.1._num.0017.590.302.44.tnum.net.").to.equal(gen.getIndependentLocation(MODULE_1)); - expect("1._0017.590.302.44._t.num.net.").to.equal(gen.getRootHostedLocation(MODULE_1)); - expect("_0017.590.302.44._t.num.net.").to.equal(gen.getRootHostedLocationNoModuleNumber(true)); - expect("1._num.0017.590.302.44.tnum.net.").to.equal(gen.getRootIndependentLocation(MODULE_1)); - expect("_num.0017.590.302.44.tnum.net.").to.equal(gen.getRootIndependentLocationNoModuleNumber(true)); - }); - - it('testBDSBranchesWithNumUri', () => { - const gen = createTNUMLookupGenerator(parseNumUri('num://+442030957100:100/foo/bar')); - expect("bar.foo.1._0017.590.302.44._t.num.net.").to.equal(gen.getHostedLocation(MODULE_1)); - expect("bar.foo.1._num.0017.590.302.44.tnum.net.").to.equal(gen.getIndependentLocation(MODULE_1)); - expect("1._0017.590.302.44._t.num.net.").to.equal(gen.getRootHostedLocation(MODULE_1)); - expect("_0017.590.302.44._t.num.net.").to.equal(gen.getRootHostedLocationNoModuleNumber(true)); - expect("1._num.0017.590.302.44.tnum.net.").to.equal(gen.getRootIndependentLocation(MODULE_1)); - expect("_num.0017.590.302.44.tnum.net.").to.equal(gen.getRootIndependentLocationNoModuleNumber(true)); - }); - -}); From 963cc0162bfd6969220efc2d1652ea91147e94fa Mon Sep 17 00:00:00 2001 From: Tony Walmsley Date: Fri, 9 Dec 2022 17:22:11 +0000 Subject: [PATCH 3/5] Updates after code review --- README.md | 35 +-------- src/client.ts | 76 +------------------ src/context.ts | 11 --- src/exceptions.ts | 3 - src/index.ts | 4 - src/lookupgenerators.ts | 17 +---- src/moduleconfig.ts | 71 ----------------- src/numuri.ts | 8 +- src/resourceloader.ts | 54 ------------- test-integration/DummyResourceLoader.ts | 70 ----------------- test-integration/NUMClient.test.ts | 41 +++------- test-integration/NUMClientInterpreter.test.ts | 8 +- test/ModuleConfig.test.ts | 46 ----------- test/NumUri.test.ts | 9 --- test/ResourceLoader.test.ts | 37 --------- test/index.html | 20 ----- 16 files changed, 15 insertions(+), 495 deletions(-) delete mode 100644 src/moduleconfig.ts delete mode 100644 src/resourceloader.ts delete mode 100644 test-integration/DummyResourceLoader.ts delete mode 100644 test/ModuleConfig.test.ts delete mode 100644 test/ResourceLoader.test.ts diff --git a/README.md b/README.md index e425646..467d48f 100644 --- a/README.md +++ b/README.md @@ -106,18 +106,6 @@ const lookup = async () => { // ... }; ``` -## Providing User Variable Values -Some modules can be provided with User Variable values to customise the output, as in this example: -```typescript -const lookup = async () => { - const numUri = parseNumUri('num.uk:1'); // Parse the NUM URI - const client = createClient(); // Create a NumClient - const ctx = client.createContext(numUri); // Set the lookup context - - const result = await client.retrieveNumRecord(ctx); // Use the context to retrieve a NUM record - console.log(result) // Handle the result -} -``` ## Using a `CallbackHandler` Lookups _can_ take several seconds, so you can provide a `CallbackHandler` rather than `await`ing the results: ```Typescript @@ -155,8 +143,7 @@ num.lookup('num.uk:1').then((result) => console.log(result)); This example shows how to use all features of the client, including - overriding the DoH resolver, - reusing the `NUMClient` -- setting user variables -- using a callback handler +- using a callback handler ```javascript const num = require('num-client'); @@ -214,15 +201,6 @@ This simple example can be modified as necessary by following the previous examp NUM URI =
-
- - - -
@@ -247,10 +225,6 @@ This simple example can be modified as necessary by following the previous examp const handler = NumClient.createDefaultCallbackHandler(); const client = NumClient.createClient(CUSTOM_RESOLVERS); - client.setDnsEnv('prod'); - client.setModuleEnv('prod'); - client.setenv('prod'); - function lookup(uri) { const numUri = NumClient.parseNumUri(uri); @@ -289,13 +263,6 @@ This simple example can be modified as necessary by following the previous examp reloadRecord(); } - function setEnvironment() { - const e = document.getElementById('env').value; - client.setDnsEnv(e); - client.setModuleEnv(e); - client.setenv(e); - reloadRecord(); - } diff --git a/src/client.ts b/src/client.ts index e92e2b1..ce48bf2 100644 --- a/src/client.ts +++ b/src/client.ts @@ -23,11 +23,9 @@ import { NumProtocolErrorCode, NumProtocolException, } from './exceptions'; -import { setenvDomainLookups } from './lookupgenerators'; import { createLookupLocationStateMachine } from './lookupstatemachine'; import { createModlServices, ModlServices } from './modlservices'; -import { NumUri, parseNumUri } from './numuri'; -import { createResourceLoader, ResourceLoader } from './resourceloader'; +import { NumUri, parseNumUri, PositiveInteger } from './numuri'; import { log } from 'num-easy-log'; //------------------------------------------------------------------------------------------------------------------------ @@ -81,44 +79,12 @@ export interface NumClient { */ retrieveNumRecord(ctx: Context, handler?: CallbackHandler): Promise; - /** - * - * @param loader Override the default ResourceLoader - mainly used for testing. - */ - setResourceLoader(loader: ResourceLoader): void; - /** * * @param modl a raw MODL string * @param moduleNumber a PositiveInteger module number - * @param userVariables a Map of user-supplied values such as 'C' and 'L' for country and language respectively. - * @param targetExpandedVersion the version number of the required expanded schema, as a string value. - */ - interpret(modl: string): string | null; - - /** - * Set the execution environment. - * Calls setDnsEnv() and setModuleEnv() with the same environment name - * - * @param env `test` for the test environment - */ - setenv(env: string): void; - - /** - * Set the execution environment. - * Sets the environment to use for DNS - * - * @param env `test` for the test environment */ - setDnsEnv(env: string): void; - - /** - * Set the execution environment. - * Sets the environment to use for the modules files. - * - * @param env `test` for the test environment - */ - setModuleEnv(env: string): void; + interpret(modl: string, moduleNumber: PositiveInteger): string | null; /** * Set a timeout for DoH requests. @@ -239,7 +205,6 @@ export class DefaultCallbackHandler implements CallbackHandler { class NumClientImpl implements NumClient { readonly dnsServices: DnsServices; readonly modlServices: ModlServices; - private resourceLoader: ResourceLoader; /** * Creates an instance of num client impl. @@ -251,43 +216,6 @@ class NumClientImpl implements NumClient { resolvers && resolvers.length > 0 ? createDnsServices(DNS_REQUEST_TIMEOUT_MS, resolvers) : createDnsServices(DNS_REQUEST_TIMEOUT_MS, DEFAULT_RESOLVERS); this.modlServices = createModlServices(); - this.resourceLoader = createResourceLoader(); - } - - /** - * - * @param loader Override the default resource loader for testing. - */ - setResourceLoader(loader: ResourceLoader): void { - this.resourceLoader = loader; - } - - /** - * Set the execution environment. - * - * @param env `test` for the test environment - */ - setenv(env: string): void { - this.setDnsEnv(env); - this.setModuleEnv(env); - } - - /** - * Set the execution environment. - * - * @param env `test` for the test environment - */ - setDnsEnv(env: string): void { - setenvDomainLookups(env); - } - - /** - * Set whete the modules files should be loaded from. - * - * @param env `test` for the test environment - */ - setModuleEnv(env: string): void { - this.resourceLoader.setenv(env); } setTimeoutMillis(t: number): void { diff --git a/src/context.ts b/src/context.ts index 30272e7..e6c1acb 100644 --- a/src/context.ts +++ b/src/context.ts @@ -23,7 +23,6 @@ const MAX_NUM_REDIRECTS = 3; //------------------------------------------------------------------------------------------------------------------------ // Exports //------------------------------------------------------------------------------------------------------------------------ -export type UserVariable = string | number | boolean; /** * Location @@ -43,7 +42,6 @@ export class Context { public location = NumLocation.independent; public result: string | null = null; public readonly numAddress: NumUri; - public targetExpandedSchemaVersion: string; _queries: ModuleDnsQueries; redirectCount = 0; /** @@ -59,17 +57,8 @@ export class Context { constructor(numAddress: NumUri) { this.numAddress = numAddress; this._queries = createModuleDnsQueries(numAddress.port, numAddress); - this.targetExpandedSchemaVersion = '1'; } - /** - * Change the target expanded schema version. - * - * @param v the target version number as a string. - */ - setTargetExpandedSchemaVersion(v: string): void { - this.targetExpandedSchemaVersion = v; - } /** * Count redirects and return the current number of redirects. * diff --git a/src/exceptions.ts b/src/exceptions.ts index 50c8f2e..07bfc7f 100644 --- a/src/exceptions.ts +++ b/src/exceptions.ts @@ -190,15 +190,12 @@ export class NumLookupBadDoHResponse extends NumException { export enum NumProtocolErrorCode { errorCreatingContext = 'ERROR_CREATING_CONTEXT', - compactSchemaError = 'COMPACT_SCHEMA_ERROR', substitutionsFileNotFoundError = 'SUBSTITUTIONS_FILE_NOT_FOUND', noUnpackerConfigFileFound = 'UNPACKER_CONFIG_FILE_NOT_FOUND', - expandedSchemaError = 'EXPANDED_SCHEMA_ERROR', moduleConfigFileNotFound = 'MODULE_CONFIG_FILE_NOT_FOUND', tooManyRedirects = 'TOO_MANY_REDIRECTS', internalError = 'INTERNAL_ERROR', noModlRecordFound = 'NUM_RECORD_NOT_FOUND', - schemaNotFound = 'SCHEMA_NOT_FOUND', badDoHResponse = 'DOH_SERVICE_ERROR', } diff --git a/src/index.ts b/src/index.ts index fadc22d..c77b8f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,6 @@ import { createUrlLookupGenerator, normaliseDomainName, normalisePath, - setenvDomainLookups, transformBranch, } from './lookupgenerators'; import { createModuleDnsQueries, ModuleDnsQueries } from './modulednsqueries'; @@ -32,7 +31,6 @@ import { UrlPath, UrlUserInfo, } from './numuri'; -import { ResourceLoader } from './resourceloader'; import { resolvePath } from './urlrelativepathresolver'; export { NumClient, parseNumUri, NumUri, PositiveInteger, Hostname, UrlUserInfo, UrlPath, buildNumUri }; @@ -51,7 +49,6 @@ export { createClient, NumProtocolErrorCode, DefaultCallbackHandler, lookup }; export { DoHResolver, createDnsClient }; export { resolvePath, - ResourceLoader, normalisePath, createModuleDnsQueries, ModuleDnsQueries, @@ -60,6 +57,5 @@ export { createDomainLookupGenerator, createEmailLookupGenerator, createUrlLookupGenerator, - setenvDomainLookups, createDefaultCallbackHandler, }; diff --git a/src/lookupgenerators.ts b/src/lookupgenerators.ts index 78e65fb..0ea3898 100644 --- a/src/lookupgenerators.ts +++ b/src/lookupgenerators.ts @@ -21,7 +21,7 @@ import { log } from 'num-easy-log'; const _NUM = '._num.'; const DNPREFIX = '_'; -let TLZ = 'num.net'; +const TLZ = 'num.net'; const EMAIL_SEP = 'e'; const POP_3LZ = 'populator'; const DEFAULT_DEPTH = 3; @@ -30,21 +30,6 @@ const SCHEME_REGEX = new RegExp(/^[a-zA-Z][0-9a-zA-Z+.-]+:/); //------------------------------------------------------------------------------------------------------------------------ // Exports //------------------------------------------------------------------------------------------------------------------------ -export const setenvDomainLookups = (env: string): void => { - switch (env) { - case 'test': - TLZ = 'n001.uk'; - break; - case 'staging': - TLZ = 'n002.uk'; - break; - case 'prod': - TLZ = 'num.net'; - break; - default: - TLZ = 'num.net'; - } -}; /** * Lookup generator diff --git a/src/moduleconfig.ts b/src/moduleconfig.ts deleted file mode 100644 index e0842f9..0000000 --- a/src/moduleconfig.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { PositiveInteger } from './numuri'; -import { ResourceLoader } from './resourceloader'; - -export interface ModuleConfigProvider { - getConfig(moduleNumber: PositiveInteger): Promise; -} - -export const createModuleConfigProvider = (resourceLoader: ResourceLoader): ModuleConfigProvider => new ModuleConfigProviderImpl(resourceLoader); - -export class ProcessingChain { - constructor(readonly modlToJson: boolean, readonly validateCompactJson: boolean, readonly unpack: boolean, readonly validateExpandedJson: boolean) {} -} - -export enum SubstitutionsType { - standard = 'standard', - locale = 'locale', -} - -export class ModuleConfig { - constructor( - readonly moduleId: PositiveInteger, - readonly moduleName: string, - readonly compactSchema: boolean, - readonly expandedSchema: boolean, - readonly substitutions: boolean, - readonly substitutionsType: SubstitutionsType, - readonly track: string - ) {} -} - -const DEFAULT_MODULES_BASE_URL = 'https://modules.numprotocol.com'; - -class ModuleConfigProviderImpl implements ModuleConfigProvider { - constructor(private resourceLoader: ResourceLoader) { - this.resourceLoader = resourceLoader; - } - - async getConfig(moduleNumber: PositiveInteger): Promise { - const response = await this.resourceLoader.load(`${DEFAULT_MODULES_BASE_URL}/${moduleNumber.n}/config.json`); - - if (response) { - return toModuleConfig(response.data as Record); - } - return null; - } -} - -export const toModuleConfig = (r: Record): ModuleConfig | null => { - let subs: SubstitutionsType; - switch (r.substitutions_type) { - case 'locale': - subs = SubstitutionsType.locale; - break; - case 'standard': - subs = SubstitutionsType.standard; - break; - case undefined: - default: - subs = SubstitutionsType.standard; - } - - return new ModuleConfig( - new PositiveInteger(r.module_id as number), - r.module_name as string, - r.compact_schema as boolean, - r.expanded_schema as boolean, - r.substitutions as boolean, - subs, - r.track as string - ); -}; diff --git a/src/numuri.ts b/src/numuri.ts index 60fc011..0cea847 100644 --- a/src/numuri.ts +++ b/src/numuri.ts @@ -15,7 +15,6 @@ import { parse } from 'url'; const DOMAIN_REGEX = new RegExp(/^(([^.\s\\\b]+?\.)*?([^!"#$%&'()*+,./:;<=>?@\[\]^_`{|}~\s\b]+?\.)([^!"#$%&'()*+,./:;<=>?@\[\]^_`{|}~\s\b]+?))\.??$/); -const TNUM_REGEX = new RegExp(/^\+\d{2,15}$/); const USERINFO_REGEX = new RegExp(/^(?!\s)[^@\f\t\r\b\s\\]+$/); const PATH_REGEX = new RegExp(/^(\/[^;,/\\?:@&=+$.#\s]+)*\/?$/); const MAX_LABEL_LENGTH = 63; @@ -214,12 +213,7 @@ export class Hostname { static isValid(s: string): boolean { const domainMatches = DOMAIN_REGEX.exec(s); - return (s.length <= MAX_DOMAIN_NAME_LENGTH && domainMatches !== null && domainMatches.length > 0) || Hostname.isValidTNUM(s); - } - - static isValidTNUM(s: string): boolean { - const tnumMatches = TNUM_REGEX.exec(s); - return tnumMatches !== null && tnumMatches.length > 0; + return s.length <= MAX_DOMAIN_NAME_LENGTH && domainMatches !== null && domainMatches.length > 0; } } diff --git a/src/resourceloader.ts b/src/resourceloader.ts deleted file mode 100644 index becaffb..0000000 --- a/src/resourceloader.ts +++ /dev/null @@ -1,54 +0,0 @@ -import axios, { AxiosResponse } from 'axios'; -import { LruCache } from './lrucache'; -import { log } from 'num-easy-log'; - -//------------------------------------------------------------------------------------------------------------------------ -// Exports -//------------------------------------------------------------------------------------------------------------------------ - -export interface ResourceLoader { - setenv(env: string): void; - - load(url: string): Promise | null>; -} - -export const createResourceLoader = (): ResourceLoader => new ResourceLoaderImpl() as ResourceLoader; - -//------------------------------------------------------------------------------------------------------------------------ -// Internals -//------------------------------------------------------------------------------------------------------------------------ - -class ResourceLoaderImpl implements ResourceLoader { - private static cache: LruCache>>; - private env: string | null; - - constructor() { - ResourceLoaderImpl.cache = new LruCache(); - this.env = null; - } - - setenv(env: string): void { - this.env = env === 'test' || env === 'staging' ? env : null; - } - - async load(url: string): Promise | null> { - try { - if (url) { - url = this.env ? url.replace('modules.numprotocol.com', `${this.env}.modules.numprotocol.com`) : url; - const cached = ResourceLoaderImpl.cache.get(url); - if (cached) { - return cached; - } else { - const loadedResourcePromise: Promise> = axios.get(url); - ResourceLoaderImpl.cache.put(url, loadedResourcePromise); - return loadedResourcePromise; - } - } - } catch (e) { - if (e instanceof Error) { - log.error(`Cannot load resource from ${url} - ${e.message}`); - } - } - return null; - } -} diff --git a/test-integration/DummyResourceLoader.ts b/test-integration/DummyResourceLoader.ts deleted file mode 100644 index 12d2452..0000000 --- a/test-integration/DummyResourceLoader.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { readFileSync } from 'fs'; -import { ResourceLoader } from '../src/resourceloader'; -import { AxiosResponse } from 'axios'; -import { log } from 'num-easy-log' - -export class DummyResourceLoader implements ResourceLoader { - setenv(env: string) { - throw new Error('Method not implemented.'); - } - async load(url: string): Promise | null> { - try { - if (url.includes('/1/compact/v1/schema.json')) { - log.info('Returning local file for url: ' + url); - return { data: compactSchema1, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/1/expanded/v1/schema.json')) { - log.info('Returning local file for url: ' + url); - return { data: schema1v1, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/1/expanded/v2/schema.json')) { - log.info('Returning local file for url: ' + url); - return { data: schema1v2, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/3/expanded/v1/schema.json')) { - log.info('Returning local file for url: ' + url); - return { data: schema3v1, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/1/config.json')) { - log.info('Returning local file for url: ' + url); - return { data: moduleSpec1, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/1/locales/en-gb.json')) { - log.info('Returning local file for url: ' + url); - return { data: localeEnGb1, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/1/locales/en-us.json')) { - log.info('Returning local file for url: ' + url); - return { data: localeEnUs1, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/1/transformation/c1-e1.json')) { - log.info('Returning local file for url: ' + url); - return { data: schemaMap1, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/1/transformation/c1-e2.json')) { - log.info('Returning local file for url: ' + url); - return { data: schemaMap2, status: 200, statusText: 'OK', headers: [], config: {} }; - } - if (url.includes('/1/transformation/map.json')) { - log.info('Returning local file for url: ' + url); - return { data: transMap, status: 200, statusText: 'OK', headers: [], config: {} }; - } - } catch (e) { - if (e instanceof Error) { - log.error(`Cannot load resource from ${url} - ${e.message}`); - } - } - log.error(`Cannot load resource from ${url}`); - return null; - } -} -const compactSchema1 = JSON.parse(readFileSync('../modules/data/1/compact/v1/schema.json', {}).toString()); -const schema1v1 = JSON.parse(readFileSync('../modules/data/1/expanded/v1/schema.json', {}).toString()); -const schema1v2 = JSON.parse(readFileSync('../modules/data/1/expanded/v2/schema.json', {}).toString()); -const schema3v1 = JSON.parse(readFileSync('../modules/data/3/expanded/v1/schema.json', {}).toString()); -const moduleSpec1 = JSON.parse(readFileSync('../modules/data/1/config.json', {}).toString()); -const localeEnGb1 = JSON.parse(readFileSync('../modules/data/1/locales/en-gb.json', {}).toString()); -const localeEnUs1 = JSON.parse(readFileSync('../modules/data/1/locales/en-us.json', {}).toString()); -const schemaMap1 = JSON.parse(readFileSync('../modules/data/1/transformation/c1-e1.json', {}).toString()); -const schemaMap2 = JSON.parse(readFileSync('../modules/data/1/transformation/c1-e2.json', {}).toString()); -const transMap = JSON.parse(readFileSync('../modules/data/1/transformation/map.json', {}).toString()); diff --git a/test-integration/NUMClient.test.ts b/test-integration/NUMClient.test.ts index 40569e1..7444deb 100644 --- a/test-integration/NUMClient.test.ts +++ b/test-integration/NUMClient.test.ts @@ -27,7 +27,6 @@ import { NumLocation } from '../src/context'; import { DoHResolver } from '../src/dnsclient'; import { NumProtocolErrorCode } from '../src/exceptions'; import { parseNumUri } from '../src/numuri'; -import { DummyResourceLoader } from './DummyResourceLoader'; import { log, Level } from 'num-easy-log'; const DEFAULT_RESOLVERS = [ @@ -35,13 +34,10 @@ const DEFAULT_RESOLVERS = [ new DoHResolver('Cloudflare', 'https://cloudflare-dns.com/dns-query'), ]; -const dummyResourceLoader = new DummyResourceLoader(); - describe('NUMClient', () => { it('should be able to create a new NUMClient', () => { const client = createClient(DEFAULT_RESOLVERS); log.setLevel(Level.info); - client.setResourceLoader(dummyResourceLoader); expect(client).not.equal(null); }); @@ -51,11 +47,9 @@ describe('NUMClient', () => { const client = createClient(); log.setLevel(Level.info); - client.setResourceLoader(dummyResourceLoader); const ctx = client.createContext(numUri); - ctx.setTargetExpandedSchemaVersion('2'); - const result = await client.retrieveNumRecord(ctx, handler); + const result = await client.retrieveNumRecordJson(ctx, handler); expect(result).not.equal(null); @@ -74,14 +68,11 @@ describe('NUMClient', () => { const handler = createDefaultCallbackHandler(); const client = createClient(); - client.disableSchemaValidation(); log.setLevel(Level.info); - client.setResourceLoader(dummyResourceLoader); const ctx = client.createContext(numUri); - ctx.setTargetExpandedSchemaVersion('2'); - const result = await client.retrieveNumRecord(ctx, handler); + const result = await client.retrieveNumRecordJson(ctx, handler); expect(result).not.equal(null); @@ -101,11 +92,9 @@ describe('NUMClient', () => { const client = createClient(); log.setLevel(Level.info); - client.setResourceLoader(dummyResourceLoader); const ctx = client.createContext(numUri); - ctx.setTargetExpandedSchemaVersion('2'); - const result = await client.retrieveNumRecord(ctx, handler); + const result = await client.retrieveNumRecordJson(ctx, handler); expect(result).not.equal(null); @@ -125,14 +114,10 @@ describe('NUMClient', () => { const client = createClient(DEFAULT_RESOLVERS); log.setLevel(Level.info); - client.setResourceLoader(dummyResourceLoader); const ctx = client.createContext(numUri); - ctx.setTargetExpandedSchemaVersion('2'); - ctx.setUserVariable('_L', 'en'); - ctx.setUserVariable('_C', 'us'); - const result = await client.retrieveNumRecord(ctx, handler); + const result = await client.retrieveNumRecordJson(ctx, handler); expect(result).not.equal(null); const expected = '{"@n":1,"@version":2,"object_type":"organization","object_display_name":"Organization","name":"NUM","slogan":"Organising the world\'s open data","contacts":[{"method_type":"twitter","method_display_name":"Twitter","description_default":"View Twitter profile","description":null,"action":"https://www.twitter.com/NUMprotocol","controller":"twitter.com","value":"@NUMprotocol"},{"method_type":"linkedin","method_display_name":"LinkedIn","description_default":"View LinkedIn page","description":null,"action":"https://www.linkedin.com/company/20904983","controller":"linkedin.com","value":"/company/20904983"}]}'; @@ -160,11 +145,9 @@ describe('NUMClient', () => { const client = createClient(DEFAULT_RESOLVERS); log.setLevel(Level.info); - client.setResourceLoader(dummyResourceLoader); const ctx = client.createContext(numUri); - ctx.setTargetExpandedSchemaVersion('2'); - await client.retrieveNumRecord(ctx, handler).then((r) => { + await client.retrieveNumRecordJson(ctx, handler).then((r) => { const expected = '{"@n":1, "@version":2,"object_type":"organization","object_display_name":"Organization","name":"NUM","slogan":"Organising the world\'s open data","contacts":[{"method_type":"twitter","method_display_name":"Twitter","description_default":"View Twitter profile","description":null,"action":"https://www.twitter.com/NUMprotocol","controller":"twitter.com","value":"@NUMprotocol"},{"method_type":"linkedin","method_display_name":"LinkedIn","description_default":"View LinkedIn page","description":null,"action":"https://www.linkedin.com/company/20904983","controller":"linkedin.com","value":"/company/20904983"}]}'; @@ -197,10 +180,8 @@ describe('NUMClient', () => { const client = createClient(DEFAULT_RESOLVERS); log.setLevel(Level.info); - client.setResourceLoader(dummyResourceLoader); const ctx = client.createContext(numUri); - ctx.setTargetExpandedSchemaVersion('2'); - const result = await client.retrieveNumRecord(ctx, handler); + const result = await client.retrieveNumRecordJson(ctx, handler); expect(result).equal(null); }); @@ -211,18 +192,14 @@ describe('NUMClient', () => { const client = createClient(); log.setLevel(Level.info); - client.setResourceLoader(dummyResourceLoader); const ctx1 = client.createContext(numUri1); - ctx1.setTargetExpandedSchemaVersion('2'); const ctx2 = client.createContext(numUri2); - ctx2.setTargetExpandedSchemaVersion('2'); const ctx3 = client.createContext(numUri3); - ctx3.setTargetExpandedSchemaVersion('2'); - const result1 = client.retrieveNumRecord(ctx1); - const result2 = client.retrieveNumRecord(ctx2); - const result3 = client.retrieveNumRecord(ctx3); + const result1 = client.retrieveNumRecordJson(ctx1); + const result2 = client.retrieveNumRecordJson(ctx2); + const result3 = client.retrieveNumRecordJson(ctx3); const result = await Promise.all([result1, result2, result3]); diff --git a/test-integration/NUMClientInterpreter.test.ts b/test-integration/NUMClientInterpreter.test.ts index fa8c64a..329d03a 100644 --- a/test-integration/NUMClientInterpreter.test.ts +++ b/test-integration/NUMClientInterpreter.test.ts @@ -22,22 +22,16 @@ import { expect } from 'chai'; import deepEql from 'deep-eql'; import { createClient } from '../src/client'; -import { UserVariable } from '../src/context'; import { PositiveInteger } from '../src/numuri'; -import { DummyResourceLoader } from './DummyResourceLoader'; import { log } from 'num-easy-log'; -const dummyResourceLoader = new DummyResourceLoader(); - describe('NUMClient with Interpreter', () => { it('should be able to lookup a NUM record using the NUMClient', async () => { const client = createClient(); - client.setResourceLoader(dummyResourceLoader); const modl = "@n=1;o(n=NUM;s=Organising the world's open data;c[tw(v=NUMprotocol);li(v=company/20904983)])"; const moduleNumber = new PositiveInteger(1); - const userVariables = new Map(); - const result = await client.interpret(modl, moduleNumber, userVariables, '2'); + const result = client.interpret(modl, moduleNumber); expect(result).not.equal(null); diff --git a/test/ModuleConfig.test.ts b/test/ModuleConfig.test.ts deleted file mode 100644 index c43249f..0000000 --- a/test/ModuleConfig.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* eslint-disable no-console */ -/* eslint-disable @typescript-eslint/no-unsafe-call */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import { expect } from 'chai'; -import { toModuleConfig } from '../src/moduleconfig'; -// Copyright 2020 NUM Technology Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -describe('ModuleConfig', () => { - it('should be able to create a module config object from a JSON object', () => { - - const specObj = { - "module_id": 1, - "module_name": "Contacts", - "compact_schema": true, - "expanded_schema": true, - "substitutions": true, - "substitutions_type": "locale", - "track": "draft" - } as Record; - - const moduleSpec = toModuleConfig(specObj); - - expect(moduleSpec).not.null; - expect(moduleSpec?.moduleId.n).to.equal(1); - expect(moduleSpec?.moduleName).to.equal('Contacts'); - expect(moduleSpec?.compactSchema).to.equal(true); - expect(moduleSpec?.expandedSchema).to.equal(true); - expect(moduleSpec?.substitutions).to.equal(true); - expect(moduleSpec?.substitutionsType).to.equal('locale'); - expect(moduleSpec?.track).to.equal('draft'); - }); - -}); diff --git a/test/NumUri.test.ts b/test/NumUri.test.ts index 3f1a825..168f49b 100644 --- a/test/NumUri.test.ts +++ b/test/NumUri.test.ts @@ -115,15 +115,6 @@ describe('NumUri Parsing', () => { expect(uri.path.s).equal('/'); }); - it('can parse a TNUM URI', () => { - const uri = parseNumUri('num://+448000683827:65000'); - - expect(uri.userinfo.s).equal(''); - expect(uri.host.s).equal('+448000683827'); - expect(uri.port.n).equal(65000); - expect(uri.path.s).equal('/'); - }); - it('can handle URIs with http', () => { const uri = parseNumUri('http.com'); diff --git a/test/ResourceLoader.test.ts b/test/ResourceLoader.test.ts deleted file mode 100644 index c1f0eb5..0000000 --- a/test/ResourceLoader.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { expect } from 'chai'; -import { createResourceLoader } from '../src/resourceloader'; -// Copyright 2020 NUM Technology Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -const loader = createResourceLoader(); - -describe('ResourceLoader', () => { - it('should be able to load a valid resource', async () => { - const rcf = await loader.load('https://modules.numprotocol.com/1/rcf.txt'); - expect(rcf).not.null; - expect((rcf?.data as string).includes('*id=contact;')).true; - }); - - it('should return null for an invalid resource', async () => { - loader.load('https://modules.numprotocol.com/1/blahblah.txt').then((rcf) => { - expect(rcf).equal(null); - }); - }); - - it('should return null for an invalid web site', async () => { - loader.load('https://doesnotexisthdgfksajhdgfkahsdgfhkjdgsdjhfg.com/1/blahblah.txt').then((rcf) => { - expect(rcf).equal(null); - }); - }); -}); diff --git a/test/index.html b/test/index.html index 508c546..80216ac 100644 --- a/test/index.html +++ b/test/index.html @@ -12,15 +12,6 @@

NUM Protocol Example

NUM URI =
-
- - - -
@@ -45,10 +36,6 @@

NUM Protocol Example

const handler = NumClient.createDefaultCallbackHandler(); const client = NumClient.createClient(CUSTOM_RESOLVERS); - client.setDnsEnv('prod'); - client.setModuleEnv('prod'); - client.setenv('prod'); - function lookup(uri) { const numUri = NumClient.parseNumUri(uri); @@ -87,13 +74,6 @@

NUM Protocol Example

reloadRecord(); } - function setEnvironment() { - const e = document.getElementById('env').value; - client.setDnsEnv(e); - client.setModuleEnv(e); - client.setenv(e); - reloadRecord(); - } From f2c3b633178550ce6a94d549fa96f462655ed203 Mon Sep 17 00:00:00 2001 From: Tony Walmsley Date: Sat, 10 Dec 2022 14:04:12 +0000 Subject: [PATCH 4/5] Fix integration tests and remove redundant ones. --- test-integration/NUMClient.test.ts | 52 ++----------------- test-integration/NUMClientInterpreter.test.ts | 6 +-- 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/test-integration/NUMClient.test.ts b/test-integration/NUMClient.test.ts index 7444deb..94c958b 100644 --- a/test-integration/NUMClient.test.ts +++ b/test-integration/NUMClient.test.ts @@ -53,31 +53,7 @@ describe('NUMClient', () => { expect(result).not.equal(null); - const expected = - '{"@n":1,"@version":2,"object_type":"organization","object_display_name":"Organization","name":"NUM","slogan":"Organising the world\'s open data","contacts":[{"method_type":"twitter","method_display_name":"Twitter","description_default":"View Twitter profile","description":null,"action":"https://www.twitter.com/NUMprotocol","controller":"twitter.com","value":"@NUMprotocol"},{"method_type":"linkedin","method_display_name":"LinkedIn","description_default":"View LinkedIn page","description":null,"action":"https://www.linkedin.com/company/20904983","controller":"linkedin.com","value":"/company/20904983"}]}'; - const same = deepEql(JSON.parse(result as string), JSON.parse(expected)); - if (!same) { - log.info(`Actual : ${result}`); - log.info(`Expected: ${expected}`); - } - expect(same).to.equal(true); - }); - - it('should be able to disable schema validation.', async () => { - const numUri = parseNumUri('num.uk:1'); - const handler = createDefaultCallbackHandler(); - - const client = createClient(); - - log.setLevel(Level.info); - - const ctx = client.createContext(numUri); - const result = await client.retrieveNumRecordJson(ctx, handler); - - expect(result).not.equal(null); - - const expected = - '{"@n":1,"@version":2,"object_type":"organization","object_display_name":"Organization","name":"NUM","slogan":"Organising the world\'s open data","contacts":[{"method_type":"twitter","method_display_name":"Twitter","description_default":"View Twitter profile","description":null,"action":"https://www.twitter.com/NUMprotocol","controller":"twitter.com","value":"@NUMprotocol"},{"method_type":"linkedin","method_display_name":"LinkedIn","description_default":"View LinkedIn page","description":null,"action":"https://www.linkedin.com/company/20904983","controller":"linkedin.com","value":"/company/20904983"}]}'; + const expected = '{"@n":1,"@p":true,"o":{"n":"NUM","c":[{"u":"num.uk"}]}}'; const same = deepEql(JSON.parse(result as string), JSON.parse(expected)); if (!same) { log.info(`Actual : ${result}`); @@ -99,28 +75,7 @@ describe('NUMClient', () => { expect(result).not.equal(null); const expected = - '{"@n":1,"@version":2,"object_type":"organization","object_display_name":"Organization","name":"SES Water","slogan":null,"contacts":[{"method_type":"url","method_display_name":"Web URL","description_default":"Click","description":"Moving Home New Customers","action":"https://seswater.co.uk/your-account/moving-home/moving-into-our-area/moving-into-our-area-form","value":"seswater.co.uk/your-account/moving-home/moving-into-our-area/moving-into-our-area-form","controller":null},{"method_type":"url","method_display_name":"Web URL","description_default":"Click","description":"Make a Payment Online","action":"https://ip.e-paycapita.com/AIP/accountSearch.do?link=showAccountSearchPage&requestId=pk0znolfk2tpa4u9kkgtted9ntd03uo","value":"ip.e-paycapita.com/AIP/accountSearch.do?link=showAccountSearchPage&requestId=pk0znolfk2tpa4u9kkgtted9ntd03uo","controller":null},{"method_type":"telephone","method_display_name":"Telephone","description_default":"Call","description":"Customer Services","action":"tel:+44173 777 2000","value":"+44173 777 2000","controller":null,"hours":{"time_zone_location":"LON","available":["wd@9-17"]}},{"method_type":"telephone","method_display_name":"Telephone","description_default":"Call","description":"Automated Freephone Payment Line","action":"tel:+44800 587 2936","value":"+44800 587 2936","controller":null,"hours":{"time_zone_location":"LON","available":["d@0-24"]}},{"method_type":"telephone","method_display_name":"Telephone","description_default":"Call","description":"Emergency Line","action":"tel:+44173 777 2000","value":"+44173 777 2000","controller":null,"hours":{"time_zone_location":"LON","available":["d@0-24"]}},{"method_type":"telephone","method_display_name":"Telephone","description_default":"Call","description":"Thames Water 24 hour Service","action":"tel:+44845 920 0800","value":"+44845 920 0800","controller":null,"hours":{"time_zone_location":"LON","available":["d@0-24"]}},{"method_type":"telephone","method_display_name":"Telephone","description_default":"Call","description":"Southern Water 24 hour Service","action":"tel:+44845 278 0845","value":"+44845 278 0845","controller":null,"hours":{"time_zone_location":"LON","available":["d@0-24"]}},{"method_type":"twitter","method_display_name":"Twitter","description_default":"View Twitter profile","description":null,"action":"https://www.twitter.com/SESWater","controller":"twitter.com","value":"@SESWater"},{"method_type":"facebook","method_display_name":"Facebook","description_default":"View Facebook profile","description":null,"action":"https://www.facebook.com/SESWaterOfficial","controller":"facebook.com","value":"/SESWaterOfficial"},{"method_type":"linkedin","method_display_name":"LinkedIn","description_default":"View LinkedIn page","description":null,"action":"https://www.linkedin.com/company/seswater","controller":"linkedin.com","value":"/company/seswater"}]}'; - const same = deepEql(JSON.parse(result as string), JSON.parse(expected)); - if (!same) { - log.info(`Actual : ${result}`); - log.info(`Expected: ${expected}`); - } - expect(same).to.equal(true); - }); - - it('should be able to lookup a NUM record using the NUMClient and custom user variables', async () => { - const numUri = parseNumUri('num.uk:1'); - const handler = createDefaultCallbackHandler(); - - const client = createClient(DEFAULT_RESOLVERS); - log.setLevel(Level.info); - - const ctx = client.createContext(numUri); - - const result = await client.retrieveNumRecordJson(ctx, handler); - expect(result).not.equal(null); - const expected = - '{"@n":1,"@version":2,"object_type":"organization","object_display_name":"Organization","name":"NUM","slogan":"Organising the world\'s open data","contacts":[{"method_type":"twitter","method_display_name":"Twitter","description_default":"View Twitter profile","description":null,"action":"https://www.twitter.com/NUMprotocol","controller":"twitter.com","value":"@NUMprotocol"},{"method_type":"linkedin","method_display_name":"LinkedIn","description_default":"View LinkedIn page","description":null,"action":"https://www.linkedin.com/company/20904983","controller":"linkedin.com","value":"/company/20904983"}]}'; + '{"@n":1,"o":{"n":"SES Water","c":[{"u":{"v":"seswater.co.uk/your-account/moving-home/moving-into-our-area/moving-into-our-area-form","d":"Moving Home New Customers"}},{"u":{"v":"ip.e-paycapita.com/AIP/accountSearch.do?link=showAccountSearchPage&requestId=pk0znolfk2tpa4u9kkgtted9ntd03uo","d":"Make a Payment Online"}},{"t":{"v":"+44173 777 2000","d":"Customer Services","h":{"tz":"LON","av":["wd@9-17"]}}},{"t":{"v":"+44800 587 2936","d":"Automated Freephone Payment Line","h":{"tz":"LON","av":["d@0-24"]}}},{"t":{"v":"+44173 777 2000","d":"Emergency Line","h":{"tz":"LON","av":["d@0-24"]}}},{"t":{"v":"+44845 920 0800","d":"Thames Water 24 hour Service","h":{"tz":"LON","av":["d@0-24"]}}},{"t":{"v":"+44845 278 0845","d":"Southern Water 24 hour Service","h":{"tz":"LON","av":["d@0-24"]}}},{"tw":{"v":"SESWater"}},{"fb":{"v":"SESWaterOfficial"}},{"li":{"v":"company/seswater"}}]}}'; const same = deepEql(JSON.parse(result as string), JSON.parse(expected)); if (!same) { log.info(`Actual : ${result}`); @@ -148,8 +103,7 @@ describe('NUMClient', () => { const ctx = client.createContext(numUri); await client.retrieveNumRecordJson(ctx, handler).then((r) => { - const expected = - '{"@n":1, "@version":2,"object_type":"organization","object_display_name":"Organization","name":"NUM","slogan":"Organising the world\'s open data","contacts":[{"method_type":"twitter","method_display_name":"Twitter","description_default":"View Twitter profile","description":null,"action":"https://www.twitter.com/NUMprotocol","controller":"twitter.com","value":"@NUMprotocol"},{"method_type":"linkedin","method_display_name":"LinkedIn","description_default":"View LinkedIn page","description":null,"action":"https://www.linkedin.com/company/20904983","controller":"linkedin.com","value":"/company/20904983"}]}'; + const expected = '{"@n":1,"@p":true,"o":{"n":"NUM","c":[{"u":"num.uk"}]}}'; if (r) { const same = deepEql(JSON.parse(r), JSON.parse(expected)); diff --git a/test-integration/NUMClientInterpreter.test.ts b/test-integration/NUMClientInterpreter.test.ts index 329d03a..a44b5d1 100644 --- a/test-integration/NUMClientInterpreter.test.ts +++ b/test-integration/NUMClientInterpreter.test.ts @@ -23,10 +23,9 @@ import { expect } from 'chai'; import deepEql from 'deep-eql'; import { createClient } from '../src/client'; import { PositiveInteger } from '../src/numuri'; -import { log } from 'num-easy-log'; describe('NUMClient with Interpreter', () => { - it('should be able to lookup a NUM record using the NUMClient', async () => { + it('should be able to interpret a NUM record using the NUMClient', async () => { const client = createClient(); const modl = "@n=1;o(n=NUM;s=Organising the world's open data;c[tw(v=NUMprotocol);li(v=company/20904983)])"; @@ -35,8 +34,7 @@ describe('NUMClient with Interpreter', () => { expect(result).not.equal(null); - const expected = - '{"@n":1,"@version":2,"object_type":"organization","object_display_name":"Organization","name":"NUM","slogan":"Organising the world\'s open data","contacts":[{"method_type":"twitter","method_display_name":"Twitter","description_default":"View Twitter profile","description":null,"action":"https://www.twitter.com/NUMprotocol","controller":"twitter.com","value":"@NUMprotocol"},{"method_type":"linkedin","method_display_name":"LinkedIn","description_default":"View LinkedIn page","description":null,"action":"https://www.linkedin.com/company/20904983","controller":"linkedin.com","value":"/company/20904983"}]}'; + const expected = '{"@n":1,"o":{"n":"NUM","s":"Organising the world\'s open data","c":[{"tw":{"v":"NUMprotocol"}},{"li":{"v":"company/20904983"}}]}}'; const same = deepEql(JSON.parse(result as string), JSON.parse(expected)); if (!same) { console.log(`Actual : ${result}`); From 28df8e721674fbd177c81e2010e4da6de5837223 Mon Sep 17 00:00:00 2001 From: Tony Walmsley Date: Sat, 10 Dec 2022 14:14:59 +0000 Subject: [PATCH 5/5] Remove nodeJS v10 from the GH workflow since it always fails. A recent NodeJS is required. --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 673bd33..bed96a2 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [10.x, 12.x, 14.x] + node-version: [12.x, 14.x] steps: - uses: actions/checkout@v2