From fd0752b2f166d15563b50dd36544b42e7007516c Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 2 Sep 2024 13:18:49 +0100 Subject: [PATCH 1/2] Add safe storage methods --- src/System.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/System.php b/src/System.php index 55353689..3e2aa088 100644 --- a/src/System.php +++ b/src/System.php @@ -22,6 +22,25 @@ public function promptTouchID(string $reason): bool ])->successful(); } + public function canEncrypt(): bool + { + return $this->client->get('system/can-encrypt')->json('result'); + } + + public function encrypt(string $string): string + { + $this->client->post('system/encrypt', [ + 'string' => $string, + ])->json('result'); + } + + public function decrypt(string $string): string + { + $this->client->post('system/decrypt', [ + 'string' => $string, + ])->json('result'); + } + /** * @return array<\Native\Laravel\DataObjects\Printer> */ From 0c7e829b3245757cc7e9bbf5898f32220fc6fcab Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 2 Sep 2024 14:58:34 +0100 Subject: [PATCH 2/2] fix --- src/Facades/System.php | 3 +++ src/System.php | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Facades/System.php b/src/Facades/System.php index b4203687..088ce1dc 100644 --- a/src/Facades/System.php +++ b/src/Facades/System.php @@ -7,6 +7,9 @@ /** * @method static bool canPromptTouchID() * @method static bool promptTouchID(string $reason) + * @method static bool canEncrypt() + * @method static string encrypt(string $string) + * @method static string decrypt(string $string) * @method static array printers() * @method static void print(string $html, ?\Native\Laravel\DataObjects\Printer $printer = null) * @method static string printToPDF(string $reason) diff --git a/src/System.php b/src/System.php index 3e2aa088..b6c7e075 100644 --- a/src/System.php +++ b/src/System.php @@ -27,16 +27,16 @@ public function canEncrypt(): bool return $this->client->get('system/can-encrypt')->json('result'); } - public function encrypt(string $string): string + public function encrypt(string $string): ?string { - $this->client->post('system/encrypt', [ + return $this->client->post('system/encrypt', [ 'string' => $string, ])->json('result'); } - public function decrypt(string $string): string + public function decrypt(string $string): ?string { - $this->client->post('system/decrypt', [ + return $this->client->post('system/decrypt', [ 'string' => $string, ])->json('result'); }