@account-kit/smart-contracts 4.41.0 → 4.42.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/dist/esm/src/ma-v2/account/common/modularAccountV2Base.d.ts +17 -3
- package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js +23 -5
- package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js.map +1 -1
- package/dist/esm/src/ma-v2/account/modularAccountV2.d.ts +15 -1
- package/dist/esm/src/ma-v2/account/modularAccountV2.js +67 -7
- package/dist/esm/src/ma-v2/account/modularAccountV2.js.map +1 -1
- package/dist/esm/src/ma-v2/client/client.d.ts +15 -7
- package/dist/esm/src/ma-v2/client/client.js +23 -7
- package/dist/esm/src/ma-v2/client/client.js.map +1 -1
- package/dist/esm/src/ma-v2/errors.d.ts +22 -0
- package/dist/esm/src/ma-v2/errors.js +44 -0
- package/dist/esm/src/ma-v2/errors.js.map +1 -0
- package/dist/esm/src/ma-v2/index.d.ts +1 -0
- package/dist/esm/src/ma-v2/index.js +1 -0
- package/dist/esm/src/ma-v2/index.js.map +1 -1
- package/dist/esm/src/ma-v2/modules/webauthn-validation/signingMethods.d.ts +36 -0
- package/dist/esm/src/ma-v2/modules/webauthn-validation/signingMethods.js +119 -0
- package/dist/esm/src/ma-v2/modules/webauthn-validation/signingMethods.js.map +1 -0
- package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts +17 -3
- package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts.map +1 -1
- package/dist/types/src/ma-v2/account/modularAccountV2.d.ts +15 -1
- package/dist/types/src/ma-v2/account/modularAccountV2.d.ts.map +1 -1
- package/dist/types/src/ma-v2/client/client.d.ts +15 -7
- package/dist/types/src/ma-v2/client/client.d.ts.map +1 -1
- package/dist/types/src/ma-v2/errors.d.ts +23 -0
- package/dist/types/src/ma-v2/errors.d.ts.map +1 -0
- package/dist/types/src/ma-v2/index.d.ts +1 -0
- package/dist/types/src/ma-v2/index.d.ts.map +1 -1
- package/dist/types/src/ma-v2/modules/webauthn-validation/signingMethods.d.ts +37 -0
- package/dist/types/src/ma-v2/modules/webauthn-validation/signingMethods.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/ma-v2/account/common/modularAccountV2Base.ts +71 -8
- package/src/ma-v2/account/modularAccountV2.ts +115 -9
- package/src/ma-v2/client/client.ts +73 -17
- package/src/ma-v2/errors.ts +33 -0
- package/src/ma-v2/index.ts +1 -0
- package/src/ma-v2/modules/webauthn-validation/signingMethods.ts +158 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Address, type Chain, type Hex, type SignableMessage, type TypedData, type TypedDataDefinition } from "viem";
|
|
2
|
+
import { type ToWebAuthnAccountParameters } from "viem/account-abstraction";
|
|
3
|
+
/**
|
|
4
|
+
* Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { webauthnSigningFunctions } from "@account-kit/smart-contracts";
|
|
10
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
11
|
+
*
|
|
12
|
+
* const messageSigner = webauthnSigningFunctions(credential, getFn, rpId, chain, account.address, account.signerEntity.entityId);
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param {ToWebAuthnAccountParameters} credential the Webauthn public key credential object
|
|
16
|
+
* @param {ToWebAuthnAccountParameters["getFn"]} getFn function to retrieve the WebAuthn credential
|
|
17
|
+
* @param {ToWebAuthnAccountParameters["rpId"]} rpId the relying party ID for the WebAuthn credential
|
|
18
|
+
* @param {Chain} chain Chain object for the signer
|
|
19
|
+
* @param {Address} accountAddress address of the smart account using this signer
|
|
20
|
+
* @param {number} entityId the entity id of the signing validation
|
|
21
|
+
* @param {Hex} deferredActionData optional deferred action data to prepend to the uo signatures
|
|
22
|
+
* @returns {object} an object with methods for signing operations and managing signatures
|
|
23
|
+
*/
|
|
24
|
+
export declare const webauthnSigningFunctions: (credential: ToWebAuthnAccountParameters["credential"], getFn: ToWebAuthnAccountParameters["getFn"], rpId: ToWebAuthnAccountParameters["rpId"], chain: Chain, accountAddress: Address, entityId: number, deferredActionData?: Hex) => {
|
|
25
|
+
id: string;
|
|
26
|
+
publicKey: `0x${string}`;
|
|
27
|
+
getDummySignature: () => Hex;
|
|
28
|
+
sign: ({ hash }: {
|
|
29
|
+
hash: Hex;
|
|
30
|
+
}) => Promise<`0x${string}`>;
|
|
31
|
+
signUserOperationHash: (uoHash: Hex) => Promise<Hex>;
|
|
32
|
+
signMessage({ message }: {
|
|
33
|
+
message: SignableMessage;
|
|
34
|
+
}): Promise<Hex>;
|
|
35
|
+
signTypedData: <const typedData extends TypedData | Record<string, unknown>, primaryType extends keyof typedData | "EIP712Domain" = keyof typedData>(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as WebAuthnP256 from "ox/WebAuthnP256";
|
|
2
|
+
import { concatHex, encodeAbiParameters, hashMessage, hashTypedData, } from "viem";
|
|
3
|
+
import {} from "viem/account-abstraction";
|
|
4
|
+
import { pack1271Signature } from "../../utils.js";
|
|
5
|
+
import { getDefaultWebauthnValidationModuleAddress } from "../utils.js";
|
|
6
|
+
/**
|
|
7
|
+
* Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { webauthnSigningFunctions } from "@account-kit/smart-contracts";
|
|
13
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
14
|
+
*
|
|
15
|
+
* const messageSigner = webauthnSigningFunctions(credential, getFn, rpId, chain, account.address, account.signerEntity.entityId);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param {ToWebAuthnAccountParameters} credential the Webauthn public key credential object
|
|
19
|
+
* @param {ToWebAuthnAccountParameters["getFn"]} getFn function to retrieve the WebAuthn credential
|
|
20
|
+
* @param {ToWebAuthnAccountParameters["rpId"]} rpId the relying party ID for the WebAuthn credential
|
|
21
|
+
* @param {Chain} chain Chain object for the signer
|
|
22
|
+
* @param {Address} accountAddress address of the smart account using this signer
|
|
23
|
+
* @param {number} entityId the entity id of the signing validation
|
|
24
|
+
* @param {Hex} deferredActionData optional deferred action data to prepend to the uo signatures
|
|
25
|
+
* @returns {object} an object with methods for signing operations and managing signatures
|
|
26
|
+
*/
|
|
27
|
+
export const webauthnSigningFunctions = (credential, getFn, rpId, chain, accountAddress, entityId, deferredActionData) => {
|
|
28
|
+
const { id, publicKey } = credential;
|
|
29
|
+
const sign = async ({ hash }) => {
|
|
30
|
+
const { metadata, signature } = await WebAuthnP256.sign({
|
|
31
|
+
credentialId: id,
|
|
32
|
+
getFn,
|
|
33
|
+
challenge: hash,
|
|
34
|
+
rpId,
|
|
35
|
+
});
|
|
36
|
+
return encodeAbiParameters([
|
|
37
|
+
{
|
|
38
|
+
name: "params",
|
|
39
|
+
type: "tuple",
|
|
40
|
+
components: [
|
|
41
|
+
{ name: "authenticatorData", type: "bytes" },
|
|
42
|
+
{ name: "clientDataJSON", type: "string" },
|
|
43
|
+
{ name: "challengeIndex", type: "uint256" },
|
|
44
|
+
{ name: "typeIndex", type: "uint256" },
|
|
45
|
+
{ name: "r", type: "uint256" },
|
|
46
|
+
{ name: "s", type: "uint256" },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
], [
|
|
50
|
+
{
|
|
51
|
+
authenticatorData: metadata.authenticatorData,
|
|
52
|
+
clientDataJSON: metadata.clientDataJSON,
|
|
53
|
+
challengeIndex: BigInt(metadata.challengeIndex),
|
|
54
|
+
typeIndex: BigInt(metadata.typeIndex),
|
|
55
|
+
r: signature.r,
|
|
56
|
+
s: signature.s,
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
id,
|
|
62
|
+
publicKey,
|
|
63
|
+
getDummySignature: () => "0xff000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000",
|
|
64
|
+
sign,
|
|
65
|
+
signUserOperationHash: async (uoHash) => {
|
|
66
|
+
let sig = await sign({ hash: hashMessage({ raw: uoHash }) });
|
|
67
|
+
if (deferredActionData) {
|
|
68
|
+
sig = concatHex([deferredActionData, sig]);
|
|
69
|
+
deferredActionData = undefined;
|
|
70
|
+
}
|
|
71
|
+
return concatHex(["0xff", sig]);
|
|
72
|
+
},
|
|
73
|
+
async signMessage({ message }) {
|
|
74
|
+
const hash = hashTypedData({
|
|
75
|
+
domain: {
|
|
76
|
+
chainId: Number(chain.id),
|
|
77
|
+
verifyingContract: getDefaultWebauthnValidationModuleAddress(chain),
|
|
78
|
+
salt: concatHex([`0x${"00".repeat(12)}`, accountAddress]),
|
|
79
|
+
},
|
|
80
|
+
types: {
|
|
81
|
+
ReplaySafeHash: [{ name: "hash", type: "bytes32" }],
|
|
82
|
+
},
|
|
83
|
+
message: {
|
|
84
|
+
hash: hashMessage(message),
|
|
85
|
+
},
|
|
86
|
+
primaryType: "ReplaySafeHash",
|
|
87
|
+
});
|
|
88
|
+
return pack1271Signature({
|
|
89
|
+
validationSignature: await sign({ hash }),
|
|
90
|
+
entityId,
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
signTypedData: async (typedDataDefinition) => {
|
|
94
|
+
const isDeferredAction = typedDataDefinition?.primaryType === "DeferredAction" &&
|
|
95
|
+
// @ts-expect-error the domain type I think changed in viem, so this is not working correctly (TODO: fix this)
|
|
96
|
+
"verifyingContract" in typedDataDefinition.domain &&
|
|
97
|
+
typedDataDefinition.domain.verifyingContract === accountAddress;
|
|
98
|
+
const hash = await hashTypedData({
|
|
99
|
+
domain: {
|
|
100
|
+
chainId: Number(chain.id),
|
|
101
|
+
verifyingContract: getDefaultWebauthnValidationModuleAddress(chain),
|
|
102
|
+
salt: concatHex([`0x${"00".repeat(12)}`, accountAddress]),
|
|
103
|
+
},
|
|
104
|
+
types: {
|
|
105
|
+
ReplaySafeHash: [{ name: "hash", type: "bytes32" }],
|
|
106
|
+
},
|
|
107
|
+
message: {
|
|
108
|
+
hash: hashTypedData(typedDataDefinition),
|
|
109
|
+
},
|
|
110
|
+
primaryType: "ReplaySafeHash",
|
|
111
|
+
});
|
|
112
|
+
const validationSignature = await sign({ hash });
|
|
113
|
+
return isDeferredAction
|
|
114
|
+
? pack1271Signature({ validationSignature, entityId })
|
|
115
|
+
: validationSignature;
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=signingMethods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signingMethods.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/modules/webauthn-validation/signingMethods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAGL,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,aAAa,GAKd,MAAM,MAAM,CAAC;AACd,OAAO,EAAoC,MAAM,0BAA0B,CAAC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AAiB,CAAC;gBACvB,mBAAmB,EAAE,MAAM,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;gBACzC,QAAQ;aACT,CAAC,CAAC;QACL,CAAC;QAED,aAAa,EAAE,KAAK,EAIlB,mBAAgE,EAClD,EAAE;YAChB,MAAM,gBAAgB,GACpB,mBAAmB,EAAE,WAAW,KAAK,gBAAgB;gBACrD,8GAA8G;gBAC9G,mBAAmB,IAAI,mBAAmB,CAAC,MAAM;gBACjD,mBAAmB,CAAC,MAAM,CAAC,iBAAiB,KAAK,cAAc,CAAC;YAElE,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC;gBAC/B,MAAM,EAAE;oBACN,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,iBAAiB,EAAE,yCAAyC,CAAC,KAAK,CAAC;oBACnE,IAAI,EAAE,SAAS,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;iBAC1D;gBACD,KAAK,EAAE;oBACL,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;iBACpD;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,aAAa,CAAC,mBAAmB,CAAC;iBACzC;gBACD,WAAW,EAAE,gBAAgB;aAC9B,CAAC,CAAC;YAEH,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YAEjD,OAAO,gBAAgB;gBACrB,CAAC,CAAC,iBAAiB,CAAC,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC;gBACtD,CAAC,CAAC,mBAAmB,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import * as WebAuthnP256 from \"ox/WebAuthnP256\";\nimport {\n type Address,\n type Chain,\n concatHex,\n encodeAbiParameters,\n hashMessage,\n hashTypedData,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { type ToWebAuthnAccountParameters } from \"viem/account-abstraction\";\nimport { pack1271Signature } from \"../../utils.js\";\nimport { getDefaultWebauthnValidationModuleAddress } from \"../utils.js\";\n\n/**\n * Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data.\n *\n * @example \n \n * ```ts\n * import { webauthnSigningFunctions } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n *\n * const messageSigner = webauthnSigningFunctions(credential, getFn, rpId, chain, account.address, account.signerEntity.entityId);\n * ```\n *\n * @param {ToWebAuthnAccountParameters} credential the Webauthn public key credential object\n * @param {ToWebAuthnAccountParameters[\"getFn\"]} getFn function to retrieve the WebAuthn credential\n * @param {ToWebAuthnAccountParameters[\"rpId\"]} rpId the relying party ID for the WebAuthn credential\n * @param {Chain} chain Chain object for the signer\n * @param {Address} accountAddress address of the smart account using this signer\n * @param {number} entityId the entity id of the signing validation\n * @param {Hex} deferredActionData optional deferred action data to prepend to the uo signatures\n * @returns {object} an object with methods for signing operations and managing signatures\n */\nexport const webauthnSigningFunctions = (\n credential: ToWebAuthnAccountParameters[\"credential\"],\n getFn: ToWebAuthnAccountParameters[\"getFn\"],\n rpId: ToWebAuthnAccountParameters[\"rpId\"],\n chain: Chain,\n accountAddress: Address,\n entityId: number,\n deferredActionData?: Hex,\n) => {\n const { id, publicKey } = credential;\n\n const sign = async ({ hash }: { hash: Hex }) => {\n const { metadata, signature } = await WebAuthnP256.sign({\n credentialId: id,\n getFn,\n challenge: hash,\n rpId,\n });\n\n return encodeAbiParameters(\n [\n {\n name: \"params\",\n type: \"tuple\",\n components: [\n { name: \"authenticatorData\", type: \"bytes\" },\n { name: \"clientDataJSON\", type: \"string\" },\n { name: \"challengeIndex\", type: \"uint256\" },\n { name: \"typeIndex\", type: \"uint256\" },\n { name: \"r\", type: \"uint256\" },\n { name: \"s\", type: \"uint256\" },\n ],\n },\n ],\n [\n {\n authenticatorData: metadata.authenticatorData,\n clientDataJSON: metadata.clientDataJSON,\n challengeIndex: BigInt(metadata.challengeIndex),\n typeIndex: BigInt(metadata.typeIndex),\n r: signature.r,\n s: signature.s,\n },\n ],\n );\n };\n\n return {\n id,\n publicKey,\n getDummySignature: (): Hex =>\n \"0xff000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000\",\n sign,\n signUserOperationHash: async (uoHash: Hex): Promise<Hex> => {\n let sig = await sign({ hash: hashMessage({ raw: uoHash }) });\n if (deferredActionData) {\n sig = concatHex([deferredActionData, sig]);\n deferredActionData = undefined;\n }\n\n return concatHex([\"0xff\", sig]);\n },\n\n async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {\n const hash = hashTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract: getDefaultWebauthnValidationModuleAddress(chain),\n salt: concatHex([`0x${\"00\".repeat(12)}`, accountAddress]),\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash: hashMessage(message),\n },\n primaryType: \"ReplaySafeHash\",\n });\n\n return pack1271Signature({\n validationSignature: await sign({ hash }),\n entityId,\n });\n },\n\n signTypedData: async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ): Promise<Hex> => {\n const isDeferredAction =\n typedDataDefinition?.primaryType === \"DeferredAction\" &&\n // @ts-expect-error the domain type I think changed in viem, so this is not working correctly (TODO: fix this)\n \"verifyingContract\" in typedDataDefinition.domain &&\n typedDataDefinition.domain.verifyingContract === accountAddress;\n\n const hash = await hashTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract: getDefaultWebauthnValidationModuleAddress(chain),\n salt: concatHex([`0x${\"00\".repeat(12)}`, accountAddress]),\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash: hashTypedData(typedDataDefinition),\n },\n primaryType: \"ReplaySafeHash\",\n });\n\n const validationSignature = await sign({ hash });\n\n return isDeferredAction\n ? pack1271Signature({ validationSignature, entityId })\n : validationSignature;\n },\n };\n};\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type SmartAccountSigner, type SmartContractAccountWithSigner, type ToSmartContractAccountParams } from "@aa-sdk/core";
|
|
1
|
+
import { type SmartAccountSigner, type SmartContractAccountWithSigner, type ToSmartContractAccountParams, type SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import { type Hex, type Address, type Chain, type Transport } from "viem";
|
|
3
|
+
import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
|
|
3
4
|
export declare const executeUserOpSelector: Hex;
|
|
4
5
|
export type SignerEntity = {
|
|
5
6
|
isGlobalValidation: boolean;
|
|
@@ -30,12 +31,25 @@ export type ModularAccountV2<TSigner extends SmartAccountSigner = SmartAccountSi
|
|
|
30
31
|
getValidationData: (args: ValidationDataParams) => Promise<ValidationDataView>;
|
|
31
32
|
encodeCallData: (callData: Hex) => Promise<Hex>;
|
|
32
33
|
};
|
|
33
|
-
export type
|
|
34
|
+
export type WebauthnModularAccountV2 = SmartContractAccount<"ModularAccountV2", "0.7.0"> & {
|
|
35
|
+
params: ToWebAuthnAccountParameters;
|
|
36
|
+
signerEntity: SignerEntity;
|
|
37
|
+
getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;
|
|
38
|
+
getValidationData: (args: ValidationDataParams) => Promise<ValidationDataView>;
|
|
39
|
+
encodeCallData: (callData: Hex) => Promise<Hex>;
|
|
40
|
+
};
|
|
41
|
+
export type CreateMAV2BaseParams<TSigner extends SmartAccountSigner | undefined = SmartAccountSigner | undefined, TTransport extends Transport = Transport> = Omit<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "encodeExecute" | "encodeBatchExecute" | "getNonce" | "signMessage" | "signTypedData" | "getDummySignature" | "prepareSign" | "formatSign"> & {
|
|
34
42
|
signer: TSigner;
|
|
35
43
|
signerEntity?: SignerEntity;
|
|
36
44
|
accountAddress: Address;
|
|
37
45
|
deferredAction?: Hex;
|
|
38
46
|
};
|
|
47
|
+
export type CreateWebauthnMAV2BaseParams = Omit<CreateMAV2BaseParams, "signer"> & {
|
|
48
|
+
credential: ToWebAuthnAccountParameters["credential"];
|
|
49
|
+
getFn?: ToWebAuthnAccountParameters["getFn"] | undefined;
|
|
50
|
+
rpId?: ToWebAuthnAccountParameters["rpId"] | undefined;
|
|
51
|
+
};
|
|
39
52
|
export type CreateMAV2BaseReturnType<TSigner extends SmartAccountSigner = SmartAccountSigner> = Promise<ModularAccountV2<TSigner>>;
|
|
40
|
-
export declare function createMAv2Base
|
|
53
|
+
export declare function createMAv2Base(config: CreateWebauthnMAV2BaseParams): Promise<WebauthnModularAccountV2>;
|
|
54
|
+
export declare function createMAv2Base<TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateMAV2BaseParams): CreateMAV2BaseReturnType<TSigner>;
|
|
41
55
|
//# sourceMappingURL=modularAccountV2Base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modularAccountV2Base.d.ts","sourceRoot":"","sources":["../../../../../../src/ma-v2/account/common/modularAccountV2Base.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,
|
|
1
|
+
{"version":3,"file":"modularAccountV2Base.d.ts","sourceRoot":"","sources":["../../../../../../src/ma-v2/account/common/modularAccountV2Base.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,SAAS,EAOf,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAG5E,eAAO,MAAM,qBAAqB,EAAE,GAAkB,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,cAAc,EAAE,SAAS,GAAG,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,SAAS,GAAG,EAAE,CAAC;IAChC,cAAc,EAAE,SAAS,GAAG,EAAE,CAAC;IAC/B,SAAS,EAAE,SAAS,GAAG,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B;IACE,uBAAuB,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,uBAAuB,CAAC,EAAE,KAAK,CAAC;IAChC,QA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,YAAY,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,GAAG,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,oBAAoB,EACpB,QAAQ,CACT,GAAG;IACF,UAAU,EAAE,2BAA2B,CAAC,YAAY,CAAC,CAAC;IACtD,KAAK,CAAC,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IACzD,IAAI,CAAC,EAAE,2BAA2B,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAClC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,IACrD,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAGvC,wBAAsB,cAAc,CAClC,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAErC,wBAAsB,cAAc,CAClC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EACvD,MAAM,EAAE,oBAAoB,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EntryPointDef, SmartAccountSigner, ToSmartContractAccountParams } from "@aa-sdk/core";
|
|
2
2
|
import { type Address, type Chain, type Hex, type Transport } from "viem";
|
|
3
|
-
import { type SignerEntity, type ModularAccountV2 } from "./common/modularAccountV2Base.js";
|
|
3
|
+
import { type SignerEntity, type ModularAccountV2, type WebauthnModularAccountV2 } from "./common/modularAccountV2Base.js";
|
|
4
|
+
import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
|
|
4
5
|
export type CreateModularAccountV2Params<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = (Pick<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "transport" | "chain" | "accountAddress"> & {
|
|
5
6
|
signer: TSigner;
|
|
6
7
|
entryPoint?: EntryPointDef<"0.7.0", Chain>;
|
|
@@ -15,5 +16,18 @@ export type CreateModularAccountV2Params<TTransport extends Transport = Transpor
|
|
|
15
16
|
} | {
|
|
16
17
|
mode: "7702";
|
|
17
18
|
});
|
|
19
|
+
export type CreateWebauthnModularAccountV2Params<TTransport extends Transport = Transport> = Pick<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "transport" | "chain" | "accountAddress"> & {
|
|
20
|
+
mode: "webauthn";
|
|
21
|
+
credential: ToWebAuthnAccountParameters["credential"];
|
|
22
|
+
getFn?: ToWebAuthnAccountParameters["getFn"] | undefined;
|
|
23
|
+
rpId?: ToWebAuthnAccountParameters["rpId"] | undefined;
|
|
24
|
+
entryPoint?: EntryPointDef<"0.7.0", Chain>;
|
|
25
|
+
deferredAction?: Hex;
|
|
26
|
+
signerEntity?: SignerEntity;
|
|
27
|
+
salt?: bigint;
|
|
28
|
+
factoryAddress?: Address;
|
|
29
|
+
initCode?: Hex;
|
|
30
|
+
};
|
|
18
31
|
export declare function createModularAccountV2<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateModularAccountV2Params<TTransport, TSigner>): Promise<ModularAccountV2<TSigner>>;
|
|
32
|
+
export declare function createModularAccountV2<TTransport extends Transport = Transport>(config: CreateWebauthnModularAccountV2Params<TTransport>): Promise<WebauthnModularAccountV2>;
|
|
19
33
|
//# sourceMappingURL=modularAccountV2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modularAccountV2.d.ts","sourceRoot":"","sources":["../../../../../src/ma-v2/account/modularAccountV2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"modularAccountV2.d.ts","sourceRoot":"","sources":["../../../../../src/ma-v2/account/modularAccountV2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAC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,UAAU,EAAE,2BAA2B,CAAC,YAAY,CAAC,CAAC;IACtD,KAAK,CAAC,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IACzD,IAAI,CAAC,EAAE,2BAA2B,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACvD,UAAU,CAAC,EAAE,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EAEvD,MAAM,EAAE,4BAA4B,CAAC,UAAU,EAAE,OAAO,CAAC,GACxD,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEtC,wBAAsB,sBAAsB,CAC1C,UAAU,SAAS,SAAS,GAAG,SAAS,EAExC,MAAM,EAAE,oCAAoC,CAAC,UAAU,CAAC,GACvD,OAAO,CAAC,wBAAwB,CAAC,CAAC"}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { type SmartAccountClient, type
|
|
1
|
+
import { type SmartAccountClient, type SmartAccountClientConfig, type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type Chain, type Transport } from "viem";
|
|
3
|
-
import { type CreateModularAccountV2Params } from "../account/modularAccountV2.js";
|
|
4
|
-
import { type AlchemySmartAccountClientConfig, type AlchemyTransport } from "@account-kit/infra";
|
|
3
|
+
import { type CreateModularAccountV2Params, type CreateWebauthnModularAccountV2Params } from "../account/modularAccountV2.js";
|
|
4
|
+
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig, type AlchemyTransport } from "@account-kit/infra";
|
|
5
5
|
import type { LightAccount } from "../../light-account/accounts/account.js";
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
export type
|
|
6
|
+
import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
|
|
7
|
+
import type { ModularAccountV2, WebauthnModularAccountV2 } from "../account/common/modularAccountV2Base.js";
|
|
8
|
+
export type ModularAccountV2Client<TSigner extends SmartAccountSigner = SmartAccountSigner, TChain extends Chain = Chain, TTransport extends Transport | AlchemyTransport = Transport> = TTransport extends AlchemyTransport ? AlchemySmartAccountClient<TChain, ModularAccountV2<TSigner>> : SmartAccountClient<TTransport, TChain, ModularAccountV2<TSigner>>;
|
|
9
|
+
export type WebauthnModularAccountV2Client<TChain extends Chain = Chain, TTransport extends Transport | AlchemyTransport = Transport> = TTransport extends AlchemyTransport ? AlchemySmartAccountClient<TChain, WebauthnModularAccountV2> : SmartAccountClient<TTransport, TChain, WebauthnModularAccountV2>;
|
|
10
|
+
export type CreateModularAccountV2ClientParams<TTransport extends Transport | AlchemyTransport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = CreateModularAccountV2Params<TTransport, TSigner> & Omit<TTransport extends AlchemyTransport ? AlchemySmartAccountClientConfig<TChain> : SmartAccountClientConfig<TTransport, TChain>, "transport" | "account" | "chain">;
|
|
11
|
+
export type CreateWebauthnModularAccountV2ClientParams<TTransport extends Transport | AlchemyTransport = Transport, TChain extends Chain = Chain> = CreateWebauthnModularAccountV2Params<TTransport> & Omit<TTransport extends AlchemyTransport ? AlchemySmartAccountClientConfig<TChain> : SmartAccountClientConfig<TTransport, TChain>, "transport" | "account" | "chain"> & {
|
|
12
|
+
credential: ToWebAuthnAccountParameters["credential"];
|
|
13
|
+
getFn?: ToWebAuthnAccountParameters["getFn"];
|
|
14
|
+
rpId?: ToWebAuthnAccountParameters["rpId"];
|
|
15
|
+
};
|
|
9
16
|
export type CreateModularAccountV2AlchemyClientParams<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>, "account"> & {
|
|
10
17
|
paymasterAndData?: never;
|
|
11
18
|
dummyPaymasterAndData?: never;
|
|
12
19
|
};
|
|
13
20
|
export declare function createModularAccountV2Client<TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateModularAccountV2AlchemyClientParams<AlchemyTransport, TChain, TSigner>): Promise<ModularAccountV2Client<TSigner, TChain, AlchemyTransport>>;
|
|
14
|
-
export declare function createModularAccountV2Client<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>
|
|
21
|
+
export declare function createModularAccountV2Client<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>): Promise<ModularAccountV2Client<TSigner, TChain, TTransport>>;
|
|
22
|
+
export declare function createModularAccountV2Client<TTransport extends Transport = Transport, TChain extends Chain = Chain>(args: CreateWebauthnModularAccountV2ClientParams<TTransport, TChain>): Promise<WebauthnModularAccountV2Client<TChain, TTransport>>;
|
|
15
23
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/ma-v2/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/ma-v2/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,M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AAE,gBAAgB,CAAC,CAAC,CAAC;AAEtE,wBAAgB,4BAA4B,CAC1C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,KAAK,EAC5B,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EAEvD,IAAI,EAAE,kCAAkC,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,GACpE,OAAO,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAEhE,wBAAgB,4BAA4B,CAC1C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,KAAK,EAE5B,IAAI,EAAE,0CAA0C,CAAC,UAAU,EAAE,MAAM,CAAC,GACnE,OAAO,CAAC,8BAA8B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseError } from "@aa-sdk/core";
|
|
2
|
+
/**
|
|
3
|
+
* Error when Webauthn credentials are not passed to Webauthn Modular Account V2
|
|
4
|
+
*/
|
|
5
|
+
export declare class WebauthnCredentialsRequiredError extends BaseError {
|
|
6
|
+
name: string;
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error when a signer is not passed to 7702 version of Modular Account V2
|
|
11
|
+
*/
|
|
12
|
+
export declare class SignerRequiredFor7702Error extends BaseError {
|
|
13
|
+
name: string;
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Error when a signer is not passed to default Modular Account V2
|
|
18
|
+
*/
|
|
19
|
+
export declare class SignerRequiredForDefaultError extends BaseError {
|
|
20
|
+
name: string;
|
|
21
|
+
constructor();
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/ma-v2/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AACH,qBAAa,gCAAiC,SAAQ,SAAS;IACpD,IAAI,SAAsC;;CAMpD;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IAC9C,IAAI,SAAgC;;CAI9C;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,SAAS;IACjD,IAAI,SAAmC;;CAIjD"}
|
|
@@ -26,4 +26,5 @@ export { SingleSignerValidationModule } from "./modules/single-signer-validation
|
|
|
26
26
|
export { timeRangeModuleAbi } from "./modules/time-range-module/abis/timeRangeModuleAbi.js";
|
|
27
27
|
export { TimeRangeModule } from "./modules/time-range-module/module.js";
|
|
28
28
|
export { webauthnValidationModuleAbi } from "./modules/webauthn-validation/abis/webauthnValidationAbi.js";
|
|
29
|
+
export { WebAuthnValidationModule } from "./modules/webauthn-validation/module.js";
|
|
29
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ma-v2/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,mBAAmB,mD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C;AAC7H,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6DAA6D,CAAC;AAC1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Address, type Chain, type Hex, type SignableMessage, type TypedData, type TypedDataDefinition } from "viem";
|
|
2
|
+
import { type ToWebAuthnAccountParameters } from "viem/account-abstraction";
|
|
3
|
+
/**
|
|
4
|
+
* Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { webauthnSigningFunctions } from "@account-kit/smart-contracts";
|
|
10
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
11
|
+
*
|
|
12
|
+
* const messageSigner = webauthnSigningFunctions(credential, getFn, rpId, chain, account.address, account.signerEntity.entityId);
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param {ToWebAuthnAccountParameters} credential the Webauthn public key credential object
|
|
16
|
+
* @param {ToWebAuthnAccountParameters["getFn"]} getFn function to retrieve the WebAuthn credential
|
|
17
|
+
* @param {ToWebAuthnAccountParameters["rpId"]} rpId the relying party ID for the WebAuthn credential
|
|
18
|
+
* @param {Chain} chain Chain object for the signer
|
|
19
|
+
* @param {Address} accountAddress address of the smart account using this signer
|
|
20
|
+
* @param {number} entityId the entity id of the signing validation
|
|
21
|
+
* @param {Hex} deferredActionData optional deferred action data to prepend to the uo signatures
|
|
22
|
+
* @returns {object} an object with methods for signing operations and managing signatures
|
|
23
|
+
*/
|
|
24
|
+
export declare const webauthnSigningFunctions: (credential: ToWebAuthnAccountParameters["credential"], getFn: ToWebAuthnAccountParameters["getFn"], rpId: ToWebAuthnAccountParameters["rpId"], chain: Chain, accountAddress: Address, entityId: number, deferredActionData?: Hex) => {
|
|
25
|
+
id: string;
|
|
26
|
+
publicKey: `0x${string}`;
|
|
27
|
+
getDummySignature: () => Hex;
|
|
28
|
+
sign: ({ hash }: {
|
|
29
|
+
hash: Hex;
|
|
30
|
+
}) => Promise<`0x${string}`>;
|
|
31
|
+
signUserOperationHash: (uoHash: Hex) => Promise<Hex>;
|
|
32
|
+
signMessage({ message }: {
|
|
33
|
+
message: SignableMessage;
|
|
34
|
+
}): Promise<Hex>;
|
|
35
|
+
signTypedData: <const typedData extends TypedData | Record<string, unknown>, primaryType extends keyof typedData | "EIP712Domain" = keyof typedData>(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=signingMethods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signingMethods.d.ts","sourceRoot":"","sources":["../../../../../../src/ma-v2/modules/webauthn-validation/signingMethods.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAKV,KAAK,GAAG,EACR,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAI5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,GACnC,YAAY,2BAA2B,CAAC,YAAY,CAAC,EACrD,OAAO,2BAA2B,CAAC,OAAO,CAAC,EAC3C,MAAM,2BAA2B,CAAC,MAAM,CAAC,EACzC,OAAO,KAAK,EACZ,gBAAgB,OAAO,EACvB,UAAU,MAAM,EAChB,qBAAqB,GAAG;;;6BA2CC,GAAG;qBAvCE;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE;oCA0CH,GAAG,KAAG,OAAO,CAAC,GAAG,CAAC;6BAUzB;QAAE,OAAO,EAAE,eAAe,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;0BAuBlE,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,yCAE/B,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,KAC/D,OAAO,CAAC,GAAG,CAAC;CA6BlB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/smart-contracts",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.42.0",
|
|
4
4
|
"description": "aa-sdk compatible interfaces for Alchemy Smart Accounts",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"test:run": "vitest run"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@account-kit/plugingen": "^4.
|
|
55
|
+
"@account-kit/plugingen": "^4.42.0",
|
|
56
56
|
"change-case": "^5.1.2",
|
|
57
57
|
"dedent": "^1.5.1",
|
|
58
58
|
"dotenv": "^16.3.1",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
71
71
|
},
|
|
72
72
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "924c688a7ac5de77c453cc1b1fce41f6bbf02dce",
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@aa-sdk/core": "^4.
|
|
76
|
-
"@account-kit/infra": "^4.
|
|
75
|
+
"@aa-sdk/core": "^4.42.0",
|
|
76
|
+
"@account-kit/infra": "^4.42.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"viem": "2.29.2"
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type SmartAccountSigner,
|
|
10
10
|
type SmartContractAccountWithSigner,
|
|
11
11
|
type ToSmartContractAccountParams,
|
|
12
|
+
type SmartContractAccount,
|
|
12
13
|
} from "@aa-sdk/core";
|
|
13
14
|
import { DEFAULT_OWNER_ENTITY_ID, parseDeferredAction } from "../../utils.js";
|
|
14
15
|
import {
|
|
@@ -27,6 +28,8 @@ import { modularAccountAbi } from "../../abis/modularAccountAbi.js";
|
|
|
27
28
|
import { serializeModuleEntity } from "../../actions/common/utils.js";
|
|
28
29
|
import { nativeSMASigner } from "../nativeSMASigner.js";
|
|
29
30
|
import { singleSignerMessageSigner } from "../../modules/single-signer-validation/signer.js";
|
|
31
|
+
import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
|
|
32
|
+
import { webauthnSigningFunctions } from "../../modules/webauthn-validation/signingMethods.js";
|
|
30
33
|
|
|
31
34
|
export const executeUserOpSelector: Hex = "0x8DD7712F";
|
|
32
35
|
|
|
@@ -70,8 +73,23 @@ export type ModularAccountV2<
|
|
|
70
73
|
encodeCallData: (callData: Hex) => Promise<Hex>;
|
|
71
74
|
};
|
|
72
75
|
|
|
76
|
+
export type WebauthnModularAccountV2 = SmartContractAccount<
|
|
77
|
+
"ModularAccountV2",
|
|
78
|
+
"0.7.0"
|
|
79
|
+
> & {
|
|
80
|
+
params: ToWebAuthnAccountParameters;
|
|
81
|
+
signerEntity: SignerEntity;
|
|
82
|
+
getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;
|
|
83
|
+
getValidationData: (
|
|
84
|
+
args: ValidationDataParams,
|
|
85
|
+
) => Promise<ValidationDataView>;
|
|
86
|
+
encodeCallData: (callData: Hex) => Promise<Hex>;
|
|
87
|
+
};
|
|
88
|
+
|
|
73
89
|
export type CreateMAV2BaseParams<
|
|
74
|
-
TSigner extends SmartAccountSigner =
|
|
90
|
+
TSigner extends SmartAccountSigner | undefined =
|
|
91
|
+
| SmartAccountSigner
|
|
92
|
+
| undefined,
|
|
75
93
|
TTransport extends Transport = Transport,
|
|
76
94
|
> = Omit<
|
|
77
95
|
ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">,
|
|
@@ -91,17 +109,36 @@ export type CreateMAV2BaseParams<
|
|
|
91
109
|
deferredAction?: Hex;
|
|
92
110
|
};
|
|
93
111
|
|
|
112
|
+
export type CreateWebauthnMAV2BaseParams = Omit<
|
|
113
|
+
CreateMAV2BaseParams,
|
|
114
|
+
"signer"
|
|
115
|
+
> & {
|
|
116
|
+
credential: ToWebAuthnAccountParameters["credential"];
|
|
117
|
+
getFn?: ToWebAuthnAccountParameters["getFn"] | undefined;
|
|
118
|
+
rpId?: ToWebAuthnAccountParameters["rpId"] | undefined;
|
|
119
|
+
};
|
|
120
|
+
|
|
94
121
|
export type CreateMAV2BaseReturnType<
|
|
95
122
|
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
96
123
|
> = Promise<ModularAccountV2<TSigner>>;
|
|
97
124
|
|
|
125
|
+
// function overload
|
|
126
|
+
export async function createMAv2Base(
|
|
127
|
+
config: CreateWebauthnMAV2BaseParams,
|
|
128
|
+
): Promise<WebauthnModularAccountV2>;
|
|
129
|
+
|
|
130
|
+
export async function createMAv2Base<
|
|
131
|
+
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
132
|
+
>(config: CreateMAV2BaseParams): CreateMAV2BaseReturnType<TSigner>;
|
|
133
|
+
|
|
98
134
|
export async function createMAv2Base<
|
|
99
135
|
TSigner extends SmartAccountSigner = SmartAccountSigner,
|
|
100
|
-
>(
|
|
136
|
+
>(
|
|
137
|
+
config: CreateMAV2BaseParams<TSigner> | CreateWebauthnMAV2BaseParams,
|
|
138
|
+
): Promise<WebauthnModularAccountV2 | ModularAccountV2<TSigner>> {
|
|
101
139
|
let {
|
|
102
140
|
transport,
|
|
103
141
|
chain,
|
|
104
|
-
signer,
|
|
105
142
|
entryPoint = getEntryPoint(chain, { version: "0.7.0" }),
|
|
106
143
|
signerEntity = {
|
|
107
144
|
isGlobalValidation: true,
|
|
@@ -116,6 +153,11 @@ export async function createMAv2Base<
|
|
|
116
153
|
...remainingToSmartContractAccountParams
|
|
117
154
|
} = config;
|
|
118
155
|
|
|
156
|
+
const signer = "signer" in config ? config.signer : undefined;
|
|
157
|
+
const credential = "credential" in config ? config.credential : undefined;
|
|
158
|
+
const getFn = "getFn" in config ? config.getFn : undefined;
|
|
159
|
+
const rpId = "rpId" in config ? config.rpId : undefined;
|
|
160
|
+
|
|
119
161
|
if (entityId > Number(maxUint32)) {
|
|
120
162
|
throw new InvalidEntityIdError(entityId);
|
|
121
163
|
}
|
|
@@ -275,10 +317,21 @@ export async function createMAv2Base<
|
|
|
275
317
|
encodeExecute,
|
|
276
318
|
encodeBatchExecute,
|
|
277
319
|
getNonce,
|
|
278
|
-
...(
|
|
279
|
-
?
|
|
280
|
-
|
|
281
|
-
|
|
320
|
+
...(signer
|
|
321
|
+
? entityId === DEFAULT_OWNER_ENTITY_ID
|
|
322
|
+
? nativeSMASigner(signer, chain, accountAddress, deferredActionData)
|
|
323
|
+
: singleSignerMessageSigner(
|
|
324
|
+
signer,
|
|
325
|
+
chain,
|
|
326
|
+
accountAddress,
|
|
327
|
+
entityId,
|
|
328
|
+
deferredActionData,
|
|
329
|
+
)
|
|
330
|
+
: webauthnSigningFunctions(
|
|
331
|
+
// credential required for webauthn mode is checked at modularAccountV2 creation level
|
|
332
|
+
credential!,
|
|
333
|
+
getFn,
|
|
334
|
+
rpId,
|
|
282
335
|
chain,
|
|
283
336
|
accountAddress,
|
|
284
337
|
entityId,
|
|
@@ -286,6 +339,16 @@ export async function createMAv2Base<
|
|
|
286
339
|
)),
|
|
287
340
|
});
|
|
288
341
|
|
|
342
|
+
if (!signer) {
|
|
343
|
+
return {
|
|
344
|
+
...baseAccount,
|
|
345
|
+
signerEntity,
|
|
346
|
+
getExecutionData,
|
|
347
|
+
getValidationData,
|
|
348
|
+
encodeCallData,
|
|
349
|
+
} as WebauthnModularAccountV2; // TO DO: figure out when this breaks! we shouldn't have to cast
|
|
350
|
+
}
|
|
351
|
+
|
|
289
352
|
return {
|
|
290
353
|
...baseAccount,
|
|
291
354
|
getSigner: () => signer,
|
|
@@ -293,5 +356,5 @@ export async function createMAv2Base<
|
|
|
293
356
|
getExecutionData,
|
|
294
357
|
getValidationData,
|
|
295
358
|
encodeCallData,
|
|
296
|
-
}
|
|
359
|
+
} as ModularAccountV2<TSigner>; // TO DO: figure out when this breaks! we shouldn't have to cast
|
|
297
360
|
}
|