MatthieuLemoine / push-receiver

A library to subscribe to GCM/FCM and receive notifications within a node process.
https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0
MIT License
198 stars 75 forks source link

HTTP_ECE Exception due to "Unsupported state or unable to authenticate data" #8

Closed PedroKantar closed 6 years ago

PedroKantar commented 6 years ago

@MatthieuLemoine this issue can be considered as a borderline case, but it could be worth tracking it here..

In my tests, I noticed, when notifications are sent in a very agressive way (more than one notification per second), that the "http_ece" decrypt() function at line const decrypted = ece.decrypt(object.rawData, params); throws the "Unsupported state or unable to authenticate data" exception.

After Googling it, it appears to be related to the encoding type used in the Decipher final() function. Looks like, when exposed to a notification very high rate, the live socket maintained with the GCM server (mtalk.google.com) could send some corrupted data..

Here below the stack:

[2017-11-28 10:57:40.327] [ERROR] Main - Error while decrypting incoming message [2017-11-28 10:57:40.329] [ERROR] Main - Error: Unsupported state or unable to authenticate data at Decipheriv.final (crypto.js:158:26) at decryptRecord (D:\code\svn\Source\node_modules\http_ece\ece.js:340:35) at Object.decrypt (D:\code\svn\Source\node_modules\http_ece\ece.js:388:17) at decrypt (D:\code\svn\Source\node_modules\electron-push-receiver\node_modules\push-receiver\src\utils\decrypt\index.js:25:29) at onMessageReceived (D:\code\svn\Source\node_modules\electron-push-receiver\node_modules\push-receiver\src\client\socket\index.js:111:21) at TLSSocket.socket.on.buffer (D:\code\svn\Source\node_modules\electron-push-receiver\node_modules\push-receiver\src\client\socket\index.js:86:5) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:191:7) at readableAddChunk (_stream_readable.js:178:18) at TLSSocket.Readable.push (_stream_readable.js:136:10) at TLSWrap.onread (net.js:560:20)

MatthieuLemoine commented 6 years ago

Could be fix by #13

MatthieuLemoine commented 6 years ago

Released in v2.0.0