agisboye / app-store-server-api

A Node.js client for the App Store Server API
MIT License
210 stars 32 forks source link

Error on decodeNotificationPayload #10

Closed raquelmsmith closed 2 years ago

raquelmsmith commented 2 years ago

Hi! I am so excited to see this library, thank you for creating it.

I set everything up and attempted to use const payload = await decodeNotificationPayload(signedPayload). However, I got an error:

(node:1) UnhandledPromiseRejectionWarning: TypeError: crypto_1.X509Certificate is not a constructor
[cookup-action-service] [2022-05-20 21:43:16]     at /usr/src/app/node_modules/app-store-server-api/dist/cjs/Decoding.js:133:60
[cookup-action-service] [2022-05-20 21:43:16]     at Array.map (<anonymous>)
[cookup-action-service] [2022-05-20 21:43:16]     at validateCertificates (/usr/src/app/node_modules/app-store-server-api/dist/cjs/Decoding.js:133:34)
[cookup-action-service] [2022-05-20 21:43:16]     at /usr/src/app/node_modules/app-store-server-api/dist/cjs/Decoding.js:111:29
[cookup-action-service] [2022-05-20 21:43:16]     at step (/usr/src/app/node_modules/app-store-server-api/dist/cjs/Decoding.js:52:23)
[cookup-action-service] [2022-05-20 21:43:16]     at Object.next (/usr/src/app/node_modules/app-store-server-api/dist/cjs/Decoding.js:33:53)
[cookup-action-service] [2022-05-20 21:43:16]     at /usr/src/app/node_modules/app-store-server-api/dist/cjs/Decoding.js:27:71
[cookup-action-service] [2022-05-20 21:43:16]     at new Promise (<anonymous>)
[cookup-action-service] [2022-05-20 21:43:16]     at __awaiter (/usr/src/app/node_modules/app-store-server-api/dist/cjs/Decoding.js:23:12)
[cookup-action-service] [2022-05-20 21:43:16]     at getKey (/usr/src/app/node_modules/app-store-server-api/dist/cjs/Decoding.js:106:74)
[cookup-action-service] [2022-05-20 21:43:16] (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)

Any ideas?

agisboye commented 2 years ago

Hi Raquel, Make sure you are using Node.js 15.6.0 or later. This is where X509Certificate was introduced.

raquelmsmith commented 2 years ago

Upgrading node did resolve this, thank you. Getting another error but will open another issue.