@vkontakte/superappkit
Advanced tools
Comparing version 1.18.0-beta.1.0 to 1.18.0
@@ -1,2 +0,2 @@ | ||
import { AuthButtonParams, AuthButtonType, AuthParams, ButtonOneTapAuthParams, RedirectAuthParams, VKAuthSuccessResult, VKDataPolicyResult, VKOneTapAuthButtonResult, VKOneTapAuthResult, VKUserVisibleAuthResult } from './types'; | ||
import { AuthButtonParams, AuthButtonType, ButtonOneTapAuthParams, RedirectAuthParams, UserVisibleAuthParams, VKAuthSuccessResult, VKDataPolicyResult, VKOneTapAuthButtonResult, VKOneTapAuthResult, VKUserVisibleAuthResult } from './types'; | ||
declare class Connect { | ||
@@ -12,3 +12,3 @@ private readonly flags; | ||
private readonly captcha; | ||
readonly userVisibleAuth: (params?: AuthParams | undefined) => Promise<VKUserVisibleAuthResult>; | ||
readonly userVisibleAuth: (params?: UserVisibleAuthParams | undefined) => Promise<VKUserVisibleAuthResult>; | ||
readonly redirectAuth: (params: RedirectAuthParams) => void; | ||
@@ -15,0 +15,0 @@ } |
@@ -45,11 +45,12 @@ import { AuthCaptchaEventsSDK, ButtonOneTapAuthEventsSDK, DataPolicyEventsSDK, FloatingOneTapAuthEventsSDK, OneTapAuthEventsSDK, PolicyAgreementsEventsSDK } from '#/connect/events'; | ||
export declare type BridgeEvents = OneTapAuthEventsSDK | FloatingOneTapAuthEventsSDK | ButtonOneTapAuthEventsSDK | DataPolicyEventsSDK | AuthCaptchaEventsSDK | PolicyAgreementsEventsSDK; | ||
export declare type AuthParams = { | ||
source?: string; | ||
export declare type RedirectAuthParams = { | ||
url: string; | ||
state?: string; | ||
screen?: 'phone'; | ||
action?: AuthAction; | ||
}; | ||
export interface RedirectAuthParams extends AuthParams { | ||
url: string; | ||
state?: string; | ||
} | ||
export declare type UserVisibleAuthParams = { | ||
screen?: 'phone'; | ||
action?: AuthAction; | ||
}; | ||
export declare type VKOneTapAuthResult = { | ||
@@ -120,3 +121,3 @@ destroy: () => void; | ||
}; | ||
export interface ExtendTokenParams { | ||
export interface ExtendToken { | ||
name: 'extend_token'; | ||
@@ -132,3 +133,9 @@ token: string; | ||
} | ||
export declare type AuthAction = ExtendTokenParams | AuthWithUser; | ||
interface SferumInviteLink { | ||
name: '__sferum_invite_link'; | ||
params: { | ||
link: string; | ||
}; | ||
} | ||
export declare type AuthAction = ExtendToken | AuthWithUser | SferumInviteLink; | ||
export declare type AdaptivitySwitchObserver = { | ||
@@ -135,0 +142,0 @@ destroy: () => void; |
@@ -14,2 +14,1 @@ import { AuthAction, AdaptivitySwitchObserver, VKOneTapAuthOptions, ButtonOneTapAuthOptions } from '#/connect/types'; | ||
export declare function getButtonOneTapAuthOptions(options: ButtonOneTapAuthOptions): VKOneTapAuthOptions; | ||
export declare function filterObjectKeys(obj: any, filterKeys: string[]): any; |
@@ -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,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function s(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 c(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?s(Object(t),!0).forEach((function(n){a(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(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 p,u="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",d=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=u[64*Math.random()|0];return n},l=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand","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"}(p||(p={}));var h=function(){return"No params passed for load app!"},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)},_=!("undefined"==typeof window||!window.document||!window.document.createElement),E=_&&!!window.addEventListener,y=function(){};if(E)try{var O=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",y,O),window.removeEventListener("test",y,O)}catch(e){}!function(){if(!_)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 S(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?v(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):v(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 P(e){return Object.keys(e).filter((function(e){return l.includes(e)}))}function b(e){var n;return Boolean(null===(n=P(e))||void 0===n?void 0:n.length)}function D(e){var n=function(e){return P(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},k={},M={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,M.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){k.superAppToken=e},_requestSuperAppToken:function(){var e;k.superAppToken&&(e=k.superAppToken()),e&&e.then((function(e){return M.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){k.auth=e},_requestAuth:function(){var e;k.auth&&(e=k.auth()),e&&e.then((function(e){return M.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){k.openApp=e},_openApp:function(e){k.openApp&&k.openApp(e.app)}},L=["extend_token","login_with_user"];function K(e){return e&&L.includes(e.name)?btoa(JSON.stringify(e)):""}var R;function H(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=c({app_id:o,response_type:"silent_token",v:"0.0.2"},e);r&&b(r)&&(a.app_settings=D(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 x=[R.Default,R.NamePhone,R.PhoneName];function U(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}function V(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 W,G,j,F,Y,z,q=function e(n){var t=this;r(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(c({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"}(W||(W={})),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"}(G||(G={})),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"}(Y||(Y={})),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),a(this,"flags",null),a(this,"silentAuth",(function(){var e=M.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()}))})),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)}}}(),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: 0;\n max-width: 100%;\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(H(c({origin:location.protocol+"//"+location.host,uuid:a},r.pageUrlParams),r.pageUrl),{cssText:r.frameStyles}),p=new q({iframe:s,origin:"https://"+M.get().connectDomain});i.observe((function(e){p.sendMessage({handler:Y.ADAPTIVITY_CHANGE,params:{uuid:a,is_adaptive:e}}),e?(s.style.maxWidth="100%",s.style.top="auto",s.style.bottom="0"):(s.style.maxWidth="400px",s.style.top="0",s.style.bottom="auto"),s.style.display="none"})),document.body.appendChild(s);var u=function(){p.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(),p.destroy()},h=new Promise((function(t){p.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 Y.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:a}}),l();break;case Y.ADAPTIVITY_CHANGED:s.style.display="block";break;case F.AUTH_DATA_LOADED:s.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,p,e)}}))}));return{getFrame:function(){return s},destroy:l,authReadyPromise:h}})),a(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=U(e.showAgreements,0),n.show_alternative_login=U(e.showAlternativeLogin,0),n.show_agreements_dialog=U(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(H(c({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),r=e.container;r&&r.appendChild(i);var a=new q({iframe:i,origin:"https://"+M.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 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:G.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case F.AUTH_DATA_LOADED:t(r.handler);default:n.handleOneTapEvents(r,a,e)}}))}))}})),a(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:c({uuid:i},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:c({uuid:i},e)})})).catch((function(){t.sendMessage({handler:j.CAPTCHA_FAIL,params:{uuid:i}}),r.destroy()}));break;case W.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:W.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:W.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}})}})),a(this,"userDataPolicy",(function(e){var t=H({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 q({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 W.HIDE_DATA_POLICY:s(),t();break;case W.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){a.sendMessage({handler:j.CAPTCHA_SUCCESS,params:c({uuid:e},n)}),r.style.display="block"})).catch((function(){a.sendMessage({handler:j.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),s();break;default:s(),o()}}))}))},hide:s,destroy:function(){document.body.removeChild(r),a.destroy()}}})),a(this,"userPolicyAgreements",(function(e){var t,o,i,r=H({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 q({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 G.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case G.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case G.SHOW_DATA_POLICY:c();var r=function(){a.style.display="block"};n.userDataPolicy(e).show().then(r).catch(r);break;case G.POLICY_AGREEMENTS_ERROR:case G.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(a),s.destroy()}}})),a(this,"captcha",(function(e,n){var t=H(c({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 q({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}})),a(this,"userVisibleAuth",(function(e){var t=d(),o=c({origin:location.protocol+"//"+location.host,uuid:t},V(e,["screen","source","action"])),i=K(null==e?void 0:e.action);i?o.action=i:delete o.action;var r=H(o);console.log("url",r),n.flags&&(r="".concat(r,"#").concat(w(n.flags)));var a=screen.height/2-280,s=screen.width/2-410,u=window.open(r,"_blank","top=".concat(a,",left=").concat(s,",width=").concat(820,",height=").concat(560,",location"));if(!u){var l={code:p.CONNECT_WINDOW_NOT_OPENED,reason:m()};return Promise.reject(l)}return new Promise((function(e,n){var o=setInterval((function(){if(!u||u.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:p.CONNECT_WINDOW_CLOSED,reason:f()};n(e)}}),1e3);function i(r){if(r.source===u&&u)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;u.close(),e({provider:"vk",payload:a})}else if(r.data.action==="oauth_callback"+t)e({provider:r.data.payload.name}),u.close();else{u.close();var s={code:p.CONNECT_UNKNOWN_SDK_MESSAGE,reason:g(JSON.stringify(r.data))};n(s)}else{u.close();var c={code:p.CONNECT_DOMAIN_NOT_ALLOWED,reason:A(r.origin)};n(c)}}window.addEventListener("message",i)}))})),a(this,"redirectAuth",(function(e){var n=d(),t=c({redirect_uri:e.url,uuid:n},V(e,["state","screen","source","action"])),o=K(null==e?void 0:e.action);o?t.action=o:delete t.action;var i=H(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.INIT="ConnectProfileInit"}(Q||(Q={}));var $={OneTapAuthEventsSDK:F,FloatingOneTapAuthEventsSDK:Y,ButtonOneTapAuthEventsSDK:z,DataPolicyEventsSDK:W,AuthCaptchaEventsSDK:j};exports.Config=M,exports.Connect=X,exports.ConnectEvents=$,exports.MiniApp=function e(n){var t=this;r(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(exports.MiniAppEvents.OPEN),t.readyPromise})),a(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.HIDE)})),a(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)})),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(exports.MiniAppEvents.SHOW)})),a(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.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 q({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})),a(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),a(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:J.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 J.SUPERAPP_TOKEN:M._requestSuperAppToken();break;case J.AUTH_NEEDED:M._requestAuth();break;default:t.events.emit(exports.MiniAppEvents.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}})})),a(this,"getMiniAppUrl",(function(e,n){var o=M.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)})),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(exports.MiniAppEvents.CREATE_APP,{app:t.child,location:n.location})})),a(this,"openPayForm",(function(n){var o=c({},n.params);o.data&&(o.data=JSON.stringify(o.data));var i=c({},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()}))})),a(this,"handleVKPayFormMessage",(function(e){e.handler===Z.ACTION_DONE&&t.sendMessage(e)})),this.params=c({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=N()},exports.Profile=function e(){var n=this;r(this,e),a(this,"iframe",void 0),a(this,"config",void 0),a(this,"bridge",void 0),a(this,"iframeLoadPromise",void 0),a(this,"load",(function(e){if(!e.container)throw new Error("container is null");if(!e)throw new Error(h());return n.iframe||n.preload(e),n.iframeLoadPromise})),a(this,"remove",(function(){n.iframe&&n.iframe.parentNode&&n.iframe.parentNode.removeChild(n.iframe),n.destroy()})),a(this,"preload",(function(e){n.config=e;var t=document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.minHeight="100%",e.container.appendChild(t),n.setup(t)})),a(this,"setup",(function(e){M.events.on("superAppToken",n.onSuperAppToken),e.src=n.getProfileUrl(),n.iframe=e,n.iframeLoadPromise=new Promise((function(n){e.onload=function(){return n(e)}})),n.bridge=new q({iframe:n.iframe,origin:"https://"+M.get().connectDomain}),n.bridge.onMessage(n.handleMessage)})),a(this,"destroy",(function(){M.events.off("superAppToken",n.onSuperAppToken),n.bridge.destroy(),delete n.iframe,delete n.iframeLoadPromise,delete n.bridge})),a(this,"onSuperAppToken",(function(e){if(e&&n.iframe){var t=n.iframe;n.destroy(),n.setup(t)}})),a(this,"handleMessage",(function(e){switch(e.handler){case Q.INIT:n.handleInitApp().catch(console.error);break;case J.SUPERAPP_TOKEN:M._requestSuperAppToken();break;case J.AUTH_NEEDED:M._requestAuth();break;case J.OPEN_APP:M._openApp(e.params)}})),a(this,"handleInitApp",(function(){return Promise.resolve()})),a(this,"getProfileUrl",(function(){var e=M.get(),t=e.connectDomain,o=e.appId,i=e.superAppToken,r=e._debug,a=n.config.widgets,s=w({host_app_id:o,debug:r?"1":"",localhost:r?"1":"",superapp_token:i,widgets:a?a.join(","):""});return"https://".concat(t,"/super_profile?").concat(s)}))}; | ||
"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,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(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?a(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(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 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","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"No params passed for load app!"},h=function(){return"Connect window was closed."},f=function(){return"Connect window was not opened."},A=function(e){return'URL domain "'.concat(e,'" is not allowed.')},m=function(e){return"This SDK message is unknown: ".concat(e)},g=!("undefined"==typeof window||!window.document||!window.document.createElement),_=g&&!!window.addEventListener,E=function(){};if(_)try{var v=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",E,v),window.removeEventListener("test",E,v)}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 y(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=y({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 S(e){return T.stringify(e)}function w(e){return Object.keys(e).filter((function(e){return d.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 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 r;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(r=n.properties[i])&&void 0!==r?r:""}return o}function C(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 N={appId:0,superAppToken:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},I={},k={events:C(),init:function(e){if(!e.appId)throw new Error("appId required");N.appId=e.appId,N.superAppToken=e.superAppToken||"",N.loginDomain=e.loginDomain||"login.vk.com",N.oauthDomain=e.oauthDomain||"oauth.vk.com",N.connectDomain=e.connectDomain||"connect.vk.com",N.appSettings=e.appSettings,N._debug=!!e._debug},get:function(){return N},setSuperAppToken:function(e){N.superAppToken=e,k.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){I.superAppToken=e},_requestSuperAppToken:function(){var e;I.superAppToken&&(e=I.superAppToken()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){I.auth=e},_requestAuth:function(){var e;I.auth&&(e=I.auth()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){I.openApp=e},_openApp:function(e){I.openApp&&I.openApp(e.app)}},M=["extend_token","login_with_user","__sferum_invite_link"];function L(e){return e&&M.includes(e.name)?btoa(JSON.stringify(e)):""}var K;function R(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=s({app_id:o,response_type:"silent_token",v:"0.0.2"},e);r&&P(r)&&(a.app_settings=D(r));var c=S(a);return"https://".concat(i,"/").concat(n,"?").concat(c)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(K||(K={}));var H=[K.Default,K.NamePhone,K.PhoneName];function x(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}var U,V,W,G,j,F,Y=function e(n){var t=this;i(this,e),r(this,"handler",(function(){return{}})),r(this,"config",void 0),r(this,"destroy",(function(){delete t.config,window.removeEventListener("message",t.handleMessage)})),r(this,"onMessage",(function(e){t.handler=e})),r(this,"sendMessage",(function(e){t.config.iframe.contentWindow.postMessage(s({type:"vk-sak-sdk"},e),t.config.origin)})),r(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"}(V||(V={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(W||(W={})),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"}(G||(G={})),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;i(this,e),r(this,"flags",null),r(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"),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()}))})),r(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}})),r(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: 0;\n max-width: 100%;\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=u(),c=b(R(s({origin:location.protocol+"//"+location.host,uuid:a},r.pageUrlParams),r.pageUrl),{cssText:r.frameStyles}),p=new Y({iframe:c,origin:"https://"+k.get().connectDomain});i.observe((function(e){p.sendMessage({handler:j.ADAPTIVITY_CHANGE,params:{uuid:a,is_adaptive:e}}),e?(c.style.maxWidth="100%",c.style.top="auto",c.style.bottom="0"):(c.style.maxWidth="400px",c.style.top="0",c.style.bottom="auto"),c.style.display="none"})),document.body.appendChild(c);var d=function(){p.sendMessage({handler:G.RESIZE_FRAME,params:{uuid:a}})};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===a)switch(o.handler){case G.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:a,error:"not_authorized"}}),l(),t(o.handler);break;case G.RESIZE_FRAME:c.style.height="".concat(o.params.height,"px");break;case j.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:a}}),l();break;case j.ADAPTIVITY_CHANGED:c.style.display="block";break;case G.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}})),r(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=x(e.showAgreements,0),n.show_alternative_login=x(e.showAlternativeLogin,0),n.show_agreements_dialog=x(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}),r=e.container;r&&r.appendChild(i);var a=new Y({iframe:i,origin:"https://"+k.get().connectDomain}),c=function(){a.sendMessage({handler:G.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),a.destroy()},authReadyPromise:new Promise((function(t){a.onMessage((function(r){if(r.params.uuid===o)switch(r.handler){case G.RESIZE_FRAME:i.style.height="".concat(r.params.height,"px");break;case G.NOT_AUTHORIZED:t(r.handler);break;case F.SHOW_LOGIN:case F.SHOW_LOGIN_OPTIONS:e.callback({type:r.handler,payload:{uuid:o}});break;case F.SHOW_AGREEMENTS_DIALOG:n.userPolicyAgreements(o).show().then((function(e){e&&e.accepted&&a.sendMessage({handler:F.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){a.sendMessage({handler:V.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case G.AUTH_DATA_LOADED:t(r.handler);default:n.handleOneTapEvents(r,a,e)}}))}))}})),r(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case G.AUTH_DATA_LOADED:t.sendMessage({handler:G.RESIZE_FRAME,params:{uuid:i}});break;case G.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:s({uuid:i},e.params)});break;case G.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:W.CAPTCHA_SUCCESS,params:s({uuid:i},e)})})).catch((function(){t.sendMessage({handler:W.CAPTCHA_FAIL,params:{uuid:i}}),r.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 G.FULL_AUTH_NEEDED:case G.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),r(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 "),r=b(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(r);var a=new Y({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){a.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){a.sendMessage({handler:W.CAPTCHA_SUCCESS,params:s({uuid:e},n)}),r.style.display="block"})).catch((function(){a.sendMessage({handler:W.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),a.destroy()}}})),r(this,"userPolicyAgreements",(function(e){var t,o,i,r=R({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 "),b(t,{properties:{height:"".concat(o,"px")},cssText:i}));document.body.appendChild(a);var s=new Y({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 V.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case V.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case V.SHOW_DATA_POLICY:c();var r=function(){a.style.display="block"};n.userDataPolicy(e).show().then(r).catch(r);break;case V.POLICY_AGREEMENTS_ERROR:case V.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(a),s.destroy()}}})),r(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 r=new Y({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 W.CAPTCHA_SUCCESS:e(t.params),a();break;default:n(),a()}}))}))},destroy:a}})),r(this,"userVisibleAuth",(function(e){var t=u(),o={origin:location.protocol+"//"+location.host,uuid:t};(null==e?void 0:e.screen)&&(o.screen=e.screen);var i=L(null==e?void 0:e.action);i&&(o.action=i);var r=R(o);n.flags&&(r="".concat(r,"#").concat(S(n.flags)));var a=screen.height/2-280,s=screen.width/2-410,p=window.open(r,"_blank","top=".concat(a,",left=").concat(s,",width=").concat(820,",height=").concat(560,",location"));if(!p){var d={code:c.CONNECT_WINDOW_NOT_OPENED,reason:f()};return Promise.reject(d)}return new Promise((function(e,n){var o=setInterval((function(){if(!p||p.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:c.CONNECT_WINDOW_CLOSED,reason:h()};n(e)}}),1e3);function i(r){if(r.source===p&&p)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;p.close(),e({provider:"vk",payload:a})}else if(r.data.action==="oauth_callback"+t)e({provider:r.data.payload.name}),p.close();else{p.close();var s={code:c.CONNECT_UNKNOWN_SDK_MESSAGE,reason:m(JSON.stringify(r.data))};n(s)}else{p.close();var u={code:c.CONNECT_DOMAIN_NOT_ALLOWED,reason:A(r.origin)};n(u)}}window.addEventListener("message",i)}))})),r(this,"redirectAuth",(function(e){var n=u(),t={redirect_uri:e.url,uuid:n};(null==e?void 0:e.state)&&(t.redirect_state=e.state),(null==e?void 0:e.screen)&&(t.screen=e.screen);var o=L(null==e?void 0:e.action);o&&(t.action=o);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"}(z||(z={})),(q=exports.MiniAppEvents||(exports.MiniAppEvents={})).OPEN="open",q.HIDE="hide",q.CLOSE="close",q.SHOW="show",q.MESSAGE="message",q.CREATE_APP="createapp",function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp"}(Z||(Z={}));var J;!function(e){e.INIT="ConnectProfileInit"}(J||(J={}));var X={OneTapAuthEventsSDK:G,FloatingOneTapAuthEventsSDK:j,ButtonOneTapAuthEventsSDK:F,DataPolicyEventsSDK:U,AuthCaptchaEventsSDK:W};exports.Config=k,exports.Connect=B,exports.ConnectEvents=X,exports.MiniApp=function e(n){var t=this;i(this,e),r(this,"events",void 0),r(this,"iframe",void 0),r(this,"bridge",void 0),r(this,"loading",void 0),r(this,"readyPromiseResolve",null),r(this,"readyPromise",null),r(this,"bodyOverflowValue",""),r(this,"params",void 0),r(this,"child",null),r(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})),r(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.HIDE)})),r(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)})),r(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)})),r(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.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 Y({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})),r(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),r(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:Z.SUPERAPP_TOKEN,params:{result:e}})})),r(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:k._requestSuperAppToken();break;case Z.AUTH_NEEDED:k._requestAuth();break;default:t.events.emit(exports.MiniAppEvents.MESSAGE,e)}})),r(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}})}})),r(this,"handleUpdateConfig",(function(){t.bridge.sendMessage({handler:z.APP_INIT_CONFIG,params:{fullMode:t.params.fullMode}})})),r(this,"getMiniAppUrl",(function(e,n){var o=k.get(),i=o.connectDomain,r=o.appId,a=o.superAppToken,s=o._debug,c=S({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)})),r(this,"resolveReadyPromise",(function(){t.readyPromise&&t.readyPromiseResolve&&(t.readyPromiseResolve(),t.readyPromise=null,t.readyPromiseResolve=null)})),r(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})})),r(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}),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()}))})),r(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=C()},exports.Profile=function e(){var n=this;i(this,e),r(this,"iframe",void 0),r(this,"config",void 0),r(this,"bridge",void 0),r(this,"iframeLoadPromise",void 0),r(this,"load",(function(e){if(!e.container)throw new Error("container is null");if(!e)throw new Error(l());return n.iframe||n.preload(e),n.iframeLoadPromise})),r(this,"remove",(function(){n.iframe&&n.iframe.parentNode&&n.iframe.parentNode.removeChild(n.iframe),n.destroy()})),r(this,"preload",(function(e){n.config=e;var t=document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.minHeight="100%",e.container.appendChild(t),n.setup(t)})),r(this,"setup",(function(e){k.events.on("superAppToken",n.onSuperAppToken),e.src=n.getProfileUrl(),n.iframe=e,n.iframeLoadPromise=new Promise((function(n){e.onload=function(){return n(e)}})),n.bridge=new Y({iframe:n.iframe,origin:"https://"+k.get().connectDomain}),n.bridge.onMessage(n.handleMessage)})),r(this,"destroy",(function(){k.events.off("superAppToken",n.onSuperAppToken),n.bridge.destroy(),delete n.iframe,delete n.iframeLoadPromise,delete n.bridge})),r(this,"onSuperAppToken",(function(e){if(e&&n.iframe){var t=n.iframe;n.destroy(),n.setup(t)}})),r(this,"handleMessage",(function(e){switch(e.handler){case J.INIT:n.handleInitApp().catch(console.error);break;case Z.SUPERAPP_TOKEN:k._requestSuperAppToken();break;case Z.AUTH_NEEDED:k._requestAuth();break;case Z.OPEN_APP:k._openApp(e.params)}})),r(this,"handleInitApp",(function(){return Promise.resolve()})),r(this,"getProfileUrl",(function(){var e=k.get(),t=e.connectDomain,o=e.appId,i=e.superAppToken,r=e._debug,a=n.config.widgets,s=S({host_app_id:o,debug:r?"1":"",localhost:r?"1":"",superapp_token:i,widgets:a?a.join(","):""});return"https://".concat(t,"/super_profile?").concat(s)}))}; |
@@ -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,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(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 r(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){i(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var s,c="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",p=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=c[64*Math.random()|0];return n},u=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand","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"}(s||(s={}));var d=function(){return"No params passed for load app!"},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,_=function(){};if(g)try{var E=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",_,E),window.removeEventListener("test",_,E)}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 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 y(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?O(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):O(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}var v={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=y({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 v.stringify(e)}function S(e){return Object.keys(e).filter((function(e){return u.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 D(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"];function L(e){return e&&k.includes(e.name)?btoa(JSON.stringify(e)):""}var M;function K(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,s=r({app_id:o,response_type:"silent_token",v:"0.0.2"},e);a&&w(a)&&(s.app_settings=P(a));var c=T(s);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 U(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 V,x,W,G,j,F,Y=function e(n){var t=this;o(this,e),i(this,"handler",(function(){return{}})),i(this,"config",void 0),i(this,"destroy",(function(){delete t.config,window.removeEventListener("message",t.handleMessage)})),i(this,"onMessage",(function(e){t.handler=e})),i(this,"sendMessage",(function(e){t.config.iframe.contentWindow.postMessage(r({type:"vk-sak-sdk"},e),t.config.origin)})),i(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"}(V||(V={})),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"}(W||(W={})),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"}(G||(G={})),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,Z,q,B=new function e(){var n=this;o(this,e),i(this,"flags",null),i(this,"silentAuth",(function(){var e=I.get(),n=e.loginDomain,t=e.appId,o=p(),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()}))})),i(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}})),i(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: 0;\n max-width: 100%;\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 s=p(),c=D(K(r({origin:location.protocol+"//"+location.host,uuid:s},a.pageUrlParams),a.pageUrl),{cssText:a.frameStyles}),u=new Y({iframe:c,origin:"https://"+I.get().connectDomain});i.observe((function(e){u.sendMessage({handler:j.ADAPTIVITY_CHANGE,params:{uuid:s,is_adaptive:e}}),e?(c.style.maxWidth="100%",c.style.top="auto",c.style.bottom="0"):(c.style.maxWidth="400px",c.style.top="0",c.style.bottom="auto"),c.style.display="none"})),document.body.appendChild(c);var d=function(){u.sendMessage({handler:G.RESIZE_FRAME,params:{uuid:s}})};window.addEventListener("resize",d);var l=function(){c&&(c.remove(),c=null),window.removeEventListener("resize",d),i&&i.destroy(),u.destroy()},h=new Promise((function(t){u.onMessage((function(o){if(o.params.uuid===s)switch(o.handler){case G.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:s,error:"not_authorized"}}),l(),t(o.handler);break;case G.RESIZE_FRAME:c.style.height="".concat(o.params.height,"px");break;case j.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:s}}),l();break;case j.ADAPTIVITY_CHANGED:c.style.display="block";break;case G.AUTH_DATA_LOADED:c.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,u,e)}}))}));return{getFrame:function(){return c},destroy:l,authReadyPromise:h}})),i(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=p(),i=D(K(r({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),a=e.container;a&&a.appendChild(i);var s=new Y({iframe:i,origin:"https://"+I.get().connectDomain}),c=function(){s.sendMessage({handler:G.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),s.destroy()},authReadyPromise:new Promise((function(t){s.onMessage((function(a){if(a.params.uuid===o)switch(a.handler){case G.RESIZE_FRAME:i.style.height="".concat(a.params.height,"px");break;case G.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&&s.sendMessage({handler:F.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){s.sendMessage({handler:x.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case G.AUTH_DATA_LOADED:t(a.handler);default:n.handleOneTapEvents(a,s,e)}}))}))}})),i(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case G.AUTH_DATA_LOADED:t.sendMessage({handler:G.RESIZE_FRAME,params:{uuid:i}});break;case G.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:r({uuid:i},e.params)});break;case G.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:W.CAPTCHA_SUCCESS,params:r({uuid:i},e)})})).catch((function(){t.sendMessage({handler:W.CAPTCHA_FAIL,params:{uuid:i}}),a.destroy()}));break;case V.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:V.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:V.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case G.FULL_AUTH_NEEDED:case G.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),i(this,"userDataPolicy",(function(e){var t=K({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=D(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(a);var s=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){s.onMessage((function(i){switch(i.handler){case V.HIDE_DATA_POLICY:c(),t();break;case V.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){s.sendMessage({handler:W.CAPTCHA_SUCCESS,params:r({uuid:e},n)}),a.style.display="block"})).catch((function(){s.sendMessage({handler:W.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(a),s.destroy()}}})),i(this,"userPolicyAgreements",(function(e){var t,o,i,a=K({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 "),D(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()}}})),i(this,"captcha",(function(e,n){var t=K(r({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=D(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}),s=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 W.CAPTCHA_SUCCESS:e(t.params),s();break;default:n(),s()}}))}))},destroy:s}})),i(this,"userVisibleAuth",(function(e){var t=p(),o=r({origin:location.protocol+"//"+location.host,uuid:t},U(e,["screen","source","action"])),i=L(null==e?void 0:e.action);i?o.action=i:delete o.action;var a=K(o);console.log("url",a),n.flags&&(a="".concat(a,"#").concat(T(n.flags)));var c=screen.height/2-280,u=screen.width/2-410,d=window.open(a,"_blank","top=".concat(c,",left=").concat(u,",width=").concat(820,",height=").concat(560,",location"));if(!d){var A={code:s.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:s.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 c={code:s.CONNECT_UNKNOWN_SDK_MESSAGE,reason:m(JSON.stringify(a.data))};n(c)}else{d.close();var p={code:s.CONNECT_DOMAIN_NOT_ALLOWED,reason:f(a.origin)};n(p)}}window.addEventListener("message",i)}))})),i(this,"redirectAuth",(function(e){var n=p(),t=r({redirect_uri:e.url,uuid:n},U(e,["state","screen","source","action"])),o=L(null==e?void 0:e.action);o?t.action=o:delete t.action;var i=K(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"}(Z||(Z={})),function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp"}(q||(q={}));var J,X=function e(n){var t=this;o(this,e),i(this,"events",void 0),i(this,"iframe",void 0),i(this,"bridge",void 0),i(this,"loading",void 0),i(this,"readyPromiseResolve",null),i(this,"readyPromise",null),i(this,"bodyOverflowValue",""),i(this,"params",void 0),i(this,"child",null),i(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(Z.OPEN),t.readyPromise})),i(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(Z.HIDE)})),i(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(Z.CLOSE)})),i(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(Z.SHOW)})),i(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.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})),i(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),i(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:q.SUPERAPP_TOKEN,params:{result:e}})})),i(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 q.SUPERAPP_TOKEN:I._requestSuperAppToken();break;case q.AUTH_NEEDED:I._requestAuth();break;default:t.events.emit(Z.MESSAGE,e)}})),i(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}})}})),i(this,"handleUpdateConfig",(function(){t.bridge.sendMessage({handler:z.APP_INIT_CONFIG,params:{fullMode:t.params.fullMode}})})),i(this,"getMiniAppUrl",(function(e,n){var o=I.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)})),i(this,"resolveReadyPromise",(function(){t.readyPromise&&t.readyPromiseResolve&&(t.readyPromiseResolve(),t.readyPromise=null,t.readyPromiseResolve=null)})),i(this,"openMiniapp",(function(n){t.child=new e({app:n.app_id}),t.events.emit(Z.CREATE_APP,{app:t.child,location:n.location})})),i(this,"openPayForm",(function(n){var o=r({},n.params);o.data&&(o.data=JSON.stringify(o.data));var i=r({},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(Z.MESSAGE,(function(e){t.handleVKPayFormMessage(e),a.close(),t.show()})),a.events.on(Z.HIDE,(function(){a.close(),t.close()}))})),i(this,"handleVKPayFormMessage",(function(e){e.handler===z.ACTION_DONE&&t.sendMessage(e)})),this.params=r({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=b()};!function(e){e.INIT="ConnectProfileInit"}(J||(J={}));var Q=function e(){var n=this;o(this,e),i(this,"iframe",void 0),i(this,"config",void 0),i(this,"bridge",void 0),i(this,"iframeLoadPromise",void 0),i(this,"load",(function(e){if(!e.container)throw new Error("container is null");if(!e)throw new Error(d());return n.iframe||n.preload(e),n.iframeLoadPromise})),i(this,"remove",(function(){n.iframe&&n.iframe.parentNode&&n.iframe.parentNode.removeChild(n.iframe),n.destroy()})),i(this,"preload",(function(e){n.config=e;var t=document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.minHeight="100%",e.container.appendChild(t),n.setup(t)})),i(this,"setup",(function(e){I.events.on("superAppToken",n.onSuperAppToken),e.src=n.getProfileUrl(),n.iframe=e,n.iframeLoadPromise=new Promise((function(n){e.onload=function(){return n(e)}})),n.bridge=new Y({iframe:n.iframe,origin:"https://"+I.get().connectDomain}),n.bridge.onMessage(n.handleMessage)})),i(this,"destroy",(function(){I.events.off("superAppToken",n.onSuperAppToken),n.bridge.destroy(),delete n.iframe,delete n.iframeLoadPromise,delete n.bridge})),i(this,"onSuperAppToken",(function(e){if(e&&n.iframe){var t=n.iframe;n.destroy(),n.setup(t)}})),i(this,"handleMessage",(function(e){switch(e.handler){case J.INIT:n.handleInitApp().catch(console.error);break;case q.SUPERAPP_TOKEN:I._requestSuperAppToken();break;case q.AUTH_NEEDED:I._requestAuth();break;case q.OPEN_APP:I._openApp(e.params)}})),i(this,"handleInitApp",(function(){return Promise.resolve()})),i(this,"getProfileUrl",(function(){var e=I.get(),t=e.connectDomain,o=e.appId,i=e.superAppToken,a=e._debug,r=n.config.widgets,s=T({host_app_id:o,debug:a?"1":"",localhost:a?"1":"",superapp_token:i,widgets:r?r.join(","):""});return"https://".concat(t,"/super_profile?").concat(s)}))},$={OneTapAuthEventsSDK:G,FloatingOneTapAuthEventsSDK:j,ButtonOneTapAuthEventsSDK:F,DataPolicyEventsSDK:V,AuthCaptchaEventsSDK:W};export{I as Config,B as Connect,$ as ConnectEvents,X as MiniApp,Z as MiniAppEvents,Q as Profile}; | ||
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,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(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 a(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?i(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var r,s="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",c=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=s[64*Math.random()|0];return n},p=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand","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"}(r||(r={}));var d=function(){return"No params passed for load app!"},u=function(){return"Connect window was closed."},l=function(){return"Connect window was not opened."},h=function(e){return'URL domain "'.concat(e,'" is not allowed.')},f=function(e){return"This SDK message is unknown: ".concat(e)},m=!("undefined"==typeof window||!window.document||!window.document.createElement),A=m&&!!window.addEventListener,g=function(){};if(A)try{var _=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",g,_),window.removeEventListener("test",g,_)}catch(e){}!function(){if(!m)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function E(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?E(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):E(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}var v={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 y(e){return v.stringify(e)}function T(e){return Object.keys(e).filter((function(e){return p.includes(e)}))}function w(e){var n;return Boolean(null===(n=T(e))||void 0===n?void 0:n.length)}function S(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 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 b={appId:0,superAppToken:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},C={},N={events:D(),init:function(e){if(!e.appId)throw new Error("appId required");b.appId=e.appId,b.superAppToken=e.superAppToken||"",b.loginDomain=e.loginDomain||"login.vk.com",b.oauthDomain=e.oauthDomain||"oauth.vk.com",b.connectDomain=e.connectDomain||"connect.vk.com",b.appSettings=e.appSettings,b._debug=!!e._debug},get:function(){return b},setSuperAppToken:function(e){b.superAppToken=e,N.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){C.superAppToken=e},_requestSuperAppToken:function(){var e;C.superAppToken&&(e=C.superAppToken()),e&&e.then((function(e){return N.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){C.auth=e},_requestAuth:function(){var e;C.auth&&(e=C.auth()),e&&e.then((function(e){return N.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){C.openApp=e},_openApp:function(e){C.openApp&&C.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 L;function M(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=N.get(),o=t.appId,i=t.connectDomain,r=t.appSettings,s=a({app_id:o,response_type:"silent_token",v:"0.0.2"},e);r&&w(r)&&(s.app_settings=S(r));var c=y(s);return"https://".concat(i,"/").concat(n,"?").concat(c)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(L||(L={}));var K=[L.Default,L.NamePhone,L.PhoneName];function R(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}var H,U,V,x,W,G,j=function e(n){var i=this;t(this,e),o(this,"handler",(function(){return{}})),o(this,"config",void 0),o(this,"destroy",(function(){delete i.config,window.removeEventListener("message",i.handleMessage)})),o(this,"onMessage",(function(e){i.handler=e})),o(this,"sendMessage",(function(e){i.config.iframe.contentWindow.postMessage(a({type:"vk-sak-sdk"},e),i.config.origin)})),o(this,"handleMessage",(function(e){i.config.origin&&e.origin===i.config.origin&&e.source===i.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&i.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"}(H||(H={})),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"}(U||(U={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(V||(V={})),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"}(x||(x={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(W||(W={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions",e.SHOW_AGREEMENTS_DIALOG="VKSDKButtonOneTapAuthShowAgreementsDialog",e.START_AUTHORIZE="VKSDKButtonOneTapAuthStartAuthorize"}(G||(G={}));var F,Y,z,Z=new function e(){var n=this;t(this,e),o(this,"flags",null),o(this,"silentAuth",(function(){var e=N.get(),n=e.loginDomain,t=e.appId,o=c(),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()}))})),o(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}})),o(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: 0;\n max-width: 100%;\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 s=c(),p=P(M(a({origin:location.protocol+"//"+location.host,uuid:s},r.pageUrlParams),r.pageUrl),{cssText:r.frameStyles}),d=new j({iframe:p,origin:"https://"+N.get().connectDomain});i.observe((function(e){d.sendMessage({handler:W.ADAPTIVITY_CHANGE,params:{uuid:s,is_adaptive:e}}),e?(p.style.maxWidth="100%",p.style.top="auto",p.style.bottom="0"):(p.style.maxWidth="400px",p.style.top="0",p.style.bottom="auto"),p.style.display="none"})),document.body.appendChild(p);var u=function(){d.sendMessage({handler:x.RESIZE_FRAME,params:{uuid:s}})};window.addEventListener("resize",u);var l=function(){p&&(p.remove(),p=null),window.removeEventListener("resize",u),i&&i.destroy(),d.destroy()},h=new Promise((function(t){d.onMessage((function(o){if(o.params.uuid===s)switch(o.handler){case x.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:s,error:"not_authorized"}}),l(),t(o.handler);break;case x.RESIZE_FRAME:p.style.height="".concat(o.params.height,"px");break;case W.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:s}}),l();break;case W.ADAPTIVITY_CHANGED:p.style.display="block";break;case x.AUTH_DATA_LOADED:p.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,d,e)}}))}));return{getFrame:function(){return p},destroy:l,authReadyPromise:h}})),o(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){n.display=e.displayMode&&K.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=R(e.showAgreements,0),n.show_alternative_login=R(e.showAlternativeLogin,0),n.show_agreements_dialog=R(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=c(),i=P(M(a({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),r=e.container;r&&r.appendChild(i);var s=new j({iframe:i,origin:"https://"+N.get().connectDomain}),p=function(){s.sendMessage({handler:x.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",p);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",p),s.destroy()},authReadyPromise:new Promise((function(t){s.onMessage((function(a){if(a.params.uuid===o)switch(a.handler){case x.RESIZE_FRAME:i.style.height="".concat(a.params.height,"px");break;case x.NOT_AUTHORIZED:t(a.handler);break;case G.SHOW_LOGIN:case G.SHOW_LOGIN_OPTIONS:e.callback({type:a.handler,payload:{uuid:o}});break;case G.SHOW_AGREEMENTS_DIALOG:n.userPolicyAgreements(o).show().then((function(e){e&&e.accepted&&s.sendMessage({handler:G.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){s.sendMessage({handler:U.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case x.AUTH_DATA_LOADED:t(a.handler);default:n.handleOneTapEvents(a,s,e)}}))}))}})),o(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case x.AUTH_DATA_LOADED:t.sendMessage({handler:x.RESIZE_FRAME,params:{uuid:i}});break;case x.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:a({uuid:i},e.params)});break;case x.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:V.CAPTCHA_SUCCESS,params:a({uuid:i},e)})})).catch((function(){t.sendMessage({handler:V.CAPTCHA_FAIL,params:{uuid:i}}),r.destroy()}));break;case H.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:H.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:H.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case x.FULL_AUTH_NEEDED:case x.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),o(this,"userDataPolicy",(function(e){var t=M({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=P(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(r);var s=new j({iframe:r,origin:"https://"+N.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 H.HIDE_DATA_POLICY:c(),t();break;case H.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){s.sendMessage({handler:V.CAPTCHA_SUCCESS,params:a({uuid:e},n)}),r.style.display="block"})).catch((function(){s.sendMessage({handler:V.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),s.destroy()}}})),o(this,"userPolicyAgreements",(function(e){var t,o,i,a=M({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 j({iframe:r,origin:"https://"+N.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 U.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case U.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case U.SHOW_DATA_POLICY:c();var a=function(){r.style.display="block"};n.userDataPolicy(e).show().then(a).catch(a);break;case U.POLICY_AGREEMENTS_ERROR:case U.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),s.destroy()}}})),o(this,"captcha",(function(e,n){var t=M(a({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 r=new j({iframe:i,origin:"https://"+N.get().connectDomain}),s=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 V.CAPTCHA_SUCCESS:e(t.params),s();break;default:n(),s()}}))}))},destroy:s}})),o(this,"userVisibleAuth",(function(e){var t=c(),o={origin:location.protocol+"//"+location.host,uuid:t};(null==e?void 0:e.screen)&&(o.screen=e.screen);var i=k(null==e?void 0:e.action);i&&(o.action=i);var a=M(o);n.flags&&(a="".concat(a,"#").concat(y(n.flags)));var s=screen.height/2-280,p=screen.width/2-410,d=window.open(a,"_blank","top=".concat(s,",left=").concat(p,",width=").concat(820,",height=").concat(560,",location"));if(!d){var m={code:r.CONNECT_WINDOW_NOT_OPENED,reason:l()};return Promise.reject(m)}return new Promise((function(e,n){var o=setInterval((function(){if(!d||d.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:r.CONNECT_WINDOW_CLOSED,reason:u()};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 s=a.data.payload;d.close(),e({provider:"vk",payload:s})}else if(a.data.action==="oauth_callback"+t)e({provider:a.data.payload.name}),d.close();else{d.close();var c={code:r.CONNECT_UNKNOWN_SDK_MESSAGE,reason:f(JSON.stringify(a.data))};n(c)}else{d.close();var p={code:r.CONNECT_DOMAIN_NOT_ALLOWED,reason:h(a.origin)};n(p)}}window.addEventListener("message",i)}))})),o(this,"redirectAuth",(function(e){var n=c(),t={redirect_uri:e.url,uuid:n};(null==e?void 0:e.state)&&(t.redirect_state=e.state),(null==e?void 0:e.screen)&&(t.screen=e.screen);var o=k(null==e?void 0:e.action);o&&(t.action=o);var i=M(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"}(F||(F={})),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"}(z||(z={}));var q,B=function e(n){var i=this;t(this,e),o(this,"events",void 0),o(this,"iframe",void 0),o(this,"bridge",void 0),o(this,"loading",void 0),o(this,"readyPromiseResolve",null),o(this,"readyPromise",null),o(this,"bodyOverflowValue",""),o(this,"params",void 0),o(this,"child",null),o(this,"open",(function(e,n){return i.loading?(i.iframe.src=i.getMiniAppUrl(e,n),i.loading=new Promise((function(e){i.iframe.onload=function(){i.iframe.onload=null,e()}})),i.readyPromise=new Promise((function(e){return i.readyPromiseResolve=e}))):i.preload(e,n).catch(console.error),i.iframe.style.display="block",i.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",i.loading.then(i.handleResize).catch(console.error),i.events.emit(Y.OPEN),i.readyPromise})),o(this,"hide",(function(){i.iframe.style.display="none",window.document.body.style.overflow=i.bodyOverflowValue,i.events.emit(Y.HIDE)})),o(this,"close",(function(){window.document.body.style.overflowX="",N.events.off("superAppToken",i.onSuperAppToken),i.iframe&&i.iframe.remove(),i.bridge&&i.bridge.destroy(),delete i.iframe,delete i.bridge,window.removeEventListener("resize",i.handleResize),i.events.emit(Y.CLOSE)})),o(this,"show",(function(){if(!i.loading)throw new Error('App is not loaded, use "open" or "preload" methods');i.iframe.style.display="block",window.document.body.style.overflow=i.bodyOverflowValue,i.events.emit(Y.SHOW)})),o(this,"preload",(function(e,n){var t=document.createElement("iframe"),o=window.innerHeight,a=isFinite(i.params.zIndex)?i.params.zIndex:999999;return t.src=i.getMiniAppUrl(e,n),t.style.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: ").concat(a,";\n "),i.iframe=t,document.body.appendChild(i.iframe),N.events.on("superAppToken",i.onSuperAppToken),i.bridge=new j({iframe:i.iframe,origin:"https://"+N.get().connectDomain}),i.bridge.onMessage(i.handleMessage),window.addEventListener("resize",i.handleResize),i.loading=new Promise((function(e){t.onload=function(){t.onload=null,e()}})),i.readyPromise=new Promise((function(e){return i.readyPromiseResolve=e})),i.loading})),o(this,"sendMessage",(function(e){i.bridge.sendMessage(e)})),o(this,"onSuperAppToken",(function(e){i.bridge.sendMessage({handler:z.SUPERAPP_TOKEN,params:{result:e}})})),o(this,"handleMessage",(function(e){switch(e.handler){case F.APP_CLOSE:i.hide();break;case F.APP_READY:i.resolveReadyPromise(),i.handleUpdateConfig();break;case F.OPEN_APP:i.openMiniapp(e.params);break;case F.OPEN_PAY_FORM:i.openPayForm(e.params);break;case z.SUPERAPP_TOKEN:N._requestSuperAppToken();break;case z.AUTH_NEEDED:N._requestAuth();break;default:i.events.emit(Y.MESSAGE,e)}})),o(this,"handleResize",(function(){if(i.iframe){var e=innerWidth,n=innerHeight;i.iframe.style.height="".concat(n,"px"),i.iframe.style.minHeight="".concat(n,"px"),i.bridge.sendMessage({handler:F.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),o(this,"handleUpdateConfig",(function(){i.bridge.sendMessage({handler:F.APP_INIT_CONFIG,params:{fullMode:i.params.fullMode}})})),o(this,"getMiniAppUrl",(function(e,n){var t=N.get(),o=t.connectDomain,a=t.appId,r=t.superAppToken,s=t._debug,c=y({app:i.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(o,"/mini_app?").concat(c)})),o(this,"resolveReadyPromise",(function(){i.readyPromise&&i.readyPromiseResolve&&(i.readyPromiseResolve(),i.readyPromise=null,i.readyPromiseResolve=null)})),o(this,"openMiniapp",(function(n){i.child=new e({app:n.app_id}),i.events.emit(Y.CREATE_APP,{app:i.child,location:n.location})})),o(this,"openPayForm",(function(n){var t=a({},n.params);t.data&&(t.data=JSON.stringify(t.data));var o=a({},t,{app_id:n.app_id,action:n.action}),r=new e({app:6217559});r.open(o).then((function(){return i.hide()})).catch(console.error),r.events.on(Y.MESSAGE,(function(e){i.handleVKPayFormMessage(e),r.close(),i.show()})),r.events.on(Y.HIDE,(function(){r.close(),i.close()}))})),o(this,"handleVKPayFormMessage",(function(e){e.handler===F.ACTION_DONE&&i.sendMessage(e)})),this.params=a({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=D()};!function(e){e.INIT="ConnectProfileInit"}(q||(q={}));var J=function e(){var n=this;t(this,e),o(this,"iframe",void 0),o(this,"config",void 0),o(this,"bridge",void 0),o(this,"iframeLoadPromise",void 0),o(this,"load",(function(e){if(!e.container)throw new Error("container is null");if(!e)throw new Error(d());return n.iframe||n.preload(e),n.iframeLoadPromise})),o(this,"remove",(function(){n.iframe&&n.iframe.parentNode&&n.iframe.parentNode.removeChild(n.iframe),n.destroy()})),o(this,"preload",(function(e){n.config=e;var t=document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.minHeight="100%",e.container.appendChild(t),n.setup(t)})),o(this,"setup",(function(e){N.events.on("superAppToken",n.onSuperAppToken),e.src=n.getProfileUrl(),n.iframe=e,n.iframeLoadPromise=new Promise((function(n){e.onload=function(){return n(e)}})),n.bridge=new j({iframe:n.iframe,origin:"https://"+N.get().connectDomain}),n.bridge.onMessage(n.handleMessage)})),o(this,"destroy",(function(){N.events.off("superAppToken",n.onSuperAppToken),n.bridge.destroy(),delete n.iframe,delete n.iframeLoadPromise,delete n.bridge})),o(this,"onSuperAppToken",(function(e){if(e&&n.iframe){var t=n.iframe;n.destroy(),n.setup(t)}})),o(this,"handleMessage",(function(e){switch(e.handler){case q.INIT:n.handleInitApp().catch(console.error);break;case z.SUPERAPP_TOKEN:N._requestSuperAppToken();break;case z.AUTH_NEEDED:N._requestAuth();break;case z.OPEN_APP:N._openApp(e.params)}})),o(this,"handleInitApp",(function(){return Promise.resolve()})),o(this,"getProfileUrl",(function(){var e=N.get(),t=e.connectDomain,o=e.appId,i=e.superAppToken,a=e._debug,r=n.config.widgets,s=y({host_app_id:o,debug:a?"1":"",localhost:a?"1":"",superapp_token:i,widgets:r?r.join(","):""});return"https://".concat(t,"/super_profile?").concat(s)}))},X={OneTapAuthEventsSDK:x,FloatingOneTapAuthEventsSDK:W,ButtonOneTapAuthEventsSDK:G,DataPolicyEventsSDK:H,AuthCaptchaEventsSDK:V};export{N as Config,Z as Connect,X as ConnectEvents,B as MiniApp,Y as MiniAppEvents,J as Profile}; |
{ | ||
"name": "@vkontakte/superappkit", | ||
"version": "1.18.0-beta.1.0", | ||
"version": "1.18.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
631
2
70607