factory/jurisdiction (0.5.1)
Installation
{
"repositories": [{
"type": "composer",
"url": " "
}
]
}composer require factory/jurisdiction:0.5.1About this package
factory/jurisdiction — v0.2.1
Server-authoritative currency→gateway routing for the factory. Answers one
question — "which payment processor charges this currency?" — and lets a
founder re-answer it without a redeploy. The PHP peer of factory_core's Dart
GatewayRouter: same contract, same wire shape ({currency: gatewayId}), so
client and server never disagree.
Provides
- Gateway catalogue —
config('jurisdiction.gateways'), id → label. The FIXED set of processors with a real integration adapter (mpesa_daraja,paystack,flutterwave,stripe,mtn_momo_api). Code, not data — a route can only point here. MirrorskGatewayCatalogue. - Routing resolver —
GatewayResolver::gatewayForCurrency(), fail-closed: platform-admin override → config default (kDefaultGatewayRouter) → null. An unrouted currency returns null and checkout must refuse, never guess. Overrides pointing at a retired (uncatalogued) gateway are ignored, not trusted. - Editor API —
Http\Controllers\GatewayRouteController:GET /api/gateway-routes(public) —{routes: {currency: gatewayId}, catalogue}. Clients hydrateGatewayRouter.fromJson(data.routes).PUT /api/gateway-routes/{currency}(platform_admin) — assign a catalogue gateway.DELETE /api/gateway-routes/{currency}(platform_admin) — drop the override, fall back to the config default (idempotent).
- Real RBAC on the writes —
factory.auth→factory.scope→factory.role:platform_admin, fromfactory/auth. This package ships no authorization mechanism of its own; it consumes one. - Audited writes — every assign/unassign runs through the kernel audit chokepoint
(
gateway_route.assigned/.unassigned) inside a transaction; audit failure rolls the change back. The actor is resolved by the chokepoint from the authenticated token, so each row names the person who moved the routing.
Data
gateway_routes— global (NOT product-scoped): gateway assignment is a platform-level lever. Primary key is the currency, so a currency routes to exactly one processor. Absent row ⇒ config default ⇒ (if also absent) unrouted.updated_byholds the acting user'sref.
Config expected from the host app
None. config/jurisdiction.php is merged by the provider and needs no env keys.
Upgrading 0.1.x → 0.2.0 (breaking)
The X-Super-Admin-Token shared secret is gone, not deprecated. It was
fail-closed but it authenticated a string rather than a person: one value shared
by everyone who could reroute the world's payments, visible in shell history and
CI logs, rotatable only by locking out everybody at once, and every audit row it
produced said super-admin — recording that somebody knew the secret, never who.
To upgrade:
- Install
factory/auth(^0.1) — it is now a hard requirement. - Grant yourself the platform membership once (
Memberships::grant($user, Membership::PLATFORM, Role::PlatformAdmin)), then mint a token:php artisan factory:token you@example.test --product=__platform__ --name=cockpitThe role — and therefore the ability ceiling — comes from that membership, so a token can never out-rank the person holding it. - Call the editor with
Authorization: Bearer <token>instead ofX-Super-Admin-Token. Send noX-Product-Slug: this table is global, and a platform token with no header deliberately binds no product. - Delete
FACTORY_SUPERADMIN_TOKENfrom every.env— nothing reads it, and a retired secret left in place is one somebody later assumes still works.
config('jurisdiction.super_admin_token') and the factory.super-admin
middleware alias no longer exist; anything still referencing either will fail loudly.
Dependencies
Dependencies
| ID | Version |
|---|---|
| factory/auth | ^0.1 || ^0.2 || ^0.3 || ^0.4 |
| factory/infra | ^0.1 || ^0.2 || ^0.3 |
| factory/kernel | ^0.3 || ^0.4 || ^0.5 || ^0.6 || ^0.7 || ^0.8 || ^0.9 |
| illuminate/database | ^10.0 || ^11.0 || ^12.0 || ^13.0 |
| illuminate/http | ^10.0 || ^11.0 || ^12.0 || ^13.0 |
| illuminate/routing | ^10.0 || ^11.0 || ^12.0 || ^13.0 |
| illuminate/support | ^10.0 || ^11.0 || ^12.0 || ^13.0 |
| php | ^8.2 |
Development dependencies
| ID | Version |
|---|---|
| orchestra/testbench | ^8.0 || ^9.0 || ^10.0 || ^11.0 |
| phpunit/phpunit | ^10.1 || ^11.0 || ^12.0 |