Closed mjp0 closed 5 years ago
Which version of NodeJS are you running currently? (node -v
)
I was testing the examples and forgot to set the keysize back to a valid size for the examples/create_encryption_key.js
file. So if your key is over 32 characters long that might be the cause of the error.
I'll commit the fix in a few minutes but simply setting KEY_SIZE to 32 on line 63 might fix the issue.
Sorry, forgot to mention that I did notice the KEY_SIZE issue and fixed it to 32. It did give me an error about that so all good on that front.
I'm using node 10.10.0.
This is the contents of requestConfig
. Removed sensitive stuff and replaced request-id but left character counts for keys.
{
url: 'https://api.bunq.com/v1/session-server',
method: 'POST',
data:
{ secret:
'...64 chars...' },
headers:
{ 'Cache-Control': 'no-cache',
'Content-Type': 'application/json',
'X-Bunq-Language': 'en_US',
'X-Bunq-Region': 'nl_NL',
'X-Bunq-Geolocation': '0 0 0 0 000',
'X-Bunq-Client-Request-Id': 1234567890123.1234,
'X-Bunq-Client-Signature': '...344 chars...'
},
transformResponse: undefined
}
Error seems to be happening in jsdom which is interesting:
SyntaxError: The string did not match the expected pattern.
at XMLHttpRequest.setRequestHeader (./node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:759:15)
It seems to have to do with axios or dependency of it. Could you try cloning the bunqjsclient and running the tests with yarn run test
or npm run test
?
Did that and seems to be passing.
I also had the idea of trying to use cloned repo instead of npm but got stuck fighting with Babel version mismatch between bunq's 7 and ts-jest's 6 🙄
Oh I just realized, did you create the .env file and added the sandbox API key to it?
Yeah, I tried multiple ways to put in the config but nothing worked. I'm under a deadline and I only need to see the latest transactions so I did a quick script that uses Bunq's API directly to avoid further delays. Seems to work fine so at least right now I'm not using with this lib anymore.
But as always, thanks for your help :)
I'm trying to get the node example to work but
registerSession()
fails.I got API key (tried wildcard too), generated random AES pass with
create_encryption_key.ts
and I made up a device name.When I try to run it,
registerSession()
always throwsSyntaxError: The string did not match the expected pattern.
. I tried to debug this but tbh, I have no idea what could be wrong because by looking atrequestConfig
object sent everything looks fine.I'm using the latest npm version.