RusticiSoftware/TinCanJS

LRS invalid: failed to divide URL parts

Closed this issue · 5 comments

Hello,

I'm having trouble with a elearning module produced with storyline.
Since our LRS doesn't support OAuth yet, the endpoint url is something like the following (which doesn't look against the specifications):

http://user@domain.com:password@domain.com/xAPI/v1/

Problem is that the regexp used to check the endpoint fails with such an url.
Snippet from /src/Environment/Browser.js

 urlParts = this.endpoint.toLowerCase().match(/([A-Za-z]+:)\/\/([^:\/]+):?(\d+)?(\/.*)?$/);
        if (urlParts === null) {
            log("[error] LRS invalid: failed to divide URL parts", LOG_SRC);
            throw {
                code: 4,
                mesg: "LRS invalid: failed to divide URL parts"
            };
        }

Any idea how I could fix this without having to wait for the OAuth migration of the LRS ?

Thanks

The endpoint doesn't look like a valid url.

Are you passing in the endpoint via the query string to the TinCan object? That appears to be the only place we parse the endpoint so that it would hit that code. Assuming that is the case the best option would be to parse the query string yourself (or use the TinCanJS utility methods as it does internally) and then construct the TinCan.LRS object directly.

Another alternative would be to parse the query string, remove the username/password construct an auth query string parameter and add it back on to the original. There is a reasonable chance that the LRS is using Basic Auth under the hood for the URL auth handling.

See if those work, if not there are other more extreme options.

Thanks for your help!
I'm trying to use the auth query string, as the LRS is using Basic Auth (good point @brianjmiller).
I am a bit confused by this: https://github.com/RusticiSoftware/launch/blob/master/lms_lrs.md as it stated the auth parameter but doesn't really explain what to put in it (base64 encoded ? only plain login:password ?)
I tried a few things, but the module created by Articulate doesn't seem to take this auth param into account.
Any light on this would be much appreciated.
Thanks again

The auth property is the string 'Basic ' followed by the base 64 encoded login:password.

You might find this javascript example helpful: https://github.com/WatershedLRS/xAPI-launch/blob/master/launch.js#L46

Of course @garemoko... should I think of that before the last post! 👍

It works, obviously! Thanks for your help, both!