From ee86d3992c99ccc2617b54f7e2bc822d8bbac812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:32:03 -0300 Subject: [PATCH 01/10] Update SoapBase.php --- src/Common/Soap/SoapBase.php | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Common/Soap/SoapBase.php b/src/Common/Soap/SoapBase.php index 4ee4857..b282bd3 100755 --- a/src/Common/Soap/SoapBase.php +++ b/src/Common/Soap/SoapBase.php @@ -21,7 +21,7 @@ use NFePHP\Common\Exception\RuntimeException; use NFePHP\Common\Strings; use League\Flysystem\Filesystem; -use League\Flysystem\Adapter\Local; +use League\Flysystem\Local\LocalFilesystemAdapter; use Psr\Log\LoggerInterface; abstract class SoapBase implements SoapInterface @@ -99,7 +99,7 @@ abstract class SoapBase implements SoapInterface */ protected $disableCertValidation = false; /** - * @var \League\Flysystem\Adapter\Local + * @var \League\Flysystem\Local\LocalFilesystemAdapter; */ protected $adapter; /** @@ -160,7 +160,7 @@ public function __construct( $this->certificate = $this->checkCertValidity($certificate); $this->setTemporaryFolder(sys_get_temp_dir() . '/sped/'); } - + /** * Check if certificate is valid * @param Certificate $certificate @@ -181,7 +181,7 @@ private function checkCertValidity(Certificate $certificate = null) } return $certificate; } - + /** * Destructor * Clean temporary files @@ -190,7 +190,7 @@ public function __destruct() { $this->removeTemporarilyFiles(); } - + /** * Disables the security checking of host and peer certificates * @param bool $flag @@ -200,7 +200,7 @@ public function disableSecurity($flag = false) $this->disablesec = $flag; return $this->disablesec; } - + /** * ONlY for tests * @param bool $flag @@ -222,7 +222,7 @@ public function loadCA($capath) $this->casefaz = $capath; } } - + /** * Set option to encript private key before save in filesystem * for an additional layer of protection @@ -233,7 +233,7 @@ public function setEncriptPrivateKey($encript = true) { return $this->encriptPrivateKey = $encript; } - + /** * Set another temporayfolder for saving certificates for SOAP utilization * @param string $folderRealPath @@ -243,14 +243,14 @@ public function setTemporaryFolder($folderRealPath) $this->tempdir = $folderRealPath; $this->setLocalFolder($folderRealPath); } - + /** * Set Local folder for flysystem * @param string $folder */ protected function setLocalFolder($folder = '') { - $this->adapter = new Local($folder); + $this->adapter = new LocalFilesystemAdapter($folder); $this->filesystem = new Filesystem($this->adapter); } @@ -263,7 +263,7 @@ public function setDebugMode($value = false) { return $this->debugmode = $value; } - + /** * Set certificate class for SSL comunications * @param Certificate $certificate @@ -272,7 +272,7 @@ public function loadCertificate(Certificate $certificate) { $this->certificate = $this->checkCertValidity($certificate); } - + /** * Set logger class * @param LoggerInterface $logger @@ -281,7 +281,7 @@ public function loadLogger(LoggerInterface $logger) { return $this->logger = $logger; } - + /** * Set timeout for communication * @param int $timesecs @@ -290,7 +290,7 @@ public function timeout($timesecs) { return $this->soaptimeout = $timesecs; } - + /** * Set security protocol * @param int $protocol @@ -300,7 +300,7 @@ public function protocol($protocol = self::SSL_DEFAULT) { return $this->soapprotocol = $protocol; } - + /** * Set prefixes * @param array $prefixes @@ -310,7 +310,7 @@ public function setSoapPrefix($prefixes) { return $this->prefixes = $prefixes; } - + /** * Set proxy parameters * @param string $ip @@ -325,7 +325,7 @@ public function proxy($ip, $port, $user, $password) $this->proxyUser = $user; $this->proxyPass = $password; } - + /** * Send message to webservice */ @@ -336,7 +336,7 @@ abstract public function send( $envelope, $parameters ); - + /** * Mount soap envelope * @param string $request @@ -372,7 +372,7 @@ protected function makeEnvelopeSoap( . ""; return $envelope; } - + /** * Temporarily saves the certificate keys for use cURL or SoapClient */ @@ -419,7 +419,7 @@ public function saveTemporarilyKeyFiles() ); } } - + /** * Delete all files in folder */ @@ -457,7 +457,7 @@ public function removeTemporarilyFiles() } } } - + /** * Save request envelope and response for debug reasons * @param string $operation From 63a17a6c1c68cd47a42e6a924cbb011b58a1cb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:11:02 -0300 Subject: [PATCH 02/10] Update composer.json --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index a6a4d47..f18a675 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "nfephp-org/sped-nfse-ginfes", + "name": "jvkrypton/sped-nfse-ginfes", "type": "library", "description": "API para geração e comunicação de RPS e NFSe no padão Ginfes.", "keywords": ["nfe","nfse","sped","nfephp"], - "homepage": "https://github.com/nfephp-org/sped-nfse-ginfes", + "homepage": "https://github.com/jvkrypton/sped-nfse-ginfes", "license": ["LGPL-3.0-or-later", "GPL-3.0-or-later", "MIT"], "authors": [ { @@ -14,12 +14,12 @@ }, { "name": "Comunidade NFePHP", - "homepage": "https://github.com/nfephp-org/sped-nfe/graphs/contributors" + "homepage": "https://github.com/jvkrypton/sped-nfe/graphs/contributors" } ], "require": { "php" : ">= 7.1", - "nfephp-org/sped-common" : "^5.0", + "jvkrypton/sped-common" : "^5.0", "justinrainbow/json-schema": "^5.2", "ext-zlib": "*", "ext-dom": "*", From e9dd3c2995b944a0cb666f0faf3fde8eb1cfdd4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:18:58 -0300 Subject: [PATCH 03/10] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f18a675..4056927 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "require": { "php" : ">= 7.1", - "jvkrypton/sped-common" : "^5.0", + "nfephp-org/sped-common" : "^5.0", "justinrainbow/json-schema": "^5.2", "ext-zlib": "*", "ext-dom": "*", From 8bc03938e1b782c54f230103750f78c6e12e33e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Sat, 23 Dec 2023 02:12:55 -0300 Subject: [PATCH 04/10] Update SoapBase.php --- src/Common/Soap/SoapBase.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Common/Soap/SoapBase.php b/src/Common/Soap/SoapBase.php index b282bd3..f8b4205 100755 --- a/src/Common/Soap/SoapBase.php +++ b/src/Common/Soap/SoapBase.php @@ -401,15 +401,15 @@ public function saveTemporarilyKeyFiles() $this->temppass ); } - $ret &= $this->filesystem->put( + $ret &= $this->filesystem->write( $this->prifile, $private ); - $ret &= $this->filesystem->put( + $ret &= $this->filesystem->write( $this->pubfile, $this->certificate->publicKey ); - $ret &= $this->filesystem->put( + $ret &= $this->filesystem->write( $this->certfile, $private."{$this->certificate}" ); @@ -478,11 +478,11 @@ public function saveDebugFiles($operation, $request, $response) $now = \DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', '')); $time = substr($now->format("ymdHisu"), 0, 16); try { - $this->filesystem->put( + $this->filesystem->write( $this->debugdir . $time . "_" . $operation . "_sol.txt", $request ); - $this->filesystem->put( + $this->filesystem->write( $this->debugdir . $time . "_" . $operation . "_res.txt", $response ); From e6c823283364b5470995a84c80625728f3b5be91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:42:44 -0300 Subject: [PATCH 05/10] Update SoapBase.php --- src/Common/Soap/SoapBase.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Common/Soap/SoapBase.php b/src/Common/Soap/SoapBase.php index f8b4205..ecab62c 100755 --- a/src/Common/Soap/SoapBase.php +++ b/src/Common/Soap/SoapBase.php @@ -23,6 +23,7 @@ use League\Flysystem\Filesystem; use League\Flysystem\Local\LocalFilesystemAdapter; use Psr\Log\LoggerInterface; +use Illuminate\Support\Facades\File; abstract class SoapBase implements SoapInterface { @@ -158,7 +159,7 @@ public function __construct( ) { $this->logger = $logger; $this->certificate = $this->checkCertValidity($certificate); - $this->setTemporaryFolder(sys_get_temp_dir() . '/sped/'); + $this->setTemporaryFolder(storage_path('nfe') . '/'); } /** @@ -250,8 +251,8 @@ public function setTemporaryFolder($folderRealPath) */ protected function setLocalFolder($folder = '') { - $this->adapter = new LocalFilesystemAdapter($folder); - $this->filesystem = new Filesystem($this->adapter); + //$this->adapter = new LocalFilesystemAdapter($folder); + $this->filesystem = new \NFePHP\Common\Files($folder); } /** @@ -383,10 +384,12 @@ public function saveTemporarilyKeyFiles() 'Certificate not found.' ); } + $this->certsdir = $this->certificate->getCnpj() . '/certs/'; $this->prifile = $this->certsdir. Strings::randomString(10).'.pem'; $this->pubfile = $this->certsdir . Strings::randomString(10).'.pem'; $this->certfile = $this->certsdir . Strings::randomString(10).'.pem'; + $ret = true; $private = $this->certificate->privateKey; if ($this->encriptPrivateKey) { @@ -401,15 +404,17 @@ public function saveTemporarilyKeyFiles() $this->temppass ); } - $ret &= $this->filesystem->write( + + $ret &= $this->filesystem->put( $this->prifile, $private ); - $ret &= $this->filesystem->write( + + $ret &= $this->filesystem->put( $this->pubfile, $this->certificate->publicKey ); - $ret &= $this->filesystem->write( + $ret &= $this->filesystem->put( $this->certfile, $private."{$this->certificate}" ); @@ -418,6 +423,8 @@ public function saveTemporarilyKeyFiles() 'Unable to save temporary key files in folder.' ); } + + $this->removeTemporarilyFiles(); } /** @@ -478,11 +485,11 @@ public function saveDebugFiles($operation, $request, $response) $now = \DateTime::createFromFormat('U.u', number_format(microtime(true), 6, '.', '')); $time = substr($now->format("ymdHisu"), 0, 16); try { - $this->filesystem->write( + $this->filesystem->put( $this->debugdir . $time . "_" . $operation . "_sol.txt", $request ); - $this->filesystem->write( + $this->filesystem->put( $this->debugdir . $time . "_" . $operation . "_res.txt", $response ); From 5adec75035bb77f4ecf117e91f7493b2684f8694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:46:20 -0300 Subject: [PATCH 06/10] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4056927..f18a675 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "require": { "php" : ">= 7.1", - "nfephp-org/sped-common" : "^5.0", + "jvkrypton/sped-common" : "^5.0", "justinrainbow/json-schema": "^5.2", "ext-zlib": "*", "ext-dom": "*", From 2d79cd2150b5274185f687de81bc72170a02345f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:46:47 -0300 Subject: [PATCH 07/10] Update composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index f18a675..5d6db72 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "php" : ">= 7.1", "jvkrypton/sped-common" : "^5.0", "justinrainbow/json-schema": "^5.2", + "league/flysystem": "^3.23", "ext-zlib": "*", "ext-dom": "*", "ext-openssl": "*", From c47cf1307b1e4586a49616a15aaf2cfb495afc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:50:47 -0300 Subject: [PATCH 08/10] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d6db72..64cf95a 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "require": { "php" : ">= 7.1", - "jvkrypton/sped-common" : "^5.0", + "jvkrypton/sped-common" : "*", "justinrainbow/json-schema": "^5.2", "league/flysystem": "^3.23", "ext-zlib": "*", From 93da18a1871cc4c8d6e5e98b043012a0470e0fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:52:29 -0300 Subject: [PATCH 09/10] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 64cf95a..11f50f2 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "require": { "php" : ">= 7.1", - "jvkrypton/sped-common" : "*", + "jvkrypton/sped-common" : "dev-master", "justinrainbow/json-schema": "^5.2", "league/flysystem": "^3.23", "ext-zlib": "*", From 961a031ddd32af089ff54f9af6919e8a4ab57205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= <74694494+jvkrypton@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:53:55 -0300 Subject: [PATCH 10/10] Update composer.json --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 11f50f2..71cd3d4 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,6 @@ ], "require": { "php" : ">= 7.1", - "jvkrypton/sped-common" : "dev-master", "justinrainbow/json-schema": "^5.2", "league/flysystem": "^3.23", "ext-zlib": "*",