@metamask/smart-accounts-kit 1.1.0 → 1.3.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/README.md +34 -2
  3. package/dist/actions/index.cjs +5 -5
  4. package/dist/actions/index.d.cts +2 -2
  5. package/dist/actions/index.d.ts +2 -2
  6. package/dist/actions/index.mjs +4 -4
  7. package/dist/{smartAccountsEnvironment-BIcho7e0.d.cts → caveats-CQbtzOKm.d.ts} +9 -2
  8. package/dist/{smartAccountsEnvironment-Bso0CIWt.d.ts → caveats-Cey0wm33.d.cts} +9 -2
  9. package/dist/{chunk-YSBBRLMT.mjs → chunk-26PADMXR.mjs} +5 -5
  10. package/dist/{chunk-BYWRJGSK.cjs → chunk-3PBVHNYP.cjs} +16 -16
  11. package/dist/{chunk-BYWRJGSK.cjs.map → chunk-3PBVHNYP.cjs.map} +1 -1
  12. package/dist/{chunk-TPBFVDVM.mjs → chunk-4QXIOE7F.mjs} +8 -6
  13. package/dist/chunk-4QXIOE7F.mjs.map +1 -0
  14. package/dist/{chunk-F2RG26RH.cjs → chunk-57I2FJY7.cjs} +105 -105
  15. package/dist/{chunk-F2RG26RH.cjs.map → chunk-57I2FJY7.cjs.map} +1 -1
  16. package/dist/{chunk-YTELOQ4I.mjs → chunk-AC2BQSYP.mjs} +2 -2
  17. package/dist/{chunk-QMRKCB7T.cjs → chunk-AJWMPR7X.cjs} +146 -48
  18. package/dist/chunk-AJWMPR7X.cjs.map +1 -0
  19. package/dist/{chunk-23YXLKTX.cjs → chunk-DLCTHNAE.cjs} +14 -14
  20. package/dist/{chunk-23YXLKTX.cjs.map → chunk-DLCTHNAE.cjs.map} +1 -1
  21. package/dist/{chunk-NOCLGZGB.mjs → chunk-FKI4OME5.mjs} +109 -11
  22. package/dist/chunk-FKI4OME5.mjs.map +1 -0
  23. package/dist/{chunk-UUOH2WAW.cjs → chunk-GZ7HHI2D.cjs} +12 -12
  24. package/dist/{chunk-UUOH2WAW.cjs.map → chunk-GZ7HHI2D.cjs.map} +1 -1
  25. package/dist/{chunk-WV2R7BXP.mjs → chunk-KBSFVKUB.mjs} +3 -3
  26. package/dist/{chunk-45GHWVQA.mjs → chunk-LQXOM3TA.mjs} +4 -4
  27. package/dist/{chunk-VLKX4BR6.cjs → chunk-MOHCTPYQ.cjs} +8 -6
  28. package/dist/chunk-MOHCTPYQ.cjs.map +1 -0
  29. package/dist/{chunk-YDLLC6PP.cjs → chunk-SZOX7K2V.cjs} +519 -16
  30. package/dist/chunk-SZOX7K2V.cjs.map +1 -0
  31. package/dist/{chunk-C5ZEEH2Z.mjs → chunk-Z4D7ZWVB.mjs} +517 -14
  32. package/dist/chunk-Z4D7ZWVB.mjs.map +1 -0
  33. package/dist/contracts/index.cjs +6 -6
  34. package/dist/contracts/index.d.cts +2 -2
  35. package/dist/contracts/index.d.ts +2 -2
  36. package/dist/contracts/index.mjs +5 -5
  37. package/dist/{delegation-DgmIOh21.d.ts → delegation-Bx4FEAIU.d.ts} +1 -1
  38. package/dist/{delegation-Ci3me5Rg.d.cts → delegation-KbWHzRxV.d.cts} +1 -1
  39. package/dist/experimental/index.cjs +36 -4
  40. package/dist/experimental/index.cjs.map +1 -1
  41. package/dist/experimental/index.d.cts +4 -1
  42. package/dist/experimental/index.d.ts +4 -1
  43. package/dist/experimental/index.mjs +35 -3
  44. package/dist/experimental/index.mjs.map +1 -1
  45. package/dist/{index-Uj_xXVko.d.cts → index-BDC55AA9.d.cts} +5 -3
  46. package/dist/{index-UF6eCzBC.d.ts → index-D2THBlfm.d.ts} +1 -1
  47. package/dist/{index-CSjEW7MJ.d.cts → index-DE87r5KY.d.cts} +1 -1
  48. package/dist/{index-D7fBuNV-.d.ts → index-DhG2lH80.d.ts} +5 -3
  49. package/dist/index.cjs +33 -17
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +9 -11
  52. package/dist/index.d.ts +9 -11
  53. package/dist/index.mjs +24 -8
  54. package/dist/index.mjs.map +1 -1
  55. package/dist/utils/index.cjs +7 -5
  56. package/dist/utils/index.cjs.map +1 -1
  57. package/dist/utils/index.d.cts +2 -2
  58. package/dist/utils/index.d.ts +2 -2
  59. package/dist/utils/index.mjs +6 -4
  60. package/package.json +5 -4
  61. package/dist/chunk-C5ZEEH2Z.mjs.map +0 -1
  62. package/dist/chunk-NOCLGZGB.mjs.map +0 -1
  63. package/dist/chunk-QMRKCB7T.cjs.map +0 -1
  64. package/dist/chunk-TPBFVDVM.mjs.map +0 -1
  65. package/dist/chunk-VLKX4BR6.cjs.map +0 -1
  66. package/dist/chunk-YDLLC6PP.cjs.map +0 -1
  67. /package/dist/{chunk-YSBBRLMT.mjs.map → chunk-26PADMXR.mjs.map} +0 -0
  68. /package/dist/{chunk-YTELOQ4I.mjs.map → chunk-AC2BQSYP.mjs.map} +0 -0
  69. /package/dist/{chunk-WV2R7BXP.mjs.map → chunk-KBSFVKUB.mjs.map} +0 -0
  70. /package/dist/{chunk-45GHWVQA.mjs.map → chunk-LQXOM3TA.mjs.map} +0 -0
@@ -1,9 +1,20 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkYDLLC6PPcjs = require('../chunk-YDLLC6PP.cjs');
3
+
4
+ var _chunkSZOX7K2Vcjs = require('../chunk-SZOX7K2V.cjs');
4
5
 
5
6
  // src/experimental/delegationStorage.ts
6
7
  var _viem = require('viem');
8
+ var DelegationStorageEnvironment = {
9
+ dev: { apiUrl: "https://passkeys.dev-api.cx.metamask.io" },
10
+ prod: { apiUrl: "https://passkeys.api.cx.metamask.io" }
11
+ };
12
+ function getDelegationStorageEnvironment(apiUrl) {
13
+ const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(
14
+ ([_, env]) => env.apiUrl === apiUrl
15
+ );
16
+ return matchingEnvironment ? matchingEnvironment[0] : "custom";
17
+ }
7
18
  var DelegationStorageClient = class {
8
19
  #apiVersionPrefix = "api/v0";
9
20
  #config;
@@ -11,6 +22,12 @@ var DelegationStorageClient = class {
11
22
  #apiUrl;
12
23
  constructor(config) {
13
24
  const { apiUrl } = config.environment;
25
+ _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
26
+ "experimental.DelegationStorageClient.constructor",
27
+ {
28
+ environment: getDelegationStorageEnvironment(apiUrl)
29
+ }
30
+ );
14
31
  if (apiUrl.endsWith(this.#apiVersionPrefix)) {
15
32
  this.#apiUrl = apiUrl;
16
33
  } else {
@@ -51,7 +68,13 @@ var DelegationStorageClient = class {
51
68
  * is not found.
52
69
  */
53
70
  async getDelegationChain(leafDelegationOrDelegationHash) {
54
- const leafDelegationHash = typeof leafDelegationOrDelegationHash === "string" ? leafDelegationOrDelegationHash : _chunkYDLLC6PPcjs.hashDelegation.call(void 0, leafDelegationOrDelegationHash);
71
+ _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
72
+ "experimental.DelegationStorageClient.getDelegationChain",
73
+ {
74
+ inputKind: typeof leafDelegationOrDelegationHash === "string" ? "hash" : "delegation"
75
+ }
76
+ );
77
+ const leafDelegationHash = typeof leafDelegationOrDelegationHash === "string" ? leafDelegationOrDelegationHash : _chunkSZOX7K2Vcjs.hashDelegation.call(void 0, leafDelegationOrDelegationHash);
55
78
  const response = await this.#fetcher(
56
79
  `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,
57
80
  {
@@ -81,6 +104,10 @@ var DelegationStorageClient = class {
81
104
  * empty array if the delegations are not found.
82
105
  */
83
106
  async fetchDelegations(deleGatorAddress, filterMode = "RECEIVED" /* Received */) {
107
+ _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
108
+ "experimental.DelegationStorageClient.fetchDelegations",
109
+ { filterMode }
110
+ );
84
111
  const response = await this.#fetcher(
85
112
  `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,
86
113
  {
@@ -104,10 +131,14 @@ var DelegationStorageClient = class {
104
131
  * @returns A promise that resolves to the delegation hash indicating successful storage.
105
132
  */
106
133
  async storeDelegation(delegation) {
134
+ _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0,
135
+ "experimental.DelegationStorageClient.storeDelegation",
136
+ { caveatCount: delegation.caveats.length }
137
+ );
107
138
  if (!delegation.signature || delegation.signature === "0x") {
108
139
  throw new Error("Delegation must be signed to be stored");
109
140
  }
110
- const delegationHash = _chunkYDLLC6PPcjs.hashDelegation.call(void 0, delegation);
141
+ const delegationHash = _chunkSZOX7K2Vcjs.hashDelegation.call(void 0, delegation);
111
142
  const body = JSON.stringify(
112
143
  {
113
144
  ...delegation,
@@ -139,5 +170,6 @@ var DelegationStorageClient = class {
139
170
  };
140
171
 
141
172
 
142
- exports.DelegationStorageClient = DelegationStorageClient;
173
+
174
+ exports.DelegationStorageClient = DelegationStorageClient; exports.DelegationStorageEnvironment = DelegationStorageEnvironment;
143
175
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/experimental/index.cjs","../../src/experimental/delegationStorage.ts"],"names":[],"mappings":"AAAA;AACE;AACF,yDAA8B;AAC9B;AACA;ACJA,4BAAgC;AA6CzB,IAAM,wBAAA,EAAN,MAA8B;AAAA,EAC1B,CAAA,iBAAA,EAAoB,QAAA;AAAA,EAEpB,CAAA,MAAA;AAAA,EAEA,CAAA,OAAA;AAAA,EAEA,CAAA,MAAA;AAAA,E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,IAAA;AAEY,IAAA;AAChB,MAAA;AACK,QAAA;AACQ,QAAA;AACb,MAAA;AAEE,MAAA;AAGF,MAAA;AACF,IAAA;AAEiB,IAAA;AACP,MAAA;AACC,MAAA;AACP,QAAA;AACA,QAAA;AACA,QAAA;AACF,MAAA;AACA,MAAA;AACD,IAAA;AAEK,IAAA;AAGS,IAAA;AACG,MAAA;AAClB,IAAA;AAEiB,IAAA;AACL,MAAA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AAEO,IAAA;AACT,EAAA;AACF;ADzEsB;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/experimental/index.cjs","sourcesContent":[null,"import { type Hex, toHex } from 'viem';\n\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/experimental/index.cjs","../../src/experimental/delegationStorage.ts"],"names":[],"mappings":"AAAA;AACE;AACA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O,IAAA;AACT,EAAA;AACF;ADpFsB;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/experimental/index.cjs","sourcesContent":[null,"import { type Hex, toHex } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\n/**\n * Returns the DelegationStorageEnvironment ('dev' or 'prod') for a given apiUrl,\n * or 'custom' if the apiUrl does not match a known environment.\n *\n * @param apiUrl - The API URL to check.\n * @returns The environment key ('dev' or 'prod'), or 'custom'.\n */\nfunction getDelegationStorageEnvironment(\n apiUrl: string,\n): 'dev' | 'prod' | 'custom' {\n const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(\n ([_, env]) => env.apiUrl === apiUrl,\n ) as [keyof typeof DelegationStorageEnvironment, Environment] | undefined;\n\n return matchingEnvironment ? matchingEnvironment[0] : 'custom';\n}\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.constructor',\n {\n environment: getDelegationStorageEnvironment(apiUrl),\n },\n );\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.getDelegationChain',\n {\n inputKind:\n typeof leafDelegationOrDelegationHash === 'string'\n ? 'hash'\n : 'delegation',\n },\n );\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.fetchDelegations',\n { filterMode },\n );\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.storeDelegation',\n { caveatCount: delegation.caveats.length },\n );\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n"]}
@@ -9,6 +9,9 @@ declare enum DelegationStoreFilter {
9
9
  Received = "RECEIVED",
10
10
  All = "ALL"
11
11
  }
12
+ declare const DelegationStorageEnvironment: {
13
+ [K in 'dev' | 'prod']: Environment;
14
+ };
12
15
  type Environment = {
13
16
  apiUrl: string;
14
17
  };
@@ -26,4 +29,4 @@ declare class DelegationStorageClient {
26
29
  storeDelegation(delegation: Delegation): Promise<Hex>;
27
30
  }
28
31
 
29
- export { DelegationStorageClient, type DelegationStorageConfig, DelegationStoreFilter, type Environment };
32
+ export { DelegationStorageClient, type DelegationStorageConfig, DelegationStorageEnvironment, DelegationStoreFilter, type Environment };
@@ -9,6 +9,9 @@ declare enum DelegationStoreFilter {
9
9
  Received = "RECEIVED",
10
10
  All = "ALL"
11
11
  }
12
+ declare const DelegationStorageEnvironment: {
13
+ [K in 'dev' | 'prod']: Environment;
14
+ };
12
15
  type Environment = {
13
16
  apiUrl: string;
14
17
  };
@@ -26,4 +29,4 @@ declare class DelegationStorageClient {
26
29
  storeDelegation(delegation: Delegation): Promise<Hex>;
27
30
  }
28
31
 
29
- export { DelegationStorageClient, type DelegationStorageConfig, DelegationStoreFilter, type Environment };
32
+ export { DelegationStorageClient, type DelegationStorageConfig, DelegationStorageEnvironment, DelegationStoreFilter, type Environment };
@@ -1,9 +1,20 @@
1
1
  import {
2
- hashDelegation
3
- } from "../chunk-C5ZEEH2Z.mjs";
2
+ hashDelegation,
3
+ trackSmartAccountsKitFunctionCall
4
+ } from "../chunk-Z4D7ZWVB.mjs";
4
5
 
5
6
  // src/experimental/delegationStorage.ts
6
7
  import { toHex } from "viem";
8
+ var DelegationStorageEnvironment = {
9
+ dev: { apiUrl: "https://passkeys.dev-api.cx.metamask.io" },
10
+ prod: { apiUrl: "https://passkeys.api.cx.metamask.io" }
11
+ };
12
+ function getDelegationStorageEnvironment(apiUrl) {
13
+ const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(
14
+ ([_, env]) => env.apiUrl === apiUrl
15
+ );
16
+ return matchingEnvironment ? matchingEnvironment[0] : "custom";
17
+ }
7
18
  var DelegationStorageClient = class {
8
19
  #apiVersionPrefix = "api/v0";
9
20
  #config;
@@ -11,6 +22,12 @@ var DelegationStorageClient = class {
11
22
  #apiUrl;
12
23
  constructor(config) {
13
24
  const { apiUrl } = config.environment;
25
+ trackSmartAccountsKitFunctionCall(
26
+ "experimental.DelegationStorageClient.constructor",
27
+ {
28
+ environment: getDelegationStorageEnvironment(apiUrl)
29
+ }
30
+ );
14
31
  if (apiUrl.endsWith(this.#apiVersionPrefix)) {
15
32
  this.#apiUrl = apiUrl;
16
33
  } else {
@@ -51,6 +68,12 @@ var DelegationStorageClient = class {
51
68
  * is not found.
52
69
  */
53
70
  async getDelegationChain(leafDelegationOrDelegationHash) {
71
+ trackSmartAccountsKitFunctionCall(
72
+ "experimental.DelegationStorageClient.getDelegationChain",
73
+ {
74
+ inputKind: typeof leafDelegationOrDelegationHash === "string" ? "hash" : "delegation"
75
+ }
76
+ );
54
77
  const leafDelegationHash = typeof leafDelegationOrDelegationHash === "string" ? leafDelegationOrDelegationHash : hashDelegation(leafDelegationOrDelegationHash);
55
78
  const response = await this.#fetcher(
56
79
  `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,
@@ -81,6 +104,10 @@ var DelegationStorageClient = class {
81
104
  * empty array if the delegations are not found.
82
105
  */
83
106
  async fetchDelegations(deleGatorAddress, filterMode = "RECEIVED" /* Received */) {
107
+ trackSmartAccountsKitFunctionCall(
108
+ "experimental.DelegationStorageClient.fetchDelegations",
109
+ { filterMode }
110
+ );
84
111
  const response = await this.#fetcher(
85
112
  `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,
86
113
  {
@@ -104,6 +131,10 @@ var DelegationStorageClient = class {
104
131
  * @returns A promise that resolves to the delegation hash indicating successful storage.
105
132
  */
106
133
  async storeDelegation(delegation) {
134
+ trackSmartAccountsKitFunctionCall(
135
+ "experimental.DelegationStorageClient.storeDelegation",
136
+ { caveatCount: delegation.caveats.length }
137
+ );
107
138
  if (!delegation.signature || delegation.signature === "0x") {
108
139
  throw new Error("Delegation must be signed to be stored");
109
140
  }
@@ -138,6 +169,7 @@ var DelegationStorageClient = class {
138
169
  }
139
170
  };
140
171
  export {
141
- DelegationStorageClient
172
+ DelegationStorageClient,
173
+ DelegationStorageEnvironment
142
174
  };
143
175
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/experimental/delegationStorage.ts"],"sourcesContent":["import { type Hex, toHex } from 'viem';\n\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n"],"mappings":";;;;;AAAA,SAAmB,aAAa;AA6CzB,IAAM,0BAAN,MAA8B;AAAA,EAC1B,oBAAoB;AAAA,EAEpB;AAAA,EAEA;AAAA,EAEA;AAAA,EAET,YAAY,QAAiC;AAC3C,UAAM,EAAE,OAAO,IAAI,OAAO;AAE1B,QAAI,OAAO,SAAS,KAAK,iBAAiB,GAAG;AAC3C,WAAK,UAAU;AAAA,IACjB,OAAO;AACL,YAAM,YAAY,OAAO,SAAS,GAAG,IAAI,KAAK;AAC9C,WAAK,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,iBAAiB;AAAA,IAC/D;AACA,SAAK,WAAW,KAAK,mBAAmB,MAAM;AAC9C,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,mBAAmB,QAA+C;AAChE,QAAI,OAAO,SAAS;AAClB,aAAO,OAAO;AAAA,IAChB,WAAW,OAAO,YAAY,UAAU,YAAY;AAClD,aAAO,WAAW,MAAM,KAAK,UAAU;AAAA,IACzC;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,mBACJ,gCACuB;AACvB,UAAM,qBACJ,OAAO,mCAAmC,WACtC,iCACA,eAAe,8BAA8B;AAEnD,UAAM,WAAW,MAAM,KAAK;AAAA,MAC1B,GAAG,KAAK,OAAO,qBAAqB,kBAAkB;AAAA,MACtD;AAAA,QACE,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,eAAe,UAAU,KAAK,QAAQ,MAAM;AAAA,UAC5C,gBAAgB,KAAK,QAAQ;AAAA,QAC/B;AAAA,MACF;AAAA,IACF;AAEA,UAAM,eAA6C,MAAM,SAAS,KA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,MACA;AAAA,IACF,CAAC;AAED,UAAM,eACJ,MAAM,SAAS,KAAK;AAEtB,QAAI,WAAW,cAAc;AAC3B,YAAM,IAAI,MAAM,aAAa,KAAK;AAAA,IACpC;AAEA,QAAI,aAAa,mBAAmB,gBAAgB;AAClD,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,aAAa;AAAA,EACtB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/experimental/delegationStorage.ts"],"sourcesContent":["import { type Hex, toHex } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport { hashDelegation } from '../delegation';\nimport type { Delegation } from '../types';\n\ntype ErrorResponse = {\n error: string;\n data?: any;\n};\n\nexport type APIStoreDelegationResponse = {\n delegationHash: Hex;\n};\n\n/**\n * Represents the allowed filters when querying the data store for delegations.\n */\nexport enum DelegationStoreFilter {\n Given = 'GIVEN',\n Received = 'RECEIVED',\n All = 'ALL',\n}\n\n/**\n * Public Delegation Storage Service environments. To be used in the\n * DeleGationStorageService config.\n */\nexport const DelegationStorageEnvironment: {\n [K in 'dev' | 'prod']: Environment;\n} = {\n dev: { apiUrl: 'https://passkeys.dev-api.cx.metamask.io' },\n prod: { apiUrl: 'https://passkeys.api.cx.metamask.io' },\n};\n\n/**\n * Returns the DelegationStorageEnvironment ('dev' or 'prod') for a given apiUrl,\n * or 'custom' if the apiUrl does not match a known environment.\n *\n * @param apiUrl - The API URL to check.\n * @returns The environment key ('dev' or 'prod'), or 'custom'.\n */\nfunction getDelegationStorageEnvironment(\n apiUrl: string,\n): 'dev' | 'prod' | 'custom' {\n const matchingEnvironment = Object.entries(DelegationStorageEnvironment).find(\n ([_, env]) => env.apiUrl === apiUrl,\n ) as [keyof typeof DelegationStorageEnvironment, Environment] | undefined;\n\n return matchingEnvironment ? matchingEnvironment[0] : 'custom';\n}\n\nexport type Environment = {\n apiUrl: string;\n};\n\nexport type DelegationStorageConfig = {\n apiKey: string;\n apiKeyId: string;\n environment: Environment;\n fetcher?: typeof fetch;\n};\n\nexport class DelegationStorageClient {\n readonly #apiVersionPrefix = 'api/v0';\n\n readonly #config: DelegationStorageConfig;\n\n readonly #fetcher: typeof fetch;\n\n readonly #apiUrl: string;\n\n constructor(config: DelegationStorageConfig) {\n const { apiUrl } = config.environment;\n\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.constructor',\n {\n environment: getDelegationStorageEnvironment(apiUrl),\n },\n );\n\n if (apiUrl.endsWith(this.#apiVersionPrefix)) {\n this.#apiUrl = apiUrl;\n } else {\n const separator = apiUrl.endsWith('/') ? '' : '/';\n this.#apiUrl = `${apiUrl}${separator}${this.#apiVersionPrefix}`;\n }\n this.#fetcher = this.#initializeFetcher(config);\n this.#config = config;\n }\n\n /**\n * Initializes the fetch function for HTTP requests.\n *\n * - Uses `config.fetcher` if provided.\n * - Falls back to global `fetch` if available.\n * - Throws an error if no fetch function is available.\n *\n * @param config - Configuration object that may include a custom fetch function.\n * @returns The fetch function to be used for HTTP requests.\n * @throws Error if no fetch function is available in the environment.\n */\n #initializeFetcher(config: DelegationStorageConfig): typeof fetch {\n if (config.fetcher) {\n return config.fetcher;\n } else if (typeof globalThis?.fetch === 'function') {\n return globalThis.fetch.bind(globalThis);\n }\n throw new Error(\n 'Fetch API is not available in this environment. Please provide a fetch function in the config.',\n );\n }\n\n /**\n * Fetches the delegation chain from the Delegation Storage Service, ending with\n * the specified leaf delegation.\n *\n * @param leafDelegationOrDelegationHash - The leaf delegation, or the hash\n * of the leaf delegation.\n * @returns A promise that resolves to the delegation chain - empty array if the delegation\n * is not found.\n */\n async getDelegationChain(\n leafDelegationOrDelegationHash: Hex | Delegation,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.getDelegationChain',\n {\n inputKind:\n typeof leafDelegationOrDelegationHash === 'string'\n ? 'hash'\n : 'delegation',\n },\n );\n const leafDelegationHash =\n typeof leafDelegationOrDelegationHash === 'string'\n ? leafDelegationOrDelegationHash\n : hashDelegation(leafDelegationOrDelegationHash);\n\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/chain/${leafDelegationHash}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(\n `Failed to fetch delegation chain: ${responseData.error}`,\n );\n }\n\n return responseData;\n }\n\n /**\n * Fetches the delegations from the Delegation Storage Service, either `Received`\n * by, or `Given` by, (or both: `All`) the specified deleGatorAddress. Defaults\n * to `Received`.\n *\n * @param deleGatorAddress - The deleGatorAddress to retrieve the delegations for.\n * @param filterMode - The DelegationStoreFilter mode - defaults to Received.\n * @returns A promise that resolves to the list of delegations received by the deleGatorAddress,\n * empty array if the delegations are not found.\n */\n async fetchDelegations(\n deleGatorAddress: Hex,\n filterMode = DelegationStoreFilter.Received,\n ): Promise<Delegation[]> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.fetchDelegations',\n { filterMode },\n );\n const response = await this.#fetcher(\n `${this.#apiUrl}/delegation/accounts/${deleGatorAddress}?filter=${filterMode}`,\n {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n },\n },\n );\n\n const responseData: Delegation[] | ErrorResponse = await response.json();\n\n if ('error' in responseData) {\n throw new Error(`Failed to fetch delegations: ${responseData.error}`);\n }\n\n return responseData;\n }\n\n /**\n * Stores the specified delegation in the Delegation Storage Service.\n *\n * @param delegation - The delegation to store.\n * @returns A promise that resolves to the delegation hash indicating successful storage.\n */\n async storeDelegation(delegation: Delegation): Promise<Hex> {\n trackSmartAccountsKitFunctionCall(\n 'experimental.DelegationStorageClient.storeDelegation',\n { caveatCount: delegation.caveats.length },\n );\n if (!delegation.signature || delegation.signature === '0x') {\n throw new Error('Delegation must be signed to be stored');\n }\n\n const delegationHash = hashDelegation(delegation);\n\n const body = JSON.stringify(\n {\n ...delegation,\n metadata: [],\n },\n (_, value: any) =>\n typeof value === 'bigint' || typeof value === 'number'\n ? toHex(value)\n : value,\n 2,\n );\n\n const response = await this.#fetcher(`${this.#apiUrl}/delegation/store`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.#config.apiKey}`,\n 'x-api-key-id': this.#config.apiKeyId,\n 'Content-Type': 'application/json',\n },\n body,\n });\n\n const responseData: APIStoreDelegationResponse | ErrorResponse =\n await response.json();\n\n if ('error' in responseData) {\n throw new Error(responseData.error);\n }\n\n if (responseData.delegationHash !== delegationHash) {\n throw new Error(\n 'Failed to store the Delegation, the hash returned from the MM delegation storage API does not match the hash of the delegation',\n );\n }\n\n return responseData.delegationHash;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAmB,aAAa;AA4BzB,IAAM,+BAET;AAAA,EACF,KAAK,EAAE,QAAQ,0CAA0C;AAAA,EACzD,MAAM,EAAE,QAAQ,sCAAsC;AACxD;AASA,SAAS,gCACP,QAC2B;AAC3B,QAAM,sBAAsB,OAAO,QAAQ,4BAA4B,EAAE;AAAA,IACvE,CAAC,CAAC,GAAG,GAAG,MAAM,IAAI,WAAW;AAAA,EAC/B;AAEA,SAAO,sBAAsB,oBAAoB,CAAC,IAAI;AACxD;AAaO,IAAM,0BAAN,MAA8B;AAAA,EAC1B,oBAAoB;AAAA,EAEpB;AAAA,EAEA;AAAA,EAEA;AAAA,EAET,YAAY,QAAiC;AAC3C,UAAM,EAAE,OAAO,IAAI,OAAO;AAE1B;AAAA,MACE;AAAA,MACA;AAAA,QACE,aAAa,gCAAgC,MAAM;AAAA,MACrD;AAAA,IACF;AAEA,QAAI,OAAO,SAAS,KAAK,iBAAiB,GAAG;AAC3C,WAAK,UAAU;AAAA,IACjB,OAAO;AACL,YAAM,YAAY,OAAO,SAAS,GAAG,IAAI,KAAK;AAC9C,WAAK,UAAU,GAAG,MAAM,GAAG,SA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,WAAO,aAAa;AAAA,EACtB;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import { PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
1
+ import { Rule, PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
2
2
  import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, OneOf, PublicClient, SendTransactionRequest, SendTransactionParameters, WalletClient } from 'viem';
3
3
  import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
4
4
  import { l as Call, P as PermissionContext, S as SmartAccountsEnvironment, D as Delegation } from './types-BWaH4KH1.cjs';
@@ -62,6 +62,7 @@ type PermissionRequestParameter = {
62
62
  to: Hex;
63
63
  from?: Address | undefined | null;
64
64
  expiry?: number | undefined | null;
65
+ redeemer?: readonly Address[] | undefined | null;
65
66
  };
66
67
  type SupportedPermissionInfo = {
67
68
  chainIds: number[];
@@ -74,7 +75,7 @@ type PermissionRequest<TPermission extends PermissionTypes> = {
74
75
  from?: Hex;
75
76
  to: Hex;
76
77
  permission: TPermission;
77
- rules?: Record<string, unknown>[] | null;
78
+ rules?: Rule[] | null;
78
79
  };
79
80
  type PermissionResponse<TPermission extends PermissionTypes> = PermissionRequest<TPermission> & {
80
81
  context: Hex;
@@ -244,6 +245,7 @@ type index_RequestExecutionPermissionsReturnType = RequestExecutionPermissionsRe
244
245
  type index_RpcGetGrantedExecutionPermissionsResult = RpcGetGrantedExecutionPermissionsResult;
245
246
  type index_RpcGetSupportedExecutionPermissionsResult = RpcGetSupportedExecutionPermissionsResult;
246
247
  type index_RpcSupportedPermissionInfo = RpcSupportedPermissionInfo;
248
+ declare const index_Rule: typeof Rule;
247
249
  type index_SignDelegationParameters = SignDelegationParameters;
248
250
  type index_SignDelegationReturnType = SignDelegationReturnType;
249
251
  type index_SignUserOperationParameters = SignUserOperationParameters;
@@ -265,7 +267,7 @@ declare const index_signDelegationActions: typeof signDelegationActions;
265
267
  declare const index_signUserOperation: typeof signUserOperation;
266
268
  declare const index_signUserOperationActions: typeof signUserOperationActions;
267
269
  declare namespace index {
268
- export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
270
+ export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, index_Rule as Rule, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
269
271
  }
270
272
 
271
273
  export { getNativeTokenPeriodTransferEnforcerAvailableAmount as A, getNativeTokenStreamingEnforcerAvailableAmount as B, type CaveatEnforcerParams as C, type DelegatedCall as D, type Erc20TokenPeriodicPermission as E, erc7715GetSupportedExecutionPermissionsAction as F, type GetGrantedExecutionPermissionsResult as G, isValid7702Implementation as H, erc7715RequestExecutionPermissionsAction as I, signDelegation as J, signDelegationActions as K, signUserOperation as L, type MetaMaskExtensionClient as M, type NativeTokenPeriodicPermission as N, signUserOperationActions as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type SignDelegationParameters as S, type Erc20TokenRevocationPermission as a, type Erc20TokenStreamPermission as b, caveatEnforcerActions as c, type Erc7715Client as d, type GetSupportedExecutionPermissionsResult as e, type MetaMaskExtensionSchema as f, type NativeTokenStreamPermission as g, type PermissionRequestParameter as h, index as i, type PermissionTypes as j, type RequestExecutionPermissionsReturnType as k, type RpcGetGrantedExecutionPermissionsResult as l, type RpcGetSupportedExecutionPermissionsResult as m, type RpcSupportedPermissionInfo as n, type SignDelegationReturnType as o, type SignUserOperationParameters as p, type SignUserOperationReturnType as q, type StreamingResult as r, type SupportedPermissionInfo as s, erc7710BundlerActions as t, erc7710WalletActions as u, erc7715ProviderActions as v, getErc20PeriodTransferEnforcerAvailableAmount as w, getErc20StreamingEnforcerAvailableAmount as x, erc7715GetGrantedExecutionPermissionsAction as y, getMultiTokenPeriodEnforcerAvailableAmount as z };
@@ -1,7 +1,7 @@
1
1
  import { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
2
2
  import * as viem from 'viem';
3
3
  import { Client, Transport, Chain, Account, Address, Hex } from 'viem';
4
- import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-DgmIOh21.js';
4
+ import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-Bx4FEAIU.js';
5
5
  import { D as Delegation, P as PermissionContext } from './types-BWaH4KH1.js';
6
6
 
7
7
  declare const NAME$1 = "DelegationManager";
@@ -1,7 +1,7 @@
1
1
  import { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
2
2
  import * as viem from 'viem';
3
3
  import { Client, Transport, Chain, Account, Address, Hex } from 'viem';
4
- import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-Ci3me5Rg.cjs';
4
+ import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-KbWHzRxV.cjs';
5
5
  import { D as Delegation, P as PermissionContext } from './types-BWaH4KH1.cjs';
6
6
 
7
7
  declare const NAME$1 = "DelegationManager";
@@ -1,4 +1,4 @@
1
- import { PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
1
+ import { Rule, PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
2
2
  import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, OneOf, PublicClient, SendTransactionRequest, SendTransactionParameters, WalletClient } from 'viem';
3
3
  import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
4
4
  import { l as Call, P as PermissionContext, S as SmartAccountsEnvironment, D as Delegation } from './types-BWaH4KH1.js';
@@ -62,6 +62,7 @@ type PermissionRequestParameter = {
62
62
  to: Hex;
63
63
  from?: Address | undefined | null;
64
64
  expiry?: number | undefined | null;
65
+ redeemer?: readonly Address[] | undefined | null;
65
66
  };
66
67
  type SupportedPermissionInfo = {
67
68
  chainIds: number[];
@@ -74,7 +75,7 @@ type PermissionRequest<TPermission extends PermissionTypes> = {
74
75
  from?: Hex;
75
76
  to: Hex;
76
77
  permission: TPermission;
77
- rules?: Record<string, unknown>[] | null;
78
+ rules?: Rule[] | null;
78
79
  };
79
80
  type PermissionResponse<TPermission extends PermissionTypes> = PermissionRequest<TPermission> & {
80
81
  context: Hex;
@@ -244,6 +245,7 @@ type index_RequestExecutionPermissionsReturnType = RequestExecutionPermissionsRe
244
245
  type index_RpcGetGrantedExecutionPermissionsResult = RpcGetGrantedExecutionPermissionsResult;
245
246
  type index_RpcGetSupportedExecutionPermissionsResult = RpcGetSupportedExecutionPermissionsResult;
246
247
  type index_RpcSupportedPermissionInfo = RpcSupportedPermissionInfo;
248
+ declare const index_Rule: typeof Rule;
247
249
  type index_SignDelegationParameters = SignDelegationParameters;
248
250
  type index_SignDelegationReturnType = SignDelegationReturnType;
249
251
  type index_SignUserOperationParameters = SignUserOperationParameters;
@@ -265,7 +267,7 @@ declare const index_signDelegationActions: typeof signDelegationActions;
265
267
  declare const index_signUserOperation: typeof signUserOperation;
266
268
  declare const index_signUserOperationActions: typeof signUserOperationActions;
267
269
  declare namespace index {
268
- export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
270
+ export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, index_Rule as Rule, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
269
271
  }
270
272
 
271
273
  export { getNativeTokenPeriodTransferEnforcerAvailableAmount as A, getNativeTokenStreamingEnforcerAvailableAmount as B, type CaveatEnforcerParams as C, type DelegatedCall as D, type Erc20TokenPeriodicPermission as E, erc7715GetSupportedExecutionPermissionsAction as F, type GetGrantedExecutionPermissionsResult as G, isValid7702Implementation as H, erc7715RequestExecutionPermissionsAction as I, signDelegation as J, signDelegationActions as K, signUserOperation as L, type MetaMaskExtensionClient as M, type NativeTokenPeriodicPermission as N, signUserOperationActions as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type SignDelegationParameters as S, type Erc20TokenRevocationPermission as a, type Erc20TokenStreamPermission as b, caveatEnforcerActions as c, type Erc7715Client as d, type GetSupportedExecutionPermissionsResult as e, type MetaMaskExtensionSchema as f, type NativeTokenStreamPermission as g, type PermissionRequestParameter as h, index as i, type PermissionTypes as j, type RequestExecutionPermissionsReturnType as k, type RpcGetGrantedExecutionPermissionsResult as l, type RpcGetSupportedExecutionPermissionsResult as m, type RpcSupportedPermissionInfo as n, type SignDelegationReturnType as o, type SignUserOperationParameters as p, type SignUserOperationReturnType as q, type StreamingResult as r, type SupportedPermissionInfo as s, erc7710BundlerActions as t, erc7710WalletActions as u, erc7715ProviderActions as v, getErc20PeriodTransferEnforcerAvailableAmount as w, getErc20StreamingEnforcerAvailableAmount as x, erc7715GetGrantedExecutionPermissionsAction as y, getMultiTokenPeriodEnforcerAvailableAmount as z };
package/dist/index.cjs CHANGED
@@ -1,29 +1,29 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
4
 
5
- var _chunkQMRKCB7Tcjs = require('./chunk-QMRKCB7T.cjs');
5
+ var _chunkAJWMPR7Xcjs = require('./chunk-AJWMPR7X.cjs');
6
6
 
7
7
 
8
- var _chunkF2RG26RHcjs = require('./chunk-F2RG26RH.cjs');
9
- require('./chunk-UUOH2WAW.cjs');
8
+ var _chunk57I2FJY7cjs = require('./chunk-57I2FJY7.cjs');
9
+ require('./chunk-GZ7HHI2D.cjs');
10
10
 
11
11
 
12
12
 
13
13
 
14
14
 
15
- var _chunkBYWRJGSKcjs = require('./chunk-BYWRJGSK.cjs');
15
+ var _chunk3PBVHNYPcjs = require('./chunk-3PBVHNYP.cjs');
16
16
 
17
17
 
18
18
 
19
19
 
20
20
 
21
21
  var _chunkSOFB2MXGcjs = require('./chunk-SOFB2MXG.cjs');
22
- require('./chunk-23YXLKTX.cjs');
22
+ require('./chunk-DLCTHNAE.cjs');
23
23
 
24
24
 
25
25
 
26
- var _chunkVLKX4BR6cjs = require('./chunk-VLKX4BR6.cjs');
26
+ var _chunkMOHCTPYQcjs = require('./chunk-MOHCTPYQ.cjs');
27
27
 
28
28
 
29
29
 
@@ -38,7 +38,8 @@ var _chunkVLKX4BR6cjs = require('./chunk-VLKX4BR6.cjs');
38
38
 
39
39
 
40
40
 
41
- var _chunkYDLLC6PPcjs = require('./chunk-YDLLC6PP.cjs');
41
+
42
+ var _chunkSZOX7K2Vcjs = require('./chunk-SZOX7K2V.cjs');
42
43
 
43
44
  // src/toMetaMaskSmartAccount.ts
44
45
 
@@ -61,6 +62,9 @@ var signatureTypes = ["ECDSA"];
61
62
  var aggregateSignature = ({
62
63
  signatures
63
64
  }) => {
65
+ _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0, "aggregateSignature", {
66
+ signatureCount: signatures.length
67
+ });
64
68
  if (signatures.length === 0) {
65
69
  return "0x";
66
70
  }
@@ -114,7 +118,7 @@ var resolveHybridSigner = (config) => {
114
118
  if (webAuthnAccount.type !== "webAuthn") {
115
119
  throw new Error("Account is not a webAuthn account");
116
120
  }
117
- const encodeSignature = (result) => _chunkBYWRJGSKcjs.encodeDeleGatorSignature.call(void 0,
121
+ const encodeSignature = (result) => _chunk3PBVHNYPcjs.encodeDeleGatorSignature.call(void 0,
118
122
  keyId,
119
123
  result.signature,
120
124
  result.webauthn.clientDataJSON,
@@ -122,7 +126,7 @@ var resolveHybridSigner = (config) => {
122
126
  );
123
127
  const signMessage = async (args) => webAuthnAccount.signMessage(args).then(encodeSignature);
124
128
  const signTypedData = async (typedDataDefinition) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);
125
- const getStubSignature = async () => _chunkBYWRJGSKcjs.createDummyWebAuthnSignature.call(void 0, keyId);
129
+ const getStubSignature = async () => _chunk3PBVHNYPcjs.createDummyWebAuthnSignature.call(void 0, keyId);
126
130
  return {
127
131
  signMessage,
128
132
  signTypedData,
@@ -233,6 +237,12 @@ async function toMetaMaskSmartAccount(params) {
233
237
  implementation,
234
238
  nonceKeyManager
235
239
  } = params;
240
+ _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0, "toMetaMaskSmartAccount", {
241
+ implementation,
242
+ hasAddress: params.address !== void 0,
243
+ hasEnvironment: params.environment !== void 0,
244
+ chainId: _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _ => _.id]), () => ( null))
245
+ });
236
246
  if (!chain) {
237
247
  throw new Error("Chain not specified");
238
248
  }
@@ -249,7 +259,7 @@ async function toMetaMaskSmartAccount(params) {
249
259
  if (implementation === "Stateless7702" /* Stateless7702 */) {
250
260
  throw new Error("Stateless7702 does not support counterfactual accounts");
251
261
  }
252
- const accountData = await _chunkBYWRJGSKcjs.getCounterfactualAccountData.call(void 0, {
262
+ const accountData = await _chunk3PBVHNYPcjs.getCounterfactualAccountData.call(void 0, {
253
263
  factory: environment.SimpleFactory,
254
264
  implementations: environment.implementations,
255
265
  implementation,
@@ -296,7 +306,7 @@ async function toMetaMaskSmartAccount(params) {
296
306
  );
297
307
  }
298
308
  const { delegation, chainId } = delegationParams;
299
- const delegationStruct = _chunkYDLLC6PPcjs.toDelegationStruct.call(void 0, {
309
+ const delegationStruct = _chunkSZOX7K2Vcjs.toDelegationStruct.call(void 0, {
300
310
  ...delegation,
301
311
  signature: "0x"
302
312
  });
@@ -307,7 +317,7 @@ async function toMetaMaskSmartAccount(params) {
307
317
  version: "1",
308
318
  verifyingContract: environment.DelegationManager
309
319
  },
310
- types: _chunkYDLLC6PPcjs.SIGNABLE_DELEGATION_TYPED_DATA,
320
+ types: _chunkSZOX7K2Vcjs.SIGNABLE_DELEGATION_TYPED_DATA,
311
321
  primaryType: "Delegation",
312
322
  message: delegationStruct
313
323
  });
@@ -339,7 +349,7 @@ async function toMetaMaskSmartAccount(params) {
339
349
  return signature;
340
350
  };
341
351
  const getAddress = async () => address;
342
- const encodeCalls = async (calls) => _chunkBYWRJGSKcjs.encodeCallsForCaller.call(void 0, address, calls);
352
+ const encodeCalls = async (calls) => _chunk3PBVHNYPcjs.encodeCallsForCaller.call(void 0, address, calls);
343
353
  const signerMethods = _nullishCoalesce(signer, () => ( {
344
354
  signMessage: async () => {
345
355
  throw new Error(
@@ -373,7 +383,7 @@ async function toMetaMaskSmartAccount(params) {
373
383
  if (implementation === "Stateless7702" /* Stateless7702 */) {
374
384
  return {
375
385
  ...smartAccount,
376
- isDeployed: async () => _chunkQMRKCB7Tcjs.isValid7702Implementation.call(void 0, {
386
+ isDeployed: async () => _chunkAJWMPR7Xcjs.isValid7702Implementation.call(void 0, {
377
387
  client,
378
388
  accountAddress: address,
379
389
  environment
@@ -388,7 +398,10 @@ function createCaveatEnforcerClient({
388
398
  client,
389
399
  environment
390
400
  }) {
391
- return client.extend(_chunkQMRKCB7Tcjs.caveatEnforcerActions.call(void 0, { environment }));
401
+ _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createCaveatEnforcerClient", {
402
+ chainId: _nullishCoalesce(_optionalChain([client, 'access', _2 => _2.chain, 'optionalAccess', _3 => _3.id]), () => ( null))
403
+ });
404
+ return client.extend(_chunkAJWMPR7Xcjs.caveatEnforcerActions.call(void 0, { environment }));
392
405
  }
393
406
 
394
407
  // src/actions/infuraBundlerClient.ts
@@ -416,6 +429,9 @@ var infuraBundlerActions = () => (client) => ({
416
429
  }
417
430
  });
418
431
  function createInfuraBundlerClient(config) {
432
+ _chunkSZOX7K2Vcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createInfuraBundlerClient", {
433
+ chainId: _nullishCoalesce(_optionalChain([config, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.id]), () => ( null))
434
+ });
419
435
  const baseBundlerClient = _accountabstraction.createBundlerClient.call(void 0, config);
420
436
  return baseBundlerClient.extend(
421
437
  infuraBundlerActions()
@@ -444,5 +460,5 @@ function createInfuraBundlerClient(config) {
444
460
 
445
461
 
446
462
 
447
- exports.ANY_BENEFICIARY = _chunkYDLLC6PPcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _chunkYDLLC6PPcjs.BalanceChangeType; exports.CaveatType = _chunkYDLLC6PPcjs.CaveatType; exports.ExecutionMode = _chunkVLKX4BR6cjs.ExecutionMode; exports.Implementation = _chunkYDLLC6PPcjs.Implementation; exports.PREFERRED_VERSION = _chunkSOFB2MXGcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkYDLLC6PPcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkYDLLC6PPcjs.ScopeType; exports.TransferWindow = _chunkYDLLC6PPcjs.TransferWindow; exports.actions = _chunkQMRKCB7Tcjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkF2RG26RHcjs.contracts_exports; exports.createCaveat = _chunkYDLLC6PPcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkYDLLC6PPcjs.createDelegation; exports.createExecution = _chunkVLKX4BR6cjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkYDLLC6PPcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkYDLLC6PPcjs.signDelegation; exports.signUserOperation = _chunkSOFB2MXGcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
463
+ exports.ANY_BENEFICIARY = _chunkSZOX7K2Vcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _chunkSZOX7K2Vcjs.BalanceChangeType; exports.CaveatType = _chunkSZOX7K2Vcjs.CaveatType; exports.ExecutionMode = _chunkMOHCTPYQcjs.ExecutionMode; exports.Implementation = _chunkSZOX7K2Vcjs.Implementation; exports.PREFERRED_VERSION = _chunkSOFB2MXGcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkSZOX7K2Vcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkSZOX7K2Vcjs.ScopeType; exports.TransferWindow = _chunkSZOX7K2Vcjs.TransferWindow; exports.actions = _chunkAJWMPR7Xcjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunk57I2FJY7cjs.contracts_exports; exports.createCaveat = _chunkSZOX7K2Vcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkSZOX7K2Vcjs.createDelegation; exports.createExecution = _chunkMOHCTPYQcjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkSZOX7K2Vcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkSZOX7K2Vcjs.signDelegation; exports.signUserOperation = _chunkSOFB2MXGcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
448
464
  //# sourceMappingURL=index.cjs.map