How to use interface-ipfs-core - 10 common examples

To help you get started, we’ve selected a few interface-ipfs-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / js-ipfs / test / core / init.spec.js View on Github external
ipfs.init({ bits: 512, emptyRepo: true }, (err) => {
      expect(err).to.not.exist()

      // Should not have default assets
      const multihash = Buffer.from('12205e7c3ce237f936c76faf625e90f7751a9f5eeb048f59873303c215e9cce87599', 'hex')

      ipfs.object.get(multihash, {}, (err, node) => {
        expect(err).to.exist()
        done()
      })
    })
  })
github ipfs / js-ipfs / test / gateway / index.js View on Github external
it('load a directory with index.html', async () => {
    const dir = 'QmbQD7EMEL1zeebwBsWEfA3ndgSS6F7S6iTuwuqasPgVRi/' // note '/' at the end

    const res = await gateway.inject({
      method: 'GET',
      url: '/ipfs/' + dir
    })

    // confirm payload is index.html
    expect(res.statusCode).to.equal(200)
    expect(res.headers['content-type']).to.equal('text/html; charset=utf-8')
    expect(res.headers['x-ipfs-path']).to.equal('/ipfs/' + dir)
    expect(res.headers['cache-control']).to.equal('public, max-age=29030400, immutable')
    expect(res.headers['last-modified']).to.equal('Thu, 01 Jan 1970 00:00:01 GMT')
    expect(res.headers['content-length']).to.equal(res.rawPayload.length)
    expect(res.headers.etag).to.equal('"Qma6665X5k3zti8nKy7gmXK2BndNDSkgmANpV6k3FUjUeg"')
    expect(res.headers.suborigin).to.equal('ipfs000bafybeigccfheqv7upr4k64bkg5b5wiwelunyn2l2rbirmm43m34lcpuqqe')
    expect(res.rawPayload).to.deep.equal(directoryContent['index.html'])
  })
github ipfs / js-ipfs / test / core / name-pubsub.js View on Github external
// Create account for publish
    const testAccount = await nodeA.key.gen(testAccountName, {
      type: 'rsa',
      size: 2048
    })

    const keys = ipns.getIdKeys(fromB58String(testAccount.id))
    const topic = `${namespace}${base64url.encode(keys.routingKey.toBuffer())}`

    await nodeB.pubsub.subscribe(topic, checkMessage)
    await nodeA.name.publish(ipfsRef, { resolve: false, key: testAccountName })
    await waitFor(alreadySubscribed)
    const messageKey = await promisify(peerId.createFromPubKey)(publishedMessage.key)
    const pubKeyPeerId = await promisify(peerId.createFromPubKey)(publishedMessageData.pubKey)

    expect(pubKeyPeerId.toB58String()).not.to.equal(messageKey.toB58String())
    expect(pubKeyPeerId.toB58String()).to.equal(testAccount.id)
    expect(publishedMessage.from).to.equal(idA.id)
    expect(messageKey.toB58String()).to.equal(idA.id)
    expect(publishedMessageDataValue).to.equal(ipfsRef)

    // Verify the signature
    await ipns.validate(pubKeyPeerId._pubKey, publishedMessageData)
  })
})
github ipfs / js-ipfs / test / core / circuit-relay.spec.js View on Github external
])

      relayNode = res[0].ipfsd

      nodeAAddr = res[1].addrs[0]
      nodeA = res[1].ipfsd.api

      nodeBAddr = res[2].addrs[0]

      nodeB = res[2].ipfsd.api
      nodeBCircuitAddr = `/p2p-circuit/ipfs/${multiaddr(nodeBAddr).getPeerId()}`

      // ensure we have an address string
      expect(nodeAAddr).to.be.a('string')
      expect(nodeBAddr).to.be.a('string')
      expect(nodeBCircuitAddr).to.be.a('string')

      await relayNode.api.swarm.connect(nodeAAddr)
      await relayNode.api.swarm.connect(nodeBAddr)
      await new Promise(resolve => setTimeout(resolve, 1000))
      await nodeA.swarm.connect(nodeBCircuitAddr)
    })
github ipfs-shipyard / js-ipfs-http-client-lite / test / interface.spec.js View on Github external
tests.bitswap(defaultCommon, {
    skip: [
      // bitswap.stat
      {
        name: 'should not get bitswap stats when offline',
        reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078'
      },
      // bitswap.wantlist
      {
        name: 'should not get the wantlist when offline',
        reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078'
      }
    ]
  })

  tests.block(defaultCommon, {
    skip: [{
      name: 'should get a block added as CIDv1 with a CIDv0',
      reason: 'LITE: TODO: version param needs to be removed - not implemented in go-ipfs and not valid'
    }]
  })

  tests.bootstrap(defaultCommon, { skip: { reason: 'LITE: not implemented yet' } })

  tests.config(defaultCommon, {
    // skip: [
    //   // config.replace
    //   {
    //     name: 'replace',
    //     reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-http-client/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927'
    //   }
    // ]
github ipfs / js-ipfs-http-client / test / interface.spec.js View on Github external
const commonOptions = {
    test: true,
    ipfsHttpModule: {
      path: require.resolve('../src'),
      ref: require('../src')
    },
    ipfsOptions: {
      pass: 'ipfs-is-awesome-software'
    },
    ipfsBin: findBin('go')
  }
  const commonFactory = createFactory(commonOptions)

  tests.bitswap(commonFactory)

  tests.block(commonFactory, {
    skip: [{
      name: 'should get a block added as CIDv1 with a CIDv0',
      reason: 'go-ipfs does not support the `version` param'
    }]
  })

  tests.bootstrap(commonFactory)

  tests.config(commonFactory, {
    skip: [
      // config.replace
      {
        name: 'replace',
        reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-http-client/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927'
      },
      {
github ipfs / js-ipfs-http-client / test / interface.spec.js View on Github external
pass: 'ipfs-is-awesome-software'
    },
    ipfsBin: findBin('go')
  }
  const commonFactory = createFactory(commonOptions)

  tests.bitswap(commonFactory)

  tests.block(commonFactory, {
    skip: [{
      name: 'should get a block added as CIDv1 with a CIDv0',
      reason: 'go-ipfs does not support the `version` param'
    }]
  })

  tests.bootstrap(commonFactory)

  tests.config(commonFactory, {
    skip: [
      // config.replace
      {
        name: 'replace',
        reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-http-client/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927'
      },
      {
        name: 'should list config profiles',
        reason: 'TODO: Not implemented in go-ipfs'
      },
      {
        name: 'should strip private key from diff output',
        reason: 'TODO: Not implemented in go-ipfs'
      }
github ipfs-shipyard / js-ipfs-http-client-lite / test / interface.spec.js View on Github external
// bitswap.wantlist
      {
        name: 'should not get the wantlist when offline',
        reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078'
      }
    ]
  })

  tests.block(defaultCommon, {
    skip: [{
      name: 'should get a block added as CIDv1 with a CIDv0',
      reason: 'LITE: TODO: version param needs to be removed - not implemented in go-ipfs and not valid'
    }]
  })

  tests.bootstrap(defaultCommon, { skip: { reason: 'LITE: not implemented yet' } })

  tests.config(defaultCommon, {
    // skip: [
    //   // config.replace
    //   {
    //     name: 'replace',
    //     reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-http-client/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927'
    //   }
    // ]
    skip: { reason: 'LITE: not implemented yet' }
  })

  tests.dag(defaultCommon, {
    // skip: [
    //   // dag.tree
    //   {
github ipfs-shipyard / js-ipfs-http-client-lite / test / interface.spec.js View on Github external
name: 'should not get the wantlist when offline',
        reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078'
      }
    ]
  })

  tests.block(defaultCommon, {
    skip: [{
      name: 'should get a block added as CIDv1 with a CIDv0',
      reason: 'LITE: TODO: version param needs to be removed - not implemented in go-ipfs and not valid'
    }]
  })

  tests.bootstrap(defaultCommon, { skip: { reason: 'LITE: not implemented yet' } })

  tests.config(defaultCommon, {
    // skip: [
    //   // config.replace
    //   {
    //     name: 'replace',
    //     reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-http-client/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927'
    //   }
    // ]
    skip: { reason: 'LITE: not implemented yet' }
  })

  tests.dag(defaultCommon, {
    // skip: [
    //   // dag.tree
    //   {
    //     name: 'tree',
    //     reason: 'TODO vmx 2018-02-22: Currently the tree API is not exposed in go-ipfs'
github ipfs / js-ipfs-http-client / test / interface.spec.js View on Github external
ipfsBin: findBin('go')
  }
  const commonFactory = createFactory(commonOptions)

  tests.bitswap(commonFactory)

  tests.block(commonFactory, {
    skip: [{
      name: 'should get a block added as CIDv1 with a CIDv0',
      reason: 'go-ipfs does not support the `version` param'
    }]
  })

  tests.bootstrap(commonFactory)

  tests.config(commonFactory, {
    skip: [
      // config.replace
      {
        name: 'replace',
        reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-http-client/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927'
      },
      {
        name: 'should list config profiles',
        reason: 'TODO: Not implemented in go-ipfs'
      },
      {
        name: 'should strip private key from diff output',
        reason: 'TODO: Not implemented in go-ipfs'
      }
    ]
  })