fix: do conditional node checks and dynamic imports

This commit is contained in:
Derrick Hammer 2023-06-23 08:51:03 -04:00
parent 26103b475b
commit 4a90fb0f6e
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 30655 additions and 30787 deletions

234
npm-shrinkwrap.json generated
View File

@ -10,9 +10,9 @@
"dependencies": { "dependencies": {
"@noble/curves": "^1.1.0", "@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1", "@noble/hashes": "^1.3.1",
"cross-fetch": "^3.1.6",
"detect-node": "^2.1.0", "detect-node": "^2.1.0",
"multiformats": "^11.0.2", "multiformats": "^11.0.2",
"node-fetch": "^3.3.1",
"p-defer": "^4.0.0", "p-defer": "^4.0.0",
"stream-to-blob": "^2.0.1", "stream-to-blob": "^2.0.1",
"tus-js-client": "^3.1.0", "tus-js-client": "^3.1.0",
@ -1805,26 +1805,6 @@
"node": ">= 14" "node": ">= 14"
} }
}, },
"node_modules/@octokit/request/node_modules/node-fetch": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dev": true,
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/@octokit/tsconfig": { "node_modules/@octokit/tsconfig": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-2.0.0.tgz",
@ -4806,6 +4786,14 @@
"yarn": ">=1" "yarn": ">=1"
} }
}, },
"node_modules/cross-fetch": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.6.tgz",
"integrity": "sha512-riRvo06crlE8HiqOwIpQhxwdOk4fOeR7FVM/wXoxchFEqMNUjvbs3bfo4OTgMEMHzppd4DxFBDbyySj8Cv781g==",
"dependencies": {
"node-fetch": "^2.6.11"
}
},
"node_modules/cross-spawn": { "node_modules/cross-spawn": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@ -4874,14 +4862,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"engines": {
"node": ">= 12"
}
},
"node_modules/dateformat": { "node_modules/dateformat": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz",
@ -5312,7 +5292,6 @@
"version": "0.1.13", "version": "0.1.13",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"dev": true,
"optional": true, "optional": true,
"dependencies": { "dependencies": {
"iconv-lite": "^0.6.2" "iconv-lite": "^0.6.2"
@ -6135,28 +6114,6 @@
"bser": "2.1.1" "bser": "2.1.1"
} }
}, },
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/figures": { "node_modules/figures": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
@ -6271,17 +6228,6 @@
"is-callable": "^1.1.3" "is-callable": "^1.1.3"
} }
}, },
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/from2": { "node_modules/from2": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz",
@ -6788,12 +6734,6 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node_modules/github-slugger": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz",
"integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==",
"extraneous": true
},
"node_modules/glob": { "node_modules/glob": {
"version": "7.2.3", "version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
@ -7233,7 +7173,6 @@
"version": "0.6.3", "version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true,
"optional": true, "optional": true,
"dependencies": { "dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0" "safer-buffer": ">= 2.1.2 < 3.0.0"
@ -9113,27 +9052,6 @@
"node": ">= 18" "node": ">= 18"
} }
}, },
"node_modules/marked-gfm-heading-id": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/marked-gfm-heading-id/-/marked-gfm-heading-id-3.0.4.tgz",
"integrity": "sha512-k22f+k8B449kRVXbi3OYxahI6t8HywKIF0wn0L0atzYhFHYRcJynLDekh+lcxcZkNnkEGRZOHuRfTcpjMjLqDw==",
"extraneous": true,
"dependencies": {
"github-slugger": "^2.0.0"
},
"peerDependencies": {
"marked": "^4 || ^5"
}
},
"node_modules/marked-mangle": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/marked-mangle/-/marked-mangle-1.0.1.tgz",
"integrity": "sha512-ZmWErsTkfE78OFgrpry2XGh+lYNRePfGy7bGh20l4rWHsH+bciKth1IHQXO9B6Ov5dHmY0jAswvgDxtcxGcFQQ==",
"extraneous": true,
"peerDependencies": {
"marked": "^4 || ^5"
}
},
"node_modules/marked-terminal": { "node_modules/marked-terminal": {
"version": "5.2.0", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/marked-terminal/-/marked-terminal-5.2.0.tgz", "resolved": "https://registry.npmjs.org/marked-terminal/-/marked-terminal-5.2.0.tgz",
@ -9602,24 +9520,6 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-emoji": { "node_modules/node-emoji": {
"version": "1.11.0", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz",
@ -9630,20 +9530,22 @@
} }
}, },
"node_modules/node-fetch": { "node_modules/node-fetch": {
"version": "3.3.1", "version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dependencies": { "dependencies": {
"data-uri-to-buffer": "^4.0.0", "whatwg-url": "^5.0.0"
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
}, },
"engines": { "engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" "node": "4.x || >=6.0.0"
}, },
"funding": { "peerDependencies": {
"type": "opencollective", "encoding": "^0.1.0"
"url": "https://opencollective.com/node-fetch" },
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
} }
}, },
"node_modules/node-gyp": { "node_modules/node-gyp": {
@ -14962,7 +14864,6 @@
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true,
"optional": true "optional": true
}, },
"node_modules/semantic-release": { "node_modules/semantic-release": {
@ -16438,8 +16339,7 @@
"node_modules/tr46": { "node_modules/tr46": {
"version": "0.0.3", "version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
"dev": true
}, },
"node_modules/traverse": { "node_modules/traverse": {
"version": "0.6.7", "version": "0.6.7",
@ -17526,14 +17426,12 @@
"node_modules/webidl-conversions": { "node_modules/webidl-conversions": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
"dev": true
}, },
"node_modules/whatwg-url": { "node_modules/whatwg-url": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dev": true,
"dependencies": { "dependencies": {
"tr46": "~0.0.3", "tr46": "~0.0.3",
"webidl-conversions": "^3.0.0" "webidl-conversions": "^3.0.0"
@ -19214,17 +19112,6 @@
"is-plain-object": "^5.0.0", "is-plain-object": "^5.0.0",
"node-fetch": "^2.6.7", "node-fetch": "^2.6.7",
"universal-user-agent": "^6.0.0" "universal-user-agent": "^6.0.0"
},
"dependencies": {
"node-fetch": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"dev": true,
"requires": {
"whatwg-url": "^5.0.0"
}
}
} }
}, },
"@octokit/request-error": { "@octokit/request-error": {
@ -21468,6 +21355,14 @@
"cross-spawn": "^7.0.1" "cross-spawn": "^7.0.1"
} }
}, },
"cross-fetch": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.6.tgz",
"integrity": "sha512-riRvo06crlE8HiqOwIpQhxwdOk4fOeR7FVM/wXoxchFEqMNUjvbs3bfo4OTgMEMHzppd4DxFBDbyySj8Cv781g==",
"requires": {
"node-fetch": "^2.6.11"
}
},
"cross-spawn": { "cross-spawn": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@ -21514,11 +21409,6 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A=="
},
"dateformat": { "dateformat": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz",
@ -21854,7 +21744,6 @@
"version": "0.1.13", "version": "0.1.13",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
"integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"iconv-lite": "^0.6.2" "iconv-lite": "^0.6.2"
@ -22492,15 +22381,6 @@
"bser": "2.1.1" "bser": "2.1.1"
} }
}, },
"fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"requires": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
}
},
"figures": { "figures": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
@ -22587,14 +22467,6 @@
"is-callable": "^1.1.3" "is-callable": "^1.1.3"
} }
}, },
"formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"requires": {
"fetch-blob": "^3.1.2"
}
},
"from2": { "from2": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz",
@ -23022,12 +22894,6 @@
} }
} }
}, },
"github-slugger": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz",
"integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==",
"extraneous": true
},
"glob": { "glob": {
"version": "7.2.3", "version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
@ -23355,7 +23221,6 @@
"version": "0.6.3", "version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"safer-buffer": ">= 2.1.2 < 3.0.0" "safer-buffer": ">= 2.1.2 < 3.0.0"
@ -24792,20 +24657,6 @@
"integrity": "sha512-z3/nBe7aTI8JDszlYLk7dDVNpngjw0o1ZJtrA9kIfkkHcIF+xH7mO23aISl4WxP83elU+MFROgahqdpd05lMEQ==", "integrity": "sha512-z3/nBe7aTI8JDszlYLk7dDVNpngjw0o1ZJtrA9kIfkkHcIF+xH7mO23aISl4WxP83elU+MFROgahqdpd05lMEQ==",
"dev": true "dev": true
}, },
"marked-gfm-heading-id": {
"version": "https://registry.npmjs.org/marked-gfm-heading-id/-/marked-gfm-heading-id-3.0.4.tgz",
"integrity": "sha512-k22f+k8B449kRVXbi3OYxahI6t8HywKIF0wn0L0atzYhFHYRcJynLDekh+lcxcZkNnkEGRZOHuRfTcpjMjLqDw==",
"extraneous": true,
"requires": {
"github-slugger": "^2.0.0"
}
},
"marked-mangle": {
"version": "https://registry.npmjs.org/marked-mangle/-/marked-mangle-1.0.1.tgz",
"integrity": "sha512-ZmWErsTkfE78OFgrpry2XGh+lYNRePfGy7bGh20l4rWHsH+bciKth1IHQXO9B6Ov5dHmY0jAswvgDxtcxGcFQQ==",
"extraneous": true,
"requires": {}
},
"marked-terminal": { "marked-terminal": {
"version": "5.2.0", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/marked-terminal/-/marked-terminal-5.2.0.tgz", "resolved": "https://registry.npmjs.org/marked-terminal/-/marked-terminal-5.2.0.tgz",
@ -25158,11 +25009,6 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
},
"node-emoji": { "node-emoji": {
"version": "1.11.0", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.11.0.tgz",
@ -25173,13 +25019,11 @@
} }
}, },
"node-fetch": { "node-fetch": {
"version": "3.3.1", "version": "2.6.11",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
"integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==", "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==",
"requires": { "requires": {
"data-uri-to-buffer": "^4.0.0", "whatwg-url": "^5.0.0"
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
} }
}, },
"node-gyp": { "node-gyp": {
@ -28887,7 +28731,6 @@
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true,
"optional": true "optional": true
}, },
"semantic-release": { "semantic-release": {
@ -29983,8 +29826,7 @@
"tr46": { "tr46": {
"version": "0.0.3", "version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
"dev": true
}, },
"traverse": { "traverse": {
"version": "0.6.7", "version": "0.6.7",
@ -30739,14 +30581,12 @@
"webidl-conversions": { "webidl-conversions": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
"dev": true
}, },
"whatwg-url": { "whatwg-url": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dev": true,
"requires": { "requires": {
"tr46": "~0.0.3", "tr46": "~0.0.3",
"webidl-conversions": "^3.0.0" "webidl-conversions": "^3.0.0"

View File

@ -36,9 +36,9 @@
"dependencies": { "dependencies": {
"@noble/curves": "^1.1.0", "@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1", "@noble/hashes": "^1.3.1",
"cross-fetch": "^3.1.6",
"detect-node": "^2.1.0", "detect-node": "^2.1.0",
"multiformats": "^11.0.2", "multiformats": "^11.0.2",
"node-fetch": "^3.3.1",
"p-defer": "^4.0.0", "p-defer": "^4.0.0",
"stream-to-blob": "^2.0.1", "stream-to-blob": "^2.0.1",
"tus-js-client": "^3.1.0", "tus-js-client": "^3.1.0",

View File

@ -2,13 +2,7 @@ import { ed25519 as ed } from "@noble/curves/ed25519";
import * as edUtils from "@noble/curves/abstract/utils"; import * as edUtils from "@noble/curves/abstract/utils";
import { RegisterRequest } from "./requests/account.js"; import { RegisterRequest } from "./requests/account.js";
import fetch, { import fetch, { Response } from "cross-fetch";
FormData,
Blob,
RequestInit,
Response,
HeadersInit,
} from "node-fetch";
import { import {
LoginRequest, LoginRequest,
LogoutRequest, LogoutRequest,
@ -27,12 +21,14 @@ import streamToBlob from "stream-to-blob";
import defer from "p-defer"; import defer from "p-defer";
import { blake3 } from "@noble/hashes/blake3"; import { blake3 } from "@noble/hashes/blake3";
import { encodeCid } from "./cid.js"; import { encodeCid } from "./cid.js";
import { Readable as NodeReadableStream } from "stream";
import { import {
AuthStatusResponse, AuthStatusResponse,
LoginResponse, LoginResponse,
PubkeyChallengeResponse, PubkeyChallengeResponse,
} from "./responses/auth.js"; } from "./responses/auth.js";
import isNode from "detect-node";
type NodeReadableStreamType = typeof import("stream").Readable;
export interface ClientOptions { export interface ClientOptions {
portalUrl: string; portalUrl: string;
@ -211,7 +207,9 @@ export class Client {
if (options.data) { if (options.data) {
fetchOptions.body = options.data; fetchOptions.body = options.data;
if (!(fetchOptions.body instanceof FormData)) { const _FormData = await this.getFormDataObject();
if (!(fetchOptions.body instanceof _FormData)) {
fetchOptions.headers["Content-Type"] = "application/json"; fetchOptions.headers["Content-Type"] = "application/json";
fetchOptions.body = JSON.stringify(fetchOptions.body); fetchOptions.body = JSON.stringify(fetchOptions.body);
} }
@ -312,7 +310,10 @@ export class Client {
stream = await streamToBlob(stream); stream = await streamToBlob(stream);
} }
if (stream instanceof NodeReadableStream) { let NodeReadableStream =
(await this.getNodeReadableObject()) as NodeReadableStreamType;
if (NodeReadableStream && stream instanceof NodeReadableStream) {
let data = new Uint8Array(); let data = new Uint8Array();
for await (const chunk of stream) { for await (const chunk of stream) {
data = Uint8Array.from([...data, ...chunk]); data = Uint8Array.from([...data, ...chunk]);
@ -325,11 +326,16 @@ export class Client {
stream = new Blob([Buffer.from(stream)]); stream = new Blob([Buffer.from(stream)]);
} }
if (!(stream instanceof Blob) && !(stream instanceof NodeReadableStream)) { if (
!(stream instanceof Blob) &&
!(NodeReadableStream && stream instanceof NodeReadableStream)
) {
throw new Error("Invalid stream"); throw new Error("Invalid stream");
} }
const formData = new FormData(); const _FormData = await this.getFormDataObject();
const formData = new _FormData();
formData.set("file", stream as Blob); formData.set("file", stream as Blob);
const response = await this.post<UploadResponse>( const response = await this.post<UploadResponse>(
@ -373,7 +379,10 @@ export class Client {
hash = await this.computeHash(hashStream); hash = await this.computeHash(hashStream);
} }
if (stream instanceof NodeReadableStream) { let NodeReadableStream =
(await this.getNodeReadableObject()) as NodeReadableStreamType;
if (NodeReadableStream && stream instanceof NodeReadableStream) {
hash = await this.computeHash(hashStream); hash = await this.computeHash(hashStream);
} }
@ -386,7 +395,7 @@ export class Client {
if ( if (
!(stream instanceof ReadableStreamDefaultReader) && !(stream instanceof ReadableStreamDefaultReader) &&
!(stream instanceof Blob) && !(stream instanceof Blob) &&
!(stream instanceof NodeReadableStream) !(NodeReadableStream && stream instanceof NodeReadableStream)
) { ) {
throw new Error("Invalid stream"); throw new Error("Invalid stream");
} }
@ -476,7 +485,10 @@ export class Client {
return edUtils.bytesToHex(hasher.digest()); return edUtils.bytesToHex(hasher.digest());
} }
if (stream instanceof NodeReadableStream) { let NodeReadableStream =
(await this.getNodeReadableObject()) as NodeReadableStreamType;
if (NodeReadableStream && stream instanceof NodeReadableStream) {
const hasher = blake3.create({}); const hasher = blake3.create({});
for await (const chunk of stream) { for await (const chunk of stream) {
@ -494,4 +506,20 @@ export class Client {
throw new Error("Invalid stream"); throw new Error("Invalid stream");
} }
private async getFormDataObject() {
if (isNode) {
return (await import("node-fetch")).FormData;
}
return FormData;
}
private async getNodeReadableObject() {
if (isNode) {
return (await import("stream")).Readable;
}
return undefined;
}
} }