artisan-build / crate-client
The client package for Crate private Composer registry integrations.
Requires
- php: ^8.3
- artisan-build/bfc-client: ^0.2.0
- artisan-build/crate-contracts: ^1.0
- illuminate/console: ^11.17 || ^12.0 || ^13.0
- illuminate/contracts: ^11.17 || ^12.0 || ^13.0
- illuminate/http: ^11.17 || ^12.0 || ^13.0
- illuminate/support: ^11.17 || ^12.0 || ^13.0
- symfony/console: ^7.0 || ^8.0
Requires (Dev)
- laravel/pint: ^1.27
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Client-side helpers for Crate.
See the default integration guide for agent-ready installation, configuration, API, and verification steps.
This package has two surfaces:
- Consumer auth helper: write Composer HTTP Basic auth for a Crate registry.
- Issuer SDK: call a Crate deployment's unified
/bfc/credentialsendpoint with an operator service credential.
Consumer Helper
Configure the customer app with the Crate registry URL and an issued registry credential:
CRATE_URL=https://crate.example.com CRATE_TOKEN=issued-registry-credential
Generate Composer auth:
php artisan crate:auth
By default, crate:auth writes or merges auth.json in the current working directory. It adds this shape:
{
"http-basic": {
"crate.example.com": {
"username": "token",
"password": "issued-registry-credential"
}
}
}
Use a different path with --path:
php artisan crate:auth --path=/path/to/auth.json
Print the JSON instead of writing a file with --print, which is useful for COMPOSER_AUTH in CI:
export COMPOSER_AUTH="$(php artisan crate:auth --print)"
Then configure Composer to use the Crate registry and require packages normally:
composer config repositories.crate composer https://crate.example.com composer require vendor/pkg
Issuer SDK
Use CrateIssuer in the operator's own Laravel app to issue and revoke credentials around billing, onboarding, or access logic that you own.
Configure the issuer client:
CRATE_ISSUER_URL=https://crate.example.com CRATE_SERVICE_TOKEN=operator-service-credential CRATE_ISSUER_SUBJECT_REF=build-bot CRATE_ISSUER_RETRIES=2 CRATE_ISSUER_RETRY_SLEEP=100
CRATE_ISSUER_URL defaults to CRATE_URL when omitted.
Example:
use ArtisanBuild\CrateClient\CrateIssuer; $issuer = CrateIssuer::fromConfig(); $issued = $issuer->issue('build-bot'); $credentials = $issuer->list(); $rotated = $issuer->rotate($issued['credential']['id']); $issuer->revoke($rotated['credential']['id']);
The SDK calls:
POST /bfc/credentialsforissue(...), fixed to installation-owned Basicconsumptioncredentials.GET /bfc/credentialsforlist(), returning summaries without secret material.POST /bfc/credentials/{id}/rotateforrotate(...), returning replacement delivery once.DELETE /bfc/credentials/{id}forrevoke(...).
Requests use Bearer auth with CRATE_SERVICE_TOKEN, accept JSON, carry bfc-client's canonical client identity and contract-version headers, retry according to config, and throw on non-2xx responses. The service credential needs the matching closed credential verb abilities. Client identity is metadata, not authorization.