user) { $assertion->acceptedCredentials = $assertion->user->webAuthnCredentials()->get(['id', 'transports']); if ($assertion->acceptedCredentials->isNotEmpty()) { $assertion->json->set('allowCredentials', $this->parseCredentials($assertion->acceptedCredentials)); } } return $next($assertion); } /** * Adapt all credentials into an `allowCredentials` digestible array. * * @param \Illuminate\Database\Eloquent\Collection $credentials * @return \Illuminate\Support\Collection}> */ protected function parseCredentials(EloquentCollection $credentials): Collection { // @phpstan-ignore-next-line return $credentials->map(static function (WebAuthnCredential $credential): array { return array_filter([ 'id' => $credential->getKey(), 'type' => 'public-key', 'transports' => $credential->transports ]); }); } }