pps-php

Server Integration

This document explains how to integrate PPS-PHP into a server application.


Core Server Components

ChallengeGenerator
NonceManager
RegistrationHandler
AuthenticationHandler
TransactionHandler
DuressHandler
StorageInterface

Storage Backends

Available backends:

use Pps\Storage\InMemoryStorage;
use Pps\Storage\FileStorage;
use Pps\Storage\PdoStorage;
use Pps\Storage\RedisStorage;

In-Memory

$storage = new InMemoryStorage();

For testing only.

File

$storage = new FileStorage('/var/lib/pps');

For development or single-process apps.

PDO

$pdo = new PDO('mysql:host=localhost;dbname=pps', 'user', 'pass');
$storage = new PdoStorage($pdo);

For production.

Redis

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$storage = new RedisStorage($redis);

For high-performance distributed systems.


Registration Endpoint

use Pps\Server\RegistrationHandler;

$handler = new RegistrationHandler($storage);
$challenge = $handler->createChallenge('example.com');

$result = $handler->verify(
    token: $request->input('registration_token'),
    rpId: 'example.com',
    nonceB64u: $challenge->nonceB64u
);

Authentication Endpoint

use Pps\Server\AuthenticationHandler;

$handler = new AuthenticationHandler($storage);
$result = $handler->verify(
    pulseToken: $request->input('pulse_token'),
    rpId: 'example.com',
    nonceB64u: $request->input('nonce'),
    trustCode: $request->input('trust_code')
);

if ($result->honey) {
    return response()->json(['status' => 'ok']);
}

if (!$result->ok) {
    return response()->json(['status' => 'error'], 401);
}

return response()->json(['status' => 'ok']);

Rate Limiting

Recommended limits:

5 failed attempts per account per 15 minutes
20 failed attempts per IP per hour
1 Trust Code attempt per session per 30 seconds

Logging

Log:

registration
successful authentication
failed authentication
nonce reuse
counter replay
duress events
key rotations
threshold approvals

Do not log:

private keys
seeds
full sensitive transaction data
raw biometric data