Compare commits

..

4 Commits

Author SHA1 Message Date
d410517c8b 3.0.10 2022-08-02 18:19:27 +02:00
c02340813f fix(core): update 2022-08-02 18:19:27 +02:00
0d3f636af3 3.0.9 2022-07-28 16:23:11 +02:00
a64d47c02e fix(core): update 2022-07-28 16:23:11 +02:00
4 changed files with 106 additions and 88 deletions

162
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@pushrocks/webrequest",
"version": "3.0.8",
"version": "3.0.10",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@pushrocks/webrequest",
"version": "3.0.8",
"version": "3.0.10",
"license": "MIT",
"dependencies": {
"@pushrocks/smartdelay": "^2.0.13",
@ -14,7 +14,7 @@
"@pushrocks/smartjson": "^5.0.1",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/webstore": "^2.0.4",
"node-fetch": "^3.2.9"
"node-fetch": "^2.6.7"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.63",
@ -22,7 +22,7 @@
"@gitzone/tstest": "^1.0.72",
"@pushrocks/smartexpress": "^4.0.5",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.6.1",
"@types/node": "^18.6.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
}
@ -1582,6 +1582,25 @@
"lodash.clonedeep": "^4.5.0"
}
},
"node_modules/@pushrocks/webrequest/node_modules/node-fetch": {
"version": "3.2.10",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-3.2.10.tgz",
"integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==",
"dev": true,
"license": "MIT",
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-fetch"
}
},
"node_modules/@pushrocks/webstore": {
"version": "2.0.4",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fwebstore/-/webstore-2.0.4.tgz",
@ -2087,9 +2106,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "18.6.1",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-18.6.1.tgz",
"integrity": "sha512-z+2vB6yDt1fNwKOeGbckpmirO+VBDuQqecXkgeIqDlaOtmKn6hPR/viQ8cxCfqLU4fTlvM3+YjM367TukWdxpg==",
"version": "18.6.2",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-18.6.2.tgz",
"integrity": "sha512-KcfkBq9H4PI6Vpu5B/KoPeuVDAbmi+2mDBqGPGUgoL7yXQtcWGu2vJWmmRkneWK3Rh0nIAX192Aa87AqKHYChQ==",
"dev": true,
"license": "MIT"
},
@ -3460,27 +3479,6 @@
"node-fetch": "2.6.7"
}
},
"node_modules/cross-fetch/node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/crypto-random-string": {
"version": "4.0.0",
"resolved": "https://verdaccio.lossless.one/crypto-random-string/-/crypto-random-string-4.0.0.tgz",
@ -3514,6 +3512,7 @@
"version": "4.0.0",
"resolved": "https://verdaccio.lossless.one/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz",
"integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 12"
@ -4553,9 +4552,10 @@
}
},
"node_modules/fetch-blob": {
"version": "3.1.5",
"resolved": "https://verdaccio.lossless.one/fetch-blob/-/fetch-blob-3.1.5.tgz",
"integrity": "sha512-N64ZpKqoLejlrwkIAnb9iLSA3Vx/kjgzpcDhygcqJ2KKjky8nCgUQ+dzXtbrLaWZGZNmNfQTsiQ0weZ1svglHg==",
"version": "3.2.0",
"resolved": "https://verdaccio.lossless.one/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"dev": true,
"funding": [
{
"type": "github",
@ -4722,6 +4722,7 @@
"version": "4.0.10",
"resolved": "https://verdaccio.lossless.one/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"dev": true,
"license": "MIT",
"dependencies": {
"fetch-blob": "^3.1.2"
@ -6297,6 +6298,7 @@
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"dev": true,
"funding": [
{
"type": "github",
@ -6313,21 +6315,23 @@
}
},
"node_modules/node-fetch": {
"version": "3.2.9",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-3.2.9.tgz",
"integrity": "sha512-/2lI+DBecVvVm9tDhjziTVjo2wmTsSxSk58saUYP0P/fRJ3xxtfMDY24+CKTkfm0Dlhyn3CSXNL0SoRiCZ8Rzg==",
"version": "2.6.7",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"license": "MIT",
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
"node": "4.x || >=6.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-fetch"
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/normalize-newline": {
@ -7797,7 +7801,6 @@
"version": "0.0.3",
"resolved": "https://verdaccio.lossless.one/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=",
"dev": true,
"license": "MIT"
},
"node_modules/tree-kill": {
@ -8220,9 +8223,10 @@
}
},
"node_modules/web-streams-polyfill": {
"version": "3.2.0",
"resolved": "https://verdaccio.lossless.one/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz",
"integrity": "sha512-EqPmREeOzttaLRm5HS7io98goBgZ7IVz79aDvqjD0kYXLtFZTc0T/U6wHTPKyIjb+MdN7DFIIX6hgdBEpWmfPA==",
"version": "3.2.1",
"resolved": "https://verdaccio.lossless.one/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 8"
@ -8232,14 +8236,12 @@
"version": "3.0.1",
"resolved": "https://verdaccio.lossless.one/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=",
"dev": true,
"license": "BSD-2-Clause"
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://verdaccio.lossless.one/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"dev": true,
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
@ -9827,6 +9829,17 @@
"fast-json-stable-stringify": "^2.1.0",
"lodash.clonedeep": "^4.5.0"
}
},
"node-fetch": {
"version": "3.2.10",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-3.2.10.tgz",
"integrity": "sha512-MhuzNwdURnZ1Cp4XTazr69K0BTizsBroX7Zx3UgDSVcZYKF/6p0CBe4EUb/hLqmzVhl0UpYfgRljQ4yxE+iCxA==",
"dev": true,
"requires": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
}
}
}
},
@ -10274,9 +10287,9 @@
"integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ=="
},
"@types/node": {
"version": "18.6.1",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-18.6.1.tgz",
"integrity": "sha512-z+2vB6yDt1fNwKOeGbckpmirO+VBDuQqecXkgeIqDlaOtmKn6hPR/viQ8cxCfqLU4fTlvM3+YjM367TukWdxpg==",
"version": "18.6.2",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-18.6.2.tgz",
"integrity": "sha512-KcfkBq9H4PI6Vpu5B/KoPeuVDAbmi+2mDBqGPGUgoL7yXQtcWGu2vJWmmRkneWK3Rh0nIAX192Aa87AqKHYChQ==",
"dev": true
},
"@types/parse5": {
@ -11265,17 +11278,6 @@
"dev": true,
"requires": {
"node-fetch": "2.6.7"
},
"dependencies": {
"node-fetch": {
"version": "2.6.7",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dev": true,
"requires": {
"whatwg-url": "^5.0.0"
}
}
}
},
"crypto-random-string": {
@ -11298,7 +11300,8 @@
"data-uri-to-buffer": {
"version": "4.0.0",
"resolved": "https://verdaccio.lossless.one/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz",
"integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA=="
"integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==",
"dev": true
},
"dayjs": {
"version": "1.10.7",
@ -11924,9 +11927,10 @@
}
},
"fetch-blob": {
"version": "3.1.5",
"resolved": "https://verdaccio.lossless.one/fetch-blob/-/fetch-blob-3.1.5.tgz",
"integrity": "sha512-N64ZpKqoLejlrwkIAnb9iLSA3Vx/kjgzpcDhygcqJ2KKjky8nCgUQ+dzXtbrLaWZGZNmNfQTsiQ0weZ1svglHg==",
"version": "3.2.0",
"resolved": "https://verdaccio.lossless.one/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"dev": true,
"requires": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
@ -12047,6 +12051,7 @@
"version": "4.0.10",
"resolved": "https://verdaccio.lossless.one/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"dev": true,
"requires": {
"fetch-blob": "^3.1.2"
}
@ -13188,16 +13193,15 @@
"node-domexception": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"dev": true
},
"node-fetch": {
"version": "3.2.9",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-3.2.9.tgz",
"integrity": "sha512-/2lI+DBecVvVm9tDhjziTVjo2wmTsSxSk58saUYP0P/fRJ3xxtfMDY24+CKTkfm0Dlhyn3CSXNL0SoRiCZ8Rzg==",
"version": "2.6.7",
"resolved": "https://verdaccio.lossless.one/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
"whatwg-url": "^5.0.0"
}
},
"normalize-newline": {
@ -14222,8 +14226,7 @@
"tr46": {
"version": "0.0.3",
"resolved": "https://verdaccio.lossless.one/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=",
"dev": true
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"tree-kill": {
"version": "1.2.2",
@ -14495,21 +14498,20 @@
"dev": true
},
"web-streams-polyfill": {
"version": "3.2.0",
"resolved": "https://verdaccio.lossless.one/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz",
"integrity": "sha512-EqPmREeOzttaLRm5HS7io98goBgZ7IVz79aDvqjD0kYXLtFZTc0T/U6wHTPKyIjb+MdN7DFIIX6hgdBEpWmfPA=="
"version": "3.2.1",
"resolved": "https://verdaccio.lossless.one/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
"dev": true
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://verdaccio.lossless.one/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=",
"dev": true
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://verdaccio.lossless.one/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"dev": true,
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/webrequest",
"version": "3.0.8",
"version": "3.0.10",
"private": false,
"description": "securely request from browsers",
"main": "dist_ts/index.js",
@ -18,7 +18,7 @@
"@gitzone/tstest": "^1.0.72",
"@pushrocks/smartexpress": "^4.0.5",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.6.1",
"@types/node": "^18.6.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
@ -28,7 +28,7 @@
"@pushrocks/smartjson": "^5.0.1",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/webstore": "^2.0.4",
"node-fetch": "^3.2.9"
"node-fetch": "^2.6.7"
},
"files": [
"ts/**/*",

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/webrequest',
version: '3.0.8',
version: '3.0.10',
description: 'securely request from browsers'
}

View File

@ -1,5 +1,9 @@
import * as plugins from './webrequest.plugins.js';
export interface IWebrequestContructorOptions {
logging?: boolean;
}
/**
* web request
*/
@ -26,7 +30,13 @@ export class WebRequest {
storeName: 'webrequest',
});
constructor() {
public options: IWebrequestContructorOptions;
constructor(public optionsArg: IWebrequestContructorOptions = {}) {
this.options = {
logging: true,
...optionsArg
}
WebRequest.loadNeededPolyfills();
}
@ -133,7 +143,7 @@ export class WebRequest {
const buffer = await response.clone().arrayBuffer();
await this.cacheStore.set(urlArg, buffer);
}
console.log(`${urlArg} answers with status: ${response.status}`);
this.log(`${urlArg} answers with status: ${response.status}`);
return response;
}
@ -185,7 +195,7 @@ export class WebRequest {
if (!urlToUse) {
throw new Error('request failed permanently');
}
console.log(`Getting ${urlToUse} with method ${optionsArg.method}`);
this.log(`Getting ${urlToUse} with method ${optionsArg.method}`);
const response = await fetch(urlToUse, {
method: optionsArg.method,
headers: {
@ -194,7 +204,7 @@ export class WebRequest {
},
body: optionsArg.body,
});
console.log(`${urlToUse} answers with status: ${response.status}`);
this.log(`${urlToUse} answers with status: ${response.status}`);
if (response.status >= 200 && response.status < 300) {
return response;
@ -210,4 +220,10 @@ export class WebRequest {
const finalResponse: Response = await doRequest(allUrls[usedUrlIndex]);
return finalResponse;
}
public log(logArg: string) {
if (this.options.logging) {
console.log(logArg);
}
}
}