Javascript: synchronous interface of onchallenge

23 views
Skip to first unread message

typ1232

unread,
Aug 9, 2014, 8:37:44 PM8/9/14
to wam...@googlegroups.com
Hey,

when authenticating with WAMP in javascript, the "onchallenge" callback requires me to return a result.

In this callback I am hashing the users password which may take a long time with a decent hashing algorithm in javascript.

This is a bit problematic because I have to block and wait until the hash is done before returning from the callback.

Is there an anynchronous API to the onchallenge functionality that I missed?

Tobias Oberstein

unread,
Aug 10, 2014, 4:52:18 AM8/10/14
to wam...@googlegroups.com
Hi,

Am 10.08.2014 02:37, schrieb typ1232:
> Hey,
>
> when authenticating with WAMP in javascript, the "onchallenge" callback
> requires me to return a result.
>
> In this callback I am hashing the users password which may take a long
> time with a decent hashing algorithm in javascript.

Just in case you missed this: AutobahnJS includes helpers for this stuff:

https://github.com/tavendo/AutobahnJS/blob/master/package/lib/auth/cra.js

But yes: depending on salting parameters, this op can burn some CPU cycles.

>
> This is a bit problematic because I have to block and wait until the
> hash is done before returning from the callback.
>
> Is there an anynchronous API to the onchallenge functionality that I missed?

That's already possible: simply return a promise from your onchallenge
function.

However, please note, that with JavaScript in a browser, to make use of
this for a computational heavy operation (not blocking the UI thread),
you would need to run the computation on a background thread.

The only way to run a background thread on browsers is by using Web
Workers.

When using AutobahnJS on NodeJS, you also will need threads. Either
using NodeJS specific API, or a WebWorker shim like

https://www.npmjs.org/package/webworker-threads

Cheers,
/Tobias


>
> --
> You received this message because you are subscribed to the Google
> Groups "WAMP" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to wampws+un...@googlegroups.com
> <mailto:wampws+un...@googlegroups.com>.
> To post to this group, send email to wam...@googlegroups.com
> <mailto:wam...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/wampws.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/wampws/c3eafd21-a2ff-4c41-9cd7-0e2575b585c0%40googlegroups.com
> <https://groups.google.com/d/msgid/wampws/c3eafd21-a2ff-4c41-9cd7-0e2575b585c0%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages