Skip to content

passlet@4.0.0

Latest

Choose a tag to compare

@github-actions github-actions released this 28 Oct 19:20
0892208

Major Changes

  • b323088: Breaking. A smaller, documented public API:

    • Every option of every exported type now carries its documentation, so editors show it on hover.
    • The option types you build separately are exported: AppleOptions, AppleEventTicketOptions, AppleBoardingPassOptions, AppleNfc, Beacon, RelevantDate, AppleContentOptions, GoogleOptions, GoogleBoardingPassOptions, GoogleContentOptions, TotpParameter, EventVenue, WalletErrorDefinition, and ParsedTemplate, the type of template.config.
    • PassTemplate can no longer be constructed with new; get one from a Wallet method (wallet.loyalty(), …) as before. Its declaration no longer exposes passlet's provider internals.
    • LocaleCode is removed; locales keys were always plain BCP 47 strings.
    • WALLET_ERROR_CODES entries are typed as WalletErrorDefinition (status: number, message, why, fix: string) instead of their literal values. WalletErrorCode is unchanged.
    • appLinkData now takes the targets Google documents: android: { packageName } opens your Android app (Google's preferred target), web: { uri, description } opens a web page with the description Google requires on it, and displayText (at most 30 characters) labels the button. appLinkData.ios is removed, since Google no longer supports links to iOS apps, and so are each link's title, description and logoUrl, which Google no longer shows. https://developers.google.com/wallet/reference/rest/v1/AppLinkData
  • b323088: Breaking. Validation no longer bundles zod/mini: passlet checks templates and content with its own small validator. dist/index.js is 43% smaller than in 3.2.0 (205 KB → 116 KB, 33 KB gzipped), import("passlet") takes 15 ms instead of 25 ms, and building a template takes a quarter of the time. Unknown keys are still dropped and every default still applies; what changed for you:

    • Messages are passlet's own, in English, and name the failing path once: barcode.format: must be one of "QR", "PDF417", …, id: must not be empty (was TemplateConfig missing: id), google.valueAdded: accepts at most 10 entries. A problem with the content as a whole reads content: …. issues still lists every failing path.
    • expiresAt, validFrom and Google message displayInterval dates now take any W3C timestamp, as Apple and Google do: a UTC offset ("2026-12-09T13:00:00-07:00") and minute precision ("2026-12-09T13:00-07:00") were rejected before. A time zone is still required. startsAt, endsAt, departure and arrival also take minute precision with a zone.
    • Apple image URLs must be http: or https:, since passlet downloads them. Google links[].uri and valueAdded[].uri must carry a scheme (https:, tel:, mailto:, geo:, an app deep link), as Google requires; an empty string was the only thing rejected before.
    • A beacon proximityUUID may be any 8-4-4-4-12 hex UUID, not only RFC 9562 versions, and email options take any name@domain.tld.
    • An Apple relevantDates entry with both date and startDate/endDate is rejected at that entry, since Apple defines each entry as one or the other; it was read as { date } before.
  • b323088: Breaking. Every pass is built through one path, so the same checks apply everywhere:

    • A template that reaches a Wallet from elsewhere, returned by load (for wallet.update() and the Apple web service) or passed to createBundle(), is checked against that Wallet's credentials the first time it is used. A boarding pass without transitType returned by load now throws APPLE_BOARDING_MISSING_TRANSIT_TYPE instead of producing a pass Apple cannot render. createBundle() accepts a template built by another Wallet once it passes those checks, instead of rejecting it with PASS_BUNDLE_INVALID.
    • When apple.webService.registrations fails during wallet.update(), the error is a WalletError with the new code APPLE_REGISTRATIONS_FAILED, your storage's error as cause, and, with Google configured, results, so you can tell that Google already applied the update. It used to be your storage's own error, without results.
    • template.expire() throws GOOGLE_NOT_CONFIGURED without Google credentials, as publish() and sendMessage() do, instead of silently doing nothing.
  • b323088: Breaking. passlet is now published as an ES module only, and needs Node.js ^20.19.0 || >=22.12.0. Those versions load ES modules with require(), so CommonJS apps keep calling require("passlet") unchanged (Node 22.12 prints a one-time ExperimentalWarning for it; later 22.x releases don't); only Node 20.15–20.18 and 22.0–22.11 must upgrade (Node 20 itself reached end of life in April 2026). Dropping the CommonJS copy halves the package (index.cjs and index.d.cts are gone) and removes the dual-package hazard where an app that loaded passlet both ways got two WalletError classes, so instanceof WalletError and the check that a template belongs to its Wallet failed across them.

Patch Changes

  • b323088: toNodeListener no longer special-cases Set-Cookie response headers: it adapts wallet.handler, which never sets cookies. A handler of your own that sets several cookies through it now sends only the last one.
  • b323088: Apple passes take less work to issue and to serve. A template's images are now hashed once instead of on every pass, bundle item and web service render; passlet keeps its own copy of image bytes, so reusing the Uint8Array you passed in no longer changes later passes. The @1x, @2x and @3x versions of an image URL now download at the same time, and a URL named twice in a template (an icon that is also the logo) downloads once. Devices that fetch the same version of a pass at the same moment, like a holder's iPhone and Apple Watch right after wallet.update(), now share one render instead of signing the pass once each.
  • b323088: An Apple pass updated twice within the same second now reaches devices. The web service answered the second version with 304 Not Modified, because HTTP dates have whole seconds and both versions carried the same Last-Modified; the device kept the first version until the next update. Pass responses now carry Last-Modified only once the second of updatedAt is over (RFC 9110 §8.8.2.2), so a device fetching in that second always gets the full pass. Pass responses also carry Content-Length now.
  • b323088: Apple pass signatures list their signed attributes in DER order (content type, signing time, message digest), as CMS requires, so verifiers that re-encode the attributes accept them too. Signing with an in-memory signerKey no longer blocks the event loop: it runs on Node's thread pool, so the passes of a createBundle() sign in parallel and other requests keep being served meanwhile. An unsupported signer.digestAlgorithm now throws APPLE_INVALID_SIGNER_KEY from new Wallet() instead of APPLE_SIGNING_FAILED from every create(), and that error's why and fix mention it.
  • b323088: Google writes make fewer and faster requests. A Wallet remembers which classes exist (Google cannot delete a class), so after the first pass from a template create() is a single request instead of two, and concurrent first issues check and create the class once. wallet.update() patches the pass first and only looks at the class when Google has no pass yet: one request instead of two. createBundle() writes every pass in parallel, each right after its class, instead of one request after another, so a bundle waits on at most three round trips (class check, class insert, passes), and one once the Wallet knows its classes; invalid content in any item still fails before anything is written, and when one write fails, createBundle() rejects only after the others have finished, so nothing is still landing on Google afterwards. Concurrent requests on a new Wallet, or after its access token expires, now share one token exchange instead of each signing and sending its own.
  • b323088: google.messages on a generic template now reach Google. They were dropped from the class, so the messages meant for every holder of a generic pass never appeared.
  • b323088: wallet.update(serialNumber, { notify: true }) no longer sends Google's notifyPreference for generic passes. Google's genericObject has no such field and dropped it without notifying anyone; to notify generic pass holders, use PassTemplate.sendMessage() with messageType: "TEXT_AND_NOTIFY".
  • b323088: Google passes no longer show the same value twice. A gift card's balance and cardNumber, and a boarding pass's passenger name, appeared both in their own slot and again as a text module; every field that Google shows in a dedicated slot is now left out of the text modules, as loyalty and event fields already were. A boarding pass's passengerName field now also uses the field's value when the recipient sets none, instead of failing with GOOGLE_FLIGHT_MISSING_PASSENGER_NAME; values.passengerName without a template field still works.
  • b323088: Google publish() no longer wipes class fields passlet does not set. It used to read the class and write it back whole, so nested fields such as a flight's origin.gate and origin.terminal, the airline name in flightHeader, or an event's dateTime.doorsOpen were lost, and a gate change made in the Google console or by another system was undone (and could notify holders). publish() now patches the class in one request: the fields passlet owns are written or cleared, everything else stays as it is.
  • b323088: The published build now imports Node built-ins by their node: names (node:crypto, node:zlib, node:stream, node:http2) instead of bare crypto, zlib and stream. Bundlers and runtimes that resolve a bare crypto or stream to a polyfill or an npm package now get Node's own modules, as passlet's "Node built-ins only" promise intends. Every Node version passlet supports resolves these names; nothing changes for code that already runs on Node.