choice( UserVerificationRequirement::ALL, 'userVerification "%s" is not an element of the valid values: %s' ); $this->challenge = $challenge; $this->rpId = $rpId; $this->allowCredentials = $allowCredentials; $this->userVerification = $userVerification; } public static function hydrate( array $data ): self { Assert::that( $data, 'PublicKeyCredentialRequestOptions hydration does not contain "%s".' ) ->keyExists( 'challenge' ) ->keyExists( 'rpId' ) ->keyExists( 'allowCredentials' ) ->keyExists( 'userVerification' ); Assert::that( $data['allowCredentials'] ) ->isArray( 'allowCredentials "%s" is not an array.' ); Assert::thatAll( $data['allowCredentials'] ) ->isArray( 'allowCredentials item "%s" is not an array.' ); return new self( BinaryString::from_ascii( $data['challenge'] ), $data['rpId'], array_map( [ PublicKeyCredentialDescriptor::class, 'hydrate' ], $data['allowCredentials'] ), $data['userVerification'] ); } public function get_challenge(): BinaryString { return $this->challenge; } public function get_rp_id(): string { return $this->rpId; } /** @return PublicKeyCredentialDescriptor[] */ public function get_allowed_credentials(): array { return $this->allowCredentials; } public function get_user_verification(): string { return $this->userVerification; } public function jsonSerialize(): array { return \ITSEC_Lib::recursively_json_serialize( get_object_vars( $this ) ); } }