Skip to content

Commit

Permalink
feat: Moving from ipfs-http-client -> kubo-rpc-client (#1124)
Browse files Browse the repository at this point in the history
* ipfs-http-client -> kubo-rpc-client

* removing unnecessary packages
  • Loading branch information
whizzzkid committed Jan 3, 2023
1 parent bf88bee commit d439a97
Show file tree
Hide file tree
Showing 7 changed files with 1,318 additions and 323 deletions.
3 changes: 1 addition & 2 deletions add-on/src/lib/ipfs-client/external.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

import debug from 'debug'

import { create } from 'ipfs-http-client'
import { create } from 'kubo-rpc-client'
const log = debug('ipfs-companion:client:external')
log.error = debug('ipfs-companion:client:external:error')

export async function init (browser, opts) {
log(`init with IPFS API at ${opts.apiURLString}`)
const clientConfig = opts.apiURLString
// https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#importing-the-module-and-usage
const api = await create(clientConfig)
return api
}
Expand Down
4 changes: 2 additions & 2 deletions add-on/src/lib/ipfs-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function destroyIpfsClient (browser) {
*
* @typedef {embedded|brave|external} Browser
* @param {Browser} browser
* @param {import('ipfs-http-client').default} instance
* @param {import('kubo-rpc-client').default} instance
* @param {Object} opts
* @param {Array.[InternalTabReloader|LocalGatewayReloader|WebUiReloader]=} reloadExtensions
* @returns {void}
Expand Down Expand Up @@ -102,7 +102,7 @@ async function _reloadIpfsClientDependents (
*
* @typedef {embedded|brave|external} Browser
* @param {Browser} browser
* @param {import('ipfs-http-client').default} instance
* @param {import('kubo-rpc-client').default} instance
* @param {Object} opts
* @returns {void}
*/
Expand Down
2 changes: 1 addition & 1 deletion add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default async function init () {
const onBeforeSendInfoSpec = ['blocking', 'requestHeaders']
if (browser.webRequest.OnBeforeSendHeadersOptions && 'EXTRA_HEADERS' in browser.webRequest.OnBeforeSendHeadersOptions) {
// Chrome 72+ requires 'extraHeaders' for accessing all headers
// Note: we need this for code ensuring ipfs-http-client can talk to API without setting CORS
// Note: we need this for code ensuring kubo-rpc-client can talk to API without setting CORS
onBeforeSendInfoSpec.push('extraHeaders')
}
browser.webRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders, { urls: ['<all_urls>'] }, onBeforeSendInfoSpec)
Expand Down
2 changes: 1 addition & 1 deletion add-on/src/lib/ipfs-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export function createRequestModifier (getState, dnslinkResolver, ipfsPathValida
// '403 - Forbidden' fix for Chrome and Firefox
// --------------------------------------------
// We update "Origin: *-extension://" HTTP headers in requests made to API
// by js-ipfs-http-client running in the background page of browser
// by js-kubo-rpc-client running in the background page of browser
// extension. Without this, some users would need to do manual CORS
// whitelisting by adding "..extension://<UUID>" to
// API.HTTPHeaders.Access-Control-Allow-Origin in go-ipfs config.
Expand Down
Loading

0 comments on commit d439a97

Please sign in to comment.