Skip to content

Commit

Permalink
deps!: update multiformats to v11
Browse files Browse the repository at this point in the history
`multiformats@11.x.x` shipped with a [breaking change](multiformats/js-multiformats#230) so update all deps using
multiformats to the latest version.
  • Loading branch information
achingbrain committed Jan 7, 2023
1 parent eabdd43 commit e669855
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 102 deletions.
68 changes: 4 additions & 64 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,66 +1,6 @@
dist/
docs/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# while testing npm5
node_modules
dist
.docs
.coverage
package-lock.json
yarn.lock
types
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
[![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/js-datastore-pubsub.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-datastore-pubsub)
[![CI](https://img.shields.io/github/workflow/status/ipfs/js-datastore-pubsub/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-datastore-pubsub/actions/workflows/js-test-and-release.yml)
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-datastore-pubsub/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/js-datastore-pubsub/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)

> Responsible for providing an interface-datastore compliant api to pubsub
## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Usage](#usage)
- [API](#api)
- - [Setup](#setup)
- [Get](#get)
- [Put](#put)
- [Unsubscribe](#unsubscribe)
- [Contribute](#contribute)
- [API Docs](#api-docs)
- [License](#license)
- [Contribute](#contribute-1)

Expand All @@ -26,6 +28,14 @@
$ npm i datastore-pubsub
```

### Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `DatastorePubsub` in the global namespace.

```html
<script src="https://unpkg.com/datastore-pubsub/dist/index.min.js"></script>
```

## Usage

```js
Expand Down Expand Up @@ -109,6 +119,10 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c

[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)

## API Docs

- <https://ipfs.github.io/js-datastore-pubsub>

## License

Licensed under either of
Expand Down
34 changes: 11 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,39 +154,27 @@
"test:firefox": "aegir test -t browser -- --browser firefox",
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"test:electron-main": "aegir test -t electron-main",
"dep-check": "aegir dep-check -i rimraf"
"dep-check": "aegir dep-check",
"docs": "aegir docs"
},
"dependencies": {
"@libp2p/interface-dht": "^1.0.1",
"@libp2p/interface-dht": "^2.0.0",
"@libp2p/interface-pubsub": "^3.0.0",
"@libp2p/interfaces": "^3.0.3",
"@libp2p/interfaces": "^3.2.0",
"@libp2p/logger": "^2.0.0",
"datastore-core": "^8.0.1",
"debug": "^4.2.0",
"err-code": "^3.0.1",
"interface-datastore": "^7.0.0",
"uint8arrays": "^4.0.2"
},
"devDependencies": {
"@libp2p/floodsub": "^5.0.0",
"@libp2p/interface-compliance-tests": "^3.0.2",
"@libp2p/interface-mocks": "^7.0.1",
"@libp2p/interface-peer-id": "^1.0.5",
"@libp2p/floodsub": "^6.0.0",
"@libp2p/interface-mocks": "^9.0.0",
"@libp2p/interface-peer-id": "^2.0.0",
"@libp2p/interface-registrar": "^2.0.3",
"@libp2p/peer-id-factory": "^1.0.9",
"@libp2p/record": "^2.0.0",
"@types/detect-node": "^2.0.0",
"aegir": "^37.0.13",
"detect-node": "^2.0.4",
"install": "^0.13.0",
"ipfs-core-types": "^0.12.1",
"it-pair": "^2.0.2",
"libp2p": "next",
"npm": "^8.10.0",
"@libp2p/peer-id-factory": "^2.0.0",
"@libp2p/record": "^3.0.0",
"aegir": "^37.10.0",
"p-wait-for": "^5.0.0",
"peer-id": "^0.16.0",
"rimraf": "^3.0.2",
"sinon": "^14.0.0",
"util": "^0.12.4"
"sinon": "^15.0.1"
}
}
26 changes: 13 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Key } from 'interface-datastore'
import { BaseDatastore } from 'datastore-core'
import { encodeBase32, keyToTopic, topicToKey } from './utils.js'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
import errcode from 'err-code'
import { CodeError } from '@libp2p/interfaces/errors'
import { logger } from '@libp2p/logger'

const log = logger('datastore-pubsub:publisher')
Expand Down Expand Up @@ -32,19 +32,19 @@ export class PubSubDatastore extends BaseDatastore {
super()

if (!validator) {
throw errcode(new TypeError('missing validator'), 'ERR_INVALID_PARAMETERS')
throw new CodeError('missing validator', 'ERR_INVALID_PARAMETERS')
}

if (typeof validator !== 'function') {
throw errcode(new TypeError('missing validate function'), 'ERR_INVALID_PARAMETERS')
throw new CodeError('missing validate function', 'ERR_INVALID_PARAMETERS')
}

if (typeof selector !== 'function') {
throw errcode(new TypeError('missing select function'), 'ERR_INVALID_PARAMETERS')
throw new CodeError('missing select function', 'ERR_INVALID_PARAMETERS')
}

if (subscriptionKeyFn && typeof subscriptionKeyFn !== 'function') {
throw errcode(new TypeError('invalid subscriptionKeyFn received'), 'ERR_INVALID_PARAMETERS')
throw new CodeError('invalid subscriptionKeyFn received', 'ERR_INVALID_PARAMETERS')
}

this._pubsub = pubsub
Expand Down Expand Up @@ -72,14 +72,14 @@ export class PubSubDatastore extends BaseDatastore {
const errMsg = 'datastore key does not have a valid format'

log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY')
throw new CodeError(errMsg, 'ERR_INVALID_DATASTORE_KEY')
}

if (!(val instanceof Uint8Array)) {
const errMsg = 'received value is not a Uint8Array'

log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_INVALID_VALUE_RECEIVED')
throw new CodeError(errMsg, 'ERR_INVALID_VALUE_RECEIVED')
}

const stringifiedTopic = keyToTopic(key)
Expand All @@ -102,7 +102,7 @@ export class PubSubDatastore extends BaseDatastore {
const errMsg = 'datastore key does not have a valid format'

log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY')
throw new CodeError(errMsg, 'ERR_INVALID_DATASTORE_KEY')
}

const stringifiedTopic = keyToTopic(key)
Expand All @@ -120,7 +120,7 @@ export class PubSubDatastore extends BaseDatastore {
const errMsg = `cannot subscribe topic ${stringifiedTopic}`

log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_SUBSCRIBING_TOPIC')
throw new CodeError(errMsg, 'ERR_SUBSCRIBING_TOPIC')
}
log(`subscribed values for key ${stringifiedTopic}`)

Expand Down Expand Up @@ -158,19 +158,19 @@ export class PubSubDatastore extends BaseDatastore {
const errMsg = `unexpected error getting the ipns record for ${routingKey.toString()}`

log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_UNEXPECTED_ERROR_GETTING_RECORD')
throw new CodeError(errMsg, 'ERR_UNEXPECTED_ERROR_GETTING_RECORD')
}
const errMsg = `local record requested was not found for ${routingKey.toString()}`

log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_NOT_FOUND')
throw new CodeError(errMsg, 'ERR_NOT_FOUND')
}

if (!(dsVal instanceof Uint8Array)) {
const errMsg = 'found record that we couldn\'t convert to a value'

log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_INVALID_RECORD_RECEIVED')
throw new CodeError(errMsg, 'ERR_INVALID_RECORD_RECEIVED')
}

return dsVal
Expand Down Expand Up @@ -286,7 +286,7 @@ export class PubSubDatastore extends BaseDatastore {
const errMsg = 'record received through pubsub is not valid'

log.error(errMsg)
throw errcode(new Error(errMsg), 'ERR_NOT_VALID_RECORD')
throw new CodeError(errMsg, 'ERR_NOT_VALID_RECORD')
}

// Get Local record
Expand Down
2 changes: 1 addition & 1 deletion test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { expect } from 'aegir/chai'
import sinon from 'sinon'
import errcode from 'err-code'
import isNode from 'detect-node'
import { isNode } from 'aegir/env'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { PubSubDatastore } from '../src/index.js'
Expand Down

0 comments on commit e669855

Please sign in to comment.