# PasskeysEvent events

> 5 FeatherPanel plugin events on PasskeysEvent (5 emitted by the core): the event names, the arguments each listener gets, where they fire and a PHP listener for each.

Source: https://featherpanel.com/docs/plugins/events/passkeys/

Part of the [plugin events reference](https://featherpanel.com/docs/plugins/events/). Listeners get the payload values as positional arguments in the order shown, cannot cancel the action, and must catch their own exceptions.

## Setup

Import `PasskeysEvent` in your entry class and register listeners in `processEvents()`:

```php
<?php

namespace App\Addons\myplugin;

use App\App;
use App\Plugins\AppPlugin;
use App\Plugins\PluginEvents;
use App\Plugins\Events\Events\PasskeysEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(PasskeysEvent::onPasskeyDeleted(), function ($user, $passkeyId): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:auth:passkey:deleted ' . json_encode(['user' => $user, 'passkey_id' => $passkeyId]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}
```

## `PasskeysEvent::onPasskeyAuthenticationFailed()`

- Name: `featherpanel:auth:passkey:authentication:failed`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PasskeysEvent.php#L59)

Docblock: array context. (the emitter passes 2 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `error` | `$error` | `string` |
| 2 | `message` | `$message` | not declared |

When it fires (1 site)

-   [`PasskeyController::postAuthenticationVerify`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Auth/PasskeyController.php#L235) via `emitPluginEvent()`[`POST /api/user/auth/passkeys/authentication/verify`](https://featherpanel.com/docs/api/reference/user/passkeys/#post-user-auth-passkeys-authentication-verify)

```php
$event->on(PasskeysEvent::onPasskeyAuthenticationFailed(), function ($error, $message): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:auth:passkey:authentication:failed ' . json_encode(['error' => $error]));
});
```

## `PasskeysEvent::onPasskeyAuthenticationSuccess()`

- Name: `featherpanel:auth:passkey:authentication:success`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PasskeysEvent.php#L51)

Docblock: array user.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user` | `$user` | `array`from docblock |

When it fires (1 site)

-   [`PasskeyController::postAuthenticationVerify`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Auth/PasskeyController.php#L267) via `emitPluginEvent()`[`POST /api/user/auth/passkeys/authentication/verify`](https://featherpanel.com/docs/api/reference/user/passkeys/#post-user-auth-passkeys-authentication-verify)

```php
$event->on(PasskeysEvent::onPasskeyAuthenticationSuccess(), function ($user): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:auth:passkey:authentication:success ' . json_encode(['user' => $user]));
});
```

## `PasskeysEvent::onPasskeyDeleted()`

- Name: `featherpanel:auth:passkey:deleted`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PasskeysEvent.php#L35)

Docblock: array user, int passkey id.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user` | `$user` | `array`from docblock |
| 2 | `passkey_id` | `$passkeyId` | `bool` |

When it fires (1 site)

-   [`PasskeyController::delete`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Auth/PasskeyController.php#L486) via `emitPluginEvent()`[`DELETE /api/user/passkeys/{id}`](https://featherpanel.com/docs/api/reference/user/passkeys/#delete-user-passkeys-id)

```php
$event->on(PasskeysEvent::onPasskeyDeleted(), function ($user, $passkeyId): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:auth:passkey:deleted ' . json_encode(['user' => $user, 'passkey_id' => $passkeyId]));
});
```

## `PasskeysEvent::onPasskeyRegistered()`

- Name: `featherpanel:auth:passkey:registered`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PasskeysEvent.php#L27)

Docblock: array user, array passkey. (the emitter passes 3 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user` | `$user` | not declared |
| 2 | `passkey_id` | `$passkeyId` | not declared |
| 3 | `label` | `$label` | `string` |

When it fires (1 site)

-   [`PasskeyController::postRegistrationVerify`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Auth/PasskeyController.php#L459) via `emitPluginEvent()`[`POST /api/user/passkeys/registration/verify`](https://featherpanel.com/docs/api/reference/user/passkeys/#post-user-passkeys-registration-verify)

```php
$event->on(PasskeysEvent::onPasskeyRegistered(), function ($user, $passkeyId, $label): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:auth:passkey:registered ' . json_encode(['label' => $label]));
});
```

## `PasskeysEvent::onPasskeyUpdated()`

- Name: `featherpanel:auth:passkey:updated`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PasskeysEvent.php#L43)

Docblock: array user, array passkey. (the emitter passes 3 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `user` | `$user` | not declared |
| 2 | `passkey_id` | `$passkeyId` | `bool` |
| 3 | `label` | `$label` | not declared |

When it fires (1 site)

-   [`PasskeyController::patch`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/User/Auth/PasskeyController.php#L524) via `emitPluginEvent()`[`PATCH /api/user/passkeys/{id}`](https://featherpanel.com/docs/api/reference/user/passkeys/#patch-user-passkeys-id)

```php
$event->on(PasskeysEvent::onPasskeyUpdated(), function ($user, $passkeyId, $label): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:auth:passkey:updated ' . json_encode(['passkey_id' => $passkeyId]));
});
```
