PHP Classes

File: tests/cli/command-preamble.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  Chronicle  >  tests/cli/command-preamble.php  >  Download  
File: tests/cli/command-preamble.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Chronicle
Append arbitrary data to a storage container
Author: By
Last change:
Date: 3 years ago
Size: 1,627 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);
namespace
ParagonIE\Chronicle\CliTests;

use
GuzzleHttp\Client;
use
ParagonIE\ConstantTime\Base64UrlSafe;
use
ParagonIE\Sapient\CryptographyKeys\SigningPublicKey;
use
ParagonIE\Sapient\CryptographyKeys\SigningSecretKey;
use
ParagonIE\Sapient\Sapient;

require_once
__DIR__ . '/cli-include.php';

/**
 * @global Client $http
 * @global Sapient $sapient
 * @global SigningPublickey $serverPublicKey
 */
if (!($http instanceof Client) || !($sapient instanceof Sapient) || !($serverPublicKey instanceof SigningPublicKey)) {
    echo
'Include failed', PHP_EOL;
    exit(
1);
}

if (!\
is_readable((__DIR__ . '/client.json'))) {
    echo
'client.json is not found!', PHP_EOL;
    exit(
255);
}
$clientData = \json_decode(\file_get_contents(__DIR__ . '/client.json'), true);
$client = [
   
'secret-key' => new SigningSecretKey(Base64UrlSafe::decode($clientData['secret-key'])),
   
'public-key' => new SigningPublicKey(Base64UrlSafe::decode($clientData['public-key']))
];

if (!\
is_readable((__DIR__ . '/client-admin.json'))) {
    echo
'client-admin.json is not found!', PHP_EOL;
    exit(
255);
}
$clientAdminData = \json_decode(\file_get_contents(__DIR__ . '/client-admin.json'), true);
$clientAdmin = [
   
'secret-key' => new SigningSecretKey(Base64UrlSafe::decode($clientAdminData['secret-key'])),
   
'public-key' => new SigningPublicKey(Base64UrlSafe::decode($clientAdminData['public-key']))
];

/*
$request = $sapient->createSignedJsonRequest(
    'POST',
    $baseUrl . '/chronicle/export',
    [
        'now' => (new \DateTime())->format(\DateTime::ATOM)
    ],
    $client['secret-key']
);
*/

For more information send a message to info at phpclasses dot org.