Repository navigation
Releases
Releases · Pharaonic/php-fingerprint
v8.5.0
Added
- Every builder method,
make(),verify(),result(),message()and theFingerprintentry points have#[\NoDiscard]. PHP warns when their result is thrown away, which catches calls such as$builder->ignore('x');that never had an effect because builders never change. Cast a call made only for its exception to(void).
Changed
- Requires PHP 8.5. Every value that the earlier versions accept keeps its fingerprint.
Full Changelog: 8.4.0...8.5.0
v8.4.0
Changed
- Requires PHP 8.4. Every value that the earlier versions accept keeps its fingerprint:
trim()still removes only ASCII whitespace, andprecision()does not depend on the rounding changes of PHP 8.4.
Full Changelog: 8.3.0...8.4.0
v8.3.0
Changed
- Requires PHP 8.3. Every value that the earlier versions accept keeps its fingerprint.
Full Changelog: 8.2.0...8.3.0
v8.2.0
Changed
- Requires PHP 8.2. Every value that 8.0.x and 8.1.x accept keeps its fingerprint.
- The HMAC secret is marked with
#[\SensitiveParameter], so PHP replaces it with aSensitiveParameterValuein every stack trace that records arguments.
Full Changelog: 8.1.0...8.2.0
v8.1.0
Added
- Enum cases can be fingerprinted. A case is encoded with its enum class, its case name and its backed value, so it never matches its name or its value, and cases of different enums never match, even with equal backed values. Lists of cases can be ordered and de-duplicated, and a
normalize()callback for an enum class still takes precedence. enumsByName()andenumsByValue()use a case's name or backed value instead, on every value or at a path withat().enumsByValue()throws anUnsupportedValueExceptionfor a case without a backed value.- Ordered signatures sign the backed value of an enum case. A case without a backed value throws unless
enumsByName()ortransform()handles it. - The
xxh32,xxh64,xxh3,xxh128andmurmur3*algorithms of PHP 8.1 work withalgorithm(). Like the checksums, they are non-cryptographic and cannot be used withhmac().
Changed
- Requires PHP 8.1. Every value that 8.0.x accepts keeps its fingerprint.
Full Changelog: 8.0.3...8.1.0
v8.0.3
Changed
- The docs describe only the 8.0.x line: the Installation and Guarantees & Limitations pages no longer mention features or release lines of later PHP versions.
- The Overview drops the Learning Path table, and the Quick Start links straight to Ordered Signatures and Signature Examples.
Full Changelog: 8.0.2...8.0.3
v8.0.2
Changed
- The documentation reads as a learning path, from simple to advanced: Getting Started, The Basics, Going Further, Signed Callbacks & Webhooks, then Reference. Each page builds only on the pages before it and links to the next one.
- A new Signature Examples page covers your own webhooks, Paymob callbacks and Kashier payment hashes, and a new How Rules Combine page explains rule order and precedence.
- More examples clarify
sortBy(), namespaces,onMissing(),JsonSerializableobjects and input paths, and the README labels its documentation link.
Full Changelog: 8.0.1...8.0.2
v8.0.1
Changed
- The package page and README show the package cover, and the README links to Packagist with version and download badges.
Full Changelog: 8.0.0...8.0.1
v8.0.0
Added
Fingerprint::make()andFingerprint::for(): SHA-256 fingerprints ofnull, booleans, integers, floats, strings and arrays, encoded with canonical format v1.- Associative keys are ordered canonically at every level, lists keep their order, and types are preserved (
1,'1',1.0andtrueall differ). - Closures, resources, unsupported objects,
NANand values nested deeper than 512 levels throw anUnsupportedValueExceptionthat names the offending path. - Filters:
ignore(),only()(path order never matters),ignoreWhen(),ignoreNulls(),ignoreEmptyStrings()andignoreEmptyArrays(). Lists stay lists and are re-indexed after removals; maps stay maps even when emptied. - Path rules:
at()scopes the following value rules to a dot path, andtransform()replaces a value before it is fingerprinted. Paths use php-dot-array's syntax:*matches one key or index, and\.,\*and\\escape a literal character. - List rules:
unordered(),sortBy()(one or more fields or dot paths, ascending or descending),sortUsing(),unique()anduniqueBy(). Lists are ordered first, then de-duplicated keeping the first occurrence; the rules leave maps and scalars alone. - String rules:
trim()andnormalizeWhitespace()(ASCII whitespace),lower()andupper()(UTF-8 through mbstring), andunicode()(NFC, NFD, NFKC, NFKD; needs ext-intl or symfony/polyfill-intl-normalizer). Invalid UTF-8 is rejected instead of silently replaced. - Number and boolean rules:
precision()rounds floats from their exact binary value, the same on every PHP version;normalizeNumericStrings()converts plain decimal strings;normalizeBooleans()mapstrue,1,'1','true'and their false counterparts. - Dates:
DateTimeInterfacevalues are fingerprinted by their UTC instant with microseconds;datePrecision()truncates them andkeepTimezone()keeps the local time and timezone instead. - Objects:
stdClass(always a map),JsonSerializable,Traversable(generators excluded) andnormalize(Class::class, $callback)for any class or interface. Other objects are rejected, private state is never read, and objects that contain themselves throw aCircularReferenceException. - Hashing:
algorithm()accepts any algorithmhash()supports (SHA-256 by default),hmac()signs with a secret, andhex(),binary(),base64()andbase64Url()choose the output. Unavailable algorithms and non-HMAC algorithms with a secret throw instead of falling back. namespace()keeps fingerprints of identical data used for different purposes apart.Fingerprint::verify()andFingerprintBuilder::verify()compare in constant time, hex case-insensitively.- The HMAC secret never appears in
var_dump(),print_r(), exception messages or exception traces, and builders refuse to be serialized. An algorithm that cannot do HMAC is therefore reported when hashing, not byhmac()itself. - Ordered signatures:
Fingerprint::signature($payload)->fields([...])joins the selected fields in exactly the declared order and hashes or signs them, for protocols such as payment gateway callbacks.valuesOnly()orkeyValue(),separator()andkeyValueSeparator()shape the message,onMissing()andonNull()decide what missing and null fields become (both throw by default), andat()applies string rules,precision()andtransform()per field.message()shows the exact string that is signed, andverify()checks a received signature in constant time. Fingerprint::file()andFingerprint::stream()fingerprint raw bytes in chunks, never loading a whole file into memory, with the same algorithm, HMAC, encoding andverify()options. Streams are read from their current position and are never rewound or closed. Missing files, directories and non-readable streams throw anUnreadableResourceException.FingerprintBuilder::result()returns aFingerprintResultwith the hash, algorithm, encoding, HMAC flag, namespace, format version, the exact canonical bytes and the normalized value as plain PHP data, to see why two fingerprints differ. It never holds the secret.maxDepth()changes the nesting limit (512 by default, likejson_decode()).FingerprintBuilder::for()reuses a configuration for another value. Invalid paths, path lists and callback results throw aConfigurationException.
Full Changelog: https://github.com/Pharaonic/php-fingerprint/commits/8.0.0