diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml deleted file mode 100644 index 63f1adf..0000000 --- a/.github/workflows/publish-npm.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: Publish NPM package - -on: - release: - types: [created] - -jobs: - publish-npm: - uses: snapshot-labs/actions/.github/workflows/publish-npm.yml@main - secrets: inherit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 386e961..db01391 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,11 +4,5 @@ on: [push] jobs: test: - strategy: - matrix: - target: ['16', '18', '20'] - uses: snapshot-labs/actions/.github/workflows/test.yml@main secrets: inherit - with: - target: ${{ matrix.target }} diff --git a/package.json b/package.json index f596a36..af6c32f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@snapshot-labs/pineapple", - "version": "0.3.0", + "version": "0.2.0", "license": "MIT", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -18,7 +18,7 @@ }, "prettier": "@snapshot-labs/prettier-config", "dependencies": { - "node-fetch": "^2.7.0" + "cross-fetch": "^3.1.5" }, "devDependencies": { "@snapshot-labs/eslint-config": "^0.1.0-beta.9", diff --git a/src/index.ts b/src/index.ts index 08ecf7c..f551ec6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,6 @@ -import fetch from 'node-fetch'; -import http from 'node:http'; -import https from 'node:https'; +import fetch from 'cross-fetch'; const PINEAPPLE_URL = 'https://pineapple.fyi'; -const agentOptions = { keepAlive: true }; export async function pin(json: any, url: string = PINEAPPLE_URL) { const init = { @@ -17,11 +14,7 @@ export async function pin(json: any, url: string = PINEAPPLE_URL) { method: 'pin', params: json, id: null - }), - agent: - new URL(url).protocol === 'http:' - ? new http.Agent(agentOptions) - : new https.Agent(agentOptions) + }) }; const res = await fetch(url, init); const content = await res.json(); diff --git a/test/upload.test.ts b/test/upload.test.ts index f4226d2..2f90648 100644 --- a/test/upload.test.ts +++ b/test/upload.test.ts @@ -10,7 +10,7 @@ describe('upload()', () => { formData.append('file', createReadStream(path.join(__dirname, './fixtures/valid.png'))); const receipt = await upload(formData); expect(receipt.provider).toBe('4everland'); - expect(receipt.cid).toBe('bafkreidxvfyqu6l3tb3y5gi2nq5zqyincpev2rangnv7nmaocrk7q3o2fi'); + expect(receipt.cid).toBe('bafkreibenzwnm4pckgeqdyzlwnxemfavkofaynnpxj6o23oojcfe77hvte'); }, 30e3); }); diff --git a/yarn.lock b/yarn.lock index 6ddb6c1..9e0e251 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1240,6 +1240,13 @@ convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0: dependencies: safe-buffer "~5.1.1" +cross-fetch@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" + integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== + dependencies: + node-fetch "2.6.7" + cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" @@ -2725,10 +2732,10 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== -node-fetch@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== +node-fetch@2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== dependencies: whatwg-url "^5.0.0" @@ -3320,7 +3327,7 @@ tr46@^2.1.0: tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= ts-jest@^27.1.4: version "27.1.5" @@ -3452,7 +3459,7 @@ walker@^1.0.7: webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= webidl-conversions@^5.0.0: version "5.0.0" @@ -3479,7 +3486,7 @@ whatwg-mimetype@^2.3.0: whatwg-url@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= dependencies: tr46 "~0.0.3" webidl-conversions "^3.0.0"