A Deno-first, TypeScript module scaffolding inspired by Apple's App Store Server Library
(Node/Java/Swift). It uses Deno's fetch and WebCrypto via jose for JWT/JWS.
import { AppStoreServerAPIClient, createAuthToken } from "./mod.ts"; // or a URL import once publishedconst env = {
issuerId: "<ISSUER_ID_UUID>",
keyId: "<KEY_ID>",
bundleId: "com.example.app",
privateKey: Deno.readTextFileSync("./AuthKey_XXXXXX.p8"),
endpoint: "sandbox" as const,
};
const token = await createAuthToken(env);
console.log(token.token);const client = new AppStoreServerAPIClient(env);
const history = await client.getTransactionHistory("<transactionId>");
console.log(history);- Apple requires the JWT's
exp - iatto be ≤ 20 minutes; the helper clamps to 10 minutes by default. - The client auto-caches the JWT and refreshes ~1 minute before expiry.
- Extend
client.tswith more endpoints as needed.