Search by

proit365 / multikey-auth

ProIT365

PHP client SDK for ProIT365 MultiKey Auth MKAP v1

v1.0.0 2026-11-22 05:33 UTC

This package is auto-updated.

Last update: 2026-11-22 06:49:46 UTC


README

proit365/multikey-auth provides PHP request signing against an MKAP v1 server. It validates client exports, obtains a challenge, derives the proof internally, and returns the target API's normal HTTP response.

Installation

After the package and its Core dependency are available from Packagist:

composer require proit365/multikey-auth:^1.0

The package requires PHP ^8.2; Core requires the OpenSSL PHP extension.

Usage

use ProIT365\MultiKeyAuth\Client\ClientConfig;
use ProIT365\MultiKeyAuth\Client\ExportLoader;
use ProIT365\MultiKeyAuth\Client\PhpMultiKeyClient;
use ProIT365\MultiKeyAuth\Core\Key\IdentifierGenerator;

$keyPool = (new ExportLoader())->fromJson($exportJson);
$client = new PhpMultiKeyClient(
    new ClientConfig(
        'https://api.example.test',
        'CLIENT_001',
        1,
        6,
        IdentifierGenerator::DEFAULT_ALPHABET
    ),
    $keyPool,
    $httpTransport
);

$response = $client->request('POST', '/api/orders', $exactBodyBytes);

Provide an implementation of HttpTransportInterface. The transport must preserve the supplied HTTP method, request target, body bytes, and headers, and must not follow redirects. Redirecting a signed request can change the origin or request target outside the proof binding.

The base URI must be HTTPS by default and contain no path, query, credentials, or fragment. HTTP is allowed only when requireHttps is explicitly disabled for development or testing.

request() accepts the exact body string to send. It does not serialize application payloads; serialize once in the application and pass those bytes unchanged. Challenge endpoint errors throw ChallengeRequestFailedException. Malformed or oversized challenge responses throw InvalidChallengeResponseException. API responses, including non-2xx responses, are returned as HttpResponse. In particular, an API 401 is returned unchanged. The SDK does not replay requests automatically because a 401 can also be an application response after the server has already authorized the request.

The SDK keeps validated secrets in memory for the lifetime of the loaded pool. Protect the export and process memory appropriately. A complete export compromise allows client impersonation.

Source and support

Project website: https://www.proit365.com.

The monorepo is the development source of truth: github.com/proit365/multikey-auth. Report issues through its issue tracker.