{
  "name": "node-apple-receipt-verify",
  "description": "A Node.js module for Apple In-App-Purchase receipt validation for iOS",
  "version": "1.15.0",
  "homepage": "https://github.com/ladeiko/node-apple-receipt-verify",
  "repository": {
    "type": "git",
    "url": "git@github.com:ladeiko/node-apple-receipt-verify.git"
  },
  "author": {
    "name": "Siarhei Ladzeika",
    "email": "sergey.ladeiko@gmail.com"
  },
  "main": "./index.js",
  "dependencies": {
    "async": "^3.2.0",
    "http-proxy-agent": "^7.0.2",
    "https-proxy-agent": "^7.0.6",
    "joi": "^17.2.1",
    "lodash": "^4.17.11"
  },
  "scripts": {
    "test": "mocha --bail",
    "lint": "eslint lib/*.js test/*.js",
    "prepublishOnly": "node ./tools/sync_readme.js"
  },
  "engines": {
    "node": ">= 0.9.0"
  },
  "keywords": [
    "purchase",
    "receipt",
    "apple",
    "inapp",
    "ios receipt",
    "inapppurchase",
    "in-app-purchase",
    "apple receipt"
  ],
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/ladeiko/node-apple-receipt-verify/issues"
  },
  "maintainers": [
    {
      "name": "Siarhei Ladzeika",
      "email": "sergey.ladeiko@gmail.com"
    }
  ],
  "directories": {},
  "devDependencies": {
    "@eslint/eslintrc": "^3.3.1",
    "@eslint/js": "^9.23.0",
    "@types/joi": "^17.2.3",
    "@types/lodash": "^4.14.123",
    "@types/mocha": "^10.0.10",
    "@types/node": "^22.13.13",
    "eslint": "^9.23.0",
    "eslint-plugin-mocha": "^10.5.0",
    "globals": "^16.0.0",
    "mocha": "^11.1.0",
    "nock": "^14.0.1",
    "should": "^13.2.3"
  },
  "config": {
    "unsafe-perm": true
  },
  "readme": "# node-apple-receipt-verify\n\nA Node.js module for Apple In-App-Purchase receipt validation for iOS.\n### Note: Storekit Versions:\nThis works module with the (older) Storekit API, the newer [Storekit 2](https://developer.apple.com/storekit/) uses JWT tokens which can be verified without an API call to Apple\n\n\n### Changes\n\nSee [CHANGELOG](CHANGELOG.md)\n\n### Debug Logging\n\nThe module can optionally turn on verbose debug log.\n\nIn order to enable the verbose logging, give the following to `.config()`:\n\n```javascript\nvar appleReceiptVerify = require('node-apple-receipt-verify');\nappleReceiptVerify.config({\n  verbose: true\n});\n```\n\n### Methods\n\n#### .config(options [object])\n\nInitializes module. Can be called more than once to reconfigure module.\n\n**options**: supports following keys:\n- `secret` \\[string\\] \\[optional\\] - Apple shared secret (See it in iTunes Connect: Go to My Apps > (select your app) > In-App Purchases > View or generate a shared secret) [required]\n- `verbose` \\[boolean\\] \\[optional\\] - verbose logging switch, `false` by default. [optional]\n- `environment` \\[array of strings\\] \\[optional\\] - defines environments used for receipt validation on Apple servers. Supported environments: 'sandbox', 'production'. The sequence is important. Defaults to `['production']`.\n- `ignoreExpiredError` \\[boolean\\] \\[optional\\] - if true, then does not return error if receipt is expired. Default is false.\n- `ignoreExpired` \\[boolean\\] \\[optional\\] - if `true`, then expired purchases are skipped. Defaults to `true`.\n- `extended` \\[boolean\\] \\[optional\\] - if `true`, then purchases contains extended information. Defaults to `false`. (since v1.1.1)\n- `excludeOldTransactions` \\[boolean\\] \\[optional\\] -  If value is true, response includes only the latest renewal transaction for any subscriptions ([Apple Documentation](https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW3)).\n- `doNotRemoveNonSubscriptions` \\[boolean\\] \\[optional\\] -  If true, then lifetime purchases also will be returned.\n\n#### .config()\n\nReturns current global config.\n\n#### .validate(options [object], callback [function (err, purchasedProducts [array of objects ])])\n\nValidates an in-app-purchase receipt.\n\n**options**: supports keys:\n- `receipt` \\[required\\] - base64 encoded receipt.\n- `device` \\[optional\\] - iOS vendor identifier. NOTE: [deprecated]\n\nYou can also add options passed to ```config()```, they override default options.\n\n**callback** \\[optional\\]:  receives error or list of purchased products embedded in receipt.\n\nThe purchased products list has structure:\n\n```\n[\n{\n    bundleId: <string>,\n    transactionId: <string>,\n    productId: <string>,\n    purchaseDate: <number>,\n    quantity: <number>,\n    *expirationDate: <number>,\n    *isTrialPeriod: <boolean>,              // only for subscriptions and if extented = true\n    *isInIntroOfferPeriod: <boolean>,       // only for subscriptions and if extented = true, since v1.5.1\n    *environment: <string>,                 // only if extented = true\n    *originalPurchaseDate: <number>,        // only if extented = true\n    *applicationVersion: <string>,          // only if extented = true\n    *originalApplicationVersion: <string>   // only if extented = true\n},\n...\n]\n```\n\n### Usage\n\n```javascript\nconst appleReceiptVerify = require('node-apple-receipt-verify');\n\n// Common initialization, later you can pass options for every request in options\nappleReceiptVerify.config({\n    secret: \"1234567890abcdef1234567890abcdef\",\n    environment: ['sandbox']\n});\n\n// Callback version\nappleReceiptVerify.validate({\n    receipt: appleReceipt,\n    device: '438498A7-4850-41DB-BCBE-4E1756378E39'\n }, (err, products) => {\n    if (err) {\n        return console.error(err);\n    }\n    // ok!\n});\n\n// Callback version without device\nappleReceiptVerify.validate({\n    receipt: appleReceipt\n  }, (err, products) => {\n    if (err) {\n        return console.error(err);\n    }\n    // ok!\n});\n\n// Promise version\ntry {\n  \n  const products = await appleReceiptVerify.validate({\n    receipt: appleReceipt,\n    device: '438498A7-4850-41DB-BCBE-4E1756378E39'\n  });\n  \n  // todo\n}\ncatch (e) {\n  if (e instanceof appleReceiptVerify.EmptyError) {\n    // todo\n  }\n  else if (e instanceof appleReceiptVerify.ServiceUnavailableError) {\n    // todo \n  }\n}\n\n// Override environment\nappleReceiptVerify.validate({\n    receipt: appleReceipt,\n    device: '438498A7-4850-41DB-BCBE-4E1756378E39',\n    environment: ['sandbox' ]\n  },  (err, products) => {\n    if (err) {\n        return console.error(err);\n    }\n    // ok!\n});\n\n```\n\n### Errors\n\nErrors can have additional optional properties:\n\n* isRetryable (bool) - true if Apple service recommends to retry request a bit more later.\n* appleStatus (number) - status returned by Apple validation service.\n\n#### Special errors\n\n##### EmptyError - returned in case of receipt without purchase\n\n```\nconst appleReceiptVerify = require('node-apple-receipt-verify');\nconst EmptyError = appleReceiptVerify.EmptyError;\n```\n\n##### ServiceUnavailableError - returned when Apple validation service returned, e.g: 503, etc.\n\nYou can retry request later.\n\n### Author\n* Siarhei Ladzeika < <sergey.ladeiko@gmail.com> >\n\n## LICENSE\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n"
}