web-auth/cose-lib
PHP 8.1+ COSE (RFC 9052/9053) library supporting Sign1/Sign, Encrypt0/Encrypt, Mac0/Mac with full tag support. Implements ECDSA, EdDSA, RSA and HMAC algorithms for signing, encryption and MAC; compatible with WebAuthn/FIDO2.
spomky-labs/cbor-php (adds ~100KB dependency).Illuminate\Contracts\Encryption).CoseServiceProvider).webauthn/webauthn-php for FIDO2 attestation.typhoon/php-jwt for compact signatures (COSE_Sign1 vs. JWT).league/encrypted-storage for structured encryption.| Risk Area | Mitigation Strategy |
|---|---|
| CBOR Parsing Overhead | Benchmark against JSON alternatives (e.g., firebase/php-jwt). |
| Algorithm Support Gaps | Audit required algorithms (e.g., if only ES256 is needed, simplify dependency). |
| Key Management | Integrate with Laravel’s config/cose.php for key storage (e.g., AWS KMS, HashiCorp). |
| Performance | Profile COSE operations vs. OpenSSL direct calls (e.g., openssl_sign). |
| Debugging Complexity | Add Laravel logging middleware for COSE payloads (e.g., CoseLogMiddleware). |
webauthn/webauthn-php) handle the use case without COSE?CoseException or integrate with Laravel’s ProblemDetails?laravel/sanctum JWTs with COSE_Sign1 for smaller tokens.webauthn/webauthn-php for attestation assertions.web-auth/cose-lib (COSE logic).spomky-labs/cbor-php (required for tag support).brick/math, spomky-labs/pki-framework (included as dependencies).paragonie/sodium-compat for EdDSA/Ed25519 (if not using OpenSSL).| Phase | Action | Laravel Integration Point |
|---|---|---|
| 1. Evaluation | Benchmark COSE vs. JSON/JWT for target use case (e.g., WebAuthn attestation). | config/auth.php (WebAuthn config). |
| 2. Dependency | Add web-auth/cose-lib and spomky-labs/cbor-php to composer.json. |
config/cose.php (new). |
| 3. Service Layer | Create CoseService (e.g., app/Services/CoseService.php) to wrap COSE operations. |
Illuminate\Support\Facades\Cose. |
| 4. Use Case | Implement COSE_Sign1 for WebAuthn or COSE_Mac for API auth. | app/Http/Middleware/CoseAuth.php. |
| 5. Storage | Define database schema for COSE payloads (BLOB fields). | migrations/xxxx_create_cose_payloads.php. |
| 6. Testing | Add tests for COSE operations (e.g., tests/Feature/CoseSignatureTest.php). |
phpunit.xml (include COSE tests). |
webauthn/webauthn-php (attestation assertions).league/encrypted-storage for structured encryption.typhoon/php-jwt for compact signatures.File facade or Storage can handle CBOR binary data.mediumBlob (MySQL) or bytea (PostgreSQL).CoseService to Laravel’s service container.CoseAuthMiddleware).CosePayload::fromBlob()).web-auth/cose-lib and spomky-labs/cbor-php for security patches.composer normalize + php-cs-fixer to manage dependency updates.cose.signature.verified, cose.encryption.failed).Log facade or structured logging (e.g., monolog).php artisan cose:decode --payload=base64_data
CoseInvalidSignatureException).ProblemDetails for API errors.README.md.How can I help you explore Laravel packages today?