bunqCommunity / bunqJSClient

A javascript SDK for the bunq API
MIT License
58 stars 23 forks source link

nodejs_example.js is broken #25

Closed nicka closed 6 years ago

nicka commented 6 years ago

Checklist before submitting

Information

To make things easier provide us with as much information as possible.

Issue

Thanks for working on this js client, unfortunately having some issues with the example. I did a clone of the project and running it locally.

The error returned is:

TypeError: tmp.length is not a function
    at forge.aes.Algorithm.initialize (/Users/nickdenengelsman/Development/flow/bunqJSClient/node_modules/node-forge/lib/aes.js:203:19)
    at new forge.cipher.BlockCipher (/Users/nickdenengelsman/Development/flow/bunqJSClient/node_modules/node-forge/lib/cipher.js:118:18)
    at Object.forge.cipher.createCipher (/Users/nickdenengelsman/Development/flow/bunqJSClient/node_modules/node-forge/lib/cipher.js:42:10)
    at Object.exports.encryptString (/Users/nickdenengelsman/Development/flow/bunqJSClient/dist/Crypto/Aes.js:18:32)
    at Session.encryptSession (/Users/nickdenengelsman/Development/flow/bunqJSClient/dist/Session.js:59:47)
    at Session.storeSession (/Users/nickdenengelsman/Development/flow/bunqJSClient/dist/Session.js:350:27)
    at BunqJSClient.install (/Users/nickdenengelsman/Development/flow/bunqJSClient/dist/BunqJSClient.js:112:32)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
TypeError: Cannot read property 'data' of undefined
    at BunqClient.install.catch.error (/Users/nickdenengelsman/Development/flow/bunqJSClient/examples/nodejs_example.js:32:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
TypeError: Cannot read property 'data' of undefined
    at BunqClient.install.catch.error (/Users/nickdenengelsman/Development/flow/bunqJSClient/examples/nodejs_example.js:32:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
Crecket commented 6 years ago

I think this might be caused by an invalid encryption key. I'll add some checks and an example script to generate a valid one

Crecket commented 6 years ago

examples/create_encryption_key.js has been added to generate keys at random or based on a password. It also now throws an error if it fails to validate the AES key