@rhinestone/sdk 1.0.0-alpha.8 → 1.0.0-beta.38

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 (153) hide show
  1. package/dist/src/accounts/error.d.ts +38 -3
  2. package/dist/src/accounts/error.d.ts.map +1 -1
  3. package/dist/src/accounts/error.js +57 -7
  4. package/dist/src/accounts/index.d.ts +30 -15
  5. package/dist/src/accounts/index.d.ts.map +1 -1
  6. package/dist/src/accounts/index.js +304 -138
  7. package/dist/src/accounts/index.test.js +3 -5
  8. package/dist/src/accounts/json-rpc/index.d.ts +5 -0
  9. package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
  10. package/dist/src/accounts/json-rpc/index.js +16 -0
  11. package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
  12. package/dist/src/accounts/json-rpc/index.test.js +16 -0
  13. package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
  14. package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
  15. package/dist/src/accounts/json-rpc/providers.js +14 -0
  16. package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
  17. package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
  18. package/dist/src/accounts/json-rpc/providers.test.js +15 -0
  19. package/dist/src/accounts/kernel.d.ts +4 -3
  20. package/dist/src/accounts/kernel.d.ts.map +1 -1
  21. package/dist/src/accounts/kernel.js +32 -6
  22. package/dist/src/accounts/kernel.test.js +41 -19
  23. package/dist/src/accounts/nexus.d.ts +14 -7
  24. package/dist/src/accounts/nexus.d.ts.map +1 -1
  25. package/dist/src/accounts/nexus.js +191 -34
  26. package/dist/src/accounts/nexus.test.js +44 -18
  27. package/dist/src/accounts/safe.d.ts +2 -2
  28. package/dist/src/accounts/safe.d.ts.map +1 -1
  29. package/dist/src/accounts/safe.js +88 -58
  30. package/dist/src/accounts/safe.test.js +40 -14
  31. package/dist/src/accounts/signing/common.d.ts +27 -0
  32. package/dist/src/accounts/signing/common.d.ts.map +1 -0
  33. package/dist/src/accounts/signing/common.js +145 -0
  34. package/dist/src/accounts/signing/message.d.ts +5 -0
  35. package/dist/src/accounts/signing/message.d.ts.map +1 -0
  36. package/dist/src/accounts/signing/message.js +47 -0
  37. package/dist/src/accounts/signing/passkeys.d.ts +36 -0
  38. package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
  39. package/dist/src/accounts/signing/passkeys.js +125 -0
  40. package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
  41. package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
  42. package/dist/src/accounts/signing/passkeys.test.js +88 -0
  43. package/dist/src/accounts/signing/typedData.d.ts +5 -0
  44. package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
  45. package/dist/src/accounts/signing/typedData.js +35 -0
  46. package/dist/src/accounts/startale.d.ts +20 -0
  47. package/dist/src/accounts/startale.d.ts.map +1 -0
  48. package/dist/src/accounts/startale.js +100 -0
  49. package/dist/src/accounts/startale.test.d.ts +2 -0
  50. package/dist/src/accounts/startale.test.d.ts.map +1 -0
  51. package/dist/src/accounts/startale.test.js +92 -0
  52. package/dist/src/accounts/utils.d.ts +4 -4
  53. package/dist/src/accounts/utils.d.ts.map +1 -1
  54. package/dist/src/accounts/utils.js +3 -40
  55. package/dist/src/accounts/walletClient.d.ts +7 -0
  56. package/dist/src/accounts/walletClient.d.ts.map +1 -0
  57. package/dist/src/accounts/walletClient.js +38 -0
  58. package/dist/src/actions/compact.d.ts +13 -0
  59. package/dist/src/actions/compact.d.ts.map +1 -0
  60. package/dist/src/actions/compact.js +210 -0
  61. package/dist/src/actions/ecdsa.d.ts +35 -0
  62. package/dist/src/actions/ecdsa.d.ts.map +1 -0
  63. package/dist/src/actions/ecdsa.js +114 -0
  64. package/dist/src/actions/ecdsa.test.d.ts +2 -0
  65. package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
  66. package/dist/src/actions/ecdsa.test.js +99 -0
  67. package/dist/src/actions/index.d.ts +23 -38
  68. package/dist/src/actions/index.d.ts.map +1 -1
  69. package/dist/src/actions/index.js +29 -294
  70. package/dist/src/actions/mfa.d.ts +37 -0
  71. package/dist/src/actions/mfa.d.ts.map +1 -0
  72. package/dist/src/actions/mfa.js +133 -0
  73. package/dist/src/actions/passkeys.d.ts +37 -0
  74. package/dist/src/actions/passkeys.d.ts.map +1 -0
  75. package/dist/src/actions/passkeys.js +129 -0
  76. package/dist/src/actions/passkeys.test.d.ts +2 -0
  77. package/dist/src/actions/passkeys.test.d.ts.map +1 -0
  78. package/dist/src/actions/passkeys.test.js +54 -0
  79. package/dist/src/actions/recovery.d.ts +33 -0
  80. package/dist/src/actions/recovery.d.ts.map +1 -0
  81. package/dist/src/actions/recovery.js +193 -0
  82. package/dist/src/actions/recovery.test.d.ts +2 -0
  83. package/dist/src/actions/recovery.test.d.ts.map +1 -0
  84. package/dist/src/actions/recovery.test.js +168 -0
  85. package/dist/src/actions/smart-session.d.ts +6 -0
  86. package/dist/src/actions/smart-session.d.ts.map +1 -1
  87. package/dist/src/actions/smart-session.js +6 -0
  88. package/dist/src/errors/index.d.ts +5 -0
  89. package/dist/src/errors/index.d.ts.map +1 -0
  90. package/dist/src/errors/index.js +35 -0
  91. package/dist/src/execution/compact.d.ts +150 -7
  92. package/dist/src/execution/compact.d.ts.map +1 -1
  93. package/dist/src/execution/compact.js +112 -95
  94. package/dist/src/execution/error.d.ts +2 -9
  95. package/dist/src/execution/error.d.ts.map +1 -1
  96. package/dist/src/execution/error.js +4 -13
  97. package/dist/src/execution/index.d.ts +34 -22
  98. package/dist/src/execution/index.d.ts.map +1 -1
  99. package/dist/src/execution/index.js +62 -43
  100. package/dist/src/execution/permit2.d.ts +148 -0
  101. package/dist/src/execution/permit2.d.ts.map +1 -0
  102. package/dist/src/execution/permit2.js +282 -0
  103. package/dist/src/execution/smart-session.d.ts +3 -3
  104. package/dist/src/execution/smart-session.d.ts.map +1 -1
  105. package/dist/src/execution/types.d.ts +35 -0
  106. package/dist/src/execution/types.d.ts.map +1 -0
  107. package/dist/src/execution/types.js +2 -0
  108. package/dist/src/execution/utils.d.ts +36 -27
  109. package/dist/src/execution/utils.d.ts.map +1 -1
  110. package/dist/src/execution/utils.js +357 -103
  111. package/dist/src/index.d.ts +41 -22
  112. package/dist/src/index.d.ts.map +1 -1
  113. package/dist/src/index.js +199 -65
  114. package/dist/src/modules/common.d.ts +10 -4
  115. package/dist/src/modules/common.d.ts.map +1 -1
  116. package/dist/src/modules/common.js +22 -1
  117. package/dist/src/modules/index.d.ts +4 -18
  118. package/dist/src/modules/index.d.ts.map +1 -1
  119. package/dist/src/modules/index.js +15 -63
  120. package/dist/src/modules/index.test.js +9 -26
  121. package/dist/src/modules/omni-account.d.ts +2 -1
  122. package/dist/src/modules/omni-account.d.ts.map +1 -1
  123. package/dist/src/modules/omni-account.js +3 -1
  124. package/dist/src/modules/read.d.ts.map +1 -1
  125. package/dist/src/modules/read.js +5 -0
  126. package/dist/src/modules/validators/core.d.ts +5 -3
  127. package/dist/src/modules/validators/core.d.ts.map +1 -1
  128. package/dist/src/modules/validators/core.js +64 -41
  129. package/dist/src/modules/validators/core.test.js +7 -7
  130. package/dist/src/modules/validators/smart-sessions.js +3 -3
  131. package/dist/src/modules/validators/smart-sessions.test.js +4 -7
  132. package/dist/src/orchestrator/client.d.ts +4 -4
  133. package/dist/src/orchestrator/client.d.ts.map +1 -1
  134. package/dist/src/orchestrator/client.js +30 -15
  135. package/dist/src/orchestrator/index.d.ts +2 -3
  136. package/dist/src/orchestrator/index.d.ts.map +1 -1
  137. package/dist/src/orchestrator/index.js +1 -3
  138. package/dist/src/orchestrator/registry.d.ts +1 -23
  139. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  140. package/dist/src/orchestrator/registry.js +37 -33
  141. package/dist/src/orchestrator/registry.test.js +7 -7
  142. package/dist/src/orchestrator/types.d.ts +97 -29
  143. package/dist/src/orchestrator/types.d.ts.map +1 -1
  144. package/dist/src/orchestrator/utils.d.ts +1 -3
  145. package/dist/src/orchestrator/utils.d.ts.map +1 -1
  146. package/dist/src/orchestrator/utils.js +0 -102
  147. package/dist/src/types.d.ts +74 -10
  148. package/dist/src/types.d.ts.map +1 -1
  149. package/package.json +72 -1
  150. package/dist/src/actions/index.test.d.ts.map +0 -1
  151. package/dist/src/actions/index.test.js +0 -302
  152. package/dist/src/orchestrator/registry.json +0 -365
  153. /package/dist/src/{actions → accounts/json-rpc}/index.test.d.ts +0 -0
@@ -1,306 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodeSmartSessionSignature = void 0;
4
- exports.enableEcdsa = enableEcdsa;
5
- exports.enablePasskeys = enablePasskeys;
6
- exports.disableEcdsa = disableEcdsa;
7
- exports.disablePasskeys = disablePasskeys;
8
- exports.addOwner = addOwner;
9
- exports.removeOwner = removeOwner;
10
- exports.changeThreshold = changeThreshold;
11
- exports.recover = recover;
12
- exports.setUpRecovery = setUpRecovery;
13
- exports.enableMultiFactor = enableMultiFactor;
14
- exports.disableMultiFactor = disableMultiFactor;
15
- exports.changeMultiFactorThreshold = changeMultiFactorThreshold;
16
- exports.setSubValidator = setSubValidator;
17
- exports.removeSubValidator = removeSubValidator;
18
- const viem_1 = require("viem");
3
+ exports.installModule = installModule;
4
+ exports.uninstallModule = uninstallModule;
19
5
  const accounts_1 = require("../accounts");
20
- const utils_1 = require("../accounts/utils");
21
- const core_1 = require("../modules/validators/core");
22
- const smart_session_1 = require("./smart-session");
23
- Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return smart_session_1.encodeSmartSessionSignature; } });
24
- function setUpRecovery({ rhinestoneAccount, guardians, threshold = 1, }) {
25
- const module = (0, core_1.getSocialRecoveryValidator)(guardians, threshold);
26
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
27
- return calls;
28
- }
29
- async function recover(address, newOwners, chain, provider) {
30
- switch (newOwners.type) {
31
- case 'ecdsa': {
32
- return recoverEcdsaOwnership(address, newOwners, chain, provider);
33
- }
34
- case 'passkey': {
35
- throw new Error('Passkey ownership recovery is not yet supported');
36
- }
37
- case 'multi-factor': {
38
- throw new Error('Multi-factor ownership recovery is not yet supported');
39
- }
40
- }
41
- }
42
- function enableEcdsa({ rhinestoneAccount, owners, threshold = 1, }) {
43
- const module = (0, core_1.getOwnableValidator)(threshold, owners);
44
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
45
- return calls;
46
- }
47
- function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }) {
48
- const module = (0, core_1.getWebAuthnValidator)({ pubKey, authenticatorId });
49
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
50
- return calls;
51
- }
52
- function disableEcdsa({ rhinestoneAccount, }) {
53
- const module = (0, core_1.getOwnableValidator)(1, []);
54
- const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
55
- return calls;
56
- }
57
- function disablePasskeys({ rhinestoneAccount, }) {
58
- const module = (0, core_1.getWebAuthnValidator)({
59
- // Mocked values
60
- pubKey: '0x580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1',
61
- authenticatorId: '0x',
62
- });
63
- const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
64
- return calls;
65
- }
66
- function addOwner(owner) {
67
- return {
68
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
69
- value: 0n,
70
- data: (0, viem_1.encodeFunctionData)({
71
- abi: [
72
- {
73
- inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
74
- name: 'addOwner',
75
- outputs: [],
76
- stateMutability: 'nonpayable',
77
- type: 'function',
78
- },
79
- ],
80
- functionName: 'addOwner',
81
- args: [owner],
82
- }),
83
- };
84
- }
85
- function removeOwner(prevOwner, ownerToRemove) {
86
- return {
87
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
88
- value: 0n,
89
- data: (0, viem_1.encodeFunctionData)({
90
- abi: [
91
- {
92
- inputs: [
93
- { internalType: 'address', name: 'prevOwner', type: 'address' },
94
- { internalType: 'address', name: 'owner', type: 'address' },
95
- ],
96
- name: 'removeOwner',
97
- outputs: [],
98
- stateMutability: 'nonpayable',
99
- type: 'function',
100
- },
101
- ],
102
- functionName: 'removeOwner',
103
- args: [prevOwner, ownerToRemove],
104
- }),
105
- };
106
- }
107
- function changeThreshold(newThreshold) {
108
- return {
109
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
110
- value: 0n,
111
- data: (0, viem_1.encodeFunctionData)({
112
- abi: [
113
- {
114
- inputs: [
115
- { internalType: 'uint256', name: '_threshold', type: 'uint256' },
116
- ],
117
- name: 'setThreshold',
118
- outputs: [],
119
- stateMutability: 'nonpayable',
120
- type: 'function',
121
- },
122
- ],
123
- functionName: 'setThreshold',
124
- args: [BigInt(newThreshold)],
125
- }),
126
- };
127
- }
128
- async function recoverEcdsaOwnership(address, newOwners, chain, provider) {
129
- const publicClient = (0, viem_1.createPublicClient)({
130
- chain,
131
- transport: (0, utils_1.createTransport)(chain, provider),
132
- });
133
- // Read the existing config
134
- const results = await publicClient.multicall({
135
- contracts: [
136
- {
137
- address: core_1.OWNABLE_VALIDATOR_ADDRESS,
138
- abi: [
139
- {
140
- inputs: [
141
- { internalType: 'address', name: 'account', type: 'address' },
142
- ],
143
- name: 'getOwners',
144
- outputs: [
145
- {
146
- internalType: 'address[]',
147
- name: 'ownersArray',
148
- type: 'address[]',
149
- },
150
- ],
151
- stateMutability: 'view',
152
- type: 'function',
153
- },
154
- ],
155
- functionName: 'getOwners',
156
- args: [address],
157
- },
158
- {
159
- address: core_1.OWNABLE_VALIDATOR_ADDRESS,
160
- abi: [
161
- {
162
- inputs: [
163
- { internalType: 'address', name: 'account', type: 'address' },
164
- ],
165
- name: 'threshold',
166
- outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
167
- stateMutability: 'view',
168
- type: 'function',
169
- },
170
- ],
171
- functionName: 'threshold',
172
- args: [address],
173
- },
174
- ],
175
- });
176
- const existingOwnersResult = results[0];
177
- const existingThresholdResult = results[1];
178
- if (existingOwnersResult.error || existingThresholdResult.error) {
179
- throw new Error('Failed to read existing owners or threshold');
180
- }
181
- const existingOwners = existingOwnersResult.result;
182
- const existingThreshold = existingThresholdResult.result;
183
- const normalizedExistingOwners = existingOwners.map((owner) => owner.toLowerCase());
184
- const calls = [];
185
- // Convert new owners config to addresses and threshold
186
- const newOwnerAddresses = newOwners.accounts
187
- .map((account) => account.address.toLowerCase())
188
- .sort();
189
- const newThreshold = newOwners.threshold ?? 1;
190
- // Check if threshold needs to be updated
191
- if (Number(existingThreshold) !== newThreshold) {
192
- calls.push(changeThreshold(newThreshold));
193
- }
194
- const ownersToAdd = newOwnerAddresses.filter((owner) => !normalizedExistingOwners.includes(owner));
195
- const ownersToRemove = normalizedExistingOwners.filter((owner) => !newOwnerAddresses.includes(owner));
196
- // Maintain the list as making changes to keep track of the previous owner for removals
197
- // Note: new owners are added to the START of the linked list
198
- let currentOwners = [...normalizedExistingOwners];
199
- for (const owner of ownersToAdd) {
200
- calls.push(addOwner(owner));
201
- currentOwners.unshift(owner);
202
- }
203
- for (const ownerToRemove of ownersToRemove) {
204
- const ownerIndex = currentOwners.indexOf(ownerToRemove);
205
- let prevOwner;
206
- if (ownerIndex === 0) {
207
- // If it's the first owner, use the sentinel address
208
- prevOwner = '0x0000000000000000000000000000000000000001';
209
- }
210
- else {
211
- prevOwner = currentOwners[ownerIndex - 1];
212
- }
213
- calls.push(removeOwner(prevOwner, ownerToRemove));
214
- currentOwners = currentOwners.filter((owner) => owner !== ownerToRemove);
215
- }
216
- return calls;
217
- }
218
- function enableMultiFactor({ rhinestoneAccount, validators, threshold = 1, }) {
219
- const module = (0, core_1.getMultiFactorValidator)(threshold, validators);
220
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
221
- return calls;
222
- }
223
- function disableMultiFactor({ rhinestoneAccount, }) {
224
- const module = (0, core_1.getMultiFactorValidator)(1, []);
225
- const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
226
- return calls;
227
- }
228
- function changeMultiFactorThreshold(newThreshold) {
6
+ const common_1 = require("../modules/common");
7
+ /**
8
+ * Install a custom module
9
+ * @param module Module to install
10
+ * @returns Calls to install the module
11
+ */
12
+ function installModule(module) {
13
+ const moduleData = getModule(module);
229
14
  return {
230
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
231
- value: 0n,
232
- data: (0, viem_1.encodeFunctionData)({
233
- abi: [
234
- {
235
- inputs: [{ internalType: 'uint8', name: 'threshold', type: 'uint8' }],
236
- name: 'setThreshold',
237
- outputs: [],
238
- stateMutability: 'nonpayable',
239
- type: 'function',
240
- },
241
- ],
242
- functionName: 'setThreshold',
243
- args: [newThreshold],
244
- }),
15
+ async resolve({ config }) {
16
+ return (0, accounts_1.getModuleInstallationCalls)(config, moduleData);
17
+ },
245
18
  };
246
19
  }
247
- function setSubValidator(id, validator) {
248
- const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
249
- const validatorModule = (0, core_1.getValidator)(validator);
20
+ /**
21
+ * Uninstall a custom module
22
+ * @param module Module to uninstall
23
+ * @returns Calls to uninstall the module
24
+ */
25
+ function uninstallModule(module) {
26
+ const moduleData = getModule(module);
250
27
  return {
251
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
252
- value: 0n,
253
- data: (0, viem_1.encodeFunctionData)({
254
- abi: [
255
- {
256
- type: 'function',
257
- name: 'setValidator',
258
- inputs: [
259
- {
260
- type: 'address',
261
- name: 'validatorAddress',
262
- },
263
- {
264
- type: 'bytes12',
265
- name: 'validatorId',
266
- },
267
- {
268
- type: 'bytes',
269
- name: 'newValidatorData',
270
- },
271
- ],
272
- },
273
- ],
274
- functionName: 'setValidator',
275
- args: [validatorModule.address, validatorId, validatorModule.initData],
276
- }),
28
+ async resolve({ config }) {
29
+ return (0, accounts_1.getModuleUninstallationCalls)(config, moduleData);
30
+ },
277
31
  };
278
32
  }
279
- function removeSubValidator(id, validator) {
280
- const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
281
- const validatorModule = (0, core_1.getValidator)(validator);
33
+ function getModule(module) {
282
34
  return {
283
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
284
- value: 0n,
285
- data: (0, viem_1.encodeFunctionData)({
286
- abi: [
287
- {
288
- type: 'function',
289
- name: 'removeValidator',
290
- inputs: [
291
- {
292
- type: 'address',
293
- name: 'validatorAddress',
294
- },
295
- {
296
- type: 'bytes12',
297
- name: 'validatorId',
298
- },
299
- ],
300
- },
301
- ],
302
- functionName: 'removeValidator',
303
- args: [validatorModule.address, validatorId],
304
- }),
35
+ type: (0, common_1.toModuleTypeId)(module.type),
36
+ address: module.address,
37
+ initData: module.initData ?? '0x',
38
+ deInitData: module.deInitData ?? '0x',
39
+ additionalContext: module.additionalContext ?? '0x',
305
40
  };
306
41
  }
@@ -0,0 +1,37 @@
1
+ import { type Hex } from 'viem';
2
+ import type { CalldataInput, LazyCallInput, OwnableValidatorConfig, WebauthnValidatorConfig } from '../types';
3
+ /**
4
+ * Enable multi-factor authentication
5
+ * @param validators List of validators to use
6
+ * @param threshold Threshold for the validators
7
+ * @returns Calls to enable multi-factor authentication
8
+ */
9
+ declare function enable(validators: (OwnableValidatorConfig | WebauthnValidatorConfig | null)[], threshold?: number): LazyCallInput;
10
+ /**
11
+ * Change the multi-factor threshold
12
+ * @param newThreshold New threshold
13
+ * @returns Call to change the threshold
14
+ */
15
+ declare function changeThreshold(newThreshold: number): CalldataInput;
16
+ /**
17
+ * Disable multi-factor authentication
18
+ * @param rhinestoneAccount Account to disable multi-factor authentication on
19
+ * @returns Calls to disable multi-factor authentication
20
+ */
21
+ declare function disable(): LazyCallInput;
22
+ /**
23
+ * Set a sub-validator (multi-factor)
24
+ * @param id Validator ID
25
+ * @param validator Validator module
26
+ * @returns Call to set the sub-validator
27
+ */
28
+ declare function setSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): CalldataInput;
29
+ /**
30
+ * Remove a sub-validator (multi-factor)
31
+ * @param id Validator ID
32
+ * @param validator Validator module
33
+ * @returns Call to remove the sub-validator
34
+ */
35
+ declare function removeSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): CalldataInput;
36
+ export { enable, changeThreshold, disable, setSubValidator, removeSubValidator };
37
+ //# sourceMappingURL=mfa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfa.d.ts","sourceRoot":"","sources":["../../../actions/mfa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,GAAG,EAAiB,MAAM,MAAM,CAAA;AAUlE,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,UAAU,CAAA;AAEjB;;;;;GAKG;AACH,iBAAS,MAAM,CACb,UAAU,EAAE,CAAC,sBAAsB,GAAG,uBAAuB,GAAG,IAAI,CAAC,EAAE,EACvE,SAAS,SAAI,GACZ,aAAa,CAOf;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAkB5D;AAED;;;;GAIG;AACH,iBAAS,OAAO,IAAI,aAAa,CAOhC;AAED;;;;;GAKG;AACH,iBAAS,eAAe,CACtB,EAAE,EAAE,GAAG,GAAG,MAAM,EAChB,SAAS,EAAE,sBAAsB,GAAG,uBAAuB,GAC1D,aAAa,CA+Bf;AAED;;;;;GAKG;AACH,iBAAS,kBAAkB,CACzB,EAAE,EAAE,GAAG,GAAG,MAAM,EAChB,SAAS,EAAE,sBAAsB,GAAG,uBAAuB,GAC1D,aAAa,CA2Bf;AAED,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAA"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enable = enable;
4
+ exports.changeThreshold = changeThreshold;
5
+ exports.disable = disable;
6
+ exports.setSubValidator = setSubValidator;
7
+ exports.removeSubValidator = removeSubValidator;
8
+ const viem_1 = require("viem");
9
+ const accounts_1 = require("../accounts");
10
+ const core_1 = require("../modules/validators/core");
11
+ /**
12
+ * Enable multi-factor authentication
13
+ * @param validators List of validators to use
14
+ * @param threshold Threshold for the validators
15
+ * @returns Calls to enable multi-factor authentication
16
+ */
17
+ function enable(validators, threshold = 1) {
18
+ const module = (0, core_1.getMultiFactorValidator)(threshold, validators);
19
+ return {
20
+ async resolve({ config }) {
21
+ return (0, accounts_1.getModuleInstallationCalls)(config, module);
22
+ },
23
+ };
24
+ }
25
+ /**
26
+ * Change the multi-factor threshold
27
+ * @param newThreshold New threshold
28
+ * @returns Call to change the threshold
29
+ */
30
+ function changeThreshold(newThreshold) {
31
+ return {
32
+ to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
33
+ value: 0n,
34
+ data: (0, viem_1.encodeFunctionData)({
35
+ abi: [
36
+ {
37
+ inputs: [{ internalType: 'uint8', name: 'threshold', type: 'uint8' }],
38
+ name: 'setThreshold',
39
+ outputs: [],
40
+ stateMutability: 'nonpayable',
41
+ type: 'function',
42
+ },
43
+ ],
44
+ functionName: 'setThreshold',
45
+ args: [newThreshold],
46
+ }),
47
+ };
48
+ }
49
+ /**
50
+ * Disable multi-factor authentication
51
+ * @param rhinestoneAccount Account to disable multi-factor authentication on
52
+ * @returns Calls to disable multi-factor authentication
53
+ */
54
+ function disable() {
55
+ const module = (0, core_1.getMultiFactorValidator)(1, []);
56
+ return {
57
+ async resolve({ config }) {
58
+ return (0, accounts_1.getModuleUninstallationCalls)(config, module);
59
+ },
60
+ };
61
+ }
62
+ /**
63
+ * Set a sub-validator (multi-factor)
64
+ * @param id Validator ID
65
+ * @param validator Validator module
66
+ * @returns Call to set the sub-validator
67
+ */
68
+ function setSubValidator(id, validator) {
69
+ const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
70
+ const validatorModule = (0, core_1.getValidator)(validator);
71
+ return {
72
+ to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
73
+ value: 0n,
74
+ data: (0, viem_1.encodeFunctionData)({
75
+ abi: [
76
+ {
77
+ type: 'function',
78
+ name: 'setValidator',
79
+ inputs: [
80
+ {
81
+ type: 'address',
82
+ name: 'validatorAddress',
83
+ },
84
+ {
85
+ type: 'bytes12',
86
+ name: 'validatorId',
87
+ },
88
+ {
89
+ type: 'bytes',
90
+ name: 'newValidatorData',
91
+ },
92
+ ],
93
+ },
94
+ ],
95
+ functionName: 'setValidator',
96
+ args: [validatorModule.address, validatorId, validatorModule.initData],
97
+ }),
98
+ };
99
+ }
100
+ /**
101
+ * Remove a sub-validator (multi-factor)
102
+ * @param id Validator ID
103
+ * @param validator Validator module
104
+ * @returns Call to remove the sub-validator
105
+ */
106
+ function removeSubValidator(id, validator) {
107
+ const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
108
+ const validatorModule = (0, core_1.getValidator)(validator);
109
+ return {
110
+ to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
111
+ value: 0n,
112
+ data: (0, viem_1.encodeFunctionData)({
113
+ abi: [
114
+ {
115
+ type: 'function',
116
+ name: 'removeValidator',
117
+ inputs: [
118
+ {
119
+ type: 'address',
120
+ name: 'validatorAddress',
121
+ },
122
+ {
123
+ type: 'bytes12',
124
+ name: 'validatorId',
125
+ },
126
+ ],
127
+ },
128
+ ],
129
+ functionName: 'removeValidator',
130
+ args: [validatorModule.address, validatorId],
131
+ }),
132
+ };
133
+ }
@@ -0,0 +1,37 @@
1
+ import { type WebauthnCredential } from '../modules/validators/core';
2
+ import type { CalldataInput, LazyCallInput } from '../types';
3
+ /**
4
+ * Enable passkeys authentication
5
+ * @param pubKey Public key for the passkey
6
+ * @param authenticatorId Authenticator ID for the passkey
7
+ * @returns Calls to enable passkeys authentication
8
+ */
9
+ declare function enable(credential: WebauthnCredential): LazyCallInput;
10
+ /**
11
+ * Disable passkeys (WebAuthn) authentication
12
+ * @returns Calls to disable passkeys authentication
13
+ */
14
+ declare function disable(): LazyCallInput;
15
+ /**
16
+ * Add a passkey owner
17
+ * @param pubKeyX Public key X
18
+ * @param pubKeyY Public key Y
19
+ * @param requireUserVerification Whether to require user verification
20
+ * @returns Call to add the passkey owner
21
+ */
22
+ declare function addOwner(pubKeyX: bigint, pubKeyY: bigint, requireUserVerification: boolean): CalldataInput;
23
+ /**
24
+ * Remove a passkey owner
25
+ * @param pubKeyX Public key X
26
+ * @param pubKeyY Public key Y
27
+ * @returns Call to remove the passkey owner
28
+ */
29
+ declare function removeOwner(pubKeyX: bigint, pubKeyY: bigint): CalldataInput;
30
+ /**
31
+ * Change an account's signer threshold (passkey)
32
+ * @param newThreshold New threshold
33
+ * @returns Call to change the threshold
34
+ */
35
+ declare function changeThreshold(newThreshold: number): CalldataInput;
36
+ export { addOwner, removeOwner, changeThreshold, disable, enable };
37
+ //# sourceMappingURL=passkeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkeys.d.ts","sourceRoot":"","sources":["../../../actions/passkeys.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE5D;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAO7D;AAED;;;GAGG;AACH,iBAAS,OAAO,IAAI,aAAa,CAchC;AAED;;;;;;GAMG;AACH,iBAAS,QAAQ,CACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,uBAAuB,EAAE,OAAO,GAC/B,aAAa,CAyBf;AAED;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAqBpE;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAoB5D;AAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addOwner = addOwner;
4
+ exports.removeOwner = removeOwner;
5
+ exports.changeThreshold = changeThreshold;
6
+ exports.disable = disable;
7
+ exports.enable = enable;
8
+ const viem_1 = require("viem");
9
+ const accounts_1 = require("../accounts");
10
+ const core_1 = require("../modules/validators/core");
11
+ /**
12
+ * Enable passkeys authentication
13
+ * @param pubKey Public key for the passkey
14
+ * @param authenticatorId Authenticator ID for the passkey
15
+ * @returns Calls to enable passkeys authentication
16
+ */
17
+ function enable(credential) {
18
+ const module = (0, core_1.getWebAuthnValidator)(1, [credential]);
19
+ return {
20
+ async resolve({ config }) {
21
+ return (0, accounts_1.getModuleInstallationCalls)(config, module);
22
+ },
23
+ };
24
+ }
25
+ /**
26
+ * Disable passkeys (WebAuthn) authentication
27
+ * @returns Calls to disable passkeys authentication
28
+ */
29
+ function disable() {
30
+ const module = (0, core_1.getWebAuthnValidator)(1, [
31
+ {
32
+ // Mocked values
33
+ pubKey: '0x580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1',
34
+ authenticatorId: '0x',
35
+ },
36
+ ]);
37
+ return {
38
+ async resolve({ config }) {
39
+ return (0, accounts_1.getModuleUninstallationCalls)(config, module);
40
+ },
41
+ };
42
+ }
43
+ /**
44
+ * Add a passkey owner
45
+ * @param pubKeyX Public key X
46
+ * @param pubKeyY Public key Y
47
+ * @param requireUserVerification Whether to require user verification
48
+ * @returns Call to add the passkey owner
49
+ */
50
+ function addOwner(pubKeyX, pubKeyY, requireUserVerification) {
51
+ return {
52
+ to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
53
+ value: 0n,
54
+ data: (0, viem_1.encodeFunctionData)({
55
+ abi: [
56
+ {
57
+ inputs: [
58
+ { name: 'pubKeyX', type: 'uint256' },
59
+ { name: 'pubKeyY', type: 'uint256' },
60
+ {
61
+ name: 'requireUserVerification',
62
+ type: 'bool',
63
+ },
64
+ ],
65
+ name: 'addCredential',
66
+ outputs: [],
67
+ stateMutability: 'nonpayable',
68
+ type: 'function',
69
+ },
70
+ ],
71
+ functionName: 'addCredential',
72
+ args: [pubKeyX, pubKeyY, requireUserVerification],
73
+ }),
74
+ };
75
+ }
76
+ /**
77
+ * Remove a passkey owner
78
+ * @param pubKeyX Public key X
79
+ * @param pubKeyY Public key Y
80
+ * @returns Call to remove the passkey owner
81
+ */
82
+ function removeOwner(pubKeyX, pubKeyY) {
83
+ return {
84
+ to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
85
+ value: 0n,
86
+ data: (0, viem_1.encodeFunctionData)({
87
+ abi: [
88
+ {
89
+ inputs: [
90
+ { name: 'pubKeyX', type: 'uint256' },
91
+ { name: 'pubKeyY', type: 'uint256' },
92
+ ],
93
+ name: 'removeCredential',
94
+ outputs: [],
95
+ stateMutability: 'nonpayable',
96
+ type: 'function',
97
+ },
98
+ ],
99
+ functionName: 'removeCredential',
100
+ args: [pubKeyX, pubKeyY],
101
+ }),
102
+ };
103
+ }
104
+ /**
105
+ * Change an account's signer threshold (passkey)
106
+ * @param newThreshold New threshold
107
+ * @returns Call to change the threshold
108
+ */
109
+ function changeThreshold(newThreshold) {
110
+ return {
111
+ to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
112
+ value: 0n,
113
+ data: (0, viem_1.encodeFunctionData)({
114
+ abi: [
115
+ {
116
+ inputs: [
117
+ { internalType: 'uint256', name: '_threshold', type: 'uint256' },
118
+ ],
119
+ name: 'setThreshold',
120
+ outputs: [],
121
+ stateMutability: 'nonpayable',
122
+ type: 'function',
123
+ },
124
+ ],
125
+ functionName: 'setThreshold',
126
+ args: [BigInt(newThreshold)],
127
+ }),
128
+ };
129
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=passkeys.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passkeys.test.d.ts","sourceRoot":"","sources":["../../../actions/passkeys.test.ts"],"names":[],"mappings":""}