@appboxo/js-sdk
Advanced tools
Comparing version
@@ -31,3 +31,3 @@ !function(){"use strict"; | ||
limitations under the License. | ||
*/function s(e){return e&&e.status>=200&&e.status<300?Promise.resolve(e.json()):Promise.reject(new Error(e.statusText))}var u=function(e,t,o,n){var r,p=t,i=n||a;return"GET"===e?(p=t+"?"+Object.keys(o).map((function(e){return e+"="+o[e]})).join("&"),r=void 0):r=JSON.stringify(o),fetch(p,{method:e,headers:i,body:r}).then(s)},c=function(){function e(){}return e.post=function(e,t,o){return void 0===t&&(t={}),u("POST",e,t,o)},e.get=function(e,t,o){return void 0===t&&(t={}),u("GET",e,t,o)},e.put=function(e,t,o){return void 0===t&&(t={}),u("PUT",e,t,o)},e.delete=function(e,t,o){return void 0===t&&(t={}),u("DELETE",e,t,o)},e}(),l=["AppBoxoWebAppInit","AppBoxoWebAppGetInitData","AppBoxoWebAppOpenMiniApp","AppBoxoWebAppCloseMiniapp","AppBoxoWebAppClearToken","AppBoxoWebAppSaveToken","AppBoxoWebAppGetMiniappSettings","AppBoxoWebAppShowAuthConfirmBox","AppBoxoWebAppSetStatusBarColor","AppBoxoWebAppSetTabBar","AppBoxoWebAppSetActionButton","AppBoxoWebAppSetNavigationBar","AppBoxoWebAppLoadingIndicator","AppBoxoWebAppOpenQRCodeReader","AppBoxoWebAppVibrate","AppBoxoWebAppShowActionSheet","AppBoxoWebAppCustomEvent","AppBoxoWebAppGetGeodata","AppBoxoWebAppShowAlert","AppBoxoWebAppShowImages","AppBoxoWebAppStorageGet","AppBoxoWebAppStorageGetKeys","AppBoxoWebAppStorageSet","AppBoxoWebAppStorageRemove","AppBoxoWebAppStorageClear","AppBoxoWebAppGetClipboard","AppBoxoWebAppSetClipboard","AppBoxoWebAppGetSystemInfo","AppBoxoWebAppOpenLocation","AppBoxoWebAppChooseLocation","AppBoxoWebAppStartAccelerometer","AppBoxoWebAppStopAccelerometer","AppBoxoWebAppOnAccelerometerChange","AppBoxoWebAppStartGyroscope","AppBoxoWebAppStopGyroscope","AppBoxoWebAppOnGyroscopeChange","AppBoxoWebAppStartCompass","AppBoxoWebAppStopCompass","AppBoxoWebAppOnCompassChange","AppBoxoWebAppSetBackgroundColor","AppBoxoWebAppOnRestore"],d="undefined"!=typeof window,f=d&&window.webkit&&void 0!==window.webkit.messageHandlers,b={confirmModalText:"This service is requesting access to your account details",postConfirmCallback:function(){}},A=[],v=d?window.AppboxoJs:void 0,g=f?window.webkit.messageHandlers:void 0,x=d&&!v&&!g,h=x?"message":"AppBoxoWebAppEvent"; | ||
*/function s(e){return e&&e.status>=200&&e.status<300?Promise.resolve(e.json()):Promise.reject(new Error(e.statusText))}var u=function(e,t,o,n){var r,p=t,i=n||a;return"GET"===e?(p=t+"?"+Object.keys(o).map((function(e){return e+"="+o[e]})).join("&"),r=void 0):r=JSON.stringify(o),fetch(p,{method:e,headers:i,body:r}).then(s)},c=function(){function e(){}return e.post=function(e,t,o){return void 0===t&&(t={}),u("POST",e,t,o)},e.get=function(e,t,o){return void 0===t&&(t={}),u("GET",e,t,o)},e.put=function(e,t,o){return void 0===t&&(t={}),u("PUT",e,t,o)},e.delete=function(e,t,o){return void 0===t&&(t={}),u("DELETE",e,t,o)},e}(),l=["AppBoxoWebAppInit","AppBoxoWebAppGetInitData","AppBoxoWebAppOpenMiniApp","AppBoxoWebAppCloseMiniapp","AppBoxoWebAppClearToken","AppBoxoWebAppSaveToken","AppBoxoWebAppGetMiniappSettings","AppBoxoWebAppShowAuthConfirmBox","AppBoxoWebAppSetStatusBarColor","AppBoxoWebAppSetTabBar","AppBoxoWebAppSetActionButton","AppBoxoWebAppSetNavigationBar","AppBoxoWebAppLoadingIndicator","AppBoxoWebAppOpenQRCodeReader","AppBoxoWebAppVibrate","AppBoxoWebAppShowActionSheet","AppBoxoWebAppCustomEvent","AppBoxoWebAppGetGeodata","AppBoxoWebAppShowAlert","AppBoxoWebAppShowImages","AppBoxoWebAppStorageGet","AppBoxoWebAppStorageGetKeys","AppBoxoWebAppStorageSet","AppBoxoWebAppStorageRemove","AppBoxoWebAppStorageClear","AppBoxoWebAppGetClipboard","AppBoxoWebAppSetClipboard","AppBoxoWebAppGetSystemInfo","AppBoxoWebAppOpenLocation","AppBoxoWebAppChooseLocation","AppBoxoWebAppStartAccelerometer","AppBoxoWebAppStopAccelerometer","AppBoxoWebAppOnAccelerometerChange","AppBoxoWebAppStartGyroscope","AppBoxoWebAppStopGyroscope","AppBoxoWebAppOnGyroscopeChange","AppBoxoWebAppStartCompass","AppBoxoWebAppStopCompass","AppBoxoWebAppOnCompassChange","AppBoxoWebAppSetBackgroundColor","AppBoxoWebAppOnRestore","AppBoxoWebGetNfcRecords"],d="undefined"!=typeof window,f=d&&window.webkit&&void 0!==window.webkit.messageHandlers,b={confirmModalText:"This service is requesting access to your account details",postConfirmCallback:function(){}},A=[],v=d?window.AppboxoJs:void 0,x=f?window.webkit.messageHandlers:void 0,g=d&&!v&&!x,h=g?"message":"AppBoxoWebAppEvent"; | ||
/** | ||
@@ -48,3 +48,3 @@ @license | ||
limitations under the License. | ||
*/d&&(window.CustomEvent||(window.CustomEvent=function(){function e(e,t){var o=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!o.bubbles,!!o.cancelable,o.detail),n}return e.prototype=Event.prototype,e}()),window.addEventListener(h,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=n(A);if(x&&e[0]&&"data"in e[0]){var r=e[0].data;o.forEach((function(e){e({detail:r})}))}else o.forEach((function(t){t.apply(null,e)}))})));var y=function(e,t){void 0===t&&(t={}),v&&"function"==typeof v[e]&&v[e](JSON.stringify(t)),g&&g[e]&&"function"==typeof g[e].postMessage&&g[e].postMessage(t),x&&(console.log("postMessage: ",{handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.18"}),parent.postMessage({handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.18"},"*"))},m=function(e){A.push(e)},w=function(t,o){var n,r,p=(n={current:0,next:function(){return this.current+=1,this.current}},r={},{add:function(e){var t=n.next();return r[t]=e,t},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return new Promise((function(r,i){var a=p.add({resolve:r,reject:i});t(o,e(e({},n),{request_id:a}))}))}}(y,m),B=function(e){return!(!v||"function"!=typeof v[e])||(!(!g||!g[e]||"function"!=typeof g[e].postMessage)||!(g||v||!l.includes(e)))},W={send:y,subscribe:m,sendPromise:w,unsubscribe:function(e){var t=A.indexOf(e);t>-1&&A.splice(t,1)},isWebView:function(){return!(!v&&!g)},init:function(){y("AppBoxoWebAppInit")},getInitData:function(){return w("AppBoxoWebAppGetInitData").then((function(e){var t=e.app_id,o=e.client_id,n=e.payload,p=e.token,i=void 0===p?"":p,a=e.data;return r.set("ab_app_id",t),r.set("ab_client_id",o),r.set("ab_payload",n),r.set("ab_token",i),{app_id:t,client_id:o,payload:n,token:i,data:a}}))},login:function(n){void 0===n&&(n={});var p=e(e({},b),n),a=r.get("ab_app_id"),s=r.get("ab_client_id"),u=r.get("ab_payload");return B("AppBoxoWebAppLogin")?new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var t,r,i,a;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,w("AppBoxoWebAppLogin",{confirmModalText:p.confirmModalText})];case 1:return t=o.sent(),(null==(r=null===(a=t)||void 0===a?void 0:a.payload)?void 0:r.token)?e(r):n({status:"Error",message:"No auth token received",error:"No auth token received"}),[3,3];case 2:return i=o.sent(),[2,n({status:"Error",message:"Login failed",error:i})];case 3:return[2]}}))}))})):new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var l,d;return o(this,(function(f){switch(f.label){case 0:if(!(a&&s&&u))return[3,9];f.label=1;case 1:return f.trys.push([1,7,,8]),[4,(b=p.confirmModalText,t(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,w("AppBoxoWebAppShowAuthConfirmBox",{message:b})]}))})))];case 2:f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!0}),p.postConfirmCallback(!0),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,c.post(i.Auth.Login,{client_id:s,app_id:a,payload:u})];case 4:if((l=f.sent()).token)return r.set("ab_token",l.token),y("AppBoxoWebAppSaveToken",{token:l.token}),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,e(l.token)];throw new Error("No auth token received");case 5:return d=f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,n({status:"Error",message:"Login failed",error:d})];case 6:return[3,8];case 7:return f.sent(),p.postConfirmCallback(!1),[2,n({status:"Reject",message:"Login confirmation rejected"})];case 8:return[3,10];case 9:return[2,n({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 10:return[2]}var b}))}))}))},logout:function(){return B("AppBoxoWebAppLogin")?w("AppBoxoWebAppLogout"):(r.remove("ab_token"),w("AppBoxoWebAppClearToken"))},supports:B,track:function(n){if(B("AppBoxoWebAppTrack"))return new Promise((function(e,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,w("AppBoxoWebAppTrack",n)];case 1:return t=o.sent(),[2,e(t)];case 2:return p=o.sent(),[2,r({status:"Reject",message:"Failed sending tracking details with: "+p})];case 3:return[2]}}))}))}));var p=r.get("ab_app_id"),a=r.get("ab_client_id");return new Promise((function(r,s){return t(void 0,void 0,void 0,(function(){var t,u;return o(this,(function(o){switch(o.label){case 0:if(!p||!a)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,c.post(i.Analytics.Tracking,e(e({},n),{app_id:p,client_id:a}))];case 2:return t=o.sent(),[2,r(t)];case 3:return u=o.sent(),[2,s({status:"Reject",message:"Failed sending tracking details with: "+u})];case 4:return[3,6];case 5:return[2,s({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))},pay:function(e){return new Promise((function(n,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:if(!B("AppBoxoWebAppPay"))return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,w("AppBoxoWebAppPay",e)];case 2:return t=o.sent(),[2,n(t)];case 3:return p=o.sent(),[2,r({status:"Error",message:"Payment failed",error:p})];case 4:return[3,6];case 5:return[2,r({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))}};if("object"!=typeof exports||"undefined"==typeof module){var k=null;"undefined"!=typeof window?k=window:"undefined"!=typeof global?k=global:"undefined"!=typeof self&&(k=self),k&&(k.appboxoSDK=W)} | ||
*/d&&(window.CustomEvent||(window.CustomEvent=function(){function e(e,t){var o=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!o.bubbles,!!o.cancelable,o.detail),n}return e.prototype=Event.prototype,e}()),window.addEventListener(h,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=n(A);if(g&&e[0]&&"data"in e[0]){var r=e[0].data;o.forEach((function(e){e({detail:r})}))}else o.forEach((function(t){t.apply(null,e)}))})));var y=function(e,t){void 0===t&&(t={}),v&&"function"==typeof v[e]&&v[e](JSON.stringify(t)),x&&x[e]&&"function"==typeof x[e].postMessage&&x[e].postMessage(t),g&&(console.log("postMessage: ",{handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.19"}),parent.postMessage({handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.19"},"*"))},m=function(e){A.push(e)},w=function(t,o){var n,r,p=(n={current:0,next:function(){return this.current+=1,this.current}},r={},{add:function(e){var t=n.next();return r[t]=e,t},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return new Promise((function(r,i){var a=p.add({resolve:r,reject:i});t(o,e(e({},n),{request_id:a}))}))}}(y,m),B=function(e){return!(!v||"function"!=typeof v[e])||(!(!x||!x[e]||"function"!=typeof x[e].postMessage)||!(x||v||!l.includes(e)))},W={send:y,subscribe:m,sendPromise:w,unsubscribe:function(e){var t=A.indexOf(e);t>-1&&A.splice(t,1)},isWebView:function(){return!(!v&&!x)},init:function(){y("AppBoxoWebAppInit")},getInitData:function(){return w("AppBoxoWebAppGetInitData").then((function(e){var t=e.app_id,o=e.client_id,n=e.payload,p=e.token,i=void 0===p?"":p,a=e.data;return r.set("ab_app_id",t),r.set("ab_client_id",o),r.set("ab_payload",n),r.set("ab_token",i),{app_id:t,client_id:o,payload:n,token:i,data:a}}))},login:function(n){void 0===n&&(n={});var p=e(e({},b),n),a=r.get("ab_app_id"),s=r.get("ab_client_id"),u=r.get("ab_payload");return B("AppBoxoWebAppLogin")?new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var t,r,i,a;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,w("AppBoxoWebAppLogin",{confirmModalText:p.confirmModalText})];case 1:return t=o.sent(),(null==(r=null===(a=t)||void 0===a?void 0:a.payload)?void 0:r.token)?e(r):n({status:"Error",message:"No auth token received",error:"No auth token received"}),[3,3];case 2:return i=o.sent(),[2,n({status:"Error",message:"Login failed",error:i})];case 3:return[2]}}))}))})):new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var l,d;return o(this,(function(f){switch(f.label){case 0:if(!(a&&s&&u))return[3,9];f.label=1;case 1:return f.trys.push([1,7,,8]),[4,(b=p.confirmModalText,t(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,w("AppBoxoWebAppShowAuthConfirmBox",{message:b})]}))})))];case 2:f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!0}),p.postConfirmCallback(!0),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,c.post(i.Auth.Login,{client_id:s,app_id:a,payload:u})];case 4:if((l=f.sent()).token)return r.set("ab_token",l.token),y("AppBoxoWebAppSaveToken",{token:l.token}),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,e(l.token)];throw new Error("No auth token received");case 5:return d=f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,n({status:"Error",message:"Login failed",error:d})];case 6:return[3,8];case 7:return f.sent(),p.postConfirmCallback(!1),[2,n({status:"Reject",message:"Login confirmation rejected"})];case 8:return[3,10];case 9:return[2,n({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 10:return[2]}var b}))}))}))},logout:function(){return B("AppBoxoWebAppLogin")?w("AppBoxoWebAppLogout"):(r.remove("ab_token"),w("AppBoxoWebAppClearToken"))},supports:B,track:function(n){if(B("AppBoxoWebAppTrack"))return new Promise((function(e,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,w("AppBoxoWebAppTrack",n)];case 1:return t=o.sent(),[2,e(t)];case 2:return p=o.sent(),[2,r({status:"Reject",message:"Failed sending tracking details with: "+p})];case 3:return[2]}}))}))}));var p=r.get("ab_app_id"),a=r.get("ab_client_id");return new Promise((function(r,s){return t(void 0,void 0,void 0,(function(){var t,u;return o(this,(function(o){switch(o.label){case 0:if(!p||!a)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,c.post(i.Analytics.Tracking,e(e({},n),{app_id:p,client_id:a}))];case 2:return t=o.sent(),[2,r(t)];case 3:return u=o.sent(),[2,s({status:"Reject",message:"Failed sending tracking details with: "+u})];case 4:return[3,6];case 5:return[2,s({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))},pay:function(e){return new Promise((function(n,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:if(!B("AppBoxoWebAppPay"))return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,w("AppBoxoWebAppPay",e)];case 2:return t=o.sent(),[2,n(t)];case 3:return p=o.sent(),[2,r({status:"Error",message:"Payment failed",error:p})];case 4:return[3,6];case 5:return[2,r({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))}};if("object"!=typeof exports||"undefined"==typeof module){var k=null;"undefined"!=typeof window?k=window:"undefined"!=typeof global?k=global:"undefined"!=typeof self&&(k=self),k&&(k.appboxoSDK=W)} | ||
/** | ||
@@ -51,0 +51,0 @@ @license |
@@ -31,3 +31,3 @@ /*! ***************************************************************************** | ||
limitations under the License. | ||
*/function s(e){return e&&e.status>=200&&e.status<300?Promise.resolve(e.json()):Promise.reject(new Error(e.statusText))}var u=function(e,t,o,n){var r,p=t,a=n||i;return"GET"===e?(p=t+"?"+Object.keys(o).map((function(e){return e+"="+o[e]})).join("&"),r=void 0):r=JSON.stringify(o),fetch(p,{method:e,headers:a,body:r}).then(s)},c=function(){function e(){}return e.post=function(e,t,o){return void 0===t&&(t={}),u("POST",e,t,o)},e.get=function(e,t,o){return void 0===t&&(t={}),u("GET",e,t,o)},e.put=function(e,t,o){return void 0===t&&(t={}),u("PUT",e,t,o)},e.delete=function(e,t,o){return void 0===t&&(t={}),u("DELETE",e,t,o)},e}(),l=["AppBoxoWebAppInit","AppBoxoWebAppGetInitData","AppBoxoWebAppOpenMiniApp","AppBoxoWebAppCloseMiniapp","AppBoxoWebAppClearToken","AppBoxoWebAppSaveToken","AppBoxoWebAppGetMiniappSettings","AppBoxoWebAppShowAuthConfirmBox","AppBoxoWebAppSetStatusBarColor","AppBoxoWebAppSetTabBar","AppBoxoWebAppSetActionButton","AppBoxoWebAppSetNavigationBar","AppBoxoWebAppLoadingIndicator","AppBoxoWebAppOpenQRCodeReader","AppBoxoWebAppVibrate","AppBoxoWebAppShowActionSheet","AppBoxoWebAppCustomEvent","AppBoxoWebAppGetGeodata","AppBoxoWebAppShowAlert","AppBoxoWebAppShowImages","AppBoxoWebAppStorageGet","AppBoxoWebAppStorageGetKeys","AppBoxoWebAppStorageSet","AppBoxoWebAppStorageRemove","AppBoxoWebAppStorageClear","AppBoxoWebAppGetClipboard","AppBoxoWebAppSetClipboard","AppBoxoWebAppGetSystemInfo","AppBoxoWebAppOpenLocation","AppBoxoWebAppChooseLocation","AppBoxoWebAppStartAccelerometer","AppBoxoWebAppStopAccelerometer","AppBoxoWebAppOnAccelerometerChange","AppBoxoWebAppStartGyroscope","AppBoxoWebAppStopGyroscope","AppBoxoWebAppOnGyroscopeChange","AppBoxoWebAppStartCompass","AppBoxoWebAppStopCompass","AppBoxoWebAppOnCompassChange","AppBoxoWebAppSetBackgroundColor","AppBoxoWebAppOnRestore"],d="undefined"!=typeof window,f=d&&window.webkit&&void 0!==window.webkit.messageHandlers,b={confirmModalText:"This service is requesting access to your account details",postConfirmCallback:function(){}},A=[],v=d?window.AppboxoJs:void 0,g=f?window.webkit.messageHandlers:void 0,x=d&&!v&&!g,h=x?"message":"AppBoxoWebAppEvent"; | ||
*/function s(e){return e&&e.status>=200&&e.status<300?Promise.resolve(e.json()):Promise.reject(new Error(e.statusText))}var u=function(e,t,o,n){var r,p=t,a=n||i;return"GET"===e?(p=t+"?"+Object.keys(o).map((function(e){return e+"="+o[e]})).join("&"),r=void 0):r=JSON.stringify(o),fetch(p,{method:e,headers:a,body:r}).then(s)},c=function(){function e(){}return e.post=function(e,t,o){return void 0===t&&(t={}),u("POST",e,t,o)},e.get=function(e,t,o){return void 0===t&&(t={}),u("GET",e,t,o)},e.put=function(e,t,o){return void 0===t&&(t={}),u("PUT",e,t,o)},e.delete=function(e,t,o){return void 0===t&&(t={}),u("DELETE",e,t,o)},e}(),l=["AppBoxoWebAppInit","AppBoxoWebAppGetInitData","AppBoxoWebAppOpenMiniApp","AppBoxoWebAppCloseMiniapp","AppBoxoWebAppClearToken","AppBoxoWebAppSaveToken","AppBoxoWebAppGetMiniappSettings","AppBoxoWebAppShowAuthConfirmBox","AppBoxoWebAppSetStatusBarColor","AppBoxoWebAppSetTabBar","AppBoxoWebAppSetActionButton","AppBoxoWebAppSetNavigationBar","AppBoxoWebAppLoadingIndicator","AppBoxoWebAppOpenQRCodeReader","AppBoxoWebAppVibrate","AppBoxoWebAppShowActionSheet","AppBoxoWebAppCustomEvent","AppBoxoWebAppGetGeodata","AppBoxoWebAppShowAlert","AppBoxoWebAppShowImages","AppBoxoWebAppStorageGet","AppBoxoWebAppStorageGetKeys","AppBoxoWebAppStorageSet","AppBoxoWebAppStorageRemove","AppBoxoWebAppStorageClear","AppBoxoWebAppGetClipboard","AppBoxoWebAppSetClipboard","AppBoxoWebAppGetSystemInfo","AppBoxoWebAppOpenLocation","AppBoxoWebAppChooseLocation","AppBoxoWebAppStartAccelerometer","AppBoxoWebAppStopAccelerometer","AppBoxoWebAppOnAccelerometerChange","AppBoxoWebAppStartGyroscope","AppBoxoWebAppStopGyroscope","AppBoxoWebAppOnGyroscopeChange","AppBoxoWebAppStartCompass","AppBoxoWebAppStopCompass","AppBoxoWebAppOnCompassChange","AppBoxoWebAppSetBackgroundColor","AppBoxoWebAppOnRestore","AppBoxoWebGetNfcRecords"],d="undefined"!=typeof window,f=d&&window.webkit&&void 0!==window.webkit.messageHandlers,b={confirmModalText:"This service is requesting access to your account details",postConfirmCallback:function(){}},A=[],v=d?window.AppboxoJs:void 0,g=f?window.webkit.messageHandlers:void 0,x=d&&!v&&!g,h=x?"message":"AppBoxoWebAppEvent"; | ||
/** | ||
@@ -48,2 +48,2 @@ @license | ||
limitations under the License. | ||
*/d&&(window.CustomEvent||(window.CustomEvent=function(){function e(e,t){var o=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!o.bubbles,!!o.cancelable,o.detail),n}return e.prototype=Event.prototype,e}()),window.addEventListener(h,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=n(A);if(x&&e[0]&&"data"in e[0]){var r=e[0].data;o.forEach((function(e){e({detail:r})}))}else o.forEach((function(t){t.apply(null,e)}))})));var y=function(e,t){void 0===t&&(t={}),v&&"function"==typeof v[e]&&v[e](JSON.stringify(t)),g&&g[e]&&"function"==typeof g[e].postMessage&&g[e].postMessage(t),x&&(console.log("postMessage: ",{handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.18"}),parent.postMessage({handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.18"},"*"))},m=function(e){A.push(e)},w=function(t,o){var n,r,p=(n={current:0,next:function(){return this.current+=1,this.current}},r={},{add:function(e){var t=n.next();return r[t]=e,t},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return new Promise((function(r,a){var i=p.add({resolve:r,reject:a});t(o,e(e({},n),{request_id:i}))}))}}(y,m),B=function(e){return!(!v||"function"!=typeof v[e])||(!(!g||!g[e]||"function"!=typeof g[e].postMessage)||!(g||v||!l.includes(e)))},W={send:y,subscribe:m,sendPromise:w,unsubscribe:function(e){var t=A.indexOf(e);t>-1&&A.splice(t,1)},isWebView:function(){return!(!v&&!g)},init:function(){y("AppBoxoWebAppInit")},getInitData:function(){return w("AppBoxoWebAppGetInitData").then((function(e){var t=e.app_id,o=e.client_id,n=e.payload,p=e.token,a=void 0===p?"":p,i=e.data;return r.set("ab_app_id",t),r.set("ab_client_id",o),r.set("ab_payload",n),r.set("ab_token",a),{app_id:t,client_id:o,payload:n,token:a,data:i}}))},login:function(n){void 0===n&&(n={});var p=e(e({},b),n),i=r.get("ab_app_id"),s=r.get("ab_client_id"),u=r.get("ab_payload");return B("AppBoxoWebAppLogin")?new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var t,r,a,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,w("AppBoxoWebAppLogin",{confirmModalText:p.confirmModalText})];case 1:return t=o.sent(),(null==(r=null===(i=t)||void 0===i?void 0:i.payload)?void 0:r.token)?e(r):n({status:"Error",message:"No auth token received",error:"No auth token received"}),[3,3];case 2:return a=o.sent(),[2,n({status:"Error",message:"Login failed",error:a})];case 3:return[2]}}))}))})):new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var l,d;return o(this,(function(f){switch(f.label){case 0:if(!(i&&s&&u))return[3,9];f.label=1;case 1:return f.trys.push([1,7,,8]),[4,(b=p.confirmModalText,t(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,w("AppBoxoWebAppShowAuthConfirmBox",{message:b})]}))})))];case 2:f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!0}),p.postConfirmCallback(!0),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,c.post(a.Auth.Login,{client_id:s,app_id:i,payload:u})];case 4:if((l=f.sent()).token)return r.set("ab_token",l.token),y("AppBoxoWebAppSaveToken",{token:l.token}),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,e(l.token)];throw new Error("No auth token received");case 5:return d=f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,n({status:"Error",message:"Login failed",error:d})];case 6:return[3,8];case 7:return f.sent(),p.postConfirmCallback(!1),[2,n({status:"Reject",message:"Login confirmation rejected"})];case 8:return[3,10];case 9:return[2,n({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 10:return[2]}var b}))}))}))},logout:function(){return B("AppBoxoWebAppLogin")?w("AppBoxoWebAppLogout"):(r.remove("ab_token"),w("AppBoxoWebAppClearToken"))},supports:B,track:function(n){if(B("AppBoxoWebAppTrack"))return new Promise((function(e,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,w("AppBoxoWebAppTrack",n)];case 1:return t=o.sent(),[2,e(t)];case 2:return p=o.sent(),[2,r({status:"Reject",message:"Failed sending tracking details with: "+p})];case 3:return[2]}}))}))}));var p=r.get("ab_app_id"),i=r.get("ab_client_id");return new Promise((function(r,s){return t(void 0,void 0,void 0,(function(){var t,u;return o(this,(function(o){switch(o.label){case 0:if(!p||!i)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,c.post(a.Analytics.Tracking,e(e({},n),{app_id:p,client_id:i}))];case 2:return t=o.sent(),[2,r(t)];case 3:return u=o.sent(),[2,s({status:"Reject",message:"Failed sending tracking details with: "+u})];case 4:return[3,6];case 5:return[2,s({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))},pay:function(e){return new Promise((function(n,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:if(!B("AppBoxoWebAppPay"))return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,w("AppBoxoWebAppPay",e)];case 2:return t=o.sent(),[2,n(t)];case 3:return p=o.sent(),[2,r({status:"Error",message:"Payment failed",error:p})];case 4:return[3,6];case 5:return[2,r({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))}};if("object"!=typeof exports||"undefined"==typeof module){var k=null;"undefined"!=typeof window?k=window:"undefined"!=typeof global?k=global:"undefined"!=typeof self&&(k=self),k&&(k.appboxoSDK=W)}export default W; | ||
*/d&&(window.CustomEvent||(window.CustomEvent=function(){function e(e,t){var o=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!o.bubbles,!!o.cancelable,o.detail),n}return e.prototype=Event.prototype,e}()),window.addEventListener(h,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=n(A);if(x&&e[0]&&"data"in e[0]){var r=e[0].data;o.forEach((function(e){e({detail:r})}))}else o.forEach((function(t){t.apply(null,e)}))})));var y=function(e,t){void 0===t&&(t={}),v&&"function"==typeof v[e]&&v[e](JSON.stringify(t)),g&&g[e]&&"function"==typeof g[e].postMessage&&g[e].postMessage(t),x&&(console.log("postMessage: ",{handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.19"}),parent.postMessage({handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.19"},"*"))},m=function(e){A.push(e)},B=function(t,o){var n,r,p=(n={current:0,next:function(){return this.current+=1,this.current}},r={},{add:function(e){var t=n.next();return r[t]=e,t},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return new Promise((function(r,a){var i=p.add({resolve:r,reject:a});t(o,e(e({},n),{request_id:i}))}))}}(y,m),w=function(e){return!(!v||"function"!=typeof v[e])||(!(!g||!g[e]||"function"!=typeof g[e].postMessage)||!(g||v||!l.includes(e)))},W={send:y,subscribe:m,sendPromise:B,unsubscribe:function(e){var t=A.indexOf(e);t>-1&&A.splice(t,1)},isWebView:function(){return!(!v&&!g)},init:function(){y("AppBoxoWebAppInit")},getInitData:function(){return B("AppBoxoWebAppGetInitData").then((function(e){var t=e.app_id,o=e.client_id,n=e.payload,p=e.token,a=void 0===p?"":p,i=e.data;return r.set("ab_app_id",t),r.set("ab_client_id",o),r.set("ab_payload",n),r.set("ab_token",a),{app_id:t,client_id:o,payload:n,token:a,data:i}}))},login:function(n){void 0===n&&(n={});var p=e(e({},b),n),i=r.get("ab_app_id"),s=r.get("ab_client_id"),u=r.get("ab_payload");return w("AppBoxoWebAppLogin")?new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var t,r,a,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,B("AppBoxoWebAppLogin",{confirmModalText:p.confirmModalText})];case 1:return t=o.sent(),(null==(r=null===(i=t)||void 0===i?void 0:i.payload)?void 0:r.token)?e(r):n({status:"Error",message:"No auth token received",error:"No auth token received"}),[3,3];case 2:return a=o.sent(),[2,n({status:"Error",message:"Login failed",error:a})];case 3:return[2]}}))}))})):new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var l,d;return o(this,(function(f){switch(f.label){case 0:if(!(i&&s&&u))return[3,9];f.label=1;case 1:return f.trys.push([1,7,,8]),[4,(b=p.confirmModalText,t(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,B("AppBoxoWebAppShowAuthConfirmBox",{message:b})]}))})))];case 2:f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!0}),p.postConfirmCallback(!0),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,c.post(a.Auth.Login,{client_id:s,app_id:i,payload:u})];case 4:if((l=f.sent()).token)return r.set("ab_token",l.token),y("AppBoxoWebAppSaveToken",{token:l.token}),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,e(l.token)];throw new Error("No auth token received");case 5:return d=f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,n({status:"Error",message:"Login failed",error:d})];case 6:return[3,8];case 7:return f.sent(),p.postConfirmCallback(!1),[2,n({status:"Reject",message:"Login confirmation rejected"})];case 8:return[3,10];case 9:return[2,n({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 10:return[2]}var b}))}))}))},logout:function(){return w("AppBoxoWebAppLogin")?B("AppBoxoWebAppLogout"):(r.remove("ab_token"),B("AppBoxoWebAppClearToken"))},supports:w,track:function(n){if(w("AppBoxoWebAppTrack"))return new Promise((function(e,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,B("AppBoxoWebAppTrack",n)];case 1:return t=o.sent(),[2,e(t)];case 2:return p=o.sent(),[2,r({status:"Reject",message:"Failed sending tracking details with: "+p})];case 3:return[2]}}))}))}));var p=r.get("ab_app_id"),i=r.get("ab_client_id");return new Promise((function(r,s){return t(void 0,void 0,void 0,(function(){var t,u;return o(this,(function(o){switch(o.label){case 0:if(!p||!i)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,c.post(a.Analytics.Tracking,e(e({},n),{app_id:p,client_id:i}))];case 2:return t=o.sent(),[2,r(t)];case 3:return u=o.sent(),[2,s({status:"Reject",message:"Failed sending tracking details with: "+u})];case 4:return[3,6];case 5:return[2,s({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))},pay:function(e){return new Promise((function(n,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:if(!w("AppBoxoWebAppPay"))return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,B("AppBoxoWebAppPay",e)];case 2:return t=o.sent(),[2,n(t)];case 3:return p=o.sent(),[2,r({status:"Error",message:"Payment failed",error:p})];case 4:return[3,6];case 5:return[2,r({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))}};if("object"!=typeof exports||"undefined"==typeof module){var k=null;"undefined"!=typeof window?k=window:"undefined"!=typeof global?k=global:"undefined"!=typeof self&&(k=self),k&&(k.appboxoSDK=W)}export default W; |
@@ -32,3 +32,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}); | ||
limitations under the License. | ||
*/function s(e){return e&&e.status>=200&&e.status<300?Promise.resolve(e.json()):Promise.reject(new Error(e.statusText))}var u=function(e,t,o,n){var r,p=t,a=n||i;return"GET"===e?(p=t+"?"+Object.keys(o).map((function(e){return e+"="+o[e]})).join("&"),r=void 0):r=JSON.stringify(o),fetch(p,{method:e,headers:a,body:r}).then(s)},c=function(){function e(){}return e.post=function(e,t,o){return void 0===t&&(t={}),u("POST",e,t,o)},e.get=function(e,t,o){return void 0===t&&(t={}),u("GET",e,t,o)},e.put=function(e,t,o){return void 0===t&&(t={}),u("PUT",e,t,o)},e.delete=function(e,t,o){return void 0===t&&(t={}),u("DELETE",e,t,o)},e}(),l=["AppBoxoWebAppInit","AppBoxoWebAppGetInitData","AppBoxoWebAppOpenMiniApp","AppBoxoWebAppCloseMiniapp","AppBoxoWebAppClearToken","AppBoxoWebAppSaveToken","AppBoxoWebAppGetMiniappSettings","AppBoxoWebAppShowAuthConfirmBox","AppBoxoWebAppSetStatusBarColor","AppBoxoWebAppSetTabBar","AppBoxoWebAppSetActionButton","AppBoxoWebAppSetNavigationBar","AppBoxoWebAppLoadingIndicator","AppBoxoWebAppOpenQRCodeReader","AppBoxoWebAppVibrate","AppBoxoWebAppShowActionSheet","AppBoxoWebAppCustomEvent","AppBoxoWebAppGetGeodata","AppBoxoWebAppShowAlert","AppBoxoWebAppShowImages","AppBoxoWebAppStorageGet","AppBoxoWebAppStorageGetKeys","AppBoxoWebAppStorageSet","AppBoxoWebAppStorageRemove","AppBoxoWebAppStorageClear","AppBoxoWebAppGetClipboard","AppBoxoWebAppSetClipboard","AppBoxoWebAppGetSystemInfo","AppBoxoWebAppOpenLocation","AppBoxoWebAppChooseLocation","AppBoxoWebAppStartAccelerometer","AppBoxoWebAppStopAccelerometer","AppBoxoWebAppOnAccelerometerChange","AppBoxoWebAppStartGyroscope","AppBoxoWebAppStopGyroscope","AppBoxoWebAppOnGyroscopeChange","AppBoxoWebAppStartCompass","AppBoxoWebAppStopCompass","AppBoxoWebAppOnCompassChange","AppBoxoWebAppSetBackgroundColor","AppBoxoWebAppOnRestore"],d="undefined"!=typeof window,f=d&&window.webkit&&void 0!==window.webkit.messageHandlers,b={confirmModalText:"This service is requesting access to your account details",postConfirmCallback:function(){}},A=[],v=d?window.AppboxoJs:void 0,g=f?window.webkit.messageHandlers:void 0,x=d&&!v&&!g,h=x?"message":"AppBoxoWebAppEvent"; | ||
*/function s(e){return e&&e.status>=200&&e.status<300?Promise.resolve(e.json()):Promise.reject(new Error(e.statusText))}var u=function(e,t,o,n){var r,p=t,a=n||i;return"GET"===e?(p=t+"?"+Object.keys(o).map((function(e){return e+"="+o[e]})).join("&"),r=void 0):r=JSON.stringify(o),fetch(p,{method:e,headers:a,body:r}).then(s)},c=function(){function e(){}return e.post=function(e,t,o){return void 0===t&&(t={}),u("POST",e,t,o)},e.get=function(e,t,o){return void 0===t&&(t={}),u("GET",e,t,o)},e.put=function(e,t,o){return void 0===t&&(t={}),u("PUT",e,t,o)},e.delete=function(e,t,o){return void 0===t&&(t={}),u("DELETE",e,t,o)},e}(),l=["AppBoxoWebAppInit","AppBoxoWebAppGetInitData","AppBoxoWebAppOpenMiniApp","AppBoxoWebAppCloseMiniapp","AppBoxoWebAppClearToken","AppBoxoWebAppSaveToken","AppBoxoWebAppGetMiniappSettings","AppBoxoWebAppShowAuthConfirmBox","AppBoxoWebAppSetStatusBarColor","AppBoxoWebAppSetTabBar","AppBoxoWebAppSetActionButton","AppBoxoWebAppSetNavigationBar","AppBoxoWebAppLoadingIndicator","AppBoxoWebAppOpenQRCodeReader","AppBoxoWebAppVibrate","AppBoxoWebAppShowActionSheet","AppBoxoWebAppCustomEvent","AppBoxoWebAppGetGeodata","AppBoxoWebAppShowAlert","AppBoxoWebAppShowImages","AppBoxoWebAppStorageGet","AppBoxoWebAppStorageGetKeys","AppBoxoWebAppStorageSet","AppBoxoWebAppStorageRemove","AppBoxoWebAppStorageClear","AppBoxoWebAppGetClipboard","AppBoxoWebAppSetClipboard","AppBoxoWebAppGetSystemInfo","AppBoxoWebAppOpenLocation","AppBoxoWebAppChooseLocation","AppBoxoWebAppStartAccelerometer","AppBoxoWebAppStopAccelerometer","AppBoxoWebAppOnAccelerometerChange","AppBoxoWebAppStartGyroscope","AppBoxoWebAppStopGyroscope","AppBoxoWebAppOnGyroscopeChange","AppBoxoWebAppStartCompass","AppBoxoWebAppStopCompass","AppBoxoWebAppOnCompassChange","AppBoxoWebAppSetBackgroundColor","AppBoxoWebAppOnRestore","AppBoxoWebGetNfcRecords"],d="undefined"!=typeof window,f=d&&window.webkit&&void 0!==window.webkit.messageHandlers,b={confirmModalText:"This service is requesting access to your account details",postConfirmCallback:function(){}},A=[],v=d?window.AppboxoJs:void 0,x=f?window.webkit.messageHandlers:void 0,g=d&&!v&&!x,h=g?"message":"AppBoxoWebAppEvent"; | ||
/** | ||
@@ -49,2 +49,2 @@ @license | ||
limitations under the License. | ||
*/d&&(window.CustomEvent||(window.CustomEvent=function(){function e(e,t){var o=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!o.bubbles,!!o.cancelable,o.detail),n}return e.prototype=Event.prototype,e}()),window.addEventListener(h,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=n(A);if(x&&e[0]&&"data"in e[0]){var r=e[0].data;o.forEach((function(e){e({detail:r})}))}else o.forEach((function(t){t.apply(null,e)}))})));var y=function(e,t){void 0===t&&(t={}),v&&"function"==typeof v[e]&&v[e](JSON.stringify(t)),g&&g[e]&&"function"==typeof g[e].postMessage&&g[e].postMessage(t),x&&(console.log("postMessage: ",{handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.18"}),parent.postMessage({handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.18"},"*"))},m=function(e){A.push(e)},w=function(t,o){var n,r,p=(n={current:0,next:function(){return this.current+=1,this.current}},r={},{add:function(e){var t=n.next();return r[t]=e,t},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return new Promise((function(r,a){var i=p.add({resolve:r,reject:a});t(o,e(e({},n),{request_id:i}))}))}}(y,m),B=function(e){return!(!v||"function"!=typeof v[e])||(!(!g||!g[e]||"function"!=typeof g[e].postMessage)||!(g||v||!l.includes(e)))},W={send:y,subscribe:m,sendPromise:w,unsubscribe:function(e){var t=A.indexOf(e);t>-1&&A.splice(t,1)},isWebView:function(){return!(!v&&!g)},init:function(){y("AppBoxoWebAppInit")},getInitData:function(){return w("AppBoxoWebAppGetInitData").then((function(e){var t=e.app_id,o=e.client_id,n=e.payload,p=e.token,a=void 0===p?"":p,i=e.data;return r.set("ab_app_id",t),r.set("ab_client_id",o),r.set("ab_payload",n),r.set("ab_token",a),{app_id:t,client_id:o,payload:n,token:a,data:i}}))},login:function(n){void 0===n&&(n={});var p=e(e({},b),n),i=r.get("ab_app_id"),s=r.get("ab_client_id"),u=r.get("ab_payload");return B("AppBoxoWebAppLogin")?new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var t,r,a,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,w("AppBoxoWebAppLogin",{confirmModalText:p.confirmModalText})];case 1:return t=o.sent(),(null==(r=null===(i=t)||void 0===i?void 0:i.payload)?void 0:r.token)?e(r):n({status:"Error",message:"No auth token received",error:"No auth token received"}),[3,3];case 2:return a=o.sent(),[2,n({status:"Error",message:"Login failed",error:a})];case 3:return[2]}}))}))})):new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var l,d;return o(this,(function(f){switch(f.label){case 0:if(!(i&&s&&u))return[3,9];f.label=1;case 1:return f.trys.push([1,7,,8]),[4,(b=p.confirmModalText,t(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,w("AppBoxoWebAppShowAuthConfirmBox",{message:b})]}))})))];case 2:f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!0}),p.postConfirmCallback(!0),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,c.post(a.Auth.Login,{client_id:s,app_id:i,payload:u})];case 4:if((l=f.sent()).token)return r.set("ab_token",l.token),y("AppBoxoWebAppSaveToken",{token:l.token}),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,e(l.token)];throw new Error("No auth token received");case 5:return d=f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,n({status:"Error",message:"Login failed",error:d})];case 6:return[3,8];case 7:return f.sent(),p.postConfirmCallback(!1),[2,n({status:"Reject",message:"Login confirmation rejected"})];case 8:return[3,10];case 9:return[2,n({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 10:return[2]}var b}))}))}))},logout:function(){return B("AppBoxoWebAppLogin")?w("AppBoxoWebAppLogout"):(r.remove("ab_token"),w("AppBoxoWebAppClearToken"))},supports:B,track:function(n){if(B("AppBoxoWebAppTrack"))return new Promise((function(e,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,w("AppBoxoWebAppTrack",n)];case 1:return t=o.sent(),[2,e(t)];case 2:return p=o.sent(),[2,r({status:"Reject",message:"Failed sending tracking details with: "+p})];case 3:return[2]}}))}))}));var p=r.get("ab_app_id"),i=r.get("ab_client_id");return new Promise((function(r,s){return t(void 0,void 0,void 0,(function(){var t,u;return o(this,(function(o){switch(o.label){case 0:if(!p||!i)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,c.post(a.Analytics.Tracking,e(e({},n),{app_id:p,client_id:i}))];case 2:return t=o.sent(),[2,r(t)];case 3:return u=o.sent(),[2,s({status:"Reject",message:"Failed sending tracking details with: "+u})];case 4:return[3,6];case 5:return[2,s({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))},pay:function(e){return new Promise((function(n,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:if(!B("AppBoxoWebAppPay"))return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,w("AppBoxoWebAppPay",e)];case 2:return t=o.sent(),[2,n(t)];case 3:return p=o.sent(),[2,r({status:"Error",message:"Payment failed",error:p})];case 4:return[3,6];case 5:return[2,r({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))}};if("object"!=typeof exports||"undefined"==typeof module){var k=null;"undefined"!=typeof window?k=window:"undefined"!=typeof global?k=global:"undefined"!=typeof self&&(k=self),k&&(k.appboxoSDK=W)}exports.default=W; | ||
*/d&&(window.CustomEvent||(window.CustomEvent=function(){function e(e,t){var o=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!o.bubbles,!!o.cancelable,o.detail),n}return e.prototype=Event.prototype,e}()),window.addEventListener(h,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=n(A);if(g&&e[0]&&"data"in e[0]){var r=e[0].data;o.forEach((function(e){e({detail:r})}))}else o.forEach((function(t){t.apply(null,e)}))})));var y=function(e,t){void 0===t&&(t={}),v&&"function"==typeof v[e]&&v[e](JSON.stringify(t)),x&&x[e]&&"function"==typeof x[e].postMessage&&x[e].postMessage(t),g&&(console.log("postMessage: ",{handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.19"}),parent.postMessage({handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.19"},"*"))},m=function(e){A.push(e)},B=function(t,o){var n,r,p=(n={current:0,next:function(){return this.current+=1,this.current}},r={},{add:function(e){var t=n.next();return r[t]=e,t},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return new Promise((function(r,a){var i=p.add({resolve:r,reject:a});t(o,e(e({},n),{request_id:i}))}))}}(y,m),w=function(e){return!(!v||"function"!=typeof v[e])||(!(!x||!x[e]||"function"!=typeof x[e].postMessage)||!(x||v||!l.includes(e)))},W={send:y,subscribe:m,sendPromise:B,unsubscribe:function(e){var t=A.indexOf(e);t>-1&&A.splice(t,1)},isWebView:function(){return!(!v&&!x)},init:function(){y("AppBoxoWebAppInit")},getInitData:function(){return B("AppBoxoWebAppGetInitData").then((function(e){var t=e.app_id,o=e.client_id,n=e.payload,p=e.token,a=void 0===p?"":p,i=e.data;return r.set("ab_app_id",t),r.set("ab_client_id",o),r.set("ab_payload",n),r.set("ab_token",a),{app_id:t,client_id:o,payload:n,token:a,data:i}}))},login:function(n){void 0===n&&(n={});var p=e(e({},b),n),i=r.get("ab_app_id"),s=r.get("ab_client_id"),u=r.get("ab_payload");return w("AppBoxoWebAppLogin")?new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var t,r,a,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,B("AppBoxoWebAppLogin",{confirmModalText:p.confirmModalText})];case 1:return t=o.sent(),(null==(r=null===(i=t)||void 0===i?void 0:i.payload)?void 0:r.token)?e(r):n({status:"Error",message:"No auth token received",error:"No auth token received"}),[3,3];case 2:return a=o.sent(),[2,n({status:"Error",message:"Login failed",error:a})];case 3:return[2]}}))}))})):new Promise((function(e,n){return t(void 0,void 0,void 0,(function(){var l,d;return o(this,(function(f){switch(f.label){case 0:if(!(i&&s&&u))return[3,9];f.label=1;case 1:return f.trys.push([1,7,,8]),[4,(b=p.confirmModalText,t(void 0,void 0,void 0,(function(){return o(this,(function(e){return[2,B("AppBoxoWebAppShowAuthConfirmBox",{message:b})]}))})))];case 2:f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!0}),p.postConfirmCallback(!0),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,c.post(a.Auth.Login,{client_id:s,app_id:i,payload:u})];case 4:if((l=f.sent()).token)return r.set("ab_token",l.token),y("AppBoxoWebAppSaveToken",{token:l.token}),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,e(l.token)];throw new Error("No auth token received");case 5:return d=f.sent(),y("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,n({status:"Error",message:"Login failed",error:d})];case 6:return[3,8];case 7:return f.sent(),p.postConfirmCallback(!1),[2,n({status:"Reject",message:"Login confirmation rejected"})];case 8:return[3,10];case 9:return[2,n({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 10:return[2]}var b}))}))}))},logout:function(){return w("AppBoxoWebAppLogin")?B("AppBoxoWebAppLogout"):(r.remove("ab_token"),B("AppBoxoWebAppClearToken"))},supports:w,track:function(n){if(w("AppBoxoWebAppTrack"))return new Promise((function(e,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,B("AppBoxoWebAppTrack",n)];case 1:return t=o.sent(),[2,e(t)];case 2:return p=o.sent(),[2,r({status:"Reject",message:"Failed sending tracking details with: "+p})];case 3:return[2]}}))}))}));var p=r.get("ab_app_id"),i=r.get("ab_client_id");return new Promise((function(r,s){return t(void 0,void 0,void 0,(function(){var t,u;return o(this,(function(o){switch(o.label){case 0:if(!p||!i)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,c.post(a.Analytics.Tracking,e(e({},n),{app_id:p,client_id:i}))];case 2:return t=o.sent(),[2,r(t)];case 3:return u=o.sent(),[2,s({status:"Reject",message:"Failed sending tracking details with: "+u})];case 4:return[3,6];case 5:return[2,s({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))},pay:function(e){return new Promise((function(n,r){return t(void 0,void 0,void 0,(function(){var t,p;return o(this,(function(o){switch(o.label){case 0:if(!w("AppBoxoWebAppPay"))return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,B("AppBoxoWebAppPay",e)];case 2:return t=o.sent(),[2,n(t)];case 3:return p=o.sent(),[2,r({status:"Error",message:"Payment failed",error:p})];case 4:return[3,6];case 5:return[2,r({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))}};if("object"!=typeof exports||"undefined"==typeof module){var k=null;"undefined"!=typeof window?k=window:"undefined"!=typeof global?k=global:"undefined"!=typeof self&&(k=self),k&&(k.appboxoSDK=W)}exports.default=W; |
@@ -31,3 +31,3 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).appboxoSDK={})}(this,(function(e){"use strict"; | ||
limitations under the License. | ||
*/function u(e){return e&&e.status>=200&&e.status<300?Promise.resolve(e.json()):Promise.reject(new Error(e.statusText))}var c=function(e,t,o,n){var r,p=t,i=n||s;return"GET"===e?(p=t+"?"+Object.keys(o).map((function(e){return e+"="+o[e]})).join("&"),r=void 0):r=JSON.stringify(o),fetch(p,{method:e,headers:i,body:r}).then(u)},l=function(){function e(){}return e.post=function(e,t,o){return void 0===t&&(t={}),c("POST",e,t,o)},e.get=function(e,t,o){return void 0===t&&(t={}),c("GET",e,t,o)},e.put=function(e,t,o){return void 0===t&&(t={}),c("PUT",e,t,o)},e.delete=function(e,t,o){return void 0===t&&(t={}),c("DELETE",e,t,o)},e}(),d=["AppBoxoWebAppInit","AppBoxoWebAppGetInitData","AppBoxoWebAppOpenMiniApp","AppBoxoWebAppCloseMiniapp","AppBoxoWebAppClearToken","AppBoxoWebAppSaveToken","AppBoxoWebAppGetMiniappSettings","AppBoxoWebAppShowAuthConfirmBox","AppBoxoWebAppSetStatusBarColor","AppBoxoWebAppSetTabBar","AppBoxoWebAppSetActionButton","AppBoxoWebAppSetNavigationBar","AppBoxoWebAppLoadingIndicator","AppBoxoWebAppOpenQRCodeReader","AppBoxoWebAppVibrate","AppBoxoWebAppShowActionSheet","AppBoxoWebAppCustomEvent","AppBoxoWebAppGetGeodata","AppBoxoWebAppShowAlert","AppBoxoWebAppShowImages","AppBoxoWebAppStorageGet","AppBoxoWebAppStorageGetKeys","AppBoxoWebAppStorageSet","AppBoxoWebAppStorageRemove","AppBoxoWebAppStorageClear","AppBoxoWebAppGetClipboard","AppBoxoWebAppSetClipboard","AppBoxoWebAppGetSystemInfo","AppBoxoWebAppOpenLocation","AppBoxoWebAppChooseLocation","AppBoxoWebAppStartAccelerometer","AppBoxoWebAppStopAccelerometer","AppBoxoWebAppOnAccelerometerChange","AppBoxoWebAppStartGyroscope","AppBoxoWebAppStopGyroscope","AppBoxoWebAppOnGyroscopeChange","AppBoxoWebAppStartCompass","AppBoxoWebAppStopCompass","AppBoxoWebAppOnCompassChange","AppBoxoWebAppSetBackgroundColor","AppBoxoWebAppOnRestore"],f="undefined"!=typeof window,b=f&&window.webkit&&void 0!==window.webkit.messageHandlers,A={confirmModalText:"This service is requesting access to your account details",postConfirmCallback:function(){}},v=[],x=f?window.AppboxoJs:void 0,g=b?window.webkit.messageHandlers:void 0,h=f&&!x&&!g,y=h?"message":"AppBoxoWebAppEvent"; | ||
*/function u(e){return e&&e.status>=200&&e.status<300?Promise.resolve(e.json()):Promise.reject(new Error(e.statusText))}var c=function(e,t,o,n){var r,p=t,i=n||s;return"GET"===e?(p=t+"?"+Object.keys(o).map((function(e){return e+"="+o[e]})).join("&"),r=void 0):r=JSON.stringify(o),fetch(p,{method:e,headers:i,body:r}).then(u)},l=function(){function e(){}return e.post=function(e,t,o){return void 0===t&&(t={}),c("POST",e,t,o)},e.get=function(e,t,o){return void 0===t&&(t={}),c("GET",e,t,o)},e.put=function(e,t,o){return void 0===t&&(t={}),c("PUT",e,t,o)},e.delete=function(e,t,o){return void 0===t&&(t={}),c("DELETE",e,t,o)},e}(),d=["AppBoxoWebAppInit","AppBoxoWebAppGetInitData","AppBoxoWebAppOpenMiniApp","AppBoxoWebAppCloseMiniapp","AppBoxoWebAppClearToken","AppBoxoWebAppSaveToken","AppBoxoWebAppGetMiniappSettings","AppBoxoWebAppShowAuthConfirmBox","AppBoxoWebAppSetStatusBarColor","AppBoxoWebAppSetTabBar","AppBoxoWebAppSetActionButton","AppBoxoWebAppSetNavigationBar","AppBoxoWebAppLoadingIndicator","AppBoxoWebAppOpenQRCodeReader","AppBoxoWebAppVibrate","AppBoxoWebAppShowActionSheet","AppBoxoWebAppCustomEvent","AppBoxoWebAppGetGeodata","AppBoxoWebAppShowAlert","AppBoxoWebAppShowImages","AppBoxoWebAppStorageGet","AppBoxoWebAppStorageGetKeys","AppBoxoWebAppStorageSet","AppBoxoWebAppStorageRemove","AppBoxoWebAppStorageClear","AppBoxoWebAppGetClipboard","AppBoxoWebAppSetClipboard","AppBoxoWebAppGetSystemInfo","AppBoxoWebAppOpenLocation","AppBoxoWebAppChooseLocation","AppBoxoWebAppStartAccelerometer","AppBoxoWebAppStopAccelerometer","AppBoxoWebAppOnAccelerometerChange","AppBoxoWebAppStartGyroscope","AppBoxoWebAppStopGyroscope","AppBoxoWebAppOnGyroscopeChange","AppBoxoWebAppStartCompass","AppBoxoWebAppStopCompass","AppBoxoWebAppOnCompassChange","AppBoxoWebAppSetBackgroundColor","AppBoxoWebAppOnRestore","AppBoxoWebGetNfcRecords"],f="undefined"!=typeof window,b=f&&window.webkit&&void 0!==window.webkit.messageHandlers,A={confirmModalText:"This service is requesting access to your account details",postConfirmCallback:function(){}},v=[],x=f?window.AppboxoJs:void 0,g=b?window.webkit.messageHandlers:void 0,h=f&&!x&&!g,y=h?"message":"AppBoxoWebAppEvent"; | ||
/** | ||
@@ -48,2 +48,2 @@ @license | ||
limitations under the License. | ||
*/f&&(window.CustomEvent||(window.CustomEvent=function(){function e(e,t){var o=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!o.bubbles,!!o.cancelable,o.detail),n}return e.prototype=Event.prototype,e}()),window.addEventListener(y,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=r(v);if(h&&e[0]&&"data"in e[0]){var n=e[0].data;o.forEach((function(e){e({detail:n})}))}else o.forEach((function(t){t.apply(null,e)}))})));var m=function(e,t){void 0===t&&(t={}),x&&"function"==typeof x[e]&&x[e](JSON.stringify(t)),g&&g[e]&&"function"==typeof g[e].postMessage&&g[e].postMessage(t),h&&(console.log("postMessage: ",{handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.18"}),parent.postMessage({handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.18"},"*"))},w=function(e){v.push(e)},B=function(e,o){var n,r,p=(n={current:0,next:function(){return this.current+=1,this.current}},r={},{add:function(e){var t=n.next();return r[t]=e,t},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return new Promise((function(r,i){var a=p.add({resolve:r,reject:i});e(o,t(t({},n),{request_id:a}))}))}}(m,w),W=function(e){return!(!x||"function"!=typeof x[e])||(!(!g||!g[e]||"function"!=typeof g[e].postMessage)||!(g||x||!d.includes(e)))},k={send:m,subscribe:w,sendPromise:B,unsubscribe:function(e){var t=v.indexOf(e);t>-1&&v.splice(t,1)},isWebView:function(){return!(!x&&!g)},init:function(){m("AppBoxoWebAppInit")},getInitData:function(){return B("AppBoxoWebAppGetInitData").then((function(e){var t=e.app_id,o=e.client_id,n=e.payload,r=e.token,i=void 0===r?"":r,a=e.data;return p.set("ab_app_id",t),p.set("ab_client_id",o),p.set("ab_payload",n),p.set("ab_token",i),{app_id:t,client_id:o,payload:n,token:i,data:a}}))},login:function(e){void 0===e&&(e={});var r=t(t({},A),e),i=p.get("ab_app_id"),s=p.get("ab_client_id"),u=p.get("ab_payload");return W("AppBoxoWebAppLogin")?new Promise((function(e,t){return o(void 0,void 0,void 0,(function(){var o,p,i,a;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,B("AppBoxoWebAppLogin",{confirmModalText:r.confirmModalText})];case 1:return o=n.sent(),(null==(p=null===(a=o)||void 0===a?void 0:a.payload)?void 0:p.token)?e(p):t({status:"Error",message:"No auth token received",error:"No auth token received"}),[3,3];case 2:return i=n.sent(),[2,t({status:"Error",message:"Login failed",error:i})];case 3:return[2]}}))}))})):new Promise((function(e,t){return o(void 0,void 0,void 0,(function(){var c,d;return n(this,(function(f){switch(f.label){case 0:if(!(i&&s&&u))return[3,9];f.label=1;case 1:return f.trys.push([1,7,,8]),[4,(b=r.confirmModalText,o(void 0,void 0,void 0,(function(){return n(this,(function(e){return[2,B("AppBoxoWebAppShowAuthConfirmBox",{message:b})]}))})))];case 2:f.sent(),m("AppBoxoWebAppLoadingIndicator",{show:!0}),r.postConfirmCallback(!0),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,l.post(a.Auth.Login,{client_id:s,app_id:i,payload:u})];case 4:if((c=f.sent()).token)return p.set("ab_token",c.token),m("AppBoxoWebAppSaveToken",{token:c.token}),m("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,e(c.token)];throw new Error("No auth token received");case 5:return d=f.sent(),m("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,t({status:"Error",message:"Login failed",error:d})];case 6:return[3,8];case 7:return f.sent(),r.postConfirmCallback(!1),[2,t({status:"Reject",message:"Login confirmation rejected"})];case 8:return[3,10];case 9:return[2,t({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 10:return[2]}var b}))}))}))},logout:function(){return W("AppBoxoWebAppLogin")?B("AppBoxoWebAppLogout"):(p.remove("ab_token"),B("AppBoxoWebAppClearToken"))},supports:W,track:function(e){if(W("AppBoxoWebAppTrack"))return new Promise((function(t,r){return o(void 0,void 0,void 0,(function(){var o,p;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,B("AppBoxoWebAppTrack",e)];case 1:return o=n.sent(),[2,t(o)];case 2:return p=n.sent(),[2,r({status:"Reject",message:"Failed sending tracking details with: "+p})];case 3:return[2]}}))}))}));var r=p.get("ab_app_id"),i=p.get("ab_client_id");return new Promise((function(p,s){return o(void 0,void 0,void 0,(function(){var o,u;return n(this,(function(n){switch(n.label){case 0:if(!r||!i)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,l.post(a.Analytics.Tracking,t(t({},e),{app_id:r,client_id:i}))];case 2:return o=n.sent(),[2,p(o)];case 3:return u=n.sent(),[2,s({status:"Reject",message:"Failed sending tracking details with: "+u})];case 4:return[3,6];case 5:return[2,s({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))},pay:function(e){return new Promise((function(t,r){return o(void 0,void 0,void 0,(function(){var o,p;return n(this,(function(n){switch(n.label){case 0:if(!W("AppBoxoWebAppPay"))return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,B("AppBoxoWebAppPay",e)];case 2:return o=n.sent(),[2,t(o)];case 3:return p=n.sent(),[2,r({status:"Error",message:"Payment failed",error:p})];case 4:return[3,6];case 5:return[2,r({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))}};if("object"!=typeof e||"undefined"==typeof module){var S=null;"undefined"!=typeof window?S=window:"undefined"!=typeof global?S=global:"undefined"!=typeof self&&(S=self),S&&(S.appboxoSDK=k)}e.default=k,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/f&&(window.CustomEvent||(window.CustomEvent=function(){function e(e,t){var o=t||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!o.bubbles,!!o.cancelable,o.detail),n}return e.prototype=Event.prototype,e}()),window.addEventListener(y,(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=r(v);if(h&&e[0]&&"data"in e[0]){var n=e[0].data;o.forEach((function(e){e({detail:n})}))}else o.forEach((function(t){t.apply(null,e)}))})));var m=function(e,t){void 0===t&&(t={}),x&&"function"==typeof x[e]&&x[e](JSON.stringify(t)),g&&g[e]&&"function"==typeof g[e].postMessage&&g[e].postMessage(t),h&&(console.log("postMessage: ",{handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.19"}),parent.postMessage({handler:e,params:t,type:"appboxo-js-sdk",sdkVersion:"1.3.19"},"*"))},B=function(e){v.push(e)},w=function(e,o){var n,r,p=(n={current:0,next:function(){return this.current+=1,this.current}},r={},{add:function(e){var t=n.next();return r[t]=e,t},resolve:function(e,t,o){var n=r[e];n&&(o(t)?n.resolve(t):n.reject(t),r[e]=null)}});return o((function(e){if(e.detail&&e.detail.data){var t=e.detail.data,o=t.request_id,n=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o}(t,["request_id"]);o&&p.resolve(o,n,(function(e){return!("error_type"in e)}))}})),function(o,n){return new Promise((function(r,i){var a=p.add({resolve:r,reject:i});e(o,t(t({},n),{request_id:a}))}))}}(m,B),W=function(e){return!(!x||"function"!=typeof x[e])||(!(!g||!g[e]||"function"!=typeof g[e].postMessage)||!(g||x||!d.includes(e)))},k={send:m,subscribe:B,sendPromise:w,unsubscribe:function(e){var t=v.indexOf(e);t>-1&&v.splice(t,1)},isWebView:function(){return!(!x&&!g)},init:function(){m("AppBoxoWebAppInit")},getInitData:function(){return w("AppBoxoWebAppGetInitData").then((function(e){var t=e.app_id,o=e.client_id,n=e.payload,r=e.token,i=void 0===r?"":r,a=e.data;return p.set("ab_app_id",t),p.set("ab_client_id",o),p.set("ab_payload",n),p.set("ab_token",i),{app_id:t,client_id:o,payload:n,token:i,data:a}}))},login:function(e){void 0===e&&(e={});var r=t(t({},A),e),i=p.get("ab_app_id"),s=p.get("ab_client_id"),u=p.get("ab_payload");return W("AppBoxoWebAppLogin")?new Promise((function(e,t){return o(void 0,void 0,void 0,(function(){var o,p,i,a;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,w("AppBoxoWebAppLogin",{confirmModalText:r.confirmModalText})];case 1:return o=n.sent(),(null==(p=null===(a=o)||void 0===a?void 0:a.payload)?void 0:p.token)?e(p):t({status:"Error",message:"No auth token received",error:"No auth token received"}),[3,3];case 2:return i=n.sent(),[2,t({status:"Error",message:"Login failed",error:i})];case 3:return[2]}}))}))})):new Promise((function(e,t){return o(void 0,void 0,void 0,(function(){var c,d;return n(this,(function(f){switch(f.label){case 0:if(!(i&&s&&u))return[3,9];f.label=1;case 1:return f.trys.push([1,7,,8]),[4,(b=r.confirmModalText,o(void 0,void 0,void 0,(function(){return n(this,(function(e){return[2,w("AppBoxoWebAppShowAuthConfirmBox",{message:b})]}))})))];case 2:f.sent(),m("AppBoxoWebAppLoadingIndicator",{show:!0}),r.postConfirmCallback(!0),f.label=3;case 3:return f.trys.push([3,5,,6]),[4,l.post(a.Auth.Login,{client_id:s,app_id:i,payload:u})];case 4:if((c=f.sent()).token)return p.set("ab_token",c.token),m("AppBoxoWebAppSaveToken",{token:c.token}),m("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,e(c.token)];throw new Error("No auth token received");case 5:return d=f.sent(),m("AppBoxoWebAppLoadingIndicator",{show:!1}),[2,t({status:"Error",message:"Login failed",error:d})];case 6:return[3,8];case 7:return f.sent(),r.postConfirmCallback(!1),[2,t({status:"Reject",message:"Login confirmation rejected"})];case 8:return[3,10];case 9:return[2,t({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 10:return[2]}var b}))}))}))},logout:function(){return W("AppBoxoWebAppLogin")?w("AppBoxoWebAppLogout"):(p.remove("ab_token"),w("AppBoxoWebAppClearToken"))},supports:W,track:function(e){if(W("AppBoxoWebAppTrack"))return new Promise((function(t,r){return o(void 0,void 0,void 0,(function(){var o,p;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,w("AppBoxoWebAppTrack",e)];case 1:return o=n.sent(),[2,t(o)];case 2:return p=n.sent(),[2,r({status:"Reject",message:"Failed sending tracking details with: "+p})];case 3:return[2]}}))}))}));var r=p.get("ab_app_id"),i=p.get("ab_client_id");return new Promise((function(p,s){return o(void 0,void 0,void 0,(function(){var o,u;return n(this,(function(n){switch(n.label){case 0:if(!r||!i)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,l.post(a.Analytics.Tracking,t(t({},e),{app_id:r,client_id:i}))];case 2:return o=n.sent(),[2,p(o)];case 3:return u=n.sent(),[2,s({status:"Reject",message:"Failed sending tracking details with: "+u})];case 4:return[3,6];case 5:return[2,s({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))},pay:function(e){return new Promise((function(t,r){return o(void 0,void 0,void 0,(function(){var o,p;return n(this,(function(n){switch(n.label){case 0:if(!W("AppBoxoWebAppPay"))return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,w("AppBoxoWebAppPay",e)];case 2:return o=n.sent(),[2,t(o)];case 3:return p=n.sent(),[2,r({status:"Error",message:"Payment failed",error:p})];case 4:return[3,6];case 5:return[2,r({status:"Error",message:"Init app data is not provided, please call `.getInitData()`"})];case 6:return[2]}}))}))}))}};if("object"!=typeof e||"undefined"==typeof module){var S=null;"undefined"!=typeof window?S=window:"undefined"!=typeof global?S=global:"undefined"!=typeof self&&(S=self),S&&(S.appboxoSDK=k)}e.default=k,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -60,3 +60,3 @@ /** | ||
locationEnabled: boolean; | ||
systemUiMode: 'dark' | 'light'; | ||
systemUiMode: "dark" | "light"; | ||
}; | ||
@@ -136,3 +136,3 @@ /** | ||
AppBoxoWebAppVibrate: { | ||
style: 'light' | 'medium' | 'heavy'; | ||
style: "light" | "medium" | "heavy"; | ||
}; | ||
@@ -144,3 +144,3 @@ AppBoxoWebAppShowActionSheet: { | ||
text: string; | ||
role?: 'cancel' | 'destructive' | 'selected'; | ||
role?: "cancel" | "destructive" | "selected"; | ||
}>; | ||
@@ -165,3 +165,3 @@ }; | ||
text: string; | ||
role?: 'cancel' | 'destructive'; | ||
role?: "cancel" | "destructive"; | ||
}>; | ||
@@ -214,2 +214,7 @@ }; | ||
AppBoxoWebAppPay: PaymentData; | ||
AppBoxoWebGetNfcRecords: { | ||
type?: string; | ||
data?: Object; | ||
payload?: Object; | ||
}; | ||
}; | ||
@@ -304,2 +309,7 @@ /** | ||
}; | ||
AppBoxoWebGetNfcRecords: { | ||
type?: string; | ||
data?: Object; | ||
payload?: Object; | ||
}; | ||
}; | ||
@@ -345,11 +355,11 @@ /** Name of the method that can be sent */ | ||
export declare type ErrorData = { | ||
error_type: 'client_error'; | ||
error_type: "client_error"; | ||
error_data: ErrorDataClientError; | ||
request_id?: number | string; | ||
} | { | ||
error_type: 'api_error'; | ||
error_type: "api_error"; | ||
error_data: ErrorDataAPIError; | ||
request_id?: number | string; | ||
} | { | ||
error_type: 'auth_error'; | ||
error_type: "auth_error"; | ||
error_data: ErrorDataAuthError; | ||
@@ -356,0 +366,0 @@ request_id?: number | string; |
{ | ||
"name": "@appboxo/js-sdk", | ||
"version": "1.3.18", | ||
"version": "1.3.19", | ||
"description": "JavaScript SDK for AppBoxo mini-app platform", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
93006
0.36%906
1.12%2
100%