forked from ladeiko/node-apple-receipt-verify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.json
75 lines (75 loc) · 6.93 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
"name": "node-apple-receipt-verify",
"description": "A Node.js module for Apple In-App-Purchase receipt validation for iOS",
"version": "1.7.4",
"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": "^2.6.2",
"bluebird": "^3.5.4",
"clone": "^2.1.2",
"got": "^9.6.0",
"joi": "^14.3.1",
"lodash": "^4.17.11",
"shelljs": "^0.8.3"
},
"scripts": {
"test": "mocha --bail",
"lint": "eslint lib/*.js test/*.js",
"prepublishOnly": "node ./tools/sync_readme.js",
"preinstall": "mkdir -p bin && cd src && make clean && make || true"
},
"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": {},
"os": [
"darwin",
"linux"
],
"devDependencies": {
"@types/joi": "^14.3.2",
"@types/lodash": "^4.14.123",
"@types/mocha": "^5.2.6",
"@types/node": "^11.13.0",
"eslint": "^5.16.0",
"eslint-plugin-mocha": "^5.3.0",
"mocha": "^6.0.2",
"nock": "^10.0.6",
"should": "^13.2.3",
"standard": "^12.0.1",
"surge": "^0.20.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\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\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. Example `438498A7-4850-41DB-BCBE-4E1756378E39`. If specified, then module will check if receipt belongs to vendor identifier.\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"
}