@metamask-previews/keyring-api 8.1.0-preview-4ddfc4a → 8.1.0-preview-46bb5ff

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.
Files changed (51) hide show
  1. package/dist/JsonRpcRequest.d.ts +1 -1
  2. package/dist/JsonRpcRequest.js +3 -3
  3. package/dist/JsonRpcRequest.js.map +1 -1
  4. package/dist/KeyringClient.js +10 -10
  5. package/dist/KeyringClient.js.map +1 -1
  6. package/dist/api/account.d.ts +1 -1
  7. package/dist/api/account.js +3 -4
  8. package/dist/api/account.js.map +1 -1
  9. package/dist/api/balance.js +3 -4
  10. package/dist/api/balance.js.map +1 -1
  11. package/dist/api/caip.js +3 -3
  12. package/dist/api/caip.js.map +1 -1
  13. package/dist/api/request.d.ts +1 -1
  14. package/dist/api/request.js +6 -7
  15. package/dist/api/request.js.map +1 -1
  16. package/dist/api/response.js +6 -6
  17. package/dist/api/response.js.map +1 -1
  18. package/dist/btc/types.d.ts +1 -1
  19. package/dist/btc/types.js +2 -2
  20. package/dist/btc/types.js.map +1 -1
  21. package/dist/eth/erc4337/types.d.ts +5 -5
  22. package/dist/eth/erc4337/types.js +10 -11
  23. package/dist/eth/erc4337/types.js.map +1 -1
  24. package/dist/eth/types.d.ts +2 -2
  25. package/dist/eth/types.js +6 -6
  26. package/dist/eth/types.js.map +1 -1
  27. package/dist/index.d.ts +0 -1
  28. package/dist/index.js +0 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/internal/api.d.ts +10 -10
  31. package/dist/internal/api.js +32 -33
  32. package/dist/internal/api.js.map +1 -1
  33. package/dist/internal/events.d.ts +8 -8
  34. package/dist/internal/events.js +16 -17
  35. package/dist/internal/events.js.map +1 -1
  36. package/dist/internal/types.d.ts +19 -19
  37. package/dist/internal/types.js +9 -9
  38. package/dist/internal/types.js.map +1 -1
  39. package/package.json +2 -2
  40. package/dist/superstruct.d.ts +0 -83
  41. package/dist/superstruct.js +0 -81
  42. package/dist/superstruct.js.map +0 -1
  43. package/dist/utils/index.d.ts +0 -2
  44. package/dist/utils/index.js +0 -19
  45. package/dist/utils/index.js.map +0 -1
  46. package/dist/utils/types.d.ts +0 -17
  47. package/dist/utils/types.js +0 -29
  48. package/dist/utils/types.js.map +0 -1
  49. package/dist/utils/typing.d.ts +0 -32
  50. package/dist/utils/typing.js +0 -21
  51. package/dist/utils/typing.js.map +0 -1
@@ -32,8 +32,8 @@ export declare const InternalAccountMetadataStruct: Struct<{
32
32
  lastSelected?: number;
33
33
  }, {
34
34
  name: Struct<string, null>;
35
- nameLastUpdatedAt: Struct<number | import("../superstruct").ExactOptionalTag, null>;
36
- snap: Struct<import("../superstruct").ExactOptionalTag | {
35
+ nameLastUpdatedAt: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
36
+ snap: Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
37
37
  id: string;
38
38
  name: string;
39
39
  enabled: boolean;
@@ -42,7 +42,7 @@ export declare const InternalAccountMetadataStruct: Struct<{
42
42
  enabled: Struct<boolean, null>;
43
43
  name: Struct<string, null>;
44
44
  }>;
45
- lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>;
45
+ lastSelected: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
46
46
  importTime: Struct<number, null>;
47
47
  keyring: Struct<{
48
48
  type: string;
@@ -52,8 +52,8 @@ export declare const InternalAccountMetadataStruct: Struct<{
52
52
  }>;
53
53
  }>;
54
54
  export declare const InternalEthEoaAccountStruct: Struct<{
55
- type: "eip155:eoa";
56
55
  id: string;
56
+ type: "eip155:eoa";
57
57
  address: string;
58
58
  options: Record<string, import("@metamask/utils").Json>;
59
59
  methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
@@ -100,8 +100,8 @@ export declare const InternalEthEoaAccountStruct: Struct<{
100
100
  lastSelected?: number;
101
101
  }, {
102
102
  name: Struct<string, null>;
103
- nameLastUpdatedAt: Struct<number | import("../superstruct").ExactOptionalTag, null>;
104
- snap: Struct<import("../superstruct").ExactOptionalTag | {
103
+ nameLastUpdatedAt: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
104
+ snap: Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
105
105
  id: string;
106
106
  name: string;
107
107
  enabled: boolean;
@@ -110,7 +110,7 @@ export declare const InternalEthEoaAccountStruct: Struct<{
110
110
  enabled: Struct<boolean, null>;
111
111
  name: Struct<string, null>;
112
112
  }>;
113
- lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>;
113
+ lastSelected: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
114
114
  importTime: Struct<number, null>;
115
115
  keyring: Struct<{
116
116
  type: string;
@@ -120,8 +120,8 @@ export declare const InternalEthEoaAccountStruct: Struct<{
120
120
  }>;
121
121
  }>;
122
122
  export declare const InternalEthErc4337AccountStruct: Struct<{
123
- type: "eip155:erc4337";
124
123
  id: string;
124
+ type: "eip155:erc4337";
125
125
  address: string;
126
126
  options: Record<string, import("@metamask/utils").Json>;
127
127
  methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
@@ -170,8 +170,8 @@ export declare const InternalEthErc4337AccountStruct: Struct<{
170
170
  lastSelected?: number;
171
171
  }, {
172
172
  name: Struct<string, null>;
173
- nameLastUpdatedAt: Struct<number | import("../superstruct").ExactOptionalTag, null>;
174
- snap: Struct<import("../superstruct").ExactOptionalTag | {
173
+ nameLastUpdatedAt: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
174
+ snap: Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
175
175
  id: string;
176
176
  name: string;
177
177
  enabled: boolean;
@@ -180,7 +180,7 @@ export declare const InternalEthErc4337AccountStruct: Struct<{
180
180
  enabled: Struct<boolean, null>;
181
181
  name: Struct<string, null>;
182
182
  }>;
183
- lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>;
183
+ lastSelected: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
184
184
  importTime: Struct<number, null>;
185
185
  keyring: Struct<{
186
186
  type: string;
@@ -190,8 +190,8 @@ export declare const InternalEthErc4337AccountStruct: Struct<{
190
190
  }>;
191
191
  }>;
192
192
  export declare const InternalBtcP2wpkhAccountStruct: Struct<{
193
- type: "bip122:p2wpkh";
194
193
  id: string;
194
+ type: "bip122:p2wpkh";
195
195
  address: string;
196
196
  options: Record<string, import("@metamask/utils").Json>;
197
197
  methods: "btc_sendmany"[];
@@ -233,8 +233,8 @@ export declare const InternalBtcP2wpkhAccountStruct: Struct<{
233
233
  lastSelected?: number;
234
234
  }, {
235
235
  name: Struct<string, null>;
236
- nameLastUpdatedAt: Struct<number | import("../superstruct").ExactOptionalTag, null>;
237
- snap: Struct<import("../superstruct").ExactOptionalTag | {
236
+ nameLastUpdatedAt: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
237
+ snap: Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
238
238
  id: string;
239
239
  name: string;
240
240
  enabled: boolean;
@@ -243,7 +243,7 @@ export declare const InternalBtcP2wpkhAccountStruct: Struct<{
243
243
  enabled: Struct<boolean, null>;
244
244
  name: Struct<string, null>;
245
245
  }>;
246
- lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>;
246
+ lastSelected: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
247
247
  importTime: Struct<number, null>;
248
248
  keyring: Struct<{
249
249
  type: string;
@@ -258,8 +258,8 @@ export declare type InternalBtcP2wpkhAccount = Infer<typeof InternalBtcP2wpkhAcc
258
258
  export declare const InternalAccountStructs: Record<string, Struct<InternalEthEoaAccount> | Struct<InternalEthErc4337Account> | Struct<InternalBtcP2wpkhAccount>>;
259
259
  export declare type InternalAccountTypes = InternalEthEoaAccount | InternalEthErc4337Account | InternalBtcP2wpkhAccount;
260
260
  export declare const InternalAccountStruct: Struct<{
261
- type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh";
262
261
  id: string;
262
+ type: "eip155:eoa" | "eip155:erc4337" | "bip122:p2wpkh";
263
263
  address: string;
264
264
  options: Record<string, import("@metamask/utils").Json>;
265
265
  methods: string[];
@@ -293,8 +293,8 @@ export declare const InternalAccountStruct: Struct<{
293
293
  lastSelected?: number;
294
294
  }, {
295
295
  name: Struct<string, null>;
296
- nameLastUpdatedAt: Struct<number | import("../superstruct").ExactOptionalTag, null>;
297
- snap: Struct<import("../superstruct").ExactOptionalTag | {
296
+ nameLastUpdatedAt: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
297
+ snap: Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
298
298
  id: string;
299
299
  name: string;
300
300
  enabled: boolean;
@@ -303,7 +303,7 @@ export declare const InternalAccountStruct: Struct<{
303
303
  enabled: Struct<boolean, null>;
304
304
  name: Struct<string, null>;
305
305
  }>;
306
- lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>;
306
+ lastSelected: Struct<number | import("@metamask/keyring-utils").ExactOptionalTag, null>;
307
307
  importTime: Struct<number, null>;
308
308
  keyring: Struct<{
309
309
  type: string;
@@ -5,19 +5,19 @@ const superstruct_1 = require("@metamask/superstruct");
5
5
  const api_1 = require("../api");
6
6
  const types_1 = require("../btc/types");
7
7
  const types_2 = require("../eth/types");
8
- const superstruct_2 = require("../superstruct");
9
- exports.InternalAccountMetadataStruct = (0, superstruct_2.object)({
10
- metadata: (0, superstruct_2.object)({
8
+ const keyring_utils_1 = require("@metamask/keyring-utils");
9
+ exports.InternalAccountMetadataStruct = (0, keyring_utils_1.object)({
10
+ metadata: (0, keyring_utils_1.object)({
11
11
  name: (0, superstruct_1.string)(),
12
- nameLastUpdatedAt: (0, superstruct_2.exactOptional)((0, superstruct_1.number)()),
13
- snap: (0, superstruct_2.exactOptional)((0, superstruct_2.object)({
12
+ nameLastUpdatedAt: (0, keyring_utils_1.exactOptional)((0, superstruct_1.number)()),
13
+ snap: (0, keyring_utils_1.exactOptional)((0, keyring_utils_1.object)({
14
14
  id: (0, superstruct_1.string)(),
15
15
  enabled: (0, superstruct_1.boolean)(),
16
16
  name: (0, superstruct_1.string)(),
17
17
  })),
18
- lastSelected: (0, superstruct_2.exactOptional)((0, superstruct_1.number)()),
18
+ lastSelected: (0, keyring_utils_1.exactOptional)((0, superstruct_1.number)()),
19
19
  importTime: (0, superstruct_1.number)(),
20
- keyring: (0, superstruct_2.object)({
20
+ keyring: (0, keyring_utils_1.object)({
21
21
  type: (0, superstruct_1.string)(),
22
22
  }),
23
23
  }),
@@ -29,7 +29,7 @@ exports.InternalAccountMetadataStruct = (0, superstruct_2.object)({
29
29
  * @returns The `InternalAccount` associated to `accountStruct`.
30
30
  */
31
31
  function asInternalAccountStruct(accountStruct) {
32
- return (0, superstruct_2.object)({
32
+ return (0, keyring_utils_1.object)({
33
33
  ...accountStruct.schema,
34
34
  ...exports.InternalAccountMetadataStruct.schema,
35
35
  });
@@ -42,7 +42,7 @@ exports.InternalAccountStructs = {
42
42
  [`${api_1.EthAccountType.Erc4337}`]: exports.InternalEthErc4337AccountStruct,
43
43
  [`${api_1.BtcAccountType.P2wpkh}`]: exports.InternalBtcP2wpkhAccountStruct,
44
44
  };
45
- exports.InternalAccountStruct = (0, superstruct_2.object)({
45
+ exports.InternalAccountStruct = (0, keyring_utils_1.object)({
46
46
  ...api_1.KeyringAccountStruct.schema,
47
47
  ...exports.InternalAccountMetadataStruct.schema,
48
48
  });
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":";;;AACA,uDAAgE;AAEhE,gCAA8E;AAC9E,wCAAsD;AACtD,wCAA4E;AAC5E,gDAAuD;AAI1C,QAAA,6BAA6B,GAAG,IAAA,oBAAM,EAAC;IAClD,QAAQ,EAAE,IAAA,oBAAM,EAAC;QACf,IAAI,EAAE,IAAA,oBAAM,GAAE;QACd,iBAAiB,EAAE,IAAA,2BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;QAC1C,IAAI,EAAE,IAAA,2BAAa,EACjB,IAAA,oBAAM,EAAC;YACL,EAAE,EAAE,IAAA,oBAAM,GAAE;YACZ,OAAO,EAAE,IAAA,qBAAO,GAAE;YAClB,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC,CACH;QACD,YAAY,EAAE,IAAA,2BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;QACrC,UAAU,EAAE,IAAA,oBAAM,GAAE;QACpB,OAAO,EAAE,IAAA,oBAAM,EAAC;YACd,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAS,uBAAuB,CAC9B,aAA6C;IAE7C,OAAO,IAAA,oBAAM,EAAC;QACZ,GAAG,aAAa,CAAC,MAAM;QACvB,GAAG,qCAA6B,CAAC,MAAM;KACxC,CAAC,CAAC;AACL,CAAC;AAEY,QAAA,2BAA2B,GACtC,uBAAuB,CAAC,2BAAmB,CAAC,CAAC;AAElC,QAAA,+BAA+B,GAAG,uBAAuB,CACpE,+BAAuB,CACxB,CAAC;AAEW,QAAA,8BAA8B,GAAG,uBAAuB,CACnE,8BAAsB,CACvB,CAAC;AAYW,QAAA,sBAAsB,GAK/B;IACF,CAAC,GAAG,oBAAc,CAAC,GAAG,EAAE,CAAC,EAAE,mCAA2B;IACtD,CAAC,GAAG,oBAAc,CAAC,OAAO,EAAE,CAAC,EAAE,uCAA+B;IAC9D,CAAC,GAAG,oBAAc,CAAC,MAAM,EAAE,CAAC,EAAE,sCAA8B;CAC7D,CAAC;AAOW,QAAA,qBAAqB,GAAG,IAAA,oBAAM,EAAC;IAC1C,GAAG,0BAAoB,CAAC,MAAM;IAC9B,GAAG,qCAA6B,CAAC,MAAM;CACxC,CAAC,CAAC","sourcesContent":["import type { Infer, Struct } from '@metamask/superstruct';\nimport { boolean, string, number } from '@metamask/superstruct';\n\nimport { BtcAccountType, EthAccountType, KeyringAccountStruct } from '../api';\nimport { BtcP2wpkhAccountStruct } from '../btc/types';\nimport { EthEoaAccountStruct, EthErc4337AccountStruct } from '../eth/types';\nimport { exactOptional, object } from '../superstruct';\n\nexport type InternalAccountType = EthAccountType | BtcAccountType;\n\nexport const InternalAccountMetadataStruct = object({\n metadata: object({\n name: string(),\n nameLastUpdatedAt: exactOptional(number()),\n snap: exactOptional(\n object({\n id: string(),\n enabled: boolean(),\n name: string(),\n }),\n ),\n lastSelected: exactOptional(number()),\n importTime: number(),\n keyring: object({\n type: string(),\n }),\n }),\n});\n\n/**\n * Creates an `InternalAccount` from an existing account `superstruct` object.\n *\n * @param accountStruct - An account `superstruct` object.\n * @returns The `InternalAccount` associated to `accountStruct`.\n */\nfunction asInternalAccountStruct<Account, AccountSchema>(\n accountStruct: Struct<Account, AccountSchema>,\n) {\n return object({\n ...accountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n });\n}\n\nexport const InternalEthEoaAccountStruct =\n asInternalAccountStruct(EthEoaAccountStruct);\n\nexport const InternalEthErc4337AccountStruct = asInternalAccountStruct(\n EthErc4337AccountStruct,\n);\n\nexport const InternalBtcP2wpkhAccountStruct = asInternalAccountStruct(\n BtcP2wpkhAccountStruct,\n);\n\nexport type InternalEthEoaAccount = Infer<typeof InternalEthEoaAccountStruct>;\n\nexport type InternalEthErc4337Account = Infer<\n typeof InternalEthErc4337AccountStruct\n>;\n\nexport type InternalBtcP2wpkhAccount = Infer<\n typeof InternalBtcP2wpkhAccountStruct\n>;\n\nexport const InternalAccountStructs: Record<\n string,\n | Struct<InternalEthEoaAccount>\n | Struct<InternalEthErc4337Account>\n | Struct<InternalBtcP2wpkhAccount>\n> = {\n [`${EthAccountType.Eoa}`]: InternalEthEoaAccountStruct,\n [`${EthAccountType.Erc4337}`]: InternalEthErc4337AccountStruct,\n [`${BtcAccountType.P2wpkh}`]: InternalBtcP2wpkhAccountStruct,\n};\n\nexport type InternalAccountTypes =\n | InternalEthEoaAccount\n | InternalEthErc4337Account\n | InternalBtcP2wpkhAccount;\n\nexport const InternalAccountStruct = object({\n ...KeyringAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\n/**\n * Internal account representation.\n *\n * This type is used internally by MetaMask to add additional metadata to the\n * account object. It's should not be used by external applications.\n */\nexport type InternalAccount = Infer<typeof InternalAccountStruct>;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/internal/types.ts"],"names":[],"mappings":";;;AACA,uDAAgE;AAEhE,gCAA8E;AAC9E,wCAAsD;AACtD,wCAA4E;AAC5E,2DAAgE;AAInD,QAAA,6BAA6B,GAAG,IAAA,sBAAM,EAAC;IAClD,QAAQ,EAAE,IAAA,sBAAM,EAAC;QACf,IAAI,EAAE,IAAA,oBAAM,GAAE;QACd,iBAAiB,EAAE,IAAA,6BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;QAC1C,IAAI,EAAE,IAAA,6BAAa,EACjB,IAAA,sBAAM,EAAC;YACL,EAAE,EAAE,IAAA,oBAAM,GAAE;YACZ,OAAO,EAAE,IAAA,qBAAO,GAAE;YAClB,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC,CACH;QACD,YAAY,EAAE,IAAA,6BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;QACrC,UAAU,EAAE,IAAA,oBAAM,GAAE;QACpB,OAAO,EAAE,IAAA,sBAAM,EAAC;YACd,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAS,uBAAuB,CAC9B,aAA6C;IAE7C,OAAO,IAAA,sBAAM,EAAC;QACZ,GAAG,aAAa,CAAC,MAAM;QACvB,GAAG,qCAA6B,CAAC,MAAM;KACxC,CAAC,CAAC;AACL,CAAC;AAEY,QAAA,2BAA2B,GACtC,uBAAuB,CAAC,2BAAmB,CAAC,CAAC;AAElC,QAAA,+BAA+B,GAAG,uBAAuB,CACpE,+BAAuB,CACxB,CAAC;AAEW,QAAA,8BAA8B,GAAG,uBAAuB,CACnE,8BAAsB,CACvB,CAAC;AAYW,QAAA,sBAAsB,GAK/B;IACF,CAAC,GAAG,oBAAc,CAAC,GAAG,EAAE,CAAC,EAAE,mCAA2B;IACtD,CAAC,GAAG,oBAAc,CAAC,OAAO,EAAE,CAAC,EAAE,uCAA+B;IAC9D,CAAC,GAAG,oBAAc,CAAC,MAAM,EAAE,CAAC,EAAE,sCAA8B;CAC7D,CAAC;AAOW,QAAA,qBAAqB,GAAG,IAAA,sBAAM,EAAC;IAC1C,GAAG,0BAAoB,CAAC,MAAM;IAC9B,GAAG,qCAA6B,CAAC,MAAM;CACxC,CAAC,CAAC","sourcesContent":["import type { Infer, Struct } from '@metamask/superstruct';\nimport { boolean, string, number } from '@metamask/superstruct';\n\nimport { BtcAccountType, EthAccountType, KeyringAccountStruct } from '../api';\nimport { BtcP2wpkhAccountStruct } from '../btc/types';\nimport { EthEoaAccountStruct, EthErc4337AccountStruct } from '../eth/types';\nimport { exactOptional, object } from '@metamask/keyring-utils';\n\nexport type InternalAccountType = EthAccountType | BtcAccountType;\n\nexport const InternalAccountMetadataStruct = object({\n metadata: object({\n name: string(),\n nameLastUpdatedAt: exactOptional(number()),\n snap: exactOptional(\n object({\n id: string(),\n enabled: boolean(),\n name: string(),\n }),\n ),\n lastSelected: exactOptional(number()),\n importTime: number(),\n keyring: object({\n type: string(),\n }),\n }),\n});\n\n/**\n * Creates an `InternalAccount` from an existing account `superstruct` object.\n *\n * @param accountStruct - An account `superstruct` object.\n * @returns The `InternalAccount` associated to `accountStruct`.\n */\nfunction asInternalAccountStruct<Account, AccountSchema>(\n accountStruct: Struct<Account, AccountSchema>,\n) {\n return object({\n ...accountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n });\n}\n\nexport const InternalEthEoaAccountStruct =\n asInternalAccountStruct(EthEoaAccountStruct);\n\nexport const InternalEthErc4337AccountStruct = asInternalAccountStruct(\n EthErc4337AccountStruct,\n);\n\nexport const InternalBtcP2wpkhAccountStruct = asInternalAccountStruct(\n BtcP2wpkhAccountStruct,\n);\n\nexport type InternalEthEoaAccount = Infer<typeof InternalEthEoaAccountStruct>;\n\nexport type InternalEthErc4337Account = Infer<\n typeof InternalEthErc4337AccountStruct\n>;\n\nexport type InternalBtcP2wpkhAccount = Infer<\n typeof InternalBtcP2wpkhAccountStruct\n>;\n\nexport const InternalAccountStructs: Record<\n string,\n | Struct<InternalEthEoaAccount>\n | Struct<InternalEthErc4337Account>\n | Struct<InternalBtcP2wpkhAccount>\n> = {\n [`${EthAccountType.Eoa}`]: InternalEthEoaAccountStruct,\n [`${EthAccountType.Erc4337}`]: InternalEthErc4337AccountStruct,\n [`${BtcAccountType.P2wpkh}`]: InternalBtcP2wpkhAccountStruct,\n};\n\nexport type InternalAccountTypes =\n | InternalEthEoaAccount\n | InternalEthErc4337Account\n | InternalBtcP2wpkhAccount;\n\nexport const InternalAccountStruct = object({\n ...KeyringAccountStruct.schema,\n ...InternalAccountMetadataStruct.schema,\n});\n\n/**\n * Internal account representation.\n *\n * This type is used internally by MetaMask to add additional metadata to the\n * account object. It's should not be used by external applications.\n */\nexport type InternalAccount = Infer<typeof InternalAccountStruct>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/keyring-api",
3
- "version": "8.1.0-preview-4ddfc4a",
3
+ "version": "8.1.0-preview-46bb5ff",
4
4
  "description": "MetaMask Keyring API",
5
5
  "keywords": [
6
6
  "metamask",
@@ -39,7 +39,6 @@
39
39
  "@metamask/snaps-sdk": "^6.1.0",
40
40
  "@metamask/superstruct": "^3.1.0",
41
41
  "@metamask/utils": "^9.1.0",
42
- "@types/uuid": "^9.0.8",
43
42
  "bech32": "^2.0.0",
44
43
  "deepmerge": "^4.2.2",
45
44
  "uuid": "^9.0.1"
@@ -48,6 +47,7 @@
48
47
  "@lavamoat/allow-scripts": "^3.0.4",
49
48
  "@lavamoat/preinstall-always-fail": "^2.0.0",
50
49
  "@metamask/auto-changelog": "^3.4.4",
50
+ "@metamask/keyring-utils": "^0.0.1",
51
51
  "@metamask/providers": "^17.1.1",
52
52
  "@types/jest": "^29.5.12",
53
53
  "@types/node": "^20.12.12",
@@ -1,83 +0,0 @@
1
- import { Struct } from '@metamask/superstruct';
2
- import type { Infer, ObjectSchema, OmitBy, Optionalize, PickBy, Simplify } from '@metamask/superstruct';
3
- declare const ExactOptionalSymbol: unique symbol;
4
- export declare type ExactOptionalTag = {
5
- type: typeof ExactOptionalSymbol;
6
- };
7
- /**
8
- * Exclude type `Type` from the properties of `Obj`.
9
- *
10
- * ```ts
11
- * type Foo = { a: string | null; b: number };
12
- * type Bar = ExcludeType<Foo, null>;
13
- * // Bar = { a: string, b: number }
14
- * ```
15
- */
16
- export declare type ExcludeType<Obj, Type> = {
17
- [K in keyof Obj]: Exclude<Obj[K], Type>;
18
- };
19
- /**
20
- * Make optional all properties that have the `ExactOptionalTag` type.
21
- *
22
- * ```ts
23
- * type Foo = { a: string | ExactOptionalTag; b: number};
24
- * type Bar = ExactOptionalize<Foo>;
25
- * // Bar = { a?: string; b: number}
26
- * ```
27
- */
28
- export declare type ExactOptionalize<Schema extends object> = OmitBy<Schema, ExactOptionalTag> & Partial<ExcludeType<PickBy<Schema, ExactOptionalTag>, ExactOptionalTag>>;
29
- /**
30
- * Infer a type from an superstruct object schema.
31
- */
32
- export declare type ObjectType<Schema extends ObjectSchema> = Simplify<ExactOptionalize<Optionalize<{
33
- [K in keyof Schema]: Infer<Schema[K]>;
34
- }>>>;
35
- /**
36
- * Change the return type of a superstruct object struct to support exact
37
- * optional properties.
38
- *
39
- * @param schema - The object schema.
40
- * @returns A struct representing an object with a known set of properties.
41
- */
42
- export declare function object<Schema extends ObjectSchema>(schema: Schema): Struct<ObjectType<Schema>, Schema>;
43
- /**
44
- * Augment a struct to allow exact-optional values. Exact-optional values can
45
- * be omitted but cannot be `undefined`.
46
- *
47
- * ```ts
48
- * const foo = object({ bar: exactOptional(string()) });
49
- * type Foo = Infer<typeof foo>;
50
- * // Foo = { bar?: string }
51
- * ```
52
- *
53
- * @param struct - The struct to augment.
54
- * @returns The augmented struct.
55
- */
56
- export declare function exactOptional<Type, Schema>(struct: Struct<Type, Schema>): Struct<Type | ExactOptionalTag, Schema>;
57
- /**
58
- * Defines a new string-struct matching a regular expression.
59
- *
60
- * Example:
61
- *
62
- * ```ts
63
- * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);
64
- * ```
65
- *
66
- * @param name - Type name.
67
- * @param pattern - Regular expression to match.
68
- * @returns A new string-struct that matches the given pattern.
69
- */
70
- export declare function definePattern(name: string, pattern: RegExp): Struct<string, null>;
71
- /**
72
- * Assert that a value is valid according to a struct.
73
- *
74
- * It is similar to superstruct's mask function, but it does not ignore extra
75
- * properties.
76
- *
77
- * @param value - Value to check.
78
- * @param struct - Struct to validate the value against.
79
- * @param message - Error message to throw if the value is not valid.
80
- * @returns The value if it is valid.
81
- */
82
- export declare function strictMask<Type, Schema>(value: unknown, struct: Struct<Type, Schema>, message?: string): Type;
83
- export {};
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.strictMask = exports.definePattern = exports.exactOptional = exports.object = void 0;
4
- const superstruct_1 = require("@metamask/superstruct");
5
- /**
6
- * Change the return type of a superstruct object struct to support exact
7
- * optional properties.
8
- *
9
- * @param schema - The object schema.
10
- * @returns A struct representing an object with a known set of properties.
11
- */
12
- function object(schema) {
13
- return (0, superstruct_1.object)(schema);
14
- }
15
- exports.object = object;
16
- /**
17
- * Check if the current property is present in its parent object.
18
- *
19
- * @param ctx - The context to check.
20
- * @returns `true` if the property is present, `false` otherwise.
21
- */
22
- function hasOptional(ctx) {
23
- const property = ctx.path[ctx.path.length - 1];
24
- const parent = ctx.branch[ctx.branch.length - 2];
25
- return property in parent;
26
- }
27
- /**
28
- * Augment a struct to allow exact-optional values. Exact-optional values can
29
- * be omitted but cannot be `undefined`.
30
- *
31
- * ```ts
32
- * const foo = object({ bar: exactOptional(string()) });
33
- * type Foo = Infer<typeof foo>;
34
- * // Foo = { bar?: string }
35
- * ```
36
- *
37
- * @param struct - The struct to augment.
38
- * @returns The augmented struct.
39
- */
40
- function exactOptional(struct) {
41
- return new superstruct_1.Struct({
42
- ...struct,
43
- validator: (value, ctx) => !hasOptional(ctx) || struct.validator(value, ctx),
44
- refiner: (value, ctx) => !hasOptional(ctx) || struct.refiner(value, ctx),
45
- });
46
- }
47
- exports.exactOptional = exactOptional;
48
- /**
49
- * Defines a new string-struct matching a regular expression.
50
- *
51
- * Example:
52
- *
53
- * ```ts
54
- * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);
55
- * ```
56
- *
57
- * @param name - Type name.
58
- * @param pattern - Regular expression to match.
59
- * @returns A new string-struct that matches the given pattern.
60
- */
61
- function definePattern(name, pattern) {
62
- return (0, superstruct_1.define)(name, (value) => typeof value === 'string' && pattern.test(value));
63
- }
64
- exports.definePattern = definePattern;
65
- /**
66
- * Assert that a value is valid according to a struct.
67
- *
68
- * It is similar to superstruct's mask function, but it does not ignore extra
69
- * properties.
70
- *
71
- * @param value - Value to check.
72
- * @param struct - Struct to validate the value against.
73
- * @param message - Error message to throw if the value is not valid.
74
- * @returns The value if it is valid.
75
- */
76
- function strictMask(value, struct, message) {
77
- (0, superstruct_1.assert)(value, struct, message);
78
- return value;
79
- }
80
- exports.strictMask = strictMask;
81
- //# sourceMappingURL=superstruct.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"superstruct.js","sourceRoot":"","sources":["../src/superstruct.ts"],"names":[],"mappings":";;;AAAA,uDAK+B;AAoD/B;;;;;;GAMG;AACH,SAAgB,MAAM,CACpB,MAAc;IAEd,OAAO,IAAA,oBAAQ,EAAC,MAAM,CAAQ,CAAC;AACjC,CAAC;AAJD,wBAIC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,QAAQ,GAAW,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAA4B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE1E,OAAO,QAAQ,IAAI,MAAM,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,MAA4B;IAE5B,OAAO,IAAI,oBAAM,CAAC;QAChB,GAAG,MAAM;QAET,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACxB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAEnD,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACtB,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAa,EAAE,GAAG,CAAC;KAC1D,CAAC,CAAC;AACL,CAAC;AAZD,sCAYC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAC3B,IAAY,EACZ,OAAe;IAEf,OAAO,IAAA,oBAAM,EACX,IAAI,EACJ,CAAC,KAAc,EAAW,EAAE,CAC1B,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CACnD,CAAC;AACJ,CAAC;AATD,sCASC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,UAAU,CACxB,KAAc,EACd,MAA4B,EAC5B,OAAgB;IAEhB,IAAA,oBAAM,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,gCAOC","sourcesContent":["import {\n Struct,\n assert,\n define,\n object as stObject,\n} from '@metamask/superstruct';\nimport type {\n Infer,\n Context,\n ObjectSchema,\n OmitBy,\n Optionalize,\n PickBy,\n Simplify,\n} from '@metamask/superstruct';\n\ndeclare const ExactOptionalSymbol: unique symbol;\n\nexport type ExactOptionalTag = {\n type: typeof ExactOptionalSymbol;\n};\n\n/**\n * Exclude type `Type` from the properties of `Obj`.\n *\n * ```ts\n * type Foo = { a: string | null; b: number };\n * type Bar = ExcludeType<Foo, null>;\n * // Bar = { a: string, b: number }\n * ```\n */\nexport type ExcludeType<Obj, Type> = {\n [K in keyof Obj]: Exclude<Obj[K], Type>;\n};\n\n/**\n * Make optional all properties that have the `ExactOptionalTag` type.\n *\n * ```ts\n * type Foo = { a: string | ExactOptionalTag; b: number};\n * type Bar = ExactOptionalize<Foo>;\n * // Bar = { a?: string; b: number}\n * ```\n */\nexport type ExactOptionalize<Schema extends object> = OmitBy<\n Schema,\n ExactOptionalTag\n> &\n Partial<ExcludeType<PickBy<Schema, ExactOptionalTag>, ExactOptionalTag>>;\n\n/**\n * Infer a type from an superstruct object schema.\n */\nexport type ObjectType<Schema extends ObjectSchema> = Simplify<\n ExactOptionalize<Optionalize<{ [K in keyof Schema]: Infer<Schema[K]> }>>\n>;\n\n/**\n * Change the return type of a superstruct object struct to support exact\n * optional properties.\n *\n * @param schema - The object schema.\n * @returns A struct representing an object with a known set of properties.\n */\nexport function object<Schema extends ObjectSchema>(\n schema: Schema,\n): Struct<ObjectType<Schema>, Schema> {\n return stObject(schema) as any;\n}\n\n/**\n * Check if the current property is present in its parent object.\n *\n * @param ctx - The context to check.\n * @returns `true` if the property is present, `false` otherwise.\n */\nfunction hasOptional(ctx: Context): boolean {\n const property: string = ctx.path[ctx.path.length - 1];\n const parent: Record<string, unknown> = ctx.branch[ctx.branch.length - 2];\n\n return property in parent;\n}\n\n/**\n * Augment a struct to allow exact-optional values. Exact-optional values can\n * be omitted but cannot be `undefined`.\n *\n * ```ts\n * const foo = object({ bar: exactOptional(string()) });\n * type Foo = Infer<typeof foo>;\n * // Foo = { bar?: string }\n * ```\n *\n * @param struct - The struct to augment.\n * @returns The augmented struct.\n */\nexport function exactOptional<Type, Schema>(\n struct: Struct<Type, Schema>,\n): Struct<Type | ExactOptionalTag, Schema> {\n return new Struct({\n ...struct,\n\n validator: (value, ctx) =>\n !hasOptional(ctx) || struct.validator(value, ctx),\n\n refiner: (value, ctx) =>\n !hasOptional(ctx) || struct.refiner(value as Type, ctx),\n });\n}\n\n/**\n * Defines a new string-struct matching a regular expression.\n *\n * Example:\n *\n * ```ts\n * const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu);\n * ```\n *\n * @param name - Type name.\n * @param pattern - Regular expression to match.\n * @returns A new string-struct that matches the given pattern.\n */\nexport function definePattern(\n name: string,\n pattern: RegExp,\n): Struct<string, null> {\n return define<string>(\n name,\n (value: unknown): boolean =>\n typeof value === 'string' && pattern.test(value),\n );\n}\n\n/**\n * Assert that a value is valid according to a struct.\n *\n * It is similar to superstruct's mask function, but it does not ignore extra\n * properties.\n *\n * @param value - Value to check.\n * @param struct - Struct to validate the value against.\n * @param message - Error message to throw if the value is not valid.\n * @returns The value if it is valid.\n */\nexport function strictMask<Type, Schema>(\n value: unknown,\n struct: Struct<Type, Schema>,\n message?: string,\n): Type {\n assert(value, struct, message);\n return value;\n}\n"]}
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './typing';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = 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);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./typing"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB","sourcesContent":["export * from './types';\nexport * from './typing';\n"]}
@@ -1,17 +0,0 @@
1
- import { type Infer } from '@metamask/superstruct';
2
- /**
3
- * UUIDv4 struct.
4
- */
5
- export declare const UuidStruct: import("@metamask/superstruct").Struct<string, null>;
6
- /**
7
- * Validates if a given value is a valid URL.
8
- *
9
- * @param value - The value to be validated.
10
- * @returns A boolean indicating if the value is a valid URL.
11
- */
12
- export declare const UrlStruct: import("@metamask/superstruct").Struct<string, null>;
13
- /**
14
- * A string which contains a positive float number.
15
- */
16
- export declare const StringNumberStruct: import("@metamask/superstruct").Struct<string, null>;
17
- export declare type StringNumber = Infer<typeof StringNumberStruct>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringNumberStruct = exports.UrlStruct = exports.UuidStruct = void 0;
4
- const superstruct_1 = require("@metamask/superstruct");
5
- const superstruct_2 = require("../superstruct");
6
- /**
7
- * UUIDv4 struct.
8
- */
9
- exports.UuidStruct = (0, superstruct_2.definePattern)('UuidV4', /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu);
10
- /**
11
- * Validates if a given value is a valid URL.
12
- *
13
- * @param value - The value to be validated.
14
- * @returns A boolean indicating if the value is a valid URL.
15
- */
16
- exports.UrlStruct = (0, superstruct_1.define)('Url', (value) => {
17
- try {
18
- const url = new URL(value);
19
- return url.protocol === 'http:' || url.protocol === 'https:';
20
- }
21
- catch (_) {
22
- return false;
23
- }
24
- });
25
- /**
26
- * A string which contains a positive float number.
27
- */
28
- exports.StringNumberStruct = (0, superstruct_2.definePattern)('StringNumber', /^\d+(\.\d+)?$/u);
29
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":";;;AAAA,uDAA2D;AAE3D,gDAA+C;AAE/C;;GAEG;AACU,QAAA,UAAU,GAAG,IAAA,2BAAa,EACrC,QAAQ,EACR,yEAAyE,CAC1E,CAAC;AAEF;;;;;GAKG;AACU,QAAA,SAAS,GAAG,IAAA,oBAAM,EAAS,KAAK,EAAE,CAAC,KAAc,EAAE,EAAE;IAChE,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAC;QACrC,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;KAC9D;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAA,2BAAa,EAC7C,cAAc,EACd,gBAAgB,CACjB,CAAC","sourcesContent":["import { define, type Infer } from '@metamask/superstruct';\n\nimport { definePattern } from '../superstruct';\n\n/**\n * UUIDv4 struct.\n */\nexport const UuidStruct = definePattern(\n 'UuidV4',\n /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,\n);\n\n/**\n * Validates if a given value is a valid URL.\n *\n * @param value - The value to be validated.\n * @returns A boolean indicating if the value is a valid URL.\n */\nexport const UrlStruct = define<string>('Url', (value: unknown) => {\n try {\n const url = new URL(value as string);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch (_) {\n return false;\n }\n});\n\n/**\n * A string which contains a positive float number.\n */\nexport const StringNumberStruct = definePattern(\n 'StringNumber',\n /^\\d+(\\.\\d+)?$/u,\n);\nexport type StringNumber = Infer<typeof StringNumberStruct>;\n"]}
@@ -1,32 +0,0 @@
1
- /**
2
- * Omit keys from a union type.
3
- *
4
- * The normal `Omit` type does not distribute over unions. So we use this
5
- * workaround that applies `Omit` to each member of the union.
6
- *
7
- * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>
8
- */
9
- export declare type OmitUnion<Type, Key extends keyof any> = Type extends any ? Omit<Type, Key> : never;
10
- /**
11
- * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.
12
- *
13
- * @example
14
- * ```ts
15
- * type A = Extends<{a: string, b: string}, {a: string}>; // true
16
- * type B = Extends<{a: string}, {a: string, b: string}>; // false
17
- * ```
18
- */
19
- export declare type Extends<Child, Base> = Child extends Base ? true : false;
20
- /**
21
- * Assert that a type extends `true`. It can be used, for example, to assert
22
- * that a given type extends another type.
23
- *
24
- * @example
25
- * ```ts
26
- * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok
27
- * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error
28
- * ```
29
- *
30
- * This function follows the naming pattern used on `tsd`.
31
- */
32
- export declare function expectTrue<Type extends true>(): void;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expectTrue = void 0;
4
- /**
5
- * Assert that a type extends `true`. It can be used, for example, to assert
6
- * that a given type extends another type.
7
- *
8
- * @example
9
- * ```ts
10
- * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok
11
- * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error
12
- * ```
13
- *
14
- * This function follows the naming pattern used on `tsd`.
15
- */
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- function expectTrue() {
18
- // Intentionally empty
19
- }
20
- exports.expectTrue = expectTrue;
21
- //# sourceMappingURL=typing.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typing.js","sourceRoot":"","sources":["../../src/utils/typing.ts"],"names":[],"mappings":";;;AAuBA;;;;;;;;;;;GAWG;AACH,6DAA6D;AAC7D,SAAgB,UAAU;IACxB,sBAAsB;AACxB,CAAC;AAFD,gCAEC","sourcesContent":["/**\n * Omit keys from a union type.\n *\n * The normal `Omit` type does not distribute over unions. So we use this\n * workaround that applies `Omit` to each member of the union.\n *\n * See: <https://github.com/microsoft/TypeScript/issues/31501#issuecomment-1280579305>\n */\nexport type OmitUnion<Type, Key extends keyof any> = Type extends any\n ? Omit<Type, Key>\n : never;\n\n/**\n * Type that resolves to `true` if `Child` extends `Base`, otherwise `false`.\n *\n * @example\n * ```ts\n * type A = Extends<{a: string, b: string}, {a: string}>; // true\n * type B = Extends<{a: string}, {a: string, b: string}>; // false\n * ```\n */\nexport type Extends<Child, Base> = Child extends Base ? true : false;\n\n/**\n * Assert that a type extends `true`. It can be used, for example, to assert\n * that a given type extends another type.\n *\n * @example\n * ```ts\n * expectTrue<Extends<{a: string, b: string}, {a: string}>>(); // Ok\n * expectTrue<Extends<{a: string}, {a: string, b: string}>>(); // Error\n * ```\n *\n * This function follows the naming pattern used on `tsd`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function expectTrue<Type extends true>(): void {\n // Intentionally empty\n}\n"]}