@atproto/common 0.4.5 → 0.4.7

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atproto/common
2
2
 
3
+ ## 0.4.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#3481](https://github.com/bluesky-social/atproto/pull/3481) [`52c687a05`](https://github.com/bluesky-social/atproto/commit/52c687a05c70d5660fae1de9e1bbc6297f37f1f4) Thanks [@dholms](https://github.com/dholms)! - Parse safe uint64 as number
8
+
9
+ ## 0.4.6
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`72eba67af`](https://github.com/bluesky-social/atproto/commit/72eba67af1af8320b5400bcb9319d5c3c8407d99), [`72eba67af`](https://github.com/bluesky-social/atproto/commit/72eba67af1af8320b5400bcb9319d5c3c8407d99)]:
14
+ - @atproto/common-web@0.3.2
15
+
3
16
  ## 0.4.5
4
17
 
5
18
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"ipld-multi.d.ts","sourceRoot":"","sources":["../src/ipld-multi.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,eAAe,YAAa,UAAU,KAAG,OAAO,EAM5D,CAAA"}
1
+ {"version":3,"file":"ipld-multi.d.ts","sourceRoot":"","sources":["../src/ipld-multi.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,eAAe,YAAa,UAAU,KAAG,OAAO,EAM5D,CAAA"}
@@ -42,9 +42,14 @@ cborx.addExtension({
42
42
  return cid_1.CID.decode(bytes.subarray(1)); // ignore leading 0x00
43
43
  },
44
44
  });
45
+ const decoder = new cborx.Decoder({
46
+ // @ts-ignore
47
+ int64AsNumber: true, // not in types for some reason
48
+ useRecords: false,
49
+ });
45
50
  const cborDecodeMulti = (encoded) => {
46
51
  const decoded = [];
47
- cborx.decodeMultiple(encoded, (value) => {
52
+ decoder.decodeMultiple(encoded, (value) => {
48
53
  decoded.push(value);
49
54
  });
50
55
  return decoded;
@@ -1 +1 @@
1
- {"version":3,"file":"ipld-multi.js","sourceRoot":"","sources":["../src/ipld-multi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA+B;AAC/B,0CAAsC;AAEtC,kCAAkC;AAClC,0CAA0C;AAC1C,iCAAiC;AACjC,KAAK,CAAC,YAAY,CAAC;IACjB,KAAK,EAAE,SAAG;IACV,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,GAAG,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IACvC,CAAC;IACD,MAAM,EAAE,CAAC,KAAiB,EAAO,EAAE;QACjC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACvE,CAAC;QACD,OAAO,SAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,sBAAsB;IAC7D,CAAC;CACF,CAAC,CAAA;AAEK,MAAM,eAAe,GAAG,CAAC,OAAmB,EAAa,EAAE;IAChE,MAAM,OAAO,GAAc,EAAE,CAAA;IAC7B,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACtC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B"}
1
+ {"version":3,"file":"ipld-multi.js","sourceRoot":"","sources":["../src/ipld-multi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA+B;AAC/B,0CAAsC;AAEtC,kCAAkC;AAClC,0CAA0C;AAC1C,iCAAiC;AACjC,KAAK,CAAC,YAAY,CAAC;IACjB,KAAK,EAAE,SAAG;IACV,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,GAAG,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IACvC,CAAC;IACD,MAAM,EAAE,CAAC,KAAiB,EAAO,EAAE;QACjC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACvE,CAAC;QACD,OAAO,SAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,sBAAsB;IAC7D,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC;IAChC,aAAa;IACb,aAAa,EAAE,IAAI,EAAE,+BAA+B;IACpD,UAAU,EAAE,KAAK;CAClB,CAAC,CAAA;AAEK,MAAM,eAAe,GAAG,CAAC,OAAmB,EAAa,EAAE;IAChE,MAAM,OAAO,GAAc,EAAE,CAAA;IAC7B,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACxC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/common",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "license": "MIT",
5
5
  "description": "Shared web-platform-friendly code for atproto libraries",
6
6
  "keywords": [
@@ -20,7 +20,7 @@
20
20
  "iso-datestring-validator": "^2.2.2",
21
21
  "multiformats": "^9.9.0",
22
22
  "pino": "^8.21.0",
23
- "@atproto/common-web": "^0.3.1"
23
+ "@atproto/common-web": "^0.3.2"
24
24
  },
25
25
  "devDependencies": {
26
26
  "jest": "^28.1.2",
package/src/ipld-multi.ts CHANGED
@@ -18,9 +18,15 @@ cborx.addExtension({
18
18
  },
19
19
  })
20
20
 
21
+ const decoder = new cborx.Decoder({
22
+ // @ts-ignore
23
+ int64AsNumber: true, // not in types for some reason
24
+ useRecords: false,
25
+ })
26
+
21
27
  export const cborDecodeMulti = (encoded: Uint8Array): unknown[] => {
22
28
  const decoded: unknown[] = []
23
- cborx.decodeMultiple(encoded, (value) => {
29
+ decoder.decodeMultiple(encoded, (value) => {
24
30
  decoded.push(value)
25
31
  })
26
32
  return decoded
@@ -22,4 +22,13 @@ describe('ipld decode multi', () => {
22
22
  expect(decoded[0]).toEqual(one)
23
23
  expect(decoded[1]).toEqual(two)
24
24
  })
25
+
26
+ it('parses safe ints as number', async () => {
27
+ const one = {
28
+ test: Number.MAX_SAFE_INTEGER,
29
+ }
30
+ const encoded = cborEncode(one)
31
+ const decoded = cborDecodeMulti(encoded)
32
+ expect(Number.isInteger(decoded[0]?.['test'])).toBe(true)
33
+ })
25
34
  })