npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kilnjs/payments-appstore

v0.1.3

Published

App Store Server Notifications for KilnJS: the signed payload verified against Apple's own chain, with no SDK

Readme

@kilnjs/payments-appstore

App Store Server Notifications V2 for KilnJS, verified against Apple's own certificate chain. No SDK.

yarn add @kilnjs/payments @kilnjs/payments-appstore
// app.config.ts
import { payments } from "@kilnjs/payments";
import "@kilnjs/payments-appstore";

| option | environment | | | --- | --- | --- | | bundleId | APPSTORE_BUNDLE_ID | required. Checked against every notification | | root | | Apple's G3 root, overridable for a test or a future one | | keyId | APPSTORE_KEY_ID | for looking a subscription up | | issuerId | APPSTORE_ISSUER_ID | as above | | privateKey | APPSTORE_PRIVATE_KEY | as above | | environment | APPSTORE_ENVIRONMENT | production, or sandbox | | timeout | APPSTORE_TIMEOUT_MS | 10000 |

Verifying a notification needs no secret at all, which is the interesting part: a notification proves itself with Apple's chain. The key above is only for asking Apple questions, so a server that merely listens holds no credential.

What verification checks

A notification is a JWS whose header carries the chain that signed it, leaf first. That is convenient and dangerous in equal measure: anybody can put a chain in a header, so a verifier that checks the signature against the leaf it was handed accepts a payload anybody can mint. All four of these are checked, and each has a forgery of its own in the tests:

  • the leaf's signature over the payload, with ES256 read as raw r || s, which is the one incompatibility nobody finds by reading;
  • each certificate signed by the next one up;
  • the top of the chain being the root this server pins;
  • every certificate being inside its own validity window.

The transaction inside a notification is signed separately and verified the same way: the payload carrying it does not vouch for it, Apple's chain does.

A notification about another bundle is refused even though Apple signed it: acting on one would grant an entitlement here for a purchase made in a different app.

What it maps

| Apple | kind | | --- | --- | | SUBSCRIBED, ONE_TIME_CHARGE | purchased | | DID_RENEW | renewed | | DID_FAIL_TO_RENEW | billing_failed | | EXPIRED, GRACE_PERIOD_EXPIRED | expired | | REFUND, REVOKE | refunded | | DID_CHANGE_RENEWAL_STATUS + subtype | cancelled or recovered | | anything else | other, with both payloads whole in raw |

The type and the subtype together are what mean something, which is why the pair is mapped rather than the type.

externalId is the original transaction id, the one identifier that survives every renewal: the per-renewal id would make each renewal look like a new purchase and every subscription look a month old.

Who bought it is appAccountToken and nothing else. Apple deliberately tells a server nothing about the person behind an Apple ID, so an application that wants to know must set that token when it starts the purchase.

Verifying

yarn verify   # ts:check, lint, build, exports:check, test

Apple is never reached. The suite builds its own root, intermediate and leaf with openssl, signs payloads with the leaf, and forges each part a forger would - including a chain that holds together perfectly and ends at the wrong root, which is the forgery that matters.