Socket
Socket
Sign inDemoInstall

multiformats

Package Overview
Dependencies
Maintainers
3
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multiformats - npm Package Compare versions

Comparing version 10.0.1 to 10.0.2

dist/types/test/test-varint.spec.d.ts

13

CHANGELOG.md

@@ -0,1 +1,14 @@

## [10.0.2](https://github.com/multiformats/js-multiformats/compare/v10.0.1...v10.0.2) (2022-10-19)
### Bug Fixes
* use slash as flag that an object is a CID ([#217](https://github.com/multiformats/js-multiformats/issues/217)) ([1cec619](https://github.com/multiformats/js-multiformats/commit/1cec619e2818d893292323539f397324ace82280)), closes [#212](https://github.com/multiformats/js-multiformats/issues/212) [#213](https://github.com/multiformats/js-multiformats/issues/213)
### Trivial Changes
* **no-release:** rename varint test file so it is run ([#209](https://github.com/multiformats/js-multiformats/issues/209)) ([e32fe47](https://github.com/multiformats/js-multiformats/commit/e32fe4703ee0c48100af89f9c9c7181f65935176))
* remove unnecessary dev deps ([#218](https://github.com/multiformats/js-multiformats/issues/218)) ([a43ffff](https://github.com/multiformats/js-multiformats/commit/a43ffff672495ba86486be47084697df4e1ecacc))
## [10.0.1](https://github.com/multiformats/js-multiformats/compare/v10.0.0...v10.0.1) (2022-10-17)

@@ -2,0 +15,0 @@

9

dist/types/src/cid.d.ts

@@ -160,3 +160,10 @@ export * from "./link/interface.js";

/** @readonly */
readonly asCID: CID<Data, Format, Alg, Version>;
readonly '/': Uint8Array;
/**
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
* please either use `CID.asCID(cid)` or switch to new signalling mechanism
*
* @deprecated
*/
get asCID(): CID<Data, Format, Alg, Version>;
get byteOffset(): number;

@@ -163,0 +170,0 @@ get byteLength(): number;

7

package.json
{
"name": "multiformats",
"version": "10.0.1",
"version": "10.0.2",
"description": "Interface for multihash, multicodec, multibase and CID",

@@ -265,10 +265,5 @@ "author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)",

"@stablelib/sha512": "^1.0.1",
"@types/chai": "^4.3.0",
"@types/chai-as-promised": "^7.1.4",
"@types/mocha": "^10.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"

@@ -275,0 +270,0 @@ },

@@ -81,7 +81,18 @@ import * as varint from './varint.js'

// Circular reference
// flag to serializers that this is a CID and
// should be treated specially
/** @readonly */
this.asCID = this
this['/'] = bytes
}
/**
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
* please either use `CID.asCID(cid)` or switch to new signalling mechanism
*
* @deprecated
*/
get asCID () {
return this
}
// ArrayBufferView

@@ -233,2 +244,6 @@ get byteOffset () {

static asCID (input) {
if (input == null) {
return null
}
const value = /** @type {any} */ (input)

@@ -238,8 +253,8 @@ if (value instanceof CID) {

return value
} else if (value != null && value.asCID === value) {
// If value isn't instance of this CID class but `this.asCID === this` is
// true it is CID instance coming from a different implementation (diff
// version or duplicate). In that case we rebase it to this `CID`
// implementation so caller is guaranteed to get instance with expected
// API.
} else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {
// If value isn't instance of this CID class but `this.asCID === this` or
// `value['/'] === value.bytes` is true it is CID instance coming from a
// different implementation (diff version or duplicate). In that case we
// rebase it to this `CID` implementation so caller is guaranteed to get
// instance with expected API.
const { version, code, multihash, bytes } = value

@@ -252,3 +267,3 @@ return new CID(

)
} else if (value != null && value[cidSymbol] === true) {
} else if (value[cidSymbol] === true) {
// If value is a CID from older implementation that used to be tagged via

@@ -255,0 +270,0 @@ // symbol we still rebase it to the this `CID` implementation by

@@ -39,5 +39,22 @@ // Linter can see that API is used in types.

*/
export const isLink = value =>
value != null && /** @type {{asCID: unknown}} */ (value).asCID === value
export const isLink = value => {
if (value == null) {
return false
}
const withSlash = /** @type {{'/'?: Uint8Array, bytes: Uint8Array}} */ (value)
if (withSlash['/'] != null && withSlash['/'] === withSlash.bytes) {
return true
}
const withAsCID = /** @type {{'asCID'?: unknown}} */ (value)
if (withAsCID.asCID === value) {
return true
}
return false
}
/**

@@ -44,0 +61,0 @@ * Takes cid in a string representation and creates an instance. If `base`

@@ -6,8 +6,4 @@ /* globals describe, it */

import { CID, bytes } from '../src/index.js'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { assert } from 'aegir/chai'
chai.use(chaiAsPromised)
const { assert } = chai
const fixture = { hello: 'world' }

@@ -14,0 +10,0 @@ const link = CID.parse('bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae')

/* globals describe, it */
import * as bytes from '../src/bytes.js'
import { assert } from 'chai'
import { assert } from 'aegir/chai'

@@ -5,0 +5,0 @@ describe('bytes', () => {

@@ -11,4 +11,3 @@ /* globals describe, it */

import OLDCID from 'cids'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { assert } from 'aegir/chai'
// Linter can see that API is used in types.

@@ -18,5 +17,2 @@ // eslint-disable-next-line

chai.use(chaiAsPromised)
const { assert } = chai
const textEncoder = new TextEncoder()

@@ -709,5 +705,5 @@

})
assert.strictEqual(cid2.asCID, cid2)
sender.close()
receiver.close()
assert.strictEqual(cid2['/'], cid2.bytes)
})

@@ -714,0 +710,0 @@

/* globals describe, it */
import * as Link from '../src/link.js'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { assert } from 'aegir/chai'
import { sha256 } from '../src/hashes/sha2.js'
chai.use(chaiAsPromised)
const { assert } = chai
const utf8 = new TextEncoder()

@@ -11,0 +8,0 @@

@@ -5,8 +5,4 @@ /* eslint-env mocha */

import { fromString } from '../src/bytes.js'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { assert } from 'aegir/chai'
chai.use(chaiAsPromised)
const { assert } = chai
const encoded = [

@@ -13,0 +9,0 @@ {

@@ -11,8 +11,4 @@ /* globals describe, it */

import * as b64 from '../src/bases/base64.js'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { assert } from 'aegir/chai'
chai.use(chaiAsPromised)
const { assert } = chai
const { base16, base32, base58btc, base64 } = { ...b16, ...b32, ...b58, ...b64 }

@@ -19,0 +15,0 @@

@@ -5,8 +5,4 @@ /* globals describe, it */

import * as json from '../src/codecs/json.js'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { assert } from 'aegir/chai'
chai.use(chaiAsPromised)
const { assert } = chai
describe('multicodec', () => {

@@ -13,0 +9,0 @@ it('encode/decode raw', () => {

@@ -10,8 +10,4 @@ /* globals describe, it */

import { hash as slSha512 } from '@stablelib/sha512'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { assert } from 'aegir/chai'
chai.use(chaiAsPromised)
const { assert } = chai
/**

@@ -18,0 +14,0 @@ * @param {number|string} code

@@ -7,3 +7,3 @@ /* globals describe, it */

import { fromString } from '../src/bytes.js'
import { assert } from 'chai'
import { assert } from 'aegir/chai'

@@ -10,0 +10,0 @@ /** @typedef {import('../src/cid.js').CID} CID */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc