iapiConf = {"casinoname":"","loginServer":"platform/","clientSkin":"","clientType":"casino","clientPlatform":"flash","clientVersion":null,"systemId":"16","serviceType":"GamePlay","loginDomainRetryCount":"1","loginDomainRequestTimeout":"5","loginDomainRetryInterval":"1","fingerprintEnabled":"0","onlypostrequestsforlogout":null,"useIframeForGetLoggedInPlayer":"0","syncDone":"0","syncHops":5,"clientUrl_casino":""}; function setResponseCookie(domain) { if (!self.$domainSync) { self.$domainSync = []; } self.$domainSync.push(domain); } if (iapiConf && iapiConf['syncDone']=="1"){ setResponseCookie(iapiConf['loginServer']); } var iapiVersion = "_version_"; var iapiERR_OK = 0; var iapiERR_NOK = -1; var iapiERR_BLOCKED = -2; var iapiCALLOUT_LOGIN = 'Login'; var iapiCALLOUT_EMAILLOGIN = 'EmailLogin'; var iapiCALLOUT_TEMPORARYTOKEN = 'GetTemporaryAuthenticationToken'; var iapiCALLOUT_LOGINANDGETTEMPTOKEN = 'LoginAndGetTempToken'; var iapiCALLOUT_EMAILLOGINANDGETTEMPTOKEN = 'EmailLoginAndGetTempToken'; var iapiCALLOUT_SESSIONVALIDATION = 'ValidateLoginSession'; var iapiCALLOUT_MESSAGES = 'GetWaitingMessages'; var iapiCALLOUT_SUBMITDIALOG = 'SubmitDialog'; var iapiCALLOUT_FORGOTPASSWORD = 'ForgotPassword'; var iapiCALLOUT_STARTFORGOTEMAIL = 'StartForgotEamil'; var iapiCALLOUT_COMPLETEFORGOTEMAIL = 'CompleteForgotEmail'; var iapiCALLOUT_ONLINEFORGOTPASSWORD = 'OnlineForgotPassword'; var iapiCALLOUT_GETLOGGEDINPLAYER = 'GetLoggedInPlayer'; var iapiCALLOUT_KEEPALIVE = 'KeepAlive'; var iapiCALLOUT_LOGOUT = 'Logout'; var iapiCALLOUT_GETURLS = 'GetUrls'; var iapiEVENT_TIMER = 10; var STOCK_AUTH_PHONE_NUMBER = "pinAuth888"; var iapiUsername = null; // remember username var iapiPassword = null; // remember password, at least temporary var iapiEmail = null; // remember email var iapiAdminUsername = null; var iapiRealMode = 1; // real mode for login var iapiAuthenticationType = null; // remember authentication type var iapiDivname = 'iapidiv'; // div name var iapiIframename = 'iapiiframe'; // iframe name var iapiRealCookieIframe = 'iapirealcookieiframe'; // client cookie realmode iframe name var iapiFunCookieIframe = 'iapifuncookieiframe'; // client cookie funmode iframe name var iapiGetLoggedInPlayerRequestIdReal = 1234567890; // get logged in player request id is fixed, real var iapiGetLoggedInPlayerRequestIdFun = 9876543210; // get logged in player request id is fixed, fun var iapiClientParams = []; // defined by integration page var iapiWaitingMessagesId = 0; // to remember waiting messages requestId var iapiRememberMeLogin = null; var iapiCalloutFunctions = []; // defined by integration page var iapiRequestIds = []; // id's and callout types for requests var iapiLoginSuccess = false; // login success var iapiSessionValid = 0; // session valid (from login) var iapiNextLogin = null; // if login is in progress, then remember next login var iapiLoginModeDownload = false; // when download login is in progress var iapiLoginModeFlash = false; // when flash login is in progress var iapiFlashLoginClientType = null; // remember flash login client type var iapiFlashLoginGameType = null; // remember flash login game type var iapiMessagesSupported = false; // support receiving messages var iapiMessagesAnswered = false; // support sending messages to php scripts // enum, list of available authentication types var iapiLoginTypes = Object.freeze( { SESSION_TOKEN : 'sessionToken', EXTERNAL_TOKEN : 'externalToken', ADMIN_USERNAME : 'adminUsername', NICKNAME : 'nickname', EMAIL : 'email', TOKEN_CODE : 'tokenCode', PRINTED_TOKEN_CODE : 'printedTokenCode', USERNAME_AND_PIN : 'usernameAndPin', TOKEN_CODE_AND_PASS: 'tokenCodeAndPass' }); // public, login with username and password, and realMode (1/0) and language code in lowercase function iapiLogin(user, pass, realMode, language, rememberMeLogin) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiConf['authenticationType']; iapiBaseLogin(user, pass, realMode, language, rememberMeLogin); return iapiERR_OK; }; function iapiEmailLogin(email, pass, realMode, language, rememberMeLogin) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.EMAIL; iapiBaseLogin(email, pass, realMode, language, rememberMeLogin); return iapiERR_OK; }; // public, login with external token, and realMode (1/0) and language code in lowercase function iapiLoginExternalToken(token, realMode, language) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.EXTERNAL_TOKEN; iapiBaseLogin(null, token, realMode, language); return iapiERR_OK; } function iapiLoginUsernameExternalToken(user, token, realMode, language) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.EXTERNAL_TOKEN; iapiBaseLogin(user, token, realMode, language); return iapiERR_OK; } // public, login with admin username, token, realMode (1/0), language code in lowercase and player username function iapiLoginAdminUsername(adminUser, token, realMode, language, user) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.ADMIN_USERNAME; iapiAdminUsername = adminUser; iapiBaseLogin(user, token, realMode, language); return iapiERR_OK; } // public, login with session token, and realMode (1/0) and language code in lowercase function iapiLoginSessionToken(token, realMode, language) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.SESSION_TOKEN; iapiBaseLogin(null, token, realMode, language); return iapiERR_OK; } // public, login with nickname, password, realMode (1/0) and language code in lowercase function iapiLoginNickname(nickname, pass, realMode, language) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.NICKNAME; iapiBaseLogin(nickname, pass, realMode, language); return iapiERR_OK; }; function iapiLoginIdTokenCodeAndPin(tokenCode, pin, language, rememberMeLogin) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.TOKEN_CODE; iapiBaseLogin(tokenCode, pin, 1, language, rememberMeLogin); return iapiERR_OK; }; function iapiLoginPrintedIdTokenCodeAndPin(printedTokenCode, pin, language, rememberMeLogin) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.PRINTED_TOKEN_CODE; iapiBaseLogin(printedTokenCode, pin, 1, language, rememberMeLogin); return iapiERR_OK; }; function iapiLoginUsernameAndPin(user, pin, language, rememberMeLogin) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.USERNAME_AND_PIN; iapiBaseLogin(user, pin, 1, language, rememberMeLogin); return iapiERR_OK; }; function iapiLoginIdTokenCodeAndPassword(tokenCode, pass, language) { iapiLoginModeDownload = false; iapiLoginModeFlash = false; iapiAuthenticationType = iapiLoginTypes.TOKEN_CODE_AND_PASS; iapiBaseLogin(tokenCode, pass, 1, language); return iapiERR_OK; }; // public, open client window, clientMode is one of ('real', 'fun', 'offline'), // windowName (optional), if window or iframe already exists the game is opened there, if no then new window is opened with this name // windowWidth and windowHeight can be given to override window size values from conf, use -1,-1 to open window in fullscreen function iapiLaunchClient(clientType, gameType, clientMode, windowName, windowWidth, windowHeight) { // create url var url = iapiConf['clientUrl_' + clientType]; if (url){ if (gameType) { url = iapiAddUrlParams(url, 'game=' + gameType); } if (clientMode) { url = iapiAddUrlParams(url, 'preferedmode=' + clientMode); } // set additional client params if (iapiClientParams['clientParams_' + clientType]) { url = iapiAddUrlParams(url, iapiClientParams['clientParams_' + clientType]); } if (url.indexOf('$domain')>=0 || url.indexOf('')>=0) { var domain = getCurrentDomain(); url = url.replace("$domain", domain); url = url.replace("", domain); } if (iapiLoginModeFlash) { document.location = url; return; } // window sizes from conf, default 800x600 var sizeStr = 'width=800,height=600'; if (windowWidth != undefined && windowHeight != undefined) { if (windowWidth == -1 && windowHeight == -1) { sizeStr = ''; // for IE and safari set position if (navigator.appName == 'Microsoft Internet Explorer' || (navigator.userAgent.indexOf('Safari') >= 0 && navigator.userAgent.indexOf('Chrome') < 0)) { sizeStr = 'left=0,top=0,'; }; var availWidth = screen.width; var availHeight = screen.height; if (screen.availWidth != undefined) { availWidth = screen.availWidth; availHeight = screen.availHeight; } if (typeof (innerWidth) == 'number' && typeof (outerWidth) == 'number') { availWidth -= (outerWidth - innerWidth); availHeight -= (outerWidth - innerWidth); } sizeStr += 'width=' + availWidth + ',height=' + availHeight; } else { sizeStr = 'width=' + windowWidth + ',height=' + windowHeight; }; } else if (iapiConf['windowSize_' + clientType]) { var sizeIndex = iapiConf['windowSize_' + clientType][gameType]; if (sizeIndex == undefined) { sizeIndex = iapiConf['windowSize_' + clientType]['default']; }; if (sizeIndex != undefined && iapiConf['windowSizes'][sizeIndex]) { sizeStr = iapiConf['windowSizes'][sizeIndex]; }; }; if (windowName != null && windowName.length > 0) { var w = document.getElementById(windowName); if (w) { w.src = url; return iapiERR_OK; }; } else { windowName = ''; } var par = 'toolbar=no,menubar=no,scrollbars=no,resizable=no'; if (iapiConf['windowParams_' + clientType]) { par = iapiConf['windowParams_' + clientType]; }; windowParams = sizeStr + ',' + par; var win = window.open(url, windowName, windowParams); // if popup blocked window if (win == null || win.closed) { return iapiERR_BLOCKED; }; return iapiERR_OK; } return iapiERR_NOK; }; // public, set additional parameters for client, params is parameters string in format "param1=value1&...¶mn=valuen" function iapiSetClientParams(clientType, params) { iapiClientParams['clientParams_' + clientType] = params; }; function NoSystemId(){} NoSystemId.prototype.toString = function empty(){return '';} noSystemId = new NoSystemId(); // public, request temporary token, realMode (1/0), system id (int) optional, serviceType (String) optional function iapiRequestTemporaryToken(realMode, systemId, serviceType) { var requestUrl = 'GetTemporaryAuthenticationToken.php?' + 'casinoname=' + iapiConf['casinoname']; if (serviceType != undefined) { requestUrl += '&serviceType=' + serviceType; } else { requestUrl += '&serviceType=' + iapiConf['serviceType']; }; if (0 === systemId || 0===parseInt(systemId)){ systemId = undefined; } else if (!systemId){//null/empty string come here systemId = iapiConf['systemId']; } else if (!new String(systemId).toString()){ systemId = undefined; } if (systemId){ requestUrl += '&systemId=' + systemId; }; if (realMode != undefined) { requestUrl += '&realMode=' + realMode; }; iapiMakeRedirectRequest(requestUrl, null, iapiCALLOUT_TEMPORARYTOKEN); return iapiERR_OK; }; // public, login and request temporary token, username, password, realMode (1/0), language, systemId (int) optional, serviceType (String) optional function iapiLoginAndGetTempToken(user, pass, realMode, language, systemId, serviceType, rememberMeLogin) { iapiClearRedirectRequests(iapiCALLOUT_LOGINANDGETTEMPTOKEN, realMode); if (0 === systemId || 0===parseInt(systemId)){ systemId = undefined; } else if (!systemId){//null/empty string come here systemId = iapiConf['systemId']; } else if (!new String(systemId).toString()){ systemId = undefined; } if (!serviceType) { serviceType = iapiConf['serviceType']; }; if (language) { iapiSetLanguageCode(language); } // login params var requestUrl = 'LoginAndGetTempToken.php?' + 'casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode + '&serviceType=' + serviceType; if (systemId) requestUrl +='&systemId=' + systemId; if (rememberMeLogin == 1) { requestUrl += '&rememberMeLogin=1'; } // login post data var params = []; iapiAuthenticationType = iapiConf['authenticationType']; if (iapiAuthenticationType == iapiLoginTypes.EXTERNAL_TOKEN) { if (user) { params['username'] = user; } params['externalToken'] = pass; } else if (iapiAuthenticationType == iapiLoginTypes.SESSION_TOKEN) { params['sessionToken'] = pass; } else if (iapiAuthenticationType == iapiLoginTypes.ADMIN_USERNAME) { if (user) { params['adminUsername'] = user; } params['externalToken'] = pass; } else if (iapiAuthenticationType == iapiLoginTypes.NICKNAME) { params['nickname'] = user; params['password'] = pass; params['systemId'] = systemId; } else if (iapiAuthenticationType == iapiLoginTypes.EMAIL) { if (user) { params['email'] = user; } params['password'] = pass; } else { params['username'] = user; params['password'] = pass; if (iapiConf['iovationBlackbox']) { params['iovationBlackbox'] = iapiConf['iovationBlackbox']; } }; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_LOGINANDGETTEMPTOKEN); return iapiERR_OK; }; function iapiEmailLoginAndGetTempToken(email, pass, realMode, language, systemId, serviceType, rememberMeLogin) { iapiConf['authenticationType'] = iapiLoginTypes.EMAIL; iapiLoginAndGetTempToken(email, pass, realMode, language, systemId, serviceType, rememberMeLogin); iapiConf['authenticationType'] = null; } // public, login with external token and request temporary token, // Parameters: username, externalToken, realMode (1/0), language, systemId (int) optional, serviceType (String) optional, rememberMeLogin (1/0) optional function iapiLoginExternalTokenAndGetTempToken(user, externalToken, realMode, language, systemId, serviceType, rememberMeLogin) { iapiConf['authenticationType'] = iapiLoginTypes.EXTERNAL_TOKEN; iapiLoginAndGetTempToken(user, externalToken, realMode, language, systemId, serviceType, rememberMeLogin) iapiConf['authenticationType'] = null; }; // public, make login and temptoken and call necessary htcmd, realMode (1/0), language code in lowercase function iapiDownloadLogin(user, pass, realMode, language) { iapiAuthenticationType = null; iapiLoginModeDownload = true; iapiLoginModeFlash = false; iapiBaseLogin(user, pass, realMode, language); return iapiERR_OK; }; function iapiDownloadEmailLogin(email, pass, realMode, language) { iapiAuthenticationType = iapiLoginTypes.EMAIL; iapiLoginModeDownload = true; iapiLoginModeFlash = false; iapiBaseLogin(email, pass, realMode, language); return iapiERR_OK; }; // public, make login and redirect to weblogin or client function iapiFlashLogin(user, pass, realMode, language, clientType, gameType) { iapiAuthenticationType = null; iapiLoginModeFlash = true; iapiLoginModeDownload = false; iapiFlashLoginClientType = clientType; iapiFlashLoginGameType = gameType; iapiBaseLogin(user, pass, realMode, language); return iapiERR_OK; }; function iapiFlashEmailLogin(email, pass, realMode, language, clientType, gameType) { iapiAuthenticationType = iapiLoginTypes.EMAIL; iapiLoginModeFlash = true; iapiLoginModeDownload = false; iapiFlashLoginClientType = clientType; iapiFlashLoginGameType = gameType; iapiBaseLogin(email, pass, realMode, language); return iapiERR_OK; }; // public, logout allSessions(0/1), realMode (1/0), behaviour(this, all, hierarchical) function iapiLogout(allSessions, realMode, behaviour, invalidateRememberMe) { iapiUsername = null; iapiPassword = null; iapiEmail = null; iapiClearRedirectRequests(iapiCALLOUT_LOGIN, realMode); // params for POST request var params = []; // write cookie for real and fun mode if (realMode == 1) { iapiWriteClientCookie('loginSuccess=0&errorCode=0&expire=-1', 1); } else { iapiWriteClientCookie('loginSuccess=0&errorCode=0&expire=-1', 0); }; if (behaviour == undefined) { if (allSessions == 1) { behaviour = 'all'; } else { behaviour = 'this'; } }; var requestUrl = 'Logout.php?' + 'allSessions=' + allSessions + '&casinoname=' + iapiConf['casinoname'] + '&behaviour=' + behaviour; params['allSessions'] = allSessions; params['casinoname'] = iapiConf['casinoname']; params['behaviour'] = behaviour; if (realMode != undefined) { requestUrl += '&realMode=' + realMode; params['realMode'] = realMode; }; if (invalidateRememberMe == 1) { requestUrl += '&invalidateRememberMe=1'; params['invalidateRememberMe'] = 1; } if (iapiConf['onlypostrequestsforlogout']) { // POST request iapiMakeRedirectRequest('Logout.php', params, iapiCALLOUT_LOGOUT); } else { // GET request iapiMakeRedirectRequest(requestUrl, null, iapiCALLOUT_LOGOUT); } return iapiERR_OK; }; // public, callout functionality, example: iapiSetCallout(iapiCALLOUT_FORGOTPASSWORD, myCalloutForgotPasswordFunction); function iapiSetCallout(id, func) { iapiCalloutFunctions[id] = func; return iapiERR_OK; }; // public, request waiting messages, messageTypes is comma separated string IN(login, bonus, alert, bonus:2, logout, before_logout), realMode (1/0) function iapiGetWaitingMessages(messageTypes, realMode) { iapiClearRedirectRequests(iapiCALLOUT_MESSAGES, 0); iapiClearRedirectRequests(iapiCALLOUT_MESSAGES, 1); if (!messageTypes) { messageTypes = 'login,bonus,alert'; }; var requestUrl = 'GetWaitingMessages.php?' + 'messageTypes=' + messageTypes + '&casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode; iapiMakeRedirectRequest(requestUrl, null, iapiCALLOUT_MESSAGES); return iapiERR_OK; }; // public, submit accept pending limits dialog, action in ['accept', 'cancel'], realMode (1/0) function iapiAcceptPendingLimits(action, realMode) { var requestUrl = 'SubmitDialog.php?' + 'dialogType=' + 'AcceptPendingLimits' + '&casinoname=' + iapiConf['casinoname']; if (realMode != undefined) { requestUrl += '&realMode=' + realMode; }; var params = []; params['action'] = action; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SUBMITDIALOG); return iapiERR_OK; }; // public, submit bonus confirmation dialog, bonusIdentifier is identifier from message, accept (1/0), realMode (1/0) function iapiBonusConfirmation(bonusIdentifier, accept, realMode) { var requestUrl = 'SubmitDialog.php?' + 'dialogType=' + 'BonusConfirmation' + '&casinoname=' + iapiConf['casinoname']; if (realMode != undefined) { requestUrl += '&realMode=' + realMode; }; var params = []; params['bonusIdentifier'] = bonusIdentifier; if (accept) { params['accept'] = 1; } else { params['accept'] = 0; }; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SUBMITDIALOG); return iapiERR_OK; }; // public, accept terms and conditions, reference is tc version from login or validate login session response, accept (1/0), realMode (1/0) function iapiValidateTCVersion(reference, accept, realMode) { var requestUrl = 'ValidateLoginSession.php?' + 'validationType=' + 'TCVersion' + '&casinoname=' + iapiConf['casinoname']; if (realMode != undefined) { requestUrl += '&realMode=' + realMode; }; var params = []; params['termVersionReference'] = reference; if (accept) { params['accept'] = 1; } else { params['accept'] = 0; }; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SESSIONVALIDATION); return iapiERR_OK; }; // public, validate password change, oldPassword, newPassword, changePassword (1/0) if 1 then player’s password is also physically changed, realMode (1/0) function iapiValidatePasswordChange(oldPassword, newPassword, changePassword, realMode) { var requestUrl = 'ValidateLoginSession.php?' + 'validationType=' + 'PasswordChange' + '&casinoname=' + iapiConf['casinoname']; if (realMode != undefined) { requestUrl += '&realMode=' + realMode; }; var params = []; params['oldPassword'] = oldPassword; params['newPassword'] = newPassword; if (changePassword) { params['changePassword'] = 1; }; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SESSIONVALIDATION); return iapiERR_OK; }; // public, validate player confirmation token; parameter (string), realMode (1/0) function iapiValidateConfirmationToken(parameter, realMode) { var requestUrl = 'ValidateLoginSession.php?' + 'validationType=' + 'ConfirmationToken' + '&casinoname=' + iapiConf['casinoname']; if (realMode) { requestUrl += '&realMode=' + realMode; }; var params = []; params['parameter'] = parameter; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SESSIONVALIDATION); return iapiERR_OK; }; // public, validate player birthdate token; birthdate (yyyy-MM-dd), realMode (1/0) function iapiValidateBirthdateToken(birthdate, realMode) { var requestUrl = 'ValidateLoginSession.php?' + 'validationType=' + 'Birthdate' + '&casinoname=' + iapiConf['casinoname']; if (realMode) { requestUrl += '&realMode=' + realMode; }; var params = []; params['birthdate'] = birthdate; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SESSIONVALIDATION); return iapiERR_OK; }; // public, validate player activation code; activationCode (string), realMode (1/0) function iapiValidateActivationCode(activationCode, realMode) { var requestUrl = 'ValidateLoginSession.php?' + 'validationType=' + 'ActivationCode' + '&casinoname=' + iapiConf['casinoname']; if (realMode) { requestUrl += '&realMode=' + realMode; }; var params = []; params['activationCode'] = activationCode; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SESSIONVALIDATION); return iapiERR_OK; }; function iapiValidatePinChange(oldPin, newPin) { var requestUrl = 'ValidateLoginSession.php?' + 'validationType=' + 'PINChange' + '&casinoname=' + iapiConf['casinoname'] + '&realMode=1'; var params = []; params['oldPin'] = oldPin; params['newPin'] = newPin; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SESSIONVALIDATION); } function iapiValidatePinToken(pin) { var requestUrl = 'ValidateLoginSession.php?' + 'validationType=' + 'PINToken' + '&casinoname=' + iapiConf['casinoname'] + '&realMode=1'; var params = []; params['pin'] = pin; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_SESSIONVALIDATION); } // public, forgot password, username, email, birthDate in format "yyyy-mm-dd", realMode (1/0), verificationAnswer function iapiForgotPassword(username, email, birthDate, realMode, verificationAnswer) { var requestUrl = 'ForgotPassword.php?' + 'casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode; var params = []; params['username'] = username; params['email'] = email; params['birthDate'] = birthDate; if (verificationAnswer) { params['verificationAnswer'] = verificationAnswer; } iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_FORGOTPASSWORD); return iapiERR_OK; }; // public, start forgot email, cellphone, birthDate in format "yyyy-mm-dd", realMode (1/0) function iapiStartForgotEmail(cellphone, birthdate, realMode) { var requestUrl = 'StartForgotEmail.php?' + 'casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode; var params = []; params['cellphone'] = cellphone; params['birthdate'] = birthdate; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_STARTFORGOTEMAIL); return iapiERR_OK; }; // public, complete forgot email, token, realMode (1/0), [pin] function iapiCompleteForgotEmail(token, realMode, pin) { var requestUrl = 'CompleteForgotEmail.php?' + 'casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode; var params = []; params['token'] = token; if (pin) { params['pin'] = pin; } iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_COMPLETEFORGOTEMAIL); return iapiERR_OK; }; // public, online forgot password, username, email, birthDate in format "yyyy-mm-dd", realMode (1/0), verificationAnswer, newPassword function iapiOnlineForgotPassword(username, email, birthDate, realMode, verificationAnswer, newPassword) { var requestUrl = 'OnlineForgotPassword.php?' + 'casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode; var params = []; params['username'] = username; if (email) { params['email'] = email; } if (birthDate) { params['birthDate'] = birthDate; } if (verificationAnswer) { params['verificationAnswer'] = verificationAnswer; } if (newPassword) { params['newPassword'] = newPassword; } iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_ONLINEFORGOTPASSWORD); return iapiERR_OK; }; // public, get logged in player, realMode (1/0) function iapiGetLoggedInPlayer(realMode) { var requestUrl = 'GetLoggedInPlayer.php?' + 'casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode; iapiMakeRedirectRequest(requestUrl, null, iapiCALLOUT_GETLOGGEDINPLAYER); return iapiERR_OK; }; // public, keep alive, realMode (1/0), milliseconds from last action function iapiKeepAlive(realMode, millisFromLastAction) { var requestUrl = 'KeepAlive.php?' + 'casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode; if (millisFromLastAction) { requestUrl += '&millisFromLastAction=' + millisFromLastAction; } iapiMakeRedirectRequest(requestUrl, null, iapiCALLOUT_KEEPALIVE); return iapiERR_OK; } // public, get urls, configured by url templates; urlTypeList (comma-separated list of strings) function iapiGetUrls(urlTypeList) { var requestUrl = 'GetUrls.php?' + 'casinoname=' + iapiConf['casinoname'] + '&realMode=1' + '&urlTypeList=' + urlTypeList; iapiMakeRedirectRequest(requestUrl, null, iapiCALLOUT_GETURLS); return iapiERR_OK; } // public, set authentication type, authType ("password" or "externalToken"), default is "password" function iapiSetAuthenticationType(authType) { iapiConf['authenticationType'] = authType; }; // public, set client skin used in login, overwrites client skin from conf function iapiSetClientSkin(clientSkin) { iapiConf['clientSkin'] = clientSkin; }; // public, set client type used in login, overwrites client type from conf function iapiSetClientType(clientType) { iapiConf['clientType'] = clientType; }; //public, set client URL used in login, overwrites client URL from conf function iapiSetClientUrl(clientType, value) { iapiConf['clientUrl_'+clientType] = value; }; // public, set client version used in login, overwrites client version from conf function iapiSetClientVersion(clientVersion) { iapiConf['clientVersion'] = clientVersion; }; // public, set client channel used in login, overwrites client channel from conf function iapiSetClientChannel(clientChannel) { iapiConf['clientChannel'] = clientChannel; }; // public, set game type used in login, overwrites game type from conf function iapiSetGameType(gameType) { iapiConf['gameType'] = gameType; }; // public, set game type prefix used in login, overwrites game type prefix from conf function iapiSetGameTypePrefix(gameTypePrefix) { iapiConf['gameTypePrefix'] = gameTypePrefix; }; // public, set client platform used in login, overwrites client platform from conf function iapiSetClientPlatform(clientPlatform) { iapiConf['clientPlatform'] = clientPlatform; }; // public, set system id, overwrites system id from conf function iapiSetSystemId(systemId) { iapiConf['systemId'] = systemId; }; // public, set service type, overwrites service type from conf function iapiSetServiceType(serviceType) { iapiConf['serviceType'] = serviceType; }; // public, set language code function iapiSetLanguageCode(languageCode) { iapiConf['languageCode'] = languageCode; }; // public, set call id function iapiSetCallId(callId) { iapiConf['callId'] = callId; }; // public, set delivery platform function iapiSetDeliveryPlatform(deliveryPlatform) { iapiConf['deliveryPlatform'] = deliveryPlatform; }; // public, set device browser function iapiSetDeviceBrowser(deviceBrowser) { iapiConf['deviceBrowser'] = deviceBrowser; }; // public, set general name of the operating system used. function iapiSetOsName(osName) { iapiConf['osName'] = osName; }; // public, set os version function iapiSetOsVersion(osVersion) { iapiConf['osVersion'] = osVersion; }; //public, set device ID function iapiSetDeviceId(deviceId) { iapiConf['deviceId'] = deviceId; }; //public, set device type function iapiSetDeviceType(deviceType) { iapiConf['deviceType'] = deviceType; }; //public, set device family function iapiSetDeviceFamily(deviceFamily) { iapiConf['deviceFamily'] = deviceFamily; }; //deprecated, use iapiSetDeviceId instead //public, set soft serial function iapiSetSoftSerial(softSerial) { iapiConf['softSerial'] = softSerial; }; //public set Iovation blockbox string function iapiSetIovationBlackbox(iovationBlackbox) { iapiConf['iovationBlackbox'] = iovationBlackbox; } // public, enable to receive user error objects in callout function parameter function iapiEnableUserErrors() { iapiConf['errorLevel'] = 1; }; // private, jsonp callback arrives here function iapiCallbackWaitingMessages(messages) { // check request id and type var request = iapiGetRequest(iapiWaitingMessagesId); if (!request) { return; }; var error = { "errorCode" : 6, "errorText" : "Invalid response.", "playerMessage" : "" }; if (messages) { if (messages.errorCode) { error = { "errorCode" : messages.errorCode, "errorText" : messages.errorText, "playerMessage" : messages.playerMessage }; } else { error = null; } } else { messages = error; } // if error 6 and not enough tries then retry if (error && error.errorCode == 6) { if (request[3].length < iapiConf['loginDomainRetryCount']) { var requestId = (new Date().getTime()) + Math.round(Math.random() * 1000000); var failedTimer = setTimeout('iapiRequestFailed(' + requestId + ')', iapiConf['loginDomainRetryInterval'] * 1000); iapiRegisterRequestId(requestId, iapiCALLOUT_MESSAGES, failedTimer, request[3], request[4], request[5]); return; } } // successful or error response if (iapiCalloutFunctions[iapiCALLOUT_MESSAGES]) { setTimeout(function() { iapiCalloutFunctions[iapiCALLOUT_MESSAGES](messages); }, iapiEVENT_TIMER); }; }; // private, login with this username and password, and realMode (1/0) and language code function iapiBaseLogin(user, pass, realMode, language, rememberMeLogin) { // if login is already in progress and this login is for different mode then put to waiting status if ((iapiHasRedirectRequest(iapiCALLOUT_LOGIN)) && iapiRealMode != realMode) { iapiNextLogin = [user, pass, realMode, language, rememberMeLogin]; return iapiERR_OK; }; if (iapiAuthenticationType == iapiLoginTypes.EMAIL) { iapiEmail = user; } else { iapiUsername = user; } iapiPassword = pass; if (realMode == 1) { iapiRealMode = 1; } else { iapiRealMode = 0; }; if (language) { iapiSetLanguageCode(language); } iapiRememberMeLogin = rememberMeLogin; // write to client cookie that login is being processed iapiLoginSuccess = false; iapiWriteClientCookie('loginInProgress=1', iapiRealMode); // create divs/frames, post login iapiContinueLogin(); return iapiERR_OK; }; // private, create frames/divs, open login url function iapiContinueLogin() { iapiClearRedirectRequests(iapiCALLOUT_LOGIN, 0); iapiClearRedirectRequests(iapiCALLOUT_LOGIN, 1); var requestUrl = 'Login.php?' + 'casinoname=' + iapiConf['casinoname']; if (iapiRealMode == 1) { requestUrl += '&realMode=1'; } else { requestUrl += '&realMode=0'; }; if (iapiRememberMeLogin == 1) { requestUrl += '&rememberMeLogin=1'; } var params = []; if (iapiAuthenticationType == iapiLoginTypes.EXTERNAL_TOKEN) { if (iapiUsername) { params['username'] = iapiUsername; } params['externalToken'] = iapiPassword; } else if (iapiAuthenticationType == iapiLoginTypes.EMAIL) { if (iapiEmail) { params['email'] = iapiEmail; } params['password'] = iapiPassword; } else if (iapiAuthenticationType == iapiLoginTypes.SESSION_TOKEN) { params['sessionToken'] = iapiPassword; } else if (iapiAuthenticationType == iapiLoginTypes.ADMIN_USERNAME) { if (iapiAdminUsername) { params['adminUsername'] = iapiAdminUsername; } params['username'] = iapiUsername; params['externalToken'] = iapiPassword; } else if (iapiAuthenticationType == iapiLoginTypes.NICKNAME) { params['nickname'] = iapiUsername; params['password'] = iapiPassword; params['systemId'] = iapiConf['systemId']; } else if (iapiAuthenticationType == iapiLoginTypes.TOKEN_CODE) { params['tokenCode'] = iapiUsername; params['pin'] = iapiPassword; params['systemId'] = iapiConf['systemId']; } else if (iapiAuthenticationType == iapiLoginTypes.PRINTED_TOKEN_CODE) { params['printedTokenCode'] = iapiUsername; params['pin'] = iapiPassword; params['systemId'] = iapiConf['systemId']; } else if (iapiAuthenticationType == iapiLoginTypes.USERNAME_AND_PIN) { params['username'] = iapiUsername; params['phone'] = STOCK_AUTH_PHONE_NUMBER; params['pin'] = iapiPassword; params['systemId'] = iapiConf['systemId']; } else if (iapiAuthenticationType == iapiLoginTypes.TOKEN_CODE_AND_PASS) { params['tokenCode'] = iapiUsername; params['password'] = iapiPassword; params['systemId'] = iapiConf['systemId']; } else { params['username'] = iapiUsername; params['password'] = iapiPassword; if (iapiConf['iovationBlackbox']) { params['iovationBlackbox'] = iapiConf['iovationBlackbox']; } }; iapiMakeRedirectRequest(requestUrl, params, iapiCALLOUT_LOGIN); }; // private, Write client cookie function iapiWriteClientCookie(params, realMode) { // do not write client cookie in download login mode if (iapiLoginModeDownload) { return; } var tmpUrl = iapiConf['clientCookieUrl']; // if client cookie url doesn't exist then cookie is not needed if (!tmpUrl) { return; } if (tmpUrl.indexOf('://') < 0) { tmpUrl = location.protocol + '//' + tmpUrl; } var cookieUrl = tmpUrl + '?' + params + '&casinoname=' + iapiConf['casinoname'] + '&realMode=' + realMode; var iframename = iapiRealCookieIframe; if (realMode == 0) { iframename = iapiFunCookieIframe; } iapiCreateDiv(iapiDivname); iapiCreateIframe(iapiDivname, iframename); iapiGet(iframename, cookieUrl); }; // private, Create new div if div with given id doesn't exist function iapiCreateDiv(id) { if (document.getElementById(id)) { return; }; var newdiv = document.createElement('div'); newdiv.setAttribute('id', id); newdiv.setAttribute('style', 'DISPLAY:none;'); document.body.appendChild(newdiv); }; // private, create iframe function iapiCreateIframe(divName, frameName) { var l = document.getElementById(divName); // if iframe exists then return only for getloggedinplayer if (document.getElementById(frameName)) { if (frameName == iapiIframename + '_' + iapiGetLoggedInPlayerRequestIdReal || frameName == iapiIframename + '_' + iapiGetLoggedInPlayerRequestIdFun) { return true; } l.removeChild(document.getElementById(frameName)); } var iframeelement; try { iframeelement = document.createElement("