@charterlabs/rhinestone-sdk 0.2.4 → 0.2.6
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/index.js +2 -2
- package/dist/src/accounts/nexus.d.ts +2 -1
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +62 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +0 -2
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +0 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +1 -1
- package/dist/src/modules/index.d.ts +2 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +20 -26
- package/dist/src/modules/index.test.js +20 -14
- package/dist/src/modules/validators/core.d.ts +2 -1
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +1 -0
- package/package.json +1 -1
|
@@ -193,7 +193,7 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
193
193
|
}
|
|
194
194
|
case 'nexus': {
|
|
195
195
|
const signature = await signFn(hash);
|
|
196
|
-
return (0, nexus_1.packSignature)(signature, validator, transformSignature);
|
|
196
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, undefined, config, chain);
|
|
197
197
|
}
|
|
198
198
|
case 'kernel': {
|
|
199
199
|
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
@@ -217,7 +217,7 @@ async function getTypedDataPackedSignature(config, signers, chain, validator, pa
|
|
|
217
217
|
}
|
|
218
218
|
case 'nexus': {
|
|
219
219
|
const signature = await signFn(parameters);
|
|
220
|
-
return (0, nexus_1.packSignature)(signature, validator, transformSignature);
|
|
220
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, undefined, config, chain);
|
|
221
221
|
}
|
|
222
222
|
case 'kernel': {
|
|
223
223
|
const address = getAddress(config);
|
|
@@ -3,6 +3,7 @@ import { type SmartAccount, type SmartAccountImplementation } from 'viem/account
|
|
|
3
3
|
import type { Module } from '../modules/common';
|
|
4
4
|
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
5
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
+
import type { Chain } from 'viem';
|
|
6
7
|
import { type ValidatorConfig } from './utils';
|
|
7
8
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
9
|
factory: `0x${string}`;
|
|
@@ -14,7 +15,7 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
14
15
|
};
|
|
15
16
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
16
17
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
17
|
-
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
18
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address, config?: RhinestoneAccountConfig, chain?: Chain): Promise<`0x${string}`>;
|
|
18
19
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
19
20
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
20
21
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAapE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,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,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAEjC,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAgBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;EAwDrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBA4BlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AA8ED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,EACtE,uBAAuB,GAAE,OAAyC,EAClE,MAAM,CAAC,EAAE,uBAAuB,EAChC,KAAK,CAAC,EAAE,KAAK,0BAsBd;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACjC,uBAAuB,GAAE,OAAyC,iEAYnE;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,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,EACjC,uBAAuB,GAAE,OAAyC,iEAwCnE;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,EACjC,uBAAuB,GAAE,OAAyC,iEAcnE;AAqFD,iBAAe,mBAAmB,CAChC,MAAM,EAAE,uBAAuB,EAC/B,GAAG,EAAE,OAAO,0BA0Bb;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,SAAS,EAAE,GAAG;;;GAuCf;AAED,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
|
|
@@ -14,6 +14,7 @@ const account_abstraction_1 = require("viem/account-abstraction");
|
|
|
14
14
|
const modules_1 = require("../modules");
|
|
15
15
|
const validators_1 = require("../modules/validators");
|
|
16
16
|
const core_1 = require("../modules/validators/core");
|
|
17
|
+
const modules_2 = require("../modules");
|
|
17
18
|
const error_1 = require("./error");
|
|
18
19
|
const utils_1 = require("./utils");
|
|
19
20
|
// On-chain Nexus default validator is Ownable. Using this here ensures
|
|
@@ -120,10 +121,70 @@ function getInstallData(module) {
|
|
|
120
121
|
args: [module.type, module.address, module.initData],
|
|
121
122
|
});
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
+
function buildWebAuthnValidatorPayload(encodedWebAuthnAuth, config, chain) {
|
|
125
|
+
// Get the account address
|
|
126
|
+
const accountAddress = getAddress(config);
|
|
127
|
+
// Extract pubKey from config - for passkey owners
|
|
128
|
+
if (config.owners.type !== 'passkey') {
|
|
129
|
+
throw new Error('WebAuthn validator can only be used with passkey owners');
|
|
130
|
+
}
|
|
131
|
+
const { x: pubKeyX, y: pubKeyY } = (0, core_1.parsePublicKey)(config.owners.account.publicKey);
|
|
132
|
+
// Generate credential ID using the same logic as the contract
|
|
133
|
+
const credentialId = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
|
|
134
|
+
{ type: 'uint256', name: 'pubKeyX' },
|
|
135
|
+
{ type: 'uint256', name: 'pubKeyY' },
|
|
136
|
+
{ type: 'address', name: 'account' },
|
|
137
|
+
], [pubKeyX, pubKeyY, accountAddress]));
|
|
138
|
+
// Determine usePrecompile based on chain support
|
|
139
|
+
const usePrecompile = (0, modules_2.isRip7212SupportedNetwork)(chain);
|
|
140
|
+
// Decode the WebAuthnAuth struct that was encoded by getWebauthnValidatorSignature
|
|
141
|
+
const decodedAuth = (0, viem_1.decodeAbiParameters)([
|
|
142
|
+
{
|
|
143
|
+
components: [
|
|
144
|
+
{ type: 'bytes', name: 'authenticatorData' },
|
|
145
|
+
{ type: 'string', name: 'clientDataJSON' },
|
|
146
|
+
{ type: 'uint256', name: 'challengeIndex' },
|
|
147
|
+
{ type: 'uint256', name: 'typeIndex' },
|
|
148
|
+
{ type: 'uint256', name: 'r' },
|
|
149
|
+
{ type: 'uint256', name: 's' },
|
|
150
|
+
],
|
|
151
|
+
type: 'tuple',
|
|
152
|
+
name: 'auth',
|
|
153
|
+
},
|
|
154
|
+
], encodedWebAuthnAuth)[0];
|
|
155
|
+
// Build the payload expected by WebAuthnValidator._validateSignatureWithConfig
|
|
156
|
+
// Format: abi.encode(bytes32[] credIds, bool usePrecompile, WebAuthn.WebAuthnAuth[] auth)
|
|
157
|
+
return (0, viem_1.encodeAbiParameters)([
|
|
158
|
+
{ type: 'bytes32[]', name: 'credIds' },
|
|
159
|
+
{ type: 'bool', name: 'usePrecompile' },
|
|
160
|
+
{
|
|
161
|
+
components: [
|
|
162
|
+
{ type: 'bytes', name: 'authenticatorData' },
|
|
163
|
+
{ type: 'string', name: 'clientDataJSON' },
|
|
164
|
+
{ type: 'uint256', name: 'challengeIndex' },
|
|
165
|
+
{ type: 'uint256', name: 'typeIndex' },
|
|
166
|
+
{ type: 'uint256', name: 'r' },
|
|
167
|
+
{ type: 'uint256', name: 's' },
|
|
168
|
+
],
|
|
169
|
+
type: 'tuple[]',
|
|
170
|
+
name: 'auth',
|
|
171
|
+
},
|
|
172
|
+
], [
|
|
173
|
+
[credentialId], // Single credential ID in array
|
|
174
|
+
usePrecompile,
|
|
175
|
+
[decodedAuth], // Single WebAuthnAuth in array
|
|
176
|
+
]);
|
|
177
|
+
}
|
|
178
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS, config, chain) {
|
|
124
179
|
const validatorAddress = validator.address === defaultValidatorAddress
|
|
125
180
|
? viem_1.zeroAddress
|
|
126
181
|
: validator.address;
|
|
182
|
+
// Special handling for WebAuthn validator
|
|
183
|
+
if (validator.address === core_1.WEBAUTHN_VALIDATOR_ADDRESS && config && chain) {
|
|
184
|
+
const webAuthnPayload = buildWebAuthnValidatorPayload(signature, config, chain);
|
|
185
|
+
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(webAuthnPayload)]);
|
|
186
|
+
return packedSig;
|
|
187
|
+
}
|
|
127
188
|
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
|
|
128
189
|
return packedSig;
|
|
129
190
|
}
|
|
@@ -1 +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;
|
|
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;AA6BD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -41,11 +41,9 @@ async function signEcdsa(account, hash) {
|
|
|
41
41
|
}
|
|
42
42
|
async function signPasskey(account, chain, hash) {
|
|
43
43
|
const { webauthn, signature } = await account.sign({ hash });
|
|
44
|
-
const usePrecompiled = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
45
44
|
const encodedSignature = (0, modules_1.getWebauthnValidatorSignature)({
|
|
46
45
|
webauthn,
|
|
47
46
|
signature,
|
|
48
|
-
usePrecompiled,
|
|
49
47
|
});
|
|
50
48
|
return encodedSignature;
|
|
51
49
|
}
|
|
@@ -1 +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;
|
|
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;AA+BD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -29,11 +29,9 @@ async function signEcdsa(account, parameters) {
|
|
|
29
29
|
}
|
|
30
30
|
async function signPasskey(account, chain, parameters) {
|
|
31
31
|
const { webauthn, signature } = await account.signTypedData(parameters);
|
|
32
|
-
const usePrecompiled = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
33
32
|
const encodedSignature = (0, modules_1.getWebauthnValidatorSignature)({
|
|
34
33
|
webauthn,
|
|
35
34
|
signature,
|
|
36
|
-
usePrecompiled,
|
|
37
35
|
});
|
|
38
36
|
return encodedSignature;
|
|
39
37
|
}
|
|
@@ -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,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAQ1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAa9C,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAuDrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBA4BlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBAErC;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,
|
|
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,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAQ1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAa9C,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAuDrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBA4BlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBAErC;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAUvE;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,oKAUlC;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,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"}
|
|
@@ -87,7 +87,7 @@ function getInstallData(module) {
|
|
|
87
87
|
return (0, nexus_1.getInstallData)(module);
|
|
88
88
|
}
|
|
89
89
|
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
90
|
-
return (0, nexus_1.packSignature)(signature, validator, transformSignature, K1_DEFAULT_VALIDATOR_ADDRESS);
|
|
90
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, K1_DEFAULT_VALIDATOR_ADDRESS, undefined, undefined);
|
|
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);
|
|
@@ -7,12 +7,12 @@ import { getOwnerValidator } from './validators';
|
|
|
7
7
|
interface WebAuthnData {
|
|
8
8
|
authenticatorData: Hex;
|
|
9
9
|
clientDataJSON: string;
|
|
10
|
+
challengeIndex: number | bigint;
|
|
10
11
|
typeIndex: number | bigint;
|
|
11
12
|
}
|
|
12
13
|
interface WebauthnValidatorSignature {
|
|
13
14
|
webauthn: WebAuthnData;
|
|
14
15
|
signature: WebauthnSignature | Hex | Uint8Array;
|
|
15
|
-
usePrecompiled?: boolean;
|
|
16
16
|
}
|
|
17
17
|
interface WebauthnSignature {
|
|
18
18
|
r: bigint;
|
|
@@ -25,7 +25,7 @@ interface ModeleSetup {
|
|
|
25
25
|
hooks: Module[];
|
|
26
26
|
}
|
|
27
27
|
declare function getSetup(config: RhinestoneAccountConfig): ModeleSetup;
|
|
28
|
-
declare function getWebauthnValidatorSignature({ webauthn, signature,
|
|
28
|
+
declare function getWebauthnValidatorSignature({ webauthn, signature, }: WebauthnValidatorSignature): `0x${string}`;
|
|
29
29
|
declare function isRip7212SupportedNetwork(chain: Chain): boolean;
|
|
30
30
|
export { HOOK_ADDRESS, getSetup, getOwnerValidator, getWebauthnValidatorSignature, getOwners, getValidators, isRip7212SupportedNetwork, };
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,KAAK,EA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AG,GAAG,GAAG,UAAU,CAAA;CAChD;AAED,UAAU,iBAAiB;IACzB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,iBAAS,QAAQ,CAAC,MAAM,EAAE,uBAAuB,GAAG,WAAW,CAwD9D;AAED,iBAAS,6BAA6B,CAAC,EACrC,QAAQ,EACR,SAAS,GACV,EAAE,0BAA0B,iBAuC5B;AAED,iBAAS,yBAAyB,CAAC,KAAK,EAAE,KAAK,WAY9C;AAaD,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,6BAA6B,EAC7B,SAAS,EACT,aAAa,EACb,yBAAyB,GAC1B,CAAA"}
|
|
@@ -61,8 +61,8 @@ function getSetup(config) {
|
|
|
61
61
|
hooks,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function getWebauthnValidatorSignature({ webauthn, signature,
|
|
65
|
-
const { authenticatorData, clientDataJSON, typeIndex } = webauthn;
|
|
64
|
+
function getWebauthnValidatorSignature({ webauthn, signature, }) {
|
|
65
|
+
const { authenticatorData, clientDataJSON, challengeIndex, typeIndex } = webauthn;
|
|
66
66
|
let r;
|
|
67
67
|
let s;
|
|
68
68
|
if (typeof signature === 'string' || signature instanceof Uint8Array) {
|
|
@@ -74,35 +74,29 @@ function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled = f
|
|
|
74
74
|
r = signature.r;
|
|
75
75
|
s = signature.s;
|
|
76
76
|
}
|
|
77
|
+
// Return abi-encoded WebAuthnAuth struct (not the full validator payload)
|
|
77
78
|
return (0, viem_1.encodeAbiParameters)([
|
|
78
|
-
{ type: 'bytes', name: 'authenticatorData' },
|
|
79
79
|
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
type: '
|
|
89
|
-
name: '
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
type: 'uint256',
|
|
93
|
-
name: 's',
|
|
80
|
+
components: [
|
|
81
|
+
{ type: 'bytes', name: 'authenticatorData' },
|
|
82
|
+
{ type: 'string', name: 'clientDataJSON' },
|
|
83
|
+
{ type: 'uint256', name: 'challengeIndex' },
|
|
84
|
+
{ type: 'uint256', name: 'typeIndex' },
|
|
85
|
+
{ type: 'uint256', name: 'r' },
|
|
86
|
+
{ type: 'uint256', name: 's' },
|
|
87
|
+
],
|
|
88
|
+
type: 'tuple',
|
|
89
|
+
name: 'auth',
|
|
94
90
|
},
|
|
91
|
+
], [
|
|
95
92
|
{
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
authenticatorData,
|
|
94
|
+
clientDataJSON,
|
|
95
|
+
challengeIndex: typeof challengeIndex === 'bigint' ? challengeIndex : BigInt(challengeIndex),
|
|
96
|
+
typeIndex: typeof typeIndex === 'bigint' ? typeIndex : BigInt(typeIndex),
|
|
97
|
+
r,
|
|
98
|
+
s,
|
|
98
99
|
},
|
|
99
|
-
], [
|
|
100
|
-
authenticatorData,
|
|
101
|
-
clientDataJSON,
|
|
102
|
-
typeof typeIndex === 'bigint' ? typeIndex : BigInt(typeIndex),
|
|
103
|
-
r,
|
|
104
|
-
s,
|
|
105
|
-
usePrecompiled,
|
|
106
100
|
]);
|
|
107
101
|
}
|
|
108
102
|
function isRip7212SupportedNetwork(chain) {
|
|
@@ -87,18 +87,24 @@ const index_1 = require("./index");
|
|
|
87
87
|
});
|
|
88
88
|
vitest_1.test.todo('using the omni account should install the necessary modules');
|
|
89
89
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
// describe('WebAuthn Validator Signature', () => {
|
|
91
|
+
// test('default', () => {
|
|
92
|
+
// const signature = getWebauthnValidatorSignature({
|
|
93
|
+
// webauthn: {
|
|
94
|
+
// authenticatorData:
|
|
95
|
+
// '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000',
|
|
96
|
+
// clientDataJSON:
|
|
97
|
+
// '{"type":"webauthn.get","challenge":"tbxXNFS9X_4Byr1cMwqKrIGB-_30a0QhZ6y7ucM0BOE","origin":"http://localhost:3000","crossOrigin":false, "other_keys_can_be_added_here":"do not compare clientDataJSON against a template. See https://goo.gl/yabPex"}',
|
|
98
|
+
// typeIndex:
|
|
99
|
+
// 44941127272049826721201904734628716258498742255959991581049806490182030242267n,
|
|
100
|
+
// },
|
|
101
|
+
// signature:
|
|
102
|
+
// '0x00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001635bc6d0f68ff895cae8a288ecf7542a6a9cd555df784b73e1e2ea7e9104b1db15e9015d280cb19527881c625fee43fd3a405d5b0d199a8c8e6589a7381209e40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f47b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22746278584e465339585f3442797231634d77714b724947422d5f3330613051685a36793775634d30424f45222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73652c20226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f796162506578227d000000000000000000000000',
|
|
103
|
+
// usePrecompiled: true,
|
|
104
|
+
// })
|
|
105
|
+
// expect(signature).toEqual(
|
|
106
|
+
// '0x00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120635bc6d0f68ff895cae8a288ecf7542a6a9cd555df784b73e1e2ea7e9104b1db00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f47b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22746278584e465339585f3442797231634d77714b724947422d5f3330613051685a36793775634d30424f45222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73652c20226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f796162506578227d000000000000000000000000',
|
|
107
|
+
// )
|
|
108
|
+
// })
|
|
109
|
+
// })
|
|
104
110
|
});
|
|
@@ -20,6 +20,7 @@ declare function getOwnableValidator(threshold: number, owners: Address[]): Modu
|
|
|
20
20
|
declare function getWebAuthnValidator(webAuthnCredential: WebauthnCredential): Module;
|
|
21
21
|
declare function getMultiFactorValidator(threshold: number, validators: (OwnableValidatorConfig | WebauthnValidatorConfig | null)[]): Module;
|
|
22
22
|
declare function getSocialRecoveryValidator(guardians: Account[], threshold?: number): Module;
|
|
23
|
-
|
|
23
|
+
declare function parsePublicKey(publicKey: Hex | Uint8Array): PublicKey;
|
|
24
|
+
export { OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, getOwnerValidator, getOwnableValidator, getWebAuthnValidator, getMultiFactorValidator, getSocialRecoveryValidator, getValidator, getMockSignature, parsePublicKey, };
|
|
24
25
|
export type { WebauthnCredential };
|
|
25
26
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../modules/validators/core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EAKZ,KAAK,GAAG,EAIT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EACV,sBAAsB,EACtB,QAAQ,EACR,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AAEjE,UAAU,SAAS;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,UAAU,kBAAkB;IAC1B,MAAM,EAAE,SAAS,GAAG,GAAG,GAAG,UAAU,CAAA;IACpC,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,QAAA,MAAM,yBAAyB,EAAE,OACa,CAAA;AAC9C,QAAA,MAAM,0BAA0B,EAAE,OACY,CAAA;AAG9C,QAAA,MAAM,8BAA8B,EAAE,OACQ,CAAA;AAO9C,iBAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,UAEzD;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAiDjD;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,QAAQ,UAgBrC;AAED,iBAAS,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAiBzE;AAED,iBAAS,oBAAoB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,MAAM,CA0D5E;AAED,iBAAS,uBAAuB,CAC9B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,CAAC,sBAAsB,GAAG,uBAAuB,GAAG,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AC,sBAAsB,GAAG,uBAAuB,GAAG,IAAI,CAAC,EAAE,GACtE,MAAM,CAgDR;AAED,iBAAS,0BAA0B,CACjC,SAAS,EAAE,OAAO,EAAE,EACpB,SAAS,SAAI,GACZ,MAAM,CAsBR;AAED,iBAAS,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG,SAAS,CAW9D;AAED,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,8BAA8B,EAC9B,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,CAAA;AACD,YAAY,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -8,6 +8,7 @@ exports.getMultiFactorValidator = getMultiFactorValidator;
|
|
|
8
8
|
exports.getSocialRecoveryValidator = getSocialRecoveryValidator;
|
|
9
9
|
exports.getValidator = getValidator;
|
|
10
10
|
exports.getMockSignature = getMockSignature;
|
|
11
|
+
exports.parsePublicKey = parsePublicKey;
|
|
11
12
|
const viem_1 = require("viem");
|
|
12
13
|
const common_1 = require("../common");
|
|
13
14
|
const OWNABLE_VALIDATOR_ADDRESS = '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5';
|