Client
in package
A typed, synchronous client for hush-hush, a standalone secrets object store.
Tags
Table of Contents
Constants
- API_KEY_ENV_VAR : mixed = 'HUSH_HUSH_API_KEY'
- DEFAULT_MAX_RETRIES : mixed = 3
- DEFAULT_TIMEOUT : mixed = 30.0
Properties
- $auditLogApi : AuditLogApi
- $healthApi : HealthApi
- $objectsApi : ObjectsApi
Methods
- __construct() : mixed
- createObject() : ObjectMetadata
- Stores an already-sealed value under a new object id. Requires a credential.
- deleteObject() : void
- Permanently removes an object. A subsequent fetch by this id returns 404.
- getObject() : string
- Fetches an object's sealed ciphertext exactly as stored — this SDK never decrypts it, the same as the server. Needs no credential.
- getObjectUsedBy() : UsedBy
- Returns the recorded list of consumers for an object — the "what depends on this" mapping set at creation. Needs no credential.
- health() : Health
- Answers whether the server process is up. Needs no credential.
- queryAuditLog() : array<string|int, AuditLogEntry>
- Queries the audit log — every create, read, update, and delete call is recorded here. Needs no credential. Filters combine with AND when more than one is given.
- updateObject() : ObjectMetadata
- Replaces the stored ciphertext for an existing object. The object's id and used-by metadata are unchanged. Requires a credential.
- buildHttpClient() : Client
- call() : T
- expectType() : T
- Generated methods declare a return type spanning every documented status code's model, since the generator has no way to know a 2xx-only shape at codegen time — a spec-conforming server only ever produces the success type here, since every non-2xx status routes through {@see GeneratedApiException} instead (Guzzle's default `http_errors` behavior). This just makes that guarantee explicit for the type checker and callers alike.
Constants
API_KEY_ENV_VAR
private
mixed
API_KEY_ENV_VAR
= 'HUSH_HUSH_API_KEY'
DEFAULT_MAX_RETRIES
private
mixed
DEFAULT_MAX_RETRIES
= 3
DEFAULT_TIMEOUT
private
mixed
DEFAULT_TIMEOUT
= 30.0
Properties
$auditLogApi
private
AuditLogApi
$auditLogApi
$healthApi
private
HealthApi
$healthApi
$objectsApi
private
ObjectsApi
$objectsApi
Methods
__construct()
public
__construct(string $baseUrl[, null|string $apiKey = null ][, float $timeout = self::DEFAULT_TIMEOUT ][, int $maxRetries = self::DEFAULT_MAX_RETRIES ][, null|ClientInterface $httpClient = null ]) : mixed
Parameters
- $baseUrl : string
-
hush-hush's base URL, e.g.
https://hush-hush.example.com. - $apiKey : null|string = null
-
Bearer credential for write paths (create/update/delete). Falls back to the
HUSH_HUSH_API_KEYenvironment variable when not supplied. Read paths (get, used-by, audit-log query) need no credential at all. - $timeout : float = self::DEFAULT_TIMEOUT
-
per-request timeout, in seconds
- $maxRetries : int = self::DEFAULT_MAX_RETRIES
-
maximum retry attempts for network failures and 5xx/429 responses
- $httpClient : null|ClientInterface = null
-
Override for the underlying HTTP client, mainly for tests. When given,
$timeoutand$maxRetriesare ignored — the caller owns retry/timeout configuration on the client it passes in.
createObject()
Stores an already-sealed value under a new object id. Requires a credential.
public
createObject(string $id, string $value[, null|array<string|int, string> $usedBy = null ][, null|string $caller = null ]) : ObjectMetadata
Parameters
- $id : string
-
The new object's id. Must match hush-hush's id pattern (lowercase alphanumeric,
-/_). - $value : string
-
The already-sealed (encrypted) value, as raw bytes. This SDK never encrypts or decrypts anything.
- $usedBy : null|array<string|int, string> = null
-
Consumers (repos or hosts) recorded as depending on this object. Set once, at creation; unaffected by later value updates.
- $caller : null|string = null
-
Recorded in the audit log as the calling program's self-reported identity. Not verified by the server.
Tags
Return values
ObjectMetadatadeleteObject()
Permanently removes an object. A subsequent fetch by this id returns 404.
public
deleteObject(string $id[, null|string $caller = null ]) : void
Requires a credential.
Parameters
- $id : string
-
the object's id
- $caller : null|string = null
-
recorded in the audit log as the calling program's self-reported identity
Tags
getObject()
Fetches an object's sealed ciphertext exactly as stored — this SDK never decrypts it, the same as the server. Needs no credential.
public
getObject(string $id[, null|string $caller = null ]) : string
Parameters
- $id : string
-
the object's id
- $caller : null|string = null
-
recorded in the audit log as the calling program's self-reported identity
Tags
Return values
stringgetObjectUsedBy()
Returns the recorded list of consumers for an object — the "what depends on this" mapping set at creation. Needs no credential.
public
getObjectUsedBy(string $id) : UsedBy
Parameters
- $id : string
-
the object's id
Tags
Return values
UsedByhealth()
Answers whether the server process is up. Needs no credential.
public
health() : Health
Return values
HealthqueryAuditLog()
Queries the audit log — every create, read, update, and delete call is recorded here. Needs no credential. Filters combine with AND when more than one is given.
public
queryAuditLog([array{objectId?: string, caller?: string, from?: string, to?: string} $filter = [] ]) : array<string|int, AuditLogEntry>
hush-hush's /audit-log endpoint has no pagination parameters, so this
always returns the full matching result set as a single array, never a page
plus a cursor.
Parameters
- $filter : array{objectId?: string, caller?: string, from?: string, to?: string} = []
-
Optional filters.
objectIdrestricts to entries for that object id;callerto entries recorded with that caller identity;from/to(ISO-8601 timestamps) bound the timestamp range.
Return values
array<string|int, AuditLogEntry>updateObject()
Replaces the stored ciphertext for an existing object. The object's id and used-by metadata are unchanged. Requires a credential.
public
updateObject(string $id, string $value[, null|string $caller = null ]) : ObjectMetadata
Parameters
- $id : string
-
the existing object's id
- $value : string
-
the new already-sealed (encrypted) value, as raw bytes
- $caller : null|string = null
-
recorded in the audit log as the calling program's self-reported identity
Tags
Return values
ObjectMetadatabuildHttpClient()
private
static buildHttpClient(float $timeout, int $maxRetries) : Client
Parameters
- $timeout : float
- $maxRetries : int
Return values
Clientcall()
private
call(callable(): T $fn) : T
Parameters
- $fn : callable(): T
Tags
Return values
TexpectType()
Generated methods declare a return type spanning every documented status code's model, since the generator has no way to know a 2xx-only shape at codegen time — a spec-conforming server only ever produces the success type here, since every non-2xx status routes through {@see GeneratedApiException} instead (Guzzle's default `http_errors` behavior). This just makes that guarantee explicit for the type checker and callers alike.
private
static expectType(mixed $value, T> $class) : T
Parameters
- $value : mixed
- $class : T>