lib/sandbox.js
function Sandbox (options) {
    var securityVersion = 'v1';

    this.url = options.url;
    this.container = options.container;
    this.token = options.token;
    this.onBeforeRequest = []
        .concat(options.onBeforeRequest)
        .filter(hook => typeof hook === 'function');

    try {
        var typ = Decode(options.token, { header: true }).typ;

        if (typ && typ.toLowerCase() === 'jwt') {
            securityVersion = 'v2';
        }
    } catch (_) {
        // Ignore jwt decoding failures and assume v1 opaque token
    }

    this.securityVersion = securityVersion;
}
function Sandbox (options) {
    var securityVersion = 'v1';

    this.url = options.url;
    this.container = options.container;
    this.token = options.token;
    this.onBeforeRequest = []
        .concat(options.onBeforeRequest)
        .filter(hook => typeof hook === 'function');

    try {
        var typ = Decode(options.token, { header: true }).typ;

        if (typ && typ.toLowerCase() === 'jwt') {
            securityVersion = 'v2';
        }
    } catch (_) {
        // Ignore jwt decoding failures and assume v1 opaque token
    }

    this.securityVersion = securityVersion;
}
Creates an object representing a user's webtask.io credentials

@constructor
@param {Object} options - Options used to configure the profile
@param {String} options.url - The url of the webtask cluster where code will run
@param {String} options.container - The name of the container in which code will run
@param {String} options.token - The JWT (see: http://jwt.io) issued by webtask.io that grants rights to run code in the indicated container
@param {String} [options.onBeforeRequest] - An array of hook functions to be invoked with a prepared request