• Hi I am trying to generate time based single sign on tokens on my Pixl and puckjs. these can then be sent to a PC or phone over BT via the keyboard HID.

    My research so far says that I need the crypto.js lib from modules and OTPAuth from npm as it has no dependencies

    So far I am only getting erros. I think I do not have my requires working I will post more after I get better results

  • I think I have found the issue the OTPAuth is too large when loaded with the crypto.js lib.

    var crypto = require("crypto");
    var otp = require("https://raw.githubusercontent.c­om/hectorm/otpauth/master/dist/otpauth.m­in.js");

    Gives the following error

     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v03 (c) 2018 G.Williams
    >Uncaught SyntaxError: Got UNFINISHED STRING expected EOF
     at line 1 col 98
    ...aster/dist/otpauth.min.js","(function­(){/*\n otpauth v4.0.0 ...
    Execution Interrupted
    New interpreter error: LOW_MEMORY,MEMORY
    >Uncaught Error: Module https://raw.githubusercontent.com/hector­m/otpauth/master/dist/otpauth.min.js not found
     at line 3 col 81

    I will look for a different OTP lib

  • I am now trying Tiny-OTP which is only 4K when minified. I still get a memory error

    1. https://github.com/triestpa/Tiny-OTP
  • Now trying JS-OTP but still rungging low on memory...


  • Sat 2019.08.10

    Hello @user101436, while I'm not going to be able to find a solution to the issue you have, as the crypto and OAuth topics are beyond my knowledge base, I can confirm that attempting to load just the otp file on to an MDBT42Q, produces the same error.

    ={ "free": 2476, "usage": 24, "total": 2500, "history": 7,

    I don't have a Puck nor a Pixl handy, but I believe the Pixl has the same memory capacity. Would you mind posting process.memory() for others to assist please.

    I double checked with Google's Closure Compiler and there don't appear to be obvious code/string related errors.

    I saved the .min.js file to disk on Windows10 and have a file size of 25K. I was able to load a 29K file onto the MDBT board, but my file has comment blocks that are stripped prior to upload.

    Are you able to pare down that file?

    ' at line 1 col 98 ...aster/dist/otpauth.min.js","'

    Do you know if this otp module can even be loaded on to an Espruino device?
    It is quite possible that the length of that particular minified string is just too long for the receive buffer on Espruino.

    '){return"undefined"!=typeof window&&window===f?'

    Around the fifth line down scares me a bit. If this is the browser window object, this file may eventually load, but possibly not execute on an Espruino device.

  • New interpreter error: LOW_MEMORY,MEMORY

    The LOW_MEMORY means the Espruino is low on memory, but it's just a warning, if you see it alone.
    MEMORY means Espruino definitely ran out of memory.

    You can try one thing: In the Web IDE settings, go to Communication, and

    • check "Modules uploaded as functions"
    • Save on Send -> set to "Direct to Flash"

    Btw https://github.com/triestpa/Tiny-OTP fits this way, but there is an error running it:

    Uncaught SyntaxError: Got '=' expected ','
     at line 1 col 69

    I think Espruino doesn't support default parameters.

    As Robin said, there could be couple of tiny issues preventing you from uploading code that runs fine on node or in browser...

  • Sat 2019.08.10

    'I think Espruino doesn't support default parameters'

    Bingo! @AkosLukacs you are correct. Not implemented yet. Below ES6 heading:


  • Thanks for the suggestions I have JS-OTP (One Time Password) loading now without the error or memory warning by editing out the ES6 default values. I cut and pasted the GIT hub code into the right hand IDE panel and uploaded it from there. I also removed any browser objects as the code was designed to work in browser.

    But I hit a new issue with HMAC. (HMAC stands for Keyed-Hashing for Message Authentication) The hash features used by JS-OTP and TinyOTP expect a .hmac method on the hash object. The built in crypto libs do not have this feature.

    I don't think I can implement HMAC so I am looking for an OTP implementation that is not using HMAC.

    I will update here when I make progress.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Sending single sign in tokens using Keybaord HID for TOTP sign in

Posted by Avatar for user101436 @user101436