-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from mercadopago/release/1.8.3
v.1.8.3
- Loading branch information
Showing
37 changed files
with
721 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace MercadoPago\AdbPayment\Block; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Framework\Math\Random; | ||
use Magento\Csp\Model\Collector\DynamicCollector; | ||
use Magento\Csp\Model\Policy\FetchPolicy; | ||
|
||
class MpDeviceSessionId extends Template | ||
{ | ||
private const NONCE_LENGTH = 32; | ||
|
||
private DynamicCollector $dynamicCollector; | ||
private Random $random; | ||
|
||
/** | ||
* @param Context $context | ||
* @param DynamicCollector $dynamicCollector | ||
* @param Random $random | ||
* @param array $data | ||
*/ | ||
public function __construct(Context $context, DynamicCollector $dynamicCollector, Random $random, array $data = []) | ||
{ | ||
parent::__construct($context, $data); | ||
|
||
$this->dynamicCollector = $dynamicCollector; | ||
$this->random = $random; | ||
} | ||
|
||
public function getNonce(): string | ||
{ | ||
$nonce = $this->random->getRandomString( | ||
self::NONCE_LENGTH, | ||
Random::CHARS_DIGITS . Random::CHARS_LOWERS | ||
); | ||
|
||
$policy = new FetchPolicy( | ||
'script-src', | ||
false, | ||
[], | ||
[], | ||
false, | ||
false, | ||
false, | ||
[$nonce], | ||
[] | ||
); | ||
|
||
$this->dynamicCollector->add($policy); | ||
|
||
return base64_encode($nonce); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.