Resolve License Status Synchronously at Launch#5
Conversation
|
Thanks, @lucasfischer! This does appear to fix the main issue on my side: a valid stored token can now be decoded synchronously during One small request before merge: could you add a regression test for the launch initializer path that asserts a stored valid token produces One nuance I noticed: expired-but-still-within-grace cached tokens seem to remain |
|
Thanks for keeping me on my toes! I added a new test that asserts that a stored valid token produces Thank you for pointing out the grace period weirdness. IMO |
|
Thank you! Looks good now 🙂 |
What
AmoreLicensing.statusis now resolved synchronously duringinit, so thecorrect license state is available on the very first read at app launch with no
async round-trip and no transient "invalid" flash before the network validate
completes.
Why
Status couldn't be set synchronously before because verification went through
JWTKit's
JWTKeyCollection, whose key configuration (add(eddsa:)) andverifyare bothasync. The stored token therefore couldn't be decoded untila
Taskhad run, leavingstatusmomentarily wrong at launch.The fix is to verify locally with a synchronous primitive. JWTKit can't do that,
so it's replaced with a small, purpose-built EdDSA (Ed25519) verifier backed by
swift-crypto.How
AmoreJWTtarget — synchronousEdDSAJWT.sign/verifyplusbase64url helpers, built on
Curve25519.Signing.AmoreLicensing.initnow callsvalidateLocally()synchronously to seedstatusfrom the stored token, then kicks off the async servervalidate()as before. The async
JWTKeyCollection,keysReadyflag, andensureKeysConfigured()are gone.invalidSignaturereplaced byinvalidPublicKey(bad key config)and
invalidToken(anything unverifiable on arrival).