@rhinestone/sdk 1.0.0-alpha.31 → 1.0.0-alpha.33

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 (78) hide show
  1. package/dist/src/accounts/index.d.ts +18 -18
  2. package/dist/src/accounts/index.d.ts.map +1 -1
  3. package/dist/src/accounts/index.js +12 -8
  4. package/dist/src/accounts/index.test.js +0 -2
  5. package/dist/src/accounts/kernel.test.js +0 -6
  6. package/dist/src/accounts/nexus.test.js +0 -6
  7. package/dist/src/accounts/safe.test.js +0 -6
  8. package/dist/src/accounts/signing/common.d.ts +3 -3
  9. package/dist/src/accounts/signing/common.d.ts.map +1 -1
  10. package/dist/src/accounts/signing/common.js +10 -8
  11. package/dist/src/accounts/signing/message.d.ts +1 -1
  12. package/dist/src/accounts/signing/message.d.ts.map +1 -1
  13. package/dist/src/accounts/signing/message.js +3 -3
  14. package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
  15. package/dist/src/accounts/signing/typedData.js +2 -2
  16. package/dist/src/accounts/startale.test.js +0 -4
  17. package/dist/src/accounts/utils.d.ts +2 -2
  18. package/dist/src/accounts/utils.d.ts.map +1 -1
  19. package/dist/src/actions/compact.d.ts +13 -0
  20. package/dist/src/actions/compact.d.ts.map +1 -0
  21. package/dist/src/actions/compact.js +210 -0
  22. package/dist/src/actions/ecdsa.d.ts +35 -0
  23. package/dist/src/actions/ecdsa.d.ts.map +1 -0
  24. package/dist/src/actions/ecdsa.js +114 -0
  25. package/dist/src/actions/ecdsa.test.d.ts +2 -0
  26. package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
  27. package/dist/src/actions/ecdsa.test.js +99 -0
  28. package/dist/src/actions/index.d.ts +5 -176
  29. package/dist/src/actions/index.d.ts.map +1 -1
  30. package/dist/src/actions/index.js +10 -563
  31. package/dist/src/actions/mfa.d.ts +37 -0
  32. package/dist/src/actions/mfa.d.ts.map +1 -0
  33. package/dist/src/actions/mfa.js +133 -0
  34. package/dist/src/actions/passkeys.d.ts +37 -0
  35. package/dist/src/actions/passkeys.d.ts.map +1 -0
  36. package/dist/src/actions/passkeys.js +129 -0
  37. package/dist/src/actions/passkeys.test.d.ts +2 -0
  38. package/dist/src/actions/passkeys.test.d.ts.map +1 -0
  39. package/dist/src/actions/passkeys.test.js +54 -0
  40. package/dist/src/actions/recovery.d.ts +33 -0
  41. package/dist/src/actions/recovery.d.ts.map +1 -0
  42. package/dist/src/actions/recovery.js +193 -0
  43. package/dist/src/actions/recovery.test.d.ts +2 -0
  44. package/dist/src/actions/recovery.test.d.ts.map +1 -0
  45. package/dist/src/actions/recovery.test.js +168 -0
  46. package/dist/src/errors/index.d.ts +5 -0
  47. package/dist/src/errors/index.d.ts.map +1 -0
  48. package/dist/src/errors/index.js +35 -0
  49. package/dist/src/execution/compact.d.ts +2 -7
  50. package/dist/src/execution/compact.d.ts.map +1 -1
  51. package/dist/src/execution/compact.js +1 -100
  52. package/dist/src/execution/error.d.ts +2 -16
  53. package/dist/src/execution/error.d.ts.map +1 -1
  54. package/dist/src/execution/error.js +4 -22
  55. package/dist/src/execution/index.d.ts +24 -24
  56. package/dist/src/execution/index.d.ts.map +1 -1
  57. package/dist/src/execution/index.js +39 -25
  58. package/dist/src/execution/smart-session.d.ts +3 -3
  59. package/dist/src/execution/smart-session.d.ts.map +1 -1
  60. package/dist/src/execution/utils.d.ts +33 -29
  61. package/dist/src/execution/utils.d.ts.map +1 -1
  62. package/dist/src/execution/utils.js +81 -72
  63. package/dist/src/index.d.ts +28 -16
  64. package/dist/src/index.d.ts.map +1 -1
  65. package/dist/src/index.js +69 -65
  66. package/dist/src/modules/index.d.ts +2 -2
  67. package/dist/src/modules/index.d.ts.map +1 -1
  68. package/dist/src/modules/index.js +1 -1
  69. package/dist/src/modules/index.test.js +0 -4
  70. package/dist/src/modules/validators/smart-sessions.test.js +0 -3
  71. package/dist/src/orchestrator/types.d.ts +1 -6
  72. package/dist/src/orchestrator/types.d.ts.map +1 -1
  73. package/dist/src/types.d.ts +23 -4
  74. package/dist/src/types.d.ts.map +1 -1
  75. package/package.json +36 -1
  76. package/dist/src/actions/index.test.d.ts +0 -2
  77. package/dist/src/actions/index.test.d.ts.map +0 -1
  78. package/dist/src/actions/index.test.js +0 -302
@@ -1,586 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodeSmartSessionSignature = void 0;
4
3
  exports.installModule = installModule;
5
4
  exports.uninstallModule = uninstallModule;
6
- exports.enableEcdsa = enableEcdsa;
7
- exports.enablePasskeys = enablePasskeys;
8
- exports.disableEcdsa = disableEcdsa;
9
- exports.disablePasskeys = disablePasskeys;
10
- exports.addOwner = addOwner;
11
- exports.removeOwner = removeOwner;
12
- exports.changeThreshold = changeThreshold;
13
- exports.addPasskeyOwner = addPasskeyOwner;
14
- exports.removePasskeyOwner = removePasskeyOwner;
15
- exports.changePasskeyThreshold = changePasskeyThreshold;
16
- exports.recover = recover;
17
- exports.recoverEcdsaOwnership = recoverEcdsaOwnership;
18
- exports.recoverPasskeyOwnership = recoverPasskeyOwnership;
19
- exports.setUpRecovery = setUpRecovery;
20
- exports.enableMultiFactor = enableMultiFactor;
21
- exports.disableMultiFactor = disableMultiFactor;
22
- exports.changeMultiFactorThreshold = changeMultiFactorThreshold;
23
- exports.setSubValidator = setSubValidator;
24
- exports.removeSubValidator = removeSubValidator;
25
- const viem_1 = require("viem");
26
5
  const accounts_1 = require("../accounts");
27
- const utils_1 = require("../accounts/utils");
28
6
  const common_1 = require("../modules/common");
29
- const core_1 = require("../modules/validators/core");
30
- const smart_session_1 = require("./smart-session");
31
- Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return smart_session_1.encodeSmartSessionSignature; } });
32
7
  /**
33
8
  * Install a custom module
34
- * @param rhinestoneAccount Account to install the module on
35
9
  * @param module Module to install
36
10
  * @returns Calls to install the module
37
11
  */
38
- function installModule({ rhinestoneAccount, module, }) {
12
+ function installModule(module) {
39
13
  const moduleData = getModule(module);
40
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, moduleData);
41
- return calls;
14
+ return {
15
+ async resolve({ config }) {
16
+ return (0, accounts_1.getModuleInstallationCalls)(config, moduleData);
17
+ },
18
+ };
42
19
  }
43
20
  /**
44
21
  * Uninstall a custom module
45
- * @param rhinestoneAccount Account to uninstall the module on
46
22
  * @param module Module to uninstall
47
23
  * @returns Calls to uninstall the module
48
24
  */
49
- function uninstallModule({ rhinestoneAccount, module, }) {
25
+ function uninstallModule(module) {
50
26
  const moduleData = getModule(module);
51
- const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, moduleData);
52
- return calls;
53
- }
54
- /**
55
- * Set up social recovery
56
- * @param rhinestoneAccount Account to set up social recovery on
57
- * @param guardians Guardians to use for recovery
58
- * @param threshold Threshold for the guardians
59
- * @returns Calls to set up social recovery
60
- */
61
- function setUpRecovery({ rhinestoneAccount, guardians, threshold = 1, }) {
62
- const module = (0, core_1.getSocialRecoveryValidator)(guardians, threshold);
63
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
64
- return calls;
65
- }
66
- /**
67
- * Recover an account's ownership
68
- * @param address Account address
69
- * @param newOwners New owners
70
- * @param chain Chain to recover ownership on
71
- * @param provider Provider to use for the recovery
72
- * @returns Calls to recover ownership
73
- * @deprecated Use `recoverEcdsaOwnership` or `recoverPasskeyOwnership` instead
74
- */
75
- async function recover(address, newOwners, chain, provider) {
76
- switch (newOwners.type) {
77
- case 'ecdsa': {
78
- return recoverEcdsaOwnership(address, newOwners, chain, provider);
79
- }
80
- case 'passkey': {
81
- throw new Error('Passkey ownership recovery is not yet supported');
82
- }
83
- case 'multi-factor': {
84
- throw new Error('Multi-factor ownership recovery is not yet supported');
85
- }
86
- }
87
- }
88
- /**
89
- * Enable ECDSA authentication
90
- * @param rhinestoneAccount Account to enable ECDSA authentication on
91
- * @param owners Owners to use for authentication
92
- * @param threshold Threshold for the owners
93
- * @returns Calls to enable ECDSA authentication
94
- */
95
- function enableEcdsa({ rhinestoneAccount, owners, threshold = 1, }) {
96
- const module = (0, core_1.getOwnableValidator)(threshold, owners);
97
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
98
- return calls;
99
- }
100
- /**
101
- * Enable passkeys authentication
102
- * @param rhinestoneAccount Account to enable passkeys authentication on
103
- * @param pubKey Public key for the passkey
104
- * @param authenticatorId Authenticator ID for the passkey
105
- * @returns Calls to enable passkeys authentication
106
- */
107
- function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }) {
108
- const module = (0, core_1.getWebAuthnValidator)(1, [{ pubKey, authenticatorId }]);
109
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
110
- return calls;
111
- }
112
- /**
113
- * Disable ECDSA authentication
114
- * @param rhinestoneAccount Account to disable ECDSA authentication on
115
- * @returns Calls to disable ECDSA authentication
116
- */
117
- function disableEcdsa({ rhinestoneAccount, }) {
118
- const module = (0, core_1.getOwnableValidator)(1, []);
119
- const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
120
- return calls;
121
- }
122
- /**
123
- * Disable passkeys (WebAuthn) authentication
124
- * @param rhinestoneAccount Account to disable passkeys authentication on
125
- * @returns Calls to disable passkeys authentication
126
- */
127
- function disablePasskeys({ rhinestoneAccount, }) {
128
- const module = (0, core_1.getWebAuthnValidator)(1, [
129
- {
130
- // Mocked values
131
- pubKey: '0x580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1',
132
- authenticatorId: '0x',
133
- },
134
- ]);
135
- const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
136
- return calls;
137
- }
138
- /**
139
- * Add an ECDSA owner
140
- * @param owner Owner address
141
- * @returns Call to add the owner
142
- */
143
- function addOwner(owner) {
144
- return {
145
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
146
- value: 0n,
147
- data: (0, viem_1.encodeFunctionData)({
148
- abi: [
149
- {
150
- inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
151
- name: 'addOwner',
152
- outputs: [],
153
- stateMutability: 'nonpayable',
154
- type: 'function',
155
- },
156
- ],
157
- functionName: 'addOwner',
158
- args: [owner],
159
- }),
160
- };
161
- }
162
- /**
163
- * Remove an ECDSA owner
164
- * @param prevOwner Previous owner address
165
- * @param ownerToRemove Owner to remove
166
- * @returns Call to remove the owner
167
- */
168
- function removeOwner(prevOwner, ownerToRemove) {
169
- return {
170
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
171
- value: 0n,
172
- data: (0, viem_1.encodeFunctionData)({
173
- abi: [
174
- {
175
- inputs: [
176
- { internalType: 'address', name: 'prevOwner', type: 'address' },
177
- { internalType: 'address', name: 'owner', type: 'address' },
178
- ],
179
- name: 'removeOwner',
180
- outputs: [],
181
- stateMutability: 'nonpayable',
182
- type: 'function',
183
- },
184
- ],
185
- functionName: 'removeOwner',
186
- args: [prevOwner, ownerToRemove],
187
- }),
188
- };
189
- }
190
- /**
191
- * Change an account's signer threshold (ECDSA)
192
- * @param newThreshold New threshold
193
- * @returns Call to change the threshold
194
- */
195
- function changeThreshold(newThreshold) {
196
- return {
197
- to: core_1.OWNABLE_VALIDATOR_ADDRESS,
198
- value: 0n,
199
- data: (0, viem_1.encodeFunctionData)({
200
- abi: [
201
- {
202
- inputs: [
203
- { internalType: 'uint256', name: '_threshold', type: 'uint256' },
204
- ],
205
- name: 'setThreshold',
206
- outputs: [],
207
- stateMutability: 'nonpayable',
208
- type: 'function',
209
- },
210
- ],
211
- functionName: 'setThreshold',
212
- args: [BigInt(newThreshold)],
213
- }),
214
- };
215
- }
216
- /**
217
- * Add a passkey owner
218
- * @param pubKeyX Public key X
219
- * @param pubKeyY Public key Y
220
- * @param requireUserVerification Whether to require user verification
221
- * @returns Call to add the passkey owner
222
- */
223
- function addPasskeyOwner(pubKeyX, pubKeyY, requireUserVerification) {
224
- return {
225
- to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
226
- value: 0n,
227
- data: (0, viem_1.encodeFunctionData)({
228
- abi: [
229
- {
230
- inputs: [
231
- { name: 'pubKeyX', type: 'uint256' },
232
- { name: 'pubKeyY', type: 'uint256' },
233
- {
234
- name: 'requireUserVerification',
235
- type: 'bool',
236
- },
237
- ],
238
- name: 'addCredential',
239
- outputs: [],
240
- stateMutability: 'nonpayable',
241
- type: 'function',
242
- },
243
- ],
244
- functionName: 'addCredential',
245
- args: [pubKeyX, pubKeyY, requireUserVerification],
246
- }),
247
- };
248
- }
249
- /**
250
- * Remove a passkey owner
251
- * @param pubKeyX Public key X
252
- * @param pubKeyY Public key Y
253
- * @returns Call to remove the passkey owner
254
- */
255
- function removePasskeyOwner(pubKeyX, pubKeyY) {
256
- return {
257
- to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
258
- value: 0n,
259
- data: (0, viem_1.encodeFunctionData)({
260
- abi: [
261
- {
262
- inputs: [
263
- { name: 'pubKeyX', type: 'uint256' },
264
- { name: 'pubKeyY', type: 'uint256' },
265
- ],
266
- name: 'removeCredential',
267
- outputs: [],
268
- stateMutability: 'nonpayable',
269
- type: 'function',
270
- },
271
- ],
272
- functionName: 'removeCredential',
273
- args: [pubKeyX, pubKeyY],
274
- }),
275
- };
276
- }
277
- /**
278
- * Change an account's signer threshold (passkey)
279
- * @param newThreshold New threshold
280
- * @returns Call to change the threshold
281
- */
282
- function changePasskeyThreshold(newThreshold) {
283
27
  return {
284
- to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
285
- value: 0n,
286
- data: (0, viem_1.encodeFunctionData)({
287
- abi: [
288
- {
289
- inputs: [
290
- { internalType: 'uint256', name: '_threshold', type: 'uint256' },
291
- ],
292
- name: 'setThreshold',
293
- outputs: [],
294
- stateMutability: 'nonpayable',
295
- type: 'function',
296
- },
297
- ],
298
- functionName: 'setThreshold',
299
- args: [BigInt(newThreshold)],
300
- }),
301
- };
302
- }
303
- /**
304
- * Recover an account's ownership (ECDSA)
305
- * @param address Account address
306
- * @param newOwners New owners
307
- * @param chain Chain to recover ownership on
308
- * @param provider Provider to use for the recovery
309
- * @returns Calls to recover ownership
310
- */
311
- async function recoverEcdsaOwnership(address, newOwners, chain, provider) {
312
- const publicClient = (0, viem_1.createPublicClient)({
313
- chain,
314
- transport: (0, utils_1.createTransport)(chain, provider),
315
- });
316
- // Read the existing config
317
- const results = await publicClient.multicall({
318
- contracts: [
319
- {
320
- address: core_1.OWNABLE_VALIDATOR_ADDRESS,
321
- abi: [
322
- {
323
- inputs: [
324
- { internalType: 'address', name: 'account', type: 'address' },
325
- ],
326
- name: 'getOwners',
327
- outputs: [
328
- {
329
- internalType: 'address[]',
330
- name: 'ownersArray',
331
- type: 'address[]',
332
- },
333
- ],
334
- stateMutability: 'view',
335
- type: 'function',
336
- },
337
- ],
338
- functionName: 'getOwners',
339
- args: [address],
340
- },
341
- {
342
- address: core_1.OWNABLE_VALIDATOR_ADDRESS,
343
- abi: [
344
- {
345
- inputs: [
346
- { internalType: 'address', name: 'account', type: 'address' },
347
- ],
348
- name: 'threshold',
349
- outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
350
- stateMutability: 'view',
351
- type: 'function',
352
- },
353
- ],
354
- functionName: 'threshold',
355
- args: [address],
356
- },
357
- ],
358
- });
359
- const existingOwnersResult = results[0];
360
- const existingThresholdResult = results[1];
361
- if (existingOwnersResult.error || existingThresholdResult.error) {
362
- throw new Error('Failed to read existing owners or threshold');
363
- }
364
- const existingOwners = existingOwnersResult.result;
365
- const existingThreshold = existingThresholdResult.result;
366
- const normalizedExistingOwners = existingOwners.map((owner) => owner.toLowerCase());
367
- const calls = [];
368
- // Convert new owners config to addresses and threshold
369
- const newOwnerAddresses = newOwners.accounts
370
- .map((account) => account.address.toLowerCase())
371
- .sort();
372
- const newThreshold = newOwners.threshold ?? 1;
373
- // Check if threshold needs to be updated
374
- if (Number(existingThreshold) !== newThreshold) {
375
- calls.push(changeThreshold(newThreshold));
376
- }
377
- const ownersToAdd = newOwnerAddresses.filter((owner) => !normalizedExistingOwners.includes(owner));
378
- const ownersToRemove = normalizedExistingOwners.filter((owner) => !newOwnerAddresses.includes(owner));
379
- // Maintain the list as making changes to keep track of the previous owner for removals
380
- // Note: new owners are added to the START of the linked list
381
- let currentOwners = [...normalizedExistingOwners];
382
- for (const owner of ownersToAdd) {
383
- calls.push(addOwner(owner));
384
- currentOwners.unshift(owner);
385
- }
386
- for (const ownerToRemove of ownersToRemove) {
387
- const ownerIndex = currentOwners.indexOf(ownerToRemove);
388
- let prevOwner;
389
- if (ownerIndex === 0) {
390
- // If it's the first owner, use the sentinel address
391
- prevOwner = '0x0000000000000000000000000000000000000001';
392
- }
393
- else {
394
- prevOwner = currentOwners[ownerIndex - 1];
395
- }
396
- calls.push(removeOwner(prevOwner, ownerToRemove));
397
- currentOwners = currentOwners.filter((owner) => owner !== ownerToRemove);
398
- }
399
- return calls;
400
- }
401
- /**
402
- * Recover an account's ownership (Passkey)
403
- * @param address Account address
404
- * @param oldCredentials Old credentials to be replaced (with pubKeyX, pubKeyY)
405
- * @param newOwners New passkey owners
406
- * @param chain Chain to recover ownership on
407
- * @param provider Provider to use for the recovery
408
- * @returns Calls to recover ownership
409
- */
410
- async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain, provider) {
411
- const publicClient = (0, viem_1.createPublicClient)({
412
- chain,
413
- transport: (0, utils_1.createTransport)(chain, provider),
414
- });
415
- const existingThreshold = await publicClient.readContract({
416
- address: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
417
- abi: [
418
- {
419
- inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
420
- name: 'threshold',
421
- outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
422
- stateMutability: 'view',
423
- type: 'function',
424
- },
425
- ],
426
- functionName: 'threshold',
427
- args: [address],
428
- });
429
- const calls = [];
430
- // Convert new owners config to credentials and threshold
431
- const newCredentials = newOwners.accounts.map((account) => {
432
- const publicKey = account.publicKey;
433
- // Parse the public key hex string to extract x and y coordinates
434
- const publicKeyBytes = publicKey.startsWith('0x')
435
- ? publicKey.slice(2)
436
- : publicKey;
437
- // The public key is 64 bytes: 32 bytes for x, 32 bytes for y
438
- const x = BigInt(`0x${publicKeyBytes.slice(0, 64)}`);
439
- const y = BigInt(`0x${publicKeyBytes.slice(64, 128)}`);
440
- return {
441
- pubKeyX: x,
442
- pubKeyY: y,
443
- requireUV: false, // Default to false for now
444
- };
445
- });
446
- const newThreshold = newOwners.threshold ?? 1;
447
- // Check if threshold needs to be updated
448
- if (Number(existingThreshold) !== newThreshold) {
449
- calls.push(changePasskeyThreshold(newThreshold));
450
- }
451
- // Compare existing and new credentials to determine what to add/remove
452
- const existingCredentialKeys = oldCredentials.map((cred) => `${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`);
453
- const newCredentialKeys = newCredentials.map((cred) => `${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`);
454
- // Find credentials to add (new ones not in existing)
455
- const credentialsToAdd = newCredentials.filter((cred) => !existingCredentialKeys.includes(`${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`));
456
- // Find credentials to remove (existing ones not in new)
457
- const credentialsToRemove = oldCredentials.filter((cred) => !newCredentialKeys.includes(`${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`));
458
- // Remove old credentials first (important for security in recovery scenarios)
459
- for (const credential of credentialsToRemove) {
460
- calls.push(removePasskeyOwner(credential.pubKeyX, credential.pubKeyY));
461
- }
462
- // Then add new credentials
463
- for (const credential of credentialsToAdd) {
464
- calls.push(addPasskeyOwner(credential.pubKeyX, credential.pubKeyY, credential.requireUV));
465
- }
466
- return calls;
467
- }
468
- /**
469
- * Enable multi-factor authentication
470
- * @param rhinestoneAccount Account to enable multi-factor authentication on
471
- * @param validators List of validators to use
472
- * @param threshold Threshold for the validators
473
- * @returns Calls to enable multi-factor authentication
474
- */
475
- function enableMultiFactor({ rhinestoneAccount, validators, threshold = 1, }) {
476
- const module = (0, core_1.getMultiFactorValidator)(threshold, validators);
477
- const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
478
- return calls;
479
- }
480
- /**
481
- * Disable multi-factor authentication
482
- * @param rhinestoneAccount Account to disable multi-factor authentication on
483
- * @returns Calls to disable multi-factor authentication
484
- */
485
- function disableMultiFactor({ rhinestoneAccount, }) {
486
- const module = (0, core_1.getMultiFactorValidator)(1, []);
487
- const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
488
- return calls;
489
- }
490
- /**
491
- * Change the multi-factor threshold
492
- * @param newThreshold New threshold
493
- * @returns Call to change the threshold
494
- */
495
- function changeMultiFactorThreshold(newThreshold) {
496
- return {
497
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
498
- value: 0n,
499
- data: (0, viem_1.encodeFunctionData)({
500
- abi: [
501
- {
502
- inputs: [{ internalType: 'uint8', name: 'threshold', type: 'uint8' }],
503
- name: 'setThreshold',
504
- outputs: [],
505
- stateMutability: 'nonpayable',
506
- type: 'function',
507
- },
508
- ],
509
- functionName: 'setThreshold',
510
- args: [newThreshold],
511
- }),
512
- };
513
- }
514
- /**
515
- * Set a sub-validator (multi-factor)
516
- * @param id Validator ID
517
- * @param validator Validator module
518
- * @returns Call to set the sub-validator
519
- */
520
- function setSubValidator(id, validator) {
521
- const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
522
- const validatorModule = (0, core_1.getValidator)(validator);
523
- return {
524
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
525
- value: 0n,
526
- data: (0, viem_1.encodeFunctionData)({
527
- abi: [
528
- {
529
- type: 'function',
530
- name: 'setValidator',
531
- inputs: [
532
- {
533
- type: 'address',
534
- name: 'validatorAddress',
535
- },
536
- {
537
- type: 'bytes12',
538
- name: 'validatorId',
539
- },
540
- {
541
- type: 'bytes',
542
- name: 'newValidatorData',
543
- },
544
- ],
545
- },
546
- ],
547
- functionName: 'setValidator',
548
- args: [validatorModule.address, validatorId, validatorModule.initData],
549
- }),
550
- };
551
- }
552
- /**
553
- * Remove a sub-validator (multi-factor)
554
- * @param id Validator ID
555
- * @param validator Validator module
556
- * @returns Call to remove the sub-validator
557
- */
558
- function removeSubValidator(id, validator) {
559
- const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
560
- const validatorModule = (0, core_1.getValidator)(validator);
561
- return {
562
- to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
563
- value: 0n,
564
- data: (0, viem_1.encodeFunctionData)({
565
- abi: [
566
- {
567
- type: 'function',
568
- name: 'removeValidator',
569
- inputs: [
570
- {
571
- type: 'address',
572
- name: 'validatorAddress',
573
- },
574
- {
575
- type: 'bytes12',
576
- name: 'validatorId',
577
- },
578
- ],
579
- },
580
- ],
581
- functionName: 'removeValidator',
582
- args: [validatorModule.address, validatorId],
583
- }),
28
+ async resolve({ config }) {
29
+ return (0, accounts_1.getModuleUninstallationCalls)(config, moduleData);
30
+ },
584
31
  };
585
32
  }
586
33
  function getModule(module) {
@@ -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"}