Skip to content

Commit ad4b020

Browse files
committed
Readme: use the same wording for key/secret as in the UI
1 parent 32d958b commit ad4b020

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Why do you need to require `guzzlehttp/guzzle`? We are decoupled from any HTTP m
159159
require_once __DIR__ . '/vendor/autoload.php';
160160

161161
$client = new \PrivatePackagist\ApiClient\Client();
162-
$client->authenticate('api-token', 'api-secret');
162+
$client->authenticate('api-key', 'api-secret');
163163
$packages = $client->packages()->all();
164164
```
165165

Diff for: src/Client.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public function __construct(HttpPluginClientBuilder $httpClientBuilder = null, $
4545
}
4646

4747
/**
48-
* @param string $token
48+
* @param string $key
4949
* @param string $secret
5050
*/
51-
public function authenticate($token, $secret)
51+
public function authenticate($key, $secret)
5252
{
5353
$this->httpClientBuilder->removePlugin(RequestSignature::class);
54-
$this->httpClientBuilder->addPlugin(new RequestSignature($token, $secret));
54+
$this->httpClientBuilder->addPlugin(new RequestSignature($key, $secret));
5555
}
5656

5757
public function credentials()

Diff for: src/HttpClient/Plugin/RequestSignature.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ class RequestSignature implements Plugin
1717
use Plugin\VersionBridgePlugin;
1818

1919
/** @var string */
20-
private $token;
20+
private $key;
2121
/** @var string */
2222
private $secret;
2323

2424
/**
25-
* @param string $token
25+
* @param string $key
2626
* @param string $secret
2727
*/
28-
public function __construct($token, $secret)
28+
public function __construct($key, $secret)
2929
{
30-
if (!$token || !$secret) {
31-
throw new \InvalidArgumentException('$token and $secret must be set');
30+
if (!$key || !$secret) {
31+
throw new \InvalidArgumentException('$key and $secret must be set');
3232
}
3333

34-
$this->token = $token;
34+
$this->key = $key;
3535
$this->secret = $secret;
3636
}
3737

@@ -41,7 +41,7 @@ public function __construct($token, $secret)
4141
protected function doHandleRequest(RequestInterface $request, callable $next, callable $first)
4242
{
4343
$params = [
44-
'key' => $this->token,
44+
'key' => $this->key,
4545
'timestamp' => $this->getTimestamp(),
4646
'cnonce' => $this->getNonce(),
4747
];

Diff for: tests/HttpClient/Plugin/RequestSignatureTest.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ class RequestSignatureTest extends TestCase
1919
private $plugin;
2020
private $next;
2121
private $first;
22-
private $token;
22+
private $key;
2323
private $secret;
2424
private $timestamp;
2525
private $nonce;
2626

2727
protected function setUp(): void
2828
{
29-
$this->token = 'token';
29+
$this->key = 'token';
3030
$this->secret = 'secret';
3131
$this->timestamp = 1518721253;
3232
$this->nonce = '78b9869e96cf58b5902154e0228f8576f042e5ac';
33-
$this->plugin = new RequestSignatureMock($this->token, $this->secret);
33+
$this->plugin = new RequestSignatureMock($this->key, $this->secret);
3434
$this->plugin->init($this->timestamp, $this->nonce);
3535
$this->next = function (Request $request) {
3636
return new FulfilledPromise($request);
@@ -47,7 +47,7 @@ public function testPrefixRequestPath()
4747
'POST',
4848
'/packages/?foo=bar',
4949
[
50-
'Authorization' => ["PACKAGIST-HMAC-SHA256 Key={$this->token}, Timestamp={$this->timestamp}, Cnonce={$this->nonce}, Signature=a6wxBLYrmz4Mwmv/TKBZR5WHFcSCRbsny2frobJMt24="],
50+
'Authorization' => ["PACKAGIST-HMAC-SHA256 Key={$this->key}, Timestamp={$this->timestamp}, Cnonce={$this->nonce}, Signature=a6wxBLYrmz4Mwmv/TKBZR5WHFcSCRbsny2frobJMt24="],
5151
],
5252
json_encode(['foo' => 'bar'])
5353
);
@@ -67,20 +67,20 @@ public function testPrefixRequestPathSmoke()
6767
}
6868

6969
/**
70-
* @dataProvider tokenSecretProvider
70+
* @dataProvider keySecretProvider
7171
*/
72-
public function testMissingTokenOrSecret(string $token, string $secret): void
72+
public function testMissingTokenOrSecret(string $key, string $secret): void
7373
{
7474
$this->expectException(\InvalidArgumentException::class);
7575

76-
new RequestSignature($token, $secret);
76+
new RequestSignature($key, $secret);
7777
}
7878

79-
public function tokenSecretProvider(): array
79+
public function keySecretProvider(): array
8080
{
8181
return [
8282
['', ''],
83-
['token', ''],
83+
['key', ''],
8484
['', 'secret'],
8585
];
8686
}

0 commit comments

Comments
 (0)