1 | <?php |
||
17 | class Json25519Parser extends JsonParser |
||
18 | { |
||
19 | /** |
||
20 | * @const HASH_HEADER |
||
21 | */ |
||
22 | const HASH_HEADER = 'x-hashid'; |
||
23 | |||
24 | /** |
||
25 | * @const PUBLICKEY_HEADER |
||
26 | */ |
||
27 | const PUBLICKEY_HEADER = 'x-pubkey'; |
||
28 | |||
29 | /** |
||
30 | * @const NONCE_HEADER |
||
31 | */ |
||
32 | const NONCE_HEADER = 'x-nonce'; |
||
33 | |||
34 | /** |
||
35 | * Parses a HTTP request body. |
||
36 | * @param string $rawBody the raw HTTP request body. |
||
37 | * @param string $contentType the content type specified for the request body. |
||
38 | * @return array parameters parsed from the request body |
||
39 | * @throws BadRequestHttpException if the body contains invalid json and [[throwException]] is `true`. |
||
40 | */ |
||
41 | public function parse($rawBody, $contentType) |
||
73 | |||
74 | /** |
||
75 | * Decrypts the raw body using TokenKeyPair, the client submitted nonce and crypto_box_open |
||
76 | * @param TokenKeyPair $token |
||
77 | * @param string $nonce |
||
78 | * @param string $rawBody |
||
79 | * @return string |
||
80 | */ |
||
81 | private function getRawBodyFromTokenAndNonce($token, $nonce, $rawBody) |
||
98 | |||
99 | /** |
||
100 | * Decrypts the raw body using TokenKeyPair and crypto_box_seal_open |
||
101 | * @param TokenKeyPair $token |
||
102 | * @param string $rawBody |
||
103 | * @return string |
||
104 | */ |
||
105 | private function getRawBodyFromToken($token, $rawBody) |
||
119 | |||
120 | /** |
||
121 | * Helper method to retrieve and valdiate the token |
||
122 | * @return Token |
||
123 | */ |
||
124 | public static function getTokenFromHash($hash) |
||
139 | } |