@helia/verified-fetch 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"dag-cbor-to-safe-json.d.ts","sourceRoot":"","sources":["../../../src/utils/dag-cbor-to-safe-json.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAsB1D"}
1
+ {"version":3,"file":"dag-cbor-to-safe-json.d.ts","sourceRoot":"","sources":["../../../src/utils/dag-cbor-to-safe-json.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAE,GAAG,EAAE,UAAU,GAAG,MAAM,CAkB1D"}
@@ -1,31 +1,19 @@
1
1
  import { decode } from 'cborg';
2
2
  import { encode } from 'cborg/json';
3
- import { CID } from 'multiformats/cid';
4
- // https://github.com/ipfs/go-ipfs/issues/3570#issuecomment-273931692
5
- const CID_CBOR_TAG = 0x2A;
6
- function cidDecoder(bytes) {
7
- if (bytes[0] !== 0) {
8
- throw new Error('Invalid CID for CBOR tag 42; expected leading 0x00');
9
- }
10
- return CID.decode(bytes.subarray(1)); // ignore leading 0x00
11
- }
12
3
  /**
13
4
  * Take a `DAG-CBOR` encoded `Uint8Array`, deserialize it as an object and
14
5
  * re-serialize it in a form that can be passed to `JSON.serialize` and then
15
6
  * `JSON.parse` without losing any data.
16
7
  */
17
8
  export function dagCborToSafeJSON(buf) {
18
- const tags = [];
19
- tags[CID_CBOR_TAG] = cidDecoder;
20
9
  const obj = decode(buf, {
21
10
  allowIndefinite: false,
22
- coerceUndefinedToNull: true,
11
+ coerceUndefinedToNull: false,
23
12
  allowNaN: false,
24
13
  allowInfinity: false,
25
14
  strict: true,
26
15
  useMaps: false,
27
16
  rejectDuplicateMapKeys: true,
28
- tags,
29
17
  // this is different to `DAG-CBOR` - the reason we disallow BigInts is
30
18
  // because we are about to re-encode to `JSON` which does not support
31
19
  // BigInts. Blocks containing large numbers should be deserialized using a
@@ -1 +1 @@
1
- {"version":3,"file":"dag-cbor-to-safe-json.js","sourceRoot":"","sources":["../../../src/utils/dag-cbor-to-safe-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,qEAAqE;AACrE,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB,SAAS,UAAU,CAAE,KAAiB;IACpC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;IACvE,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,sBAAsB;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAE,GAAe;IAChD,MAAM,IAAI,GAAiB,EAAE,CAAA;IAC7B,IAAI,CAAC,YAAY,CAAC,GAAG,UAAU,CAAA;IAE/B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE;QACtB,eAAe,EAAE,KAAK;QACtB,qBAAqB,EAAE,IAAI;QAC3B,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAC5B,IAAI;QAEJ,sEAAsE;QACtE,qEAAqE;QACrE,0EAA0E;QAC1E,uBAAuB;QACvB,WAAW,EAAE,KAAK;KACnB,CAAC,CAAA;IAEF,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAC9C,CAAC"}
1
+ {"version":3,"file":"dag-cbor-to-safe-json.js","sourceRoot":"","sources":["../../../src/utils/dag-cbor-to-safe-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAE,GAAe;IAChD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,EAAE;QACtB,eAAe,EAAE,KAAK;QACtB,qBAAqB,EAAE,KAAK;QAC5B,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,IAAI;QAE5B,sEAAsE;QACtE,qEAAqE;QACrE,0EAA0E;QAC1E,uBAAuB;QACvB,WAAW,EAAE,KAAK;KACnB,CAAC,CAAA;IAEF,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAC9C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/verified-fetch",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A fetch-like API for obtaining verified & trustless IPFS content on the web",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia-verified-fetch/tree/main/packages/verified-fetch#readme",
@@ -1,18 +1,5 @@
1
1
  import { decode } from 'cborg'
2
2
  import { encode } from 'cborg/json'
3
- import { CID } from 'multiformats/cid'
4
- import type { TagDecoder } from 'cborg'
5
-
6
- // https://github.com/ipfs/go-ipfs/issues/3570#issuecomment-273931692
7
- const CID_CBOR_TAG = 0x2A
8
-
9
- function cidDecoder (bytes: Uint8Array): CID {
10
- if (bytes[0] !== 0) {
11
- throw new Error('Invalid CID for CBOR tag 42; expected leading 0x00')
12
- }
13
-
14
- return CID.decode(bytes.subarray(1)) // ignore leading 0x00
15
- }
16
3
 
17
4
  /**
18
5
  * Take a `DAG-CBOR` encoded `Uint8Array`, deserialize it as an object and
@@ -20,18 +7,14 @@ function cidDecoder (bytes: Uint8Array): CID {
20
7
  * `JSON.parse` without losing any data.
21
8
  */
22
9
  export function dagCborToSafeJSON (buf: Uint8Array): string {
23
- const tags: TagDecoder[] = []
24
- tags[CID_CBOR_TAG] = cidDecoder
25
-
26
10
  const obj = decode(buf, {
27
11
  allowIndefinite: false,
28
- coerceUndefinedToNull: true,
12
+ coerceUndefinedToNull: false,
29
13
  allowNaN: false,
30
14
  allowInfinity: false,
31
15
  strict: true,
32
16
  useMaps: false,
33
17
  rejectDuplicateMapKeys: true,
34
- tags,
35
18
 
36
19
  // this is different to `DAG-CBOR` - the reason we disallow BigInts is
37
20
  // because we are about to re-encode to `JSON` which does not support