[SDK-193] JWT auth example - #73
Conversation
Enable the Expo example to exercise Iterable JWT login without changing the default email path or the plugin public API. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep .agent, .cursor, and similar editor/agent folders out of version control. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep local review and design artifacts out of version control. Co-authored-by: Cursor <cursoragent@cursor.com>
Hermes has no SubtleCrypto, so the Web Crypto signer failed on iOS and Android. Co-authored-by: Cursor <cursoragent@cursor.com>
Helpers take explicit enabled/secret args so tests do not depend on inlined EXPO_PUBLIC env. Prefetch failures Alert without PII and skip setEmail without a token. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Coverage Impact This PR will not change total coverage. 🚦 See full report on Qlty Cloud »🛟 Help
|
❌ 1 blocking issue (1 total)
|
| return; | ||
| } | ||
|
|
||
| config.retryPolicy = { |
There was a problem hiding this comment.
JWT mode currently still logs the user’s email.
logReactNativeSdkCalls defaults to true independently of config.logLevel, and the SDK’s setEmail implementation logs setEmail: <email>. This conflicts with the PR’s stated requirement that emails not appear in logs.
Suggest setting config.logReactNativeSdkCalls = false when JWT mode is enabled and cover that configuration in the test.

🎟️ JIRA ticket(s)
🏕 Description
Adds an opt-in JWT auth demo to the Expo plugin example app so a JWT-enabled mobile API key can be exercised the same way as the RN example (SDK-191), without native JWT modules or a backend.
Default login is unchanged: email + a non-JWT API key. JWT is off unless
EXPO_PUBLIC_ITERABLE_JWT_ENABLED=trueand a realEXPO_PUBLIC_ITERABLE_JWT_SECRETare set inexample/.env.local.When JWT is configured:
Iterable.initializegetsauthHandler,onJwtError, andretryPolicy{ maxRetry: 5, retryInterval: 5, retryBackoff: linear }{ email, iat, exp }, 1-day TTL) and callsIterable.setEmail(email, token)onJwtError/ prefetch failure show an Alert with failure reason only (no JWT,authToken, email,userId,userKey, orfailedAuthToken)authHandler(match RN)Signer is demo-only (pure JS HMAC-SHA256; Hermes has no SubtleCrypto). Production apps must fetch the token from a backend that holds the secret —
EXPO_PUBLIC_*values are inlined into the JS bundle.Out of scope: plugin pipeline /
app.jsonoptions, native JWT modules,userIdlogin, plugin README / Zendesk, changelog / version bump (example-only;example/is not published).Also ignores local agent tooling dirs (
.agent/,.artifacts/,.cursor/, etc.) so they are not committed by accident.📷 Screenshots
No Login layout changes. JWT failures show a system Alert (
JWT authentication failed+ reason). Screenshots optional after device verification.🧐 Testing
Unit (done on this branch)
yarn tsc --noEmityarn tsc --noEmit -p exampleyarn lintyarn test— includessignDemoJwt(payload + NodecreateHmacsignature match) anddemoAuth(flags,authHandler/retryPolicy/onJwtError, Alert does not includeuserKeyorfailedAuthToken)Default path (JWT off) — iOS and Android
example/.env→example/.env.localnpx expo prebuild --cleanand run the exampleJWT enabled, valid key + secret — iOS and Android
.env.local: set that API key,EXPO_PUBLIC_ITERABLE_JWT_ENABLED=true,EXPO_PUBLIC_ITERABLE_JWT_SECRET=<secret>userIdin logs or AlertsJWT failure paths (app must not crash)
YOUR_ITERABLE_JWT_SECRET— noauthHandler; login may leave Login; inbox/in-app do not load as a JWT sessiononJwtErrorAlert with reason only; UI may still leave Login; inbox/in-app do not load📝 Documentation
How have you documented these changes?
example/README.md— new JWT authentication (optional) section: env vars (EXPO_PUBLIC_ITERABLE_JWT_ENABLED,EXPO_PUBLIC_ITERABLE_JWT_SECRET, existing API key / email), how to create a JWT-enabled mobile API key, demo-only secret warning (EXPO_PUBLIC_*inlined), and that productionauthHandlershouldfetchfrom a backendexample/.env— commented JWT template next to the existing API key / email varsexample/src/jwt/demoAuth.ts—getDemoAuthTokencomment with a backendfetchstub and DEMO ONLY markingNo plugin
README.md, Zendesk, orCHANGELOG.mdupdate (ticket: example docs only; no public plugin options).