6
6
use Ramsey \Uuid \Uuid ;
7
7
use GuzzleHttp \Psr7 \Request ;
8
8
use SoapBox \SignedRequests \Signature ;
9
- use Illuminate \Support \Facades \Config ;
10
- use Illuminate \Contracts \Config \Repository ;
9
+ use SoapBox \SignedRequests \Configurations \Configuration ;
11
10
12
11
class Generator
13
12
{
14
13
/**
15
- * An instance of the configuration repository .
14
+ * A configuration to use for generating signatures .
16
15
*
17
- * @var \Illuminate\Contracts\Config\Repository
16
+ * @var \SoapBox\SignedRequests\Configurations\Configuration
18
17
*/
19
- private $ repository ;
18
+ private $ configuration ;
20
19
21
20
/**
22
21
* Constructs our signed request generator with an instance of the
23
22
* configurations.
24
23
*
25
- * @param \Illuminate\Contracts\Config\Repository $repository
26
- * A configuration repository .
24
+ * @param \SoapBox\SignedRequests\Configurations\Configuration $configuration
25
+ * The configuration to use for generating the signed request .
27
26
*/
28
- public function __construct (Repository $ repository )
27
+ public function __construct (Configuration $ configuration )
29
28
{
30
- $ this ->repository = $ repository ;
29
+ $ this ->configuration = $ configuration ;
31
30
}
32
31
33
32
/**
@@ -37,15 +36,15 @@ public function __construct(Repository $repository)
37
36
* The request to sign.
38
37
*
39
38
* @return \GuzzleHttp\Psr7\Request
40
- * The request with an id, algorith , and signature.
39
+ * The request with an id, algorithm , and signature.
41
40
*/
42
41
public function sign (Request $ request ) : Request
43
42
{
44
- $ algorithmHeader = $ this ->repository -> get ( ' signed-requests.headers.algorithm ' );
45
- $ signatureHeader = $ this ->repository -> get ( ' signed-requests.headers.signature ' );
43
+ $ algorithmHeader = $ this ->configuration -> getAlgorithmHeader ( );
44
+ $ signatureHeader = $ this ->configuration -> getSignatureHeader ( );
46
45
47
- $ algorithm = $ this ->repository -> get ( ' signed-requests.algorithm ' );
48
- $ key = $ this ->repository -> get ( ' signed-requests.key ' );
46
+ $ algorithm = $ this ->configuration -> getSigningAlgorithm ( );
47
+ $ key = $ this ->configuration -> getSigningKey ( );
49
48
50
49
$ request = $ request ->withHeader ('X-SIGNED-ID ' , (string ) Uuid::uuid4 ());
51
50
$ request = $ request ->withHeader ('X-SIGNED-TIMESTAMP ' , (string ) Carbon::now ());
0 commit comments