src/util/resolveToken.js
function resolveToken(callback) {
    var crossDomainStorageAvailable = crossDomainStorage.isAvailable();
    logger.info('Resolving token from OfferEngine');

    if (crossDomainStorageAvailable) {
        initXDomainStorage(function () {
            crossDomainStorage.getItem(appSettings.tokenCookieKey, function (data) {
                if (data.value) {
                    logger.info('Retrieved existing token: ' + data.value);
                    callback(data.value);
                } else {
                    setCrossDomainToken(callback);
                }
            });
        });
    } else {
        // If there is no cross domain storage, we just generate a random token.
        // In reality, cross domain storage will be available on pretty much all devices
        // Because they all support localStorage now
        var token = utils.generateToken();
        callback(token);
    }
}
function resolveToken(callback) {
    var crossDomainStorageAvailable = crossDomainStorage.isAvailable();
    logger.info('Resolving token from OfferEngine');

    if (crossDomainStorageAvailable) {
        initXDomainStorage(function () {
            crossDomainStorage.getItem(appSettings.tokenCookieKey, function (data) {
                if (data.value) {
                    logger.info('Retrieved existing token: ' + data.value);
                    callback(data.value);
                } else {
                    setCrossDomainToken(callback);
                }
            });
        });
    } else {
        // If there is no cross domain storage, we just generate a random token.
        // In reality, cross domain storage will be available on pretty much all devices
        // Because they all support localStorage now
        var token = utils.generateToken();
        callback(token);
    }
}
function resolveToken ( callback ) { var crossDomainStorageAvailable = crossDomainStorage . isAvailable ( ) ; logger . info ( 'Resolving token from OfferEngine' ) ; if ( crossDomainStorageAvailable ) { initXDomainStorage ( function ( ) { crossDomainStorage . getItem ( appSettings . tokenCookieKey , function ( data ) { if ( data . value ) { logger . info ( 'Retrieved existing token: ' + data . value ) ; callback ( data . value ) ; } else { setCrossDomainToken ( callback ) ; } } ) ; } ) ; } else { // If there is no cross domain storage, we just generate a random token. // In reality, cross domain storage will be available on pretty much all devices // Because they all support localStorage now var token = utils . generateToken ( ) ; callback ( token ) ; } }
Resolve the token for the user visiting the page
@param callback - The callback that is executed when the token is resolved
Resolve the token for the user visiting the page