From 7cf4583847b0958b4c8db6fedb33e1a7349506ee Mon Sep 17 00:00:00 2001 From: KONFeature Date: Mon, 4 Mar 2024 11:54:52 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20webauthn=20authenticator=20id?= =?UTF-8?q?=20in=20the=20enable=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/validator/webauthn/WebAuthnFclValidator.sol | 7 ++++--- test/foundry/validator/WebAuthnFclValidator.t.sol | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/validator/webauthn/WebAuthnFclValidator.sol b/src/validator/webauthn/WebAuthnFclValidator.sol index fbbc41ed..5ad4cf64 100644 --- a/src/validator/webauthn/WebAuthnFclValidator.sol +++ b/src/validator/webauthn/WebAuthnFclValidator.sol @@ -23,7 +23,8 @@ struct WebAuthnFclValidatorStorage { /// @notice Inspired by the cometh Gnosis Safe signer: https://github.com/cometh-game/p256-signer contract WebAuthnFclValidator is IKernelValidator { /// @dev Event emitted when the public key signing the WebAuthN user operation is changed for a given `kernel`. - event WebAuthnPublicKeyChanged(address indexed kernel, uint256 x, uint256 y); + /// @dev The `b64AuthenticatorId` param represent the webauthn authenticator id used to create this public key + event WebAuthnPublicKeyChanged(address indexed kernel, string indexed b64AuthenticatorId, uint256 x, uint256 y); /// @dev Mapping of kernel address to each webAuthn specific storage mapping(address kernel => WebAuthnFclValidatorStorage webAuthnStorage) private webAuthnValidatorStorage; @@ -44,13 +45,13 @@ contract WebAuthnFclValidator is IKernelValidator { /// @dev Enable this validator for a given `kernel` (msg.sender) function enable(bytes calldata _data) external payable override { // Extract the x & y coordinates of the public key from the `_data` bytes - (uint256 x, uint256 y) = abi.decode(_data, (uint256, uint256)); + (string memory authenticatorId, uint256 x, uint256 y) = abi.decode(_data, (string, uint256, uint256)); // Update the pub key data WebAuthnFclValidatorStorage storage kernelValidatorStorage = webAuthnValidatorStorage[msg.sender]; kernelValidatorStorage.x = x; kernelValidatorStorage.y = y; // Emit the update event - emit WebAuthnPublicKeyChanged(msg.sender, x, y); + emit WebAuthnPublicKeyChanged(msg.sender, authenticatorId, x, y); } /// @dev Validate a `_userOp` using a WebAuthn Signature for the kernel account who is the `_userOp` sender diff --git a/test/foundry/validator/WebAuthnFclValidator.t.sol b/test/foundry/validator/WebAuthnFclValidator.t.sol index ec2134d2..e548eaba 100644 --- a/test/foundry/validator/WebAuthnFclValidator.t.sol +++ b/test/foundry/validator/WebAuthnFclValidator.t.sol @@ -67,7 +67,9 @@ contract WebAuthnFclValidatorTest is KernelTestBase { } function getInitializeData() internal view override returns (bytes memory) { - return abi.encodeWithSelector(KernelStorage.initialize.selector, webAuthNValidator, abi.encode(x, y)); + return abi.encodeWithSelector( + KernelStorage.initialize.selector, webAuthNValidator, abi.encode("authenticator-id", x, y) + ); } function test_default_validator_enable() external override { @@ -76,7 +78,7 @@ contract WebAuthnFclValidatorTest is KernelTestBase { IKernel.execute.selector, address(webAuthNValidator), 0, - abi.encodeWithSelector(webAuthNValidator.enable.selector, abi.encode(x, y)), + abi.encodeWithSelector(webAuthNValidator.enable.selector, abi.encode("authenticator-id", x, y)), Operation.Call ) );