Skip to main content

tom_crypto 1.2.2 copy "tom_crypto: ^1.2.2" to clipboard
tom_crypto: ^1.2.2 copied to clipboard

Cryptographic utilities for secure authentication and data protection including JWT tokens, password hashing, and RSA encryption.

1.2.2 #

  • Changed: TomClientJwtToken.payload is read-only. It returned the live decoded map, so a reader of a token could edit a claim with one statement and the token afterwards could not tell what it decoded from what somebody assigned. It now returns an unmodifiable view; assigning, inserting, removing or clearing throws UnsupportedError, and a refused edit leaves the next read unchanged. test/jwt_payload_readonly_test.dart pins each case.
  • Fixed: validUntil and exp are the same instant, in UTC. A token carried both, written from two clock reads in two encodings: exp in epoch seconds and validUntil as an offset-less local ISO string, which means whatever the reader's zone says it means. A token minted in one zone and read in another was out by the difference. Issue now takes one clock read, in UTC, truncated to whole seconds; validUntil/validFrom end in Z, and exp/nbf are written into the payload from that same instant instead of being recomputed by sign. test/jwt_validity_window_test.dart asserts exp == validUntil and nbf == validFrom to the second.
  • Changed: requires tom_basics 3.0.0 or later.
  • Removed: the unused lib/src/version.versioner.dart stamp. Nothing exported or read it.

1.2.1 #

  • Fixed: a token's validity window was never quite the width it was asked for. TomServerJwtToken wrote validUntil and validFrom as offsets from DateTime.now(), calling it once for each, so the two claims were offsets from two instants a few microseconds apart. The window came out marginally narrower than expiresIn - notBefore, and with the default zero notBefore the validFrom claim named an instant slightly after the issue it stands for. Both are now offsets from a single clock read. The skew was sub-millisecond and never wrongly expired a token, but it made the two claims impossible to reason about as a pair — validUntil.difference(validFrom) did not equal the duration the caller passed.
  • Added: test/jwt_validity_window_test.dart, which asserts that equality directly, including for a one-millisecond window where the old skew could exceed the window itself.

1.2.0 #

  • Fixed: TomJwtConfiguration could not be constructed by a consumer. All four positional parameters of its constructor are typed by this package's dependencies — JWTKey and JWTAlgorithm from dart_jsonwebtoken, RSAPrivateKey and RSAPublicKey from pointycastle — and none of the four was exported, so no code outside this package could name them. The class's own dartdoc documents the construction it made impossible. TomClientJwtToken.token and .audience had the same problem: their values could be read but their types could not be written down.
  • Added: the barrel now exports the types this package's public API names — Audience, JWT, JWTAlgorithm, JWTKey and SecretKey from dart_jsonwebtoken, and RSAPrivateKey and RSAPublicKey from pointycastle. The lists are exactly the names this surface mentions. Both dependencies declare an RSAPrivateKey and an RSAPublicKey, so exporting either wholesale would give consumers an ambiguous name; the pointycastle pair wins because it is what TomJwtConfiguration holds and what RsaKeyHelper.parsePrivateKeyFromPem returns. Code needing dart_jsonwebtoken's own RSA/EC/EdDSA signing keys, which this surface never names, imports that package directly.
  • Added: test/barrel_surface_test.dart, a compile-time guard. It imports only the barrel and names each type in a declaration, so losing an export stops the file compiling rather than failing an assertion inside it.

1.1.0 #

  • Fixed: secure random bytes could never take the value 255. Both places that drew raw randomness used Random.nextInt(255), whose bound is exclusive, so every generated byte fell in 0..254. This affected the Fortuna seed in RsaKeyHelper.getSecureRandom (and therefore every RSA key pair) and the salt in TomPasswordHasher.generateSalt (which is hex-encoded into the stored salt$hash). The loss is about 0.0056 bits per byte. Existing password hashes remain verifiable — the salt is stored alongside the hash — so no migration is required.
  • Added: TomSecureBytes.generate, now the single source of raw randomness in this package. Both call sites above previously carried their own copy of the same draw loop, and both copies were wrong in the same way; there is now one implementation for a third copy to not drift from.

1.0.0 #

  • Initial version.
0
likes
0
points
497
downloads

Publisher

unverified uploader

Weekly Downloads

Cryptographic utilities for secure authentication and data protection including JWT tokens, password hashing, and RSA encryption.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

asn1lib, dart_jsonwebtoken, pointycastle, tom_basics

More

Packages that depend on tom_crypto