625 lines
20 KiB
JavaScript
625 lines
20 KiB
JavaScript
(function () {
|
|
var localGatewayBase = 'http://192.168.110.64:1100';
|
|
var productionGatewayBase = 'https://jvapi.haiyihy.com';
|
|
var defaultGatewayBase = resolveDefaultGatewayBase();
|
|
var defaultGatewayPrefix = '/go';
|
|
var defaultSysOrigin = 'LIKEI';
|
|
var defaultReqClient = 'Android';
|
|
var defaultReqAppIntel = {
|
|
version: '1.0.0',
|
|
build: '1',
|
|
model: 'SM-G9550',
|
|
sysVersion: '9',
|
|
channel: 'Google'
|
|
};
|
|
var defaultReqImei = '8fa54d728ab449e04f9292329ed44bda';
|
|
var defaultReqVersion = 'V2';
|
|
var sysOriginAliases = {
|
|
ATYOU: 'LIKEI',
|
|
YUMI: 'LIKEI',
|
|
SOULLA: 'LIKEI',
|
|
'4PARTY': 'LIKEI',
|
|
FOURPARTY: 'LIKEI'
|
|
};
|
|
var managedGatewayHeaders = {
|
|
'req-sys-origin': 'req-sys-origin',
|
|
reqsysorigin: 'req-sys-origin',
|
|
'req-client': 'req-client',
|
|
reqclient: 'req-client',
|
|
'req-app-intel': 'req-app-intel',
|
|
reqappintel: 'req-app-intel',
|
|
'req-imei': 'req-imei',
|
|
reqimei: 'req-imei',
|
|
'req-lang': 'req-lang',
|
|
reqlang: 'req-lang',
|
|
'req-version': 'req-version',
|
|
reqversion: 'req-version',
|
|
'req-zone': 'req-zone',
|
|
reqzone: 'req-zone'
|
|
};
|
|
|
|
function resolveDefaultGatewayBase() {
|
|
var hostname = '';
|
|
try {
|
|
hostname = window.location.hostname;
|
|
} catch (error) {}
|
|
return hostname === 'h5.haiyihy.com' ? productionGatewayBase : localGatewayBase;
|
|
}
|
|
|
|
function readParams() {
|
|
var pairs = [];
|
|
if (window.location.search) pairs.push(window.location.search.slice(1));
|
|
var hash = window.location.hash || '';
|
|
var queryIndex = hash.indexOf('?');
|
|
if (queryIndex >= 0) pairs.push(hash.slice(queryIndex + 1));
|
|
|
|
var params = {};
|
|
pairs.forEach(function (query) {
|
|
query.split('&').forEach(function (item) {
|
|
if (!item) return;
|
|
var index = item.indexOf('=');
|
|
var key = index >= 0 ? item.slice(0, index) : item;
|
|
var value = index >= 0 ? item.slice(index + 1) : '';
|
|
try {
|
|
key = decodeURIComponent(key);
|
|
value = decodeURIComponent(value.replace(/\+/g, ' '));
|
|
} catch (error) {}
|
|
if (key) params[key] = value;
|
|
});
|
|
});
|
|
return params;
|
|
}
|
|
|
|
function normalizeBase(value) {
|
|
return String(value || '').replace(/\/+$/, '');
|
|
}
|
|
|
|
function normalizePrefix(value) {
|
|
value = String(value || '');
|
|
if (!value) return '';
|
|
if (value.charAt(0) !== '/') value = '/' + value;
|
|
return value.replace(/\/+$/, '');
|
|
}
|
|
|
|
function bearer(value) {
|
|
value = String(value || '').trim();
|
|
if (!value) return '';
|
|
return /^bearer\s+/i.test(value) ? value : 'Bearer ' + value;
|
|
}
|
|
|
|
function bearerToken(value) {
|
|
return String(value || '').replace(/^bearer\s+/i, '').trim();
|
|
}
|
|
|
|
function normalizeSysOrigin(value) {
|
|
value = String(value || '').trim();
|
|
if (!value) return '';
|
|
if (value.indexOf('=') >= 0) {
|
|
value = parseReqSysOrigin(value).origin;
|
|
}
|
|
value = String(value || '').trim().toUpperCase();
|
|
return sysOriginAliases[value] || value;
|
|
}
|
|
|
|
function parseReqSysOrigin(value) {
|
|
var result = { origin: '', originChild: '' };
|
|
value = String(value || '').trim();
|
|
if (!value) return result;
|
|
|
|
if (value.indexOf('=') === -1) {
|
|
result.origin = value;
|
|
result.originChild = value;
|
|
return result;
|
|
}
|
|
|
|
value.split(';').forEach(function (item) {
|
|
var index = item.indexOf('=');
|
|
if (index < 0) return;
|
|
var key = item.slice(0, index).trim().toLowerCase();
|
|
var val = item.slice(index + 1).trim();
|
|
if (key === 'origin') result.origin = val;
|
|
if (key === 'originchild' || key === 'origin_child') result.originChild = val;
|
|
});
|
|
if (result.origin && !result.originChild) result.originChild = result.origin;
|
|
return result;
|
|
}
|
|
|
|
function parseHeaderPairs(value) {
|
|
var result = {};
|
|
String(value || '').split(';').forEach(function (item) {
|
|
var index = item.indexOf('=');
|
|
if (index < 0) return;
|
|
var key = item.slice(0, index).trim();
|
|
var val = item.slice(index + 1).trim();
|
|
if (key) result[key] = val;
|
|
});
|
|
return result;
|
|
}
|
|
|
|
function normalizeReqClient(value) {
|
|
value = String(value || '').trim();
|
|
if (/^ios$/i.test(value)) return 'iOS';
|
|
if (/^android$/i.test(value)) return 'Android';
|
|
if (/^h5$/i.test(value)) return 'H5';
|
|
if (/^ops$/i.test(value)) return 'Ops';
|
|
return '';
|
|
}
|
|
|
|
function resolveReqClient(rawValue) {
|
|
return normalizeReqClient(params.reqClient || params.client || rawValue) || defaultReqClient;
|
|
}
|
|
|
|
function resolveReqAppIntel(rawValue) {
|
|
var raw = parseHeaderPairs(rawValue);
|
|
var version = String(params.appVersion || raw.version || defaultReqAppIntel.version).trim();
|
|
var build = String(params.buildVersion || params.build || raw.build || defaultReqAppIntel.build).trim();
|
|
var model = String(params.model || raw.model || defaultReqAppIntel.model).trim();
|
|
var sysVersion = String(params.sysVersion || raw.sysVersion || defaultReqAppIntel.sysVersion).trim();
|
|
var channel = String(params.appChannel || params.channel || raw.channel || defaultReqAppIntel.channel).trim();
|
|
|
|
if (!/^[1-9]\d*$/.test(build)) build = defaultReqAppIntel.build;
|
|
return [
|
|
'version=' + (version || defaultReqAppIntel.version),
|
|
'build=' + build,
|
|
'model=' + (model || defaultReqAppIntel.model),
|
|
'sysVersion=' + (sysVersion || defaultReqAppIntel.sysVersion),
|
|
'channel=' + (channel || defaultReqAppIntel.channel)
|
|
].join(';');
|
|
}
|
|
|
|
function resolveReqLang(rawValue) {
|
|
return String(rawValue || params.appLanguage || params.lang || navigator.language || 'en').trim() || 'en';
|
|
}
|
|
|
|
function resolveReqZone(rawValue) {
|
|
var timezone = '';
|
|
try {
|
|
timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || '';
|
|
} catch (error) {}
|
|
return String(params.reqZone || params.timeZone || rawValue || timezone || 'Asia/Shanghai').trim();
|
|
}
|
|
|
|
function decodeBase64(value) {
|
|
value = String(value || '').replace(/-/g, '+').replace(/_/g, '/');
|
|
while (value.length % 4) value += '=';
|
|
try {
|
|
return decodeURIComponent(escape(window.atob(value)));
|
|
} catch (error) {
|
|
try {
|
|
return window.atob(value);
|
|
} catch (innerError) {
|
|
return '';
|
|
}
|
|
}
|
|
}
|
|
|
|
function tokenSysOrigin(value) {
|
|
var token = bearerToken(value);
|
|
if (!token) return '';
|
|
|
|
var payload = '';
|
|
var dotIndex = token.indexOf('.');
|
|
if (dotIndex >= 0) {
|
|
payload = token.slice(dotIndex + 1);
|
|
} else {
|
|
payload = token;
|
|
}
|
|
payload = decodeBase64(payload);
|
|
if (!payload) return '';
|
|
|
|
var parts = payload.split(':');
|
|
if (parts.length < 3) return '';
|
|
return normalizeSysOrigin(parts[2]);
|
|
}
|
|
|
|
function resolveReqSysOriginHeader(xhr, rawValue) {
|
|
var raw = parseReqSysOrigin(rawValue);
|
|
var headerValues = xhr.__wheelGatewayHeaderValues || {};
|
|
var tokenOrigin =
|
|
tokenSysOrigin(explicitToken) ||
|
|
tokenSysOrigin(headerValues.token) ||
|
|
tokenSysOrigin(explicitAuthorization) ||
|
|
tokenSysOrigin(headerValues.authorization);
|
|
var origin =
|
|
tokenOrigin ||
|
|
normalizeSysOrigin(params.sysOrigin || params.reqSysOrigin || window.__YUMI_WHEEL_SYS_ORIGIN__) ||
|
|
normalizeSysOrigin(raw.origin) ||
|
|
defaultSysOrigin;
|
|
var originChild =
|
|
tokenOrigin ||
|
|
normalizeSysOrigin(params.sysOriginChild || params.originChild || raw.originChild) ||
|
|
origin;
|
|
return 'origin=' + origin + ';originChild=' + originChild;
|
|
}
|
|
|
|
function storageGet(storage, key) {
|
|
try {
|
|
return storage.getItem(key) || '';
|
|
} catch (error) {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
var params = readParams();
|
|
var gatewayBase = normalizeBase(
|
|
params.gatewayBase ||
|
|
params.apiBase ||
|
|
window.__YUMI_WHEEL_GATEWAY_BASE__ ||
|
|
defaultGatewayBase
|
|
);
|
|
var gatewayPrefix = normalizePrefix(
|
|
params.gatewayPrefix ||
|
|
window.__YUMI_WHEEL_GATEWAY_PREFIX__ ||
|
|
defaultGatewayPrefix
|
|
);
|
|
var explicitAuthorization = bearer(
|
|
params.Authorization ||
|
|
params.authorization ||
|
|
params.auth ||
|
|
storageGet(window.localStorage, 'yumiWheelAuthorization') ||
|
|
''
|
|
);
|
|
var explicitToken = String(
|
|
params.token ||
|
|
storageGet(window.localStorage, 'yumiWheelToken') ||
|
|
''
|
|
).trim();
|
|
|
|
if (explicitAuthorization && !explicitToken) {
|
|
explicitToken = explicitAuthorization.replace(/^bearer\s+/i, '').trim();
|
|
}
|
|
if (explicitToken && !explicitAuthorization) {
|
|
explicitAuthorization = bearer(explicitToken);
|
|
}
|
|
|
|
try {
|
|
if (explicitAuthorization) {
|
|
window.sessionStorage.setItem('Authorization', explicitAuthorization);
|
|
window.localStorage.setItem('yumiWheelAuthorization', explicitAuthorization);
|
|
}
|
|
if (explicitToken) {
|
|
window.sessionStorage.setItem('token', explicitToken);
|
|
window.localStorage.setItem('yumiWheelToken', explicitToken);
|
|
}
|
|
} catch (error) {}
|
|
|
|
if (!window.location.hash || window.location.hash === '#' || window.location.hash === '#/') {
|
|
window.location.hash = '/lucky-box-new?appLanguage=en';
|
|
} else if (window.location.hash.indexOf('appLanguage=') === -1) {
|
|
var separator = window.location.hash.indexOf('?') === -1 ? '?' : '&';
|
|
window.location.hash = window.location.hash + separator + 'appLanguage=en';
|
|
}
|
|
|
|
function normalizedPath(url) {
|
|
try {
|
|
return new URL(url, window.location.href).pathname;
|
|
} catch (error) {
|
|
return String(url || '').replace(/^https?:\/\/[^/]+/i, '').split('?')[0];
|
|
}
|
|
}
|
|
|
|
function isWheelApiPath(path) {
|
|
return (
|
|
path === '/client/api/v1/config/mobile' ||
|
|
path === '/api/v1/config/mobile' ||
|
|
path === '/client/api/v1/wallet/list' ||
|
|
path === '/api/v1/wallet/list' ||
|
|
path.indexOf('/client/api/v1/probability/') === 0 ||
|
|
path.indexOf('/api/v1/probability/') === 0
|
|
);
|
|
}
|
|
|
|
function isWheelDrawPath(path) {
|
|
return /\/client\/api\/v1\/probability\/[^/]+\/draw$/.test(path) ||
|
|
/\/api\/v1\/probability\/[^/]+\/draw$/.test(path);
|
|
}
|
|
|
|
function normalizeCompareValue(value) {
|
|
return String(value || '').trim().toLowerCase();
|
|
}
|
|
|
|
function firstPresentValue(source, keys) {
|
|
source = source || {};
|
|
for (var index = 0; index < keys.length; index += 1) {
|
|
var value = source[keys[index]];
|
|
if (value !== undefined && value !== null && String(value).trim() !== '') {
|
|
return value;
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
|
|
function randomPart() {
|
|
try {
|
|
if (window.crypto && window.crypto.getRandomValues) {
|
|
var values = new Uint32Array(2);
|
|
window.crypto.getRandomValues(values);
|
|
return values[0].toString(16) + values[1].toString(16);
|
|
}
|
|
} catch (error) {}
|
|
return Math.floor(Math.random() * 0x100000000).toString(16) +
|
|
Math.floor(Math.random() * 0x100000000).toString(16);
|
|
}
|
|
|
|
function createIdempotencyKey(activity) {
|
|
var uid = String(params._login_uid || params.uid || params.userId || params.loginUid || 'guest').trim();
|
|
return ['h5', activity, uid || 'guest', Date.now(), randomPart()].join('-').slice(0, 128);
|
|
}
|
|
|
|
function queryHasIdempotencyKey(url) {
|
|
try {
|
|
var parsed = new URL(url, window.location.href);
|
|
return !!(
|
|
parsed.searchParams.get('idempotencyKey') ||
|
|
parsed.searchParams.get('idempotency_key') ||
|
|
parsed.searchParams.get('requestId') ||
|
|
parsed.searchParams.get('request_id') ||
|
|
parsed.searchParams.get('nonce')
|
|
);
|
|
} catch (error) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function bodyHasIdempotencyKey(body) {
|
|
if (!body) return false;
|
|
if (typeof FormData !== 'undefined' && body instanceof FormData) {
|
|
return !!(
|
|
body.get('idempotencyKey') ||
|
|
body.get('idempotency_key') ||
|
|
body.get('requestId') ||
|
|
body.get('request_id') ||
|
|
body.get('nonce')
|
|
);
|
|
}
|
|
if (typeof URLSearchParams !== 'undefined' && body instanceof URLSearchParams) {
|
|
return !!(
|
|
body.get('idempotencyKey') ||
|
|
body.get('idempotency_key') ||
|
|
body.get('requestId') ||
|
|
body.get('request_id') ||
|
|
body.get('nonce')
|
|
);
|
|
}
|
|
if (typeof body === 'string') {
|
|
try {
|
|
var payload = JSON.parse(body);
|
|
if (payload && typeof payload === 'object') {
|
|
return !!(
|
|
payload.idempotencyKey ||
|
|
payload.idempotency_key ||
|
|
payload.requestId ||
|
|
payload.request_id ||
|
|
payload.nonce
|
|
);
|
|
}
|
|
} catch (error) {}
|
|
try {
|
|
var params = new URLSearchParams(body);
|
|
return !!(
|
|
params.get('idempotencyKey') ||
|
|
params.get('idempotency_key') ||
|
|
params.get('requestId') ||
|
|
params.get('request_id') ||
|
|
params.get('nonce')
|
|
);
|
|
} catch (innerError) {}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function firstDrawReward(drawResult) {
|
|
drawResult = drawResult || {};
|
|
if (Array.isArray(drawResult.records) && drawResult.records.length > 0) {
|
|
return drawResult.records[0];
|
|
}
|
|
if (Array.isArray(drawResult.rewards) && drawResult.rewards.length > 0) {
|
|
return drawResult.rewards[0];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function rewardDisplayValue(reward) {
|
|
var value = firstPresentValue(reward, [
|
|
'value',
|
|
'displayGoldAmount',
|
|
'goldAmount',
|
|
'rewardValue',
|
|
'amount'
|
|
]);
|
|
return Number(value || 0);
|
|
}
|
|
|
|
function gridItemDisplayValue(item) {
|
|
return Number(firstPresentValue(item, ['value', 'displayGoldAmount', 'goldAmount']) || 0);
|
|
}
|
|
|
|
function resolveRewardTargetIndex(gridItems, drawResult) {
|
|
var reward = firstDrawReward(drawResult);
|
|
if (!reward || !Array.isArray(gridItems) || gridItems.length === 0) return 0;
|
|
|
|
var rewardId = normalizeCompareValue(firstPresentValue(reward, [
|
|
'id',
|
|
'rewardId',
|
|
'rewardConfigId',
|
|
'resourceId'
|
|
]));
|
|
var rewardName = normalizeCompareValue(firstPresentValue(reward, [
|
|
'name',
|
|
'resourceName',
|
|
'rewardName'
|
|
]));
|
|
var rewardCover = normalizeCompareValue(firstPresentValue(reward, [
|
|
'coverUrl',
|
|
'cover',
|
|
'resourceCover'
|
|
]));
|
|
var rewardValue = rewardDisplayValue(reward);
|
|
|
|
function matchBy(predicate) {
|
|
for (var index = 0; index < gridItems.length; index += 1) {
|
|
if (predicate(gridItems[index] || {})) return index;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
var byId = rewardId ? matchBy(function (item) {
|
|
return normalizeCompareValue(firstPresentValue(item, [
|
|
'id',
|
|
'rewardId',
|
|
'rewardConfigId',
|
|
'resourceId'
|
|
])) === rewardId;
|
|
}) : -1;
|
|
if (byId >= 0) return byId;
|
|
|
|
var byCoverValue = rewardCover ? matchBy(function (item) {
|
|
var merchandise = item.merchandise || {};
|
|
return normalizeCompareValue(firstPresentValue(merchandise, ['coverUrl', 'cover'])) === rewardCover &&
|
|
(!rewardValue || gridItemDisplayValue(item) === rewardValue);
|
|
}) : -1;
|
|
if (byCoverValue >= 0) return byCoverValue;
|
|
|
|
var byNameValue = rewardName ? matchBy(function (item) {
|
|
var merchandise = item.merchandise || {};
|
|
return normalizeCompareValue(firstPresentValue(merchandise, ['name', 'resourceName'])) === rewardName &&
|
|
(!rewardValue || gridItemDisplayValue(item) === rewardValue);
|
|
}) : -1;
|
|
if (byNameValue >= 0) return byNameValue;
|
|
|
|
var byValue = rewardValue ? matchBy(function (item) {
|
|
return gridItemDisplayValue(item) === rewardValue;
|
|
}) : -1;
|
|
return byValue >= 0 ? byValue : 0;
|
|
}
|
|
|
|
window.__YUMI_WHEEL_RESOLVE_TARGET_INDEX__ = resolveRewardTargetIndex;
|
|
|
|
function rewriteUrl(url) {
|
|
if (!gatewayBase) return url;
|
|
|
|
var parsed;
|
|
try {
|
|
parsed = new URL(url, window.location.href);
|
|
} catch (error) {
|
|
return url;
|
|
}
|
|
|
|
if (!isWheelApiPath(parsed.pathname)) return url;
|
|
|
|
var path = parsed.pathname;
|
|
if (path.indexOf('/api/v1/') === 0) {
|
|
path = '/client' + path;
|
|
}
|
|
|
|
return gatewayBase + gatewayPrefix + path + parsed.search;
|
|
}
|
|
|
|
var nativeOpen = XMLHttpRequest.prototype.open;
|
|
var nativeSend = XMLHttpRequest.prototype.send;
|
|
var nativeSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
|
|
|
XMLHttpRequest.prototype.open = function (method, url) {
|
|
var originalPath = normalizedPath(url);
|
|
var nextUrl = rewriteUrl(url);
|
|
this.__wheelGatewayRequest = nextUrl !== url && isWheelApiPath(originalPath);
|
|
this.__wheelGatewayDrawRequest = this.__wheelGatewayRequest && isWheelDrawPath(originalPath);
|
|
this.__wheelGatewayUrl = nextUrl;
|
|
this.__wheelGatewayHeaders = {};
|
|
this.__wheelGatewayHeaderValues = {};
|
|
if (this.__wheelGatewayRequest) {
|
|
window.__YUMI_WHEEL_LAST_API_REWRITE__ = {
|
|
from: String(url || ''),
|
|
to: nextUrl,
|
|
at: Date.now()
|
|
};
|
|
}
|
|
arguments[1] = nextUrl;
|
|
return nativeOpen.apply(this, arguments);
|
|
};
|
|
|
|
XMLHttpRequest.prototype.setRequestHeader = function (name, value) {
|
|
if (this.__wheelGatewayRequest) {
|
|
var lowerName = String(name || '').toLowerCase();
|
|
if (lowerName === 'authorization' && explicitAuthorization) {
|
|
value = explicitAuthorization;
|
|
}
|
|
if (lowerName === 'token' && explicitToken) {
|
|
value = explicitToken;
|
|
}
|
|
var managedHeaderName = managedGatewayHeaders[lowerName];
|
|
if (managedHeaderName) {
|
|
this.__wheelGatewayHeaderValues[managedHeaderName] = value;
|
|
return;
|
|
}
|
|
this.__wheelGatewayHeaders[lowerName] = true;
|
|
this.__wheelGatewayHeaderValues[lowerName] = value;
|
|
}
|
|
return nativeSetRequestHeader.call(this, name, value);
|
|
};
|
|
|
|
XMLHttpRequest.prototype.send = function () {
|
|
if (this.__wheelGatewayDrawRequest && arguments.length > 0) {
|
|
arguments[0] = stripRoomId(arguments[0]);
|
|
}
|
|
if (this.__wheelGatewayRequest) {
|
|
if (explicitAuthorization && !this.__wheelGatewayHeaders.authorization) {
|
|
nativeSetRequestHeader.call(this, 'Authorization', explicitAuthorization);
|
|
}
|
|
if (explicitToken && !this.__wheelGatewayHeaders.token) {
|
|
nativeSetRequestHeader.call(this, 'token', explicitToken);
|
|
}
|
|
var reqSysOrigin = resolveReqSysOriginHeader(this, this.__wheelGatewayHeaderValues['req-sys-origin']);
|
|
nativeSetRequestHeader.call(this, 'req-sys-origin', reqSysOrigin);
|
|
this.__wheelGatewayHeaderValues['req-sys-origin'] = reqSysOrigin;
|
|
nativeSetRequestHeader.call(this, 'req-client', resolveReqClient(this.__wheelGatewayHeaderValues['req-client']));
|
|
nativeSetRequestHeader.call(this, 'req-app-intel', resolveReqAppIntel(this.__wheelGatewayHeaderValues['req-app-intel']));
|
|
nativeSetRequestHeader.call(this, 'req-imei', this.__wheelGatewayHeaderValues['req-imei'] || params.reqImei || defaultReqImei);
|
|
nativeSetRequestHeader.call(this, 'req-version', this.__wheelGatewayHeaderValues['req-version'] || params.reqVersion || defaultReqVersion);
|
|
nativeSetRequestHeader.call(this, 'req-zone', resolveReqZone(this.__wheelGatewayHeaderValues['req-zone']));
|
|
nativeSetRequestHeader.call(this, 'req-lang', resolveReqLang(this.__wheelGatewayHeaderValues['req-lang']));
|
|
if (this.__wheelGatewayDrawRequest &&
|
|
!this.__wheelGatewayHeaders['idempotency-key'] &&
|
|
!this.__wheelGatewayHeaders['x-idempotency-key'] &&
|
|
!queryHasIdempotencyKey(this.__wheelGatewayUrl) &&
|
|
!bodyHasIdempotencyKey(arguments[0])) {
|
|
nativeSetRequestHeader.call(this, 'Idempotency-Key', createIdempotencyKey('wheel'));
|
|
}
|
|
if (explicitAuthorization) {
|
|
try {
|
|
window.sessionStorage.setItem('Authorization', explicitAuthorization);
|
|
window.sessionStorage.setItem('token', explicitToken);
|
|
} catch (error) {}
|
|
}
|
|
}
|
|
return nativeSend.apply(this, arguments);
|
|
};
|
|
|
|
function stripRoomId(body) {
|
|
if (typeof body !== 'string' || body.indexOf('roomId') === -1) return body;
|
|
try {
|
|
var payload = JSON.parse(body);
|
|
if (payload && typeof payload === 'object') {
|
|
delete payload.roomId;
|
|
return JSON.stringify(payload);
|
|
}
|
|
} catch (error) {}
|
|
return body;
|
|
}
|
|
|
|
window.__YUMI_WHEEL_GATEWAY__ = {
|
|
base: gatewayBase,
|
|
prefix: gatewayPrefix,
|
|
reqSysOrigin: function () {
|
|
return resolveReqSysOriginHeader({ __wheelGatewayHeaderValues: {} }, '');
|
|
},
|
|
reqClient: function () {
|
|
return resolveReqClient('');
|
|
},
|
|
reqAppIntel: function () {
|
|
return resolveReqAppIntel('');
|
|
},
|
|
rewriteUrl: rewriteUrl
|
|
};
|
|
})();
|