@charterlabs/rhinestone-sdk 0.1.12 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +181 -74
- package/dist/src/accounts/index.d.ts +8 -7
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +65 -172
- package/dist/src/accounts/index.test.js +2 -3
- package/dist/src/accounts/kernel.d.ts +3 -2
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -5
- package/dist/src/accounts/kernel.test.js +5 -12
- package/dist/src/accounts/nexus.d.ts +2 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +17 -17
- package/dist/src/accounts/nexus.test.js +11 -14
- 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 +3 -5
- package/dist/src/accounts/safe.test.js +4 -7
- package/dist/src/accounts/signing/common.d.ts +23 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +113 -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 +51 -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 +39 -0
- package/dist/src/accounts/startale.d.ts +2 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +3 -3
- package/dist/src/accounts/startale.test.js +4 -7
- package/dist/src/actions/index.d.ts +84 -0
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +92 -0
- package/dist/src/actions/index.test.js +15 -15
- 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/execution/compact.d.ts +128 -1
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +91 -0
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +2 -3
- package/dist/src/execution/utils.d.ts +6 -5
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +37 -17
- package/dist/src/index.d.ts +8 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +89 -31
- package/dist/src/modules/index.d.ts +3 -8
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +26 -27
- package/dist/src/modules/index.test.js +1 -4
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +19 -14
- package/dist/src/modules/validators/core.test.js +4 -11
- package/dist/src/modules/validators/index.d.ts +1 -2
- package/dist/src/modules/validators/index.d.ts.map +1 -1
- package/dist/src/modules/validators/index.js +1 -13
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/index.d.ts +1 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- 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 +2 -5
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAEV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAMb,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAS5C,iBAAe,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAiB7E;AA+BD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sign = sign;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const modules_1 = require("../../modules");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const common_1 = require("./common");
|
|
8
|
+
async function sign(signers, chain, hash) {
|
|
9
|
+
const signingFunctions = {
|
|
10
|
+
signEcdsa: (account, hash) => signEcdsa(account, hash),
|
|
11
|
+
signPasskey: (account, chain, hash) => signPasskey(account, chain, hash),
|
|
12
|
+
};
|
|
13
|
+
switch (signers.type) {
|
|
14
|
+
case 'owner': {
|
|
15
|
+
return (0, common_1.signWithOwners)(signers, chain, hash, signingFunctions, sign);
|
|
16
|
+
}
|
|
17
|
+
case 'session': {
|
|
18
|
+
return (0, common_1.signWithSession)(signers, chain, hash, sign);
|
|
19
|
+
}
|
|
20
|
+
case 'guardians': {
|
|
21
|
+
return (0, common_1.signWithGuardians)(signers, hash, signingFunctions);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function signEcdsa(account, hash) {
|
|
26
|
+
if (!account.signMessage) {
|
|
27
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
28
|
+
}
|
|
29
|
+
const originalSignature = await account.signMessage({
|
|
30
|
+
message: { raw: hash },
|
|
31
|
+
});
|
|
32
|
+
// Manually tweak the `v` value to trigger the message prefixing onchain
|
|
33
|
+
// https://github.com/rhinestonewtf/checknsignatures/blob/main/src/CheckNSignatures.sol#L53-L61
|
|
34
|
+
const { r, s, v } = (0, viem_1.parseSignature)(originalSignature);
|
|
35
|
+
if (!v) {
|
|
36
|
+
throw new Error('Invalid signature');
|
|
37
|
+
}
|
|
38
|
+
const newV = v + 4n;
|
|
39
|
+
const newSignature = (0, viem_1.concat)([r, s, (0, viem_1.toHex)(newV)]);
|
|
40
|
+
return newSignature;
|
|
41
|
+
}
|
|
42
|
+
async function signPasskey(account, chain, hash) {
|
|
43
|
+
const { webauthn, signature } = await account.sign({ hash });
|
|
44
|
+
const usePrecompiled = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
45
|
+
const encodedSignature = (0, modules_1.getWebauthnValidatorSignature)({
|
|
46
|
+
webauthn,
|
|
47
|
+
signature,
|
|
48
|
+
usePrecompiled,
|
|
49
|
+
});
|
|
50
|
+
return encodedSignature;
|
|
51
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Chain, HashTypedDataParameters, Hex, TypedData } from 'viem';
|
|
2
|
+
import type { SignerSet } from '../../types';
|
|
3
|
+
declare function sign<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(signers: SignerSet, chain: Chain, parameters: HashTypedDataParameters<typedData, primaryType>): Promise<Hex>;
|
|
4
|
+
export { sign };
|
|
5
|
+
//# sourceMappingURL=typedData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedData.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/typedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,KAAK,EACL,uBAAuB,EACvB,GAAG,EACH,SAAS,EACV,MAAM,MAAM,CAAA;AAMb,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAS5C,iBAAe,IAAI,CACjB,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACjE,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,GAAG,MAAM,SAAS,EAEtE,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,GAC1D,OAAO,CAAC,GAAG,CAAC,CAoBd;AAiCD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sign = sign;
|
|
4
|
+
const modules_1 = require("../../modules");
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
async function sign(signers, chain, parameters) {
|
|
8
|
+
const signingFunctions = {
|
|
9
|
+
signEcdsa: (account, params) => signEcdsa(account, params),
|
|
10
|
+
signPasskey: (account, chain, params) => signPasskey(account, chain, params),
|
|
11
|
+
};
|
|
12
|
+
switch (signers.type) {
|
|
13
|
+
case 'owner': {
|
|
14
|
+
return (0, common_1.signWithOwners)(signers, chain, parameters, signingFunctions, sign);
|
|
15
|
+
}
|
|
16
|
+
case 'session': {
|
|
17
|
+
return (0, common_1.signWithSession)(signers, chain, parameters, sign);
|
|
18
|
+
}
|
|
19
|
+
case 'guardians': {
|
|
20
|
+
return (0, common_1.signWithGuardians)(signers, parameters, signingFunctions);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function signEcdsa(account, parameters) {
|
|
25
|
+
if (!account.signTypedData) {
|
|
26
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
27
|
+
}
|
|
28
|
+
return await account.signTypedData(parameters);
|
|
29
|
+
}
|
|
30
|
+
async function signPasskey(account, chain, parameters) {
|
|
31
|
+
const { webauthn, signature } = await account.signTypedData(parameters);
|
|
32
|
+
const usePrecompiled = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
33
|
+
const encodedSignature = (0, modules_1.getWebauthnValidatorSignature)({
|
|
34
|
+
webauthn,
|
|
35
|
+
signature,
|
|
36
|
+
usePrecompiled,
|
|
37
|
+
});
|
|
38
|
+
return encodedSignature;
|
|
39
|
+
}
|
|
@@ -12,9 +12,9 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
12
12
|
};
|
|
13
13
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
14
14
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
15
|
-
declare function
|
|
15
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
16
16
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
17
17
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
18
18
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
19
|
-
export { getInstallData, getAddress,
|
|
19
|
+
export { getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, };
|
|
20
20
|
//# sourceMappingURL=startale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startale.d.ts","sourceRoot":"","sources":["../../../accounts/startale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAatD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,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,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,EACpC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,oKAWlC;AAED,iBAAe,uBAAuB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,oKAUlC;AAED,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInstallData = getInstallData;
|
|
4
4
|
exports.getAddress = getAddress;
|
|
5
|
-
exports.
|
|
5
|
+
exports.packSignature = packSignature;
|
|
6
6
|
exports.getDeployArgs = getDeployArgs;
|
|
7
7
|
exports.getSmartAccount = getSmartAccount;
|
|
8
8
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
@@ -86,8 +86,8 @@ function getAddress(config) {
|
|
|
86
86
|
function getInstallData(module) {
|
|
87
87
|
return (0, nexus_1.getInstallData)(module);
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
90
|
-
return (0, nexus_1.
|
|
89
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
90
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, K1_DEFAULT_VALIDATOR_ADDRESS);
|
|
91
91
|
}
|
|
92
92
|
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
93
93
|
return (0, nexus_1.getSmartAccount)(client, address, owners, validatorAddress, sign, K1_DEFAULT_VALIDATOR_ADDRESS);
|
|
@@ -19,10 +19,10 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
19
19
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
20
20
|
});
|
|
21
21
|
(0, vitest_1.expect)(factory).toEqual('0x0000003B3E7b530b4f981aE80d9350392Defef90');
|
|
22
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
22
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000552a5fae3db7a8f3917c435448f49ba6a9000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003240984b2f700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000020c008719ba9d8aa14c7d07d122cd5e965aa8da5000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da0994869360000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
23
23
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
24
24
|
(0, vitest_1.expect)(implementation).toEqual('0x000000b8f5f723a680d3d7ee624fe0bc84a6e05a');
|
|
25
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
25
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a1419000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000552a5fae3db7a8f3917c435448f49ba6a9000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003240984b2f700000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000020c008719ba9d8aa14c7d07d122cd5e965aa8da5000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da0994869360000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
26
26
|
});
|
|
27
27
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
28
28
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, startale_1.getDeployArgs)({
|
|
@@ -32,7 +32,6 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
32
32
|
owners: {
|
|
33
33
|
type: 'passkey',
|
|
34
34
|
account: consts_1.passkeyAccount,
|
|
35
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
36
35
|
},
|
|
37
36
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
38
37
|
});
|
|
@@ -55,7 +54,7 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
55
54
|
},
|
|
56
55
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
57
56
|
});
|
|
58
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
57
|
+
(0, vitest_1.expect)(address).toEqual('0xf7782b971b6d4c38f99cbb1420993c244f957ed0');
|
|
59
58
|
});
|
|
60
59
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
61
60
|
const address = (0, startale_1.getAddress)({
|
|
@@ -65,7 +64,6 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
65
64
|
owners: {
|
|
66
65
|
type: 'passkey',
|
|
67
66
|
account: consts_1.passkeyAccount,
|
|
68
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
69
67
|
},
|
|
70
68
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
71
69
|
});
|
|
@@ -86,13 +84,12 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
86
84
|
});
|
|
87
85
|
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
88
86
|
(0, vitest_1.test)('Mock signature', async () => {
|
|
89
|
-
const hash = '0xabcd';
|
|
90
87
|
const mockSignature = '0x1234';
|
|
91
88
|
const validator = {
|
|
92
89
|
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
93
90
|
isRoot: true,
|
|
94
91
|
};
|
|
95
|
-
const signature = await (0, startale_1.
|
|
92
|
+
const signature = await (0, startale_1.packSignature)(mockSignature, validator);
|
|
96
93
|
(0, vitest_1.expect)(signature).toEqual('0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb41234');
|
|
97
94
|
});
|
|
98
95
|
});
|
|
@@ -3,37 +3,121 @@ import type { RhinestoneAccount } from '..';
|
|
|
3
3
|
import { type WebauthnCredential } from '../modules/validators/core';
|
|
4
4
|
import type { Call, OwnableValidatorConfig, OwnerSet, ProviderConfig, Recovery, WebauthnValidatorConfig } from '../types';
|
|
5
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
|
+
*/
|
|
6
13
|
declare function setUpRecovery({ rhinestoneAccount, guardians, threshold, }: {
|
|
7
14
|
rhinestoneAccount: RhinestoneAccount;
|
|
8
15
|
} & Recovery): Call[];
|
|
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
|
+
*/
|
|
9
24
|
declare function recover(address: Address, newOwners: OwnerSet, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Enable ECDSA authentication
|
|
27
|
+
* @param rhinestoneAccount Account to enable ECDSA authentication on
|
|
28
|
+
* @param owners Owners to use for authentication
|
|
29
|
+
* @param threshold Threshold for the owners
|
|
30
|
+
* @returns Calls to enable ECDSA authentication
|
|
31
|
+
*/
|
|
10
32
|
declare function enableEcdsa({ rhinestoneAccount, owners, threshold, }: {
|
|
11
33
|
rhinestoneAccount: RhinestoneAccount;
|
|
12
34
|
owners: Address[];
|
|
13
35
|
threshold?: number;
|
|
14
36
|
}): Call[];
|
|
37
|
+
/**
|
|
38
|
+
* Enable passkeys authentication
|
|
39
|
+
* @param rhinestoneAccount Account to enable passkeys authentication on
|
|
40
|
+
* @param pubKey Public key for the passkey
|
|
41
|
+
* @param authenticatorId Authenticator ID for the passkey
|
|
42
|
+
* @returns Calls to enable passkeys authentication
|
|
43
|
+
*/
|
|
15
44
|
declare function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }: {
|
|
16
45
|
rhinestoneAccount: RhinestoneAccount;
|
|
17
46
|
} & WebauthnCredential): Call[];
|
|
47
|
+
/**
|
|
48
|
+
* Disable ECDSA authentication
|
|
49
|
+
* @param rhinestoneAccount Account to disable ECDSA authentication on
|
|
50
|
+
* @returns Calls to disable ECDSA authentication
|
|
51
|
+
*/
|
|
18
52
|
declare function disableEcdsa({ rhinestoneAccount, }: {
|
|
19
53
|
rhinestoneAccount: RhinestoneAccount;
|
|
20
54
|
}): Call[];
|
|
55
|
+
/**
|
|
56
|
+
* Disable passkeys (WebAuthn) authentication
|
|
57
|
+
* @param rhinestoneAccount Account to disable passkeys authentication on
|
|
58
|
+
* @returns Calls to disable passkeys authentication
|
|
59
|
+
*/
|
|
21
60
|
declare function disablePasskeys({ rhinestoneAccount, }: {
|
|
22
61
|
rhinestoneAccount: RhinestoneAccount;
|
|
23
62
|
}): Call[];
|
|
63
|
+
/**
|
|
64
|
+
* Add an ECDSA owner
|
|
65
|
+
* @param owner Owner address
|
|
66
|
+
* @returns Call to add the owner
|
|
67
|
+
*/
|
|
24
68
|
declare function addOwner(owner: Address): Call;
|
|
69
|
+
/**
|
|
70
|
+
* Remove an ECDSA owner
|
|
71
|
+
* @param prevOwner Previous owner address
|
|
72
|
+
* @param ownerToRemove Owner to remove
|
|
73
|
+
* @returns Call to remove the owner
|
|
74
|
+
*/
|
|
25
75
|
declare function removeOwner(prevOwner: Address, ownerToRemove: Address): Call;
|
|
76
|
+
/**
|
|
77
|
+
* Change an account's signer threshold (ECDSA)
|
|
78
|
+
* @param newThreshold New threshold
|
|
79
|
+
* @returns Call to change the threshold
|
|
80
|
+
*/
|
|
26
81
|
declare function changeThreshold(newThreshold: number): Call;
|
|
82
|
+
/**
|
|
83
|
+
* Enable multi-factor authentication
|
|
84
|
+
* @param rhinestoneAccount Account to enable multi-factor authentication on
|
|
85
|
+
* @param validators List of validators to use
|
|
86
|
+
* @param threshold Threshold for the validators
|
|
87
|
+
* @returns Calls to enable multi-factor authentication
|
|
88
|
+
*/
|
|
27
89
|
declare function enableMultiFactor({ rhinestoneAccount, validators, threshold, }: {
|
|
28
90
|
rhinestoneAccount: RhinestoneAccount;
|
|
29
91
|
validators: (OwnableValidatorConfig | WebauthnValidatorConfig | null)[];
|
|
30
92
|
threshold?: number;
|
|
31
93
|
}): Call[];
|
|
94
|
+
/**
|
|
95
|
+
* Disable multi-factor authentication
|
|
96
|
+
* @param rhinestoneAccount Account to disable multi-factor authentication on
|
|
97
|
+
* @returns Calls to disable multi-factor authentication
|
|
98
|
+
*/
|
|
32
99
|
declare function disableMultiFactor({ rhinestoneAccount, }: {
|
|
33
100
|
rhinestoneAccount: RhinestoneAccount;
|
|
34
101
|
}): Call[];
|
|
102
|
+
/**
|
|
103
|
+
* Change the multi-factor threshold
|
|
104
|
+
* @param newThreshold New threshold
|
|
105
|
+
* @returns Call to change the threshold
|
|
106
|
+
*/
|
|
35
107
|
declare function changeMultiFactorThreshold(newThreshold: number): Call;
|
|
108
|
+
/**
|
|
109
|
+
* Set a sub-validator (multi-factor)
|
|
110
|
+
* @param id Validator ID
|
|
111
|
+
* @param validator Validator module
|
|
112
|
+
* @returns Call to set the sub-validator
|
|
113
|
+
*/
|
|
36
114
|
declare function setSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
|
|
115
|
+
/**
|
|
116
|
+
* Remove a sub-validator (multi-factor)
|
|
117
|
+
* @param id Validator ID
|
|
118
|
+
* @param validator Validator module
|
|
119
|
+
* @returns Call to remove the sub-validator
|
|
120
|
+
*/
|
|
37
121
|
declare function removeSubValidator(id: Hex | number, validator: OwnableValidatorConfig | WebauthnValidatorConfig): Call;
|
|
38
122
|
export { enableEcdsa, enablePasskeys, disableEcdsa, disablePasskeys, addOwner, removeOwner, changeThreshold, recover, setUpRecovery, encodeSmartSessionSignature, enableMultiFactor, disableMultiFactor, changeMultiFactorThreshold, setSubValidator, removeSubValidator, };
|
|
39
123
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAGV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AAM3C,OAAO,EAQL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EACV,IAAI,EACJ,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,uBAAuB,EACxB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AAE7D,iBAAS,aAAa,CAAC,EACrB,iBAAiB,EACjB,SAAS,EACT,SAAa,GACd,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,GAAG,QAAQ,UAIX;AAED,iBAAe,OAAO,CACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,KAAK,EAAE,KAAK,EACZ,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,IAAI,EAAE,CAAC,CAYjB;AAED,iBAAS,WAAW,CAAC,EACnB,iBA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,CAAC,sBAAsB,GAAG,uBAAuB,GAAG,IAAI,CAAC,EAAE,CAAA;IACvE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,UAIA;AAED;;;;GAIG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,iBAAiB,GAClB,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,UAIA;AAED;;;;GAIG;AACH,iBAAS,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAkB9D;AAED;;;;;GAKG;AACH,iBAAS,eAAe,CACtB,EAAE,EAAE,GAAG,GAAG,MAAM,EAChB,SAAS,EAAE,sBAAsB,GAAG,uBAAuB,GAC1D,IAAI,CA+BN;AAED;;;;;GAKG;AACH,iBAAS,kBAAkB,CACzB,EAAE,EAAE,GAAG,GAAG,MAAM,EAChB,SAAS,EAAE,sBAAsB,GAAG,uBAAuB,GAC1D,IAAI,CA2BN;AAED,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,WAAW,EACX,eAAe,EACf,OAAO,EACP,aAAa,EACb,2BAA2B,EAC3B,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,GACnB,CAAA"}
|
|
@@ -21,11 +21,26 @@ const utils_1 = require("../accounts/utils");
|
|
|
21
21
|
const core_1 = require("../modules/validators/core");
|
|
22
22
|
const smart_session_1 = require("./smart-session");
|
|
23
23
|
Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return smart_session_1.encodeSmartSessionSignature; } });
|
|
24
|
+
/**
|
|
25
|
+
* Set up social recovery
|
|
26
|
+
* @param rhinestoneAccount Account to set up social recovery on
|
|
27
|
+
* @param guardians Guardians to use for recovery
|
|
28
|
+
* @param threshold Threshold for the guardians
|
|
29
|
+
* @returns Calls to set up social recovery
|
|
30
|
+
*/
|
|
24
31
|
function setUpRecovery({ rhinestoneAccount, guardians, threshold = 1, }) {
|
|
25
32
|
const module = (0, core_1.getSocialRecoveryValidator)(guardians, threshold);
|
|
26
33
|
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
27
34
|
return calls;
|
|
28
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Recover an account's ownership
|
|
38
|
+
* @param address Account address
|
|
39
|
+
* @param newOwners New owners
|
|
40
|
+
* @param chain Chain to recover ownership on
|
|
41
|
+
* @param provider Provider to use for the recovery
|
|
42
|
+
* @returns Calls to recover ownership
|
|
43
|
+
*/
|
|
29
44
|
async function recover(address, newOwners, chain, provider) {
|
|
30
45
|
switch (newOwners.type) {
|
|
31
46
|
case 'ecdsa': {
|
|
@@ -39,21 +54,45 @@ async function recover(address, newOwners, chain, provider) {
|
|
|
39
54
|
}
|
|
40
55
|
}
|
|
41
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Enable ECDSA authentication
|
|
59
|
+
* @param rhinestoneAccount Account to enable ECDSA authentication on
|
|
60
|
+
* @param owners Owners to use for authentication
|
|
61
|
+
* @param threshold Threshold for the owners
|
|
62
|
+
* @returns Calls to enable ECDSA authentication
|
|
63
|
+
*/
|
|
42
64
|
function enableEcdsa({ rhinestoneAccount, owners, threshold = 1, }) {
|
|
43
65
|
const module = (0, core_1.getOwnableValidator)(threshold, owners);
|
|
44
66
|
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
45
67
|
return calls;
|
|
46
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Enable passkeys authentication
|
|
71
|
+
* @param rhinestoneAccount Account to enable passkeys authentication on
|
|
72
|
+
* @param pubKey Public key for the passkey
|
|
73
|
+
* @param authenticatorId Authenticator ID for the passkey
|
|
74
|
+
* @returns Calls to enable passkeys authentication
|
|
75
|
+
*/
|
|
47
76
|
function enablePasskeys({ rhinestoneAccount, pubKey, authenticatorId, }) {
|
|
48
77
|
const module = (0, core_1.getWebAuthnValidator)({ pubKey, authenticatorId });
|
|
49
78
|
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
50
79
|
return calls;
|
|
51
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Disable ECDSA authentication
|
|
83
|
+
* @param rhinestoneAccount Account to disable ECDSA authentication on
|
|
84
|
+
* @returns Calls to disable ECDSA authentication
|
|
85
|
+
*/
|
|
52
86
|
function disableEcdsa({ rhinestoneAccount, }) {
|
|
53
87
|
const module = (0, core_1.getOwnableValidator)(1, []);
|
|
54
88
|
const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
|
|
55
89
|
return calls;
|
|
56
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Disable passkeys (WebAuthn) authentication
|
|
93
|
+
* @param rhinestoneAccount Account to disable passkeys authentication on
|
|
94
|
+
* @returns Calls to disable passkeys authentication
|
|
95
|
+
*/
|
|
57
96
|
function disablePasskeys({ rhinestoneAccount, }) {
|
|
58
97
|
const module = (0, core_1.getWebAuthnValidator)({
|
|
59
98
|
// Mocked values
|
|
@@ -63,6 +102,11 @@ function disablePasskeys({ rhinestoneAccount, }) {
|
|
|
63
102
|
const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
|
|
64
103
|
return calls;
|
|
65
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Add an ECDSA owner
|
|
107
|
+
* @param owner Owner address
|
|
108
|
+
* @returns Call to add the owner
|
|
109
|
+
*/
|
|
66
110
|
function addOwner(owner) {
|
|
67
111
|
return {
|
|
68
112
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
@@ -82,6 +126,12 @@ function addOwner(owner) {
|
|
|
82
126
|
}),
|
|
83
127
|
};
|
|
84
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Remove an ECDSA owner
|
|
131
|
+
* @param prevOwner Previous owner address
|
|
132
|
+
* @param ownerToRemove Owner to remove
|
|
133
|
+
* @returns Call to remove the owner
|
|
134
|
+
*/
|
|
85
135
|
function removeOwner(prevOwner, ownerToRemove) {
|
|
86
136
|
return {
|
|
87
137
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
@@ -104,6 +154,11 @@ function removeOwner(prevOwner, ownerToRemove) {
|
|
|
104
154
|
}),
|
|
105
155
|
};
|
|
106
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Change an account's signer threshold (ECDSA)
|
|
159
|
+
* @param newThreshold New threshold
|
|
160
|
+
* @returns Call to change the threshold
|
|
161
|
+
*/
|
|
107
162
|
function changeThreshold(newThreshold) {
|
|
108
163
|
return {
|
|
109
164
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
@@ -125,6 +180,14 @@ function changeThreshold(newThreshold) {
|
|
|
125
180
|
}),
|
|
126
181
|
};
|
|
127
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Recover an account's ownership (ECDSA)
|
|
185
|
+
* @param address Account address
|
|
186
|
+
* @param newOwners New owners
|
|
187
|
+
* @param chain Chain to recover ownership on
|
|
188
|
+
* @param provider Provider to use for the recovery
|
|
189
|
+
* @returns Calls to recover ownership
|
|
190
|
+
*/
|
|
128
191
|
async function recoverEcdsaOwnership(address, newOwners, chain, provider) {
|
|
129
192
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
130
193
|
chain,
|
|
@@ -215,16 +278,33 @@ async function recoverEcdsaOwnership(address, newOwners, chain, provider) {
|
|
|
215
278
|
}
|
|
216
279
|
return calls;
|
|
217
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Enable multi-factor authentication
|
|
283
|
+
* @param rhinestoneAccount Account to enable multi-factor authentication on
|
|
284
|
+
* @param validators List of validators to use
|
|
285
|
+
* @param threshold Threshold for the validators
|
|
286
|
+
* @returns Calls to enable multi-factor authentication
|
|
287
|
+
*/
|
|
218
288
|
function enableMultiFactor({ rhinestoneAccount, validators, threshold = 1, }) {
|
|
219
289
|
const module = (0, core_1.getMultiFactorValidator)(threshold, validators);
|
|
220
290
|
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
221
291
|
return calls;
|
|
222
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* Disable multi-factor authentication
|
|
295
|
+
* @param rhinestoneAccount Account to disable multi-factor authentication on
|
|
296
|
+
* @returns Calls to disable multi-factor authentication
|
|
297
|
+
*/
|
|
223
298
|
function disableMultiFactor({ rhinestoneAccount, }) {
|
|
224
299
|
const module = (0, core_1.getMultiFactorValidator)(1, []);
|
|
225
300
|
const calls = (0, accounts_1.getModuleUninstallationCalls)(rhinestoneAccount.config, module);
|
|
226
301
|
return calls;
|
|
227
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Change the multi-factor threshold
|
|
305
|
+
* @param newThreshold New threshold
|
|
306
|
+
* @returns Call to change the threshold
|
|
307
|
+
*/
|
|
228
308
|
function changeMultiFactorThreshold(newThreshold) {
|
|
229
309
|
return {
|
|
230
310
|
to: core_1.MULTI_FACTOR_VALIDATOR_ADDRESS,
|
|
@@ -244,6 +324,12 @@ function changeMultiFactorThreshold(newThreshold) {
|
|
|
244
324
|
}),
|
|
245
325
|
};
|
|
246
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Set a sub-validator (multi-factor)
|
|
329
|
+
* @param id Validator ID
|
|
330
|
+
* @param validator Validator module
|
|
331
|
+
* @returns Call to set the sub-validator
|
|
332
|
+
*/
|
|
247
333
|
function setSubValidator(id, validator) {
|
|
248
334
|
const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
|
|
249
335
|
const validatorModule = (0, core_1.getValidator)(validator);
|
|
@@ -276,6 +362,12 @@ function setSubValidator(id, validator) {
|
|
|
276
362
|
}),
|
|
277
363
|
};
|
|
278
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Remove a sub-validator (multi-factor)
|
|
367
|
+
* @param id Validator ID
|
|
368
|
+
* @param validator Validator module
|
|
369
|
+
* @returns Call to remove the sub-validator
|
|
370
|
+
*/
|
|
279
371
|
function removeSubValidator(id, validator) {
|
|
280
372
|
const validatorId = (0, viem_1.padHex)((0, viem_1.toHex)(id), { size: 12 });
|
|
281
373
|
const validatorModule = (0, core_1.getValidator)(validator);
|