Download the PHP package timefrontiers/api-auth-client without Composer
On this page you can find all versions of the php package timefrontiers/api-auth-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download timefrontiers/api-auth-client
More information about timefrontiers/api-auth-client
Files in timefrontiers/api-auth-client
Package api-auth-client
Short Description Client-side API authentication and request signing
License MIT
Informations about the package api-auth-client
TimeFrontiers API Auth Client
Client-side HMAC request authentication for TimeFrontiers APIs.
Installation
Requirements: PHP 8.5+, ext-curl, and ext-json.
Quick start
public_key is a key selector used by a 1.1 server to cross-check the app and
credential record. It is not an asymmetric public key, is not a second secret,
and is not included in the six canonical lines.
Credentials can also be loaded with Credentials::fromArray() or
Credentials::fromEnv('API'). The latter reads API_APP_ID,
API_PUBLIC_KEY, and API_SECRET_KEY. Credential objects redact the HMAC
secret from debug output and cannot be serialized.
Client configuration
- HTTPS is required. TLS peer and host verification cannot be disabled.
- Redirects are not followed, so credentials are never forwarded implicitly.
- cURL is restricted to HTTPS and performs no automatic retries.
- Positive finite connect and total timeouts up to 86,400 seconds are required; sub-millisecond values safely round up to one millisecond.
- HTTP can only be enabled for
localhost,127.0.0.1, or::1with the explicitallow_http_for_local_development: trueconstructor option. - Base URLs may contain a path. That path becomes part of the exact signed
request-target: base
https://api.example.com/v1plus/userssigns and sends/v1/users.
The verify_ssl argument remains for source compatibility with 1.0 callers,
but passing false now throws. Remove any insecure override before upgrading.
Use withBaseUrl() and withHeaders() to create configured copies. Defaults
and per-request headers are compared case-insensitively. X-App-Id,
X-Public-Key, X-Timestamp, X-Nonce, X-Body-Hash, and X-Signature are
reserved and cannot be supplied by callers.
Request construction
The convenience methods are get(), post(), put(), patch(), and
delete(). request() accepts an exact string body and an already-built
origin-form target:
The path must begin with one /. Absolute URLs, network-path targets beginning
with //, fragments, spaces, controls, and targets over 8192 bytes are
rejected. A manually built query is transmitted without parsing or re-encoding.
The default transport sets both cURL's explicit request-target and path-as-is
controls so dot segments and percent-escape casing remain byte-for-byte intact.
Array queries use RFC 3986 (%20, never +). Associative keys are sorted at
every level and list order is retained. PHP bracket notation represents nested
and repeated values:
JSON bodies recursively sort associative keys and preserve list order. The
exact encoding flags are JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION. Encoding failure throws
ClientConfigurationException with code JSON_ENCODING_ERROR before a
transport is opened.
Signing protocol
The canonical string remains the 1.0 six-line format:
body_hash is lowercase SHA-256 hexadecimal for every non-empty byte string.
The body "0" is non-empty and is hashed. Only '' leaves the final canonical
line empty and omits X-Body-Hash.
A new timestamp and nonce are generated for each physical request. Version 1.1 does not retry. A future retry implementation must re-sign every attempt and limit retries to explicitly retry-safe operations.
Deterministic shared vectors, including empty and "0" bodies, UTF-8 JSON,
RFC 3986 spaces, nested/repeated queries, and an invalid signature, live in
fixtures/protocol-v1.1.json. The paired
timefrontiers/api-auth 1.1 verifier must consume this committed fixture.
JavaScript signing
Python signing
Bash/cURL signing
Injectable transport
ApiClient uses CurlTransport by default. Tests and host applications may
inject HttpTransportInterface. A transport receives one immutable
HttpRequest containing the final URL, exact target, exact body, normalized
headers, timeouts, TLS verification policy, redirect policy, and protocol
allowlist. It returns ApiResponse or throws ApiException for a transport
failure. Implementations must not log request headers or bodies and must not
retry automatically.
Responses and errors
Malformed and scalar JSON are separately observable without changing the
backward-compatible json(): ?array return. Repeated response headers are
retained. Remote error message/code fields are type-normalized and bounded;
large or malformed error bodies produce a generic HTTP error rather than being
copied into an exception.
getBody(), getHeadersMulti(), and getHeaderValues() are explicit raw
accessors. Their values may contain secrets or personal data and must not be
logged. toArray() intentionally returns safe metadata only.
Development
The CI gate runs PHP 8.5 with both highest and lowest supported dependencies.
License
MIT License.
All versions of api-auth-client with dependencies
ext-json Version *
ext-curl Version *