gablau / node-red-contrib-blynk-ws

Old/Legacy Blynk library implementation for Node-RED using WebSockets
MIT License
31 stars 10 forks source link

obsolete validation regexp on auth tokens #13

Closed premier-boats closed 5 years ago

premier-boats commented 5 years ago

When setting up a new flow on a new device, deploying the flow warns that "The workspace contains some nodes that are not properly configured:"

In the blynk-ws-client settings node, the auth token is highlighted in red. Annotation 2019-07-18 101934

If I ignore the warning on deploying the flow, the flow works as expected and the Blynk nodes connect successfully.

Current auth tokens include any alphanumeric character as well as some symbols (possibly the Base64 encoding alphabet?). The validation regexp only allows 32 a-fA-F0-9 characters.

I can't find specifics from Blynk on the auth token format. For validation it might be sufficient to require the field to be non-empty to avoid problems with future format changes.

gablau commented 5 years ago

Hi and thanks for reporting, it's true, the way to generate tokens changed on June 17th, now it's a base64 see here. So let's say I can change the regexp with this: ^[a-zA-Z0-9]{32}$

Soon update the library with a new version.

Best regard

premier-boats commented 5 years ago

"-_=" are all legal characters for URL-encoded base64, as used here: https://github.com/blynkkk/blynk-server/blob/master/server/utils/src/main/java/cc/blynk/utils/TokenGeneratorUtil.java

The "=" (padding) character should never appear as the server is encoding exactly 24 bytes, which fits perfectly into 32 base64 digits.

See the base64 URL-safe table, here, for legal characters: https://tools.ietf.org/html/rfc4648#page-7

gablau commented 5 years ago

fix in release 1.0.0