Download the PHP package crumbls/sealcraft without Composer

On this page you can find all versions of the php package crumbls/sealcraft. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sealcraft

Sealcraft

KMS-backed, field-level encryption for Laravel. Runs alongside Laravel's built-in Crypt -- it does not replace it.

What this is

Sealcraft encrypts specific database columns with short-lived Data Encryption Keys (DEKs) that are wrapped by a long-lived Key Encryption Key (KEK) inside a cloud KMS. Use it when a particular column needs KMS-backed key custody, documented rotation, per-tenant isolation, or cryptographic destruction on demand.

Sealcraft does not replace Laravel's Crypt facade or encrypted cast. Those keep doing what they do best -- sessions, cookies, signed URLs, queue payloads, and casual field encryption where APP_KEY custody is acceptable. Most apps that adopt Sealcraft still use Crypt everywhere else.

Use cases

How it works: a plaintext DEK is unwrapped on demand, cached in memory for the request, and the primary DEK reference is best-effort zeroed at request termination. PHP's string immutability and copy-on-write semantics mean transient copies created inside cipher and KMS provider calls may persist until garbage collection; the zeroing guarantee covers the single in-memory cache slot only. Rotating the KEK rewraps one DB row per tenant; column ciphertext never changes.

When NOT to use this

Install

sealcraft:install publishes config, publishes the migration, and runs migrate. sealcraft:verify round-trips a synthetic DEK through your configured provider and cipher so you know the deploy is actually wired up. Both commands are idempotent.

If you need to run the steps manually (for example in a CI pipeline that runs migrations separately), the low-level form still works:

Provider SDKs are optional — install only what you use:

Quick start

Model integration

That's it. Reads and writes transparently encrypt. Null values stay null.

Structured columns — encrypt JSON leaves while preserving shape

Need to keep a column queryable as a JSON tree (so admin tools, analytics, or schema validators can see keys and structure) while protecting the inner values? Use the EncryptedJson cast.

On disk, the column stays valid JSON — every leaf string is individually encrypted under the same DEK as the row's scalar encrypted columns, while keys, nesting, and non-string scalars (ints, floats, bools, nulls) remain readable. On read, leaves that carry a cipher prefix are decrypted; strings without a prefix pass through unchanged so columns can mix plaintext shape data with encrypted leaves.

AWS KMS

.env:

GCP Cloud KMS

Bind your token resolver in a service provider (ADC, workload identity, etc.):

Azure Key Vault

Azure's wrapKey/unwrapKey don't accept AAD natively. The default synthetic strategy prepends an HMAC-SHA256 of the canonical context over the DEK and verifies it on unwrap — defense-in-depth equivalent to AWS/GCP. Switch to cipher_only if you can accept relying solely on cipher-layer AAD plus Key Vault RBAC.

Bind the token resolver and (for synthetic AAD) an HMAC key resolver:

HashiCorp Vault Transit

Local (dev/test only)

Refuses to load in production unless SEALCRAFT_LOCAL_ALLOW_PRODUCTION=true.

Encryption contexts

Every DEK is bound to an encryption context — a (type, id) pair plus optional scalar attributes. The context canonicalizes to stable UTF-8 bytes (NFC-normalized, byte-sorted keys, escaped separators, 4KB cap) and is used as AAD at the cipher layer, and, where the provider supports it, at the wrap layer too. A cross-context decrypt attempt fails authentication.

Configure a model's context with a single $sealcraft array:

Only the keys that differ from defaults need to be set.

Per-group (default) — one DEK per tenant / user / patient

Every row sharing a context value uses one DEK. KEK rotation rewraps one row per context. Best for multi-tenant SaaS.

Per-row — one DEK per record

Each row carries its own sealcraft_key column (auto-populated UUID) and gets its own DEK. Best for vault-style rows where each row is an independent security boundary.

Add sealcraft_key string(191) nullable index to your model's migration.

Delegated context — user "passes" their key to related models

A record delegates its context to a parent so all of a user's data across multiple tables shares one DEK. This is the HIPAA primitive for one-shot crypto-shred.

Per-column override — one model, multiple contexts

Most models use one context for all encrypted columns. When you need to split — for example, a patient record where most fields belong to the patient but one field belongs to the employer who issued it — pass type= and column= as cast parameters:

The two context bindings are independent — shredding the patient destroys ssn and history but leaves work_notes readable until the employer context is shredded separately.

The legacy form — four separate properties ($sealcraftStrategy, $sealcraftContextType, $sealcraftContextColumn, $sealcraftRowKeyColumn) — still works. The $sealcraft array is the recommended form going forward.

Changing context (tenant moves, record re-owned)

Changing the context column on an existing row is a security-sensitive event. Sealcraft's default is to auto-reencrypt on save:

Two events fire:

Set SEALCRAFT_AUTO_REENCRYPT=false to require explicit migration via sealcraft:reencrypt-context instead — the trait throws InvalidContextException on any uncoordinated context change. Wire the events to your SIEM regardless.

Right-to-be-forgotten: crypto-shred

Permanent destruction of a user's data without DELETE-ing anything:

Or:

After shred, every ciphertext ever wrapped under that context becomes cryptographically unrecoverable. Reads raise ContextShreddedException (a separate exception from DecryptionFailedException, so apps can render a "record destroyed at user request" message instead of a 500). Writes to a shredded context also fail with ContextShreddedException, preventing accidental resurrection.

The DekShredded event fires on success — wire it to your compliance audit log.

Key rotation playbook

KEK rotation (rotate the wrapping key)

Fast. No data is re-encrypted. Just rewraps each DataKey under the current KEK version.

Run during normal operation — the existing DataKey's stored KEK version keeps older data decryptable during the rotation window.

DEK rotation (rotate the data key itself)

Slower. Synchronously decrypts every row under the old DEK, re-encrypts under a new DEK, then retires the old DEK. Run during a maintenance window (the command assumes no concurrent writes for the affected context).

The command acquires a DB-level advisory lock before re-encrypting rows, so two concurrent rotate-dek invocations on the same context will not race — the second fails immediately with a clear error. The lock does not block normal application writes. A concurrent application write during rotation can land under the old DEK after the command has already processed that row, leaving it unreadable once the old DEK is retired. Preventing this is the caller's responsibility; the DekRotationStarting event is fired immediately before re-encryption begins and can be used to wire a write-gating listener if your deployment requires true write-quiescence.

Provider migration (move from one KMS to another)

Operational commands

Command Purpose
sealcraft:generate-dek {type} {id} Manually provision a DEK
sealcraft:rotate-kek KEK rotation (all or scoped)
sealcraft:rotate-dek {model} DEK rotation (synchronous re-encryption)
sealcraft:migrate-provider --from --to Move DataKeys between providers
sealcraft:reencrypt-context {model} {id} {new} Per-row context migration
sealcraft:backfill-row-keys {model} Fill empty per-row row-key columns on existing rows
sealcraft:shred {type} {id} Crypto-shred (right to be forgotten)
sealcraft:audit Report DEK counts, distribution, optional round-trip validation

All destructive commands support --dry-run.

Operational caveats

Configuration reference

See config/sealcraft.php after publishing. Key knobs:

Events

Subscribe in a service provider to send to your SIEM / audit pipeline:

Event Fired when
DekCreated A new DataKey row is inserted
DekUnwrapped Plaintext DEK is produced (carries cacheHit flag)
DekRotated A DataKey's KEK version changed (KEK rotation)
DekShredded A context has been crypto-shredded
DecryptionFailed Any unwrap or cipher auth failure; never includes plaintext
ContextReencrypting Before auto-reencrypt; listeners may cancel by returning false
ContextReencrypted After auto-reencrypt; audit-logging hook

Performance

Shred, rotation, and audit commands iterate with chunkById so they scale to 10k+ tenants.

Threat model

What Sealcraft protects against:

What Sealcraft does NOT protect against:

Compliance notes

HIPAA and PCI-DSS expect encryption-at-rest with defensible key management — which is what envelope encryption plus a KMS gives you. Sealcraft is the key-management and cipher machinery; you still own the rest:

Crypto-shred is necessary but not sufficient for GDPR erasure — you may still need to scrub names/emails/IDs from audit logs, telemetry, and data warehouses.

Migrating from APP_KEY / encrypted cast

The short version: back up the DB, write a one-off migration that reads each encrypted column via Crypt::decrypt, re-assigns via the Encrypted cast, and saves. Do it during a maintenance window. Keep APP_KEY around for at least one full backup cycle in case of rollback.

Testing

Integration tests for AWS KMS use mocked KmsClient; GCP, Azure, and Vault Transit use Http::fake. No live cloud credentials required.

Documentation

Full reference documentation — installation, configuration, every provider, every encryption-context strategy, every artisan command, troubleshooting, and ADRs — is published at:

https://www.crumbls.com/documentation/sealcraft

The Markdown sources live under docs/ in this repository and are versioned per release.

Contributing

Issues and PRs welcome. Run composer format and composer test before submitting.

License

MIT — see LICENSE.md.

Security disclosures

See SECURITY.md.


All versions of sealcraft with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-openssl Version *
ext-intl Version *
illuminate/contracts Version ^11.0 || ^12.0 || ^13.0
illuminate/database Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package crumbls/sealcraft contains the following files

Loading the files please wait ...