Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat: support remote pinning services in ipfs-http-client #3293

Merged
merged 57 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
caf935f
wip: pin.remote.add|ls|rm
lidel Sep 18, 2020
86f8c4c
Merge remote-tracking branch 'upstream/master' into feat/pin-remote
Gozala Nov 13, 2020
4d54a7c
chore: update remote pinning api implementation
Gozala Dec 5, 2020
9669fc6
fix: rename url field to endpoint
Gozala Dec 11, 2020
e1ec19d
fix: make ls type more intelegent in regards stats
Gozala Dec 11, 2020
7f4783d
chore: remove obsolete code
Gozala Dec 11, 2020
e464914
feat: improve API documntation
Gozala Dec 11, 2020
28871af
chore: don't typecheck src in interface-ipfs-core
Gozala Dec 11, 2020
02402c7
trigger ci
Gozala Dec 11, 2020
0da1850
chore: change cid dep to use git pull
Gozala Dec 11, 2020
58134d5
Revert "chore: change cid dep to use git pull"
Gozala Dec 11, 2020
01a75cd
fix: regression introduced by new cid & multicodec
Gozala Dec 11, 2020
9059fbd
chore: switch to go-ipfs 0.8-rc
Gozala Dec 11, 2020
a2ddf44
fix: remove obsolete match fields
Gozala Dec 11, 2020
0c5d277
chore: rename type dir to types
Gozala Dec 11, 2020
1dfef82
chore: merge master in
Gozala Dec 11, 2020
5e2fed3
chore: add ipfs.pin.remote.service tests
Gozala Dec 12, 2020
96eb743
chore: add ipfs.remote.add tests
Gozala Dec 15, 2020
17b47d4
chore: add tests for ipfs.remote.ls
Gozala Dec 15, 2020
83dcdac
Merge remote-tracking branch 'upstream/master' into chore/verify-cid-fix
Gozala Dec 15, 2020
446da30
Revert "chore: fixed cid and multicodec versions (#3445)"
Gozala Dec 15, 2020
2d3268f
chore: fix remaning type missmatches
Gozala Dec 15, 2020
a51a6e5
fix: regressions in examples
Gozala Dec 15, 2020
58d5d0c
chore: revert bundle size
Gozala Dec 15, 2020
f032cbd
chore: fix failing test
achingbrain Dec 15, 2020
8b185ae
chore: update require
achingbrain Dec 15, 2020
f5a37a6
chore: update deps
achingbrain Dec 15, 2020
b568e26
chore: use daemon class instead of cli which does not have it any more
achingbrain Dec 15, 2020
acb7378
Merge remote-tracking branch 'origin/master' into chore/verify-cid-fix
achingbrain Dec 15, 2020
a699b9d
chore: align versions and remove ts-ignore
achingbrain Dec 15, 2020
c2ec920
chore: factor out types into ipfs-interface
Gozala Dec 16, 2020
7dd1e72
chore: revert ts-expect-error
Gozala Dec 16, 2020
0cd45dc
chore: consolidate all the types in one place
Gozala Dec 16, 2020
371529e
chore: merge master
Gozala Dec 16, 2020
777f18e
chore: rename ipfs-interface to ipfs-core-types
Gozala Dec 16, 2020
ec4b5c8
chore: disable dep-check
Gozala Dec 17, 2020
f370ddd
chore: ignore ipfs-core-types in dep checks
Gozala Dec 17, 2020
5432000
chore: add more tests
Gozala Dec 17, 2020
c0acbf1
chore: merge chore/refactor-common-types
Gozala Dec 17, 2020
2f5e08c
chore: migrate types to ipfs-core-types
Gozala Dec 17, 2020
3ac96fa
chore: merge master
Gozala Dec 18, 2020
5dd8dad
chore: bump ipfs-interop dep
Gozala Dec 18, 2020
7947cf2
chore: merge master into feat/pin-remote
Gozala Jan 19, 2021
84b8537
fix: broken test
Gozala Jan 19, 2021
7ae51aa
chore: add pin.remote.rmAll tests
Gozala Jan 19, 2021
7433001
fix: lint issue
Gozala Jan 19, 2021
035b381
fix: node hang
Gozala Jan 20, 2021
95b2fb8
chore: report stop errors
Gozala Jan 20, 2021
3d90b4e
chore: merge master into feat/pin-remote
Gozala Jan 20, 2021
277ae23
chore: merge master into feat/pin-remote
Gozala Jan 26, 2021
9d8b44b
fix: failing type check
Gozala Jan 26, 2021
4c9494d
chore: update libp2p-crypto
Gozala Jan 27, 2021
59d4e76
fix: type annotation
Gozala Jan 28, 2021
5b565f0
Merge remote-tracking branch 'upstream/master' into feat/pin-remote
Gozala Jan 29, 2021
6bb0591
chore: go-ipfs 0.8.0-rc2
lidel Jan 29, 2021
8de937d
chore: update to rc2
Gozala Jan 29, 2021
cacf8bd
fix: incompatibilities with go-ipfs@0.8.0-rc2
Gozala Jan 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
424 changes: 413 additions & 11 deletions docs/core-api/PIN.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/browser-ipns-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"delay": "^4.4.0",
"execa": "^4.0.3",
"ipfsd-ctl": "^7.2.0",
"go-ipfs": "^0.7.0",
"go-ipfs": "0.8.0-rc1",
"parcel-bundler": "^1.12.4",
"path": "^0.12.7",
"test-ipfs-example": "^2.0.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/http-client-browser-pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"devDependencies": {
"execa": "^4.0.3",
"go-ipfs": "^0.7.0",
"go-ipfs": "0.8.0-rc1",
"ipfs": "^0.53.0",
"ipfsd-ctl": "^7.2.0",
"parcel-bundler": "^1.12.4",
Expand Down
2 changes: 1 addition & 1 deletion examples/http-client-name-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"devDependencies": {
"execa": "^4.0.3",
"go-ipfs": "^0.7.0",
"go-ipfs": "0.8.0-rc1",
"ipfsd-ctl": "^7.2.0",
"parcel-bundler": "^1.12.4",
"rimraf": "^3.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/interface-ipfs-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exports.block = require('./block')
exports.dag = require('./dag')
exports.object = require('./object')
exports.pin = require('./pin')
exports.pin.remote = require('./pin/remote')

exports.bootstrap = require('./bootstrap')
exports.dht = require('./dht')
Expand Down
149 changes: 149 additions & 0 deletions packages/interface-ipfs-core/src/pin/remote/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/* eslint-env mocha */
'use strict'

const { fixtures, clearRemotePins, clearServices } = require('../utils')
const { getDescribe, getIt, expect } = require('../../utils/mocha')
const testTimeout = require('../../utils/test-timeout')
const CID = require('cids')

/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
/**
* @param {Factory} common
* @param {Object} options
*/
module.exports = (common, options) => {
const describe = getDescribe(options)
const it = getIt(options)

const ENDPOINT = new URL(process.env.PINNING_SERVICE_ENDPOINT || '')
const KEY = process.env.PINNING_SERVIEC_KEY
const SERVICE = 'pinbot'

describe('.pin.remote.add', function () {
this.timeout(50 * 1000)

let ipfs
before(async () => {
ipfs = (await common.spawn()).api
await ipfs.pin.remote.service.add(SERVICE, {
endpoint: ENDPOINT,
key: KEY
})
})
after(async () => {
await clearServices(ipfs)
await common.clean()
})

beforeEach(async () => {
await clearRemotePins(ipfs)
})

it('should add a CID and return the added CID', async () => {
const pin = await ipfs.pin.remote.add(fixtures.files[0].cid, {
name: 'fixtures-files-0',
background: true,
service: SERVICE
})

expect(pin).to.deep.equal({
status: 'queued',
cid: fixtures.files[0].cid,
name: 'fixtures-files-0'
})
})

it('should fail if service is not provided', async () => {
const result = ipfs.pin.remote.add(fixtures.files[0].cid, {
name: 'fixtures-files-0',
background: true
})

await expect(result).to.eventually.be.rejectedWith(/service name must be passed/)
})

it('if name is not provided defaults to ""', async () => {
const pin = await ipfs.pin.remote.add(fixtures.files[0].cid, {
background: true,
service: SERVICE
})

expect(pin).to.deep.equal({
cid: fixtures.files[0].cid,
name: '',
status: 'queued'
})
})

it('should default to blocking pin', async () => {
const { cid } = fixtures.files[0]
const result = ipfs.pin.remote.add(cid, {
service: SERVICE
})

const timeout = {}

const winner = await Promise.race([
result,
new Promise(resolve => setTimeout(resolve, 100, timeout))
])

expect(winner).to.equal(timeout)

// trigger status change on the mock service
ipfs.pin.remote.add(cid, {
service: SERVICE,
name: 'pinned-block'
})

expect(await result).to.deep.equal({
cid,
status: 'pinned',
name: ''
})
})
it('should pin dag-cbor', async () => {
const cid = await ipfs.dag.put({}, {
format: 'dag-cbor',
hashAlg: 'sha2-256'
})

const pin = await ipfs.pin.remote.add(cid, {
service: SERVICE,
name: 'cbor-pin',
background: true
})

expect(pin).to.deep.equal({
cid,
name: 'cbor-pin',
status: 'queued'
})
})

it('should pin raw', async () => {
const cid = await ipfs.dag.put(new Uint8Array(0), {
format: 'raw',
hashAlg: 'sha2-256'
})

const pin = await ipfs.pin.remote.add(cid, {
service: SERVICE,
background: true
})

expect(pin).to.deep.equal({
cid,
status: 'queued',
name: ''
})
})

it('should respect timeout option when pinning a block', () => {
return testTimeout(() => ipfs.pin.remote.add(new CID('Qmd7qZS4T7xXtsNFdRoK1trfMs5zU94EpokQ9WFtxdPxsZ'), {
timeout: 1,
service: SERVICE
}))
})
})
}
12 changes: 12 additions & 0 deletions packages/interface-ipfs-core/src/pin/remote/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'
const { createSuite } = require('../../utils/suite')

const tests = {
service: require('./service'),
add: require('./add'),
ls: require('./ls'),
rm: require('./rm'),
rmAll: require('./rm-all')
}

module.exports = createSuite(tests)
Loading