Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sapient Laravel Package

paragonie/sapient

Sapient is a PHP cryptography library from Paragon Initiative Enterprises offering simple, misuse-resistant APIs for authenticated symmetric encryption, public-key encryption, and digital signatures, built on libsodium with versioned ciphertexts and key-management helpers.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy for machine-to-machine API security. Sapient is a concrete "buy" option for signed/encrypted service-to-service HTTP calls, so it shifts the conversation from "we'll design our own HMAC scheme" to "do we adopt a libsodium-based scheme or roll our own?" That is the highest-leverage decision this package informs.
  • Roadmap item: partner/B2B API hardening. If your roadmap includes opening an API to third-party integrators or accepting webhooks from partners, Sapient gives you an authenticated-encryption envelope (XChaCha20-Poly1305 symmetric mode; public-key sign/seal mode) in a few lines rather than a quarter of platform work.
  • Compliance and audit narratives. SOC 2 / ISO 27001 / PCI DSS / HIPAA questionnaires frequently ask how inter-service traffic is authenticated and protected. Adopting (or explicitly rejecting) a vetted library like Sapient is defensible evidence of a "don't roll your own crypto" posture; it also reduces the reviewer questions you must answer about a bespoke scheme.
  • Scope control on internal microservices. For internal, low-volume service calls where mTLS is operationally heavy (no service mesh, shared hosting, legacy PHP workers), Sapient's application-layer encryption is a smaller lift than standing up a PKI.
  • Data-flow architecture decisions. Choosing Sapient implies an application-layer crypto boundary that survives TLS termination at a load balancer — useful when deciding whether sensitive payloads may cross third-party proxies, CDNs, or WAFs in plaintext.
  • Dependency and vendor-risk review. This is a single-maintainer-organization package (Paragon Initiative Enterprises) with ~300 stars. That fact belongs in your dependency register and should drive a "what's our exit cost?" answer, not a feature ticket.
  • Use cases where it fits well: server-to-server request signing, encrypted webhook payloads, license/activation handshakes, signed internal RPC, and tamper-evident callbacks where you cannot assume a trusted network path.

When to Consider This Package

Adopt it when most of these hold:

  • You control both endpoints (or can mandate the protocol for a partner) and can ship a small SDK or shared key out-of-band.
  • Your stack is server-side PHP with a PSR-7/PSR-18 HTTP client already in play — Sapient's natural integration point is a request/response middleware, not a Laravel facade.
  • The threat you are mitigating is payload tampering, spoofed callers, or plaintext exposure past TLS termination — not user authentication, authorization, or rate limiting.
  • You want asymmetric mode so the receiving service only holds a public key, or symmetric mode for simpler high-throughput internal hops.
  • You accept the operational obligations: key generation and rotation, secret storage (Vault/KMS/Secrets Manager), and a replay-protection layer (nonce/timestamp cache) that the library does not provide for you.
  • You have someone who will read the actual docs and pin the version — this is security plumbing, not a drop-in feature.

Look elsewhere when:

  • You need OAuth 2.0 / OIDC / JWT / scopes. Sapient is not an identity or authorization product; it authenticates the message, not the user.
  • mTLS or a service mesh is available and accepted. Mutual TLS plus a WAF is often the cheaper, better-supported story, and auditors already know it.
  • You need a Laravel-native package. There is no first-party service provider, config file, or Artisan tooling — Laravel teams must write their own middleware, key resolution, and test helpers. That integration cost is real and should be estimated before you commit.
  • The client is not PHP. Non-PHP consumers require reimplementing the protocol (or a compatible library) — an underrated cost in cross-language shops.
  • You need high-throughput, high-volume signing. Per-request libsodium work plus key lookups can become a hot path; benchmark before committing a core payment flow.
  • Your team is small and the risk is low. For two internal services on a private subnet, signed HMAC plus TLS is sufficient and easier to reason about.
  • You need long-term vendor support with SLAs. There is community support only; plan for an escape hatch.

How to Pitch It (Stakeholders)

One line: A small, MIT-licensed PHP library from a well-known security research group that lets our services cryptographically sign and encrypt API traffic at the application layer — so we don't invent our own crypto and don't have to block partner integrations on a service mesh.

For executives: It's a low-licensing-cost, low-commitment way to answer "how do we prove our service-to-service and partner traffic is authentic and tamper-proof?" in security reviews. It compresses a multi-sprint platform effort into a middleware integration, keeps sensitive payloads encrypted even past TLS termination at the load balancer, and gives us a defensible "we use a vetted cryptography library" answer in audits. The main risk is not technical — it's concentration on a single upstream maintainer, which we mitigate by pinning the version and designing the integration behind our own thin interface so we can swap implementations later.

For engineering: It's libsodium under the hood — XChaCha20-Poly1305 authenticated encryption for shared-key mode, and sign/seal public-key mode for asymmetric flows. Integration is a PSR-7 request/response middleware: build headers on the way out, verify/decrypt on the way in. It is framework-agnostic, so Laravel teams write their own service provider and middleware; budget for that plus key management and replay protection (nonce or timestamp cache), which are ours to own. Success criteria: a working sign/verify path in staging, a documented rotation runbook, and a benchmark showing the per-request overhead is acceptable on our hottest endpoint.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib