@vkontakte/superappkit
Advanced tools
Comparing version 1.24.0-alpha.1 to 1.24.0
@@ -0,0 +0,0 @@ interface BridgeMessageData<H> { |
@@ -0,0 +0,0 @@ export declare const VERSION = "0.0.2"; |
@@ -0,0 +0,0 @@ export declare enum ERROR_CODES { |
@@ -0,0 +0,0 @@ export declare type FrameProperties = { |
@@ -0,0 +0,0 @@ import { FrameSettings } from '#/common/types'; |
export declare enum ConfigEvents { | ||
SUPERAPP_TOKEN = "VKSDKGeneralSuperAppToken", | ||
AUTH_NEEDED = "VKSDKGeneralAuthNeeded", | ||
OPEN_APP = "VKSDKGeneralOpenApp", | ||
GET_SUPERAPP_TOKEN = "SDKGetSuperAppToken" | ||
OPEN_APP = "VKSDKGeneralOpenApp" | ||
} |
@@ -6,3 +6,2 @@ import mitt from 'mitt'; | ||
superAppToken: string; | ||
superAppTokenV2: string; | ||
loginDomain: string; | ||
@@ -14,2 +13,7 @@ oauthDomain: string; | ||
} | ||
interface Handlers { | ||
superAppToken?: () => Promise<string> | void; | ||
auth?: () => Promise<string> | void; | ||
openApp?: (app: string) => void; | ||
} | ||
declare const Config: { | ||
@@ -20,14 +24,9 @@ events: mitt.Emitter; | ||
setSuperAppToken(token: string): void; | ||
setSuperAppTokenV2(token: string): void; | ||
onRequestSuperAppToken(fn: (() => void | Promise<string>) | undefined): void; | ||
onRequestSuperAppTokenV2(fn: (() => void | Promise<string>) | undefined): void; | ||
onRequestSuperAppToken(fn: Handlers['superAppToken']): void; | ||
_requestSuperAppToken(): void; | ||
_requestSuperAppTokenV2(): void; | ||
onAuth(fn: (() => void | Promise<string>) | undefined): void; | ||
_requestAuth(params?: { | ||
tokenVersion: string; | ||
} | undefined): void; | ||
onOpenApp(fn: ((app: string) => void) | undefined): void; | ||
onAuth(fn: Handlers['auth']): void; | ||
_requestAuth(): void; | ||
onOpenApp(fn: Handlers['openApp']): void; | ||
_openApp(params: any): void; | ||
}; | ||
export default Config; |
@@ -0,0 +0,0 @@ export declare enum DataPolicyEventsSDK { |
@@ -0,0 +0,0 @@ import { AuthButtonParams, AuthButtonType, AuthParams, ButtonOneTapAuthParams, RedirectAuthParams, VKAuthSuccessResult, VKDataPolicyResult, VKOneTapAuthButtonResult, VKOneTapAuthResult, VKUserVisibleAuthResult } from './types'; |
@@ -0,0 +0,0 @@ import { AuthCaptchaEventsSDK, ButtonOneTapAuthEventsSDK, DataPolicyEventsSDK, FloatingOneTapAuthEventsSDK, OneTapAuthEventsSDK, PolicyAgreementsEventsSDK } from '#/connect/events'; |
@@ -0,0 +0,0 @@ import { AuthAction, AdaptivitySwitchObserver, VKOneTapAuthOptions, ButtonOneTapAuthOptions } from '#/connect/types'; |
@@ -0,0 +0,0 @@ import { DecodeCoordsParams, DecodeCoordsResponse, DirectionsParams, DirectionsResponse, EncodeCoordsParams, EncodeCoordsResponse, ISOParams, ISOResponse, StaticMapRequestParams } from './types'; |
@@ -0,0 +0,0 @@ export declare type StaticMapRequestParams = { |
@@ -1,1 +0,1 @@ | ||
"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(n){return n&&"object"===e(n)&&"default"in n?n.default:n}Object.defineProperty(exports,"__esModule",{value:!0});var t=n(require("@babel/runtime/helpers/typeof"));require("@babel/runtime/helpers/toConsumableArray");var o=n(require("@babel/runtime/helpers/defineProperty"));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function a(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function p(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?c(Object(t),!0).forEach((function(n){s(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass");var u,d="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",l=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=d[64*Math.random()|0];return n},h=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand","vkc_display_mode","service_groups","external_device_id"];!function(e){e[e.UNKNOWN=1]="UNKNOWN",e[e.MISSING_PARAM=2]="MISSING_PARAM",e[e.CONNECTION_LOST=3]="CONNECTION_LOST",e[e.USER_DENIED=4]="USER_DENIED",e[e.INVALID_PARAMS=5]="INVALID_PARAMS",e[e.CUSTOM=6]="CUSTOM",e[e.CONNECT_WINDOW_CLOSED=7]="CONNECT_WINDOW_CLOSED",e[e.CONNECT_WINDOW_NOT_OPENED=8]="CONNECT_WINDOW_NOT_OPENED",e[e.CONNECT_DOMAIN_NOT_ALLOWED=9]="CONNECT_DOMAIN_NOT_ALLOWED",e[e.CONNECT_UNKNOWN_SDK_MESSAGE=10]="CONNECT_UNKNOWN_SDK_MESSAGE",e[e.OLD_MISSING_PARAM=100]="OLD_MISSING_PARAM"}(u||(u={}));var f=function(){return"Connect window was closed."},m=function(){return"Connect window was not opened."},A=function(e){return'URL domain "'.concat(e,'" is not allowed.')},g=function(e){return"This SDK message is unknown: ".concat(e)},v=!("undefined"==typeof window||!window.document||!window.document.createElement),y=v&&!!window.addEventListener,E=function(){};if(y)try{var _=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",E,_),window.removeEventListener("test",E,_)}catch(e){}!function(){if(!v)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function O(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function S(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?O(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var T={parse:function(e){if("string"!=typeof e)return{};if(!(e=e.trim().replace(/^[?#&]/,"")))return{};var n=/\?(.+)$/gi.exec(e);return(n?n[1]:e).split("&").reduce((function(e,n){var t=n.split("=");return t[1]&&(e[t[0]]=decodeURIComponent(t[1])),e}),{})},stringify:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==t(e)||null===e)return"";n=S({encode:!0},n);var o=function(e){return n.encode?encodeURIComponent(e):String(e)};return Object.keys(e).reduce((function(t,i){var r=e[i];return void 0===r?t:null===r?(n.skipNull||t.push([o(i),""].join("=")),t):Array.isArray(r)?(r.map((function(e){t.push("".concat(o(i),"[]=").concat(o(e)))})).join(),t):(t.push([o(i),o(r)].join("=")),t)}),[]).join("&")}};function b(e){return T.stringify(e)}function w(e){return Object.keys(e).filter((function(e){return h.includes(e)}))}function P(e){var n;return Boolean(null===(n=w(e))||void 0===n?void 0:n.length)}function D(e){var n=function(e){return w(e).reduce((function(n,t){return n[t]=e[t],n}),{})}(e);return btoa(JSON.stringify(n))}function C(e,n){var t,o=document.createElement("iframe");for(var i in e&&(o.src=e),o.style.cssText=null!==(t=null==n?void 0:n.cssText)&&void 0!==t?t:"",o.width="100%",o.height="100%",o.style.border="none",null==n?void 0:n.properties){var r;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(r=n.properties[i])&&void 0!==r?r:""}return o}function N(e){return e=e||Object.create(null),{on:function(n,t){(e[n]||(e[n]=[])).push(t)},off:function(n,t){e[n]&&e[n].splice(e[n].indexOf(t)>>>0,1)},emit:function(n,t){(e[n]||[]).slice().map((function(e){e(t)})),(e["*"]||[]).slice().map((function(e){e(n,t)}))}}}var k={appId:0,superAppToken:"",superAppTokenV2:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},I={},M={events:N(),init:function(e){if(!e.appId)throw new Error("appId required");k.appId=e.appId,k.superAppToken=e.superAppToken||"",k.superAppTokenV2=e.superAppTokenV2||"",k.loginDomain=e.loginDomain||"login.vk.com",k.oauthDomain=e.oauthDomain||"oauth.vk.com",k.connectDomain=e.connectDomain||"connect.vk.com",k.appSettings=e.appSettings,k._debug=!!e._debug},get:function(){return k},setSuperAppToken:function(e){k.superAppToken=e,M.events.emit("superAppToken",e)},setSuperAppTokenV2:function(e){k.superAppTokenV2=e,M.events.emit("superAppTokenV2",e)},onRequestSuperAppToken:function(e){I.superAppToken=e},onRequestSuperAppTokenV2:function(e){I.superAppTokenV2=e},_requestSuperAppToken:function(){var e;I.superAppToken&&(e=I.superAppToken()),e&&e.then((function(e){return M.setSuperAppToken(e)})).catch(console.error)},_requestSuperAppTokenV2:function(){var e;I.superAppTokenV2&&(e=I.superAppTokenV2()),e&&e.then((function(e){return M.setSuperAppTokenV2(e)})).catch(console.error)},onAuth:function(e){I.auth=e},_requestAuth:function(e){var n,t=(e||{}).tokenVersion;I.auth&&(n=I.auth()),n&&n.then((function(e){"2"===t?M.setSuperAppTokenV2(e):M.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){I.openApp=e},_openApp:function(e){I.openApp&&I.openApp(e.app)}},K=["extend_token","login_with_user","__sferum_invite_link"];function R(e){return e&&K.includes(e.name)?btoa(JSON.stringify(e)):""}var L;function V(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=M.get(),o=t.appId,i=t.connectDomain,r=t.appSettings,a=p({app_id:o,response_type:"silent_token",v:"0.0.2"},e);r&&P(r)&&(a.app_settings=D(r));var s=b(a);return"https://".concat(i,"/").concat(n,"?").concat(s)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(L||(L={}));var x=[L.Default,L.NamePhone,L.PhoneName];function H(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}function U(e,n){return e&&"object"===i(e)?Object.keys(e).reduce((function(t,o){return n.includes(o)?(t[o]=e[o],t):t}),{}):e}var G,W,j,q,F,z,Y=function e(n){var t=this;r(this,e),s(this,"handler",(function(){return{}})),s(this,"config",void 0),s(this,"destroy",(function(){delete t.config,window.removeEventListener("message",t.handleMessage)})),s(this,"onMessage",(function(e){t.handler=e})),s(this,"sendMessage",(function(e){t.config.iframe.contentWindow.postMessage(p({type:"vk-sak-sdk"},e),t.config.origin)})),s(this,"handleMessage",(function(e){t.config.origin&&e.origin===t.config.origin&&e.source===t.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&t.handler(e.data)})),this.config=n,window.addEventListener("message",this.handleMessage)};!function(e){e.SHOW_DATA_POLICY="VKSDKOneTapAuthConnectDataPolicy",e.HIDE_DATA_POLICY="VKSDKOneTapAuthDataPolicyClose",e.DATA_POLICY_RESULT="VKSDKOneTapAuthDataPolicyResult",e.SHOW_CAPTCHA="VKSDKOneTapAuthDataPolicyShowCaptcha"}(G||(G={})),function(e){e.SHOW_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsShow",e.HIDE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsHide",e.ACCEPT_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsAccept",e.DECLINE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsDecline",e.POLICY_AGREEMENTS_ERROR="VKSDKOneTapAuthPolicyAgreementsError",e.SHOW_DATA_POLICY="VKSDKOneTapAuthPolicyAgreementsShowDataPolicy"}(W||(W={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(j||(j={})),function(e){e.PHONE_VALIDATION_NEEDED="VKSDKOneTapAuthPhoneValidationNeeded",e.FULL_AUTH_NEEDED="VKSDKOneTapAuthFullAuthNeeded",e.AUTH_DATA_LOADED="VKSDKOneTapAuthDataLoaded",e.NOT_AUTHORIZED="VKSDKOneTapAuthNotAuthorized",e.LOGIN_SUCCESS="VKSDKOneTapAuthLoginSuccess",e.RESIZE_FRAME="VKSDKOneTapResizeFrame",e.SHOW_CAPTCHA="VKSDKOneTapShowCaptcha",e.VALIDATE_CAPTCHA="VKSDKOneTapValidateCaptcha"}(q||(q={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(F||(F={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions",e.SHOW_AGREEMENTS_DIALOG="VKSDKButtonOneTapAuthShowAgreementsDialog",e.START_AUTHORIZE="VKSDKButtonOneTapAuthStartAuthorize"}(z||(z={}));var Z,B,J,X=new function e(){var n=this;r(this,e),s(this,"flags",null),s(this,"silentAuth",(function(){var e=M.get(),n=e.loginDomain,t=e.appId,o=l(),i="https://".concat(n,"/?act=connect&app_id=").concat(t,"&response_type=").concat("silent_token","&uuid=").concat(o,"&v=").concat("0.0.2"),r=new XMLHttpRequest;return r.open("GET",i,!0),r.responseType="json",r.withCredentials=!0,new Promise((function(e,n){r.onload=function(){r.response?e({provider:"vk",payload:r.response}):n()},r.onerror=function(){n()},r.send()}))})),s(this,"oneTapAuth",(function(e,t){if(console.warn("Connect.oneTapAuth method is deprecated. Use Connect.floatingOneTapAuth and Connect.buttonOneTapAuth methods."),!["floating","button"].includes(e))return null;switch(e){case"button":return n.buttonOneTapAuth(t);case"floating":return n.floatingOneTapAuth(t);default:return null}})),s(this,"floatingOneTapAuth",(function(e){var t,o,i=function(){var e,n=window.innerWidth,t=n<=768;return{destroy:function(){return window.removeEventListener("resize",e)},isAdaptive:function(){return t},observe:function(o){e=function(){var e=window.innerWidth;n>768&&e<=768?o(t=!0):n<=768&&e>768&&o(t=!1),n=e},window.addEventListener("resize",e)}}}(),r=(t=i.isAdaptive(),o=t?"314px":"334px",{pageUrl:"floating_one_tap_auth",pageUrlParams:{adaptive:t?1:0},frameStyles:t?"\n display: none;\n position: fixed;\n bottom: 0;\n right: 50%;\n transform: translate(50%, 0);\n max-width: 468px;\n width: 100%;\n height: ".concat(o,";\n "):"\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n max-width: 400px;\n width: 100%;\n height: ".concat(o,";\n ")});if(!r)throw new Error("options were not set");var a=l(),s=C(V(p({origin:location.protocol+"//"+location.host,uuid:a},r.pageUrlParams),r.pageUrl),{cssText:r.frameStyles}),c=new Y({iframe:s,origin:"https://"+M.get().connectDomain});i.observe((function(e){c.sendMessage({handler:F.ADAPTIVITY_CHANGE,params:{uuid:a,is_adaptive:e}}),e?(s.style.maxWidth="468px",s.style.top="auto",s.style.bottom="0",s.style.right="50%",s.style.transform="translate(50%, 0)"):(s.style.maxWidth="400px",s.style.top="0",s.style.bottom="auto",s.style.right="0",s.style.transform="none"),s.style.display="none"})),document.body.appendChild(s);var u=function(){c.sendMessage({handler:q.RESIZE_FRAME,params:{uuid:a}})};window.addEventListener("resize",u);var d=function(){s&&(s.remove(),s=null),window.removeEventListener("resize",u),i&&i.destroy(),c.destroy()},h=new Promise((function(t){c.onMessage((function(o){if(o.params.uuid===a)switch(o.handler){case q.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:a,error:"not_authorized"}}),d(),t(o.handler);break;case q.RESIZE_FRAME:s.style.height="".concat(o.params.height,"px");break;case F.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:a}}),d();break;case F.ADAPTIVITY_CHANGED:s.style.display="block";break;case q.AUTH_DATA_LOADED:s.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,c,e)}}))}));return{getFrame:function(){return s},destroy:d,authReadyPromise:h}})),s(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){n.display=e.displayMode&&x.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=H(e.showAgreements,0),n.show_alternative_login=H(e.showAlternativeLogin,0),n.show_agreements_dialog=H(e.showAgreementsDialog,1);t+=n.show_alternative_login?56:0,t+=n.show_agreements?80:0}return{pageUrl:"button_one_tap_auth",pageUrlParams:n,frameStyles:"\n height: ".concat(t,"px;\n ")}}(e.options);if(!t)throw new Error("options were not set");var o=l(),i=C(V(p({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),r=e.container;r&&r.appendChild(i);var a=new Y({iframe:i,origin:"https://"+M.get().connectDomain}),s=function(){a.sendMessage({handler:q.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",s);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",s),a.destroy()},authReadyPromise:new Promise((function(t){a.onMessage((function(r){if(r.params.uuid===o)switch(r.handler){case q.RESIZE_FRAME:i.style.height="".concat(r.params.height,"px");break;case q.NOT_AUTHORIZED:t(r.handler);break;case z.SHOW_LOGIN:case z.SHOW_LOGIN_OPTIONS:e.callback({type:r.handler,payload:{uuid:o}});break;case z.SHOW_AGREEMENTS_DIALOG:n.userPolicyAgreements(o).show().then((function(e){e&&e.accepted&&a.sendMessage({handler:z.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){a.sendMessage({handler:W.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case q.AUTH_DATA_LOADED:t(r.handler);default:n.handleOneTapEvents(r,a,e)}}))}))}})),s(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case q.AUTH_DATA_LOADED:t.sendMessage({handler:q.RESIZE_FRAME,params:{uuid:i}});break;case q.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:p({uuid:i},e.params)});break;case q.SHOW_CAPTCHA:var r=n.captcha(i,{captcha_sid:e.params.captcha_sid,captcha_img:e.params.captcha_img});r.show().then((function(e){t.sendMessage({handler:j.CAPTCHA_SUCCESS,params:p({uuid:i},e)})})).catch((function(){t.sendMessage({handler:j.CAPTCHA_FAIL,params:{uuid:i}}),r.destroy()}));break;case G.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:G.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:G.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case q.FULL_AUTH_NEEDED:case q.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),s(this,"userDataPolicy",(function(e){var t=V({origin:location.protocol+"//"+location.host,uuid:e},"user_data_policy"),o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),r=C(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(r);var a=new Y({iframe:r,origin:"https://"+M.get().connectDomain}),s=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){a.onMessage((function(i){switch(i.handler){case G.HIDE_DATA_POLICY:s(),t();break;case G.SHOW_CAPTCHA:var c=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});c.show().then((function(n){a.sendMessage({handler:j.CAPTCHA_SUCCESS,params:p({uuid:e},n)}),r.style.display="block"})).catch((function(){a.sendMessage({handler:j.CAPTCHA_FAIL,params:{uuid:e}}),c.destroy()})),s();break;default:s(),o()}}))}))},hide:s,destroy:function(){document.body.removeChild(r),a.destroy()}}})),s(this,"userPolicyAgreements",(function(e){var t,o,i,r=V({origin:location.protocol+"//"+location.host,uuid:e},"user_policy_agreements"),a=(t=r,o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),C(t,{properties:{height:"".concat(o,"px")},cssText:i}));document.body.appendChild(a);var s=new Y({iframe:a,origin:"https://"+M.get().connectDomain}),c=function(){a.style.display="none"};return{show:function(){return a.style.display="block",new Promise((function(t,o){s.onMessage((function(i){switch(i.handler){case W.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case W.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case W.SHOW_DATA_POLICY:c();var r=function(){a.style.display="block"};n.userDataPolicy(e).show().then(r).catch(r);break;case W.POLICY_AGREEMENTS_ERROR:case W.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(a),s.destroy()}}})),s(this,"captcha",(function(e,n){var t=V(p({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=C(t,{cssText:"\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n ")});document.body.appendChild(i);var r=new Y({iframe:i,origin:"https://"+M.get().connectDomain}),a=function(){document.body.removeChild(i),r.destroy()};return{show:function(){return i.style.display="block",new Promise((function(e,n){r.onMessage((function(t){switch(t.handler){case j.CAPTCHA_SUCCESS:e(t.params),a();break;default:n(),a()}}))}))},destroy:a}})),s(this,"userVisibleAuth",(function(e){var t=l(),o=p({origin:location.protocol+"//"+location.host,uuid:t},U(e,["screen","source"])),i=R(null==e?void 0:e.action);i&&(o.action=i);var r=V(o);n.flags&&(r="".concat(r,"#").concat(b(n.flags)));var a=screen.height/2-280,s=screen.width/2-410,c=window.open(r,"_blank","top=".concat(a,",left=").concat(s,",width=").concat(820,",height=").concat(560,",location"));if(!c){var d={code:u.CONNECT_WINDOW_NOT_OPENED,reason:m()};return Promise.reject(d)}return new Promise((function(e,n){var o=setInterval((function(){if(!c||c.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:u.CONNECT_WINDOW_CLOSED,reason:f()};n(e)}}),1e3);function i(r){if(r.source===c&&c)if(window.removeEventListener("message",i),clearInterval(o),".vk.com"===r.origin.slice(r.origin.length-".vk.com".length))if(r.data.action==="vk_connect_response"+t){var a=r.data.payload;c.close(),e({provider:"vk",payload:a})}else if(r.data.action==="oauth_callback"+t)e({provider:r.data.payload.name}),c.close();else{c.close();var s={code:u.CONNECT_UNKNOWN_SDK_MESSAGE,reason:g(JSON.stringify(r.data))};n(s)}else{c.close();var p={code:u.CONNECT_DOMAIN_NOT_ALLOWED,reason:A(r.origin)};n(p)}}window.addEventListener("message",i)}))})),s(this,"redirectAuth",(function(e){var n=l(),t=p({redirect_uri:e.url,uuid:n},U(e,["screen","source"])),o=R(null==e?void 0:e.action);o&&(t.action=o),(null==e?void 0:e.state)&&(t.redirect_state=e.state);var i=V(t);location.assign(i)}))};!function(e){e.APP_CLOSE="VKWebAppClose",e.APP_READY="VKSDKMiniAppReady",e.RESIZE="VKSDKMiniAppResize",e.APP_INIT_CONFIG="VKSDKMiniAppInitConfig",e.OPEN_APP="VKWebAppOpenApp",e.OPEN_PAY_FORM="VKWebAppOpenPayForm",e.ACTION_DONE="VKWebAppActionDone"}(Z||(Z={})),(B=exports.MiniAppEvents||(exports.MiniAppEvents={})).OPEN="open",B.HIDE="hide",B.CLOSE="close",B.SHOW="show",B.MESSAGE="message",B.CREATE_APP="createapp",function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp",e.GET_SUPERAPP_TOKEN="SDKGetSuperAppToken"}(J||(J={}));var Q;(Q=exports.MessengerEvents||(exports.MessengerEvents={})).UPDATE_PARAMS="VKMessengerUpdateParams",Q.CLOSE="VKMessengerClose",Q.RESIZE="VKMessengerResize";var $;!function(e){e.STATIC_MAP="VKSDKRequestToGeoservice:staticmap/png/",e.SEARCH="VKSDKRequestToGeoservice:search",e.OVERALL="VKSDKRequestToGeoservice:overall",e.DIRECTIONS="VKSDKRequestToGeoservice:directions",e.ISO="VKSDKRequestToGeoservice:iso"}($||($={}));var ee=function(){function e(n){var t=this,o=n.apiKey;r(this,e),s(this,"iframe",void 0),s(this,"bridge",void 0),s(this,"requestMap",void 0),s(this,"apiKey",void 0),this.apiKey=o;var i=document.createElement("iframe"),a=M.get().appId;i.src=this.getGeoserviceProxyUrl({app_id:a}),i.style.cssText="\n display: none;\n ",this.iframe=i,document.body.appendChild(this.iframe),this.bridge=new Y({iframe:this.iframe,origin:"https://"+M.get().connectDomain}),this.requestMap={},this.bridge.onMessage((function(e){var n=e.params,o=n.requestID,i=n.response;t.requestMap[o].resolve(i),delete t.requestMap[o]}))}var n,t,o;return n=e,(t=[{key:"setApiKey",value:function(e){this.apiKey=e}},{key:"getGeoserviceProxyUrl",value:function(e){var n=M.get(),t=n.connectDomain,o=n._debug,i=p({},e||{},{origin:location.protocol+"//"+location.host,localhost:String(location.host.includes("localhost")),debug:location.host.includes("localhost")?1:String(o)});return"https://".concat(t,"/geoservice?").concat(b(i))}},{key:"prepareAnswer",value:function(e,n,t){var o=this,i=l();return this.bridge.sendMessage({handler:"VKSDKRequestToGeoservice:".concat(e),params:p({},n,{api_key:this.apiKey,wrapRequestInJSON:t,requestID:i})}),new Promise((function(e,n){o.requestMap[i]={resolve:e,reject:n}}))}},{key:"getStaticMap",value:function(e){return this.prepareAnswer("staticmap/png/",e)}},{key:"encodeCoords",value:function(e){return this.prepareAnswer("search",e)}},{key:"decodeCoords",value:function(e){return this.prepareAnswer("overall",e)}},{key:"getDirections",value:function(e){return this.prepareAnswer("directions",e,!0)}},{key:"getISO",value:function(e){return this.prepareAnswer("iso",e,!0)}}])&&a(n.prototype,t),o&&a(n,o),e}(),ne={OneTapAuthEventsSDK:q,FloatingOneTapAuthEventsSDK:F,ButtonOneTapAuthEventsSDK:z,DataPolicyEventsSDK:G,AuthCaptchaEventsSDK:j};exports.Config=M,exports.Connect=X,exports.ConnectEvents=ne,exports.GeoService=ee,exports.Messenger=function e(n){var t=this;r(this,e),s(this,"events",void 0),s(this,"iframe",void 0),s(this,"bridge",void 0),s(this,"loadingPromise",void 0),s(this,"params",void 0),s(this,"open",(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.loadingPromise;return t.loadingPromise||(o=t.preload(p({},n.query,{peer_id:e})).catch(console.error)),o.then((function(){t.bridge.sendMessage({handler:exports.MessengerEvents.UPDATE_PARAMS,params:p({},n,{peer_id:e})}),t.iframe.style.display="block"}))})),s(this,"close",(function(){t.iframe&&t.iframe.remove(),t.bridge&&t.bridge.destroy(),delete t.iframe,delete t.bridge})),s(this,"preload",(function(e){var n=isFinite(t.params.zIndex)?t.params.zIndex:999999;console.log(t.params);var o="\n display: none;\n border: none;\n z-index: ".concat(n,";\n position: fixed;\n bottom: ").concat(t.params.bottom,";\n right: ").concat(t.params.right,";\n "),i=C(t.getMessengerUrl(e),{cssText:o});return M.events.on("superAppTokenV2",t.handleSuperAppToken),t.iframe=i,t.loadingPromise=new Promise((function(e){t.iframe.onload=function(){t.iframe.onload=null,e()}})),window.document.body.appendChild(t.iframe),t.bridge=new Y({iframe:t.iframe,origin:"https://"+M.get().connectDomain}),t.bridge.onMessage(t.handleMessage),t.loadingPromise})),s(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),s(this,"handleMessage",(function(e){switch(console.log(e),e.handler){case J.GET_SUPERAPP_TOKEN:M._requestSuperAppTokenV2();break;case J.AUTH_NEEDED:M._requestAuth({tokenVersion:"2"});break;case exports.MessengerEvents.CLOSE:t.close();break;case exports.MessengerEvents.RESIZE:t.handleIframeResize(e);break;default:return}})),s(this,"getMessengerUrl",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=M.get(),t=n.connectDomain,o=n._debug,i=n.superAppTokenV2,r=n.appId;console.log("config",M.get());var a=b(p({},e,{host_app_id:r,debug:o?"1":"",localhost:o?"1":"",superapp_token:i,origin:location.protocol+"//"+location.host}));return"https://".concat(t,"/messenger?").concat(a)})),s(this,"handleSuperAppToken",(function(e){t.bridge.sendMessage({handler:"".concat(J.GET_SUPERAPP_TOKEN,"Success"),params:{result:e}})})),s(this,"handleIframeResize",(function(e){var n=e.params;console.log(n),t.iframe.width="".concat(n.width,"px"),t.iframe.height="".concat(n.height,"px")})),this.params=p({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=N()},exports.MiniApp=function e(n){var t=this;r(this,e),s(this,"events",void 0),s(this,"iframe",void 0),s(this,"bridge",void 0),s(this,"loading",void 0),s(this,"readyPromiseResolve",null),s(this,"readyPromise",null),s(this,"bodyOverflowValue",""),s(this,"params",void 0),s(this,"child",null),s(this,"open",(function(e,n){return t.loading?(t.iframe.src=t.getMiniAppUrl(e,n),t.loading=new Promise((function(e){t.iframe.onload=function(){t.iframe.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e}))):t.preload(e,n).catch(console.error),t.iframe.style.display="block",t.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",t.loading.then(t.handleResize).catch(console.error),t.events.emit(exports.MiniAppEvents.OPEN),t.readyPromise})),s(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.HIDE)})),s(this,"close",(function(){window.document.body.style.overflowX="",M.events.off("superAppToken",t.onSuperAppToken),t.iframe&&t.iframe.remove(),t.bridge&&t.bridge.destroy(),delete t.iframe,delete t.bridge,window.removeEventListener("resize",t.handleResize),t.events.emit(exports.MiniAppEvents.CLOSE)})),s(this,"show",(function(){if(!t.loading)throw new Error('App is not loaded, use "open" or "preload" methods');t.iframe.style.display="block",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.SHOW)})),s(this,"preload",(function(e,n){var o=document.createElement("iframe"),i=window.innerHeight,r=isFinite(t.params.zIndex)?t.params.zIndex:999999;return o.src=t.getMiniAppUrl(e,n),o.setAttribute("allow","geolocation"),o.style.cssText="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(i,"px;\n min-height: ").concat(i,"px;\n border: none;\n z-index: ").concat(r,";\n "),t.iframe=o,document.body.appendChild(t.iframe),M.events.on("superAppToken",t.onSuperAppToken),t.bridge=new Y({iframe:t.iframe,origin:"https://"+M.get().connectDomain}),t.bridge.onMessage(t.handleMessage),window.addEventListener("resize",t.handleResize),t.loading=new Promise((function(e){o.onload=function(){o.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e})),t.loading})),s(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),s(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:J.SUPERAPP_TOKEN,params:{result:e}})})),s(this,"handleMessage",(function(e){switch(e.handler){case Z.APP_CLOSE:t.hide();break;case Z.APP_READY:t.resolveReadyPromise(),t.handleUpdateConfig();break;case Z.OPEN_APP:t.openMiniapp(e.params);break;case Z.OPEN_PAY_FORM:t.openPayForm(e.params);break;case J.SUPERAPP_TOKEN:M._requestSuperAppToken();break;case J.AUTH_NEEDED:M._requestAuth();break;default:t.events.emit(exports.MiniAppEvents.MESSAGE,e)}})),s(this,"handleResize",(function(){if(t.iframe){var e=innerWidth,n=innerHeight;t.iframe.style.height="".concat(n,"px"),t.iframe.style.minHeight="".concat(n,"px"),t.bridge.sendMessage({handler:Z.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),s(this,"handleUpdateConfig",(function(){t.bridge.sendMessage({handler:Z.APP_INIT_CONFIG,params:{fullMode:t.params.fullMode,hideMenu:t.params.hideMenu}})})),s(this,"getMiniAppUrl",(function(e,n){var o=M.get(),i=o.connectDomain,r=o.appId,a=o.superAppToken,s=o._debug,c=b({app:t.params.app,host_app_id:r,debug:s?"1":"",localhost:s?"1":"",superapp_token:a,app_query:e?JSON.stringify(e):"",app_hash:n||""});return"https://".concat(i,"/mini_app?").concat(c)})),s(this,"resolveReadyPromise",(function(){t.readyPromise&&t.readyPromiseResolve&&(t.readyPromiseResolve(),t.readyPromise=null,t.readyPromiseResolve=null)})),s(this,"openMiniapp",(function(n){t.child=new e({app:n.app_id}),t.events.emit(exports.MiniAppEvents.CREATE_APP,{app:t.child,location:n.location})})),s(this,"openPayForm",(function(n){var o=p({},n.params);o.data&&(o.data=JSON.stringify(o.data));var i=p({},o,{app_id:n.app_id,action:n.action}),r=new e({app:6217559});r.open(i).then((function(){return t.hide()})).catch(console.error),r.events.on(exports.MiniAppEvents.MESSAGE,(function(e){t.handleVKPayFormMessage(e),r.close(),t.show()})),r.events.on(exports.MiniAppEvents.HIDE,(function(){r.close(),t.close()}))})),s(this,"handleVKPayFormMessage",(function(e){e.handler===Z.ACTION_DONE&&t.sendMessage(e)})),this.params=p({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=N()}; | ||
"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(n){return n&&"object"===e(n)&&"default"in n?n.default:n}Object.defineProperty(exports,"__esModule",{value:!0});var t=n(require("@babel/runtime/helpers/typeof"));require("@babel/runtime/helpers/toConsumableArray");var o=n(require("@babel/runtime/helpers/defineProperty"));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function a(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function c(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function p(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?c(Object(t),!0).forEach((function(n){s(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):c(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass");var u,l="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",d=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=l[64*Math.random()|0];return n},h=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand","vkc_display_mode","service_groups","external_device_id"];!function(e){e[e.UNKNOWN=1]="UNKNOWN",e[e.MISSING_PARAM=2]="MISSING_PARAM",e[e.CONNECTION_LOST=3]="CONNECTION_LOST",e[e.USER_DENIED=4]="USER_DENIED",e[e.INVALID_PARAMS=5]="INVALID_PARAMS",e[e.CUSTOM=6]="CUSTOM",e[e.CONNECT_WINDOW_CLOSED=7]="CONNECT_WINDOW_CLOSED",e[e.CONNECT_WINDOW_NOT_OPENED=8]="CONNECT_WINDOW_NOT_OPENED",e[e.CONNECT_DOMAIN_NOT_ALLOWED=9]="CONNECT_DOMAIN_NOT_ALLOWED",e[e.CONNECT_UNKNOWN_SDK_MESSAGE=10]="CONNECT_UNKNOWN_SDK_MESSAGE",e[e.OLD_MISSING_PARAM=100]="OLD_MISSING_PARAM"}(u||(u={}));var f=function(){return"Connect window was closed."},A=function(){return"Connect window was not opened."},m=function(e){return'URL domain "'.concat(e,'" is not allowed.')},y=function(e){return"This SDK message is unknown: ".concat(e)},g=!("undefined"==typeof window||!window.document||!window.document.createElement),v=g&&!!window.addEventListener,_=function(){};if(v)try{var E=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",_,E),window.removeEventListener("test",_,E)}catch(e){}!function(){if(!g)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function O(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function S(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?O(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var T={parse:function(e){if("string"!=typeof e)return{};if(!(e=e.trim().replace(/^[?#&]/,"")))return{};var n=/\?(.+)$/gi.exec(e);return(n?n[1]:e).split("&").reduce((function(e,n){var t=n.split("=");return t[1]&&(e[t[0]]=decodeURIComponent(t[1])),e}),{})},stringify:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==t(e)||null===e)return"";n=S({encode:!0},n);var o=function(e){return n.encode?encodeURIComponent(e):String(e)};return Object.keys(e).reduce((function(t,i){var r=e[i];return void 0===r?t:null===r?(n.skipNull||t.push([o(i),""].join("=")),t):Array.isArray(r)?(r.map((function(e){t.push("".concat(o(i),"[]=").concat(o(e)))})).join(),t):(t.push([o(i),o(r)].join("=")),t)}),[]).join("&")}};function w(e){return T.stringify(e)}function D(e){return Object.keys(e).filter((function(e){return h.includes(e)}))}function b(e){var n;return Boolean(null===(n=D(e))||void 0===n?void 0:n.length)}function P(e){var n=function(e){return D(e).reduce((function(n,t){return n[t]=e[t],n}),{})}(e);return btoa(JSON.stringify(n))}function C(e,n){var t,o=document.createElement("iframe");for(var i in e&&(o.src=e),o.style.cssText=null!==(t=null==n?void 0:n.cssText)&&void 0!==t?t:"",o.width="100%",o.height="100%",o.style.border="none",null==n?void 0:n.properties){var r;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(r=n.properties[i])&&void 0!==r?r:""}return o}function N(e){return e=e||Object.create(null),{on:function(n,t){(e[n]||(e[n]=[])).push(t)},off:function(n,t){e[n]&&e[n].splice(e[n].indexOf(t)>>>0,1)},emit:function(n,t){(e[n]||[]).slice().map((function(e){e(t)})),(e["*"]||[]).slice().map((function(e){e(n,t)}))}}}var I={appId:0,superAppToken:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},M={},k={events:N(),init:function(e){if(!e.appId)throw new Error("appId required");I.appId=e.appId,I.superAppToken=e.superAppToken||"",I.loginDomain=e.loginDomain||"login.vk.com",I.oauthDomain=e.oauthDomain||"oauth.vk.com",I.connectDomain=e.connectDomain||"connect.vk.com",I.appSettings=e.appSettings,I._debug=!!e._debug},get:function(){return I},setSuperAppToken:function(e){I.superAppToken=e,k.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){M.superAppToken=e},_requestSuperAppToken:function(){var e;M.superAppToken&&(e=M.superAppToken()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){M.auth=e},_requestAuth:function(){var e;M.auth&&(e=M.auth()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){M.openApp=e},_openApp:function(e){M.openApp&&M.openApp(e.app)}},K=["extend_token","login_with_user","__sferum_invite_link"];function L(e){return e&&K.includes(e.name)?btoa(JSON.stringify(e)):""}var R;function x(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=k.get(),o=t.appId,i=t.connectDomain,r=t.appSettings,a=p({app_id:o,response_type:"silent_token",v:"0.0.2"},e);r&&b(r)&&(a.app_settings=P(r));var s=w(a);return"https://".concat(i,"/").concat(n,"?").concat(s)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(R||(R={}));var H=[R.Default,R.NamePhone,R.PhoneName];function V(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}function U(e,n){return e&&"object"===i(e)?Object.keys(e).reduce((function(t,o){return n.includes(o)?(t[o]=e[o],t):t}),{}):e}var G,W,j,F,q,Y,z=function e(n){var t=this;r(this,e),s(this,"handler",(function(){return{}})),s(this,"config",void 0),s(this,"destroy",(function(){delete t.config,window.removeEventListener("message",t.handleMessage)})),s(this,"onMessage",(function(e){t.handler=e})),s(this,"sendMessage",(function(e){t.config.iframe.contentWindow.postMessage(p({type:"vk-sak-sdk"},e),t.config.origin)})),s(this,"handleMessage",(function(e){t.config.origin&&e.origin===t.config.origin&&e.source===t.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&t.handler(e.data)})),this.config=n,window.addEventListener("message",this.handleMessage)};!function(e){e.SHOW_DATA_POLICY="VKSDKOneTapAuthConnectDataPolicy",e.HIDE_DATA_POLICY="VKSDKOneTapAuthDataPolicyClose",e.DATA_POLICY_RESULT="VKSDKOneTapAuthDataPolicyResult",e.SHOW_CAPTCHA="VKSDKOneTapAuthDataPolicyShowCaptcha"}(G||(G={})),function(e){e.SHOW_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsShow",e.HIDE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsHide",e.ACCEPT_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsAccept",e.DECLINE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsDecline",e.POLICY_AGREEMENTS_ERROR="VKSDKOneTapAuthPolicyAgreementsError",e.SHOW_DATA_POLICY="VKSDKOneTapAuthPolicyAgreementsShowDataPolicy"}(W||(W={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(j||(j={})),function(e){e.PHONE_VALIDATION_NEEDED="VKSDKOneTapAuthPhoneValidationNeeded",e.FULL_AUTH_NEEDED="VKSDKOneTapAuthFullAuthNeeded",e.AUTH_DATA_LOADED="VKSDKOneTapAuthDataLoaded",e.NOT_AUTHORIZED="VKSDKOneTapAuthNotAuthorized",e.LOGIN_SUCCESS="VKSDKOneTapAuthLoginSuccess",e.RESIZE_FRAME="VKSDKOneTapResizeFrame",e.SHOW_CAPTCHA="VKSDKOneTapShowCaptcha",e.VALIDATE_CAPTCHA="VKSDKOneTapValidateCaptcha"}(F||(F={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(q||(q={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions",e.SHOW_AGREEMENTS_DIALOG="VKSDKButtonOneTapAuthShowAgreementsDialog",e.START_AUTHORIZE="VKSDKButtonOneTapAuthStartAuthorize"}(Y||(Y={}));var Z,B,J,X=new function e(){var n=this;r(this,e),s(this,"flags",null),s(this,"silentAuth",(function(){var e=k.get(),n=e.loginDomain,t=e.appId,o=d(),i="https://".concat(n,"/?act=connect&app_id=").concat(t,"&response_type=").concat("silent_token","&uuid=").concat(o,"&v=").concat("0.0.2"),r=new XMLHttpRequest;return r.open("GET",i,!0),r.responseType="json",r.withCredentials=!0,new Promise((function(e,n){r.onload=function(){r.response?e({provider:"vk",payload:r.response}):n()},r.onerror=function(){n()},r.send()}))})),s(this,"oneTapAuth",(function(e,t){if(console.warn("Connect.oneTapAuth method is deprecated. Use Connect.floatingOneTapAuth and Connect.buttonOneTapAuth methods."),!["floating","button"].includes(e))return null;switch(e){case"button":return n.buttonOneTapAuth(t);case"floating":return n.floatingOneTapAuth(t);default:return null}})),s(this,"floatingOneTapAuth",(function(e){var t,o,i=function(){var e,n=window.innerWidth,t=n<=768;return{destroy:function(){return window.removeEventListener("resize",e)},isAdaptive:function(){return t},observe:function(o){e=function(){var e=window.innerWidth;n>768&&e<=768?o(t=!0):n<=768&&e>768&&o(t=!1),n=e},window.addEventListener("resize",e)}}}(),r=(t=i.isAdaptive(),o=t?"314px":"334px",{pageUrl:"floating_one_tap_auth",pageUrlParams:{adaptive:t?1:0},frameStyles:t?"\n display: none;\n position: fixed;\n bottom: 0;\n right: 50%;\n transform: translate(50%, 0);\n max-width: 468px;\n width: 100%;\n height: ".concat(o,";\n "):"\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n max-width: 400px;\n width: 100%;\n height: ".concat(o,";\n ")});if(!r)throw new Error("options were not set");var a=d(),s=C(x(p({origin:location.protocol+"//"+location.host,uuid:a},r.pageUrlParams),r.pageUrl),{cssText:r.frameStyles}),c=new z({iframe:s,origin:"https://"+k.get().connectDomain});i.observe((function(e){c.sendMessage({handler:q.ADAPTIVITY_CHANGE,params:{uuid:a,is_adaptive:e}}),e?(s.style.maxWidth="468px",s.style.top="auto",s.style.bottom="0",s.style.right="50%",s.style.transform="translate(50%, 0)"):(s.style.maxWidth="400px",s.style.top="0",s.style.bottom="auto",s.style.right="0",s.style.transform="none"),s.style.display="none"})),document.body.appendChild(s);var u=function(){c.sendMessage({handler:F.RESIZE_FRAME,params:{uuid:a}})};window.addEventListener("resize",u);var l=function(){s&&(s.remove(),s=null),window.removeEventListener("resize",u),i&&i.destroy(),c.destroy()},h=new Promise((function(t){c.onMessage((function(o){if(o.params.uuid===a)switch(o.handler){case F.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:a,error:"not_authorized"}}),l(),t(o.handler);break;case F.RESIZE_FRAME:s.style.height="".concat(o.params.height,"px");break;case q.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:a}}),l();break;case q.ADAPTIVITY_CHANGED:s.style.display="block";break;case F.AUTH_DATA_LOADED:s.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,c,e)}}))}));return{getFrame:function(){return s},destroy:l,authReadyPromise:h}})),s(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){n.display=e.displayMode&&H.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=V(e.showAgreements,0),n.show_alternative_login=V(e.showAlternativeLogin,0),n.show_agreements_dialog=V(e.showAgreementsDialog,1);t+=n.show_alternative_login?56:0,t+=n.show_agreements?80:0}return{pageUrl:"button_one_tap_auth",pageUrlParams:n,frameStyles:"\n height: ".concat(t,"px;\n ")}}(e.options);if(!t)throw new Error("options were not set");var o=d(),i=C(x(p({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),r=e.container;r&&r.appendChild(i);var a=new z({iframe:i,origin:"https://"+k.get().connectDomain}),s=function(){a.sendMessage({handler:F.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",s);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",s),a.destroy()},authReadyPromise:new Promise((function(t){a.onMessage((function(r){if(r.params.uuid===o)switch(r.handler){case F.RESIZE_FRAME:i.style.height="".concat(r.params.height,"px");break;case F.NOT_AUTHORIZED:t(r.handler);break;case Y.SHOW_LOGIN:case Y.SHOW_LOGIN_OPTIONS:e.callback({type:r.handler,payload:{uuid:o}});break;case Y.SHOW_AGREEMENTS_DIALOG:n.userPolicyAgreements(o).show().then((function(e){e&&e.accepted&&a.sendMessage({handler:Y.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){a.sendMessage({handler:W.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case F.AUTH_DATA_LOADED:t(r.handler);default:n.handleOneTapEvents(r,a,e)}}))}))}})),s(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case F.AUTH_DATA_LOADED:t.sendMessage({handler:F.RESIZE_FRAME,params:{uuid:i}});break;case F.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:e.params});break;case F.SHOW_CAPTCHA:var r=n.captcha(i,{captcha_sid:e.params.captcha_sid,captcha_img:e.params.captcha_img});r.show().then((function(e){t.sendMessage({handler:j.CAPTCHA_SUCCESS,params:p({uuid:i},e)})})).catch((function(){t.sendMessage({handler:j.CAPTCHA_FAIL,params:{uuid:i}}),r.destroy()}));break;case G.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:G.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:G.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case F.FULL_AUTH_NEEDED:case F.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),s(this,"userDataPolicy",(function(e){var t=x({origin:location.protocol+"//"+location.host,uuid:e},"user_data_policy"),o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),r=C(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(r);var a=new z({iframe:r,origin:"https://"+k.get().connectDomain}),s=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){a.onMessage((function(i){switch(i.handler){case G.HIDE_DATA_POLICY:s(),t();break;case G.SHOW_CAPTCHA:var c=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});c.show().then((function(n){a.sendMessage({handler:j.CAPTCHA_SUCCESS,params:p({uuid:e},n)}),r.style.display="block"})).catch((function(){a.sendMessage({handler:j.CAPTCHA_FAIL,params:{uuid:e}}),c.destroy()})),s();break;default:s(),o()}}))}))},hide:s,destroy:function(){document.body.removeChild(r),a.destroy()}}})),s(this,"userPolicyAgreements",(function(e){var t,o,i,r=x({origin:location.protocol+"//"+location.host,uuid:e},"user_policy_agreements"),a=(t=r,o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),C(t,{properties:{height:"".concat(o,"px")},cssText:i}));document.body.appendChild(a);var s=new z({iframe:a,origin:"https://"+k.get().connectDomain}),c=function(){a.style.display="none"};return{show:function(){return a.style.display="block",new Promise((function(t,o){s.onMessage((function(i){switch(i.handler){case W.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case W.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case W.SHOW_DATA_POLICY:c();var r=function(){a.style.display="block"};n.userDataPolicy(e).show().then(r).catch(r);break;case W.POLICY_AGREEMENTS_ERROR:case W.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(a),s.destroy()}}})),s(this,"captcha",(function(e,n){var t=x(p({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=C(t,{cssText:"\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n ")});document.body.appendChild(i);var r=new z({iframe:i,origin:"https://"+k.get().connectDomain}),a=function(){document.body.removeChild(i),r.destroy()};return{show:function(){return i.style.display="block",new Promise((function(e,n){r.onMessage((function(t){switch(t.handler){case j.CAPTCHA_SUCCESS:e(t.params),a();break;default:n(),a()}}))}))},destroy:a}})),s(this,"userVisibleAuth",(function(e){var t=d(),o=p({origin:location.protocol+"//"+location.host,uuid:t},U(e,["screen","source"])),i=L(null==e?void 0:e.action);i&&(o.action=i);var r=x(o);n.flags&&(r="".concat(r,"#").concat(w(n.flags)));var a=screen.height/2-280,s=screen.width/2-410,c=window.open(r,"_blank","top=".concat(a,",left=").concat(s,",width=").concat(820,",height=").concat(560,",location"));if(!c){var l={code:u.CONNECT_WINDOW_NOT_OPENED,reason:A()};return Promise.reject(l)}return new Promise((function(e,n){var o=setInterval((function(){if(!c||c.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:u.CONNECT_WINDOW_CLOSED,reason:f()};n(e)}}),1e3);function i(r){if(r.source===c&&c)if(window.removeEventListener("message",i),clearInterval(o),".vk.com"===r.origin.slice(r.origin.length-".vk.com".length))if(r.data.action==="vk_connect_response"+t){var a=r.data.payload;c.close(),e({provider:"vk",payload:a})}else if(r.data.action==="oauth_callback"+t)e({provider:r.data.payload.name}),c.close();else if(r.data.action==="skip_callback"+t){var s=r.data.payload.redirectURL;s&&(window.location.href=s),c.close()}else{c.close();var p={code:u.CONNECT_UNKNOWN_SDK_MESSAGE,reason:y(JSON.stringify(r.data))};n(p)}else{c.close();var l={code:u.CONNECT_DOMAIN_NOT_ALLOWED,reason:m(r.origin)};n(l)}}window.addEventListener("message",i)}))})),s(this,"redirectAuth",(function(e){var n=d(),t=p({redirect_uri:e.url,uuid:n},U(e,["screen","source"])),o=L(null==e?void 0:e.action);o&&(t.action=o),(null==e?void 0:e.state)&&(t.redirect_state=e.state);var i=x(t);location.assign(i)}))};!function(e){e.APP_CLOSE="VKWebAppClose",e.APP_READY="VKSDKMiniAppReady",e.RESIZE="VKSDKMiniAppResize",e.APP_INIT_CONFIG="VKSDKMiniAppInitConfig",e.OPEN_APP="VKWebAppOpenApp",e.OPEN_PAY_FORM="VKWebAppOpenPayForm",e.ACTION_DONE="VKWebAppActionDone"}(Z||(Z={})),(B=exports.MiniAppEvents||(exports.MiniAppEvents={})).OPEN="open",B.HIDE="hide",B.CLOSE="close",B.SHOW="show",B.MESSAGE="message",B.CREATE_APP="createapp",function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp"}(J||(J={}));var Q;!function(e){e.STATIC_MAP="VKSDKRequestToGeoservice:staticmap/png/",e.SEARCH="VKSDKRequestToGeoservice:search",e.OVERALL="VKSDKRequestToGeoservice:overall",e.DIRECTIONS="VKSDKRequestToGeoservice:directions",e.ISO="VKSDKRequestToGeoservice:iso"}(Q||(Q={}));var $=function(){function e(n){var t=this,o=n.apiKey;r(this,e),s(this,"iframe",void 0),s(this,"bridge",void 0),s(this,"requestMap",void 0),s(this,"apiKey",void 0),this.apiKey=o;var i=document.createElement("iframe"),a=k.get().appId;i.src=this.getGeoserviceProxyUrl({app_id:a}),i.style.cssText="\n display: none;\n ",this.iframe=i,document.body.appendChild(this.iframe),this.bridge=new z({iframe:this.iframe,origin:"https://"+k.get().connectDomain}),this.requestMap={},this.bridge.onMessage((function(e){var n=e.params,o=n.requestID,i=n.response;t.requestMap[o].resolve(i),delete t.requestMap[o]}))}var n,t,o;return n=e,(t=[{key:"setApiKey",value:function(e){this.apiKey=e}},{key:"getGeoserviceProxyUrl",value:function(e){var n=k.get(),t=n.connectDomain,o=n._debug,i=p({},e||{},{origin:location.protocol+"//"+location.host,localhost:String(location.host.includes("localhost")),debug:location.host.includes("localhost")?1:String(o)});return"https://".concat(t,"/geoservice?").concat(w(i))}},{key:"prepareAnswer",value:function(e,n,t){var o=this,i=d();return this.bridge.sendMessage({handler:"VKSDKRequestToGeoservice:".concat(e),params:p({},n,{api_key:this.apiKey,wrapRequestInJSON:t,requestID:i})}),new Promise((function(e,n){o.requestMap[i]={resolve:e,reject:n}}))}},{key:"getStaticMap",value:function(e){return this.prepareAnswer("staticmap/png/",e)}},{key:"encodeCoords",value:function(e){return this.prepareAnswer("search",e)}},{key:"decodeCoords",value:function(e){return this.prepareAnswer("overall",e)}},{key:"getDirections",value:function(e){return this.prepareAnswer("directions",e,!0)}},{key:"getISO",value:function(e){return this.prepareAnswer("iso",e,!0)}}])&&a(n.prototype,t),o&&a(n,o),e}(),ee={OneTapAuthEventsSDK:F,FloatingOneTapAuthEventsSDK:q,ButtonOneTapAuthEventsSDK:Y,DataPolicyEventsSDK:G,AuthCaptchaEventsSDK:j};exports.Config=k,exports.Connect=X,exports.ConnectEvents=ee,exports.GeoService=$,exports.MiniApp=function e(n){var t=this;r(this,e),s(this,"events",void 0),s(this,"iframe",void 0),s(this,"bridge",void 0),s(this,"loading",void 0),s(this,"readyPromiseResolve",null),s(this,"readyPromise",null),s(this,"bodyOverflowValue",""),s(this,"params",void 0),s(this,"child",null),s(this,"open",(function(e,n){return t.loading?(t.iframe.src=t.getMiniAppUrl(e,n),t.loading=new Promise((function(e){t.iframe.onload=function(){t.iframe.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e}))):t.preload(e,n).catch(console.error),t.iframe.style.display="block",t.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",t.loading.then(t.handleResize).catch(console.error),t.events.emit(exports.MiniAppEvents.OPEN),t.readyPromise})),s(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.HIDE)})),s(this,"close",(function(){window.document.body.style.overflowX="",k.events.off("superAppToken",t.onSuperAppToken),t.iframe&&t.iframe.remove(),t.bridge&&t.bridge.destroy(),delete t.iframe,delete t.bridge,window.removeEventListener("resize",t.handleResize),t.events.emit(exports.MiniAppEvents.CLOSE)})),s(this,"show",(function(){if(!t.loading)throw new Error('App is not loaded, use "open" or "preload" methods');t.iframe.style.display="block",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.SHOW)})),s(this,"preload",(function(e,n){var o=document.createElement("iframe"),i=window.innerHeight,r=isFinite(t.params.zIndex)?t.params.zIndex:999999;return o.src=t.getMiniAppUrl(e,n),o.setAttribute("allow","geolocation"),o.style.cssText="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(i,"px;\n min-height: ").concat(i,"px;\n border: none;\n z-index: ").concat(r,";\n "),t.iframe=o,document.body.appendChild(t.iframe),k.events.on("superAppToken",t.onSuperAppToken),t.bridge=new z({iframe:t.iframe,origin:"https://"+k.get().connectDomain}),t.bridge.onMessage(t.handleMessage),window.addEventListener("resize",t.handleResize),t.loading=new Promise((function(e){o.onload=function(){o.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e})),t.loading})),s(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),s(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:J.SUPERAPP_TOKEN,params:{result:e}})})),s(this,"handleMessage",(function(e){switch(e.handler){case Z.APP_CLOSE:t.hide();break;case Z.APP_READY:t.resolveReadyPromise(),t.handleUpdateConfig();break;case Z.OPEN_APP:t.openMiniapp(e.params);break;case Z.OPEN_PAY_FORM:t.openPayForm(e.params);break;case J.SUPERAPP_TOKEN:k._requestSuperAppToken();break;case J.AUTH_NEEDED:k._requestAuth();break;default:t.events.emit(exports.MiniAppEvents.MESSAGE,e)}})),s(this,"handleResize",(function(){if(t.iframe){var e=innerWidth,n=innerHeight;t.iframe.style.height="".concat(n,"px"),t.iframe.style.minHeight="".concat(n,"px"),t.bridge.sendMessage({handler:Z.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),s(this,"handleUpdateConfig",(function(){t.bridge.sendMessage({handler:Z.APP_INIT_CONFIG,params:{fullMode:t.params.fullMode,hideMenu:t.params.hideMenu}})})),s(this,"getMiniAppUrl",(function(e,n){var o=k.get(),i=o.connectDomain,r=o.appId,a=o.superAppToken,s=o._debug,c=w({app:t.params.app,host_app_id:r,debug:s?"1":"",localhost:s?"1":"",superapp_token:a,app_query:e?JSON.stringify(e):"",app_hash:n||""});return"https://".concat(i,"/mini_app?").concat(c)})),s(this,"resolveReadyPromise",(function(){t.readyPromise&&t.readyPromiseResolve&&(t.readyPromiseResolve(),t.readyPromise=null,t.readyPromiseResolve=null)})),s(this,"openMiniapp",(function(n){t.child=new e({app:n.app_id}),t.events.emit(exports.MiniAppEvents.CREATE_APP,{app:t.child,location:n.location})})),s(this,"openPayForm",(function(n){var o=p({},n.params);o.data&&(o.data=JSON.stringify(o.data));var i=p({},o,{app_id:n.app_id,action:n.action}),r=new e({app:6217559});r.open(i).then((function(){return t.hide()})).catch(console.error),r.events.on(exports.MiniAppEvents.MESSAGE,(function(e){t.handleVKPayFormMessage(e),r.close(),t.show()})),r.events.on(exports.MiniAppEvents.HIDE,(function(){r.close(),t.close()}))})),s(this,"handleVKPayFormMessage",(function(e){e.handler===Z.ACTION_DONE&&t.sendMessage(e)})),this.params=p({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=N()}; |
import Connect from './connect'; | ||
import MiniApp from './miniapp'; | ||
import Config from './config'; | ||
import Messenger from './messenger'; | ||
import { MiniAppEvents } from './miniapp/events'; | ||
import GeoService from './geoservice'; | ||
import { MiniAppEvents } from './miniapp/events'; | ||
import { MessengerEvents } from './messenger/events'; | ||
import { OneTapAuthEventsSDK, FloatingOneTapAuthEventsSDK, ButtonOneTapAuthEventsSDK, DataPolicyEventsSDK, AuthCaptchaEventsSDK } from './connect/events'; | ||
@@ -16,2 +14,2 @@ declare const ConnectEvents: { | ||
}; | ||
export { Connect, ConnectEvents, MiniApp, MiniAppEvents, Config, GeoService, Messenger, MessengerEvents, }; | ||
export { Connect, ConnectEvents, MiniApp, MiniAppEvents, Config, GeoService, }; |
@@ -1,1 +0,1 @@ | ||
import e from"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/defineProperty";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function i(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?r(Object(t),!0).forEach((function(n){a(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):r(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var c,p="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",u=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=p[64*Math.random()|0];return n},d=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand","vkc_display_mode","service_groups","external_device_id"];!function(e){e[e.UNKNOWN=1]="UNKNOWN",e[e.MISSING_PARAM=2]="MISSING_PARAM",e[e.CONNECTION_LOST=3]="CONNECTION_LOST",e[e.USER_DENIED=4]="USER_DENIED",e[e.INVALID_PARAMS=5]="INVALID_PARAMS",e[e.CUSTOM=6]="CUSTOM",e[e.CONNECT_WINDOW_CLOSED=7]="CONNECT_WINDOW_CLOSED",e[e.CONNECT_WINDOW_NOT_OPENED=8]="CONNECT_WINDOW_NOT_OPENED",e[e.CONNECT_DOMAIN_NOT_ALLOWED=9]="CONNECT_DOMAIN_NOT_ALLOWED",e[e.CONNECT_UNKNOWN_SDK_MESSAGE=10]="CONNECT_UNKNOWN_SDK_MESSAGE",e[e.OLD_MISSING_PARAM=100]="OLD_MISSING_PARAM"}(c||(c={}));var l=function(){return"Connect window was closed."},h=function(){return"Connect window was not opened."},f=function(e){return'URL domain "'.concat(e,'" is not allowed.')},m=function(e){return"This SDK message is unknown: ".concat(e)},A=!("undefined"==typeof window||!window.document||!window.document.createElement),g=A&&!!window.addEventListener,v=function(){};if(g)try{var _=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",v,_),window.removeEventListener("test",v,_)}catch(e){}!function(){if(!A)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function y(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function E(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?y(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}var O={parse:function(e){if("string"!=typeof e)return{};if(!(e=e.trim().replace(/^[?#&]/,"")))return{};var n=/\?(.+)$/gi.exec(e);return(n?n[1]:e).split("&").reduce((function(e,n){var t=n.split("=");return t[1]&&(e[t[0]]=decodeURIComponent(t[1])),e}),{})},stringify:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==e(n)||null===n)return"";t=E({encode:!0},t);var o=function(e){return t.encode?encodeURIComponent(e):String(e)};return Object.keys(n).reduce((function(e,i){var a=n[i];return void 0===a?e:null===a?(t.skipNull||e.push([o(i),""].join("=")),e):Array.isArray(a)?(a.map((function(n){e.push("".concat(o(i),"[]=").concat(o(n)))})).join(),e):(e.push([o(i),o(a)].join("=")),e)}),[]).join("&")}};function T(e){return O.stringify(e)}function S(e){return Object.keys(e).filter((function(e){return d.includes(e)}))}function w(e){var n;return Boolean(null===(n=S(e))||void 0===n?void 0:n.length)}function P(e){var n=function(e){return S(e).reduce((function(n,t){return n[t]=e[t],n}),{})}(e);return btoa(JSON.stringify(n))}function b(e,n){var t,o=document.createElement("iframe");for(var i in e&&(o.src=e),o.style.cssText=null!==(t=null==n?void 0:n.cssText)&&void 0!==t?t:"",o.width="100%",o.height="100%",o.style.border="none",null==n?void 0:n.properties){var a;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(a=n.properties[i])&&void 0!==a?a:""}return o}function D(e){return e=e||Object.create(null),{on:function(n,t){(e[n]||(e[n]=[])).push(t)},off:function(n,t){e[n]&&e[n].splice(e[n].indexOf(t)>>>0,1)},emit:function(n,t){(e[n]||[]).slice().map((function(e){e(t)})),(e["*"]||[]).slice().map((function(e){e(n,t)}))}}}var C={appId:0,superAppToken:"",superAppTokenV2:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},N={},k={events:D(),init:function(e){if(!e.appId)throw new Error("appId required");C.appId=e.appId,C.superAppToken=e.superAppToken||"",C.superAppTokenV2=e.superAppTokenV2||"",C.loginDomain=e.loginDomain||"login.vk.com",C.oauthDomain=e.oauthDomain||"oauth.vk.com",C.connectDomain=e.connectDomain||"connect.vk.com",C.appSettings=e.appSettings,C._debug=!!e._debug},get:function(){return C},setSuperAppToken:function(e){C.superAppToken=e,k.events.emit("superAppToken",e)},setSuperAppTokenV2:function(e){C.superAppTokenV2=e,k.events.emit("superAppTokenV2",e)},onRequestSuperAppToken:function(e){N.superAppToken=e},onRequestSuperAppTokenV2:function(e){N.superAppTokenV2=e},_requestSuperAppToken:function(){var e;N.superAppToken&&(e=N.superAppToken()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},_requestSuperAppTokenV2:function(){var e;N.superAppTokenV2&&(e=N.superAppTokenV2()),e&&e.then((function(e){return k.setSuperAppTokenV2(e)})).catch(console.error)},onAuth:function(e){N.auth=e},_requestAuth:function(e){var n,t=(e||{}).tokenVersion;N.auth&&(n=N.auth()),n&&n.then((function(e){"2"===t?k.setSuperAppTokenV2(e):k.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){N.openApp=e},_openApp:function(e){N.openApp&&N.openApp(e.app)}},I=["extend_token","login_with_user","__sferum_invite_link"];function K(e){return e&&I.includes(e.name)?btoa(JSON.stringify(e)):""}var M;function R(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=k.get(),o=t.appId,i=t.connectDomain,a=t.appSettings,r=s({app_id:o,response_type:"silent_token",v:"0.0.2"},e);a&&w(a)&&(r.app_settings=P(a));var c=T(r);return"https://".concat(i,"/").concat(n,"?").concat(c)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(M||(M={}));var L=[M.Default,M.NamePhone,M.PhoneName];function V(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}function H(e,n){return e&&"object"===t(e)?Object.keys(e).reduce((function(t,o){return n.includes(o)?(t[o]=e[o],t):t}),{}):e}var U,x,G,W,j,F,z=function e(n){var t=this;o(this,e),a(this,"handler",(function(){return{}})),a(this,"config",void 0),a(this,"destroy",(function(){delete t.config,window.removeEventListener("message",t.handleMessage)})),a(this,"onMessage",(function(e){t.handler=e})),a(this,"sendMessage",(function(e){t.config.iframe.contentWindow.postMessage(s({type:"vk-sak-sdk"},e),t.config.origin)})),a(this,"handleMessage",(function(e){t.config.origin&&e.origin===t.config.origin&&e.source===t.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&t.handler(e.data)})),this.config=n,window.addEventListener("message",this.handleMessage)};!function(e){e.SHOW_DATA_POLICY="VKSDKOneTapAuthConnectDataPolicy",e.HIDE_DATA_POLICY="VKSDKOneTapAuthDataPolicyClose",e.DATA_POLICY_RESULT="VKSDKOneTapAuthDataPolicyResult",e.SHOW_CAPTCHA="VKSDKOneTapAuthDataPolicyShowCaptcha"}(U||(U={})),function(e){e.SHOW_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsShow",e.HIDE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsHide",e.ACCEPT_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsAccept",e.DECLINE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsDecline",e.POLICY_AGREEMENTS_ERROR="VKSDKOneTapAuthPolicyAgreementsError",e.SHOW_DATA_POLICY="VKSDKOneTapAuthPolicyAgreementsShowDataPolicy"}(x||(x={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(G||(G={})),function(e){e.PHONE_VALIDATION_NEEDED="VKSDKOneTapAuthPhoneValidationNeeded",e.FULL_AUTH_NEEDED="VKSDKOneTapAuthFullAuthNeeded",e.AUTH_DATA_LOADED="VKSDKOneTapAuthDataLoaded",e.NOT_AUTHORIZED="VKSDKOneTapAuthNotAuthorized",e.LOGIN_SUCCESS="VKSDKOneTapAuthLoginSuccess",e.RESIZE_FRAME="VKSDKOneTapResizeFrame",e.SHOW_CAPTCHA="VKSDKOneTapShowCaptcha",e.VALIDATE_CAPTCHA="VKSDKOneTapValidateCaptcha"}(W||(W={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(j||(j={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions",e.SHOW_AGREEMENTS_DIALOG="VKSDKButtonOneTapAuthShowAgreementsDialog",e.START_AUTHORIZE="VKSDKButtonOneTapAuthStartAuthorize"}(F||(F={}));var q,Y,Z,B=new function e(){var n=this;o(this,e),a(this,"flags",null),a(this,"silentAuth",(function(){var e=k.get(),n=e.loginDomain,t=e.appId,o=u(),i="https://".concat(n,"/?act=connect&app_id=").concat(t,"&response_type=").concat("silent_token","&uuid=").concat(o,"&v=").concat("0.0.2"),a=new XMLHttpRequest;return a.open("GET",i,!0),a.responseType="json",a.withCredentials=!0,new Promise((function(e,n){a.onload=function(){a.response?e({provider:"vk",payload:a.response}):n()},a.onerror=function(){n()},a.send()}))})),a(this,"oneTapAuth",(function(e,t){if(console.warn("Connect.oneTapAuth method is deprecated. Use Connect.floatingOneTapAuth and Connect.buttonOneTapAuth methods."),!["floating","button"].includes(e))return null;switch(e){case"button":return n.buttonOneTapAuth(t);case"floating":return n.floatingOneTapAuth(t);default:return null}})),a(this,"floatingOneTapAuth",(function(e){var t,o,i=function(){var e,n=window.innerWidth,t=n<=768;return{destroy:function(){return window.removeEventListener("resize",e)},isAdaptive:function(){return t},observe:function(o){e=function(){var e=window.innerWidth;n>768&&e<=768?o(t=!0):n<=768&&e>768&&o(t=!1),n=e},window.addEventListener("resize",e)}}}(),a=(t=i.isAdaptive(),o=t?"314px":"334px",{pageUrl:"floating_one_tap_auth",pageUrlParams:{adaptive:t?1:0},frameStyles:t?"\n display: none;\n position: fixed;\n bottom: 0;\n right: 50%;\n transform: translate(50%, 0);\n max-width: 468px;\n width: 100%;\n height: ".concat(o,";\n "):"\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n max-width: 400px;\n width: 100%;\n height: ".concat(o,";\n ")});if(!a)throw new Error("options were not set");var r=u(),c=b(R(s({origin:location.protocol+"//"+location.host,uuid:r},a.pageUrlParams),a.pageUrl),{cssText:a.frameStyles}),p=new z({iframe:c,origin:"https://"+k.get().connectDomain});i.observe((function(e){p.sendMessage({handler:j.ADAPTIVITY_CHANGE,params:{uuid:r,is_adaptive:e}}),e?(c.style.maxWidth="468px",c.style.top="auto",c.style.bottom="0",c.style.right="50%",c.style.transform="translate(50%, 0)"):(c.style.maxWidth="400px",c.style.top="0",c.style.bottom="auto",c.style.right="0",c.style.transform="none"),c.style.display="none"})),document.body.appendChild(c);var d=function(){p.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:r}})};window.addEventListener("resize",d);var l=function(){c&&(c.remove(),c=null),window.removeEventListener("resize",d),i&&i.destroy(),p.destroy()},h=new Promise((function(t){p.onMessage((function(o){if(o.params.uuid===r)switch(o.handler){case W.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:r,error:"not_authorized"}}),l(),t(o.handler);break;case W.RESIZE_FRAME:c.style.height="".concat(o.params.height,"px");break;case j.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:r}}),l();break;case j.ADAPTIVITY_CHANGED:c.style.display="block";break;case W.AUTH_DATA_LOADED:c.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,p,e)}}))}));return{getFrame:function(){return c},destroy:l,authReadyPromise:h}})),a(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){n.display=e.displayMode&&L.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=V(e.showAgreements,0),n.show_alternative_login=V(e.showAlternativeLogin,0),n.show_agreements_dialog=V(e.showAgreementsDialog,1);t+=n.show_alternative_login?56:0,t+=n.show_agreements?80:0}return{pageUrl:"button_one_tap_auth",pageUrlParams:n,frameStyles:"\n height: ".concat(t,"px;\n ")}}(e.options);if(!t)throw new Error("options were not set");var o=u(),i=b(R(s({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),a=e.container;a&&a.appendChild(i);var r=new z({iframe:i,origin:"https://"+k.get().connectDomain}),c=function(){r.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",c);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",c),r.destroy()},authReadyPromise:new Promise((function(t){r.onMessage((function(a){if(a.params.uuid===o)switch(a.handler){case W.RESIZE_FRAME:i.style.height="".concat(a.params.height,"px");break;case W.NOT_AUTHORIZED:t(a.handler);break;case F.SHOW_LOGIN:case F.SHOW_LOGIN_OPTIONS:e.callback({type:a.handler,payload:{uuid:o}});break;case F.SHOW_AGREEMENTS_DIALOG:n.userPolicyAgreements(o).show().then((function(e){e&&e.accepted&&r.sendMessage({handler:F.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){r.sendMessage({handler:x.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case W.AUTH_DATA_LOADED:t(a.handler);default:n.handleOneTapEvents(a,r,e)}}))}))}})),a(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case W.AUTH_DATA_LOADED:t.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:i}});break;case W.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:s({uuid:i},e.params)});break;case W.SHOW_CAPTCHA:var a=n.captcha(i,{captcha_sid:e.params.captcha_sid,captcha_img:e.params.captcha_img});a.show().then((function(e){t.sendMessage({handler:G.CAPTCHA_SUCCESS,params:s({uuid:i},e)})})).catch((function(){t.sendMessage({handler:G.CAPTCHA_FAIL,params:{uuid:i}}),a.destroy()}));break;case U.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:U.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:U.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case W.FULL_AUTH_NEEDED:case W.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),a(this,"userDataPolicy",(function(e){var t=R({origin:location.protocol+"//"+location.host,uuid:e},"user_data_policy"),o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),a=b(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(a);var r=new z({iframe:a,origin:"https://"+k.get().connectDomain}),c=function(){a.style.display="none"};return{show:function(){return a.style.display="block",new Promise((function(t,o){r.onMessage((function(i){switch(i.handler){case U.HIDE_DATA_POLICY:c(),t();break;case U.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){r.sendMessage({handler:G.CAPTCHA_SUCCESS,params:s({uuid:e},n)}),a.style.display="block"})).catch((function(){r.sendMessage({handler:G.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(a),r.destroy()}}})),a(this,"userPolicyAgreements",(function(e){var t,o,i,a=R({origin:location.protocol+"//"+location.host,uuid:e},"user_policy_agreements"),r=(t=a,o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),b(t,{properties:{height:"".concat(o,"px")},cssText:i}));document.body.appendChild(r);var s=new z({iframe:r,origin:"https://"+k.get().connectDomain}),c=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){s.onMessage((function(i){switch(i.handler){case x.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case x.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case x.SHOW_DATA_POLICY:c();var a=function(){r.style.display="block"};n.userDataPolicy(e).show().then(a).catch(a);break;case x.POLICY_AGREEMENTS_ERROR:case x.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),s.destroy()}}})),a(this,"captcha",(function(e,n){var t=R(s({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=b(t,{cssText:"\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n ")});document.body.appendChild(i);var a=new z({iframe:i,origin:"https://"+k.get().connectDomain}),r=function(){document.body.removeChild(i),a.destroy()};return{show:function(){return i.style.display="block",new Promise((function(e,n){a.onMessage((function(t){switch(t.handler){case G.CAPTCHA_SUCCESS:e(t.params),r();break;default:n(),r()}}))}))},destroy:r}})),a(this,"userVisibleAuth",(function(e){var t=u(),o=s({origin:location.protocol+"//"+location.host,uuid:t},H(e,["screen","source"])),i=K(null==e?void 0:e.action);i&&(o.action=i);var a=R(o);n.flags&&(a="".concat(a,"#").concat(T(n.flags)));var r=screen.height/2-280,p=screen.width/2-410,d=window.open(a,"_blank","top=".concat(r,",left=").concat(p,",width=").concat(820,",height=").concat(560,",location"));if(!d){var A={code:c.CONNECT_WINDOW_NOT_OPENED,reason:h()};return Promise.reject(A)}return new Promise((function(e,n){var o=setInterval((function(){if(!d||d.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:c.CONNECT_WINDOW_CLOSED,reason:l()};n(e)}}),1e3);function i(a){if(a.source===d&&d)if(window.removeEventListener("message",i),clearInterval(o),".vk.com"===a.origin.slice(a.origin.length-".vk.com".length))if(a.data.action==="vk_connect_response"+t){var r=a.data.payload;d.close(),e({provider:"vk",payload:r})}else if(a.data.action==="oauth_callback"+t)e({provider:a.data.payload.name}),d.close();else{d.close();var s={code:c.CONNECT_UNKNOWN_SDK_MESSAGE,reason:m(JSON.stringify(a.data))};n(s)}else{d.close();var p={code:c.CONNECT_DOMAIN_NOT_ALLOWED,reason:f(a.origin)};n(p)}}window.addEventListener("message",i)}))})),a(this,"redirectAuth",(function(e){var n=u(),t=s({redirect_uri:e.url,uuid:n},H(e,["screen","source"])),o=K(null==e?void 0:e.action);o&&(t.action=o),(null==e?void 0:e.state)&&(t.redirect_state=e.state);var i=R(t);location.assign(i)}))};!function(e){e.APP_CLOSE="VKWebAppClose",e.APP_READY="VKSDKMiniAppReady",e.RESIZE="VKSDKMiniAppResize",e.APP_INIT_CONFIG="VKSDKMiniAppInitConfig",e.OPEN_APP="VKWebAppOpenApp",e.OPEN_PAY_FORM="VKWebAppOpenPayForm",e.ACTION_DONE="VKWebAppActionDone"}(q||(q={})),function(e){e.OPEN="open",e.HIDE="hide",e.CLOSE="close",e.SHOW="show",e.MESSAGE="message",e.CREATE_APP="createapp"}(Y||(Y={})),function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp",e.GET_SUPERAPP_TOKEN="SDKGetSuperAppToken"}(Z||(Z={}));var J,X=function e(n){var t=this;o(this,e),a(this,"events",void 0),a(this,"iframe",void 0),a(this,"bridge",void 0),a(this,"loading",void 0),a(this,"readyPromiseResolve",null),a(this,"readyPromise",null),a(this,"bodyOverflowValue",""),a(this,"params",void 0),a(this,"child",null),a(this,"open",(function(e,n){return t.loading?(t.iframe.src=t.getMiniAppUrl(e,n),t.loading=new Promise((function(e){t.iframe.onload=function(){t.iframe.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e}))):t.preload(e,n).catch(console.error),t.iframe.style.display="block",t.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",t.loading.then(t.handleResize).catch(console.error),t.events.emit(Y.OPEN),t.readyPromise})),a(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(Y.HIDE)})),a(this,"close",(function(){window.document.body.style.overflowX="",k.events.off("superAppToken",t.onSuperAppToken),t.iframe&&t.iframe.remove(),t.bridge&&t.bridge.destroy(),delete t.iframe,delete t.bridge,window.removeEventListener("resize",t.handleResize),t.events.emit(Y.CLOSE)})),a(this,"show",(function(){if(!t.loading)throw new Error('App is not loaded, use "open" or "preload" methods');t.iframe.style.display="block",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(Y.SHOW)})),a(this,"preload",(function(e,n){var o=document.createElement("iframe"),i=window.innerHeight,a=isFinite(t.params.zIndex)?t.params.zIndex:999999;return o.src=t.getMiniAppUrl(e,n),o.setAttribute("allow","geolocation"),o.style.cssText="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(i,"px;\n min-height: ").concat(i,"px;\n border: none;\n z-index: ").concat(a,";\n "),t.iframe=o,document.body.appendChild(t.iframe),k.events.on("superAppToken",t.onSuperAppToken),t.bridge=new z({iframe:t.iframe,origin:"https://"+k.get().connectDomain}),t.bridge.onMessage(t.handleMessage),window.addEventListener("resize",t.handleResize),t.loading=new Promise((function(e){o.onload=function(){o.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e})),t.loading})),a(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),a(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:Z.SUPERAPP_TOKEN,params:{result:e}})})),a(this,"handleMessage",(function(e){switch(e.handler){case q.APP_CLOSE:t.hide();break;case q.APP_READY:t.resolveReadyPromise(),t.handleUpdateConfig();break;case q.OPEN_APP:t.openMiniapp(e.params);break;case q.OPEN_PAY_FORM:t.openPayForm(e.params);break;case Z.SUPERAPP_TOKEN:k._requestSuperAppToken();break;case Z.AUTH_NEEDED:k._requestAuth();break;default:t.events.emit(Y.MESSAGE,e)}})),a(this,"handleResize",(function(){if(t.iframe){var e=innerWidth,n=innerHeight;t.iframe.style.height="".concat(n,"px"),t.iframe.style.minHeight="".concat(n,"px"),t.bridge.sendMessage({handler:q.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),a(this,"handleUpdateConfig",(function(){t.bridge.sendMessage({handler:q.APP_INIT_CONFIG,params:{fullMode:t.params.fullMode,hideMenu:t.params.hideMenu}})})),a(this,"getMiniAppUrl",(function(e,n){var o=k.get(),i=o.connectDomain,a=o.appId,r=o.superAppToken,s=o._debug,c=T({app:t.params.app,host_app_id:a,debug:s?"1":"",localhost:s?"1":"",superapp_token:r,app_query:e?JSON.stringify(e):"",app_hash:n||""});return"https://".concat(i,"/mini_app?").concat(c)})),a(this,"resolveReadyPromise",(function(){t.readyPromise&&t.readyPromiseResolve&&(t.readyPromiseResolve(),t.readyPromise=null,t.readyPromiseResolve=null)})),a(this,"openMiniapp",(function(n){t.child=new e({app:n.app_id}),t.events.emit(Y.CREATE_APP,{app:t.child,location:n.location})})),a(this,"openPayForm",(function(n){var o=s({},n.params);o.data&&(o.data=JSON.stringify(o.data));var i=s({},o,{app_id:n.app_id,action:n.action}),a=new e({app:6217559});a.open(i).then((function(){return t.hide()})).catch(console.error),a.events.on(Y.MESSAGE,(function(e){t.handleVKPayFormMessage(e),a.close(),t.show()})),a.events.on(Y.HIDE,(function(){a.close(),t.close()}))})),a(this,"handleVKPayFormMessage",(function(e){e.handler===q.ACTION_DONE&&t.sendMessage(e)})),this.params=s({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=D()};!function(e){e.UPDATE_PARAMS="VKMessengerUpdateParams",e.CLOSE="VKMessengerClose",e.RESIZE="VKMessengerResize"}(J||(J={}));var Q,$=function e(n){var t=this;o(this,e),a(this,"events",void 0),a(this,"iframe",void 0),a(this,"bridge",void 0),a(this,"loadingPromise",void 0),a(this,"params",void 0),a(this,"open",(function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.loadingPromise;return t.loadingPromise||(o=t.preload(s({},n.query,{peer_id:e})).catch(console.error)),o.then((function(){t.bridge.sendMessage({handler:J.UPDATE_PARAMS,params:s({},n,{peer_id:e})}),t.iframe.style.display="block"}))})),a(this,"close",(function(){t.iframe&&t.iframe.remove(),t.bridge&&t.bridge.destroy(),delete t.iframe,delete t.bridge})),a(this,"preload",(function(e){var n=isFinite(t.params.zIndex)?t.params.zIndex:999999;console.log(t.params);var o="\n display: none;\n border: none;\n z-index: ".concat(n,";\n position: fixed;\n bottom: ").concat(t.params.bottom,";\n right: ").concat(t.params.right,";\n "),i=b(t.getMessengerUrl(e),{cssText:o});return k.events.on("superAppTokenV2",t.handleSuperAppToken),t.iframe=i,t.loadingPromise=new Promise((function(e){t.iframe.onload=function(){t.iframe.onload=null,e()}})),window.document.body.appendChild(t.iframe),t.bridge=new z({iframe:t.iframe,origin:"https://"+k.get().connectDomain}),t.bridge.onMessage(t.handleMessage),t.loadingPromise})),a(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),a(this,"handleMessage",(function(e){switch(console.log(e),e.handler){case Z.GET_SUPERAPP_TOKEN:k._requestSuperAppTokenV2();break;case Z.AUTH_NEEDED:k._requestAuth({tokenVersion:"2"});break;case J.CLOSE:t.close();break;case J.RESIZE:t.handleIframeResize(e);break;default:return}})),a(this,"getMessengerUrl",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=k.get(),t=n.connectDomain,o=n._debug,i=n.superAppTokenV2,a=n.appId;console.log("config",k.get());var r=T(s({},e,{host_app_id:a,debug:o?"1":"",localhost:o?"1":"",superapp_token:i,origin:location.protocol+"//"+location.host}));return"https://".concat(t,"/messenger?").concat(r)})),a(this,"handleSuperAppToken",(function(e){t.bridge.sendMessage({handler:"".concat(Z.GET_SUPERAPP_TOKEN,"Success"),params:{result:e}})})),a(this,"handleIframeResize",(function(e){var n=e.params;console.log(n),t.iframe.width="".concat(n.width,"px"),t.iframe.height="".concat(n.height,"px")})),this.params=s({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=D()};!function(e){e.STATIC_MAP="VKSDKRequestToGeoservice:staticmap/png/",e.SEARCH="VKSDKRequestToGeoservice:search",e.OVERALL="VKSDKRequestToGeoservice:overall",e.DIRECTIONS="VKSDKRequestToGeoservice:directions",e.ISO="VKSDKRequestToGeoservice:iso"}(Q||(Q={}));var ee=function(){function e(n){var t=this,i=n.apiKey;o(this,e),a(this,"iframe",void 0),a(this,"bridge",void 0),a(this,"requestMap",void 0),a(this,"apiKey",void 0),this.apiKey=i;var r=document.createElement("iframe"),s=k.get().appId;r.src=this.getGeoserviceProxyUrl({app_id:s}),r.style.cssText="\n display: none;\n ",this.iframe=r,document.body.appendChild(this.iframe),this.bridge=new z({iframe:this.iframe,origin:"https://"+k.get().connectDomain}),this.requestMap={},this.bridge.onMessage((function(e){var n=e.params,o=n.requestID,i=n.response;t.requestMap[o].resolve(i),delete t.requestMap[o]}))}var n,t,r;return n=e,(t=[{key:"setApiKey",value:function(e){this.apiKey=e}},{key:"getGeoserviceProxyUrl",value:function(e){var n=k.get(),t=n.connectDomain,o=n._debug,i=s({},e||{},{origin:location.protocol+"//"+location.host,localhost:String(location.host.includes("localhost")),debug:location.host.includes("localhost")?1:String(o)});return"https://".concat(t,"/geoservice?").concat(T(i))}},{key:"prepareAnswer",value:function(e,n,t){var o=this,i=u();return this.bridge.sendMessage({handler:"VKSDKRequestToGeoservice:".concat(e),params:s({},n,{api_key:this.apiKey,wrapRequestInJSON:t,requestID:i})}),new Promise((function(e,n){o.requestMap[i]={resolve:e,reject:n}}))}},{key:"getStaticMap",value:function(e){return this.prepareAnswer("staticmap/png/",e)}},{key:"encodeCoords",value:function(e){return this.prepareAnswer("search",e)}},{key:"decodeCoords",value:function(e){return this.prepareAnswer("overall",e)}},{key:"getDirections",value:function(e){return this.prepareAnswer("directions",e,!0)}},{key:"getISO",value:function(e){return this.prepareAnswer("iso",e,!0)}}])&&i(n.prototype,t),r&&i(n,r),e}(),ne={OneTapAuthEventsSDK:W,FloatingOneTapAuthEventsSDK:j,ButtonOneTapAuthEventsSDK:F,DataPolicyEventsSDK:U,AuthCaptchaEventsSDK:G};export{k as Config,B as Connect,ne as ConnectEvents,ee as GeoService,$ as Messenger,J as MessengerEvents,X as MiniApp,Y as MiniAppEvents}; | ||
import e from"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/defineProperty";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function i(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?r(Object(t),!0).forEach((function(n){a(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):r(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var c,p="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",u=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=p[64*Math.random()|0];return n},d=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand","vkc_display_mode","service_groups","external_device_id"];!function(e){e[e.UNKNOWN=1]="UNKNOWN",e[e.MISSING_PARAM=2]="MISSING_PARAM",e[e.CONNECTION_LOST=3]="CONNECTION_LOST",e[e.USER_DENIED=4]="USER_DENIED",e[e.INVALID_PARAMS=5]="INVALID_PARAMS",e[e.CUSTOM=6]="CUSTOM",e[e.CONNECT_WINDOW_CLOSED=7]="CONNECT_WINDOW_CLOSED",e[e.CONNECT_WINDOW_NOT_OPENED=8]="CONNECT_WINDOW_NOT_OPENED",e[e.CONNECT_DOMAIN_NOT_ALLOWED=9]="CONNECT_DOMAIN_NOT_ALLOWED",e[e.CONNECT_UNKNOWN_SDK_MESSAGE=10]="CONNECT_UNKNOWN_SDK_MESSAGE",e[e.OLD_MISSING_PARAM=100]="OLD_MISSING_PARAM"}(c||(c={}));var l=function(){return"Connect window was closed."},h=function(){return"Connect window was not opened."},f=function(e){return'URL domain "'.concat(e,'" is not allowed.')},m=function(e){return"This SDK message is unknown: ".concat(e)},A=!("undefined"==typeof window||!window.document||!window.document.createElement),g=A&&!!window.addEventListener,y=function(){};if(g)try{var _=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",y,_),window.removeEventListener("test",y,_)}catch(e){}!function(){if(!A)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function v(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function O(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?v(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}var E={parse:function(e){if("string"!=typeof e)return{};if(!(e=e.trim().replace(/^[?#&]/,"")))return{};var n=/\?(.+)$/gi.exec(e);return(n?n[1]:e).split("&").reduce((function(e,n){var t=n.split("=");return t[1]&&(e[t[0]]=decodeURIComponent(t[1])),e}),{})},stringify:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==e(n)||null===n)return"";t=O({encode:!0},t);var o=function(e){return t.encode?encodeURIComponent(e):String(e)};return Object.keys(n).reduce((function(e,i){var a=n[i];return void 0===a?e:null===a?(t.skipNull||e.push([o(i),""].join("=")),e):Array.isArray(a)?(a.map((function(n){e.push("".concat(o(i),"[]=").concat(o(n)))})).join(),e):(e.push([o(i),o(a)].join("=")),e)}),[]).join("&")}};function S(e){return E.stringify(e)}function T(e){return Object.keys(e).filter((function(e){return d.includes(e)}))}function w(e){var n;return Boolean(null===(n=T(e))||void 0===n?void 0:n.length)}function D(e){var n=function(e){return T(e).reduce((function(n,t){return n[t]=e[t],n}),{})}(e);return btoa(JSON.stringify(n))}function P(e,n){var t,o=document.createElement("iframe");for(var i in e&&(o.src=e),o.style.cssText=null!==(t=null==n?void 0:n.cssText)&&void 0!==t?t:"",o.width="100%",o.height="100%",o.style.border="none",null==n?void 0:n.properties){var a;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(a=n.properties[i])&&void 0!==a?a:""}return o}function b(e){return e=e||Object.create(null),{on:function(n,t){(e[n]||(e[n]=[])).push(t)},off:function(n,t){e[n]&&e[n].splice(e[n].indexOf(t)>>>0,1)},emit:function(n,t){(e[n]||[]).slice().map((function(e){e(t)})),(e["*"]||[]).slice().map((function(e){e(n,t)}))}}}var C={appId:0,superAppToken:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},N={},I={events:b(),init:function(e){if(!e.appId)throw new Error("appId required");C.appId=e.appId,C.superAppToken=e.superAppToken||"",C.loginDomain=e.loginDomain||"login.vk.com",C.oauthDomain=e.oauthDomain||"oauth.vk.com",C.connectDomain=e.connectDomain||"connect.vk.com",C.appSettings=e.appSettings,C._debug=!!e._debug},get:function(){return C},setSuperAppToken:function(e){C.superAppToken=e,I.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){N.superAppToken=e},_requestSuperAppToken:function(){var e;N.superAppToken&&(e=N.superAppToken()),e&&e.then((function(e){return I.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){N.auth=e},_requestAuth:function(){var e;N.auth&&(e=N.auth()),e&&e.then((function(e){return I.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){N.openApp=e},_openApp:function(e){N.openApp&&N.openApp(e.app)}},k=["extend_token","login_with_user","__sferum_invite_link"];function K(e){return e&&k.includes(e.name)?btoa(JSON.stringify(e)):""}var M;function L(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=I.get(),o=t.appId,i=t.connectDomain,a=t.appSettings,r=s({app_id:o,response_type:"silent_token",v:"0.0.2"},e);a&&w(a)&&(r.app_settings=D(a));var c=S(r);return"https://".concat(i,"/").concat(n,"?").concat(c)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(M||(M={}));var R=[M.Default,M.NamePhone,M.PhoneName];function H(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}function V(e,n){return e&&"object"===t(e)?Object.keys(e).reduce((function(t,o){return n.includes(o)?(t[o]=e[o],t):t}),{}):e}var U,x,G,W,j,F,Y=function e(n){var t=this;o(this,e),a(this,"handler",(function(){return{}})),a(this,"config",void 0),a(this,"destroy",(function(){delete t.config,window.removeEventListener("message",t.handleMessage)})),a(this,"onMessage",(function(e){t.handler=e})),a(this,"sendMessage",(function(e){t.config.iframe.contentWindow.postMessage(s({type:"vk-sak-sdk"},e),t.config.origin)})),a(this,"handleMessage",(function(e){t.config.origin&&e.origin===t.config.origin&&e.source===t.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&t.handler(e.data)})),this.config=n,window.addEventListener("message",this.handleMessage)};!function(e){e.SHOW_DATA_POLICY="VKSDKOneTapAuthConnectDataPolicy",e.HIDE_DATA_POLICY="VKSDKOneTapAuthDataPolicyClose",e.DATA_POLICY_RESULT="VKSDKOneTapAuthDataPolicyResult",e.SHOW_CAPTCHA="VKSDKOneTapAuthDataPolicyShowCaptcha"}(U||(U={})),function(e){e.SHOW_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsShow",e.HIDE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsHide",e.ACCEPT_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsAccept",e.DECLINE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsDecline",e.POLICY_AGREEMENTS_ERROR="VKSDKOneTapAuthPolicyAgreementsError",e.SHOW_DATA_POLICY="VKSDKOneTapAuthPolicyAgreementsShowDataPolicy"}(x||(x={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(G||(G={})),function(e){e.PHONE_VALIDATION_NEEDED="VKSDKOneTapAuthPhoneValidationNeeded",e.FULL_AUTH_NEEDED="VKSDKOneTapAuthFullAuthNeeded",e.AUTH_DATA_LOADED="VKSDKOneTapAuthDataLoaded",e.NOT_AUTHORIZED="VKSDKOneTapAuthNotAuthorized",e.LOGIN_SUCCESS="VKSDKOneTapAuthLoginSuccess",e.RESIZE_FRAME="VKSDKOneTapResizeFrame",e.SHOW_CAPTCHA="VKSDKOneTapShowCaptcha",e.VALIDATE_CAPTCHA="VKSDKOneTapValidateCaptcha"}(W||(W={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(j||(j={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions",e.SHOW_AGREEMENTS_DIALOG="VKSDKButtonOneTapAuthShowAgreementsDialog",e.START_AUTHORIZE="VKSDKButtonOneTapAuthStartAuthorize"}(F||(F={}));var z,q,Z,B=new function e(){var n=this;o(this,e),a(this,"flags",null),a(this,"silentAuth",(function(){var e=I.get(),n=e.loginDomain,t=e.appId,o=u(),i="https://".concat(n,"/?act=connect&app_id=").concat(t,"&response_type=").concat("silent_token","&uuid=").concat(o,"&v=").concat("0.0.2"),a=new XMLHttpRequest;return a.open("GET",i,!0),a.responseType="json",a.withCredentials=!0,new Promise((function(e,n){a.onload=function(){a.response?e({provider:"vk",payload:a.response}):n()},a.onerror=function(){n()},a.send()}))})),a(this,"oneTapAuth",(function(e,t){if(console.warn("Connect.oneTapAuth method is deprecated. Use Connect.floatingOneTapAuth and Connect.buttonOneTapAuth methods."),!["floating","button"].includes(e))return null;switch(e){case"button":return n.buttonOneTapAuth(t);case"floating":return n.floatingOneTapAuth(t);default:return null}})),a(this,"floatingOneTapAuth",(function(e){var t,o,i=function(){var e,n=window.innerWidth,t=n<=768;return{destroy:function(){return window.removeEventListener("resize",e)},isAdaptive:function(){return t},observe:function(o){e=function(){var e=window.innerWidth;n>768&&e<=768?o(t=!0):n<=768&&e>768&&o(t=!1),n=e},window.addEventListener("resize",e)}}}(),a=(t=i.isAdaptive(),o=t?"314px":"334px",{pageUrl:"floating_one_tap_auth",pageUrlParams:{adaptive:t?1:0},frameStyles:t?"\n display: none;\n position: fixed;\n bottom: 0;\n right: 50%;\n transform: translate(50%, 0);\n max-width: 468px;\n width: 100%;\n height: ".concat(o,";\n "):"\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n max-width: 400px;\n width: 100%;\n height: ".concat(o,";\n ")});if(!a)throw new Error("options were not set");var r=u(),c=P(L(s({origin:location.protocol+"//"+location.host,uuid:r},a.pageUrlParams),a.pageUrl),{cssText:a.frameStyles}),p=new Y({iframe:c,origin:"https://"+I.get().connectDomain});i.observe((function(e){p.sendMessage({handler:j.ADAPTIVITY_CHANGE,params:{uuid:r,is_adaptive:e}}),e?(c.style.maxWidth="468px",c.style.top="auto",c.style.bottom="0",c.style.right="50%",c.style.transform="translate(50%, 0)"):(c.style.maxWidth="400px",c.style.top="0",c.style.bottom="auto",c.style.right="0",c.style.transform="none"),c.style.display="none"})),document.body.appendChild(c);var d=function(){p.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:r}})};window.addEventListener("resize",d);var l=function(){c&&(c.remove(),c=null),window.removeEventListener("resize",d),i&&i.destroy(),p.destroy()},h=new Promise((function(t){p.onMessage((function(o){if(o.params.uuid===r)switch(o.handler){case W.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:r,error:"not_authorized"}}),l(),t(o.handler);break;case W.RESIZE_FRAME:c.style.height="".concat(o.params.height,"px");break;case j.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:r}}),l();break;case j.ADAPTIVITY_CHANGED:c.style.display="block";break;case W.AUTH_DATA_LOADED:c.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,p,e)}}))}));return{getFrame:function(){return c},destroy:l,authReadyPromise:h}})),a(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){n.display=e.displayMode&&R.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=H(e.showAgreements,0),n.show_alternative_login=H(e.showAlternativeLogin,0),n.show_agreements_dialog=H(e.showAgreementsDialog,1);t+=n.show_alternative_login?56:0,t+=n.show_agreements?80:0}return{pageUrl:"button_one_tap_auth",pageUrlParams:n,frameStyles:"\n height: ".concat(t,"px;\n ")}}(e.options);if(!t)throw new Error("options were not set");var o=u(),i=P(L(s({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),a=e.container;a&&a.appendChild(i);var r=new Y({iframe:i,origin:"https://"+I.get().connectDomain}),c=function(){r.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",c);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",c),r.destroy()},authReadyPromise:new Promise((function(t){r.onMessage((function(a){if(a.params.uuid===o)switch(a.handler){case W.RESIZE_FRAME:i.style.height="".concat(a.params.height,"px");break;case W.NOT_AUTHORIZED:t(a.handler);break;case F.SHOW_LOGIN:case F.SHOW_LOGIN_OPTIONS:e.callback({type:a.handler,payload:{uuid:o}});break;case F.SHOW_AGREEMENTS_DIALOG:n.userPolicyAgreements(o).show().then((function(e){e&&e.accepted&&r.sendMessage({handler:F.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){r.sendMessage({handler:x.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case W.AUTH_DATA_LOADED:t(a.handler);default:n.handleOneTapEvents(a,r,e)}}))}))}})),a(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case W.AUTH_DATA_LOADED:t.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:i}});break;case W.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:e.params});break;case W.SHOW_CAPTCHA:var a=n.captcha(i,{captcha_sid:e.params.captcha_sid,captcha_img:e.params.captcha_img});a.show().then((function(e){t.sendMessage({handler:G.CAPTCHA_SUCCESS,params:s({uuid:i},e)})})).catch((function(){t.sendMessage({handler:G.CAPTCHA_FAIL,params:{uuid:i}}),a.destroy()}));break;case U.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:U.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:U.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case W.FULL_AUTH_NEEDED:case W.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),a(this,"userDataPolicy",(function(e){var t=L({origin:location.protocol+"//"+location.host,uuid:e},"user_data_policy"),o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),a=P(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(a);var r=new Y({iframe:a,origin:"https://"+I.get().connectDomain}),c=function(){a.style.display="none"};return{show:function(){return a.style.display="block",new Promise((function(t,o){r.onMessage((function(i){switch(i.handler){case U.HIDE_DATA_POLICY:c(),t();break;case U.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){r.sendMessage({handler:G.CAPTCHA_SUCCESS,params:s({uuid:e},n)}),a.style.display="block"})).catch((function(){r.sendMessage({handler:G.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(a),r.destroy()}}})),a(this,"userPolicyAgreements",(function(e){var t,o,i,a=L({origin:location.protocol+"//"+location.host,uuid:e},"user_policy_agreements"),r=(t=a,o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),P(t,{properties:{height:"".concat(o,"px")},cssText:i}));document.body.appendChild(r);var s=new Y({iframe:r,origin:"https://"+I.get().connectDomain}),c=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){s.onMessage((function(i){switch(i.handler){case x.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case x.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case x.SHOW_DATA_POLICY:c();var a=function(){r.style.display="block"};n.userDataPolicy(e).show().then(a).catch(a);break;case x.POLICY_AGREEMENTS_ERROR:case x.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),s.destroy()}}})),a(this,"captcha",(function(e,n){var t=L(s({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=P(t,{cssText:"\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n ")});document.body.appendChild(i);var a=new Y({iframe:i,origin:"https://"+I.get().connectDomain}),r=function(){document.body.removeChild(i),a.destroy()};return{show:function(){return i.style.display="block",new Promise((function(e,n){a.onMessage((function(t){switch(t.handler){case G.CAPTCHA_SUCCESS:e(t.params),r();break;default:n(),r()}}))}))},destroy:r}})),a(this,"userVisibleAuth",(function(e){var t=u(),o=s({origin:location.protocol+"//"+location.host,uuid:t},V(e,["screen","source"])),i=K(null==e?void 0:e.action);i&&(o.action=i);var a=L(o);n.flags&&(a="".concat(a,"#").concat(S(n.flags)));var r=screen.height/2-280,p=screen.width/2-410,d=window.open(a,"_blank","top=".concat(r,",left=").concat(p,",width=").concat(820,",height=").concat(560,",location"));if(!d){var A={code:c.CONNECT_WINDOW_NOT_OPENED,reason:h()};return Promise.reject(A)}return new Promise((function(e,n){var o=setInterval((function(){if(!d||d.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:c.CONNECT_WINDOW_CLOSED,reason:l()};n(e)}}),1e3);function i(a){if(a.source===d&&d)if(window.removeEventListener("message",i),clearInterval(o),".vk.com"===a.origin.slice(a.origin.length-".vk.com".length))if(a.data.action==="vk_connect_response"+t){var r=a.data.payload;d.close(),e({provider:"vk",payload:r})}else if(a.data.action==="oauth_callback"+t)e({provider:a.data.payload.name}),d.close();else if(a.data.action==="skip_callback"+t){var s=a.data.payload.redirectURL;s&&(window.location.href=s),d.close()}else{d.close();var p={code:c.CONNECT_UNKNOWN_SDK_MESSAGE,reason:m(JSON.stringify(a.data))};n(p)}else{d.close();var u={code:c.CONNECT_DOMAIN_NOT_ALLOWED,reason:f(a.origin)};n(u)}}window.addEventListener("message",i)}))})),a(this,"redirectAuth",(function(e){var n=u(),t=s({redirect_uri:e.url,uuid:n},V(e,["screen","source"])),o=K(null==e?void 0:e.action);o&&(t.action=o),(null==e?void 0:e.state)&&(t.redirect_state=e.state);var i=L(t);location.assign(i)}))};!function(e){e.APP_CLOSE="VKWebAppClose",e.APP_READY="VKSDKMiniAppReady",e.RESIZE="VKSDKMiniAppResize",e.APP_INIT_CONFIG="VKSDKMiniAppInitConfig",e.OPEN_APP="VKWebAppOpenApp",e.OPEN_PAY_FORM="VKWebAppOpenPayForm",e.ACTION_DONE="VKWebAppActionDone"}(z||(z={})),function(e){e.OPEN="open",e.HIDE="hide",e.CLOSE="close",e.SHOW="show",e.MESSAGE="message",e.CREATE_APP="createapp"}(q||(q={})),function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp"}(Z||(Z={}));var J,X=function e(n){var t=this;o(this,e),a(this,"events",void 0),a(this,"iframe",void 0),a(this,"bridge",void 0),a(this,"loading",void 0),a(this,"readyPromiseResolve",null),a(this,"readyPromise",null),a(this,"bodyOverflowValue",""),a(this,"params",void 0),a(this,"child",null),a(this,"open",(function(e,n){return t.loading?(t.iframe.src=t.getMiniAppUrl(e,n),t.loading=new Promise((function(e){t.iframe.onload=function(){t.iframe.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e}))):t.preload(e,n).catch(console.error),t.iframe.style.display="block",t.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",t.loading.then(t.handleResize).catch(console.error),t.events.emit(q.OPEN),t.readyPromise})),a(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(q.HIDE)})),a(this,"close",(function(){window.document.body.style.overflowX="",I.events.off("superAppToken",t.onSuperAppToken),t.iframe&&t.iframe.remove(),t.bridge&&t.bridge.destroy(),delete t.iframe,delete t.bridge,window.removeEventListener("resize",t.handleResize),t.events.emit(q.CLOSE)})),a(this,"show",(function(){if(!t.loading)throw new Error('App is not loaded, use "open" or "preload" methods');t.iframe.style.display="block",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(q.SHOW)})),a(this,"preload",(function(e,n){var o=document.createElement("iframe"),i=window.innerHeight,a=isFinite(t.params.zIndex)?t.params.zIndex:999999;return o.src=t.getMiniAppUrl(e,n),o.setAttribute("allow","geolocation"),o.style.cssText="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(i,"px;\n min-height: ").concat(i,"px;\n border: none;\n z-index: ").concat(a,";\n "),t.iframe=o,document.body.appendChild(t.iframe),I.events.on("superAppToken",t.onSuperAppToken),t.bridge=new Y({iframe:t.iframe,origin:"https://"+I.get().connectDomain}),t.bridge.onMessage(t.handleMessage),window.addEventListener("resize",t.handleResize),t.loading=new Promise((function(e){o.onload=function(){o.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e})),t.loading})),a(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),a(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:Z.SUPERAPP_TOKEN,params:{result:e}})})),a(this,"handleMessage",(function(e){switch(e.handler){case z.APP_CLOSE:t.hide();break;case z.APP_READY:t.resolveReadyPromise(),t.handleUpdateConfig();break;case z.OPEN_APP:t.openMiniapp(e.params);break;case z.OPEN_PAY_FORM:t.openPayForm(e.params);break;case Z.SUPERAPP_TOKEN:I._requestSuperAppToken();break;case Z.AUTH_NEEDED:I._requestAuth();break;default:t.events.emit(q.MESSAGE,e)}})),a(this,"handleResize",(function(){if(t.iframe){var e=innerWidth,n=innerHeight;t.iframe.style.height="".concat(n,"px"),t.iframe.style.minHeight="".concat(n,"px"),t.bridge.sendMessage({handler:z.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),a(this,"handleUpdateConfig",(function(){t.bridge.sendMessage({handler:z.APP_INIT_CONFIG,params:{fullMode:t.params.fullMode,hideMenu:t.params.hideMenu}})})),a(this,"getMiniAppUrl",(function(e,n){var o=I.get(),i=o.connectDomain,a=o.appId,r=o.superAppToken,s=o._debug,c=S({app:t.params.app,host_app_id:a,debug:s?"1":"",localhost:s?"1":"",superapp_token:r,app_query:e?JSON.stringify(e):"",app_hash:n||""});return"https://".concat(i,"/mini_app?").concat(c)})),a(this,"resolveReadyPromise",(function(){t.readyPromise&&t.readyPromiseResolve&&(t.readyPromiseResolve(),t.readyPromise=null,t.readyPromiseResolve=null)})),a(this,"openMiniapp",(function(n){t.child=new e({app:n.app_id}),t.events.emit(q.CREATE_APP,{app:t.child,location:n.location})})),a(this,"openPayForm",(function(n){var o=s({},n.params);o.data&&(o.data=JSON.stringify(o.data));var i=s({},o,{app_id:n.app_id,action:n.action}),a=new e({app:6217559});a.open(i).then((function(){return t.hide()})).catch(console.error),a.events.on(q.MESSAGE,(function(e){t.handleVKPayFormMessage(e),a.close(),t.show()})),a.events.on(q.HIDE,(function(){a.close(),t.close()}))})),a(this,"handleVKPayFormMessage",(function(e){e.handler===z.ACTION_DONE&&t.sendMessage(e)})),this.params=s({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=b()};!function(e){e.STATIC_MAP="VKSDKRequestToGeoservice:staticmap/png/",e.SEARCH="VKSDKRequestToGeoservice:search",e.OVERALL="VKSDKRequestToGeoservice:overall",e.DIRECTIONS="VKSDKRequestToGeoservice:directions",e.ISO="VKSDKRequestToGeoservice:iso"}(J||(J={}));var Q=function(){function e(n){var t=this,i=n.apiKey;o(this,e),a(this,"iframe",void 0),a(this,"bridge",void 0),a(this,"requestMap",void 0),a(this,"apiKey",void 0),this.apiKey=i;var r=document.createElement("iframe"),s=I.get().appId;r.src=this.getGeoserviceProxyUrl({app_id:s}),r.style.cssText="\n display: none;\n ",this.iframe=r,document.body.appendChild(this.iframe),this.bridge=new Y({iframe:this.iframe,origin:"https://"+I.get().connectDomain}),this.requestMap={},this.bridge.onMessage((function(e){var n=e.params,o=n.requestID,i=n.response;t.requestMap[o].resolve(i),delete t.requestMap[o]}))}var n,t,r;return n=e,(t=[{key:"setApiKey",value:function(e){this.apiKey=e}},{key:"getGeoserviceProxyUrl",value:function(e){var n=I.get(),t=n.connectDomain,o=n._debug,i=s({},e||{},{origin:location.protocol+"//"+location.host,localhost:String(location.host.includes("localhost")),debug:location.host.includes("localhost")?1:String(o)});return"https://".concat(t,"/geoservice?").concat(S(i))}},{key:"prepareAnswer",value:function(e,n,t){var o=this,i=u();return this.bridge.sendMessage({handler:"VKSDKRequestToGeoservice:".concat(e),params:s({},n,{api_key:this.apiKey,wrapRequestInJSON:t,requestID:i})}),new Promise((function(e,n){o.requestMap[i]={resolve:e,reject:n}}))}},{key:"getStaticMap",value:function(e){return this.prepareAnswer("staticmap/png/",e)}},{key:"encodeCoords",value:function(e){return this.prepareAnswer("search",e)}},{key:"decodeCoords",value:function(e){return this.prepareAnswer("overall",e)}},{key:"getDirections",value:function(e){return this.prepareAnswer("directions",e,!0)}},{key:"getISO",value:function(e){return this.prepareAnswer("iso",e,!0)}}])&&i(n.prototype,t),r&&i(n,r),e}(),$={OneTapAuthEventsSDK:W,FloatingOneTapAuthEventsSDK:j,ButtonOneTapAuthEventsSDK:F,DataPolicyEventsSDK:U,AuthCaptchaEventsSDK:G};export{I as Config,B as Connect,$ as ConnectEvents,Q as GeoService,X as MiniApp,q as MiniAppEvents}; |
@@ -0,0 +0,0 @@ export declare enum MiniAppHostEvents { |
@@ -0,0 +0,0 @@ import { Emitter } from 'mitt'; |
@@ -0,0 +0,0 @@ import { MiniAppHostEvents } from '#/miniapp/events'; |
{ | ||
"name": "@vkontakte/superappkit", | ||
"version": "1.24.0-alpha.1", | ||
"version": "1.24.0", | ||
"description": "VK SuperAppKit", | ||
@@ -5,0 +5,0 @@ "main": "dist/index-cjs.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
78333
21
850