Fixes static analysis
This commit is contained in:
@@ -36,7 +36,7 @@ class MayRetrieveCredentialsIdForUser
|
||||
* Adapt all credentials into an `allowCredentials` digestible array.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Collection<int, \Laragear\WebAuthn\Models\WebAuthnCredential> $credentials
|
||||
* @return Illuminate\Support\Collection<int, array{id?: mixed, type: string, transports?: non-empty-array<int, string>}>
|
||||
* @return \Illuminate\Support\Collection<int, array{id?: mixed, type: string, transports?: non-empty-array<int, string>}>
|
||||
*/
|
||||
protected function parseCredentials(EloquentCollection $credentials): Collection
|
||||
{
|
||||
|
||||
@@ -366,13 +366,21 @@ class AuthenticatorData
|
||||
protected static function readFlags(string $binFlag): object
|
||||
{
|
||||
$flags = (object) [
|
||||
// @phpstan-ignore-next-line
|
||||
'bit_0' => (bool) ($binFlag & 1),
|
||||
// @phpstan-ignore-next-line
|
||||
'bit_1' => (bool) ($binFlag & 2),
|
||||
// @phpstan-ignore-next-line
|
||||
'bit_2' => (bool) ($binFlag & 4),
|
||||
// @phpstan-ignore-next-line
|
||||
'bit_3' => (bool) ($binFlag & 8),
|
||||
// @phpstan-ignore-next-line
|
||||
'bit_4' => (bool) ($binFlag & 16),
|
||||
// @phpstan-ignore-next-line
|
||||
'bit_5' => (bool) ($binFlag & 32),
|
||||
// @phpstan-ignore-next-line
|
||||
'bit_6' => (bool) ($binFlag & 64),
|
||||
// @phpstan-ignore-next-line
|
||||
'bit_7' => (bool) ($binFlag & 128),
|
||||
'userPresent' => false,
|
||||
'userVerified' => false,
|
||||
|
||||
@@ -23,6 +23,7 @@ class AddUserDescriptor
|
||||
$config = $attestable->user->webAuthnData();
|
||||
|
||||
// Create a new User UUID if it doesn't existe already in the credentials.
|
||||
// @phpstan-ignore-next-line
|
||||
$config['id'] = $attestable->user->webAuthnCredentials()->value('user_id')
|
||||
?: Str::uuid()->getHex()->toString();
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ class MayPreventDuplicateCredentials
|
||||
return $user
|
||||
->webAuthnCredentials()
|
||||
->get(['id', 'transports'])
|
||||
// @phpstan-ignore-next-line
|
||||
->map(static function (WebAuthnCredential $credential): array {
|
||||
return array_filter([
|
||||
'id'=> $credential->getKey(),
|
||||
|
||||
@@ -50,6 +50,7 @@ class WebAuthnUserProvider extends EloquentUserProvider
|
||||
/** @noinspection PhpIncompatibleReturnTypeInspection */
|
||||
return $this->newModelQuery()
|
||||
->whereHas('webAuthnCredentials', static function (Builder $query) use ($credentials): void {
|
||||
// @phpstan-ignore-next-line
|
||||
$query->whereKey($credentials['id'])->whereEnabled();
|
||||
})
|
||||
->first();
|
||||
|
||||
@@ -86,7 +86,7 @@ class ByteBuffer implements JsonSerializable, Jsonable, Stringable
|
||||
* @param string $binaryData
|
||||
* @param int $dataLength
|
||||
*/
|
||||
public function __construct(protected string $binaryData, protected int $dataLength = 0)
|
||||
final public function __construct(protected string $binaryData, protected int $dataLength = 0)
|
||||
{
|
||||
$this->dataLength = strlen($binaryData);
|
||||
}
|
||||
@@ -194,7 +194,7 @@ class ByteBuffer implements JsonSerializable, Jsonable, Stringable
|
||||
* Returns the value of a single unsigned 16-bit integer.
|
||||
*
|
||||
* @param int $offset
|
||||
* @return mixed
|
||||
* @return int
|
||||
*/
|
||||
public function getUint16Val(int $offset = 0): int
|
||||
{
|
||||
@@ -209,7 +209,7 @@ class ByteBuffer implements JsonSerializable, Jsonable, Stringable
|
||||
* Returns the value of a single unsigned 32-bit integer.
|
||||
*
|
||||
* @param int $offset
|
||||
* @return mixed
|
||||
* @return int
|
||||
*/
|
||||
public function getUint32Val(int $offset = 0): int
|
||||
{
|
||||
@@ -404,7 +404,7 @@ class ByteBuffer implements JsonSerializable, Jsonable, Stringable
|
||||
throw new InvalidArgumentException('ByteBuffer: Invalid base64 url string');
|
||||
}
|
||||
|
||||
return new ByteBuffer($bin);
|
||||
return new static($bin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,7 +419,7 @@ class ByteBuffer implements JsonSerializable, Jsonable, Stringable
|
||||
throw new InvalidArgumentException('ByteBuffer: Invalid base64 string');
|
||||
}
|
||||
|
||||
return new ByteBuffer($bin);
|
||||
return new static($bin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,6 +140,7 @@ class CborDecoder
|
||||
|
||||
try {
|
||||
return static::parseItemData($type, $val, $buf, $offset);
|
||||
// @phpstan-ingnore-next-line
|
||||
} catch (InvalidArgumentException $e) {
|
||||
throw new DataException($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class Challenge
|
||||
* @param bool $verify
|
||||
* @param array $properties
|
||||
*/
|
||||
public function __construct(
|
||||
final public function __construct(
|
||||
public ByteBuffer $data,
|
||||
public int $timeout,
|
||||
public bool $verify = true,
|
||||
|
||||
@@ -41,7 +41,7 @@ interface WebAuthnAuthenticatable
|
||||
/**
|
||||
* Returns a queryable relationship for its WebAuthn Credentials.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany&\Laragear\WebAuthn\Models\WebAuthnCredential
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany|\Laragear\WebAuthn\Models\WebAuthnCredential
|
||||
*/
|
||||
public function webAuthnCredentials(): MorphMany;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class AssertionException extends ValidationException implements WebAuthnExceptio
|
||||
* Create a new Assertion Exception with the error message.
|
||||
*
|
||||
* @param string $message
|
||||
* @return \Laragear\WebAuthn\Exceptions\AssertionException
|
||||
* @return static
|
||||
*/
|
||||
public static function make(string $message): static
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ class AttestationException extends ValidationException implements WebAuthnExcept
|
||||
* Create a new Attestation Exception with the error message.
|
||||
*
|
||||
* @param string $message
|
||||
* @return \Laragear\WebAuthn\Exceptions\AttestationException
|
||||
* @return static
|
||||
*/
|
||||
public static function make(string $message): static
|
||||
{
|
||||
|
||||
@@ -48,10 +48,11 @@ class AssertedRequest extends FormRequest
|
||||
* Logs in the user for this assertion request.
|
||||
*
|
||||
* @param string|null $guard
|
||||
* @return \Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable&\Illuminate\Contracts\Auth\Authenticatable|null
|
||||
* @return \Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable|\Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function login(string $guard = null, bool $remember = null, bool $destroySession = false): ?WebAuthnAuthenticatable
|
||||
{
|
||||
/** @var \Illuminate\Contracts\Auth\StatefulGuard $guard */
|
||||
$auth = Auth::guard($guard);
|
||||
|
||||
if ($auth->attempt($this->validated(), $remember ?? $this->hasRemember())) {
|
||||
|
||||
@@ -133,7 +133,9 @@ class AssertionRequest extends FormRequest
|
||||
// retrieve by its ID, otherwise we will fall back to credentials. Once done, we
|
||||
// will check it uses WebAuthn if is not null, otherwise we'll fail miserably.
|
||||
$user = is_string($credentials) || is_int($credentials)
|
||||
// @phpstan-ignore-next-line
|
||||
? Auth::guard($this->guard)->getProvider()->retrieveById($credentials)
|
||||
// @phpstan-ignore-next-line
|
||||
: Auth::guard($this->guard)->getProvider()->retrieveByCredentials($credentials);
|
||||
|
||||
if ($user && ! $user instanceof WebAuthnAuthenticatable) {
|
||||
|
||||
@@ -9,7 +9,7 @@ use Laragear\WebAuthn\Events\CredentialDisabled;
|
||||
use Laragear\WebAuthn\Events\CredentialEnabled;
|
||||
|
||||
/**
|
||||
* @mixin \Illuminate\Database\Eloquent\Builder<\Laragear\WebAuthn\Models\WebAuthnCredential>
|
||||
* @mixin \Illuminate\Database\Eloquent\Builder
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|static query()
|
||||
* @method \Illuminate\Database\Eloquent\Builder|static newQuery()
|
||||
@@ -22,10 +22,10 @@ use Laragear\WebAuthn\Events\CredentialEnabled;
|
||||
* @method \Laragear\WebAuthn\Models\WebAuthnCredential firstOr($columns = ['*'], \Closure $callback = null)
|
||||
* @method \Laragear\WebAuthn\Models\WebAuthnCredential firstWhere($column, $operator = null, $value = null, $boolean = 'and')
|
||||
* @method \Laragear\WebAuthn\Models\WebAuthnCredential updateOrCreate(array $attributes, array $values = [])
|
||||
* @method static|null first($columns = ['*'])
|
||||
* @method ?static first($columns = ['*'])
|
||||
* @method static static findOrFail($id, $columns = ['*'])
|
||||
* @method static static findOrNew($id, $columns = ['*'])
|
||||
* @method static static|null find($id, $columns = ['*'])
|
||||
* @method static ?null find($id, $columns = ['*'])
|
||||
*
|
||||
* @property-read string $id
|
||||
*
|
||||
@@ -98,7 +98,7 @@ class WebAuthnCredential extends Model
|
||||
protected $visible = ['id', 'origin', 'alias', 'aaguid', 'attestation_format', 'disabled_at', 'is_enabled'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo&\Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo|\Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable
|
||||
*/
|
||||
public function authenticatable(): MorphTo
|
||||
{
|
||||
@@ -113,6 +113,7 @@ class WebAuthnCredential extends Model
|
||||
*/
|
||||
protected function scopeWhereEnabled(Builder $query): Builder
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
return $query->whereNull('disabled_at');
|
||||
}
|
||||
/**
|
||||
@@ -123,6 +124,7 @@ class WebAuthnCredential extends Model
|
||||
*/
|
||||
protected function scopeWhereDisabled(Builder $query): Builder
|
||||
{
|
||||
// @phpstan-ignore-next-line
|
||||
return $query->whereNotNull('disabled_at');
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ class WebAuthnServiceProvider extends ServiceProvider
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->publishesMigrations(static::MIGRATIONS);
|
||||
$this->publishes([static::ROUTES => $this->app->basePath('routes/webauthn.php')], 'routes');
|
||||
// @phpstan-ignore-next-line
|
||||
$this->publishes([static::CONTROLLERS => $this->app->path('Http/Controllers/WebAuthn')], 'controllers');
|
||||
$this->publishes([static::JS => $this->app->resourcePath('js/vendor/webauthn')], 'js');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user