lookyman / chronicle-api
This package is abandoned and no longer maintained.
No replacement package was suggested.
Client library for interacting with Chronicle
2.0.1
2018-01-25 12:57 UTC
Requires
- php: ^7.1
- http-interop/http-factory: ^0.3.0
- paragonie/sapient: ^1.0
- paragonie/sodium_compat: ^1.5.5
- php-http/httplug: ^1.1
- roave/security-advisories: dev-master
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^0.9.2
- lookyman/coding-standard: ^0.1.0
- phpstan/phpstan: ^0.9.1
- phpstan/phpstan-phpunit: ^0.9.3
- phpstan/phpstan-strict-rules: ^0.9.0
- phpunit/phpunit: ^6.1
This package is auto-updated.
Last update: 2024-05-04 16:01:58 UTC
README
Client library for interacting with Chronicle.
Installation
composer require lookyman/chronicle-api
Usage
use Lookyman\Chronicle\Api; use ParagonIE\ConstantTime\Base64UrlSafe; use ParagonIE\Sapient\CryptographyKeys\SigningPublicKey; use ParagonIE\Sapient\CryptographyKeys\SigningSecretKey; $api = new Api( new Client(), // Client must implement Http\Client\HttpAsyncClient new RequestFactory(), // RequestFactory must implement Interop\Http\Factory\RequestFactoryInterface 'https://chronicle.uri', new SigningPublicKey(Base64UrlSafe::decode('chronicle public key')) // optional, omit if you don't care about validating API responses ); var_dump($api->lastHash()->wait()); // you must authenticate first before you can publish a message $api->authenticate( new SigningSecretKey(Base64UrlSafe::decode('your secret key')), 'your client id' ); var_dump($api->publish('hello world')->wait());
For implementations of client and request factory, you can use for example Guzzle 6 HTTP Adapter and HTTP Factory for Guzzle respectively.
All endpoints return Http\Promise\Promise
, so you can either just ->wait()
for the response, or handle it asynchronously with ->then()
. Responses are just plain arrays, look up the structure in the Chronicle's documentation.