diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0bc3b42 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 + commit-message: + prefix: "deps" + prefix-development: "deps(dev)" diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..d57c2a0 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,8 @@ +name: Automerge +on: [ pull_request ] + +jobs: + automerge: + uses: protocol/.github/.github/workflows/automerge.yml@master + with: + job: 'automerge' diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml new file mode 100644 index 0000000..5168641 --- /dev/null +++ b/.github/workflows/js-test-and-release.yml @@ -0,0 +1,181 @@ +name: test & maybe release +on: + push: + branches: + - main + pull_request: + +jobs: + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present lint + - run: npm run --if-present dep-check + + test-node: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + node: [lts/*] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:node + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: node + + test-chrome: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: chrome + + test-chrome-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:chrome-webworker + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: chrome-webworker + + test-firefox: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: firefox + + test-firefox-webworker: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:firefox-webworker + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: firefox-webworker + + test-webkit: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + node: [lts/*] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:webkit + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: webkit + + test-webkit-webworker: + needs: check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + node: [lts/*] + fail-fast: true + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present test:webkit-webworker + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: webkit-webworker + + test-electron-main: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-main + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: electron-main + + test-electron-renderer: + needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npx xvfb-maybe npm run --if-present test:electron-renderer + - uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1 + with: + flags: electron-renderer + + release: + needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-webkit, test-webkit-webworker, test-electron-main, test-electron-renderer] + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/docker-login@master + with: + docker-token: ${{ secrets.DOCKER_TOKEN }} + docker-username: ${{ secrets.DOCKER_USERNAME }} + - run: npm run --if-present release + env: + GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN || github.token }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..6f6d895 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,26 @@ +name: Close and mark stale issue + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.' + close-issue-message: 'This issue was closed because it is missing author input.' + stale-issue-label: 'kind/stale' + any-of-labels: 'need/author-input' + exempt-issue-labels: 'need/triage,need/community-input,need/maintainer-input,need/maintainers-input,need/analysis,status/blocked,status/in-progress,status/ready,status/deferred,status/inactive' + days-before-issue-stale: 6 + days-before-issue-close: 7 + enable-statistics: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7ad9e67 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +node_modules +build +dist +.docs +.coverage +node_modules +package-lock.json +yarn.lock +.vscode diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..20ce483 --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..14478a3 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..72dc60d --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..85e4946 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# @helia/strings + +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-strings.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-strings) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-strings/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-strings/actions/workflows/js-test-and-release.yml?query=branch%3Amain) + +> Add/get IPLD blocks containing strings with your Helia node + +## Table of contents + +- - [Structure](#structure) +- [@helia/unixfs ](#heliaunixfs----omit-in-toc---) + - [API Docs](#api-docs) + - [License](#license) + - [Contribute](#contribute) + +## Structure + +- [`/packages/interop`](./packages/interop) Interop tests for @helia/unixfs +- [`/packages/strings`](./packages/strings) Add/get IPLD blocks containing strings with your Helia node + +

+ + Helia logo + +

+ +# @helia/unixfs + +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-unixfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-unixfs) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-unixfs/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-unixfs/actions/workflows/js-test-and-release.yml?query=branch%3Amain) + +## API Docs + +- + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-strings/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/package.json b/package.json new file mode 100644 index 0000000..d0eb968 --- /dev/null +++ b/package.json @@ -0,0 +1,48 @@ +{ + "name": "@helia/strings", + "version": "0.0.0", + "description": "Add/get IPLD blocks containing strings with your Helia node", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/helia-strings#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/helia-strings.git" + }, + "bugs": { + "url": "https://github.com/ipfs/helia-strings/issues" + }, + "keywords": [ + "ipfs" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "private": true, + "scripts": { + "reset": "aegir run clean && aegir clean **/node_modules **/package-lock.json", + "test": "aegir run test", + "test:node": "aegir run test:node", + "test:chrome": "aegir run test:chrome", + "test:chrome-webworker": "aegir run test:chrome-webworker", + "test:firefox": "aegir run test:firefox", + "test:firefox-webworker": "aegir run test:firefox-webworker", + "test:electron-main": "aegir run test:electron-main", + "test:electron-renderer": "aegir run test:electron-renderer", + "clean": "aegir run clean", + "generate": "aegir run generate", + "build": "aegir run build", + "lint": "aegir run lint", + "docs": "NODE_OPTIONS=--max_old_space_size=4096 aegir docs", + "docs:no-publish": "npm run docs -- --publish false", + "dep-check": "aegir run dep-check", + "release": "npm run docs:no-publish && aegir run release && npm run docs" + }, + "devDependencies": { + "aegir": "^38.1.0" + }, + "type": "module", + "workspaces": [ + "packages/*" + ] +} diff --git a/packages/interop/.aegir.js b/packages/interop/.aegir.js new file mode 100644 index 0000000..498799a --- /dev/null +++ b/packages/interop/.aegir.js @@ -0,0 +1,45 @@ +import getPort from 'aegir/get-port' +import { createServer } from 'ipfsd-ctl' +import * as kuboRpcClient from 'kubo-rpc-client' + +/** @type {import('aegir').PartialOptions} */ +export default { + test: { + before: async (options) => { + if (options.runner !== 'node') { + const ipfsdPort = await getPort() + const ipfsdServer = await createServer({ + host: '127.0.0.1', + port: ipfsdPort + }, { + ipfsBin: (await import('go-ipfs')).default.path(), + kuboRpcModule: kuboRpcClient, + ipfsOptions: { + config: { + Addresses: { + Swarm: [ + "/ip4/0.0.0.0/tcp/4001", + "/ip4/0.0.0.0/tcp/4002/ws" + ] + } + } + } + }).start() + + return { + env: { + IPFSD_SERVER: `http://127.0.0.1:${ipfsdPort}` + }, + ipfsdServer + } + } + + return {} + }, + after: async (options, beforeResult) => { + if (options.runner !== 'node') { + await beforeResult.ipfsdServer.stop() + } + } + } +} diff --git a/packages/interop/LICENSE b/packages/interop/LICENSE new file mode 100644 index 0000000..20ce483 --- /dev/null +++ b/packages/interop/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/interop/LICENSE-APACHE b/packages/interop/LICENSE-APACHE new file mode 100644 index 0000000..14478a3 --- /dev/null +++ b/packages/interop/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/interop/LICENSE-MIT b/packages/interop/LICENSE-MIT new file mode 100644 index 0000000..72dc60d --- /dev/null +++ b/packages/interop/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/interop/README.md b/packages/interop/README.md new file mode 100644 index 0000000..7469aa2 --- /dev/null +++ b/packages/interop/README.md @@ -0,0 +1,67 @@ +# @helia/unixfs-interop + +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-strings.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-strings) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-strings/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-strings/actions/workflows/js-test-and-release.yml?query=branch%3Amain) + +> Interop tests for @helia/unixfs + +## Table of contents + +- - [Install](#install) + - [Browser ` +``` + +

+ + Helia logo + +

+ +# @helia/unixfs-interop + +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-unixfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-unixfs) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-unixfs/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-unixfs/actions/workflows/js-test-and-release.yml?query=branch%3Amain) + +## API Docs + +- + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-strings/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/interop/package.json b/packages/interop/package.json new file mode 100644 index 0000000..8fbc53f --- /dev/null +++ b/packages/interop/package.json @@ -0,0 +1,84 @@ +{ + "name": "@helia/unixfs-interop", + "version": "0.0.0", + "description": "Interop tests for @helia/unixfs", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/helia-strings/tree/master/packages/interop#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/helia-strings.git" + }, + "bugs": { + "url": "https://github.com/ipfs/helia-strings/issues" + }, + "keywords": [ + "IPFS" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "scripts": { + "clean": "aegir clean", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "build": "aegir build", + "test": "aegir test", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "test:node": "aegir test -t node --cov", + "test:electron-main": "aegir test -t electron-main" + }, + "devDependencies": { + "@chainsafe/libp2p-noise": "^11.0.0", + "@chainsafe/libp2p-yamux": "^3.0.5", + "@helia/interface": "^1.0.0", + "@helia/strings": "~0.0.0", + "@libp2p/tcp": "^6.1.2", + "@libp2p/websockets": "^5.0.3", + "aegir": "^38.1.0", + "blockstore-core": "^4.0.1", + "datastore-core": "^9.0.3", + "go-ipfs": "^0.19.0", + "helia": "^1.0.0", + "ipfs-core-types": "^0.14.0", + "ipfs-unixfs-importer": "^15.1.0", + "ipfsd-ctl": "^13.0.0", + "it-to-buffer": "^4.0.1", + "kubo-rpc-client": "^3.0.0", + "libp2p": "^0.43.2", + "merge-options": "^3.0.4", + "multiformats": "^11.0.1", + "wherearewe": "^2.0.1" + }, + "browser": { + "./dist/test/fixtures/create-helia.js": "./dist/test/fixtures/create-helia.browser.js", + "go-ipfs": false + }, + "private": true, + "typedoc": { + "entryPoint": "./src/index.ts" + } +} diff --git a/packages/interop/src/index.ts b/packages/interop/src/index.ts new file mode 100644 index 0000000..336ce12 --- /dev/null +++ b/packages/interop/src/index.ts @@ -0,0 +1 @@ +export {} diff --git a/packages/interop/test/fixtures/create-helia.browser.ts b/packages/interop/test/fixtures/create-helia.browser.ts new file mode 100644 index 0000000..d28c6ef --- /dev/null +++ b/packages/interop/test/fixtures/create-helia.browser.ts @@ -0,0 +1,41 @@ +import { createHelia } from 'helia' +import { createLibp2p } from 'libp2p' +import { webSockets } from '@libp2p/websockets' +import { all } from '@libp2p/websockets/filters' +import { noise } from '@chainsafe/libp2p-noise' +import { yamux } from '@chainsafe/libp2p-yamux' +import { MemoryBlockstore } from 'blockstore-core' +import { MemoryDatastore } from 'datastore-core' +import type { Helia } from '@helia/interface' + +export async function createHeliaNode (): Promise { + const blockstore = new MemoryBlockstore() + const datastore = new MemoryDatastore() + + // dial-only in the browser until webrtc browser-to-browser arrives + const libp2p = await createLibp2p({ + transports: [ + webSockets({ + filter: all + }) + ], + connectionEncryption: [ + noise() + ], + streamMuxers: [ + yamux() + ], + datastore, + nat: { + enabled: false + } + }) + + const helia = await createHelia({ + libp2p, + blockstore, + datastore + }) + + return helia +} diff --git a/packages/interop/test/fixtures/create-helia.ts b/packages/interop/test/fixtures/create-helia.ts new file mode 100644 index 0000000..7a7201b --- /dev/null +++ b/packages/interop/test/fixtures/create-helia.ts @@ -0,0 +1,38 @@ +import { createHelia } from 'helia' +import { createLibp2p, Libp2pOptions } from 'libp2p' +import { tcp } from '@libp2p/tcp' +import { noise } from '@chainsafe/libp2p-noise' +import { yamux } from '@chainsafe/libp2p-yamux' +import { MemoryBlockstore } from 'blockstore-core' +import { MemoryDatastore } from 'datastore-core' +import type { Helia } from '@helia/interface' + +export async function createHeliaNode (config: Libp2pOptions = {}): Promise { + const blockstore = new MemoryBlockstore() + const datastore = new MemoryDatastore() + + const libp2p = await createLibp2p({ + transports: [ + tcp() + ], + connectionEncryption: [ + noise() + ], + streamMuxers: [ + yamux() + ], + datastore, + nat: { + enabled: false + }, + ...config + }) + + const helia = await createHelia({ + libp2p, + blockstore, + datastore + }) + + return helia +} diff --git a/packages/interop/test/fixtures/create-kubo.ts b/packages/interop/test/fixtures/create-kubo.ts new file mode 100644 index 0000000..7fd4872 --- /dev/null +++ b/packages/interop/test/fixtures/create-kubo.ts @@ -0,0 +1,28 @@ + +// @ts-expect-error no types +import * as goIpfs from 'go-ipfs' +import { Controller, ControllerOptions, createController } from 'ipfsd-ctl' +import * as kuboRpcClient from 'kubo-rpc-client' +import { isElectronMain, isNode } from 'wherearewe' +import mergeOptions from 'merge-options' + +export async function createKuboNode (options: ControllerOptions<'go'> = {}): Promise { + const opts = mergeOptions({ + kuboRpcModule: kuboRpcClient, + ipfsBin: isNode || isElectronMain ? goIpfs.path() : undefined, + test: true, + endpoint: process.env.IPFSD_SERVER, + ipfsOptions: { + config: { + Addresses: { + Swarm: [ + '/ip4/0.0.0.0/tcp/4001', + '/ip4/0.0.0.0/tcp/4002/ws' + ] + } + } + } + }, options) + + return await createController(opts) +} diff --git a/packages/interop/test/strings.spec.ts b/packages/interop/test/strings.spec.ts new file mode 100644 index 0000000..a243a58 --- /dev/null +++ b/packages/interop/test/strings.spec.ts @@ -0,0 +1,65 @@ +/* eslint-env mocha */ + +import { expect } from 'aegir/chai' +import { createHeliaNode } from './fixtures/create-helia.js' +import { createKuboNode } from './fixtures/create-kubo.js' +import type { Helia } from '@helia/interface' +import type { Controller } from 'ipfsd-ctl' +import { strings, Strings, AddOptions } from '@helia/strings' +import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' +import { toString as uint8ArrayToString } from 'uint8arrays/to-string' +import type { PutOptions as KuboAddOptions } from 'ipfs-core-types/src/block/index.js' + +describe('strings interop', () => { + let helia: Helia + let str: Strings + let kubo: Controller + + async function expectSameCid (data: () => string, heliaOpts: Partial = {}, kuboOpts: KuboAddOptions = {}): Promise { + const heliaCid = await str.add(data(), heliaOpts) + const kuboCid = await kubo.api.block.put(uint8ArrayFromString(data()), kuboOpts) + + expect(heliaCid.toString()).to.equal(kuboCid.toString()) + } + + beforeEach(async () => { + helia = await createHeliaNode() + str = strings(helia) + kubo = await createKuboNode() + + await helia.libp2p.dial((await (kubo.api.id())).addresses) + }) + + afterEach(async () => { + if (helia != null) { + await helia.stop() + } + + if (kubo != null) { + await kubo.stop() + } + }) + + it('should create the same CID for a string', async () => { + const candidate = (): string => 'hello world' + + await expectSameCid(candidate) + }) + + it('should add to helia and fetch from kubo', async () => { + const input = 'hello world' + const cid = await str.add(input) + const block = await kubo.api.block.get(cid) + const output = uint8ArrayToString(block) + + expect(output).to.equal(input) + }) + + it('should add to kubo and fetch from helia', async () => { + const input = 'hello world' + const cid = await kubo.api.block.put(uint8ArrayFromString(input)) + const output = await str.get(cid) + + expect(output).to.equal(input) + }) +}) diff --git a/packages/interop/tsconfig.json b/packages/interop/tsconfig.json new file mode 100644 index 0000000..a5e5a4c --- /dev/null +++ b/packages/interop/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": [ + "src", + "test" + ], + "references": [ + { + "path": "../strings" + } + ] +} diff --git a/packages/strings/CHANGELOG.md b/packages/strings/CHANGELOG.md new file mode 100644 index 0000000..e00510b --- /dev/null +++ b/packages/strings/CHANGELOG.md @@ -0,0 +1,83 @@ +## [@helia/unixfs-v1.2.1](https://github.com/ipfs/helia-unixfs/compare/@helia/unixfs-v1.2.0...@helia/unixfs-v1.2.1) (2023-03-23) + + +### Dependencies + +* update helia deps to v1 ([#16](https://github.com/ipfs/helia-unixfs/issues/16)) ([7497590](https://github.com/ipfs/helia-unixfs/commit/74975903ec619a4662e5bfa9546997641e9f8e8c)) + +## [@helia/unixfs-v1.2.0](https://github.com/ipfs/helia-unixfs/compare/@helia/unixfs-v1.1.0...@helia/unixfs-v1.2.0) (2023-03-17) + + +### Features + +* expose unixfs progress events in types ([#14](https://github.com/ipfs/helia-unixfs/issues/14)) ([36cf3b2](https://github.com/ipfs/helia-unixfs/commit/36cf3b2143276a59b685ceb58299c4f881545fee)) + +## [@helia/unixfs-v1.1.0](https://github.com/ipfs/helia-unixfs/compare/@helia/unixfs-v1.0.5...@helia/unixfs-v1.1.0) (2023-03-15) + + +### Features + +* expose progress events from importer, blockstore and bitswap ([#13](https://github.com/ipfs/helia-unixfs/issues/13)) ([de78f4d](https://github.com/ipfs/helia-unixfs/commit/de78f4d03ebafe9ed9a2dfcbfb7a516fa215585c)) + + +### Trivial Changes + +* add interop test suite ([#12](https://github.com/ipfs/helia-unixfs/issues/12)) ([3ad5f5d](https://github.com/ipfs/helia-unixfs/commit/3ad5f5d8199a5596aa333916d4a240584bc0842a)) + +## [1.0.5](https://github.com/ipfs/helia-unixfs/compare/v1.0.4...v1.0.5) (2023-03-14) + + +### Bug Fixes + +* align defaults with filecoin ([#6](https://github.com/ipfs/helia-unixfs/issues/6)) ([a6bd198](https://github.com/ipfs/helia-unixfs/commit/a6bd1983bd7baac21af3de6fa269219f52664cde)) + +## [1.0.4](https://github.com/ipfs/helia-unixfs/compare/v1.0.3...v1.0.4) (2023-02-27) + + +### Bug Fixes + +* simplify shard handling ([#5](https://github.com/ipfs/helia-unixfs/issues/5)) ([52d4786](https://github.com/ipfs/helia-unixfs/commit/52d4786831c3b2b60322de562b752ecfbc8791bb)) + +## [1.0.3](https://github.com/ipfs/helia-unixfs/compare/v1.0.2...v1.0.3) (2023-02-25) + + +### Bug Fixes + +* enable last shard tests ([#4](https://github.com/ipfs/helia-unixfs/issues/4)) ([9774460](https://github.com/ipfs/helia-unixfs/commit/97744606d6da2e61a1aefa6af8f0f3b68f8827ab)) + +## [1.0.2](https://github.com/ipfs/helia-unixfs/compare/v1.0.1...v1.0.2) (2023-02-24) + + +### Bug Fixes + +* add methods to import data ([#3](https://github.com/ipfs/helia-unixfs/issues/3)) ([917a564](https://github.com/ipfs/helia-unixfs/commit/917a564c0d990dfd35d4615436fc8e3609c72a76)) + + +### Tests + +* move test file data to fixtures ([1b76084](https://github.com/ipfs/helia-unixfs/commit/1b760847a18b7b7c1e3fa8c871fd75acb298480b)) + +## [1.0.1](https://github.com/ipfs/helia-unixfs/compare/v1.0.0...v1.0.1) (2023-02-17) + + +### Bug Fixes + +* update unixfs importer ([f6edeca](https://github.com/ipfs/helia-unixfs/commit/f6edeca471da4aaa2171b0b3f2d2ea91d527a00e)) + +## 1.0.0 (2023-02-16) + + +### Features + +* initial implementation ([#1](https://github.com/ipfs/helia-unixfs/issues/1)) ([adb6b0e](https://github.com/ipfs/helia-unixfs/commit/adb6b0e2626a3bdd08cdc4445e3367f104bc5bb8)) + + +### Trivial Changes + +* initial commit ([35e8a8f](https://github.com/ipfs/helia-unixfs/commit/35e8a8fd7c1ca68b21320b95211304bf01b30086)) +* Update .github/workflows/stale.yml [skip ci] ([bcb060d](https://github.com/ipfs/helia-unixfs/commit/bcb060d880175ab885479388049a1ca2e5873629)) + + +### Documentation + +* update readme ([83e5e0e](https://github.com/ipfs/helia-unixfs/commit/83e5e0e0ccfd27f9371c9a8940c237e398e9b68f)) diff --git a/packages/strings/LICENSE b/packages/strings/LICENSE new file mode 100644 index 0000000..20ce483 --- /dev/null +++ b/packages/strings/LICENSE @@ -0,0 +1,4 @@ +This project is dual licensed under MIT and Apache-2.0. + +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/strings/LICENSE-APACHE b/packages/strings/LICENSE-APACHE new file mode 100644 index 0000000..14478a3 --- /dev/null +++ b/packages/strings/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/strings/LICENSE-MIT b/packages/strings/LICENSE-MIT new file mode 100644 index 0000000..72dc60d --- /dev/null +++ b/packages/strings/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/strings/README.md b/packages/strings/README.md new file mode 100644 index 0000000..afe7604 --- /dev/null +++ b/packages/strings/README.md @@ -0,0 +1,67 @@ +# @helia/strings + +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-strings.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-strings) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-strings/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-strings/actions/workflows/js-test-and-release.yml?query=branch%3Amain) + +> Add/get IPLD blocks containing strings with your Helia node + +## Table of contents + +- - [Install](#install) + - [Browser ` +``` + +

+ + Helia logo + +

+ +# @helia/unixfs + +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-unixfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-unixfs) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-unixfs/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-unixfs/actions/workflows/js-test-and-release.yml?query=branch%3Amain) + +## API Docs + +- + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-strings/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/strings/package.json b/packages/strings/package.json new file mode 100644 index 0000000..e0d35ae --- /dev/null +++ b/packages/strings/package.json @@ -0,0 +1,154 @@ +{ + "name": "@helia/strings", + "version": "0.0.0", + "description": "Add/get IPLD blocks containing strings with your Helia node", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/helia-strings/tree/master/packages/strings#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/helia-strings.git" + }, + "bugs": { + "url": "https://github.com/ipfs/helia-strings/issues" + }, + "keywords": [ + "IPFS" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", + "files": [ + "src", + "dist", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" + } + }, + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } + }, + "release": { + "branches": [ + "main" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "revert": true, + "release": "patch" + }, + { + "type": "feat", + "release": "minor" + }, + { + "type": "fix", + "release": "patch" + }, + { + "type": "docs", + "release": "patch" + }, + { + "type": "test", + "release": "patch" + }, + { + "type": "deps", + "release": "patch" + }, + { + "scope": "no-release", + "release": false + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "chore", + "section": "Trivial Changes" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "test", + "section": "Tests" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/npm", + "@semantic-release/github", + "@semantic-release/git" + ] + }, + "scripts": { + "clean": "aegir clean", + "lint": "aegir lint", + "dep-check": "aegir dep-check", + "build": "aegir build", + "docs": "aegir docs", + "test": "aegir test", + "test:chrome": "aegir test -t browser --cov", + "test:chrome-webworker": "aegir test -t webworker", + "test:firefox": "aegir test -t browser -- --browser firefox", + "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", + "test:node": "aegir test -t node --cov", + "test:electron-main": "aegir test -t electron-main", + "release": "aegir release" + }, + "dependencies": { + "interface-blockstore": "^5.0.0", + "multiformats": "^11.0.1", + "progress-events": "^1.0.0", + "uint8arrays": "^4.0.3" + }, + "devDependencies": { + "aegir": "^38.1.0", + "blockstore-core": "^4.0.1" + }, + "typedoc": { + "entryPoint": "./src/index.ts" + } +} diff --git a/packages/strings/src/index.ts b/packages/strings/src/index.ts new file mode 100644 index 0000000..4ee415e --- /dev/null +++ b/packages/strings/src/index.ts @@ -0,0 +1,122 @@ +/** + * @packageDocumentation + * + * `@helia/strings` makes working with strings {@link https://github.com/ipfs/helia Helia} simple & straightforward. + * + * See the {@link Strings Strings interface} for all available operations. + * + * @example + * + * ```typescript + * import { createHelia } from 'helia' + * import { strings } from '@helia/strings' + * import { CID } from 'multiformats/cid' + * + * const str = strings(helia) + * const cid = await str.put('hello world') + * const string = await str.get(cid) + * + * console.info(string) + * // hello world + * ``` + */ + +import { CID } from 'multiformats/cid' +import type { Blocks, GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks' +import type { AbortOptions } from '@libp2p/interfaces' +import type { ProgressOptions } from 'progress-events' +import { sha256 } from 'multiformats/hashes/sha2' +import * as raw from 'multiformats/codecs/raw' +import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' +import { toString as uint8ArrayToString } from 'uint8arrays/to-string' +import type { BlockCodec } from 'multiformats/codecs/interface' +import type { MultihashHasher } from 'multiformats/hashes/interface' + +export interface StringsComponents { + blockstore: Blocks +} + +export interface AddOptions extends AbortOptions, ProgressOptions { + hasher: MultihashHasher + codec: BlockCodec +} + +export interface GetOptions extends AbortOptions, ProgressOptions { + codec: BlockCodec +} + +/** + * The UnixFS interface provides familiar filesystem operations to make working with + * UnixFS DAGs simple and intuitive. + */ +export interface Strings { + /** + * Add a string to your Helia node and get a CID that refers to the block the + * string has been stored as. + * + * @example + * + * ```typescript + * import { strings } from '@helia/strings' + * + * const str = strings(helia) + * const cid = await str.add('hello world') + * + * console.info(cid) + * // CID(QmFoo) + * ``` + */ + add: (str: string, options?: Partial) => Promise + + /** + * Get a string from your Helia node, either previously added to it or to + * another node on the network. + * + * @example + * + * ```typescript + * import { strings } from '@helia/strings' + * import { CID } from 'multiformats/cid' + * + * const str = strings(helia) + * const cid = CID.parse('') + * const string = await str.get(cid) + * + * console.info(string) + * // hello world + * ``` + */ + get: (cid: CID, options?: Partial) => Promise +} + +class DefaultStrings implements Strings { + private readonly components: StringsComponents + + constructor (components: StringsComponents) { + this.components = components + } + + async add (string: string, options: Partial = {}): Promise { + const buf = uint8ArrayFromString(string) + const hash = await (options.hasher ?? sha256).digest(buf) + const codec = options.codec ?? raw + const cid = CID.createV1(codec.code, hash) + + await this.components.blockstore.put(cid, buf, options) + + return cid + } + + async get (cid: CID, options: Partial = {}): Promise { + const buf = await this.components.blockstore.get(cid, options) + + return uint8ArrayToString(buf) + } +} + +/** + * Create a {@link Strings} instance for use with {@link https://github.com/ipfs/helia Helia} + */ +export function strings (helia: { blockstore: Blocks }): Strings { + return new DefaultStrings(helia) +} diff --git a/packages/strings/test/add.spec.ts b/packages/strings/test/add.spec.ts new file mode 100644 index 0000000..9864b26 --- /dev/null +++ b/packages/strings/test/add.spec.ts @@ -0,0 +1,23 @@ +/* eslint-env mocha */ + +import { expect } from 'aegir/chai' +import type { Blockstore } from 'interface-blockstore' +import { strings, Strings } from '../src/index.js' +import { MemoryBlockstore } from 'blockstore-core' + +describe('put', () => { + let blockstore: Blockstore + let str: Strings + + beforeEach(async () => { + blockstore = new MemoryBlockstore() + + str = strings({ blockstore }) + }) + + it('adds a string', async () => { + const cid = await str.add('hello world') + + expect(`${cid}`).to.equal('bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e') + }) +}) diff --git a/packages/strings/test/get.spec.ts b/packages/strings/test/get.spec.ts new file mode 100644 index 0000000..7fbfca2 --- /dev/null +++ b/packages/strings/test/get.spec.ts @@ -0,0 +1,26 @@ +/* eslint-env mocha */ + +import { expect } from 'aegir/chai' +import type { Blockstore } from 'interface-blockstore' +import { strings, Strings } from '../src/index.js' +import { MemoryBlockstore } from 'blockstore-core' +import type { CID } from 'multiformats/cid' + +describe('get', () => { + let blockstore: Blockstore + let str: Strings + let cid: CID + + beforeEach(async () => { + blockstore = new MemoryBlockstore() + + str = strings({ blockstore }) + cid = await str.add('hello world') + }) + + it('adds a string', async () => { + const string = await str.get(cid) + + expect(`${string}`).to.equal('hello world') + }) +}) diff --git a/packages/strings/tsconfig.json b/packages/strings/tsconfig.json new file mode 100644 index 0000000..13a3599 --- /dev/null +++ b/packages/strings/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": [ + "src", + "test" + ] +}