@metamask/utils 1.0.0 → 3.0.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/__fixtures__/json.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC3B,KAAK,EAAE;QACL,IAAI;QACJ,EAAE,CAAC,EAAE,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC;QACd,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACzC;IACD,OAAO,EAAE;QACP,SAAS;QACT,MAAM,CAAC,KAAK,CAAC;QACb,OAAO,CAAC,OAAO,EAAE;QACjB,GAAG,EAAE,CAAC,KAAK;QACX,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC;KACnB;CACF,CAAC;AAEW,QAAA,8BAA8B,GAAG;IAC5C,KAAK,EAAE;QACL;YACE,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,QAAQ;SACjB;QACD;YACE,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE;gBACN,GAAG,EAAE,KAAK;aACX;SACF;QACD;YACE,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,CAAC,KAAK,CAAC;SAChB;KACF;IACD,OAAO,EAAE;QACP,EAAE;QACF,EAAE;QACF,IAAI;QACJ,KAAK;QACL,IAAI;QACJ,SAAS;QACT,CAAC;QACD,KAAK;QACL;YACE,EAAE,EAAE,CAAC;YACL,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,QAAQ;SACjB;QACD;YACE,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,QAAQ;SACjB;QACD;YACE,OAAO,EAAE,GAAG;Y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;oBACL,IAAI;oBACJ,SAAS;iBACV;gBACD,QAAQ,EAAE;oBACR,QAAQ,EAAE,IAAI;oBACd,QAAQ,EAAE,SAAS;oBACnB,CAAC,EAAE,IAAI;oBACP,CAAC,EAAE,KAAK;iBACT;gBACD,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI,IAAI,EAAE;oBACpB,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;oBACzC,WAAW,EAAE,IAAI,IAAI,CAAC,iBAAiB,CAAC;iBACzC;aACF;SACF;KACF;CACF,CAAC;AAEW,QAAA,8BAA8B,GAAG;IAC5C,QAAQ,EAAE;QACR,QAAQ,EAAE;YACR,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,SAAS,EAAE,GAAG,EAAE;wBACd,OAAO,UAAU,CAAC;oBACpB,CAAC;iBACF;aACF;SACF;KACF;CACF,CAAC;AAEW,QAAA,kCAAkC,GAAG;IAChD,CAAC,KAAK;IACN,IAAI;IACJ,cAAc;IACd,CAAC,aAAa;IACd,eAAe;IACf,CAAC,SAAS;IACV,KAAK;IACL,aAAa;CACd,CAAC;AAEW,QAAA,8BAA8B,GAAG;IAC5C,IAAI;IACJ,SAAS;IACT,IAAI;IACJ,SAAS;IACT,SAAS;IACT,SAAS;IACT,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,SAAS;CACV,CAAC;AAEW,QAAA,kCAAkC,GAAG;IAChD,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,GAAG;CACP,CAAC","sourcesContent":["export const JSON_FIXTURES = {\n valid: [\n null,\n { a: 1 },\n ['a', 2, null],\n [{ a: null, b: 2, c: [{ foo: 'bar' }] }],\n ],\n invalid: [\n undefined,\n Symbol('bar'),\n Promise.resolve(),\n () => 'foo',\n [{ a: undefined }],\n ],\n};\n\nexport const JSON_RPC_NOTIFICATION_FIXTURES = {\n valid: [\n {\n jsonrpc: '2.0',\n method: 'notify',\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n params: {\n foo: 'bar',\n },\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n params: ['foo'],\n },\n ],\n invalid: [\n {},\n [],\n true,\n false,\n null,\n undefined,\n 1,\n 'foo',\n {\n id: 1,\n jsonrpc: '2.0',\n method: 'notify',\n },\n {\n jsonrpc: '1.0',\n method: 'notify',\n },\n {\n jsonrpc: 2.0,\n method: 'notify',\n },\n {\n jsonrpc: '2.0',\n method: {},\n },\n {\n jsonrpc: '2.0',\n method: [],\n },\n {\n jsonrpc: '2.0',\n method: true,\n },\n {\n jsonrpc: '2.0',\n method: false,\n },\n {\n jsonrpc: '2.0',\n method: null,\n },\n {\n jsonrpc: '2.0',\n method: undefined,\n },\n {\n jsonrpc: '2.0',\n method: 1,\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n params: true,\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n params: false,\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n params: null,\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n params: 1,\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n params: '',\n },\n ],\n};\n\nexport const JSON_RPC_REQUEST_FIXTURES = {\n valid: [\n {\n jsonrpc: '2.0',\n method: 'notify',\n id: 1,\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n id: '1',\n params: {\n foo: 'bar',\n },\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n id: 'foo',\n params: ['foo'],\n },\n {\n jsonrpc: '2.0',\n method: 'notify',\n id: null,\n },\n ],\n invalid: [\n {},\n [],\n true,\n false,\n null,\n undefined,\n 1,\n 'foo',\n {\n id: 1,\n jsonrpc: '1.0',\n method: 'notify',\n },\n {\n id: 1,\n jsonrpc: 2.0,\n method: 'notify',\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: {},\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: [],\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: true,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: false,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: null,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: undefined,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: 1,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: 'notify',\n params: true,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: 'notify',\n params: false,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: 'notify',\n params: null,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: 'notify',\n params: 1,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n method: 'notify',\n params: '',\n },\n ],\n};\n\nexport const JSON_RPC_SUCCESS_FIXTURES = {\n valid: [\n {\n id: 1,\n jsonrpc: '2.0',\n result: 'foo',\n },\n {\n id: '1',\n jsonrpc: '2.0',\n result: {\n foo: 'bar',\n },\n },\n {\n id: 'foo',\n jsonrpc: '2.0',\n result: null,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n result: [\n {\n foo: 'bar',\n },\n ],\n },\n ],\n invalid: [\n {},\n [],\n true,\n false,\n null,\n undefined,\n 1,\n 'foo',\n {\n jsonrpc: '2.0',\n result: 'foo',\n },\n {\n id: 1,\n result: 'foo',\n },\n {\n id: 1,\n jsonrpc: '2.0',\n },\n {\n id: 1,\n jsonrpc: '1.0',\n result: 'foo',\n },\n {\n id: 1,\n jsonrpc: 2.0,\n result: 'foo',\n },\n {\n id: 1,\n jsonrpc: '2.0',\n result: undefined,\n },\n {\n id: {},\n jsonrpc: '2.0',\n result: 'foo',\n },\n {\n id: [],\n jsonrpc: '2.0',\n result: 'foo',\n },\n {\n id: true,\n jsonrpc: '2.0',\n result: 'foo',\n },\n {\n id: false,\n jsonrpc: '2.0',\n result: 'foo',\n },\n {\n id: undefined,\n jsonrpc: '2.0',\n result: 'foo',\n },\n ],\n};\n\nexport const JSON_RPC_FAILURE_FIXTURES = {\n valid: [\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: '1',\n jsonrpc: '2.0',\n error: {\n code: -32001,\n message: 'Internal error',\n data: {\n foo: 'bar',\n },\n },\n },\n {\n id: 'foo',\n jsonrpc: '2.0',\n error: {\n code: -32002,\n message: 'Internal error',\n data: ['foo'],\n stack: 'bar',\n },\n },\n {\n id: 'foo',\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n data: 'foo',\n },\n },\n {\n id: 'foo',\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n data: 1,\n },\n },\n ],\n invalid: [\n {},\n [],\n true,\n false,\n null,\n undefined,\n 1,\n 'foo',\n {\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n },\n {\n id: {},\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: [],\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: true,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: false,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: undefined,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '1.0',\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: 2.0,\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: {},\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: [],\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: true,\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: false,\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: null,\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: undefined,\n error: {\n code: -32000,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: [],\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {},\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: true,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: false,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: null,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: undefined,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: 'foo',\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: 1,\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: {},\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: [],\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: true,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: false,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: null,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: undefined,\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: 'foo',\n message: 'Internal error',\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: {},\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: [],\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: true,\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: false,\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: null,\n },\n },\n {\n id: 1,\n jsonrpc: '2.0',\n error: {\n code: -32000,\n message: undefined,\n },\n },\n ],\n};\n\nexport const JSON_RPC_RESPONSE_FIXTURES = {\n valid: [\n ...JSON_RPC_SUCCESS_FIXTURES.valid,\n ...JSON_RPC_FAILURE_FIXTURES.valid,\n ],\n invalid: [\n ...JSON_RPC_SUCCESS_FIXTURES.invalid,\n ...JSON_RPC_FAILURE_FIXTURES.invalid,\n ],\n};\n\nexport const COMPLEX_OBJECT = {\n data: {\n account: {\n __typename: 'Account',\n registrations: [\n {\n __typename: 'Registration',\n domain: {\n __typename: 'Domain',\n isMigrated: true,\n labelName: 'mycrypto',\n labelhash:\n '0x9a781ca0d227debc3ee76d547c960b0803a6c9f58c6d3b4722f12ede7e6ef7c9',\n name: 'mycrypto.eth',\n parent: { __typename: 'Domain', name: 'eth' },\n },\n expiryDate: '1754111315',\n },\n ],\n },\n moreComplexity: {\n numbers: [\n -5e-11,\n 5e-9,\n 0.000000000001,\n -0.00000000009,\n 100000.00000008,\n -100.88888,\n 0.333,\n 1000000000000,\n ],\n moreNestedObjects: {\n nestedAgain: {\n nestedAgain: {\n andAgain: {\n andAgain: {\n value: true,\n again: {\n value: false,\n },\n },\n },\n },\n },\n },\n differentEncodings: {\n ascii:\n '!\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~',\n utf8: 'šđćčžЀЂЇЄЖФћΣΩδλ',\n mixed: 'ABCDEFGHIJ KLMNOPQRST UVWXYZšđćč žЀЂЇЄЖФћΣΩδλ',\n specialCharacters: '\"\\\\\\n\\r\\t',\n stringWithSpecialEscapedCharacters:\n \"this\\nis\\nsome\\\"'string\\r\\nwith\\tspecial\\\\escaped\\tcharacters'\",\n },\n specialObjectsTypesAndValues: {\n t: [true, true, true],\n f: [false, false, false],\n nulls: [null, null, null],\n undef: undefined,\n mixed: [\n null,\n undefined,\n null,\n undefined,\n null,\n true,\n null,\n false,\n null,\n undefined,\n ],\n inObject: {\n valueOne: null,\n valueTwo: undefined,\n t: true,\n f: false,\n },\n dates: {\n someDate: new Date(),\n someOther: new Date(2022, 0, 2, 15, 4, 5),\n invalidDate: new Date('bad-date-format'),\n },\n },\n },\n },\n};\n\nexport const NON_SERIALIZABLE_NESTED_OBJECT = {\n levelOne: {\n levelTwo: {\n levelThree: {\n levelFour: {\n levelFive: () => {\n return 'anything';\n },\n },\n },\n },\n },\n};\n\nexport const ARRAY_OF_DIFFRENT_KINDS_OF_NUMBERS = [\n -5e-11,\n 5e-9,\n 0.000000000001,\n -0.00000000009,\n 100000.00000008,\n -100.88888,\n 0.333,\n 1000000000000,\n];\n\nexport const ARRAY_OF_MIXED_SPECIAL_OBJECTS = [\n null,\n undefined,\n null,\n undefined,\n undefined,\n undefined,\n null,\n null,\n null,\n undefined,\n];\n\nexport const OBJECT_MIXED_WITH_UNDEFINED_VALUES = {\n a: undefined,\n b: 'b',\n c: undefined,\n d: 'd',\n e: undefined,\n f: 'f',\n};\n"]}
@@ -1,18 +1,16 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
3
- if (!privateMap.has(receiver)) {
4
- throw new TypeError("attempted to set private field on non-instance");
5
- }
6
- privateMap.set(receiver, value);
7
- return value;
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8
7
  };
9
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
10
- if (!privateMap.has(receiver)) {
11
- throw new TypeError("attempted to get private field on non-instance");
12
- }
13
- return privateMap.get(receiver);
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
14
12
  };
15
- var _map_1, _set_1;
13
+ var _FrozenMap_map, _FrozenSet_set;
16
14
  Object.defineProperty(exports, "__esModule", { value: true });
17
15
  exports.FrozenSet = exports.FrozenMap = void 0;
18
16
  /**
@@ -23,35 +21,35 @@ exports.FrozenSet = exports.FrozenMap = void 0;
23
21
  */
24
22
  class FrozenMap {
25
23
  constructor(entries) {
26
- _map_1.set(this, void 0);
27
- __classPrivateFieldSet(this, _map_1, new Map(entries));
24
+ _FrozenMap_map.set(this, void 0);
25
+ __classPrivateFieldSet(this, _FrozenMap_map, new Map(entries), "f");
28
26
  Object.freeze(this);
29
27
  }
30
28
  get size() {
31
- return __classPrivateFieldGet(this, _map_1).size;
29
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").size;
32
30
  }
33
- [(_map_1 = new WeakMap(), Symbol.iterator)]() {
34
- return __classPrivateFieldGet(this, _map_1)[Symbol.iterator]();
31
+ [(_FrozenMap_map = new WeakMap(), Symbol.iterator)]() {
32
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f")[Symbol.iterator]();
35
33
  }
36
34
  entries() {
37
- return __classPrivateFieldGet(this, _map_1).entries();
35
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").entries();
38
36
  }
39
37
  forEach(callbackfn, thisArg) {
40
38
  // We have to wrap the specified callback in order to prevent it from
41
39
  // receiving a reference to the inner map.
42
- return __classPrivateFieldGet(this, _map_1).forEach((value, key, _map) => callbackfn.call(thisArg, value, key, this));
40
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").forEach((value, key, _map) => callbackfn.call(thisArg, value, key, this));
43
41
  }
44
42
  get(key) {
45
- return __classPrivateFieldGet(this, _map_1).get(key);
43
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").get(key);
46
44
  }
47
45
  has(key) {
48
- return __classPrivateFieldGet(this, _map_1).has(key);
46
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").has(key);
49
47
  }
50
48
  keys() {
51
- return __classPrivateFieldGet(this, _map_1).keys();
49
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").keys();
52
50
  }
53
51
  values() {
54
- return __classPrivateFieldGet(this, _map_1).values();
52
+ return __classPrivateFieldGet(this, _FrozenMap_map, "f").values();
55
53
  }
56
54
  toString() {
57
55
  return `FrozenMap(${this.size}) {${this.size > 0
@@ -70,32 +68,32 @@ exports.FrozenMap = FrozenMap;
70
68
  */
71
69
  class FrozenSet {
72
70
  constructor(values) {
73
- _set_1.set(this, void 0);
74
- __classPrivateFieldSet(this, _set_1, new Set(values));
71
+ _FrozenSet_set.set(this, void 0);
72
+ __classPrivateFieldSet(this, _FrozenSet_set, new Set(values), "f");
75
73
  Object.freeze(this);
76
74
  }
77
75
  get size() {
78
- return __classPrivateFieldGet(this, _set_1).size;
76
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").size;
79
77
  }
80
- [(_set_1 = new WeakMap(), Symbol.iterator)]() {
81
- return __classPrivateFieldGet(this, _set_1)[Symbol.iterator]();
78
+ [(_FrozenSet_set = new WeakMap(), Symbol.iterator)]() {
79
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f")[Symbol.iterator]();
82
80
  }
83
81
  entries() {
84
- return __classPrivateFieldGet(this, _set_1).entries();
82
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").entries();
85
83
  }
86
84
  forEach(callbackfn, thisArg) {
87
85
  // We have to wrap the specified callback in order to prevent it from
88
86
  // receiving a reference to the inner set.
89
- return __classPrivateFieldGet(this, _set_1).forEach((value, value2, _set) => callbackfn.call(thisArg, value, value2, this));
87
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").forEach((value, value2, _set) => callbackfn.call(thisArg, value, value2, this));
90
88
  }
91
89
  has(value) {
92
- return __classPrivateFieldGet(this, _set_1).has(value);
90
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").has(value);
93
91
  }
94
92
  keys() {
95
- return __classPrivateFieldGet(this, _set_1).keys();
93
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").keys();
96
94
  }
97
95
  values() {
98
- return __classPrivateFieldGet(this, _set_1).values();
96
+ return __classPrivateFieldGet(this, _FrozenSet_set, "f").values();
99
97
  }
100
98
  toString() {
101
99
  return `FrozenSet(${this.size}) {${this.size > 0
@@ -1 +1 @@
1
- {"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,MAAM,SAAS;IAWb,YAAY,OAAmD;QAV/D,yBAA+B;QAW7B,uBAAA,IAAI,UAAQ,IAAI,GAAG,CAAa,OAAO,CAAC,EAAC;QACzC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAXD,IAAW,IAAI;QACb,OAAO,qCAAU,IAAI,CAAC;IACxB,CAAC;IAEM,0BAAC,MAAM,CAAC,QAAQ,EAAC;QACtB,OAAO,qCAAU,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACtC,CAAC;IAOM,OAAO;QACZ,OAAO,qCAAU,OAAO,EAAE,CAAC;IAC7B,CAAC;IAEM,OAAO,CACZ,UAAuD,EACvD,OAAa;QAEb,qEAAqE;QACrE,0CAA0C;QAC1C,OAA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AC;IAOM,OAAO;QACZ,OAAO,qCAAU,OAAO,EAAE,CAAC;IAC7B,CAAC;IAEM,OAAO,CACZ,UAA4D,EAC5D,OAAa;QAEb,qEAAqE;QACrE,0CAA0C;QAC1C,OAAO,qCAAU,OAAO,CAAC,CAAC,KAAY,EAAE,MAAa,EAAE,IAAa,EAAE,EAAE,CACtE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAC9C,CAAC;IACJ,CAAC;IAEM,GAAG,CAAC,KAAY;QACrB,OAAO,qCAAU,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEM,IAAI;QACT,OAAO,qCAAU,IAAI,EAAE,CAAC;IAC1B,CAAC;IAEM,MAAM;QACX,OAAO,qCAAU,MAAM,EAAE,CAAC;IAC5B,CAAC;IAEM,QAAQ;QACb,OAAO,aAAa,IAAI,CAAC,IAAI,MAC3B,IAAI,CAAC,IAAI,GAAG,CAAC;YACX,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACtE,CAAC,CAAC,EACN,GAAG,CAAC;IACN,CAAC;CACF;AAQmB,8BAAS;AAN7B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC","sourcesContent":["/**\n * A {@link ReadonlyMap} that cannot be modified after instantiation.\n * The implementation uses an inner map hidden via a private field, and the\n * immutability guarantee relies on it being impossible to get a reference\n * to this map.\n */\nclass FrozenMap<Key, Value> implements ReadonlyMap<Key, Value> {\n readonly #map: Map<Key, Value>;\n\n public get size() {\n return this.#map.size;\n }\n\n public [Symbol.iterator]() {\n return this.#map[Symbol.iterator]();\n }\n\n constructor(entries?: readonly (readonly [Key, Value])[] | null) {\n this.#map = new Map<Key, Value>(entries);\n Object.freeze(this);\n }\n\n public entries() {\n return this.#map.entries();\n }\n\n public forEach(\n callbackfn: (value: Value, key: Key, map: this) => void,\n thisArg?: any,\n ): void {\n // We have to wrap the specified callback in order to prevent it from\n // receiving a reference to the inner map.\n return this.#map.forEach((value: Value, key: Key, _map: unknown) =>\n callbackfn.call(thisArg, value, key, this),\n );\n }\n\n public get(key: Key) {\n return this.#map.get(key);\n }\n\n public has(key: Key) {\n return this.#map.has(key);\n }\n\n public keys() {\n return this.#map.keys();\n }\n\n public values() {\n return this.#map.values();\n }\n\n public toString(): string {\n return `FrozenMap(${this.size}) {${\n this.size > 0\n ? ` ${[...this.entries()]\n .map(([key, value]) => `${String(key)} => ${String(value)}`)\n .join(', ')} `\n : ''\n }}`;\n }\n}\n\n/**\n * A {@link ReadonlySet} that cannot be modified after instantiation.\n * The implementation uses an inner set hidden via a private field, and the\n * immutability guarantee relies on it being impossible to get a reference\n * to this set.\n */\nclass FrozenSet<Value> implements ReadonlySet<Value> {\n readonly #set: Set<Value>;\n\n public get size() {\n return this.#set.size;\n }\n\n public [Symbol.iterator]() {\n return this.#set[Symbol.iterator]();\n }\n\n constructor(values?: readonly Value[] | null) {\n this.#set = new Set<Value>(values);\n Object.freeze(this);\n }\n\n public entries() {\n return this.#set.entries();\n }\n\n public forEach(\n callbackfn: (value: Value, value2: Value, set: this) => void,\n thisArg?: any,\n ): void {\n // We have to wrap the specified callback in order to prevent it from\n // receiving a reference to the inner set.\n return this.#set.forEach((value: Value, value2: Value, _set: unknown) =>\n callbackfn.call(thisArg, value, value2, this),\n );\n }\n\n public has(value: Value) {\n return this.#set.has(value);\n }\n\n public keys() {\n return this.#set.keys();\n }\n\n public values() {\n return this.#set.values();\n }\n\n public toString(): string {\n return `FrozenSet(${this.size}) {${\n this.size > 0\n ? ` ${[...this.values()].map((member) => String(member)).join(', ')} `\n : ''\n }}`;\n }\n}\n\nObject.freeze(FrozenMap);\nObject.freeze(FrozenMap.prototype);\n\nObject.freeze(FrozenSet);\nObject.freeze(FrozenSet.prototype);\n\nexport { FrozenMap, FrozenSet };\n"]}
1
+ {"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,MAAM,SAAS;IAWb,YAAY,OAAmD;QAV/D,iCAA+B;QAW7B,uBAAA,IAAI,kBAAQ,IAAI,GAAG,CAAa,OAAO,CAAC,MAAA,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAXD,IAAW,IAAI;QACb,OAAO,uBAAA,IAAI,sBAAK,CAAC,IAAI,CAAC;IACxB,CAAC;IAEM,kCAAC,MAAM,CAAC,QAAQ,EAAC;QACtB,OAAO,uBAAA,IAAI,sBAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACtC,CAAC;IAOM,OAAO;QACZ,OAAO,uBAAA,IAAI,sBAAK,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAEM,OAAO,CACZ,UAAuD,EACvD,OAAa;QAEb,qEAAqE;QACrE,0CAA0C;QAC1C,OAAO,uBAAA,IAAI,sBAAK,CAAC,OAAO,CAAC,CAAC,KAAY,EAAE,GAAQ,EAAE,IAAa,EAAE,EAAE,CACjE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAC3C,CAAC;IACJ,CAAC;IAEM,GAAG,CAAC,GAAQ;QACjB,OAAO,uBAAA,IAAI,sBAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,GAAG,CAAC,GAAQ;QACjB,OAAO,uBAAA,IAAI,sBAAK,CAAC,GAAG,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EAAE,IAAa,EAAE,EAAE,CACtE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAC9C,CAAC;IACJ,CAAC;IAEM,GAAG,CAAC,KAAY;QACrB,OAAO,uBAAA,IAAI,sBAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEM,IAAI;QACT,OAAO,uBAAA,IAAI,sBAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IAEM,MAAM;QACX,OAAO,uBAAA,IAAI,sBAAK,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAEM,QAAQ;QACb,OAAO,aAAa,IAAI,CAAC,IAAI,MAC3B,IAAI,CAAC,IAAI,GAAG,CAAC;YACX,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACtE,CAAC,CAAC,EACN,GAAG,CAAC;IACN,CAAC;CACF;AAQmB,8BAAS;AAN7B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACzB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC","sourcesContent":["/**\n * A {@link ReadonlyMap} that cannot be modified after instantiation.\n * The implementation uses an inner map hidden via a private field, and the\n * immutability guarantee relies on it being impossible to get a reference\n * to this map.\n */\nclass FrozenMap<Key, Value> implements ReadonlyMap<Key, Value> {\n readonly #map: Map<Key, Value>;\n\n public get size() {\n return this.#map.size;\n }\n\n public [Symbol.iterator]() {\n return this.#map[Symbol.iterator]();\n }\n\n constructor(entries?: readonly (readonly [Key, Value])[] | null) {\n this.#map = new Map<Key, Value>(entries);\n Object.freeze(this);\n }\n\n public entries() {\n return this.#map.entries();\n }\n\n public forEach(\n callbackfn: (value: Value, key: Key, map: this) => void,\n thisArg?: any,\n ): void {\n // We have to wrap the specified callback in order to prevent it from\n // receiving a reference to the inner map.\n return this.#map.forEach((value: Value, key: Key, _map: unknown) =>\n callbackfn.call(thisArg, value, key, this),\n );\n }\n\n public get(key: Key) {\n return this.#map.get(key);\n }\n\n public has(key: Key) {\n return this.#map.has(key);\n }\n\n public keys() {\n return this.#map.keys();\n }\n\n public values() {\n return this.#map.values();\n }\n\n public toString(): string {\n return `FrozenMap(${this.size}) {${\n this.size > 0\n ? ` ${[...this.entries()]\n .map(([key, value]) => `${String(key)} => ${String(value)}`)\n .join(', ')} `\n : ''\n }}`;\n }\n}\n\n/**\n * A {@link ReadonlySet} that cannot be modified after instantiation.\n * The implementation uses an inner set hidden via a private field, and the\n * immutability guarantee relies on it being impossible to get a reference\n * to this set.\n */\nclass FrozenSet<Value> implements ReadonlySet<Value> {\n readonly #set: Set<Value>;\n\n public get size() {\n return this.#set.size;\n }\n\n public [Symbol.iterator]() {\n return this.#set[Symbol.iterator]();\n }\n\n constructor(values?: readonly Value[] | null) {\n this.#set = new Set<Value>(values);\n Object.freeze(this);\n }\n\n public entries() {\n return this.#set.entries();\n }\n\n public forEach(\n callbackfn: (value: Value, value2: Value, set: this) => void,\n thisArg?: any,\n ): void {\n // We have to wrap the specified callback in order to prevent it from\n // receiving a reference to the inner set.\n return this.#set.forEach((value: Value, value2: Value, _set: unknown) =>\n callbackfn.call(thisArg, value, value2, this),\n );\n }\n\n public has(value: Value) {\n return this.#set.has(value);\n }\n\n public keys() {\n return this.#set.keys();\n }\n\n public values() {\n return this.#set.values();\n }\n\n public toString(): string {\n return `FrozenSet(${this.size}) {${\n this.size > 0\n ? ` ${[...this.values()].map((member) => String(member)).join(', ')} `\n : ''\n }}`;\n }\n}\n\nObject.freeze(FrozenMap);\nObject.freeze(FrozenMap.prototype);\n\nObject.freeze(FrozenSet);\nObject.freeze(FrozenSet.prototype);\n\nexport { FrozenMap, FrozenSet };\n"]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './collections';
1
2
  export * from './json';
3
+ export * from './logging';
2
4
  export * from './misc';
3
5
  export * from './time';
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -10,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./collections"), exports);
13
18
  __exportStar(require("./json"), exports);
19
+ __exportStar(require("./logging"), exports);
14
20
  __exportStar(require("./misc"), exports);
15
21
  __exportStar(require("./time"), exports);
16
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,yCAAuB;AACvB,yCAAuB","sourcesContent":["export * from './json';\nexport * from './misc';\nexport * from './time';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,yCAAuB;AACvB,4CAA0B;AAC1B,yCAAuB;AACvB,yCAAuB","sourcesContent":["export * from './collections';\nexport * from './json';\nexport * from './logging';\nexport * from './misc';\nexport * from './time';\n"]}
package/dist/json.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Infer, Struct } from 'superstruct';
2
+ export declare const JsonStruct: Struct<Json>;
1
3
  /**
2
4
  * Any JSON-compatible value.
3
5
  */
@@ -15,94 +17,239 @@ export declare function isValidJson(value: unknown): value is Json;
15
17
  * The string '2.0'.
16
18
  */
17
19
  export declare const jsonrpc2: "2.0";
20
+ export declare const JsonRpcVersionStruct: Struct<"2.0", "2.0">;
18
21
  /**
19
22
  * A String specifying the version of the JSON-RPC protocol.
20
23
  * MUST be exactly "2.0".
21
24
  */
22
25
  export declare type JsonRpcVersion2 = typeof jsonrpc2;
26
+ export declare const JsonRpcIdStruct: Struct<string | number | null, null>;
23
27
  /**
24
28
  * An identifier established by the Client that MUST contain a String, Number,
25
29
  * or NULL value if included. If it is not included it is assumed to be a
26
30
  * notification. The value SHOULD normally not be Null and Numbers SHOULD
27
31
  * NOT contain fractional parts.
28
32
  */
29
- export declare type JsonRpcId = number | string | null;
33
+ export declare type JsonRpcId = Infer<typeof JsonRpcIdStruct>;
34
+ export declare const JsonRpcErrorStruct: Struct<{
35
+ code: number;
36
+ message: string;
37
+ data: unknown;
38
+ stack?: string | undefined;
39
+ }, {
40
+ code: Struct<number, null>;
41
+ message: Struct<string, null>;
42
+ data: Struct<unknown, null>;
43
+ stack: Struct<string | undefined, null>;
44
+ }>;
30
45
  /**
31
46
  * A JSON-RPC error object.
32
47
  */
33
- export declare type JsonRpcError = {
34
- code: number;
35
- message: string;
36
- data?: unknown;
37
- stack?: string;
48
+ export declare type JsonRpcError = Infer<typeof JsonRpcErrorStruct>;
49
+ export declare const JsonRpcParamsStruct: Struct<unknown[] | Record<string, unknown> | undefined, null>;
50
+ export declare type JsonRpcParams = Infer<typeof JsonRpcParamsStruct>;
51
+ export declare const JsonRpcRequestStruct: Struct<{
52
+ id: string | number | null;
53
+ jsonrpc: "2.0";
54
+ method: string;
55
+ params?: unknown[] | Record<string, unknown> | undefined;
56
+ }, {
57
+ id: Struct<string | number | null, null>;
58
+ jsonrpc: Struct<"2.0", "2.0">;
59
+ method: Struct<string, null>;
60
+ params: Struct<unknown[] | Record<string, unknown> | undefined, null>;
61
+ }>;
62
+ export declare type InferWithParams<Type extends Struct<any, unknown>, Params extends JsonRpcParams> = Omit<Infer<Type>, 'params'> & {
63
+ params: Params;
38
64
  };
39
65
  /**
40
66
  * A JSON-RPC request object.
41
- *
42
- * @template Params - The type of the params.
43
67
  */
44
- export declare type JsonRpcRequest<Params> = {
45
- id: JsonRpcId;
46
- jsonrpc: JsonRpcVersion2;
68
+ export declare type JsonRpcRequest<Params extends JsonRpcParams> = InferWithParams<typeof JsonRpcRequestStruct, Params>;
69
+ export declare const JsonRpcNotificationStruct: Struct<{
70
+ jsonrpc: "2.0";
47
71
  method: string;
48
- params?: Params;
49
- };
72
+ params?: unknown[] | Record<string, unknown> | undefined;
73
+ }, Omit<{
74
+ id: Struct<string | number | null, null>;
75
+ jsonrpc: Struct<"2.0", "2.0">;
76
+ method: Struct<string, null>;
77
+ params: Struct<unknown[] | Record<string, unknown> | undefined, null>;
78
+ }, "id">>;
50
79
  /**
51
80
  * A JSON-RPC notification object.
81
+ */
82
+ export declare type JsonRpcNotification<Params extends JsonRpcParams> = InferWithParams<typeof JsonRpcNotificationStruct, Params>;
83
+ /**
84
+ * Type guard to narrow a JSON-RPC request or notification object to a
85
+ * notification.
52
86
  *
53
- * @template Params - The type of the params.
87
+ * @param requestOrNotification - The JSON-RPC request or notification to check.
88
+ * @returns Whether the specified JSON-RPC message is a notification.
54
89
  */
55
- export declare type JsonRpcNotification<Params> = {
56
- jsonrpc: JsonRpcVersion2;
57
- method: string;
58
- params?: Params;
59
- };
90
+ export declare function isJsonRpcNotification(requestOrNotification: unknown): requestOrNotification is JsonRpcNotification<JsonRpcParams>;
60
91
  /**
61
- * A successful JSON-RPC response object.
92
+ * Assertion type guard to narrow a JSON-RPC request or notification object to a
93
+ * notification.
62
94
  *
63
- * @template Result - The type of the result.
95
+ * @param requestOrNotification - The JSON-RPC request or notification to check.
96
+ */
97
+ export declare function assertIsJsonRpcNotification(requestOrNotification: unknown): asserts requestOrNotification is JsonRpcNotification<JsonRpcParams>;
98
+ /**
99
+ * Type guard to narrow a JSON-RPC request or notification object to a request.
100
+ *
101
+ * @param requestOrNotification - The JSON-RPC request or notification to check.
102
+ * @returns Whether the specified JSON-RPC message is a request.
64
103
  */
65
- export declare type JsonRpcSuccess<Result = unknown> = {
66
- id: JsonRpcId;
67
- jsonrpc: JsonRpcVersion2;
104
+ export declare function isJsonRpcRequest(requestOrNotification: unknown): requestOrNotification is JsonRpcRequest<JsonRpcParams>;
105
+ /**
106
+ * Assertion type guard to narrow a JSON-RPC request or notification object to a
107
+ * request.
108
+ *
109
+ * @param requestOrNotification - The JSON-RPC request or notification to check.
110
+ */
111
+ export declare function assertIsJsonRpcRequest(requestOrNotification: unknown): asserts requestOrNotification is JsonRpcRequest<JsonRpcParams>;
112
+ export declare const JsonRpcSuccessStruct: Struct<{
113
+ id: string | number | null;
114
+ jsonrpc: "2.0";
115
+ result: Json;
116
+ }, {
117
+ id: Struct<string | number | null, null>;
118
+ jsonrpc: Struct<"2.0", "2.0">;
119
+ result: Struct<Json, unknown>;
120
+ }>;
121
+ /**
122
+ * A successful JSON-RPC response object.
123
+ */
124
+ export declare type JsonRpcSuccess<Result extends Json> = Omit<Infer<typeof JsonRpcSuccessStruct>, 'result'> & {
68
125
  result: Result;
69
126
  };
127
+ export declare const JsonRpcFailureStruct: Struct<{
128
+ id: string | number | null;
129
+ jsonrpc: "2.0";
130
+ error: {
131
+ code: number;
132
+ message: string;
133
+ data: unknown;
134
+ stack?: string | undefined;
135
+ };
136
+ }, {
137
+ id: Struct<string | number | null, null>;
138
+ jsonrpc: Struct<"2.0", "2.0">;
139
+ error: Struct<{
140
+ code: number;
141
+ message: string;
142
+ data: unknown;
143
+ stack?: string | undefined;
144
+ }, {
145
+ code: Struct<number, null>;
146
+ message: Struct<string, null>;
147
+ data: Struct<unknown, null>;
148
+ stack: Struct<string | undefined, null>;
149
+ }>;
150
+ }>;
70
151
  /**
71
152
  * A failed JSON-RPC response object.
72
153
  */
73
- export declare type JsonRpcFailure = {
74
- id: JsonRpcId;
75
- jsonrpc: JsonRpcVersion2;
76
- error: JsonRpcError;
77
- };
154
+ export declare type JsonRpcFailure = Infer<typeof JsonRpcFailureStruct>;
155
+ export declare const JsonRpcResponseStruct: Struct<{
156
+ id: string | number | null;
157
+ jsonrpc: "2.0";
158
+ result: Json;
159
+ } | {
160
+ id: string | number | null;
161
+ jsonrpc: "2.0";
162
+ error: {
163
+ code: number;
164
+ message: string;
165
+ data: unknown;
166
+ stack?: string | undefined;
167
+ };
168
+ }, null>;
78
169
  /**
79
170
  * A JSON-RPC response object. Must be checked to determine whether it's a
80
171
  * success or failure.
81
172
  *
82
173
  * @template Result - The type of the result.
83
174
  */
84
- export declare type JsonRpcResponse<Result = unknown> = JsonRpcSuccess<Result> | JsonRpcFailure;
175
+ export declare type JsonRpcResponse<Result extends Json> = JsonRpcSuccess<Result> | JsonRpcFailure;
85
176
  /**
86
- * ATTN: Assumes that only one of the `result` and `error` properties is
87
- * present on the `response`, as guaranteed by e.g.
88
- * [`JsonRpcEngine.handle`](https://github.com/MetaMask/json-rpc-engine/blob/main/src/JsonRpcEngine.ts).
177
+ * Type guard to check if a value is a JsonRpcResponse.
89
178
  *
179
+ * @param response - The object to check.
180
+ * @returns Whether the object is a JsonRpcResponse.
181
+ */
182
+ export declare function isJsonRpcResponse(response: unknown): response is JsonRpcResponse<Json>;
183
+ /**
184
+ * Type assertion to check if a value is a JsonRpcResponse.
185
+ *
186
+ * @param response - The response to check.
187
+ */
188
+ export declare function assertIsJsonRpcResponse(response: unknown): asserts response is JsonRpcResponse<Json>;
189
+ /**
90
190
  * Type guard to narrow a JsonRpcResponse object to a success (or failure).
91
191
  *
92
192
  * @param response - The response object to check.
93
- * @returns Whether the response object is a success, i.e. has a `result`
94
- * property.
193
+ * @returns Whether the response object is a success.
95
194
  */
96
- export declare function isJsonRpcSuccess<Result>(response: JsonRpcResponse<Result>): response is JsonRpcSuccess<Result>;
195
+ export declare function isJsonRpcSuccess(response: unknown): response is JsonRpcSuccess<Json>;
97
196
  /**
98
- * ATTN: Assumes that only one of the `result` and `error` properties is
99
- * present on the `response`, as guaranteed by e.g.
100
- * [`JsonRpcEngine.handle`](https://github.com/MetaMask/json-rpc-engine/blob/main/src/JsonRpcEngine.ts).
197
+ * Type assertion to narrow a JsonRpcResponse object to a success (or failure).
101
198
  *
199
+ * @param response - The response object to check.
200
+ */
201
+ export declare function assertIsJsonRpcSuccess(response: unknown): asserts response is JsonRpcSuccess<Json>;
202
+ /**
102
203
  * Type guard to narrow a JsonRpcResponse object to a failure (or success).
103
204
  *
104
205
  * @param response - The response object to check.
105
206
  * @returns Whether the response object is a failure, i.e. has an `error`
106
207
  * property.
107
208
  */
108
- export declare function isJsonRpcFailure(response: JsonRpcResponse<unknown>): response is JsonRpcFailure;
209
+ export declare function isJsonRpcFailure(response: unknown): response is JsonRpcFailure;
210
+ /**
211
+ * Type assertion to narrow a JsonRpcResponse object to a failure (or success).
212
+ *
213
+ * @param response - The response object to check.
214
+ */
215
+ export declare function assertIsJsonRpcFailure(response: unknown): asserts response is JsonRpcFailure;
216
+ declare type JsonRpcValidatorOptions = {
217
+ permitEmptyString?: boolean;
218
+ permitFractions?: boolean;
219
+ permitNull?: boolean;
220
+ };
221
+ /**
222
+ * Gets a function for validating JSON-RPC request / response `id` values.
223
+ *
224
+ * By manipulating the options of this factory, you can control the behavior
225
+ * of the resulting validator for some edge cases. This is useful because e.g.
226
+ * `null` should sometimes but not always be permitted.
227
+ *
228
+ * Note that the empty string (`''`) is always permitted by the JSON-RPC
229
+ * specification, but that kind of sucks and you may want to forbid it in some
230
+ * instances anyway.
231
+ *
232
+ * For more details, see the
233
+ * [JSON-RPC Specification](https://www.jsonrpc.org/specification).
234
+ *
235
+ * @param options - An options object.
236
+ * @param options.permitEmptyString - Whether the empty string (i.e. `''`)
237
+ * should be treated as a valid ID. Default: `true`
238
+ * @param options.permitFractions - Whether fractional numbers (e.g. `1.2`)
239
+ * should be treated as valid IDs. Default: `false`
240
+ * @param options.permitNull - Whether `null` should be treated as a valid ID.
241
+ * Default: `true`
242
+ * @returns The JSON-RPC ID validator function.
243
+ */
244
+ export declare function getJsonRpcIdValidator(options?: JsonRpcValidatorOptions): (id: unknown) => id is string | number | null;
245
+ /**
246
+ * Checks whether a value is JSON serializable and counts the total number
247
+ * of bytes needed to store the serialized version of the value.
248
+ *
249
+ * @param jsObject - Potential JSON serializable object.
250
+ * @param skipSizingProcess - Skip JSON size calculation (default: false).
251
+ * @returns Tuple [isValid, plainTextSizeInBytes] containing a boolean that signals whether
252
+ * the value was serializable and a number of bytes that it will use when serialized to JSON.
253
+ */
254
+ export declare function validateJsonAndGetSize(jsObject: unknown, skipSizingProcess?: boolean): [isValid: boolean, plainTextSizeInBytes: number];
255
+ export {};