@automata-network/pom-js-sdk
Advanced tools
Comparing version 0.0.79 to 0.0.80
@@ -1,2 +0,2 @@ | ||
"use strict";var r,e=require("@automata-network/pom-socket"),a=require("./index.js");exports.POMOperation=void 0,(r=exports.POMOperation||(exports.POMOperation={})).GetIdentityStatus="getIdentityStatus",r.AttestDevice="attestDevice",r.SignMessage="signMessage";const t=new Error("operation is cancelled"),o=new Error("need retry");function n(r){const{id:a=e.createRandomString(6),error:t}=r;return{id:a,data:JSON.stringify({id:a,success:null==t,error:t,...r})}}function i(r){return JSON.parse(r)}const s={Android:function(){return navigator.userAgent.match(/Android/i)},macOS:function(){return navigator.userAgent.match(/macintosh|macintel|macppc|mac68k|macos/i)},iOS:function(){return navigator.userAgent.match(/iPhone|iPad|iPod/i)},any:function(){return s.Android()||s.macOS()||s.iOS()}},c={Chrome:function(){return navigator.userAgent.match(/Chrome/i)},Safari:function(){return navigator.vendor.match(/apple/i)&&!navigator.userAgent.match(/crios/i)&&!navigator.userAgent.match(/fxios/i)&&!navigator.userAgent.match(/Opera|OPT\//)},Edge:function(){return navigator.userAgent.match(/Edg/i)},Firefox:function(){return navigator.userAgent.match(/Firefox/i)},Opera:function(){return navigator.userAgent.match(/Opera/i)},Brave:function(){return navigator.userAgent.match(/Brave/i)},Aloha:function(){return navigator.userAgent.match(/Aloha/i)},any:function(){return c.Chrome()||c.Safari()||c.Edge()||c.Firefox()||c.Opera()||c.Brave()||c.Aloha()}};Object.values(a.CallbackBrowser).filter((r=>r.startsWith("iOS"))),Object.values(a.CallbackBrowser).filter((r=>r.startsWith("android"))),Object.values(a.CallbackBrowser).filter((r=>r.startsWith("macOS"))),exports.ERR_NEED_RETRY=o,exports.ERR_OPERATION_CANCELLED=t,exports.decodeMessageData=i,exports.encodeMessageData=n,exports.getCallbackBrowser=function(){if(s.Android()){if(c.Chrome())return a.CallbackBrowser.androidChrome;if(c.Edge())return a.CallbackBrowser.androidEdge;if(c.Firefox())return a.CallbackBrowser.androidFirefox;if(c.Opera())return a.CallbackBrowser.androidOpera;if(c.Brave())return a.CallbackBrowser.androidBrave;if(c.Aloha())return a.CallbackBrowser.androidAloha}else if(s.iOS()){if(c.Chrome())return a.CallbackBrowser.iOSChrome;if(c.Safari())return a.CallbackBrowser.iOSSafari;if(c.Edge())return a.CallbackBrowser.iOSEdge;if(c.Firefox())return a.CallbackBrowser.iOSFirefox;if(c.Opera())return a.CallbackBrowser.iOSOpera;if(c.Brave())return a.CallbackBrowser.iOSBrave;if(c.Aloha())return a.CallbackBrowser.iOSAloha}else if(s.macOS()){if(c.Chrome())return a.CallbackBrowser.macOSChrome;if(c.Safari())return a.CallbackBrowser.macOSSafari;if(c.Edge())return a.CallbackBrowser.macOSEdge;if(c.Firefox())return a.CallbackBrowser.macOSFirefox;if(c.Opera())return a.CallbackBrowser.macOSOpera;if(c.Brave())return a.CallbackBrowser.macOSBrave;if(c.Aloha())return a.CallbackBrowser.macOSAloha}},exports.isBrowser=c,exports.isDevice=s,exports.runWithErrorRetry=async function(r,e){const{signal:a,maxRetry:t=5,throttleInterval:n=3e3,backoffStrategyFactor:i,timeoutError:s}=e||{};let c=0,u=!0,l=!1;for(a?.addEventListener("abort",(function r(){l=!0,a?.removeEventListener("abort",r)}));u&&!l;){u=!1;try{return await r({retryCount:c})}catch(r){if(r===o&&c<t&&!l){c+=1,u=!0,await new Promise((r=>{setTimeout((()=>{r()}),n*(i?c*i:1))}));continue}throw r}}throw s||new Error("runWithErrorRetry no result")},exports.sendMessageAndWaitForResponse=function(r){const{socket:e,op:a,data:o,resolver:s,rejecter:c}=r,u=n({op:a,data:o});function l(r){e.off(f),c(r)}const f={success(r){try{const t=i(r);t.id===u.id&&t.op===a&&(t.success?(e.off(f),s(t.data)):l(new Error(t.error||"Unknown error")))}catch(r){l(r)}},error:l};return e.on(f),e.send(u.data),()=>{l(t)}},exports.shouldInvokeAppByDeepLink=function(r){const{identityStatus:e}=r;return e?.platform===a.POMPlatform.iOS&&s.iOS()||e?.platform===a.POMPlatform.Android&&s.Android()||e?.platform===a.POMPlatform.macOS&&s.macOS()}; | ||
"use strict";var r,e=require("@automata-network/pom-socket"),a=require("./index.js");exports.POMOperation=void 0,(r=exports.POMOperation||(exports.POMOperation={})).GetIdentityStatus="getIdentityStatus",r.AttestDevice="attestDevice",r.SignMessage="signMessage";const t=new Error("operation is cancelled"),o=new Error("need retry");function n(r){const{id:a=e.createRandomString(6),error:t}=r;return{id:a,data:JSON.stringify({id:a,success:null==t,error:t,...r})}}function i(r){return JSON.parse(r)}const s={Android:function(){return navigator.userAgent.match(/Android/i)},macOS:function(){return navigator.userAgent.match(/macintosh|macintel|macppc|mac68k|macos/i)},iOS:function(){return navigator.userAgent.match(/iPhone|iPad|iPod/i)},any:function(){return s.Android()||s.macOS()||s.iOS()}},c={Chrome:function(){return navigator.userAgent.match(/Chrome/i)},Safari:function(){return navigator.vendor.match(/apple/i)&&!navigator.userAgent.match(/crios/i)&&!navigator.userAgent.match(/fxios/i)&&!navigator.userAgent.match(/Opera|OPT\//)},Edge:function(){return navigator.userAgent.match(/Edg/i)},Firefox:function(){return navigator.userAgent.match(/Firefox/i)},Opera:function(){return navigator.userAgent.match(/Opera/i)},Brave:function(){return navigator.userAgent.match(/Brave/i)},Aloha:function(){return navigator.userAgent.match(/Aloha/i)},any:function(){return c.Chrome()||c.Safari()||c.Edge()||c.Firefox()||c.Opera()||c.Brave()||c.Aloha()}};exports.ERR_NEED_RETRY=o,exports.ERR_OPERATION_CANCELLED=t,exports.decodeMessageData=i,exports.encodeMessageData=n,exports.getCallbackBrowser=function(){if(s.Android()){if(c.Chrome())return a.CallbackBrowser.androidChrome;if(c.Edge())return a.CallbackBrowser.androidEdge;if(c.Firefox())return a.CallbackBrowser.androidFirefox;if(c.Opera())return a.CallbackBrowser.androidOpera;if(c.Brave())return a.CallbackBrowser.androidBrave;if(c.Aloha())return a.CallbackBrowser.androidAloha}else if(s.iOS()){if(c.Chrome())return a.CallbackBrowser.iOSChrome;if(c.Safari())return a.CallbackBrowser.iOSSafari;if(c.Edge())return a.CallbackBrowser.iOSEdge;if(c.Firefox())return a.CallbackBrowser.iOSFirefox;if(c.Opera())return a.CallbackBrowser.iOSOpera;if(c.Brave())return a.CallbackBrowser.iOSBrave;if(c.Aloha())return a.CallbackBrowser.iOSAloha}else if(s.macOS()){if(c.Chrome())return a.CallbackBrowser.macOSChrome;if(c.Safari())return a.CallbackBrowser.macOSSafari;if(c.Edge())return a.CallbackBrowser.macOSEdge;if(c.Firefox())return a.CallbackBrowser.macOSFirefox;if(c.Opera())return a.CallbackBrowser.macOSOpera;if(c.Brave())return a.CallbackBrowser.macOSBrave;if(c.Aloha())return a.CallbackBrowser.macOSAloha}},exports.isBrowser=c,exports.isDevice=s,exports.runWithErrorRetry=async function(r,e){const{signal:a,maxRetry:t=5,throttleInterval:n=3e3,backoffStrategyFactor:i,timeoutError:s}=e||{};let c=0,u=!0,f=!1;for(a?.addEventListener("abort",(function r(){f=!0,a?.removeEventListener("abort",r)}));u&&!f;){u=!1;try{return await r({retryCount:c})}catch(r){if(r===o&&c<t&&!f){c+=1,u=!0,await new Promise((r=>{setTimeout((()=>{r()}),n*(i?c*i:1))}));continue}throw r}}throw s||new Error("runWithErrorRetry no result")},exports.sendMessageAndWaitForResponse=function(r){const{socket:e,op:a,data:o,resolver:s,rejecter:c}=r,u=n({op:a,data:o});function f(r){e.off(l),c(r)}const l={success(r){try{const t=i(r);t.id===u.id&&t.op===a&&(t.success?(e.off(l),s(t.data)):f(new Error(t.error||"Unknown error")))}catch(r){f(r)}},error:f};return e.on(l),e.send(u.data),()=>{f(t)}},exports.shouldInvokeAppByDeepLink=function(r){const{identityStatus:e}=r;return e?.platform===a.POMPlatform.iOS&&s.iOS()||e?.platform===a.POMPlatform.Android&&s.Android()||e?.platform===a.POMPlatform.macOS&&s.macOS()}; | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "@automata-network/pom-js-sdk", | ||
"version": "0.0.79", | ||
"version": "0.0.80", | ||
"description": "A socket clinet for automata's Proof Of Machinehood", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -276,12 +276,2 @@ import {POMSocket, createRandomString} from '@automata-network/pom-socket'; | ||
const iOSBrowsers = Object.values(CallbackBrowser).filter(item => | ||
item.startsWith('iOS'), | ||
); | ||
const androidBrowsers = Object.values(CallbackBrowser).filter(item => | ||
item.startsWith('android'), | ||
); | ||
const macOSBrowsers = Object.values(CallbackBrowser).filter(item => | ||
item.startsWith('macOS'), | ||
); | ||
export function shouldInvokeAppByDeepLink(options: { | ||
@@ -288,0 +278,0 @@ identityStatus?: IdentityStatusResult; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
70448
965