Add encryption handling and session flags management.

This commit is contained in:
netkas 2024-12-10 22:14:43 -05:00
parent 1d452bc71b
commit 86435a3d0b
13 changed files with 857 additions and 134 deletions

View file

@ -7,9 +7,11 @@
private bool $enabled;
private ?string $domain;
private ?string $rpcEndpoint;
private int $encryptionKeysCount;
private int $encryptionRecordsCount;
private ?string $privateKey;
private ?string $publicKey;
private ?string $encryptionKey;
private ?array $encryptionKeys;
/**
* Constructor that initializes object properties with the provided data.
@ -22,9 +24,11 @@
$this->enabled = (bool)$data['enabled'];
$this->domain = $data['domain'];
$this->rpcEndpoint = $data['rpc_endpoint'];
$this->encryptionKeysCount = $data['encryption_keys_count'];
$this->encryptionRecordsCount = $data['encryption_records_count'];
$this->privateKey = $data['private_key'];
$this->publicKey = $data['public_key'];
$this->encryptionKey = $data['encryption_key'];
$this->encryptionKeys = $data['encryption_keys'];
}
/**
@ -55,6 +59,26 @@
return $this->rpcEndpoint;
}
/**
* Retrieves the number of encryption keys.
*
* @return int The number of encryption keys.
*/
public function getEncryptionKeysCount(): int
{
return $this->encryptionKeysCount;
}
/**
* Retrieves the number of encryption records.
*
* @return int The number of encryption records.
*/
public function getEncryptionRecordsCount(): int
{
return $this->encryptionRecordsCount;
}
/**
* Retrieves the private key.
*
@ -76,12 +100,20 @@
}
/**
* Retrieves the encryption key.
* Retrieves the encryption keys.
*
* @return string|null The encryption key.
* @return array|null The encryption keys.
*/
public function getEncryptionKey(): ?string
public function getEncryptionKeys(): ?array
{
return $this->encryptionKey;
return $this->encryptionKeys;
}
/**
* @return string
*/
public function getRandomEncryptionKey(): string
{
return $this->encryptionKeys[array_rand($this->encryptionKeys)];
}
}