@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.
- package/dist/src/accounts/error.d.ts +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +57 -7
- package/dist/src/accounts/index.d.ts +30 -15
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +304 -138
- package/dist/src/accounts/index.test.js +3 -5
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.d.ts +4 -3
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +32 -6
- package/dist/src/accounts/kernel.test.js +41 -19
- package/dist/src/accounts/nexus.d.ts +14 -7
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +191 -34
- package/dist/src/accounts/nexus.test.js +44 -18
- package/dist/src/accounts/safe.d.ts +2 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +88 -58
- package/dist/src/accounts/safe.test.js +40 -14
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +145 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +36 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +125 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +88 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +35 -0
- package/dist/src/accounts/startale.d.ts +20 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +100 -0
- package/dist/src/accounts/startale.test.d.ts +2 -0
- package/dist/src/accounts/startale.test.d.ts.map +1 -0
- package/dist/src/accounts/startale.test.js +92 -0
- package/dist/src/accounts/utils.d.ts +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -38
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +29 -294
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/actions/smart-session.d.ts +6 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +150 -7
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +112 -95
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +34 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +62 -43
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +282 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/types.d.ts +35 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +36 -27
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +357 -103
- package/dist/src/index.d.ts +41 -22
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +199 -65
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +4 -18
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +15 -63
- package/dist/src/modules/index.test.js +9 -26
- package/dist/src/modules/omni-account.d.ts +2 -1
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +3 -1
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +5 -0
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +64 -41
- package/dist/src/modules/validators/core.test.js +7 -7
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -7
- package/dist/src/orchestrator/client.d.ts +4 -4
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +30 -15
- package/dist/src/orchestrator/index.d.ts +2 -3
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/registry.d.ts +1 -23
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +37 -33
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +97 -29
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +74 -10
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +72 -1
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
- package/dist/src/orchestrator/registry.json +0 -365
- /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.
|
|
4
|
-
exports.
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
|
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
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"passkeys.test.d.ts","sourceRoot":"","sources":["../../../actions/passkeys.test.ts"],"names":[],"mappings":""}
|