Conversation
src/node-binance-api.ts
Outdated
| unarmorKey(a:string):number[] { | ||
| // eslint-disable-next-line no-useless-escape | ||
| const m = /-----BEGIN [^-]+-----\n([A-Za-z0-9+\/=\s]+)\n-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/.exec(a); | ||
| if (m) { | ||
| if (m[1]) { | ||
| a = m[1]; | ||
| } else if (m[2]) { | ||
| a = m[2]; | ||
| } else { | ||
| throw new Error("RegExp out of sync"); | ||
| } | ||
| } | ||
| return base64.decode(a); | ||
| } |
There was a problem hiding this comment.
we shouldn't use this method at all, why do we need it? it is confusing (which might scare some users), does an exec, ... all red flags
There was a problem hiding this comment.
btw most crypto libs already properly parse the private key headers
There was a problem hiding this comment.
about this, I've just copy-pasted that unarmor function from ccxt:
https://github.com/ccxt/ccxt/blob/master/ts/src/base/functions/crypto.ts#L110 (the source is also in ccxt: https://github.com/ccxt/ccxt/blob/master/ts/src/static_dependencies/jsencrypt/lib/asn1js/base64.ts#L74 ), i didn't even look in details of it
as it's bad, we should also remove from ccxt
There was a problem hiding this comment.
@ttodua if you check the latest implementation in this branch it does not use any of that
No description provided.