Skip to content

Commit b8af65c

Browse files
Docblocks
1 parent 4fe4ecd commit b8af65c

File tree

6 files changed

+48
-22
lines changed

6 files changed

+48
-22
lines changed

src/Chronicle/Handlers/Index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Index implements HandlerInterface
3030
* @param array $args
3131
* @return ResponseInterface
3232
*
33+
* @throws \Exception
3334
* @throws FilesystemException
3435
*/
3536
public function __invoke(

src/Chronicle/Handlers/Lookup.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
22
namespace ParagonIE\Chronicle\Handlers;
33

4-
use ParagonIE\Chronicle\{
5-
Chronicle,
4+
use ParagonIE\Chronicle\{Chronicle,
65
Exception\FilesystemException,
76
Exception\HashNotFound,
8-
HandlerInterface
9-
};
7+
Exception\InvalidInstanceException,
8+
HandlerInterface};
109
use Psr\Http\Message\{
1110
RequestInterface,
1211
ResponseInterface
@@ -75,7 +74,10 @@ public function __invoke(
7574
*
7675
* @return ResponseInterface
7776
*
77+
* @throws \Exception
78+
* @return ResponseInterface
7879
* @throws FilesystemException
80+
* @throws InvalidInstanceException
7981
*/
8082
public function exportChain(): ResponseInterface
8183
{
@@ -97,6 +99,7 @@ public function exportChain(): ResponseInterface
9799
* @param array $args
98100
* @return ResponseInterface
99101
*
102+
* @throws \Exception
100103
* @throws FilesystemException
101104
* @throws HashNotFound
102105
*/
@@ -172,8 +175,10 @@ public function getLastHash(): ResponseInterface
172175
* @param array $args
173176
* @return ResponseInterface
174177
*
178+
* @throws \Exception
175179
* @throws FilesystemException
176180
* @throws HashNotFound
181+
* @throws InvalidInstanceException
177182
*/
178183
public function getSince(array $args = []): ResponseInterface
179184
{
@@ -228,6 +233,7 @@ public function getSince(array $args = []): ResponseInterface
228233
* Get the entire chain, as-is, as of the time of the request.
229234
*
230235
* @return array
236+
* @throws InvalidInstanceException
231237
*/
232238
protected function getFullChain(): array
233239
{

src/Chronicle/Handlers/Publish.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
namespace ParagonIE\Chronicle\Handlers;
33

44
use GuzzleHttp\Exception\GuzzleException;
5-
use ParagonIE\Chronicle\{
6-
Chronicle,
5+
use ParagonIE\Chronicle\{Chronicle,
6+
Exception\BaseException,
77
Exception\ChainAppendException,
88
Exception\ClientNotFound,
99
Exception\FilesystemException,
1010
Exception\SecurityViolation,
1111
Exception\TargetNotFound,
1212
HandlerInterface,
13-
Scheduled
14-
};
13+
Scheduled};
1514
use ParagonIE\Sapient\CryptographyKeys\SigningPublicKey;
1615
use ParagonIE\Sapient\Exception\InvalidMessageException;
1716
use ParagonIE\Sapient\Sapient;
@@ -36,6 +35,7 @@ class Publish implements HandlerInterface
3635
* @param array $args
3736
* @return ResponseInterface
3837
*
38+
* @throws BaseException
3939
* @throws ChainAppendException
4040
* @throws ClientNotFound
4141
* @throws FilesystemException
@@ -99,11 +99,17 @@ public function __invoke(
9999
// If we need to do a cross-sign, do it now:
100100
(new Scheduled())->doCrossSigns();
101101

102+
try {
103+
$now = (new \DateTime())->format(\DateTime::ATOM);
104+
} catch (\Exception $ex) {
105+
return Chronicle::errorResponse($response, $ex->getMessage(), 500);
106+
}
107+
102108
return Chronicle::getSapient()->createSignedJsonResponse(
103109
200,
104110
[
105111
'version' => Chronicle::VERSION,
106-
'datetime' => (new \DateTime())->format(\DateTime::ATOM),
112+
'datetime' => $now,
107113
'status' => 'OK',
108114
'results' => $result
109115
],
@@ -119,6 +125,7 @@ public function __invoke(
119125
* @param RequestInterface $request
120126
* @return array
121127
*
128+
* @throws BaseException
122129
* @throws SecurityViolation
123130
* @throws ClientNotFound
124131
*/

src/Chronicle/Handlers/Register.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
namespace ParagonIE\Chronicle\Handlers;
33

44
use GuzzleHttp\Exception\GuzzleException;
5-
use ParagonIE\Chronicle\{
6-
Chronicle,
5+
use ParagonIE\Chronicle\{Chronicle,
6+
Exception\BaseException,
77
Exception\ChainAppendException,
88
Exception\FilesystemException,
9+
Exception\InvalidInstanceException,
910
Exception\SecurityViolation,
1011
Exception\TargetNotFound,
1112
HandlerInterface,
12-
Scheduled
13-
};
13+
Scheduled};
1414
use ParagonIE\ConstantTime\Base64UrlSafe;
1515
use ParagonIE\Sapient\CryptographyKeys\SigningPublicKey;
1616
use ParagonIE\Sapient\Exception\InvalidMessageException;
@@ -35,13 +35,14 @@ class Register implements HandlerInterface
3535
* @param array $args
3636
* @return ResponseInterface
3737
*
38-
* @throws ChainAppendException
38+
* @throws \Exception
39+
* @throws BaseException
3940
* @throws FilesystemException
4041
* @throws GuzzleException
4142
* @throws InvalidMessageException
4243
* @throws SecurityViolation
43-
* @throws \SodiumException
4444
* @throws TargetNotFound
45+
* @throws \SodiumException
4546
*/
4647
public function __invoke(
4748
RequestInterface $request,
@@ -161,7 +162,8 @@ public function __invoke(
161162
* @param array $post
162163
* @return string
163164
*
164-
* @throws \PDOException
165+
* @throws \Exception
166+
* @throws InvalidInstanceException
165167
* @throws SecurityViolation
166168
*/
167169
protected function createClient(array $post): string

src/Chronicle/Handlers/Replica.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct(string $method = 'index')
4545
* @param array $args
4646
* @return ResponseInterface
4747
*
48+
* @throws \Exception
4849
* @throws FilesystemException
4950
*/
5051
public function __invoke(
@@ -96,6 +97,7 @@ public function __invoke(
9697
*
9798
* @return ResponseInterface
9899
*
100+
* @throws \Exception
99101
* @throws FilesystemException
100102
*/
101103
public function exportChain(): ResponseInterface
@@ -119,6 +121,7 @@ public function exportChain(): ResponseInterface
119121
* @param array $args
120122
* @return ResponseInterface
121123
*
124+
* @throws \Exception
122125
* @throws HashNotFound
123126
* @throws FilesystemException
124127
* @throws InvalidInstanceException
@@ -210,6 +213,7 @@ public function getLastHash(): ResponseInterface
210213
*
211214
* @return ResponseInterface
212215
*
216+
* @throws \Exception
213217
* @throws FilesystemException
214218
* @throws InvalidInstanceException
215219
*/
@@ -264,6 +268,7 @@ protected function getIndex(): ResponseInterface
264268
* @param array $args
265269
* @return ResponseInterface
266270
*
271+
* @throws \Exception
267272
* @throws FilesystemException
268273
* @throws HashNotFound
269274
* @throws InvalidInstanceException

src/Chronicle/Handlers/Revoke.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
namespace ParagonIE\Chronicle\Handlers;
33

44
use GuzzleHttp\Exception\GuzzleException;
5-
use ParagonIE\Chronicle\{
6-
Chronicle,
5+
use ParagonIE\Chronicle\{Chronicle,
76
Exception\AccessDenied,
8-
Exception\ChainAppendException,
7+
Exception\BaseException,
98
Exception\FilesystemException,
9+
Exception\InvalidInstanceException,
1010
Exception\TargetNotFound,
1111
HandlerInterface,
1212
Scheduled};
@@ -34,12 +34,13 @@ class Revoke implements HandlerInterface
3434
* @return ResponseInterface
3535
*
3636
* @throws AccessDenied
37-
* @throws ChainAppendException
37+
* @throws BaseException
3838
* @throws FilesystemException
3939
* @throws GuzzleException
40+
* @throws InvalidInstanceException
4041
* @throws InvalidMessageException
41-
* @throws \SodiumException
4242
* @throws TargetNotFound
43+
* @throws \SodiumException
4344
*/
4445
public function __invoke(
4546
RequestInterface $request,
@@ -134,7 +135,11 @@ public function __invoke(
134135
if (!$result['deleted']) {
135136
$result['reason'] = 'Delete operation was unsuccessful due to unknown reasons.';
136137
}
137-
$now = (new \DateTime())->format(\DateTime::ATOM);
138+
try {
139+
$now = (new \DateTime())->format(\DateTime::ATOM);
140+
} catch (\Exception $ex) {
141+
return Chronicle::errorResponse($response, $ex->getMessage(), 500);
142+
}
138143

139144
$settings = Chronicle::getSettings();
140145
if (!empty($settings['publish-revoked-clients'])) {

0 commit comments

Comments
 (0)