@liff/sub-window
Advanced tools
Comparing version 2.16.1 to 2.17.0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@liff/consts"),r=require("@liff/util"),t=require("@liff/is-in-client"),n=require("@liff/is-api-available"),i=require("tslib"),o=require("@liff/logger"),s=require("@liff/get-os"),a=require("@liff/server-api"),u=require("@liff/store"),c=require("@liff/is-sub-window"),f=require("@liff/close-window");function l(e){var r=a.getEndPoint("subWindowGetOrigin");return a.fetch(r(e))}var d={};function _(e,r){e&&d[e]&&d[e].forEach((function(e){e(r)}))}var S,I,g,m,h=function(){function t(e){this.storage=e}return t.prototype.getItem=function(e){return this.storage.getItem(this.getKeyPrefix()+":"+e)},t.prototype.setItem=function(e,r){this.storage.setItem(this.getKeyPrefix()+":"+e,r)},t.prototype.removeItem=function(e){this.storage.removeItem(this.getKeyPrefix()+":"+e)},t.prototype.clear=function(){this.storage.clear()},t.prototype.getKeyPrefix=function(){return e.STORE_KEY+":"+this.getLiffId()},t.prototype.getLiffId=function(){var t=u.getConfig().liffId;if(!t)throw r.createLiffError(e.INVALID_CONFIG,"liffId is necessary for liff.init()");return t},t}(),w=new h(r.inMemoryStorage);function E(){var e=w.getItem("subWindowStatusUpdated");return null!==e&&JSON.parse(e)}function p(e){w.setItem("subWindowStatusUpdated",String(e))}function v(e){S=e}function N(){return S}function O(){return g}var T=new h(window.sessionStorage);function U(){return T.getItem("mainWindowOrigin")}function W(t,n){return void 0===n&&(n={}),i.__awaiter(this,void 0,void 0,(function(){var s,a,c,f,d,_,S;return i.__generator(this,(function(i){switch(i.label){case 0:if(s=u.getConfig().liffId,a=U(),!window.opener||!a||!s)throw r.createLiffError(e.EXCEPTION_IN_SUBWINDOW);c=!1,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,l(s)];case 2:return f=i.sent(),c=f.subwindowCommonModule,[3,4];case 3:throw d=i.sent(),o.logger.debug(d),r.createLiffError(e.EXCEPTION_IN_SUBWINDOW);case 4:return _=JSON.stringify(n),S=c?a:location.origin,window.opener.postMessage({status:t,result:_},S),[2,{status:t,result:_}]}}))}))}function L(r){var t=m;if(r.origin===t){var n=r.data;if(n){var i,s=n.status,a=n.result;try{i=JSON.parse(a||"{}")}catch(u){i={}}switch(s){case e.SUB_WINDOW_HEALTH_CHECK_MESSAGE:window.clearInterval(O());break;case e.SUB_WINDOW_CANCEL_STATUS:case e.SUB_WINDOW_SUBMIT_STATUS:p(!0),window.clearInterval(O()),window.removeEventListener("message",L),_(s,i);break;default:o.logger.debug("unexpected message")}}}}function b(){window.clearInterval(I),window.clearInterval(O()),window.removeEventListener("message",L)}function A(t){var n=r.extractLiffId(t.url);if(!n)return Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"params.url must be liff url"));!function(){b(),p(!1);var e=N();e&&(e.close(),v(null))}();var o,a,u,c,f=t.url,d=t.appData,S=new URL(f);S.searchParams.append(e.SUB_WINDOW_IDNTIFICATION_KEY,"true"),S.hostname=(o=S.hostname,a=i.__read(o.split(".")),u=a[0],c=a.slice(1),i.__spread([u+"-ext"],c).join("."));var h=S.toString();return v("ios"!==s.getOS()||r.isIpad()?window.open("","liffsubwindow","width=480, height=640, menubar=no, toolbar=no, scrollbars=yes"):window.open()),l(n).then((function(t){var n,i=t.origin,o=t.subwindowCommonModule,s=N();if(!s)throw r.createLiffError(e.CREATE_SUBWINDOW_FAILED);o?(!function(e){m=e}(i),window.addEventListener("message",L),s.location.href=h,n=function(r,t){var n=N(),i={type:e.SUB_WINDOW_HEALTH_CHECK_MESSAGE};return t&&(i.message=JSON.stringify(t)),window.setInterval((function(){null==n||n.postMessage(i,r)}),e.SUB_WINDOW_HEALTH_CHECK_INTERVAL)}(i,d),g=n,function(e){I=e}(window.setInterval((function(){var r=N();r&&r.closed&&(b(),v(null),!1===E()&&(p(!0),_(e.SUB_WINDOW_CLOSE_STATUS,{})))}),e.SUB_WINDOW_MONITOR_CLOSE_INTERVAL))):s.close()}))}function D(t){return i.__awaiter(this,void 0,void 0,(function(){var n,o,s,u,c,f,l,d,_,S,I;return i.__generator(this,(function(i){switch(i.label){case 0:n=t.msit,o=t.mstChallenge,s=t.onSuccess,u=t.onError,c=t.reconnectCount,f=void 0===c?0:c,i.label=1;case 1:return i.trys.push([1,3,,6]),[4,a.requestWithoutErrorHandling(a.getEndPoint("subWindowSubscribe"),{method:"POST",body:JSON.stringify({msit:n,mstChallenge:o})})];case 2:return l=i.sent(),[3,6];case 3:return i.sent(),[4,C()];case 4:return i.sent(),[4,P(D,{msit:n,mstChallenge:o,onSuccess:s,onError:u,reconnectCount:f+=1})];case 5:return i.sent(),[2];case 6:return l.status>=500?[4,C()]:[3,9];case 7:return i.sent(),[4,P(D,{msit:n,mstChallenge:o,onSuccess:s,onError:u,reconnectCount:f+=1})];case 8:return i.sent(),[3,20];case 9:return l.status>=400&&500>l.status?[4,y(l)]:[3,11];case 10:return(_=i.sent())?(d=_.errorDetail,u(r.createLiffError(e.INVALID_ARGUMENT,d))):u(r.createLiffError(e.UNKNOWN,"Some error happened in the server")),[3,20];case 11:return 200!==l.status?[3,19]:[4,y(l)];case 12:return(_=i.sent())?[3,13]:(u(r.createLiffError(e.UNKNOWN,"Some error happened in the server")),[3,18]);case 13:switch(S=_.status,I=_.result,S){case e.SUB_WINDOW_ERROR_STATUS:return[3,14];case e.SUB_WINDOW_CLOSE_STATUS:case e.SUB_WINDOW_CANCEL_STATUS:case e.SUB_WINDOW_SUBMIT_STATUS:return[3,16]}return[3,17];case 14:return[4,P(D,{msit:n,mstChallenge:o,onSuccess:s,onError:u,reconnectCount:f})];case 15:return i.sent(),[3,18];case 16:return s(S,I),[3,18];case 17:u(r.createLiffError(e.UNKNOWN,"Some error happened in the server")),i.label=18;case 18:return[3,20];case 19:u(r.createLiffError(e.UNKNOWN,"Some error happened in the server")),i.label=20;case 20:return[2]}}))}))}function C(){return new Promise((function(e){return setTimeout(e,1e3)}))}function y(e){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.json()];case 1:return[2,r.sent()];case 2:return r.sent(),[2,null];case 3:return[2]}}))}))}function P(t,n){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(i){switch(i.label){case 0:return n.reconnectCount>=10?(n.onError(r.createLiffError(e.UNKNOWN,"Failed to connect")),[3,3]):[3,1];case 1:return[4,t(n)];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))}function B(e){var r={};return Object.keys(e).forEach((function(t){"closeButtonColor"===t?"white"===e[t]?r[t]="#ffffff":r[t]="#000000":r[t]=e[t]})),r}var M={height:"full",closeButtonPosition:"right",closeButtonColor:"black",closeButtonLabel:""};function R(t){var n=t.appData,i=t.native,o=u.getConfig().liffId,s=u.getMSTChallenge(),c=r.extractLiffId(t.url);if(!o)return Promise.reject(r.createLiffError(e.UNAUTHORIZED,"liffId is invalid"));if(!s)return Promise.reject(r.createLiffError(e.UNAUTHORIZED,"mst_challenge is invalid"));if(!c)return Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"params.url must be liff url"));var f=Object.assign({},M,i);return function(t){var n=t.mainLiffId,i=t.subLiffId,o=t.mstChallenge,s=t.appData,u=t.view;return n&&o?a.fetch(a.getEndPoint("subWindowGetMSIT"),{method:"POST",body:JSON.stringify({mainLiffId:n,subLiffId:i,mstChallenge:o,appData:s,view:u})}):Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"no proper argument"))}({mainLiffId:o,subLiffId:c,mstChallenge:s,appData:n,view:B(f)}).then((function(r){var n=r.msit;D({msit:n,mstChallenge:s,onSuccess:function(e,r){_(e,r)},onError:function(r){_(e.SUB_WINDOW_ERROR_STATUS,r)}}),function(r,t){var n=r.url,i=new URLSearchParams;i.set("msit",t),location.href=e.SUB_WINDOW_MODAL_SCHEME_URL+"?url="+encodeURIComponent(n)+"&"+i.toString()}(t,n)}))}function H(){if(!c.isSubWindow())throw r.createLiffError(e.UNAUTHORIZED,"this api can be only called in child window")}function j(t){if(!t.mst||!t.status)return Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"no proper argument"));var n=JSON.stringify(t);return a.fetch(a.getEndPoint("subWindowPost"),{method:"POST",body:n})}var x={on:function(e,r){d[e]||(d[e]=[]),d[e].push(r)},off:function(e,r){if(d[e]){var t=d[e].indexOf(r);t>=0&&d[e].splice(t,1)}},open:function(i){if(!n.isApiAvailable("subwindowOpen"))throw r.createLiffError(e.FORBIDDEN,"No permission for liff.subWindow.open()");return function(){if(c.isSubWindow())throw r.createLiffError(e.UNAUTHORIZED,"this api can be only called in parent window")}(),t.isInClient()?R(i):A(i)},cancel:function(n){return void 0===n&&(n={}),H(),t.isInClient()?function(t){return void 0===t&&(t={}),i.__awaiter(this,void 0,void 0,(function(){var n,o;return i.__generator(this,(function(i){switch(i.label){case 0:return(n=u.getMST())?[4,j({mst:n,status:e.SUB_WINDOW_CANCEL_STATUS,result:t})]:[2,Promise.reject(r.createLiffError(e.UNAUTHORIZED,"mst is invalid"))];case 1:return o=i.sent(),p(!0),[2,o]}}))}))}(n):function(r){return void 0===r&&(r={}),W(e.SUB_WINDOW_CANCEL_STATUS,r)}(n)},submit:function(n){return void 0===n&&(n={}),H(),t.isInClient()?function(t){return void 0===t&&(t={}),i.__awaiter(this,void 0,void 0,(function(){var n,o;return i.__generator(this,(function(i){switch(i.label){case 0:return(n=u.getMST())?[4,j({mst:n,status:e.SUB_WINDOW_SUBMIT_STATUS,result:t})]:[2,Promise.reject(r.createLiffError(e.UNAUTHORIZED,"mst is invalid"))];case 1:return o=i.sent(),p(!0),[2,o]}}))}))}(n):function(r){return void 0===r&&(r={}),W(e.SUB_WINDOW_SUBMIT_STATUS,r)}(n)},close:function(){return H(),t.isInClient()?function(){return i.__awaiter(this,void 0,void 0,(function(){var t;return i.__generator(this,(function(n){switch(n.label){case 0:return!1!==E()?[3,2]:(t=u.getMST())?[4,j({mst:t,status:e.SUB_WINDOW_CLOSE_STATUS,result:{}})]:[2,Promise.reject(r.createLiffError(e.UNAUTHORIZED,"mst is invalid"))];case 1:n.sent(),n.label=2;case 2:return f.closeWindow(),[2]}}))}))}():(f.closeWindow(),Promise.resolve())},getAppData:function(){return H(),function(){var e,r=u.getAppData();try{e=r?JSON.parse(r):{}}catch(t){e={}}return Promise.resolve(e)}()}};exports.getAppData=function(t){var n=t.mst;return n?a.fetch(a.getEndPoint("subWindowGetAppData"),{method:"POST",body:JSON.stringify({mst:n})}):Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"no proper argument"))},exports.getMSTByMSIT=function(t){var n=t.msit,i=t.mstVerifier;return n&&i?a.fetch(a.getEndPoint("subWindowGetMSTByMSIT"),{method:"POST",body:JSON.stringify({msit:n,mstVerifier:i})}):Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"no proper argument"))},exports.getMainWindowOrigin=U,exports.setMainWindowOrigin=function(e){T.setItem("mainWindowOrigin",e)},exports.subWindow=x; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@liff/consts"),r=require("@liff/util"),t=require("@liff/is-in-client"),n=require("@liff/is-api-available"),i=require("tslib"),o=require("@liff/logger"),s=require("@liff/get-os"),a=require("@liff/server-api"),u=require("@liff/store"),c=require("@liff/is-sub-window"),f=require("@liff/close-window");function l(e){var r=a.getEndPoint("subWindowGetOrigin");return a.fetch(r(e))}var d={};function _(e,r){e&&d[e]&&d[e].forEach((function(e){e(r)}))}var S,I,g,m,w=function(){function t(e){this.storage=e}return t.prototype.getItem=function(e){return this.storage.getItem(this.getKeyPrefix()+":"+e)},t.prototype.setItem=function(e,r){this.storage.setItem(this.getKeyPrefix()+":"+e,r)},t.prototype.removeItem=function(e){this.storage.removeItem(this.getKeyPrefix()+":"+e)},t.prototype.clear=function(){this.storage.clear()},t.prototype.getKeyPrefix=function(){return e.STORE_KEY+":"+this.getLiffId()},t.prototype.getLiffId=function(){var t=u.getConfig().liffId;if(!t)throw r.createLiffError(e.INVALID_CONFIG,"liffId is necessary for liff.init()");return t},t}(),h=new w(r.inMemoryStorage);function p(){var e=h.getItem("subWindowStatusUpdated");return null!==e&&JSON.parse(e)}function E(e){h.setItem("subWindowStatusUpdated",String(e))}function v(e){S=e}function N(){return S}function O(){return g}function T(){return m}var U=new w(window.sessionStorage);function W(){return U.getItem("mainWindowOrigin")}function L(t,n){return void 0===n&&(n={}),i.__awaiter(this,void 0,void 0,(function(){var s,a,c,f,d,_,S;return i.__generator(this,(function(i){switch(i.label){case 0:if(s=u.getConfig().liffId,a=W(),!window.opener||!a||!s)throw r.createLiffError(e.EXCEPTION_IN_SUBWINDOW);c=!1,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,l(s)];case 2:return f=i.sent(),c=f.subwindowCommonModule,[3,4];case 3:throw d=i.sent(),o.logger.debug(d),r.createLiffError(e.EXCEPTION_IN_SUBWINDOW);case 4:return _=JSON.stringify(n),S=c?a:location.origin,[2,new Promise((function(r){window.addEventListener("message",(function n(i){(function(r){if(r.data&&"string"==typeof r.data.type&&[e.SUB_WINDOW_SUBMIT_STATUS,e.SUB_WINDOW_CANCEL_STATUS].includes(r.data.type))return!0;return!1})(i)&&(window.removeEventListener("message",n),r({status:t,result:_}))})),window.opener.postMessage({status:t,result:_},S)}))]}}))}))}function b(r){var t,n=T();if(r.origin===n){var i=r.data;if(i){var s,a=i.status,u=i.result;try{s=JSON.parse(u||"{}")}catch(c){s={}}switch(a){case e.SUB_WINDOW_HEALTH_CHECK_MESSAGE:window.clearInterval(O());break;case e.SUB_WINDOW_CANCEL_STATUS:case e.SUB_WINDOW_SUBMIT_STATUS:E(!0),window.clearInterval(O()),window.removeEventListener("message",b),_(a,s),null===(t=N())||void 0===t||t.postMessage({type:a},T());break;default:o.logger.debug("unexpected message")}}}}function A(){window.clearInterval(I),window.clearInterval(O()),window.removeEventListener("message",b)}function D(t){var n=r.extractLiffId(t.url);if(!n)return Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"params.url must be liff url"));!function(){A(),E(!1);var e=N();e&&(e.close(),v(null))}();var o,a,u,c,f=t.url,d=t.appData,S=new URL(f);S.searchParams.append(e.SUB_WINDOW_IDNTIFICATION_KEY,"true"),S.hostname=(o=S.hostname,a=i.__read(o.split(".")),u=a[0],c=a.slice(1),i.__spread([u+"-ext"],c).join("."));var w=S.toString();return v("ios"!==s.getOS()||r.isIpad()?window.open("","liffsubwindow","width=480, height=640, menubar=no, toolbar=no, scrollbars=yes"):window.open()),l(n).then((function(t){var n,i=t.origin,o=t.subwindowCommonModule,s=N();if(!s)throw r.createLiffError(e.CREATE_SUBWINDOW_FAILED);o?(!function(e){m=e}(i),window.addEventListener("message",b),s.location.href=w,n=function(r,t){var n=N(),i={type:e.SUB_WINDOW_HEALTH_CHECK_MESSAGE};return t&&(i.message=JSON.stringify(t)),window.setInterval((function(){null==n||n.postMessage(i,r)}),e.SUB_WINDOW_HEALTH_CHECK_INTERVAL)}(i,d),g=n,function(e){I=e}(window.setInterval((function(){var r=N();r&&r.closed&&(A(),v(null),!1===p()&&(E(!0),_(e.SUB_WINDOW_CLOSE_STATUS,{})))}),e.SUB_WINDOW_MONITOR_CLOSE_INTERVAL))):s.close()}))}function C(t){return i.__awaiter(this,void 0,void 0,(function(){var n,o,s,u,c,f,l,d,_,S,I;return i.__generator(this,(function(i){switch(i.label){case 0:n=t.msit,o=t.mstChallenge,s=t.onSuccess,u=t.onError,c=t.reconnectCount,f=void 0===c?0:c,i.label=1;case 1:return i.trys.push([1,3,,6]),[4,a.requestWithoutErrorHandling(a.getEndPoint("subWindowSubscribe"),{method:"POST",body:JSON.stringify({msit:n,mstChallenge:o})})];case 2:return l=i.sent(),[3,6];case 3:return i.sent(),[4,y()];case 4:return i.sent(),[4,B(C,{msit:n,mstChallenge:o,onSuccess:s,onError:u,reconnectCount:f+=1})];case 5:return i.sent(),[2];case 6:return l.status>=500?[4,y()]:[3,9];case 7:return i.sent(),[4,B(C,{msit:n,mstChallenge:o,onSuccess:s,onError:u,reconnectCount:f+=1})];case 8:return i.sent(),[3,20];case 9:return l.status>=400&&500>l.status?[4,P(l)]:[3,11];case 10:return(_=i.sent())?(d=_.errorDetail,u(r.createLiffError(e.INVALID_ARGUMENT,d))):u(r.createLiffError(e.UNKNOWN,"Some error happened in the server")),[3,20];case 11:return 200!==l.status?[3,19]:[4,P(l)];case 12:return(_=i.sent())?[3,13]:(u(r.createLiffError(e.UNKNOWN,"Some error happened in the server")),[3,18]);case 13:switch(S=_.status,I=_.result,S){case e.SUB_WINDOW_ERROR_STATUS:return[3,14];case e.SUB_WINDOW_CLOSE_STATUS:case e.SUB_WINDOW_CANCEL_STATUS:case e.SUB_WINDOW_SUBMIT_STATUS:return[3,16]}return[3,17];case 14:return[4,B(C,{msit:n,mstChallenge:o,onSuccess:s,onError:u,reconnectCount:f})];case 15:return i.sent(),[3,18];case 16:return s(S,I),[3,18];case 17:u(r.createLiffError(e.UNKNOWN,"Some error happened in the server")),i.label=18;case 18:return[3,20];case 19:u(r.createLiffError(e.UNKNOWN,"Some error happened in the server")),i.label=20;case 20:return[2]}}))}))}function y(){return new Promise((function(e){return setTimeout(e,1e3)}))}function P(e){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.json()];case 1:return[2,r.sent()];case 2:return r.sent(),[2,null];case 3:return[2]}}))}))}function B(t,n){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(i){switch(i.label){case 0:return n.reconnectCount>=10?(n.onError(r.createLiffError(e.UNKNOWN,"Failed to connect")),[3,3]):[3,1];case 1:return[4,t(n)];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))}function M(e){var r={};return Object.keys(e).forEach((function(t){"closeButtonColor"===t?"white"===e[t]?r[t]="#ffffff":r[t]="#000000":r[t]=e[t]})),r}var R={height:"full",closeButtonPosition:"right",closeButtonColor:"black",closeButtonLabel:""};function H(t){var n=t.appData,i=t.native,o=u.getConfig().liffId,s=u.getMSTChallenge(),c=r.extractLiffId(t.url);if(!o)return Promise.reject(r.createLiffError(e.UNAUTHORIZED,"liffId is invalid"));if(!s)return Promise.reject(r.createLiffError(e.UNAUTHORIZED,"mst_challenge is invalid"));if(!c)return Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"params.url must be liff url"));var f=Object.assign({},R,i);return function(t){var n=t.mainLiffId,i=t.subLiffId,o=t.mstChallenge,s=t.appData,u=t.view;return n&&o?a.fetch(a.getEndPoint("subWindowGetMSIT"),{method:"POST",body:JSON.stringify({mainLiffId:n,subLiffId:i,mstChallenge:o,appData:s,view:u})}):Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"no proper argument"))}({mainLiffId:o,subLiffId:c,mstChallenge:s,appData:n,view:M(f)}).then((function(r){var n=r.msit;C({msit:n,mstChallenge:s,onSuccess:function(e,r){_(e,r)},onError:function(r){_(e.SUB_WINDOW_ERROR_STATUS,r)}}),function(r,t){var n=r.url,i=new URLSearchParams;i.set("msit",t),location.href=e.SUB_WINDOW_MODAL_SCHEME_URL+"?url="+encodeURIComponent(n)+"&"+i.toString()}(t,n)}))}function j(){if(!c.isSubWindow())throw r.createLiffError(e.UNAUTHORIZED,"this api can be only called in child window")}function x(t){if(!t.mst||!t.status)return Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"no proper argument"));var n=JSON.stringify(t);return a.fetch(a.getEndPoint("subWindowPost"),{method:"POST",body:n})}var G={on:function(e,r){d[e]||(d[e]=[]),d[e].push(r)},off:function(e,r){if(d[e]){var t=d[e].indexOf(r);t>=0&&d[e].splice(t,1)}},open:function(i){if(!n.isApiAvailable("subwindowOpen"))throw r.createLiffError(e.FORBIDDEN,"No permission for liff.subWindow.open()");return function(){if(c.isSubWindow())throw r.createLiffError(e.UNAUTHORIZED,"this api can be only called in parent window")}(),t.isInClient()?H(i):D(i)},cancel:function(n){return void 0===n&&(n={}),j(),t.isInClient()?function(t){return void 0===t&&(t={}),i.__awaiter(this,void 0,void 0,(function(){var n,o;return i.__generator(this,(function(i){switch(i.label){case 0:return(n=u.getMST())?[4,x({mst:n,status:e.SUB_WINDOW_CANCEL_STATUS,result:t})]:[2,Promise.reject(r.createLiffError(e.UNAUTHORIZED,"mst is invalid"))];case 1:return o=i.sent(),E(!0),[2,o]}}))}))}(n):function(r){return void 0===r&&(r={}),L(e.SUB_WINDOW_CANCEL_STATUS,r)}(n)},submit:function(n){return void 0===n&&(n={}),j(),t.isInClient()?function(t){return void 0===t&&(t={}),i.__awaiter(this,void 0,void 0,(function(){var n,o;return i.__generator(this,(function(i){switch(i.label){case 0:return(n=u.getMST())?[4,x({mst:n,status:e.SUB_WINDOW_SUBMIT_STATUS,result:t})]:[2,Promise.reject(r.createLiffError(e.UNAUTHORIZED,"mst is invalid"))];case 1:return o=i.sent(),E(!0),[2,o]}}))}))}(n):function(r){return void 0===r&&(r={}),L(e.SUB_WINDOW_SUBMIT_STATUS,r)}(n)},close:function(){return j(),t.isInClient()?function(){return i.__awaiter(this,void 0,void 0,(function(){var t;return i.__generator(this,(function(n){switch(n.label){case 0:return!1!==p()?[3,2]:(t=u.getMST())?[4,x({mst:t,status:e.SUB_WINDOW_CLOSE_STATUS,result:{}})]:[2,Promise.reject(r.createLiffError(e.UNAUTHORIZED,"mst is invalid"))];case 1:n.sent(),n.label=2;case 2:return f.closeWindow(),[2]}}))}))}():(f.closeWindow(),Promise.resolve())},getAppData:function(){return j(),function(){var e,r=u.getAppData();try{e=r?JSON.parse(r):{}}catch(t){e={}}return Promise.resolve(e)}()}};exports.getAppData=function(t){var n=t.mst;return n?a.fetch(a.getEndPoint("subWindowGetAppData"),{method:"POST",body:JSON.stringify({mst:n})}):Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"no proper argument"))},exports.getMSTByMSIT=function(t){var n=t.msit,i=t.mstVerifier;return n&&i?a.fetch(a.getEndPoint("subWindowGetMSTByMSIT"),{method:"POST",body:JSON.stringify({msit:n,mstVerifier:i})}):Promise.reject(r.createLiffError(e.INVALID_ARGUMENT,"no proper argument"))},exports.getMainWindowOrigin=W,exports.setMainWindowOrigin=function(e){U.setItem("mainWindowOrigin",e)},exports.subWindow=G; |
@@ -1,1 +0,1 @@ | ||
import{STORE_KEY as e,INVALID_CONFIG as t,EXCEPTION_IN_SUBWINDOW as n,INVALID_ARGUMENT as r,SUB_WINDOW_IDNTIFICATION_KEY as i,CREATE_SUBWINDOW_FAILED as o,SUB_WINDOW_HEALTH_CHECK_INTERVAL as s,SUB_WINDOW_MONITOR_CLOSE_INTERVAL as u,SUB_WINDOW_SUBMIT_STATUS as a,SUB_WINDOW_CANCEL_STATUS as c,SUB_WINDOW_HEALTH_CHECK_MESSAGE as f,SUB_WINDOW_CLOSE_STATUS as l,UNKNOWN as m,SUB_WINDOW_ERROR_STATUS as d,UNAUTHORIZED as p,SUB_WINDOW_MODAL_SCHEME_URL as h,FORBIDDEN as v}from"@liff/consts";import{createLiffError as w,inMemoryStorage as g,extractLiffId as b,isIpad as S}from"@liff/util";import{isInClient as y}from"@liff/is-in-client";import{isApiAvailable as I}from"@liff/is-api-available";import{__awaiter as P,__generator as O,__spread as C,__read as j}from"tslib";import{logger as L}from"@liff/logger";import{getOS as E}from"@liff/get-os";import{fetch as N,getEndPoint as W,requestWithoutErrorHandling as J}from"@liff/server-api";import{getConfig as D,getMSTChallenge as T,getMST as x,getAppData as M}from"@liff/store";import{isSubWindow as B}from"@liff/is-sub-window";import{closeWindow as U}from"@liff/close-window";function k(e){var t=W("subWindowGetOrigin");return N(t(e))}var G={};function K(e,t){e&&G[e]&&G[e].forEach((function(e){e(t)}))}var A,R,V,F,_=function(){function n(e){this.storage=e}return n.prototype.getItem=function(e){return this.storage.getItem(this.getKeyPrefix()+":"+e)},n.prototype.setItem=function(e,t){this.storage.setItem(this.getKeyPrefix()+":"+e,t)},n.prototype.removeItem=function(e){this.storage.removeItem(this.getKeyPrefix()+":"+e)},n.prototype.clear=function(){this.storage.clear()},n.prototype.getKeyPrefix=function(){return e+":"+this.getLiffId()},n.prototype.getLiffId=function(){var e=D().liffId;if(!e)throw w(t,"liffId is necessary for liff.init()");return e},n}(),q=new _(g);function z(){var e=q.getItem("subWindowStatusUpdated");return null!==e&&JSON.parse(e)}function H(e){q.setItem("subWindowStatusUpdated",String(e))}function Q(e){A=e}function X(){return A}function Y(){return V}var Z=new _(window.sessionStorage);function $(e){Z.setItem("mainWindowOrigin",e)}function ee(){return Z.getItem("mainWindowOrigin")}function te(e,t){return void 0===t&&(t={}),P(this,void 0,void 0,(function(){var r,i,o,s,u,a,c;return O(this,(function(f){switch(f.label){case 0:if(r=D().liffId,i=ee(),!window.opener||!i||!r)throw w(n);o=!1,f.label=1;case 1:return f.trys.push([1,3,,4]),[4,k(r)];case 2:return s=f.sent(),o=s.subwindowCommonModule,[3,4];case 3:throw u=f.sent(),L.debug(u),w(n);case 4:return a=JSON.stringify(t),c=o?i:location.origin,window.opener.postMessage({status:e,result:a},c),[2,{status:e,result:a}]}}))}))}function ne(e){var t=F;if(e.origin===t){var n=e.data;if(n){var r,i=n.status,o=n.result;try{r=JSON.parse(o||"{}")}catch(s){r={}}switch(i){case f:window.clearInterval(Y());break;case c:case a:H(!0),window.clearInterval(Y()),window.removeEventListener("message",ne),K(i,r);break;default:L.debug("unexpected message")}}}}function re(){window.clearInterval(R),window.clearInterval(Y()),window.removeEventListener("message",ne)}function ie(e){var t=b(e.url);if(!t)return Promise.reject(w(r,"params.url must be liff url"));!function(){re(),H(!1);var e=X();e&&(e.close(),Q(null))}();var n,a,c,m,d=e.url,p=e.appData,h=new URL(d);h.searchParams.append(i,"true"),h.hostname=(n=h.hostname,a=j(n.split(".")),c=a[0],m=a.slice(1),C([c+"-ext"],m).join("."));var v=h.toString();return Q("ios"!==E()||S()?window.open("","liffsubwindow","width=480, height=640, menubar=no, toolbar=no, scrollbars=yes"):window.open()),k(t).then((function(e){var t,n=e.origin,r=e.subwindowCommonModule,i=X();if(!i)throw w(o);r?(!function(e){F=e}(n),window.addEventListener("message",ne),i.location.href=v,t=function(e,t){var n=X(),r={type:f};return t&&(r.message=JSON.stringify(t)),window.setInterval((function(){null==n||n.postMessage(r,e)}),s)}(n,p),V=t,function(e){R=e}(window.setInterval((function(){var e=X();e&&e.closed&&(re(),Q(null),!1===z()&&(H(!0),K(l,{})))}),u))):i.close()}))}function oe(e){return P(this,void 0,void 0,(function(){var t,n,i,o,s,u,f,p,h,v,g;return O(this,(function(b){switch(b.label){case 0:t=e.msit,n=e.mstChallenge,i=e.onSuccess,o=e.onError,s=e.reconnectCount,u=void 0===s?0:s,b.label=1;case 1:return b.trys.push([1,3,,6]),[4,J(W("subWindowSubscribe"),{method:"POST",body:JSON.stringify({msit:t,mstChallenge:n})})];case 2:return f=b.sent(),[3,6];case 3:return b.sent(),[4,se()];case 4:return b.sent(),[4,ae(oe,{msit:t,mstChallenge:n,onSuccess:i,onError:o,reconnectCount:u+=1})];case 5:return b.sent(),[2];case 6:return f.status>=500?[4,se()]:[3,9];case 7:return b.sent(),[4,ae(oe,{msit:t,mstChallenge:n,onSuccess:i,onError:o,reconnectCount:u+=1})];case 8:return b.sent(),[3,20];case 9:return f.status>=400&&500>f.status?[4,ue(f)]:[3,11];case 10:return(h=b.sent())?(p=h.errorDetail,o(w(r,p))):o(w(m,"Some error happened in the server")),[3,20];case 11:return 200!==f.status?[3,19]:[4,ue(f)];case 12:return(h=b.sent())?[3,13]:(o(w(m,"Some error happened in the server")),[3,18]);case 13:switch(v=h.status,g=h.result,v){case d:return[3,14];case l:case c:case a:return[3,16]}return[3,17];case 14:return[4,ae(oe,{msit:t,mstChallenge:n,onSuccess:i,onError:o,reconnectCount:u})];case 15:return b.sent(),[3,18];case 16:return i(v,g),[3,18];case 17:o(w(m,"Some error happened in the server")),b.label=18;case 18:return[3,20];case 19:o(w(m,"Some error happened in the server")),b.label=20;case 20:return[2]}}))}))}function se(){return new Promise((function(e){return setTimeout(e,1e3)}))}function ue(e){return P(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e.json()];case 1:return[2,t.sent()];case 2:return t.sent(),[2,null];case 3:return[2]}}))}))}function ae(e,t){return P(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return t.reconnectCount>=10?(t.onError(w(m,"Failed to connect")),[3,3]):[3,1];case 1:return[4,e(t)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function ce(e){var t={};return Object.keys(e).forEach((function(n){"closeButtonColor"===n?"white"===e[n]?t[n]="#ffffff":t[n]="#000000":t[n]=e[n]})),t}var fe={height:"full",closeButtonPosition:"right",closeButtonColor:"black",closeButtonLabel:""};function le(e){var t=e.appData,n=e.native,i=D().liffId,o=T(),s=b(e.url);if(!i)return Promise.reject(w(p,"liffId is invalid"));if(!o)return Promise.reject(w(p,"mst_challenge is invalid"));if(!s)return Promise.reject(w(r,"params.url must be liff url"));var u=Object.assign({},fe,n);return function(e){var t=e.mainLiffId,n=e.subLiffId,i=e.mstChallenge,o=e.appData,s=e.view;return t&&i?N(W("subWindowGetMSIT"),{method:"POST",body:JSON.stringify({mainLiffId:t,subLiffId:n,mstChallenge:i,appData:o,view:s})}):Promise.reject(w(r,"no proper argument"))}({mainLiffId:i,subLiffId:s,mstChallenge:o,appData:t,view:ce(u)}).then((function(t){var n=t.msit;oe({msit:n,mstChallenge:o,onSuccess:function(e,t){K(e,t)},onError:function(e){K(d,e)}}),function(e,t){var n=e.url,r=new URLSearchParams;r.set("msit",t),location.href=h+"?url="+encodeURIComponent(n)+"&"+r.toString()}(e,n)}))}function me(){if(!B())throw w(p,"this api can be only called in child window")}function de(e){if(!e.mst||!e.status)return Promise.reject(w(r,"no proper argument"));var t=JSON.stringify(e);return N(W("subWindowPost"),{method:"POST",body:t})}function pe(e){var t=e.msit,n=e.mstVerifier;return t&&n?N(W("subWindowGetMSTByMSIT"),{method:"POST",body:JSON.stringify({msit:t,mstVerifier:n})}):Promise.reject(w(r,"no proper argument"))}function he(e){var t=e.mst;return t?N(W("subWindowGetAppData"),{method:"POST",body:JSON.stringify({mst:t})}):Promise.reject(w(r,"no proper argument"))}var ve={on:function(e,t){G[e]||(G[e]=[]),G[e].push(t)},off:function(e,t){if(G[e]){var n=G[e].indexOf(t);n>=0&&G[e].splice(n,1)}},open:function(e){if(!I("subwindowOpen"))throw w(v,"No permission for liff.subWindow.open()");return function(){if(B())throw w(p,"this api can be only called in parent window")}(),y()?le(e):ie(e)},cancel:function(e){return void 0===e&&(e={}),me(),y()?function(e){return void 0===e&&(e={}),P(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return(t=x())?[4,de({mst:t,status:c,result:e})]:[2,Promise.reject(w(p,"mst is invalid"))];case 1:return n=r.sent(),H(!0),[2,n]}}))}))}(e):function(e){return void 0===e&&(e={}),te(c,e)}(e)},submit:function(e){return void 0===e&&(e={}),me(),y()?function(e){return void 0===e&&(e={}),P(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return(t=x())?[4,de({mst:t,status:a,result:e})]:[2,Promise.reject(w(p,"mst is invalid"))];case 1:return n=r.sent(),H(!0),[2,n]}}))}))}(e):function(e){return void 0===e&&(e={}),te(a,e)}(e)},close:function(){return me(),y()?function(){return P(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return!1!==z()?[3,2]:(e=x())?[4,de({mst:e,status:l,result:{}})]:[2,Promise.reject(w(p,"mst is invalid"))];case 1:t.sent(),t.label=2;case 2:return U(),[2]}}))}))}():(U(),Promise.resolve())},getAppData:function(){return me(),function(){var e,t=M();try{e=t?JSON.parse(t):{}}catch(n){e={}}return Promise.resolve(e)}()}};export{he as getAppData,pe as getMSTByMSIT,ee as getMainWindowOrigin,$ as setMainWindowOrigin,ve as subWindow}; | ||
import{STORE_KEY as e,INVALID_CONFIG as t,EXCEPTION_IN_SUBWINDOW as n,SUB_WINDOW_SUBMIT_STATUS as r,SUB_WINDOW_CANCEL_STATUS as i,INVALID_ARGUMENT as o,SUB_WINDOW_IDNTIFICATION_KEY as s,CREATE_SUBWINDOW_FAILED as u,SUB_WINDOW_HEALTH_CHECK_INTERVAL as a,SUB_WINDOW_MONITOR_CLOSE_INTERVAL as c,SUB_WINDOW_HEALTH_CHECK_MESSAGE as f,SUB_WINDOW_CLOSE_STATUS as l,UNKNOWN as m,SUB_WINDOW_ERROR_STATUS as d,UNAUTHORIZED as p,SUB_WINDOW_MODAL_SCHEME_URL as v,FORBIDDEN as h}from"@liff/consts";import{createLiffError as w,inMemoryStorage as g,extractLiffId as b,isIpad as y}from"@liff/util";import{isInClient as S}from"@liff/is-in-client";import{isApiAvailable as I}from"@liff/is-api-available";import{__awaiter as P,__generator as O,__spread as C,__read as L}from"tslib";import{logger as j}from"@liff/logger";import{getOS as E}from"@liff/get-os";import{fetch as N,getEndPoint as W,requestWithoutErrorHandling as J}from"@liff/server-api";import{getConfig as D,getMSTChallenge as T,getMST as x,getAppData as M}from"@liff/store";import{isSubWindow as B}from"@liff/is-sub-window";import{closeWindow as U}from"@liff/close-window";function k(e){var t=W("subWindowGetOrigin");return N(t(e))}var G={};function K(e,t){e&&G[e]&&G[e].forEach((function(e){e(t)}))}var A,R,V,F,_=function(){function n(e){this.storage=e}return n.prototype.getItem=function(e){return this.storage.getItem(this.getKeyPrefix()+":"+e)},n.prototype.setItem=function(e,t){this.storage.setItem(this.getKeyPrefix()+":"+e,t)},n.prototype.removeItem=function(e){this.storage.removeItem(this.getKeyPrefix()+":"+e)},n.prototype.clear=function(){this.storage.clear()},n.prototype.getKeyPrefix=function(){return e+":"+this.getLiffId()},n.prototype.getLiffId=function(){var e=D().liffId;if(!e)throw w(t,"liffId is necessary for liff.init()");return e},n}(),q=new _(g);function z(){var e=q.getItem("subWindowStatusUpdated");return null!==e&&JSON.parse(e)}function H(e){q.setItem("subWindowStatusUpdated",String(e))}function Q(e){A=e}function X(){return A}function Y(){return V}function Z(){return F}var $=new _(window.sessionStorage);function ee(e){$.setItem("mainWindowOrigin",e)}function te(){return $.getItem("mainWindowOrigin")}function ne(e,t){return void 0===t&&(t={}),P(this,void 0,void 0,(function(){var o,s,u,a,c,f,l;return O(this,(function(m){switch(m.label){case 0:if(o=D().liffId,s=te(),!window.opener||!s||!o)throw w(n);u=!1,m.label=1;case 1:return m.trys.push([1,3,,4]),[4,k(o)];case 2:return a=m.sent(),u=a.subwindowCommonModule,[3,4];case 3:throw c=m.sent(),j.debug(c),w(n);case 4:return f=JSON.stringify(t),l=u?s:location.origin,[2,new Promise((function(t){window.addEventListener("message",(function n(o){(function(e){if(e.data&&"string"==typeof e.data.type&&[r,i].includes(e.data.type))return!0;return!1})(o)&&(window.removeEventListener("message",n),t({status:e,result:f}))})),window.opener.postMessage({status:e,result:f},l)}))]}}))}))}function re(e){var t,n=Z();if(e.origin===n){var o=e.data;if(o){var s,u=o.status,a=o.result;try{s=JSON.parse(a||"{}")}catch(c){s={}}switch(u){case f:window.clearInterval(Y());break;case i:case r:H(!0),window.clearInterval(Y()),window.removeEventListener("message",re),K(u,s),null===(t=X())||void 0===t||t.postMessage({type:u},Z());break;default:j.debug("unexpected message")}}}}function ie(){window.clearInterval(R),window.clearInterval(Y()),window.removeEventListener("message",re)}function oe(e){var t=b(e.url);if(!t)return Promise.reject(w(o,"params.url must be liff url"));!function(){ie(),H(!1);var e=X();e&&(e.close(),Q(null))}();var n,r,i,m,d=e.url,p=e.appData,v=new URL(d);v.searchParams.append(s,"true"),v.hostname=(n=v.hostname,r=L(n.split(".")),i=r[0],m=r.slice(1),C([i+"-ext"],m).join("."));var h=v.toString();return Q("ios"!==E()||y()?window.open("","liffsubwindow","width=480, height=640, menubar=no, toolbar=no, scrollbars=yes"):window.open()),k(t).then((function(e){var t,n=e.origin,r=e.subwindowCommonModule,i=X();if(!i)throw w(u);r?(!function(e){F=e}(n),window.addEventListener("message",re),i.location.href=h,t=function(e,t){var n=X(),r={type:f};return t&&(r.message=JSON.stringify(t)),window.setInterval((function(){null==n||n.postMessage(r,e)}),a)}(n,p),V=t,function(e){R=e}(window.setInterval((function(){var e=X();e&&e.closed&&(ie(),Q(null),!1===z()&&(H(!0),K(l,{})))}),c))):i.close()}))}function se(e){return P(this,void 0,void 0,(function(){var t,n,s,u,a,c,f,p,v,h,g;return O(this,(function(b){switch(b.label){case 0:t=e.msit,n=e.mstChallenge,s=e.onSuccess,u=e.onError,a=e.reconnectCount,c=void 0===a?0:a,b.label=1;case 1:return b.trys.push([1,3,,6]),[4,J(W("subWindowSubscribe"),{method:"POST",body:JSON.stringify({msit:t,mstChallenge:n})})];case 2:return f=b.sent(),[3,6];case 3:return b.sent(),[4,ue()];case 4:return b.sent(),[4,ce(se,{msit:t,mstChallenge:n,onSuccess:s,onError:u,reconnectCount:c+=1})];case 5:return b.sent(),[2];case 6:return f.status>=500?[4,ue()]:[3,9];case 7:return b.sent(),[4,ce(se,{msit:t,mstChallenge:n,onSuccess:s,onError:u,reconnectCount:c+=1})];case 8:return b.sent(),[3,20];case 9:return f.status>=400&&500>f.status?[4,ae(f)]:[3,11];case 10:return(v=b.sent())?(p=v.errorDetail,u(w(o,p))):u(w(m,"Some error happened in the server")),[3,20];case 11:return 200!==f.status?[3,19]:[4,ae(f)];case 12:return(v=b.sent())?[3,13]:(u(w(m,"Some error happened in the server")),[3,18]);case 13:switch(h=v.status,g=v.result,h){case d:return[3,14];case l:case i:case r:return[3,16]}return[3,17];case 14:return[4,ce(se,{msit:t,mstChallenge:n,onSuccess:s,onError:u,reconnectCount:c})];case 15:return b.sent(),[3,18];case 16:return s(h,g),[3,18];case 17:u(w(m,"Some error happened in the server")),b.label=18;case 18:return[3,20];case 19:u(w(m,"Some error happened in the server")),b.label=20;case 20:return[2]}}))}))}function ue(){return new Promise((function(e){return setTimeout(e,1e3)}))}function ae(e){return P(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e.json()];case 1:return[2,t.sent()];case 2:return t.sent(),[2,null];case 3:return[2]}}))}))}function ce(e,t){return P(this,void 0,void 0,(function(){return O(this,(function(n){switch(n.label){case 0:return t.reconnectCount>=10?(t.onError(w(m,"Failed to connect")),[3,3]):[3,1];case 1:return[4,e(t)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))}function fe(e){var t={};return Object.keys(e).forEach((function(n){"closeButtonColor"===n?"white"===e[n]?t[n]="#ffffff":t[n]="#000000":t[n]=e[n]})),t}var le={height:"full",closeButtonPosition:"right",closeButtonColor:"black",closeButtonLabel:""};function me(e){var t=e.appData,n=e.native,r=D().liffId,i=T(),s=b(e.url);if(!r)return Promise.reject(w(p,"liffId is invalid"));if(!i)return Promise.reject(w(p,"mst_challenge is invalid"));if(!s)return Promise.reject(w(o,"params.url must be liff url"));var u=Object.assign({},le,n);return function(e){var t=e.mainLiffId,n=e.subLiffId,r=e.mstChallenge,i=e.appData,s=e.view;return t&&r?N(W("subWindowGetMSIT"),{method:"POST",body:JSON.stringify({mainLiffId:t,subLiffId:n,mstChallenge:r,appData:i,view:s})}):Promise.reject(w(o,"no proper argument"))}({mainLiffId:r,subLiffId:s,mstChallenge:i,appData:t,view:fe(u)}).then((function(t){var n=t.msit;se({msit:n,mstChallenge:i,onSuccess:function(e,t){K(e,t)},onError:function(e){K(d,e)}}),function(e,t){var n=e.url,r=new URLSearchParams;r.set("msit",t),location.href=v+"?url="+encodeURIComponent(n)+"&"+r.toString()}(e,n)}))}function de(){if(!B())throw w(p,"this api can be only called in child window")}function pe(e){if(!e.mst||!e.status)return Promise.reject(w(o,"no proper argument"));var t=JSON.stringify(e);return N(W("subWindowPost"),{method:"POST",body:t})}function ve(e){var t=e.msit,n=e.mstVerifier;return t&&n?N(W("subWindowGetMSTByMSIT"),{method:"POST",body:JSON.stringify({msit:t,mstVerifier:n})}):Promise.reject(w(o,"no proper argument"))}function he(e){var t=e.mst;return t?N(W("subWindowGetAppData"),{method:"POST",body:JSON.stringify({mst:t})}):Promise.reject(w(o,"no proper argument"))}var we={on:function(e,t){G[e]||(G[e]=[]),G[e].push(t)},off:function(e,t){if(G[e]){var n=G[e].indexOf(t);n>=0&&G[e].splice(n,1)}},open:function(e){if(!I("subwindowOpen"))throw w(h,"No permission for liff.subWindow.open()");return function(){if(B())throw w(p,"this api can be only called in parent window")}(),S()?me(e):oe(e)},cancel:function(e){return void 0===e&&(e={}),de(),S()?function(e){return void 0===e&&(e={}),P(this,void 0,void 0,(function(){var t,n;return O(this,(function(r){switch(r.label){case 0:return(t=x())?[4,pe({mst:t,status:i,result:e})]:[2,Promise.reject(w(p,"mst is invalid"))];case 1:return n=r.sent(),H(!0),[2,n]}}))}))}(e):function(e){return void 0===e&&(e={}),ne(i,e)}(e)},submit:function(e){return void 0===e&&(e={}),de(),S()?function(e){return void 0===e&&(e={}),P(this,void 0,void 0,(function(){var t,n;return O(this,(function(i){switch(i.label){case 0:return(t=x())?[4,pe({mst:t,status:r,result:e})]:[2,Promise.reject(w(p,"mst is invalid"))];case 1:return n=i.sent(),H(!0),[2,n]}}))}))}(e):function(e){return void 0===e&&(e={}),ne(r,e)}(e)},close:function(){return de(),S()?function(){return P(this,void 0,void 0,(function(){var e;return O(this,(function(t){switch(t.label){case 0:return!1!==z()?[3,2]:(e=x())?[4,pe({mst:e,status:l,result:{}})]:[2,Promise.reject(w(p,"mst is invalid"))];case 1:t.sent(),t.label=2;case 2:return U(),[2]}}))}))}():(U(),Promise.resolve())},getAppData:function(){return de(),function(){var e,t=M();try{e=t?JSON.parse(t):{}}catch(n){e={}}return Promise.resolve(e)}()}};export{he as getAppData,ve as getMSTByMSIT,te as getMainWindowOrigin,ee as setMainWindowOrigin,we as subWindow}; |
{ | ||
"name": "@liff/sub-window", | ||
"version": "2.16.1", | ||
"version": "2.17.0", | ||
"description": "@liff/sub-window", | ||
@@ -34,14 +34,14 @@ "license": "SEE LICENSE IN README.md", | ||
"dependencies": { | ||
"@liff/close-window": "2.16.1", | ||
"@liff/consts": "2.16.1", | ||
"@liff/get-os": "2.16.1", | ||
"@liff/is-api-available": "2.16.1", | ||
"@liff/is-in-client": "2.16.1", | ||
"@liff/is-sub-window": "2.16.1", | ||
"@liff/logger": "2.16.1", | ||
"@liff/server-api": "2.16.1", | ||
"@liff/store": "2.16.1", | ||
"@liff/util": "2.16.1" | ||
"@liff/close-window": "2.17.0", | ||
"@liff/consts": "2.17.0", | ||
"@liff/get-os": "2.17.0", | ||
"@liff/is-api-available": "2.17.0", | ||
"@liff/is-in-client": "2.17.0", | ||
"@liff/is-sub-window": "2.17.0", | ||
"@liff/logger": "2.17.0", | ||
"@liff/server-api": "2.17.0", | ||
"@liff/store": "2.17.0", | ||
"@liff/util": "2.17.0" | ||
}, | ||
"gitHead": "a58f228b90a65ab017cba10e3fbcc38540ccd565" | ||
"gitHead": "fa845ce90b5b2a7b64f3aca5c9584cb3907e41de" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29625
259
+ Added@liff/close-window@2.17.0(transitive)
+ Added@liff/consts@2.17.0(transitive)
+ Added@liff/get-line-version@2.17.0(transitive)
+ Added@liff/get-os@2.17.0(transitive)
+ Added@liff/is-api-available@2.17.0(transitive)
+ Added@liff/is-in-client@2.17.0(transitive)
+ Added@liff/is-logged-in@2.17.0(transitive)
+ Added@liff/is-sub-window@2.17.0(transitive)
+ Added@liff/logger@2.17.0(transitive)
+ Added@liff/native-bridge@2.17.0(transitive)
+ Added@liff/server-api@2.17.0(transitive)
+ Added@liff/store@2.17.0(transitive)
+ Added@liff/types@2.17.0(transitive)
+ Added@liff/use@2.17.0(transitive)
+ Added@liff/util@2.17.0(transitive)
- Removed@liff/close-window@2.16.1(transitive)
- Removed@liff/consts@2.16.1(transitive)
- Removed@liff/get-line-version@2.16.1(transitive)
- Removed@liff/get-os@2.16.1(transitive)
- Removed@liff/is-api-available@2.16.1(transitive)
- Removed@liff/is-in-client@2.16.1(transitive)
- Removed@liff/is-logged-in@2.16.1(transitive)
- Removed@liff/is-sub-window@2.16.1(transitive)
- Removed@liff/logger@2.16.1(transitive)
- Removed@liff/native-bridge@2.16.1(transitive)
- Removed@liff/server-api@2.16.1(transitive)
- Removed@liff/store@2.16.1(transitive)
- Removed@liff/types@2.16.1(transitive)
- Removed@liff/use@2.16.1(transitive)
- Removed@liff/util@2.16.1(transitive)
Updated@liff/close-window@2.17.0
Updated@liff/consts@2.17.0
Updated@liff/get-os@2.17.0
Updated@liff/is-in-client@2.17.0
Updated@liff/is-sub-window@2.17.0
Updated@liff/logger@2.17.0
Updated@liff/server-api@2.17.0
Updated@liff/store@2.17.0
Updated@liff/util@2.17.0