multiformats
Advanced tools
Comparing version 9.8.0 to 9.8.1
341
package.json
{ | ||
"name": "multiformats", | ||
"version": "9.8.0", | ||
"version": "9.8.1", | ||
"description": "Interface for multihash, multicodec, multibase and CID", | ||
"author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)", | ||
"license": "Apache-2.0 OR MIT", | ||
"homepage": "https://github.com/multiformats/js-multiformats#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/multiformats/js-multiformats.git" | ||
"main": "./cjs/src/index.js", | ||
"types": "./types/src/index.d.ts", | ||
"scripts": { | ||
"build": "npm run build:js && npm run build:types", | ||
"build:js": "ipjs build --tests --main && npm run build:copy", | ||
"build:copy": "cp -a tsconfig.json src vendor test dist/ && rm -rf dist/test/ts-use", | ||
"build:types": "npm run build:copy && cd dist && tsc --build", | ||
"build:vendor": "npm run build:vendor:varint && npm run build:vendor:base-x", | ||
"build:vendor:varint": "npm_config_yes=true npx brrp -x varint > vendor/varint.js", | ||
"build:vendor:base-x": "npm_config_yes=true npx brrp -x @multiformats/base-x > vendor/base-x.js", | ||
"lint": "standard", | ||
"test:cjs": "npm run build:js && mocha dist/cjs/node-test/test-*.js && npm run test:cjs:browser", | ||
"test:esm": "npm run build:js && mocha dist/esm/node-test/test-*.js && npm run test:esm:browser", | ||
"test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/test-*.js", | ||
"test:cjs:browser": "polendina --page --worker --serviceworker --cleanup dist/cjs/browser-test/test-*.js", | ||
"test:esm:browser": "polendina --page --worker --serviceworker --cleanup dist/esm/browser-test/test-*.js", | ||
"test:ts": "npm run build:types && npm run test --prefix test/ts-use", | ||
"test": "npm run lint && npm run test:node && npm run test:esm && npm run test:ts", | ||
"test:ci": "npm run lint && npm run test:node && npm run test:esm && npm run test:cjs && npm run test:ts", | ||
"coverage": "c8 --reporter=html mocha test/test-*.js && npm_config_yes=true npx st -d coverage -p 8080" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/multiformats/js-multiformats/issues" | ||
"c8": { | ||
"exclude": [ | ||
"test/**", | ||
"vendor/**" | ||
] | ||
}, | ||
@@ -20,121 +37,157 @@ "keywords": [ | ||
], | ||
"engines": { | ||
"node": ">=16.0.0", | ||
"npm": ">=7.0.0" | ||
}, | ||
"type": "module", | ||
"types": "./dist/src/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"*", | ||
"dist/*", | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
], | ||
"src/*": [ | ||
"*", | ||
"dist/*", | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"src", | ||
"dist", | ||
"!dist/test", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)", | ||
"license": "(Apache-2.0 AND MIT)", | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"import": "./src/index.js" | ||
"browser": "./esm/src/index.js", | ||
"require": "./cjs/src/index.js", | ||
"import": "./esm/src/index.js" | ||
}, | ||
"./bases/base10": { | ||
"types": "./src/bases/base10.d.ts", | ||
"import": "./src/bases/base10.js" | ||
"./cid": { | ||
"browser": "./esm/src/cid.js", | ||
"require": "./cjs/src/cid.js", | ||
"import": "./esm/src/cid.js" | ||
}, | ||
"./bases/base16": { | ||
"types": "./src/bases/base16.d.ts", | ||
"import": "./src/bases/base16.js" | ||
"./basics": { | ||
"browser": "./esm/src/basics.js", | ||
"require": "./cjs/src/basics.js", | ||
"import": "./esm/src/basics.js" | ||
}, | ||
"./block": { | ||
"browser": "./esm/src/block.js", | ||
"require": "./cjs/src/block.js", | ||
"import": "./esm/src/block.js" | ||
}, | ||
"./traversal": { | ||
"browser": "./esm/src/traversal.js", | ||
"require": "./cjs/src/traversal.js", | ||
"import": "./esm/src/traversal.js" | ||
}, | ||
"./bases/identity": { | ||
"browser": "./esm/src/bases/identity.js", | ||
"require": "./cjs/src/bases/identity.js", | ||
"import": "./esm/src/bases/identity.js" | ||
}, | ||
"./bases/base2": { | ||
"types": "./src/bases/base2.d.ts", | ||
"import": "./src/bases/base2.js" | ||
"browser": "./esm/src/bases/base2.js", | ||
"require": "./cjs/src/bases/base2.js", | ||
"import": "./esm/src/bases/base2.js" | ||
}, | ||
"./bases/base256emoji": { | ||
"types": "./src/bases/base256emoji.d.ts", | ||
"import": "./src/bases/base256emoji.js" | ||
"./bases/base8": { | ||
"browser": "./esm/src/bases/base8.js", | ||
"require": "./cjs/src/bases/base8.js", | ||
"import": "./esm/src/bases/base8.js" | ||
}, | ||
"./bases/base10": { | ||
"browser": "./esm/src/bases/base10.js", | ||
"require": "./cjs/src/bases/base10.js", | ||
"import": "./esm/src/bases/base10.js" | ||
}, | ||
"./bases/base16": { | ||
"browser": "./esm/src/bases/base16.js", | ||
"require": "./cjs/src/bases/base16.js", | ||
"import": "./esm/src/bases/base16.js" | ||
}, | ||
"./bases/base32": { | ||
"types": "./src/bases/base32.d.ts", | ||
"import": "./src/bases/base32.js" | ||
"browser": "./esm/src/bases/base32.js", | ||
"require": "./cjs/src/bases/base32.js", | ||
"import": "./esm/src/bases/base32.js" | ||
}, | ||
"./bases/base36": { | ||
"types": "./src/bases/base36.d.ts", | ||
"import": "./src/bases/base36.js" | ||
"browser": "./esm/src/bases/base36.js", | ||
"require": "./cjs/src/bases/base36.js", | ||
"import": "./esm/src/bases/base36.js" | ||
}, | ||
"./bases/base58": { | ||
"types": "./src/bases/base58.d.ts", | ||
"import": "./src/bases/base58.js" | ||
"browser": "./esm/src/bases/base58.js", | ||
"require": "./cjs/src/bases/base58.js", | ||
"import": "./esm/src/bases/base58.js" | ||
}, | ||
"./bases/base64": { | ||
"types": "./src/bases/base64.d.ts", | ||
"import": "./src/bases/base64.js" | ||
"browser": "./esm/src/bases/base64.js", | ||
"require": "./cjs/src/bases/base64.js", | ||
"import": "./esm/src/bases/base64.js" | ||
}, | ||
"./bases/base8": { | ||
"types": "./src/bases/base8.d.ts", | ||
"import": "./src/bases/base8.js" | ||
"./bases/base256emoji": { | ||
"browser": "./esm/src/bases/base256emoji.js", | ||
"require": "./cjs/src/bases/base256emoji.js", | ||
"import": "./esm/src/bases/base256emoji.js" | ||
}, | ||
"./bases/identity": { | ||
"types": "./src/bases/identity.d.ts", | ||
"import": "./src/bases/identity.js" | ||
"./hashes/hasher": { | ||
"browser": "./esm/src/hashes/hasher.js", | ||
"require": "./cjs/src/hashes/hasher.js", | ||
"import": "./esm/src/hashes/hasher.js" | ||
}, | ||
"./basics": { | ||
"types": "./src/basics.d.ts", | ||
"import": "./src/basics.js" | ||
"./hashes/digest": { | ||
"browser": "./esm/src/hashes/digest.js", | ||
"require": "./cjs/src/hashes/digest.js", | ||
"import": "./esm/src/hashes/digest.js" | ||
}, | ||
"./block": { | ||
"types": "./src/block.d.ts", | ||
"import": "./src/block.js" | ||
"./hashes/sha2": { | ||
"browser": "./esm/src/hashes/sha2-browser.js", | ||
"require": "./cjs/src/hashes/sha2.js", | ||
"import": "./esm/src/hashes/sha2.js" | ||
}, | ||
"./cid": { | ||
"types": "./src/cid.d.ts", | ||
"import": "./src/cid.js" | ||
"./hashes/identity": { | ||
"browser": "./esm/src/hashes/identity.js", | ||
"require": "./cjs/src/hashes/identity.js", | ||
"import": "./esm/src/hashes/identity.js" | ||
}, | ||
"./codecs/json": { | ||
"types": "./src/codecs/json.d.ts", | ||
"import": "./src/codecs/json.js" | ||
"browser": "./esm/src/codecs/json.js", | ||
"require": "./cjs/src/codecs/json.js", | ||
"import": "./esm/src/codecs/json.js" | ||
}, | ||
"./codecs/raw": { | ||
"types": "./src/codecs/raw.d.ts", | ||
"import": "./src/codecs/raw.js" | ||
}, | ||
"./hashes/digest": { | ||
"types": "./src/hashes/digest.d.ts", | ||
"import": "./src/hashes/digest.js" | ||
}, | ||
"./hashes/hasher": { | ||
"types": "./src/hashes/hasher.d.ts", | ||
"import": "./src/hashes/hasher.js" | ||
}, | ||
"./hashes/identity": { | ||
"types": "./src/hashes/identity.d.ts", | ||
"import": "./src/hashes/identity.js" | ||
}, | ||
"./hashes/sha2": { | ||
"types": "./src/hashes/sha2.d.ts", | ||
"browser": "./src/hashes/sha2-browser.js", | ||
"import": "./src/hashes/sha2.js" | ||
}, | ||
"./traversal": { | ||
"types": "./src/traversal.d.ts", | ||
"import": "./src/traversal.js" | ||
"browser": "./esm/src/codecs/raw.js", | ||
"require": "./cjs/src/codecs/raw.js", | ||
"import": "./esm/src/codecs/raw.js" | ||
} | ||
}, | ||
"eslintConfig": { | ||
"extends": "ipfs", | ||
"parserOptions": { | ||
"sourceType": "module" | ||
"devDependencies": { | ||
"@ipld/dag-pb": "^2.1.14", | ||
"@stablelib/sha256": "^1.0.1", | ||
"@stablelib/sha512": "^1.0.1", | ||
"@types/chai": "^4.3.0", | ||
"@types/chai-as-promised": "^7.1.4", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^18.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.6.0", | ||
"@typescript-eslint/parser": "^5.6.0", | ||
"buffer": "^6.0.3", | ||
"c8": "^7.10.0", | ||
"chai": "^4.3.4", | ||
"chai-as-promised": "^7.1.1", | ||
"cids": "^1.1.9", | ||
"ipjs": "^5.2.0", | ||
"mocha": "^10.0.0", | ||
"polendina": "^3.0.0", | ||
"standard": "^17.0.0", | ||
"typescript": "^4.5.4" | ||
}, | ||
"standard": { | ||
"ignore": [ | ||
"dist", | ||
"vendor" | ||
] | ||
}, | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/multiformats/js-multiformats.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/multiformats/js-multiformats/issues" | ||
}, | ||
"homepage": "https://github.com/multiformats/js-multiformats#readme", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"types/src/*" | ||
], | ||
"types/*": [ | ||
"types/*" | ||
] | ||
} | ||
@@ -144,3 +197,3 @@ }, | ||
"branches": [ | ||
"esm-migration" | ||
"master" | ||
], | ||
@@ -170,11 +223,11 @@ "plugins": [ | ||
{ | ||
"type": "docs", | ||
"type": "chore", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "test", | ||
"type": "docs", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "deps", | ||
"type": "test", | ||
"release": "patch" | ||
@@ -209,9 +262,5 @@ }, | ||
"type": "docs", | ||
"section": "Documentation" | ||
"section": "Trivial Changes" | ||
}, | ||
{ | ||
"type": "deps", | ||
"section": "Dependencies" | ||
}, | ||
{ | ||
"type": "test", | ||
@@ -225,3 +274,8 @@ "section": "Tests" | ||
"@semantic-release/changelog", | ||
"@semantic-release/npm", | ||
[ | ||
"@semantic-release/npm", | ||
{ | ||
"pkgRoot": "dist" | ||
} | ||
], | ||
"@semantic-release/github", | ||
@@ -231,40 +285,27 @@ "@semantic-release/git" | ||
}, | ||
"scripts": { | ||
"lint": "aegir lint", | ||
"release": "aegir release", | ||
"build": "aegir build", | ||
"test": "aegir test", | ||
"test:node": "aegir test --target node", | ||
"test:browser": "aegir test --target browser" | ||
}, | ||
"devDependencies": { | ||
"@ipld/dag-pb": "^2.1.14", | ||
"@stablelib/sha256": "^1.0.1", | ||
"@stablelib/sha512": "^1.0.1", | ||
"@types/chai": "^4.3.0", | ||
"@types/chai-as-promised": "^7.1.4", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^18.0.0", | ||
"aegir": "^37.5.1", | ||
"buffer": "^6.0.3", | ||
"chai": "^4.3.4", | ||
"chai-as-promised": "^7.1.1", | ||
"cids": "^1.1.9" | ||
}, | ||
"aegir": { | ||
"build": { | ||
"bundle": false | ||
}, | ||
"test": { | ||
"cov": true, | ||
"target": [ | ||
"node", | ||
"browser" | ||
] | ||
} | ||
}, | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"main": "./src/index.js" | ||
"browser": { | ||
".": "./cjs/src/index.js", | ||
"./cid": "./cjs/src/cid.js", | ||
"./basics": "./cjs/src/basics.js", | ||
"./block": "./cjs/src/block.js", | ||
"./traversal": "./cjs/src/traversal.js", | ||
"./bases/identity": "./cjs/src/bases/identity.js", | ||
"./bases/base2": "./cjs/src/bases/base2.js", | ||
"./bases/base8": "./cjs/src/bases/base8.js", | ||
"./bases/base10": "./cjs/src/bases/base10.js", | ||
"./bases/base16": "./cjs/src/bases/base16.js", | ||
"./bases/base32": "./cjs/src/bases/base32.js", | ||
"./bases/base36": "./cjs/src/bases/base36.js", | ||
"./bases/base58": "./cjs/src/bases/base58.js", | ||
"./bases/base64": "./cjs/src/bases/base64.js", | ||
"./bases/base256emoji": "./cjs/src/bases/base256emoji.js", | ||
"./hashes/hasher": "./cjs/src/hashes/hasher.js", | ||
"./hashes/digest": "./cjs/src/hashes/digest.js", | ||
"./hashes/sha2": "./cjs/src/hashes/sha2-browser.js", | ||
"./esm/src/hashes/sha2.js": "./esm/src/hashes/sha2-browser.js", | ||
"./cjs/src/hashes/sha2.js": "./cjs/src/hashes/sha2-browser.js", | ||
"./hashes/identity": "./cjs/src/hashes/identity.js", | ||
"./codecs/json": "./cjs/src/codecs/json.js", | ||
"./codecs/raw": "./cjs/src/codecs/raw.js" | ||
} | ||
} |
@@ -1,38 +0,23 @@ | ||
# multiformats <!-- omit in toc --> | ||
# multiformats | ||
[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io) | ||
[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-multiformats.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiformats) | ||
[![CI](https://img.shields.io/github/workflow/status/multiformats/js-multiformats/test%20&%20maybe%20release/esm-migration?style=flat-square)](https://github.com/multiformats/js-multiformats/actions/workflows/js-test-and-release.yml) | ||
* [Interfaces](#interfaces) | ||
* [Creating Blocks](#creating-blocks) | ||
* [Multibase Encoders / Decoders / Codecs](#multibase-encoders--decoders--codecs) | ||
* [Multicodec Encoders / Decoders / Codecs](#multicodec-encoders--decoders--codecs) | ||
* [Multihash Hashers](#multihash-hashers) | ||
* [Traversal](#traversal) | ||
* [Legacy interface](#legacy-interface) | ||
* [Implementations](#implementations) | ||
* [Multibase codecs](#multibase-codecs) | ||
* [Multihash hashers](#multihash-hashers-1) | ||
* [IPLD codecs (multicodec)](#ipld-codecs-multicodec) | ||
* [License](#license) | ||
* [Contribution](#contribution) | ||
> Interface for multihash, multicodec, multibase and CID | ||
This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume. | ||
## Table of contents <!-- omit in toc --> | ||
This library provides implementations for most basics and many others can be found in linked repositories. | ||
- [Install](#install) | ||
- [Interfaces](#interfaces) | ||
- [Creating Blocks](#creating-blocks) | ||
- [Multibase Encoders / Decoders / Codecs](#multibase-encoders--decoders--codecs) | ||
- [Multicodec Encoders / Decoders / Codecs](#multicodec-encoders--decoders--codecs) | ||
- [Multihash Hashers](#multihash-hashers) | ||
- [Traversal](#traversal) | ||
- [Legacy interface](#legacy-interface) | ||
- [Implementations](#implementations) | ||
- [Multibase codecs](#multibase-codecs) | ||
- [Multihash hashers](#multihash-hashers-1) | ||
- [IPLD codecs (multicodec)](#ipld-codecs-multicodec) | ||
- [License](#license) | ||
- [Contribution](#contribution) | ||
## Install | ||
```console | ||
$ npm i multiformats | ||
``` | ||
## Interfaces | ||
This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume. | ||
This library provides implementations for most basics and many others can be found in linked repositories. | ||
```js | ||
@@ -95,2 +80,3 @@ import { CID } from 'multiformats/cid' | ||
```js | ||
@@ -207,8 +193,8 @@ cid.toString(base64) | ||
| bases | import | repo | | ||
| ------------------------------------------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------- | | ||
| `base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | | ||
| `base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | | ||
| `base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | | ||
| `base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | | ||
| bases | import | repo | | ||
--- | --- | --- | | ||
`base16` | `multiformats/bases/base16` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | | ||
`base32`, `base32pad`, `base32hex`, `base32hexpad`, `base32z` | `multiformats/bases/base32` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | | ||
`base64`, `base64pad`, `base64url`, `base64urlpad` | `multiformats/bases/base64` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | | ||
`base58btc`, `base58flick4` | `multiformats/bases/base58` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) | | ||
@@ -219,20 +205,20 @@ Other (less useful) bases implemented in [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/bases) include: `base2`, `base8`, `base10`, `base36` and `base256emoji`. | ||
| hashes | import | repo | | ||
| ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------ | | ||
| `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) | | ||
| `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) | | ||
| `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) | | ||
| `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) | | ||
| `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) | | ||
| hashes | import | repo | | ||
| --- | --- | --- | | ||
| `sha2-256`, `sha2-512` | `multiformats/hashes/sha2` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes) | | ||
| `sha3-224`, `sha3-256`, `sha3-384`,`sha3-512`, `shake-128`, `shake-256`, `keccak-224`, `keccak-256`, `keccak-384`, `keccak-512` | `@multiformats/sha3` | [multiformats/js-sha3](https://github.com/multiformats/js-sha3) | | ||
| `identity` | `multiformats/hashes/identity` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/hashes/identity.js) | | ||
| `murmur3-128`, `murmur3-32` | `@multiformats/murmur3` | [multiformats/js-murmur3](https://github.com/multiformats/js-murmur3) | | ||
| `blake2b-*`, `blake2s-*` | `@multiformats/blake2` | [multiformats/js-blake2](https://github.com/multiformats/js-blake2) | | ||
### IPLD codecs (multicodec) | ||
| codec | import | repo | | ||
| ---------- | -------------------------- | ------------------------------------------------------------------------------------------------------ | | ||
| `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | | ||
| `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | | ||
| `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) | | ||
| `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) | | ||
| `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) | | ||
| `dag-jose` | `dag-jose` | [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) | | ||
| codec | import | repo | | ||
| --- | --- | --- | | ||
| `raw` | `multiformats/codecs/raw` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | | ||
| `json` | `multiformats/codecs/json` | [multiformats/js-multiformats](https://github.com/multiformats/js-multiformats/tree/master/src/codecs) | | ||
| `dag-cbor` | `@ipld/dag-cbor` | [ipld/js-dag-cbor](https://github.com/ipld/js-dag-cbor) | | ||
| `dag-json` | `@ipld/dag-json` | [ipld/js-dag-json](https://github.com/ipld/js-dag-json) | | ||
| `dag-pb` | `@ipld/dag-pb` | [ipld/js-dag-pb](https://github.com/ipld/js-dag-pb) | | ||
| `dag-jose` | `dag-jose`| [ceramicnetwork/js-dag-jose](https://github.com/ceramicnetwork/js-dag-jose) | | ||
@@ -243,7 +229,7 @@ ## License | ||
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>) | ||
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>) | ||
* Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0) | ||
* MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT) | ||
## Contribution | ||
### Contribution | ||
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. |
@@ -23,3 +23,2 @@ import basex from '../../vendor/base-x.js' | ||
* prefix. | ||
* | ||
* @class | ||
@@ -73,3 +72,2 @@ * @template {string} Base | ||
* with corresponding base encoding. | ||
* | ||
* @class | ||
@@ -233,3 +231,3 @@ * @template {string} Base | ||
* @template {string} Prefix | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {Base} options.name | ||
@@ -247,3 +245,3 @@ * @param {Prefix} options.prefix | ||
* @template {string} Prefix | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {Base} options.name | ||
@@ -366,3 +364,3 @@ * @param {Prefix} options.prefix | ||
* @template {string} Prefix | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {Base} options.name | ||
@@ -369,0 +367,0 @@ * @param {Prefix} options.prefix |
@@ -11,6 +11,5 @@ // Base encoders / decoders just base encode / decode between binary and | ||
* `encode` no multibase prefix is added. | ||
* | ||
* @param bytes | ||
*/ | ||
baseEncode: (bytes: Uint8Array) => string | ||
baseEncode(bytes: Uint8Array): string | ||
} | ||
@@ -25,6 +24,5 @@ | ||
* decode | ||
* | ||
* @param text | ||
*/ | ||
baseDecode: (text: string) => Uint8Array | ||
baseDecode(text: string): Uint8Array | ||
} | ||
@@ -65,3 +63,3 @@ | ||
*/ | ||
encode: (bytes: Uint8Array) => Multibase<Prefix> | ||
encode(bytes: Uint8Array): Multibase<Prefix> | ||
} | ||
@@ -79,6 +77,5 @@ | ||
* If prefix does not match | ||
* | ||
* @param multibase | ||
*/ | ||
decode: (multibase: Multibase<Prefix>) => Uint8Array | ||
decode(multibase: Multibase<Prefix>): Uint8Array | ||
} | ||
@@ -96,2 +93,3 @@ | ||
export interface UnibaseDecoder<Prefix extends string> extends MultibaseDecoder<Prefix> { | ||
@@ -98,0 +96,0 @@ // Reserve this property so it can be used to derive type. |
125
src/block.js
import { bytes as binary, CID } from './index.js' | ||
function readonly ({ enumerable = true, configurable = false } = {}) { | ||
return { enumerable, configurable, writable: false } | ||
} | ||
const readonly = ({ enumerable = true, configurable = false } = {}) => ({ | ||
enumerable, | ||
configurable, | ||
writable: false | ||
}) | ||
/** | ||
* @param {[string|number, string]} path | ||
* @param {any} value | ||
* @returns {Iterable<[string, CID]>} | ||
*/ | ||
function * linksWithin (path, value) { | ||
if (value != null && typeof value === 'object') { | ||
if (Array.isArray(value)) { | ||
for (const [index, element] of value.entries()) { | ||
const elementPath = [...path, index] | ||
const cid = CID.asCID(element) | ||
if (cid) { | ||
yield [elementPath.join('/'), cid] | ||
} else if (typeof element === 'object') { | ||
yield * links(element, elementPath) | ||
} | ||
} | ||
} else { | ||
const cid = CID.asCID(value) | ||
if (cid) { | ||
yield [path.join('/'), cid] | ||
} else { | ||
yield * links(value, path) | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* @template T | ||
@@ -41,28 +15,27 @@ * @param {T} source | ||
*/ | ||
function * links (source, base) { | ||
if (source == null || source instanceof Uint8Array) { | ||
return | ||
} | ||
const links = function * (source, base) { | ||
if (source == null) return | ||
if (source instanceof Uint8Array) return | ||
for (const [key, value] of Object.entries(source)) { | ||
const path = /** @type {[string|number, string]} */ ([...base, key]) | ||
yield * linksWithin(path, value) | ||
} | ||
} | ||
/** | ||
* @param {[string|number, string]} path | ||
* @param {any} value | ||
* @returns {Iterable<string>} | ||
*/ | ||
function * treeWithin (path, value) { | ||
if (Array.isArray(value)) { | ||
for (const [index, element] of value.entries()) { | ||
const elementPath = [...path, index] | ||
yield elementPath.join('/') | ||
if (typeof element === 'object' && !CID.asCID(element)) { | ||
yield * tree(element, elementPath) | ||
const path = [...base, key] | ||
if (value != null && typeof value === 'object') { | ||
if (Array.isArray(value)) { | ||
for (const [index, element] of value.entries()) { | ||
const elementPath = [...path, index] | ||
const cid = CID.asCID(element) | ||
if (cid) { | ||
yield [elementPath.join('/'), cid] | ||
} else if (typeof element === 'object') { | ||
yield * links(element, elementPath) | ||
} | ||
} | ||
} else { | ||
const cid = CID.asCID(value) | ||
if (cid) { | ||
yield [path.join('/'), cid] | ||
} else { | ||
yield * links(value, path) | ||
} | ||
} | ||
} | ||
} else { | ||
yield * tree(value, path) | ||
} | ||
@@ -77,11 +50,19 @@ } | ||
*/ | ||
function * tree (source, base) { | ||
if (source == null || typeof source !== 'object') { | ||
return | ||
} | ||
const tree = function * (source, base) { | ||
if (source == null) return | ||
for (const [key, value] of Object.entries(source)) { | ||
const path = /** @type {[string|number, string]} */ ([...base, key]) | ||
const path = [...base, key] | ||
yield path.join('/') | ||
if (value != null && !(value instanceof Uint8Array) && typeof value === 'object' && !CID.asCID(value)) { | ||
yield * treeWithin(path, value) | ||
if (Array.isArray(value)) { | ||
for (const [index, element] of value.entries()) { | ||
const elementPath = [...path, index] | ||
yield elementPath.join('/') | ||
if (typeof element === 'object' && !CID.asCID(element)) { | ||
yield * tree(element, elementPath) | ||
} | ||
} | ||
} else { | ||
yield * tree(value, path) | ||
} | ||
} | ||
@@ -96,3 +77,3 @@ } | ||
*/ | ||
function get (source, path) { | ||
const get = (source, path) => { | ||
let node = /** @type {Record<string, any>} */ (source) | ||
@@ -117,3 +98,3 @@ for (const [index, key] of path.entries()) { | ||
/** | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {CID} options.cid | ||
@@ -149,4 +130,4 @@ * @param {ByteView<T>} options.bytes | ||
/** | ||
* @param {string} [path] | ||
*/ | ||
* @param {string} [path] | ||
*/ | ||
get (path = '/') { | ||
@@ -161,3 +142,3 @@ return get(this.value, path.split('/').filter(Boolean)) | ||
* @template {number} Algorithm | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {T} options.value | ||
@@ -168,3 +149,3 @@ * @param {BlockEncoder<Code, T>} options.codec | ||
*/ | ||
async function encode ({ value, codec, hasher }) { | ||
const encode = async ({ value, codec, hasher }) => { | ||
if (typeof value === 'undefined') throw new Error('Missing required argument "value"') | ||
@@ -184,3 +165,3 @@ if (!codec || !hasher) throw new Error('Missing required argument: codec or hasher') | ||
* @template {number} Algorithm | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {ByteView<T>} options.bytes | ||
@@ -191,3 +172,3 @@ * @param {BlockDecoder<Code, T>} options.codec | ||
*/ | ||
async function decode ({ bytes, codec, hasher }) { | ||
const decode = async ({ bytes, codec, hasher }) => { | ||
if (!bytes) throw new Error('Missing required argument "bytes"') | ||
@@ -204,3 +185,3 @@ if (!codec || !hasher) throw new Error('Missing required argument: codec or hasher') | ||
/** | ||
* @typedef {object} RequiredCreateOptions | ||
* @typedef {Object} RequiredCreateOptions | ||
* @property {CID} options.cid | ||
@@ -215,3 +196,3 @@ */ | ||
*/ | ||
function createUnsafe ({ bytes, cid, value: maybeValue, codec }) { | ||
const createUnsafe = ({ bytes, cid, value: maybeValue, codec }) => { | ||
const value = maybeValue !== undefined | ||
@@ -230,3 +211,3 @@ ? maybeValue | ||
* @template {number} Algorithm | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {CID} options.cid | ||
@@ -238,3 +219,3 @@ * @param {ByteView<T>} options.bytes | ||
*/ | ||
async function create ({ bytes, cid, hasher, codec }) { | ||
const create = async ({ bytes, cid, hasher, codec }) => { | ||
if (!bytes) throw new Error('Missing required argument "bytes"') | ||
@@ -241,0 +222,0 @@ if (!hasher) throw new Error('Missing required argument "hasher"') |
@@ -159,3 +159,3 @@ import * as varint from './varint.js' | ||
deprecate(/^0\.0/, IS_CID_DEPRECATION) | ||
return Boolean(value && (value[cidSymbol] || value.asCID === value)) | ||
return !!(value && (value[cidSymbol] || value.asCID === value)) | ||
} | ||
@@ -192,3 +192,2 @@ | ||
* co-exist and interop as long as binary interface is compatible. | ||
* | ||
* @param {any} value | ||
@@ -224,8 +223,8 @@ * @returns {CID|null} | ||
/** | ||
* | ||
* @param {CIDVersion} version - Version of the CID | ||
* @param {number} code - Code of the codec content is encoded in. | ||
* @param {MultihashDigest} digest - (Multi)hash of the of the content. | ||
* @returns {CID} | ||
*/ | ||
* | ||
* @param {CIDVersion} version - Version of the CID | ||
* @param {number} code - Code of the codec content is encoded in. | ||
* @param {MultihashDigest} digest - (Multi)hash of the of the content. | ||
* @returns {CID} | ||
*/ | ||
static create (version, code, digest) { | ||
@@ -256,3 +255,2 @@ if (typeof code !== 'number') { | ||
* Simplified version of `create` for CIDv0. | ||
* | ||
* @param {MultihashDigest} digest - Multihash. | ||
@@ -265,9 +263,8 @@ */ | ||
/** | ||
* Simplified version of `create` for CIDv1. | ||
* | ||
* @template {number} Code | ||
* @param {Code} code - Content encoding format code. | ||
* @param {MultihashDigest} digest - Miltihash of the content. | ||
* @returns {CID} | ||
*/ | ||
* Simplified version of `create` for CIDv1. | ||
* @template {number} Code | ||
* @param {Code} code - Content encoding format code. | ||
* @param {MultihashDigest} digest - Miltihash of the content. | ||
* @returns {CID} | ||
*/ | ||
static createV1 (code, digest) { | ||
@@ -487,3 +484,2 @@ return CID.create(1, code, digest) | ||
const deprecate = (range, message) => { | ||
/* eslint-disable no-console */ | ||
if (range.test(version)) { | ||
@@ -490,0 +486,0 @@ console.warn(message) |
@@ -7,3 +7,3 @@ /** | ||
code: Code | ||
encode: (data: T) => ByteView<T> | ||
encode(data: T): ByteView<T> | ||
} | ||
@@ -16,3 +16,3 @@ | ||
code: Code | ||
decode: (bytes: ByteView<T>) => T | ||
decode(bytes: ByteView<T>): T | ||
} | ||
@@ -19,0 +19,0 @@ |
@@ -6,3 +6,2 @@ import { coerce, equals as equalBytes } from '../bytes.js' | ||
* Creates a multihash digest. | ||
* | ||
* @template {number} Code | ||
@@ -27,3 +26,2 @@ * @param {Code} code | ||
* Turns bytes representation of multihash digest into an instance. | ||
* | ||
* @param {Uint8Array} multihash | ||
@@ -65,3 +63,2 @@ * @returns {MultihashDigest} | ||
* hashing alogrithm and an actual hash digest. | ||
* | ||
* @template {number} Code | ||
@@ -75,3 +72,2 @@ * @template {number} Size | ||
* Creates a multihash digest. | ||
* | ||
* @param {Code} code | ||
@@ -78,0 +74,0 @@ * @param {Size} size |
@@ -6,3 +6,3 @@ import * as Digest from './digest.js' | ||
* @template {number} Code | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {Name} options.name | ||
@@ -9,0 +9,0 @@ * @param {Code} options.code |
@@ -47,3 +47,3 @@ // # Multihash | ||
*/ | ||
digest: (input: Uint8Array) => Promise<MultihashDigest> | MultihashDigest | ||
digest(input: Uint8Array): Promise<MultihashDigest> | MultihashDigest | ||
@@ -72,3 +72,3 @@ /** | ||
export interface SyncMultihashHasher<Code extends number = number> extends MultihashHasher<Code> { | ||
digest: (input: Uint8Array) => MultihashDigest | ||
digest(input: Uint8Array): MultihashDigest | ||
} |
@@ -14,3 +14,3 @@ import { base58btc } from './bases/base58.js' | ||
* @template T | ||
* @param {object} options | ||
* @param {Object} options | ||
* @param {CID} options.cid | ||
@@ -17,0 +17,0 @@ * @param {(cid: CID) => Promise<Block<T>|null>} options.load |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
523499
221
100
14584
1
19
232
No