This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(pubsub): multibase in pubsub http rpc #3922
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
afeb20d
wip(pubsub): use multibase in http rpc wire format
lidel 1dcac76
fix(pubsub): new wire format in http rpc
lidel ac8ecc8
chore: go-ipfs 0.11.0-rc1
lidel 324062c
Merge branch 'master' into feat/pubsub-require-multibase
lidel 6eec580
Merge branch 'master' into feat/pubsub-require-multibase
lidel a536257
chore: fix package.json
lidel 58cce0e
chore: switch interop to pubsub+dht branch
lidel 1a8a4b5
test: pubsub multibase in ipfs-http-server
lidel ecd3b43
chore: go-ipfs 0.11.0-rc2
lidel ab80fc4
Merge 'master' into feat/pubsub-require-multibase
lidel 746dbef
refactor: sharding config in go-ipfs 0.11
lidel d1371d9
Merge 'master' into feat/pubsub-require-multibase
lidel cad816d
fix: regression in /api/v0/files/rm
lidel e2b7a9c
chore: go-ipfs 0.11.0
lidel 7bcc973
chore: disable pubsub examples
lidel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { configure } from '../lib/configure.js' | ||
import { toUrlSearchParams } from '../lib/to-url-search-params.js' | ||
import HTTP from 'ipfs-utils/src/http.js' | ||
|
||
/** | ||
* @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions | ||
|
@@ -20,7 +21,15 @@ export const createRm = configure(api => { | |
headers: options.headers | ||
}) | ||
|
||
await res.text() | ||
const body = await res.text() | ||
// we don't expect text body to be ever present | ||
// (if so, it means an error such as https://github.com/ipfs/go-ipfs/issues/8606) | ||
if (body !== '') { | ||
/** @type {Error} */ | ||
const error = new HTTP.HTTPError(res) | ||
error.message = body | ||
throw error | ||
} | ||
Comment on lines
+24
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @achingbrain would this work around be acceptable here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :groan: |
||
} | ||
return rm | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' | ||
import { toString as uint8ArrayToString } from 'uint8arrays/to-string' | ||
import { base64url } from 'multiformats/bases/base64' | ||
|
||
/* HTTP RPC: | ||
* - wraps binary data in multibase. base64url is used to avoid issues | ||
* when a binary data is passed as search param in URL. | ||
* Historical context: https://github.com/ipfs/go-ipfs/issues/7939 | ||
* Multibase wrapping introduced in: https://github.com/ipfs/go-ipfs/pull/8183 | ||
*/ | ||
|
||
/** | ||
* @param {Array<string>} strings | ||
* @returns {Array<string>} strings | ||
*/ | ||
const rpcArrayToTextArray = strings => { | ||
if (Array.isArray(strings)) { | ||
return strings.map(rpcToText) | ||
} | ||
return strings | ||
} | ||
|
||
/** | ||
* @param {string} mb | ||
* @returns {string} | ||
*/ | ||
const rpcToText = mb => uint8ArrayToString(rpcToBytes(mb)) | ||
|
||
/** | ||
* @param {string} mb | ||
* @returns {Uint8Array} | ||
*/ | ||
const rpcToBytes = mb => base64url.decode(mb) | ||
|
||
/** | ||
* @param {string} text | ||
* @returns {string} | ||
*/ | ||
const textToUrlSafeRpc = text => base64url.encode(uint8ArrayFromString(text)) | ||
|
||
export { rpcArrayToTextArray, rpcToText, rpcToBytes, textToUrlSafeRpc } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yellow goose self?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds better in Polish ;) (it is a valid sentence that includes all polish diacritics, good for testing useful utf8)