@rhinestone/sdk 1.0.0-alpha.2 → 1.0.0-alpha.21
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/custom.d.ts +18 -0
- package/dist/src/accounts/custom.d.ts.map +1 -0
- package/dist/src/accounts/custom.js +121 -0
- package/dist/src/accounts/custom.test.d.ts +2 -0
- package/dist/src/accounts/custom.test.d.ts.map +1 -0
- package/dist/src/accounts/custom.test.js +64 -0
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +2 -0
- package/dist/src/accounts/index.d.ts +22 -13
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +192 -186
- package/dist/src/accounts/index.test.js +3 -3
- 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 +2 -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 +9 -10
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -14
- package/dist/src/accounts/kernel.test.js +10 -15
- package/dist/src/accounts/nexus.d.ts +14 -13
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +121 -93
- package/dist/src/accounts/nexus.test.js +13 -14
- package/dist/src/accounts/safe.d.ts +5 -7
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +25 -35
- package/dist/src/accounts/safe.test.js +9 -10
- 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 +142 -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 +29 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +90 -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 +73 -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 +96 -0
- package/dist/src/accounts/utils.d.ts +2 -1
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +7 -0
- package/dist/src/actions/index.d.ts +145 -7
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +373 -23
- package/dist/src/actions/index.test.js +35 -17
- package/dist/src/actions/smart-session.d.ts +8 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/execution/compact.d.ts +130 -3
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +94 -1
- 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 +3 -4
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +35 -80
- package/dist/src/execution/smart-session.d.ts +1 -1
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +12 -17
- package/dist/src/execution/utils.d.ts +19 -14
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +222 -97
- package/dist/src/index.d.ts +17 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +108 -21
- package/dist/src/modules/index.d.ts +3 -22
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +5 -65
- package/dist/src/modules/index.test.js +3 -17
- package/dist/src/modules/omni-account.d.ts +2 -4
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +4 -8
- package/dist/src/modules/read.d.ts +5 -6
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +7 -37
- package/dist/src/modules/validators/core.d.ts +8 -8
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +126 -42
- package/dist/src/modules/validators/core.test.js +7 -7
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +10 -9
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/client.d.ts +5 -3
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +159 -95
- package/dist/src/orchestrator/consts.d.ts +3 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +4 -2
- package/dist/src/orchestrator/index.d.ts +3 -4
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -9
- package/dist/src/orchestrator/registry.d.ts +10 -13
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +75 -395
- package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.test.js +137 -0
- package/dist/src/orchestrator/types.d.ts +78 -16
- 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 +69 -26
- package/dist/src/types.d.ts.map +1 -1
- package/dist/test/consts.d.ts +2 -2
- package/dist/test/consts.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/src/actions/registry.d.ts +0 -7
- package/dist/src/actions/registry.d.ts.map +0 -1
- package/dist/src/actions/registry.js +0 -7
- package/dist/src/actions/registry.test.d.ts.map +0 -1
- package/dist/src/actions/registry.test.js +0 -25
- package/dist/src/modules/registry.d.ts +0 -13
- package/dist/src/modules/registry.d.ts.map +0 -1
- package/dist/src/modules/registry.js +0 -67
- /package/dist/src/{actions → orchestrator}/registry.test.d.ts +0 -0
|
@@ -1,29 +1,167 @@
|
|
|
1
|
-
import { Address, Chain } from 'viem';
|
|
2
|
-
import { RhinestoneAccount } from '..';
|
|
3
|
-
import { WebauthnCredential } from '../modules/validators/core';
|
|
4
|
-
import { Call, OwnerSet, Recovery } from '../types';
|
|
5
|
-
import { trustAttester } from './registry';
|
|
1
|
+
import { type Address, type Chain, type Hex } from 'viem';
|
|
2
|
+
import type { RhinestoneAccount } from '..';
|
|
3
|
+
import { type WebauthnCredential } from '../modules/validators/core';
|
|
4
|
+
import type { Call, OwnableValidatorConfig, OwnerSet, ProviderConfig, Recovery, WebauthnValidatorConfig } from '../types';
|
|
6
5
|
import { encodeSmartSessionSignature } from './smart-session';
|
|
6
|
+
/**
|
|
7
|
+
* Set up social recovery
|
|
8
|
+
* @param rhinestoneAccount Account to set up social recovery on
|
|
9
|
+
* @param guardians Guardians to use for recovery
|
|
10
|
+
* @param threshold Threshold for the guardians
|
|
11
|
+
* @returns Calls to set up social recovery
|
|
12
|
+
*/
|
|
7
13
|
declare function setUpRecovery({ rhinestoneAccount, guardians, threshold, }: {
|
|
8
14
|
rhinestoneAccount: RhinestoneAccount;
|
|
9
15
|
} & Recovery): Call[];
|
|
10
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Recover an account's ownership
|
|
18
|
+
* @param address Account address
|
|
19
|
+
* @param newOwners New owners
|
|
20
|
+
* @param chain Chain to recover ownership on
|
|
21
|
+
* @param provider Provider to use for the recovery
|
|
22
|
+
* @returns Calls to recover ownership
|
|
23
|
+
* @deprecated Use `recoverEcdsaOwnership` or `recoverPasskeyOwnership` instead
|
|
24
|
+
*/
|
|
25
|
+
declare function recover(address: Address, newOwners: OwnerSet, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Enable ECDSA authentication
|
|
28
|
+
* @param rhinestoneAccount Account to enable ECDSA authentication on
|
|
29
|
+
* @param owners Owners to use for authentication
|
|
30
|
+
* @param threshold Threshold for the owners
|
|
31
|
+
* @returns Calls to enable ECDSA authentication
|
|
32
|
+
*/
|
|
11
33
|
declare function enableEcdsa({ rhinestoneAccount, owners, threshold, }: {
|
|
12
34
|
rhinestoneAccount: RhinestoneAccount;
|
|
13
35
|
owners: Address[];
|
|
14
36
|
threshold?: number;
|
|
15
37
|
}): Call[];
|
|
38
|
+
/**
|
|
39
|
+
* Enable passkeys authentication
|
|
40
|
+
* @param rhinestoneAccount Account to enable passkeys authentication on
|
|
41
|
+
* @param pubKey Public key for the passkey
|
|
42
|
+
* @param authenticatorId Authenticator ID for the passkey
|
|
43
|
+
* @returns Calls to enable passkeys authentication
|
|
44
|
+
*/
|
|
16
45
|
declare function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }: {
|
|
17
46
|
rhinestoneAccount: RhinestoneAccount;
|
|
18
47
|
} & WebauthnCredential): Call[];
|
|
48
|
+
/**
|
|
49
|
+
* Disable ECDSA authentication
|
|
50
|
+
* @param rhinestoneAccount Account to disable ECDSA authentication on
|
|
51
|
+
* @returns Calls to disable ECDSA authentication
|
|
52
|
+
*/
|
|
19
53
|
declare function disableEcdsa({ rhinestoneAccount, }: {
|
|
20
54
|
rhinestoneAccount: RhinestoneAccount;
|
|
21
55
|
}): Call[];
|
|
56
|
+
/**
|
|
57
|
+
* Disable passkeys (WebAuthn) authentication
|
|
58
|
+
* @param rhinestoneAccount Account to disable passkeys authentication on
|
|
59
|
+
* @returns Calls to disable passkeys authentication
|
|
60
|
+
*/
|
|
22
61
|
declare function disablePasskeys({ rhinestoneAccount, }: {
|
|
23
62
|
rhinestoneAccount: RhinestoneAccount;
|
|
24
63
|
}): Call[];
|
|
64
|
+
/**
|
|
65
|
+
* Add an ECDSA owner
|
|
66
|
+
* @param owner Owner address
|
|
67
|
+
* @returns Call to add the owner
|
|
68
|
+
*/
|
|
25
69
|
declare function addOwner(owner: Address): Call;
|
|
70
|
+
/**
|
|
71
|
+
* Remove an ECDSA owner
|
|
72
|
+
* @param prevOwner Previous owner address
|
|
73
|
+
* @param ownerToRemove Owner to remove
|
|
74
|
+
* @returns Call to remove the owner
|
|
75
|
+
*/
|
|
26
76
|
declare function removeOwner(prevOwner: Address, ownerToRemove: Address): Call;
|
|
77
|
+
/**
|
|
78
|
+
* Change an account's signer threshold (ECDSA)
|
|
79
|
+
* @param newThreshold New threshold
|
|
80
|
+
* @returns Call to change the threshold
|
|
81
|
+
*/
|
|
27
82
|
declare function changeThreshold(newThreshold: number): Call;
|
|
28
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Add a passkey owner
|
|
85
|
+
* @param pubKeyX Public key X
|
|
86
|
+
* @param pubKeyY Public key Y
|
|
87
|
+
* @param requireUserVerification Whether to require user verification
|
|
88
|
+
* @returns Call to add the passkey owner
|
|
89
|
+
*/
|
|
90
|
+
declare function addPasskeyOwner(pubKeyX: bigint, pubKeyY: bigint, requireUserVerification: boolean): Call;
|
|
91
|
+
/**
|
|
92
|
+
* Remove a passkey owner
|
|
93
|
+
* @param pubKeyX Public key X
|
|
94
|
+
* @param pubKeyY Public key Y
|
|
95
|
+
* @returns Call to remove the passkey owner
|
|
96
|
+
*/
|
|
97
|
+
declare function removePasskeyOwner(pubKeyX: bigint, pubKeyY: bigint): Call;
|
|
98
|
+
/**
|
|
99
|
+
* Change an account's signer threshold (passkey)
|
|
100
|
+
* @param newThreshold New threshold
|
|
101
|
+
* @returns Call to change the threshold
|
|
102
|
+
*/
|
|
103
|
+
declare function changePasskeyThreshold(newThreshold: number): Call;
|
|
104
|
+
/**
|
|
105
|
+
* Recover an account's ownership (ECDSA)
|
|
106
|
+
* @param address Account address
|
|
107
|
+
* @param newOwners New owners
|
|
108
|
+
* @param chain Chain to recover ownership on
|
|
109
|
+
* @param provider Provider to use for the recovery
|
|
110
|
+
* @returns Calls to recover ownership
|
|
111
|
+
*/
|
|
112
|
+
declare function recoverEcdsaOwnership(address: Address, newOwners: OwnableValidatorConfig, chain: Chain, provider?: ProviderConfig, validatorAddress?: Address): Promise<Call[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Recover an account's ownership (Passkey)
|
|
115
|
+
* @param address Account address
|
|
116
|
+
* @param oldCredentials Old credentials to be replaced (with pubKeyX, pubKeyY)
|
|
117
|
+
* @param newOwners New passkey owners
|
|
118
|
+
* @param chain Chain to recover ownership on
|
|
119
|
+
* @param provider Provider to use for the recovery
|
|
120
|
+
* @returns Calls to recover ownership
|
|
121
|
+
*/
|
|
122
|
+
declare function recoverPasskeyOwnership(address: Address, oldCredentials: {
|
|
123
|
+
pubKeyX: bigint;
|
|
124
|
+
pubKeyY: bigint;
|
|
125
|
+
}[], newOwners: WebauthnValidatorConfig, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
|
|
126
|
+
/**
|
|
127
|
+
* Enable multi-factor authentication
|
|
128
|
+
* @param rhinestoneAccount Account to enable multi-factor authentication on
|
|
129
|
+
* @param validators List of validators to use
|
|
130
|
+
* @param threshold Threshold for the validators
|
|
131
|
+
* @returns Calls to enable multi-factor authentication
|
|
132
|
+
*/
|
|
133
|
+
declare function enableMultiFactor({ rhinestoneAccount, validators, threshold, }: {
|
|
134
|
+
rhinestoneAccount: RhinestoneAccount;
|
|
135
|
+
validators: (OwnableValidatorConfig | WebauthnValidatorConfig | null)[];
|
|
136
|
+
threshold?: number;
|
|
137
|
+
}): Call[];
|
|
138
|
+
/**
|
|
139
|
+
* Disable multi-factor authentication
|
|
140
|
+
* @param rhinestoneAccount Account to disable multi-factor authentication on
|
|
141
|
+
* @returns Calls to disable multi-factor authentication
|
|
142
|
+
*/
|
|
143
|
+
declare function disableMultiFactor({ rhinestoneAccount, }: {
|
|
144
|
+
rhinestoneAccount: RhinestoneAccount;
|
|
145
|
+
}): Call[];
|
|
146
|
+
/**
|
|
147
|
+
* Change the multi-factor threshold
|
|
148
|
+
* @param newThreshold New threshold
|
|
149
|
+
* @returns Call to change the threshold
|
|
150
|
+
*/
|
|
151
|
+
declare function changeMultiFactorThreshold(newThreshold: number): Call;
|
|
152
|
+
/**
|
|
153
|
+
* Set a sub-validator (multi-factor)
|
|
154
|
+
* @param id Validator ID
|
|
155
|
+
* @param validator Validator module
|
|
156
|
+
* @returns Call to set the sub-validator
|
|
157
|
+
*/
|
|
158
|
+
declare function setSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
|
|
159
|
+
/**
|
|
160
|
+
* Remove a sub-validator (multi-factor)
|
|
161
|
+
* @param id Validator ID
|
|
162
|
+
* @param validator Validator module
|
|
163
|
+
* @returns Call to remove the sub-validator
|
|
164
|
+
*/
|
|
165
|
+
declare function removeSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
|
|
166
|
+
export { enableEcdsa, enablePasskeys, disableEcdsa, disablePasskeys, addOwner, removeOwner, changeThreshold, addPasskeyOwner, removePasskeyOwner, changePasskeyThreshold, recover, recoverEcdsaOwnership, recoverPasskeyOwnership, setUpRecovery, encodeSmartSessionSignature, enableMultiFactor, disableMultiFactor, changeMultiFactorThreshold, setSubValidator, removeSubValidator, };
|
|
29
167
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.encodeSmartSessionSignature = void 0;
|
|
4
4
|
exports.enableEcdsa = enableEcdsa;
|
|
5
5
|
exports.enablePasskeys = enablePasskeys;
|
|
6
6
|
exports.disableEcdsa = disableEcdsa;
|
|
@@ -8,63 +8,120 @@ exports.disablePasskeys = disablePasskeys;
|
|
|
8
8
|
exports.addOwner = addOwner;
|
|
9
9
|
exports.removeOwner = removeOwner;
|
|
10
10
|
exports.changeThreshold = changeThreshold;
|
|
11
|
+
exports.addPasskeyOwner = addPasskeyOwner;
|
|
12
|
+
exports.removePasskeyOwner = removePasskeyOwner;
|
|
13
|
+
exports.changePasskeyThreshold = changePasskeyThreshold;
|
|
11
14
|
exports.recover = recover;
|
|
15
|
+
exports.recoverEcdsaOwnership = recoverEcdsaOwnership;
|
|
16
|
+
exports.recoverPasskeyOwnership = recoverPasskeyOwnership;
|
|
12
17
|
exports.setUpRecovery = setUpRecovery;
|
|
18
|
+
exports.enableMultiFactor = enableMultiFactor;
|
|
19
|
+
exports.disableMultiFactor = disableMultiFactor;
|
|
20
|
+
exports.changeMultiFactorThreshold = changeMultiFactorThreshold;
|
|
21
|
+
exports.setSubValidator = setSubValidator;
|
|
22
|
+
exports.removeSubValidator = removeSubValidator;
|
|
13
23
|
const viem_1 = require("viem");
|
|
14
24
|
const accounts_1 = require("../accounts");
|
|
25
|
+
const utils_1 = require("../accounts/utils");
|
|
15
26
|
const core_1 = require("../modules/validators/core");
|
|
16
|
-
const registry_1 = require("./registry");
|
|
17
|
-
Object.defineProperty(exports, "trustAttester", { enumerable: true, get: function () { return registry_1.trustAttester; } });
|
|
18
27
|
const smart_session_1 = require("./smart-session");
|
|
19
28
|
Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return smart_session_1.encodeSmartSessionSignature; } });
|
|
29
|
+
/**
|
|
30
|
+
* Set up social recovery
|
|
31
|
+
* @param rhinestoneAccount Account to set up social recovery on
|
|
32
|
+
* @param guardians Guardians to use for recovery
|
|
33
|
+
* @param threshold Threshold for the guardians
|
|
34
|
+
* @returns Calls to set up social recovery
|
|
35
|
+
*/
|
|
20
36
|
function setUpRecovery({ rhinestoneAccount, guardians, threshold = 1, }) {
|
|
21
37
|
const module = (0, core_1.getSocialRecoveryValidator)(guardians, threshold);
|
|
22
38
|
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
23
39
|
return calls;
|
|
24
40
|
}
|
|
25
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Recover an account's ownership
|
|
43
|
+
* @param address Account address
|
|
44
|
+
* @param newOwners New owners
|
|
45
|
+
* @param chain Chain to recover ownership on
|
|
46
|
+
* @param provider Provider to use for the recovery
|
|
47
|
+
* @returns Calls to recover ownership
|
|
48
|
+
* @deprecated Use `recoverEcdsaOwnership` or `recoverPasskeyOwnership` instead
|
|
49
|
+
*/
|
|
50
|
+
async function recover(address, newOwners, chain, provider) {
|
|
26
51
|
switch (newOwners.type) {
|
|
27
52
|
case 'ecdsa': {
|
|
28
|
-
return recoverEcdsaOwnership(address, newOwners, chain);
|
|
53
|
+
return recoverEcdsaOwnership(address, newOwners, chain, provider);
|
|
54
|
+
}
|
|
55
|
+
case 'ecdsa-v0': {
|
|
56
|
+
return recoverEcdsaOwnership(address, newOwners, chain, provider, core_1.OWNABLE_V0_VALIDATOR_ADDRESS);
|
|
29
57
|
}
|
|
30
58
|
case 'passkey': {
|
|
31
59
|
throw new Error('Passkey ownership recovery is not yet supported');
|
|
32
60
|
}
|
|
61
|
+
case 'multi-factor': {
|
|
62
|
+
throw new Error('Multi-factor ownership recovery is not yet supported');
|
|
63
|
+
}
|
|
33
64
|
}
|
|
34
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Enable ECDSA authentication
|
|
68
|
+
* @param rhinestoneAccount Account to enable ECDSA authentication on
|
|
69
|
+
* @param owners Owners to use for authentication
|
|
70
|
+
* @param threshold Threshold for the owners
|
|
71
|
+
* @returns Calls to enable ECDSA authentication
|
|
72
|
+
*/
|
|
35
73
|
function enableEcdsa({ rhinestoneAccount, owners, threshold = 1, }) {
|
|
36
|
-
const module = (0, core_1.getOwnableValidator)(
|
|
37
|
-
threshold,
|
|
38
|
-
owners,
|
|
39
|
-
});
|
|
74
|
+
const module = (0, core_1.getOwnableValidator)(threshold, owners);
|
|
40
75
|
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
41
76
|
return calls;
|
|
42
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Enable passkeys authentication
|
|
80
|
+
* @param rhinestoneAccount Account to enable passkeys authentication on
|
|
81
|
+
* @param pubKey Public key for the passkey
|
|
82
|
+
* @param authenticatorId Authenticator ID for the passkey
|
|
83
|
+
* @returns Calls to enable passkeys authentication
|
|
84
|
+
*/
|
|
43
85
|
function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }) {
|
|
44
|
-
const module = (0, core_1.getWebAuthnValidator)({ pubKey, authenticatorId });
|
|
86
|
+
const module = (0, core_1.getWebAuthnValidator)(1, [{ pubKey, authenticatorId }]);
|
|
45
87
|
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
46
88
|
return calls;
|
|
47
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Disable ECDSA authentication
|
|
92
|
+
* @param rhinestoneAccount Account to disable ECDSA authentication on
|
|
93
|
+
* @returns Calls to disable ECDSA authentication
|
|
94
|
+
*/
|
|
48
95
|
function disableEcdsa({ rhinestoneAccount, }) {
|
|
49
|
-
const module = (0, core_1.getOwnableValidator)(
|
|
50
|
-
threshold: 1,
|
|
51
|
-
owners: [],
|
|
52
|
-
});
|
|
96
|
+
const module = (0, core_1.getOwnableValidator)(1, []);
|
|
53
97
|
const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
|
|
54
98
|
return calls;
|
|
55
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Disable passkeys (WebAuthn) authentication
|
|
102
|
+
* @param rhinestoneAccount Account to disable passkeys authentication on
|
|
103
|
+
* @returns Calls to disable passkeys authentication
|
|
104
|
+
*/
|
|
56
105
|
function disablePasskeys({ rhinestoneAccount, }) {
|
|
57
|
-
const module = (0, core_1.getWebAuthnValidator)(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
106
|
+
const module = (0, core_1.getWebAuthnValidator)(1, [
|
|
107
|
+
{
|
|
108
|
+
// Mocked values
|
|
109
|
+
pubKey: '0x580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1',
|
|
110
|
+
authenticatorId: '0x',
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
62
113
|
const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
|
|
63
114
|
return calls;
|
|
64
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Add an ECDSA owner
|
|
118
|
+
* @param owner Owner address
|
|
119
|
+
* @returns Call to add the owner
|
|
120
|
+
*/
|
|
65
121
|
function addOwner(owner) {
|
|
66
122
|
return {
|
|
67
123
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
124
|
+
value: 0n,
|
|
68
125
|
data: (0, viem_1.encodeFunctionData)({
|
|
69
126
|
abi: [
|
|
70
127
|
{
|
|
@@ -80,9 +137,16 @@ function addOwner(owner) {
|
|
|
80
137
|
}),
|
|
81
138
|
};
|
|
82
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Remove an ECDSA owner
|
|
142
|
+
* @param prevOwner Previous owner address
|
|
143
|
+
* @param ownerToRemove Owner to remove
|
|
144
|
+
* @returns Call to remove the owner
|
|
145
|
+
*/
|
|
83
146
|
function removeOwner(prevOwner, ownerToRemove) {
|
|
84
147
|
return {
|
|
85
148
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
149
|
+
value: 0n,
|
|
86
150
|
data: (0, viem_1.encodeFunctionData)({
|
|
87
151
|
abi: [
|
|
88
152
|
{
|
|
@@ -101,9 +165,102 @@ function removeOwner(prevOwner, ownerToRemove) {
|
|
|
101
165
|
}),
|
|
102
166
|
};
|
|
103
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Change an account's signer threshold (ECDSA)
|
|
170
|
+
* @param newThreshold New threshold
|
|
171
|
+
* @returns Call to change the threshold
|
|
172
|
+
*/
|
|
104
173
|
function changeThreshold(newThreshold) {
|
|
105
174
|
return {
|
|
106
175
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
176
|
+
value: 0n,
|
|
177
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
178
|
+
abi: [
|
|
179
|
+
{
|
|
180
|
+
inputs: [
|
|
181
|
+
{ internalType: 'uint256', name: '_threshold', type: 'uint256' },
|
|
182
|
+
],
|
|
183
|
+
name: 'setThreshold',
|
|
184
|
+
outputs: [],
|
|
185
|
+
stateMutability: 'nonpayable',
|
|
186
|
+
type: 'function',
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
functionName: 'setThreshold',
|
|
190
|
+
args: [BigInt(newThreshold)],
|
|
191
|
+
}),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Add a passkey owner
|
|
196
|
+
* @param pubKeyX Public key X
|
|
197
|
+
* @param pubKeyY Public key Y
|
|
198
|
+
* @param requireUserVerification Whether to require user verification
|
|
199
|
+
* @returns Call to add the passkey owner
|
|
200
|
+
*/
|
|
201
|
+
function addPasskeyOwner(pubKeyX, pubKeyY, requireUserVerification) {
|
|
202
|
+
return {
|
|
203
|
+
to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
|
|
204
|
+
value: 0n,
|
|
205
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
206
|
+
abi: [
|
|
207
|
+
{
|
|
208
|
+
inputs: [
|
|
209
|
+
{ name: 'pubKeyX', type: 'uint256' },
|
|
210
|
+
{ name: 'pubKeyY', type: 'uint256' },
|
|
211
|
+
{
|
|
212
|
+
name: 'requireUserVerification',
|
|
213
|
+
type: 'bool',
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
name: 'addCredential',
|
|
217
|
+
outputs: [],
|
|
218
|
+
stateMutability: 'nonpayable',
|
|
219
|
+
type: 'function',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
functionName: 'addCredential',
|
|
223
|
+
args: [pubKeyX, pubKeyY, requireUserVerification],
|
|
224
|
+
}),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Remove a passkey owner
|
|
229
|
+
* @param pubKeyX Public key X
|
|
230
|
+
* @param pubKeyY Public key Y
|
|
231
|
+
* @returns Call to remove the passkey owner
|
|
232
|
+
*/
|
|
233
|
+
function removePasskeyOwner(pubKeyX, pubKeyY) {
|
|
234
|
+
return {
|
|
235
|
+
to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
|
|
236
|
+
value: 0n,
|
|
237
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
238
|
+
abi: [
|
|
239
|
+
{
|
|
240
|
+
inputs: [
|
|
241
|
+
{ name: 'pubKeyX', type: 'uint256' },
|
|
242
|
+
{ name: 'pubKeyY', type: 'uint256' },
|
|
243
|
+
],
|
|
244
|
+
name: 'removeCredential',
|
|
245
|
+
outputs: [],
|
|
246
|
+
stateMutability: 'nonpayable',
|
|
247
|
+
type: 'function',
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
functionName: 'removeCredential',
|
|
251
|
+
args: [pubKeyX, pubKeyY],
|
|
252
|
+
}),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Change an account's signer threshold (passkey)
|
|
257
|
+
* @param newThreshold New threshold
|
|
258
|
+
* @returns Call to change the threshold
|
|
259
|
+
*/
|
|
260
|
+
function changePasskeyThreshold(newThreshold) {
|
|
261
|
+
return {
|
|
262
|
+
to: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
|
|
263
|
+
value: 0n,
|
|
107
264
|
data: (0, viem_1.encodeFunctionData)({
|
|
108
265
|
abi: [
|
|
109
266
|
{
|
|
@@ -121,16 +278,24 @@ function changeThreshold(newThreshold) {
|
|
|
121
278
|
}),
|
|
122
279
|
};
|
|
123
280
|
}
|
|
124
|
-
|
|
281
|
+
/**
|
|
282
|
+
* Recover an account's ownership (ECDSA)
|
|
283
|
+
* @param address Account address
|
|
284
|
+
* @param newOwners New owners
|
|
285
|
+
* @param chain Chain to recover ownership on
|
|
286
|
+
* @param provider Provider to use for the recovery
|
|
287
|
+
* @returns Calls to recover ownership
|
|
288
|
+
*/
|
|
289
|
+
async function recoverEcdsaOwnership(address, newOwners, chain, provider, validatorAddress) {
|
|
125
290
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
126
291
|
chain,
|
|
127
|
-
transport: (0,
|
|
292
|
+
transport: (0, utils_1.createTransport)(chain, provider),
|
|
128
293
|
});
|
|
129
294
|
// Read the existing config
|
|
130
295
|
const results = await publicClient.multicall({
|
|
131
296
|
contracts: [
|
|
132
297
|
{
|
|
133
|
-
address: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
298
|
+
address: validatorAddress ?? core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
134
299
|
abi: [
|
|
135
300
|
{
|
|
136
301
|
inputs: [
|
|
@@ -152,7 +317,7 @@ async function recoverEcdsaOwnership(address, newOwners, chain) {
|
|
|
152
317
|
args: [address],
|
|
153
318
|
},
|
|
154
319
|
{
|
|
155
|
-
address: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
320
|
+
address: validatorAddress ?? core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
156
321
|
abi: [
|
|
157
322
|
{
|
|
158
323
|
inputs: [
|
|
@@ -211,3 +376,188 @@ async function recoverEcdsaOwnership(address, newOwners, chain) {
|
|
|
211
376
|
}
|
|
212
377
|
return calls;
|
|
213
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Recover an account's ownership (Passkey)
|
|
381
|
+
* @param address Account address
|
|
382
|
+
* @param oldCredentials Old credentials to be replaced (with pubKeyX, pubKeyY)
|
|
383
|
+
* @param newOwners New passkey owners
|
|
384
|
+
* @param chain Chain to recover ownership on
|
|
385
|
+
* @param provider Provider to use for the recovery
|
|
386
|
+
* @returns Calls to recover ownership
|
|
387
|
+
*/
|
|
388
|
+
async function recoverPasskeyOwnership(address, oldCredentials, newOwners, chain, provider) {
|
|
389
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
390
|
+
chain,
|
|
391
|
+
transport: (0, utils_1.createTransport)(chain, provider),
|
|
392
|
+
});
|
|
393
|
+
const existingThreshold = await publicClient.readContract({
|
|
394
|
+
address: core_1.WEBAUTHN_VALIDATOR_ADDRESS,
|
|
395
|
+
abi: [
|
|
396
|
+
{
|
|
397
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
398
|
+
name: 'threshold',
|
|
399
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
400
|
+
stateMutability: 'view',
|
|
401
|
+
type: 'function',
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
functionName: 'threshold',
|
|
405
|
+
args: [address],
|
|
406
|
+
});
|
|
407
|
+
const calls = [];
|
|
408
|
+
// Convert new owners config to credentials and threshold
|
|
409
|
+
const newCredentials = newOwners.accounts.map((account) => {
|
|
410
|
+
const publicKey = account.publicKey;
|
|
411
|
+
// Parse the public key hex string to extract x and y coordinates
|
|
412
|
+
const publicKeyBytes = publicKey.startsWith('0x')
|
|
413
|
+
? publicKey.slice(2)
|
|
414
|
+
: publicKey;
|
|
415
|
+
// The public key is 64 bytes: 32 bytes for x, 32 bytes for y
|
|
416
|
+
const x = BigInt(`0x${publicKeyBytes.slice(0, 64)}`);
|
|
417
|
+
const y = BigInt(`0x${publicKeyBytes.slice(64, 128)}`);
|
|
418
|
+
return {
|
|
419
|
+
pubKeyX: x,
|
|
420
|
+
pubKeyY: y,
|
|
421
|
+
requireUV: false, // Default to false for now
|
|
422
|
+
};
|
|
423
|
+
});
|
|
424
|
+
const newThreshold = newOwners.threshold ?? 1;
|
|
425
|
+
// Check if threshold needs to be updated
|
|
426
|
+
if (Number(existingThreshold) !== newThreshold) {
|
|
427
|
+
calls.push(changePasskeyThreshold(newThreshold));
|
|
428
|
+
}
|
|
429
|
+
// Compare existing and new credentials to determine what to add/remove
|
|
430
|
+
const existingCredentialKeys = oldCredentials.map((cred) => `${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`);
|
|
431
|
+
const newCredentialKeys = newCredentials.map((cred) => `${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`);
|
|
432
|
+
// Find credentials to add (new ones not in existing)
|
|
433
|
+
const credentialsToAdd = newCredentials.filter((cred) => !existingCredentialKeys.includes(`${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`));
|
|
434
|
+
// Find credentials to remove (existing ones not in new)
|
|
435
|
+
const credentialsToRemove = oldCredentials.filter((cred) => !newCredentialKeys.includes(`${cred.pubKeyX.toString()}-${cred.pubKeyY.toString()}`));
|
|
436
|
+
// Remove old credentials first (important for security in recovery scenarios)
|
|
437
|
+
for (const credential of credentialsToRemove) {
|
|
438
|
+
calls.push(removePasskeyOwner(credential.pubKeyX, credential.pubKeyY));
|
|
439
|
+
}
|
|
440
|
+
// Then add new credentials
|
|
441
|
+
for (const credential of credentialsToAdd) {
|
|
442
|
+
calls.push(addPasskeyOwner(credential.pubKeyX, credential.pubKeyY, credential.requireUV));
|
|
443
|
+
}
|
|
444
|
+
return calls;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Enable multi-factor authentication
|
|
448
|
+
* @param rhinestoneAccount Account to enable multi-factor authentication on
|
|
449
|
+
* @param validators List of validators to use
|
|
450
|
+
* @param threshold Threshold for the validators
|
|
451
|
+
* @returns Calls to enable multi-factor authentication
|
|
452
|
+
*/
|
|
453
|
+
function enableMultiFactor({ rhinestoneAccount, validators, threshold = 1, }) {
|
|
454
|
+
const module = (0, core_1.getMultiFactorValidator)(threshold, validators);
|
|
455
|
+
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
456
|
+
return calls;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Disable multi-factor authentication
|
|
460
|
+
* @param rhinestoneAccount Account to disable multi-factor authentication on
|
|
461
|
+
* @returns Calls to disable multi-factor authentication
|
|
462
|
+
*/
|
|
463
|
+
function disableMultiFactor({ rhinestoneAccount, }) {
|
|
464
|
+
const module = (0, core_1.getMultiFactorValidator)(1, []);
|
|
465
|
+
const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
|
|
466
|
+
return calls;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Change the multi-factor threshold
|
|
470
|
+
* @param newThreshold New threshold
|
|
471
|
+
* @returns Call to change the threshold
|
|
472
|
+
*/
|
|
473
|
+
function changeMultiFactorThreshold(newThreshold) {
|
|
474
|
+
return {
|
|
475
|
+
to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
|
|
476
|
+
value: 0n,
|
|
477
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
478
|
+
abi: [
|
|
479
|
+
{
|
|
480
|
+
inputs: [{ internalType: 'uint8', name: 'threshold', type: 'uint8' }],
|
|
481
|
+
name: 'setThreshold',
|
|
482
|
+
outputs: [],
|
|
483
|
+
stateMutability: 'nonpayable',
|
|
484
|
+
type: 'function',
|
|
485
|
+
},
|
|
486
|
+
],
|
|
487
|
+
functionName: 'setThreshold',
|
|
488
|
+
args: [newThreshold],
|
|
489
|
+
}),
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Set a sub-validator (multi-factor)
|
|
494
|
+
* @param id Validator ID
|
|
495
|
+
* @param validator Validator module
|
|
496
|
+
* @returns Call to set the sub-validator
|
|
497
|
+
*/
|
|
498
|
+
function setSubValidator(id, validator) {
|
|
499
|
+
const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
|
|
500
|
+
const validatorModule = (0, core_1.getValidator)(validator);
|
|
501
|
+
return {
|
|
502
|
+
to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
|
|
503
|
+
value: 0n,
|
|
504
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
505
|
+
abi: [
|
|
506
|
+
{
|
|
507
|
+
type: 'function',
|
|
508
|
+
name: 'setValidator',
|
|
509
|
+
inputs: [
|
|
510
|
+
{
|
|
511
|
+
type: 'address',
|
|
512
|
+
name: 'validatorAddress',
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
type: 'bytes12',
|
|
516
|
+
name: 'validatorId',
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
type: 'bytes',
|
|
520
|
+
name: 'newValidatorData',
|
|
521
|
+
},
|
|
522
|
+
],
|
|
523
|
+
},
|
|
524
|
+
],
|
|
525
|
+
functionName: 'setValidator',
|
|
526
|
+
args: [validatorModule.address, validatorId, validatorModule.initData],
|
|
527
|
+
}),
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Remove a sub-validator (multi-factor)
|
|
532
|
+
* @param id Validator ID
|
|
533
|
+
* @param validator Validator module
|
|
534
|
+
* @returns Call to remove the sub-validator
|
|
535
|
+
*/
|
|
536
|
+
function removeSubValidator(id, validator) {
|
|
537
|
+
const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
|
|
538
|
+
const validatorModule = (0, core_1.getValidator)(validator);
|
|
539
|
+
return {
|
|
540
|
+
to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
|
|
541
|
+
value: 0n,
|
|
542
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
543
|
+
abi: [
|
|
544
|
+
{
|
|
545
|
+
type: 'function',
|
|
546
|
+
name: 'removeValidator',
|
|
547
|
+
inputs: [
|
|
548
|
+
{
|
|
549
|
+
type: 'address',
|
|
550
|
+
name: 'validatorAddress',
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
type: 'bytes12',
|
|
554
|
+
name: 'validatorId',
|
|
555
|
+
},
|
|
556
|
+
],
|
|
557
|
+
},
|
|
558
|
+
],
|
|
559
|
+
functionName: 'removeValidator',
|
|
560
|
+
args: [validatorModule.address, validatorId],
|
|
561
|
+
}),
|
|
562
|
+
};
|
|
563
|
+
}
|