danibram / trustly-client

A node client to comunicate with trustly.
https://github.com/danibram/trustly-client
MIT License
6 stars 8 forks source link

selectAccount gives ERROR_UNABLE_TO_VERIFY_RSA_SIGNATURE [636] #33

Closed izaa closed 4 years ago

izaa commented 4 years ago

Hi,

the deposit-method works fine, but the selectAccount gives following error:

"error": {
            "message": "ERROR_UNABLE_TO_VERIFY_RSA_SIGNATURE",
            "code": 636,
            "error": {
                "signature": "pQgnQJ4I6zWvhfABDANXGoucpSLEbKR15zOh9Tg5xcnaciGGvvR+S4rmKsRMUTXG2I7hvnspk0mL4ozDo4XEEmBBR16qoYGtTokvJzMOsrqe810JxnWS0me/bWP3eAXUAuCO6iZpz8JT8ICXyuxfoqBst/NUHobwbXLB0DrvZqdpWSsxHZlGssYy5scw0Ags0y8rU/+GharLvkoXLxhOPhAm8kzwYZR5GnH8FuIvcJXVyeXfaYK5L/iIYIbOEsiAt+C8Hej+C6KBYLjeG/K94an0M5n2amv/d0cRaNjmlijG3X5Go0KXSEDeHnSRF9cmk8o5DUKJ8MQQ59Ua5MZ6bA==",
                "data": {
                    "code": 636,
                    "message": "ERROR_UNABLE_TO_VERIFY_RSA_SIGNATURE"
                },
                "uuid": "b4708852-cf14-483f-8fdb-366a24de2aa7",
                "method": "SelectAccount"
            },
            "name": "JSONRPCError"
        }

Any clues how to figure out? Thanks!

danibram commented 4 years ago

Can be the environment, can be the public/private keys and sometimes can be the parameters you are passing... If this doesnt help, the library exposes all crypto methods, but is strange that 1 method work and not the others. Are you passing all default params?

izaa commented 4 years ago

Trustly has this site https://trustly.com/en/developer/api/#/signaturetester what helped me to figure out what was the problem.

I was sending RequestDirectDebitMandate with integer value 0. and the library didn't serialize the zero value at all: "RequestDirectDebitMandate" should have been "RequestDirectDebitMandate0"

I think the problem is these line of code: (lib/trustlySerializeData.js)

            if (data[k] === null || !data[k]) {
                serializedData = serializedData + k;
            }
danibram commented 4 years ago

Yes, make sense, thanks! I will publish the fix in the next days

danibram commented 4 years ago

In the meantime you can send to the funtion string(0) instead of number 0

danibram commented 4 years ago

fixed in 3.1.0