@magic-sdk/react-native-expo 30.0.6-canary.dce1e01.0 → 30.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/es/index.js +1 -1
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var Mr=Object.create;var F=Object.defineProperty;var Lr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var Tr=Object.getPrototypeOf,kr=Object.prototype.hasOwnProperty;var d=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Br=(e,r)=>{for(var t in r)F(e,t,{get:r[t],enumerable:!0})},U=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Rr(r))!kr.call(e,a)&&a!==t&&F(e,a,{get:()=>r[a],enumerable:!(i=Lr(r,a))||i.enumerable});return e},v=(e,r,t)=>(U(e,r,"default"),t&&U(t,r,"default")),M=(e,r,t)=>(t=e!=null?Mr(Tr(e)):{},U(r||!e||!e.__esModule?F(t,"default",{value:e,enumerable:!0}):t,e)),Nr=e=>U(F({},"__esModule",{value:!0}),e);var Ve=d((Nt,fe)=>{"use strict";var ce=function(e){"use strict";var r=Object.prototype,t=r.hasOwnProperty,i,a=typeof Symbol=="function"?Symbol:{},u=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",m=a.toStringTag||"@@toStringTag";function y(o,n,s){return Object.defineProperty(o,n,{value:s,enumerable:!0,configurable:!0,writable:!0}),o[n]}try{y({},"")}catch{y=function(n,s,c){return n[s]=c}}function A(o,n,s,c){var l=n&&n.prototype instanceof ne?n:ne,p=Object.create(l.prototype),b=new se(c||[]);return p._invoke=Ar(o,s,b),p}e.wrap=A;function C(o,n,s){try{return{type:"normal",arg:o.call(n,s)}}catch(c){return{type:"throw",arg:c}}}var x="suspendedStart",te="suspendedYield",_="executing",N="completed",E={};function ne(){}function G(){}function R(){}var oe={};y(oe,u,function(){return this});var ie=Object.getPrototypeOf,V=ie&&ie(ie(ue([])));V&&V!==r&&t.call(V,u)&&(oe=V);var k=R.prototype=ne.prototype=Object.create(oe);G.prototype=R,y(k,"constructor",R),y(R,"constructor",G),G.displayName=y(R,m,"GeneratorFunction");function De(o){["next","throw","return"].forEach(function(n){y(o,n,function(s){return this._invoke(n,s)})})}e.isGeneratorFunction=function(o){var n=typeof o=="function"&&o.constructor;return n?n===G||(n.displayName||n.name)==="GeneratorFunction":!1},e.mark=function(o){return Object.setPrototypeOf?Object.setPrototypeOf(o,R):(o.__proto__=R,y(o,m,"GeneratorFunction")),o.prototype=Object.create(k),o},e.awrap=function(o){return{__await:o}};function K(o,n){function s(p,b,w,O){var I=C(o[p],o,b);if(I.type==="throw")O(I.arg);else{var le=I.arg,q=le.value;return q&&typeof q=="object"&&t.call(q,"__await")?n.resolve(q.__await).then(function(T){s("next",T,w,O)},function(T){s("throw",T,w,O)}):n.resolve(q).then(function(T){le.value=T,w(le)},function(T){return s("throw",T,w,O)})}}var c;function l(p,b){function w(){return new n(function(O,I){s(p,b,O,I)})}return c=c?c.then(w,w):w()}this._invoke=l}De(K.prototype),y(K.prototype,f,function(){return this}),e.AsyncIterator=K,e.async=function(o,n,s,c,l){l===void 0&&(l=Promise);var p=new K(A(o,n,s,c),l);return e.isGeneratorFunction(n)?p:p.next().then(function(b){return b.done?b.value:p.next()})};function Ar(o,n,s){var c=x;return function(p,b){if(c===_)throw new Error("Generator is already running");if(c===N){if(p==="throw")throw b;return Ge()}for(s.method=p,s.arg=b;;){var w=s.delegate;if(w){var O=xe(w,s);if(O){if(O===E)continue;return O}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===x)throw c=N,s.arg;s.dispatchException(s.arg)}else s.method==="return"&&s.abrupt("return",s.arg);c=_;var I=C(o,n,s);if(I.type==="normal"){if(c=s.done?N:te,I.arg===E)continue;return{value:I.arg,done:s.done}}else I.type==="throw"&&(c=N,s.method="throw",s.arg=I.arg)}}}function xe(o,n){var s=o.iterator[n.method];if(s===i){if(n.delegate=null,n.method==="throw"){if(o.iterator.return&&(n.method="return",n.arg=i,xe(o,n),n.method==="throw"))return E;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return E}var c=C(s,o.iterator,n.arg);if(c.type==="throw")return n.method="throw",n.arg=c.arg,n.delegate=null,E;var l=c.arg;if(!l)return n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,E;if(l.done)n[o.resultName]=l.value,n.next=o.nextLoc,n.method!=="return"&&(n.method="next",n.arg=i);else return l;return n.delegate=null,E}De(k),y(k,m,"Generator"),y(k,u,function(){return this}),y(k,"toString",function(){return"[object Generator]"});function Cr(o){var n={tryLoc:o[0]};1 in o&&(n.catchLoc=o[1]),2 in o&&(n.finallyLoc=o[2],n.afterLoc=o[3]),this.tryEntries.push(n)}function ae(o){var n=o.completion||{};n.type="normal",delete n.arg,o.completion=n}function se(o){this.tryEntries=[{tryLoc:"root"}],o.forEach(Cr,this),this.reset(!0)}e.keys=function(o){var n=[];for(var s in o)n.push(s);return n.reverse(),function c(){for(;n.length;){var l=n.pop();if(l in o)return c.value=l,c.done=!1,c}return c.done=!0,c}};function ue(o){if(o){var n=o[u];if(n)return n.call(o);if(typeof o.next=="function")return o;if(!isNaN(o.length)){var s=-1,c=function l(){for(;++s<o.length;)if(t.call(o,s))return l.value=o[s],l.done=!1,l;return l.value=i,l.done=!0,l};return c.next=c}}return{next:Ge}}e.values=ue;function Ge(){return{value:i,done:!0}}return se.prototype={constructor:se,reset:function(o){if(this.prev=0,this.next=0,this.sent=this._sent=i,this.done=!1,this.delegate=null,this.method="next",this.arg=i,this.tryEntries.forEach(ae),!o)for(var n in this)n.charAt(0)==="t"&&t.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=i)},stop:function(){this.done=!0;var o=this.tryEntries[0],n=o.completion;if(n.type==="throw")throw n.arg;return this.rval},dispatchException:function(o){if(this.done)throw o;var n=this;function s(O,I){return p.type="throw",p.arg=o,n.next=O,I&&(n.method="next",n.arg=i),!!I}for(var c=this.tryEntries.length-1;c>=0;--c){var l=this.tryEntries[c],p=l.completion;if(l.tryLoc==="root")return s("end");if(l.tryLoc<=this.prev){var b=t.call(l,"catchLoc"),w=t.call(l,"finallyLoc");if(b&&w){if(this.prev<l.catchLoc)return s(l.catchLoc,!0);if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else if(b){if(this.prev<l.catchLoc)return s(l.catchLoc,!0)}else if(w){if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(o,n){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc<=this.prev&&t.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var l=c;break}}l&&(o==="break"||o==="continue")&&l.tryLoc<=n&&n<=l.finallyLoc&&(l=null);var p=l?l.completion:{};return p.type=o,p.arg=n,l?(this.method="next",this.next=l.finallyLoc,E):this.complete(p)},complete:function(o,n){if(o.type==="throw")throw o.arg;return o.type==="break"||o.type==="continue"?this.next=o.arg:o.type==="return"?(this.rval=this.arg=o.arg,this.method="return",this.next="end"):o.type==="normal"&&n&&(this.next=n),E},finish:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.finallyLoc===o)return this.complete(s.completion,s.afterLoc),ae(s),E}},catch:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.tryLoc===o){var c=s.completion;if(c.type==="throw"){var l=c.arg;ae(s)}return l}}throw new Error("illegal catch attempt")},delegateYield:function(o,n,s){return this.delegate={iterator:ue(o),resultName:n,nextLoc:s},this.method==="next"&&(this.arg=i),E}},e}(typeof fe=="object"?fe.exports:{});try{regeneratorRuntime=ce}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ce:Function("r","regeneratorRuntime = r")(ce)}});var Ke=d(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he._driver="localforage-driver-memory"});var Ue=d(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});function qr(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(u){if(u.name!=="TypeError")throw u;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,i=new t,a=0;a<e.length;a+=1)i.append(e[a]);return i.getBlob(r.type)}}ve.createBlob=qr});var Je=d(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});var jr=Ue(),Fe=/^~~local_forage_type~([^~]+)~/,de=9,We=de+4,ze=Object.prototype.toString;function Ye(e){var r=e.length*.75,t=e.length;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);for(var i=new ArrayBuffer(r),a=new Uint8Array(i),u=0,f=0;u<t;u+=4){var m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u]),y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+1]),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+2]),C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+3]);a[f++]=m<<2|y>>4,a[f++]=(y&15)<<4|A>>2,a[f++]=(A&3)<<6|C&63}return i}B.stringToBuffer=Ye;function me(e){for(var r=new Uint8Array(e),t="",i=0;i<r.length;i+=3)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i]>>2],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i]&3)<<4|r[i+1]>>4],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i+1]&15)<<2|r[i+2]>>6],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}B.bufferToString=me;function Dr(e,r){var t="";if(e&&(t=ze.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&ze.call(e.buffer)==="[object ArrayBuffer]")){var i=void 0,a="__lfsc__:";e instanceof ArrayBuffer?(i=e,a+="arbf"):(i=e.buffer,t==="[object Int8Array]"?a+="si08":t==="[object Uint8Array]"?a+="ui08":t==="[object Uint8ClampedArray]"?a+="uic8":t==="[object Int16Array]"?a+="si16":t==="[object Uint16Array]"?a+="ur16":t==="[object Int32Array]"?a+="si32":t==="[object Uint32Array]"?a+="ui32":t==="[object Float32Array]"?a+="fl32":t==="[object Float64Array]"?a+="fl64":r(new Error("Failed to get type for BinaryArray"))),r(a+me(i))}else if(t==="[object Blob]"){var u=new FileReader;u.onload=function(){var f="~~local_forage_type~"+e.type+"~"+me(this.result);r("__lfsc__:blob"+f)},u.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}B.serialize=Dr;function xr(e){if(e.substring(0,de)!=="__lfsc__:")return JSON.parse(e);var r=e.substring(We),t=e.substring(de,We),i;if(t==="blob"&&Fe.test(r)){var a=r.match(Fe);i=a[1],r=r.substring(a[0].length)}var u=Ye(r);switch(t){case"arbf":return u;case"blob":return jr.createBlob([u],{type:i});case"si08":return new Int8Array(u);case"ui08":return new Uint8Array(u);case"uic8":return new Uint8ClampedArray(u);case"si16":return new Int16Array(u);case"ur16":return new Uint16Array(u);case"si32":return new Int32Array(u);case"ui32":return new Uint32Array(u);case"fl32":return new Float32Array(u);case"fl64":return new Float64Array(u);default:throw new Error("Unkown type: "+t)}}B.deserialize=xr});var Xe=d(j=>{"use strict";var Gr=j&&j.__values||function(e){var r=typeof Symbol=="function"&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}};Object.defineProperty(j,"__esModule",{value:!0});function He(e){var r,t;if(e===null||typeof e!="object"||"isActiveClone"in e)return e;var i=e instanceof Date?new Date(e):e.constructor();try{for(var a=Gr(Object.keys(e)),u=a.next();!u.done;u=a.next()){var f=u.value;Object.prototype.hasOwnProperty.call(e,f)&&(e.isActiveClone=null,i[f]=He(e[f]),delete e.isActiveClone)}}catch(m){r={error:m}}finally{try{u&&!u.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}return i}j.clone=He});var ye=d(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});function Vr(e,r){return(e.name||r.name)+"/"+(e.storeName||r.storeName)+"/"}pe.getKeyPrefix=Vr});var Ze=d(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});function Kr(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}ge.executeCallback=Kr});var be=d(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});function Ur(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}_e.getCallback=Ur});var Qe=d(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});var Fr=be(),Wr=ye();function zr(e,r){var t=this;if(r=Fr.getCallback.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var i=this.config();e.name=e.name||i.name,e.storeName=e.storeName||i.storeName}var a;return e.name?a=new Promise(function(u){e.storeName?u(Wr.getKeyPrefix(e,t._defaultConfig)):u(e.name+"/")}):a=Promise.reject("Invalid arguments"),{promise:a,callback:r}}we.dropInstanceCommon=zr});var $e=d(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});function Yr(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}Ie.normaliseKey=Yr});var P=d(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});var W=Je(),Jr=Xe();L.clone=Jr.clone;var Hr=ye();L.getKeyPrefix=Hr.getKeyPrefix;var Xr=Ze();L.executeCallback=Xr.executeCallback;var Zr=be();L.getCallback=Zr.getCallback;var Qr=Qe();L.dropInstanceCommon=Qr.dropInstanceCommon;var $r=$e();L.normaliseKey=$r.normaliseKey;L.serialiser={bufferToString:W.bufferToString,deserialize:W.deserialize,serialize:W.serialize,stringToBuffer:W.stringToBuffer}});var Ee=d(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});var z={},et=function(){function e(r){this.kp=r,this.data={}}return e.resolve=function(r){return z[r]||(z[r]=new e(r)),z[r]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete z[this.kp]},e.prototype.get=function(r){return this.data[r]},e.prototype.key=function(r){return this.keys()[r]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(r){delete this.data[r]},e.prototype.set=function(r,t){this.data[r]=t},e}();Se.Store=et});var er=d(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});var Oe=P(),rt=Ee();function tt(e){var r=e?Oe.clone(e):{},t=Oe.getKeyPrefix(r,this._defaultConfig),i=rt.Store.resolve(t);return this._dbInfo=r,this._dbInfo.serializer=Oe.serialiser,this._dbInfo.keyPrefix=t,this._dbInfo.mStore=i,Promise.resolve()}Pe._initStorage=tt});var rr=d(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});var nt=P();function ot(e){var r=this,t=this.ready().then(function(){r._dbInfo.mStore.clear()});return nt.executeCallback(t,e),t}Ae.clear=ot});var nr=d(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});var tr=P(),it=Ee();function at(e,r){var t=tr.dropInstanceCommon.apply(this,arguments),i=t.promise,a=t.callback,u=i.then(function(f){it.Store.resolve(f).drop()});return tr.executeCallback(u,a),i}Ce.dropInstance=at});var ir=d(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});var or=P();function st(e,r){var t=this;e=or.normaliseKey(e);var i=this.ready().then(function(){var a=t._dbInfo.mStore.get(e);return a==null?null:t._dbInfo.serializer.deserialize(a)});return or.executeCallback(i,r),i}Me.getItem=st});var ar=d(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var ut=P();function lt(e,r){var t=this,i=this.ready().then(function(){for(var a=t._dbInfo.mStore,u=a.keys(),f=0;f<u.length;f++){var m=a.get(u[f]);if(m&&(m=t._dbInfo.serializer.deserialize(m)),m=e(m,u[f],f+1),m!==void 0)return m}});return ut.executeCallback(i,r),i}Le.iterate=lt});var sr=d(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});var ct=P();function ft(e,r){var t=this,i=this.ready().then(function(){var a;try{a=t._dbInfo.mStore.key(e),a===void 0&&(a=null)}catch{a=null}return a});return ct.executeCallback(i,r),i}Re.key=ft});var ur=d(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});var ht=P();function vt(e){var r=this,t=this.ready().then(function(){return r._dbInfo.mStore.keys()});return ht.executeCallback(t,e),t}Te.keys=vt});var lr=d(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});var dt=P();function mt(e){var r=this.keys().then(function(t){return t.length});return dt.executeCallback(r,e),r}ke.length=mt});var fr=d(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});var cr=P();function pt(e,r){var t=this;e=cr.normaliseKey(e);var i=this.ready().then(function(){t._dbInfo.mStore.rm(e)});return cr.executeCallback(i,r),i}Be.removeItem=pt});var vr=d(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});var hr=P();function yt(e,r,t){var i=this;e=hr.normaliseKey(e);var a=this.ready().then(function(){r===void 0&&(r=null);var u=r;return new Promise(function(f,m){i._dbInfo.serializer.serialize(r,function(y,A){if(A)m(A);else try{i._dbInfo.mStore.set(e,y),f(u)}catch(C){m(C)}})})});return hr.executeCallback(a,t),a}Ne.setItem=yt});var dr=d(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S._support=!0;var gt=Ke();S._driver=gt._driver;var _t=er();S._initStorage=_t._initStorage;var bt=rr();S.clear=bt.clear;var wt=nr();S.dropInstance=wt.dropInstance;var It=ir();S.getItem=It.getItem;var St=ar();S.iterate=St.iterate;var Et=sr();S.key=Et.key;var Ot=ur();S.keys=Ot.keys;var Pt=lr();S.length=Pt.length;var At=fr();S.removeItem=At.removeItem;var Ct=vr();S.setItem=Ct.setItem});var h={};Br(h,{Magic:()=>kt,useInternetConnection:()=>J});module.exports=Nr(h);var fn=M(Ve()),Ir=require("@magic-sdk/provider"),Tt=M(require("process")),Sr=M(require("localforage")),ee=require("whatwg-url"),re=require("buffer"),Er=M(require("lodash")),Or=M(require("expo-application")),Pr=require("@aveq-research/localforage-asyncstorage-driver"),je=M(dr());var g=M(require("react")),Z=require("react-native"),gr=require("react-native-webview"),_r=require("react-native-safe-area-context"),Q=require("@magic-sdk/provider"),br=require("lodash"),D=M(require("@react-native-async-storage/async-storage")),qe=require("react-native-event-listeners");var Y=require("react"),mr=M(require("@react-native-community/netinfo")),J=()=>{let[e,r]=(0,Y.useState)(!0);return(0,Y.useEffect)(()=>{let t=i=>{r(!!i.isConnected)};return mr.default.addEventListener(t)},[]),e};var pr="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Mt="open_in_device_browser",Lt="#FFFFFF",yr="msg_posted_after_inactivity_event",H="lastMessageTime";function Rt(){return Z.StyleSheet.create({"magic-webview":{flex:1,backgroundColor:"transparent"},"webview-container":{flex:1,width:"100%",backgroundColor:"transparent",position:"absolute",top:0,left:0,right:0,bottom:0},show:{zIndex:1e4,elevation:1e4},hide:{zIndex:-1e4,elevation:0}})}var X=class extends Q.ViewController{webView;container;styles;init(){this.webView=null,this.container=null,this.styles=Rt()}Relayer=r=>{let[t,i]=(0,g.useState)(!1),[a,u]=(0,g.useState)(!0),f=J();(0,g.useEffect)(()=>{this.isConnectedToInternet=f},[f]),(0,g.useEffect)(()=>(D.default.setItem(H,""),()=>{this.isReadyForRequest=!1}),[]),(0,g.useEffect)(()=>{qe.EventRegister.addEventListener(yr,async _=>{this.isReadyForRequest=!1,u(!1),this.post(_.msgType,_.payload),await D.default.setItem(H,new Date().toISOString())})},[]),(0,g.useEffect)(()=>{a||setTimeout(()=>u(!0),10)},[a]);let m=(0,g.useCallback)(_=>{this.webView=_},[]),y=(0,g.useCallback)(_=>{this.container={..._,showOverlay:A,hideOverlay:C}},[]),A=(0,g.useCallback)(()=>{i(!0)},[]),C=(0,g.useCallback)(()=>{i(!1)},[]),x=(0,g.useMemo)(()=>[this.styles["webview-container"],t?{...this.styles.show,backgroundColor:r??Lt}:this.styles.hide],[t]),te=(0,g.useCallback)(_=>{this.handleReactNativeWebViewMessage(_)},[]);return a?g.default.createElement(_r.SafeAreaView,{ref:y,style:x},g.default.createElement(gr.WebView,{ref:m,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:te,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:_=>new URLSearchParams(_.url.split("?")[1]).get(Mt)?(Z.Linking.openURL(_.url),!1):!0})):null};handleReactNativeWebViewMessage(r){if(r.nativeEvent&&typeof r.nativeEvent.data=="string"&&(r.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||r.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let t=JSON.parse(r.nativeEvent.data,(i,a)=>{try{if(a&&typeof a=="object"&&a.flag&&a.flag===pr)return new global[a.constructor](a.data.split(","))}catch{}return a});if(t&&t.msgType&&this.messageHandlers.size){t.response=t.response??{};let i={data:t};for(let a of this.messageHandlers.values())a(i)}}}async msgPostedAfterInactivity(){let r=await D.default.getItem(H);if(r){let t=new Date(r).getTime(),i=new Date().getTime(),a=5*60*1e3;return i-t>a}return!1}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}async _post(r){if(await this.msgPostedAfterInactivity()){qe.EventRegister.emit(yr,r);return}if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(r,(t,i)=>(0,br.isTypedArray)(i)?{constructor:i.constructor.name,data:i.toString(),flag:pr}:i),this.endpoint),D.default.setItem(H,new Date().toISOString());else throw(0,Q.createModalNotReadyError)()}checkRelayerExistsInDOM(){return Promise.resolve(!0)}reloadRelayer(){return Promise.resolve(void 0)}};var wr=require("@magic-sdk/provider"),$=class extends wr.SDKBase{get Relayer(){return this.overlay.Relayer}};v(h,require("@magic-sdk/commons"),module.exports);global.process=Er.merge(global.process,Tt);global.process.browser=!1;global.Buffer=re.Buffer;global.URL=ee.URL;global.URLSearchParams=ee.URLSearchParams;global.btoa=e=>re.Buffer.from(e,"binary").toString("base64");global.atob=e=>re.Buffer.from(e,"base64").toString("binary");var kt=(0,Ir.createSDK)($,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"30.0.5",bundleId:Or.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:X,configureStorage:async()=>{let e=Sr.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),r=(0,Pr.driverWithoutSerialization)();return await Promise.all([e.defineDriver(r),e.defineDriver(je)]),await e.setDriver([r._driver,je._driver]),e}});0&&(module.exports={Magic,useInternetConnection,...require("@magic-sdk/commons")});
|
1
|
+
"use strict";var Mr=Object.create;var F=Object.defineProperty;var Lr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var Tr=Object.getPrototypeOf,kr=Object.prototype.hasOwnProperty;var d=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Br=(e,r)=>{for(var t in r)F(e,t,{get:r[t],enumerable:!0})},U=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Rr(r))!kr.call(e,a)&&a!==t&&F(e,a,{get:()=>r[a],enumerable:!(i=Lr(r,a))||i.enumerable});return e},v=(e,r,t)=>(U(e,r,"default"),t&&U(t,r,"default")),M=(e,r,t)=>(t=e!=null?Mr(Tr(e)):{},U(r||!e||!e.__esModule?F(t,"default",{value:e,enumerable:!0}):t,e)),Nr=e=>U(F({},"__esModule",{value:!0}),e);var Ve=d((Nt,fe)=>{"use strict";var ce=function(e){"use strict";var r=Object.prototype,t=r.hasOwnProperty,i,a=typeof Symbol=="function"?Symbol:{},u=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",m=a.toStringTag||"@@toStringTag";function y(o,n,s){return Object.defineProperty(o,n,{value:s,enumerable:!0,configurable:!0,writable:!0}),o[n]}try{y({},"")}catch{y=function(n,s,c){return n[s]=c}}function A(o,n,s,c){var l=n&&n.prototype instanceof ne?n:ne,p=Object.create(l.prototype),b=new se(c||[]);return p._invoke=Ar(o,s,b),p}e.wrap=A;function C(o,n,s){try{return{type:"normal",arg:o.call(n,s)}}catch(c){return{type:"throw",arg:c}}}var x="suspendedStart",te="suspendedYield",_="executing",N="completed",E={};function ne(){}function G(){}function R(){}var oe={};y(oe,u,function(){return this});var ie=Object.getPrototypeOf,V=ie&&ie(ie(ue([])));V&&V!==r&&t.call(V,u)&&(oe=V);var k=R.prototype=ne.prototype=Object.create(oe);G.prototype=R,y(k,"constructor",R),y(R,"constructor",G),G.displayName=y(R,m,"GeneratorFunction");function De(o){["next","throw","return"].forEach(function(n){y(o,n,function(s){return this._invoke(n,s)})})}e.isGeneratorFunction=function(o){var n=typeof o=="function"&&o.constructor;return n?n===G||(n.displayName||n.name)==="GeneratorFunction":!1},e.mark=function(o){return Object.setPrototypeOf?Object.setPrototypeOf(o,R):(o.__proto__=R,y(o,m,"GeneratorFunction")),o.prototype=Object.create(k),o},e.awrap=function(o){return{__await:o}};function K(o,n){function s(p,b,w,O){var I=C(o[p],o,b);if(I.type==="throw")O(I.arg);else{var le=I.arg,q=le.value;return q&&typeof q=="object"&&t.call(q,"__await")?n.resolve(q.__await).then(function(T){s("next",T,w,O)},function(T){s("throw",T,w,O)}):n.resolve(q).then(function(T){le.value=T,w(le)},function(T){return s("throw",T,w,O)})}}var c;function l(p,b){function w(){return new n(function(O,I){s(p,b,O,I)})}return c=c?c.then(w,w):w()}this._invoke=l}De(K.prototype),y(K.prototype,f,function(){return this}),e.AsyncIterator=K,e.async=function(o,n,s,c,l){l===void 0&&(l=Promise);var p=new K(A(o,n,s,c),l);return e.isGeneratorFunction(n)?p:p.next().then(function(b){return b.done?b.value:p.next()})};function Ar(o,n,s){var c=x;return function(p,b){if(c===_)throw new Error("Generator is already running");if(c===N){if(p==="throw")throw b;return Ge()}for(s.method=p,s.arg=b;;){var w=s.delegate;if(w){var O=xe(w,s);if(O){if(O===E)continue;return O}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===x)throw c=N,s.arg;s.dispatchException(s.arg)}else s.method==="return"&&s.abrupt("return",s.arg);c=_;var I=C(o,n,s);if(I.type==="normal"){if(c=s.done?N:te,I.arg===E)continue;return{value:I.arg,done:s.done}}else I.type==="throw"&&(c=N,s.method="throw",s.arg=I.arg)}}}function xe(o,n){var s=o.iterator[n.method];if(s===i){if(n.delegate=null,n.method==="throw"){if(o.iterator.return&&(n.method="return",n.arg=i,xe(o,n),n.method==="throw"))return E;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return E}var c=C(s,o.iterator,n.arg);if(c.type==="throw")return n.method="throw",n.arg=c.arg,n.delegate=null,E;var l=c.arg;if(!l)return n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,E;if(l.done)n[o.resultName]=l.value,n.next=o.nextLoc,n.method!=="return"&&(n.method="next",n.arg=i);else return l;return n.delegate=null,E}De(k),y(k,m,"Generator"),y(k,u,function(){return this}),y(k,"toString",function(){return"[object Generator]"});function Cr(o){var n={tryLoc:o[0]};1 in o&&(n.catchLoc=o[1]),2 in o&&(n.finallyLoc=o[2],n.afterLoc=o[3]),this.tryEntries.push(n)}function ae(o){var n=o.completion||{};n.type="normal",delete n.arg,o.completion=n}function se(o){this.tryEntries=[{tryLoc:"root"}],o.forEach(Cr,this),this.reset(!0)}e.keys=function(o){var n=[];for(var s in o)n.push(s);return n.reverse(),function c(){for(;n.length;){var l=n.pop();if(l in o)return c.value=l,c.done=!1,c}return c.done=!0,c}};function ue(o){if(o){var n=o[u];if(n)return n.call(o);if(typeof o.next=="function")return o;if(!isNaN(o.length)){var s=-1,c=function l(){for(;++s<o.length;)if(t.call(o,s))return l.value=o[s],l.done=!1,l;return l.value=i,l.done=!0,l};return c.next=c}}return{next:Ge}}e.values=ue;function Ge(){return{value:i,done:!0}}return se.prototype={constructor:se,reset:function(o){if(this.prev=0,this.next=0,this.sent=this._sent=i,this.done=!1,this.delegate=null,this.method="next",this.arg=i,this.tryEntries.forEach(ae),!o)for(var n in this)n.charAt(0)==="t"&&t.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=i)},stop:function(){this.done=!0;var o=this.tryEntries[0],n=o.completion;if(n.type==="throw")throw n.arg;return this.rval},dispatchException:function(o){if(this.done)throw o;var n=this;function s(O,I){return p.type="throw",p.arg=o,n.next=O,I&&(n.method="next",n.arg=i),!!I}for(var c=this.tryEntries.length-1;c>=0;--c){var l=this.tryEntries[c],p=l.completion;if(l.tryLoc==="root")return s("end");if(l.tryLoc<=this.prev){var b=t.call(l,"catchLoc"),w=t.call(l,"finallyLoc");if(b&&w){if(this.prev<l.catchLoc)return s(l.catchLoc,!0);if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else if(b){if(this.prev<l.catchLoc)return s(l.catchLoc,!0)}else if(w){if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(o,n){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc<=this.prev&&t.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var l=c;break}}l&&(o==="break"||o==="continue")&&l.tryLoc<=n&&n<=l.finallyLoc&&(l=null);var p=l?l.completion:{};return p.type=o,p.arg=n,l?(this.method="next",this.next=l.finallyLoc,E):this.complete(p)},complete:function(o,n){if(o.type==="throw")throw o.arg;return o.type==="break"||o.type==="continue"?this.next=o.arg:o.type==="return"?(this.rval=this.arg=o.arg,this.method="return",this.next="end"):o.type==="normal"&&n&&(this.next=n),E},finish:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.finallyLoc===o)return this.complete(s.completion,s.afterLoc),ae(s),E}},catch:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.tryLoc===o){var c=s.completion;if(c.type==="throw"){var l=c.arg;ae(s)}return l}}throw new Error("illegal catch attempt")},delegateYield:function(o,n,s){return this.delegate={iterator:ue(o),resultName:n,nextLoc:s},this.method==="next"&&(this.arg=i),E}},e}(typeof fe=="object"?fe.exports:{});try{regeneratorRuntime=ce}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ce:Function("r","regeneratorRuntime = r")(ce)}});var Ke=d(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he._driver="localforage-driver-memory"});var Ue=d(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});function qr(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(u){if(u.name!=="TypeError")throw u;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,i=new t,a=0;a<e.length;a+=1)i.append(e[a]);return i.getBlob(r.type)}}ve.createBlob=qr});var Je=d(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});var jr=Ue(),Fe=/^~~local_forage_type~([^~]+)~/,de=9,We=de+4,ze=Object.prototype.toString;function Ye(e){var r=e.length*.75,t=e.length;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);for(var i=new ArrayBuffer(r),a=new Uint8Array(i),u=0,f=0;u<t;u+=4){var m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u]),y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+1]),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+2]),C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+3]);a[f++]=m<<2|y>>4,a[f++]=(y&15)<<4|A>>2,a[f++]=(A&3)<<6|C&63}return i}B.stringToBuffer=Ye;function me(e){for(var r=new Uint8Array(e),t="",i=0;i<r.length;i+=3)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i]>>2],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i]&3)<<4|r[i+1]>>4],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i+1]&15)<<2|r[i+2]>>6],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}B.bufferToString=me;function Dr(e,r){var t="";if(e&&(t=ze.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&ze.call(e.buffer)==="[object ArrayBuffer]")){var i=void 0,a="__lfsc__:";e instanceof ArrayBuffer?(i=e,a+="arbf"):(i=e.buffer,t==="[object Int8Array]"?a+="si08":t==="[object Uint8Array]"?a+="ui08":t==="[object Uint8ClampedArray]"?a+="uic8":t==="[object Int16Array]"?a+="si16":t==="[object Uint16Array]"?a+="ur16":t==="[object Int32Array]"?a+="si32":t==="[object Uint32Array]"?a+="ui32":t==="[object Float32Array]"?a+="fl32":t==="[object Float64Array]"?a+="fl64":r(new Error("Failed to get type for BinaryArray"))),r(a+me(i))}else if(t==="[object Blob]"){var u=new FileReader;u.onload=function(){var f="~~local_forage_type~"+e.type+"~"+me(this.result);r("__lfsc__:blob"+f)},u.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}B.serialize=Dr;function xr(e){if(e.substring(0,de)!=="__lfsc__:")return JSON.parse(e);var r=e.substring(We),t=e.substring(de,We),i;if(t==="blob"&&Fe.test(r)){var a=r.match(Fe);i=a[1],r=r.substring(a[0].length)}var u=Ye(r);switch(t){case"arbf":return u;case"blob":return jr.createBlob([u],{type:i});case"si08":return new Int8Array(u);case"ui08":return new Uint8Array(u);case"uic8":return new Uint8ClampedArray(u);case"si16":return new Int16Array(u);case"ur16":return new Uint16Array(u);case"si32":return new Int32Array(u);case"ui32":return new Uint32Array(u);case"fl32":return new Float32Array(u);case"fl64":return new Float64Array(u);default:throw new Error("Unkown type: "+t)}}B.deserialize=xr});var Xe=d(j=>{"use strict";var Gr=j&&j.__values||function(e){var r=typeof Symbol=="function"&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}};Object.defineProperty(j,"__esModule",{value:!0});function He(e){var r,t;if(e===null||typeof e!="object"||"isActiveClone"in e)return e;var i=e instanceof Date?new Date(e):e.constructor();try{for(var a=Gr(Object.keys(e)),u=a.next();!u.done;u=a.next()){var f=u.value;Object.prototype.hasOwnProperty.call(e,f)&&(e.isActiveClone=null,i[f]=He(e[f]),delete e.isActiveClone)}}catch(m){r={error:m}}finally{try{u&&!u.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}return i}j.clone=He});var ye=d(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});function Vr(e,r){return(e.name||r.name)+"/"+(e.storeName||r.storeName)+"/"}pe.getKeyPrefix=Vr});var Ze=d(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});function Kr(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}ge.executeCallback=Kr});var be=d(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});function Ur(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}_e.getCallback=Ur});var Qe=d(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});var Fr=be(),Wr=ye();function zr(e,r){var t=this;if(r=Fr.getCallback.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var i=this.config();e.name=e.name||i.name,e.storeName=e.storeName||i.storeName}var a;return e.name?a=new Promise(function(u){e.storeName?u(Wr.getKeyPrefix(e,t._defaultConfig)):u(e.name+"/")}):a=Promise.reject("Invalid arguments"),{promise:a,callback:r}}we.dropInstanceCommon=zr});var $e=d(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});function Yr(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}Ie.normaliseKey=Yr});var P=d(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});var W=Je(),Jr=Xe();L.clone=Jr.clone;var Hr=ye();L.getKeyPrefix=Hr.getKeyPrefix;var Xr=Ze();L.executeCallback=Xr.executeCallback;var Zr=be();L.getCallback=Zr.getCallback;var Qr=Qe();L.dropInstanceCommon=Qr.dropInstanceCommon;var $r=$e();L.normaliseKey=$r.normaliseKey;L.serialiser={bufferToString:W.bufferToString,deserialize:W.deserialize,serialize:W.serialize,stringToBuffer:W.stringToBuffer}});var Ee=d(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});var z={},et=function(){function e(r){this.kp=r,this.data={}}return e.resolve=function(r){return z[r]||(z[r]=new e(r)),z[r]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete z[this.kp]},e.prototype.get=function(r){return this.data[r]},e.prototype.key=function(r){return this.keys()[r]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(r){delete this.data[r]},e.prototype.set=function(r,t){this.data[r]=t},e}();Se.Store=et});var er=d(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});var Oe=P(),rt=Ee();function tt(e){var r=e?Oe.clone(e):{},t=Oe.getKeyPrefix(r,this._defaultConfig),i=rt.Store.resolve(t);return this._dbInfo=r,this._dbInfo.serializer=Oe.serialiser,this._dbInfo.keyPrefix=t,this._dbInfo.mStore=i,Promise.resolve()}Pe._initStorage=tt});var rr=d(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});var nt=P();function ot(e){var r=this,t=this.ready().then(function(){r._dbInfo.mStore.clear()});return nt.executeCallback(t,e),t}Ae.clear=ot});var nr=d(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});var tr=P(),it=Ee();function at(e,r){var t=tr.dropInstanceCommon.apply(this,arguments),i=t.promise,a=t.callback,u=i.then(function(f){it.Store.resolve(f).drop()});return tr.executeCallback(u,a),i}Ce.dropInstance=at});var ir=d(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});var or=P();function st(e,r){var t=this;e=or.normaliseKey(e);var i=this.ready().then(function(){var a=t._dbInfo.mStore.get(e);return a==null?null:t._dbInfo.serializer.deserialize(a)});return or.executeCallback(i,r),i}Me.getItem=st});var ar=d(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var ut=P();function lt(e,r){var t=this,i=this.ready().then(function(){for(var a=t._dbInfo.mStore,u=a.keys(),f=0;f<u.length;f++){var m=a.get(u[f]);if(m&&(m=t._dbInfo.serializer.deserialize(m)),m=e(m,u[f],f+1),m!==void 0)return m}});return ut.executeCallback(i,r),i}Le.iterate=lt});var sr=d(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});var ct=P();function ft(e,r){var t=this,i=this.ready().then(function(){var a;try{a=t._dbInfo.mStore.key(e),a===void 0&&(a=null)}catch{a=null}return a});return ct.executeCallback(i,r),i}Re.key=ft});var ur=d(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});var ht=P();function vt(e){var r=this,t=this.ready().then(function(){return r._dbInfo.mStore.keys()});return ht.executeCallback(t,e),t}Te.keys=vt});var lr=d(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});var dt=P();function mt(e){var r=this.keys().then(function(t){return t.length});return dt.executeCallback(r,e),r}ke.length=mt});var fr=d(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});var cr=P();function pt(e,r){var t=this;e=cr.normaliseKey(e);var i=this.ready().then(function(){t._dbInfo.mStore.rm(e)});return cr.executeCallback(i,r),i}Be.removeItem=pt});var vr=d(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});var hr=P();function yt(e,r,t){var i=this;e=hr.normaliseKey(e);var a=this.ready().then(function(){r===void 0&&(r=null);var u=r;return new Promise(function(f,m){i._dbInfo.serializer.serialize(r,function(y,A){if(A)m(A);else try{i._dbInfo.mStore.set(e,y),f(u)}catch(C){m(C)}})})});return hr.executeCallback(a,t),a}Ne.setItem=yt});var dr=d(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S._support=!0;var gt=Ke();S._driver=gt._driver;var _t=er();S._initStorage=_t._initStorage;var bt=rr();S.clear=bt.clear;var wt=nr();S.dropInstance=wt.dropInstance;var It=ir();S.getItem=It.getItem;var St=ar();S.iterate=St.iterate;var Et=sr();S.key=Et.key;var Ot=ur();S.keys=Ot.keys;var Pt=lr();S.length=Pt.length;var At=fr();S.removeItem=At.removeItem;var Ct=vr();S.setItem=Ct.setItem});var h={};Br(h,{Magic:()=>kt,useInternetConnection:()=>J});module.exports=Nr(h);var fn=M(Ve()),Ir=require("@magic-sdk/provider"),Tt=M(require("process")),Sr=M(require("localforage")),ee=require("whatwg-url"),re=require("buffer"),Er=M(require("lodash")),Or=M(require("expo-application")),Pr=require("@aveq-research/localforage-asyncstorage-driver"),je=M(dr());var g=M(require("react")),Z=require("react-native"),gr=require("react-native-webview"),_r=require("react-native-safe-area-context"),Q=require("@magic-sdk/provider"),br=require("lodash"),D=M(require("@react-native-async-storage/async-storage")),qe=require("react-native-event-listeners");var Y=require("react"),mr=M(require("@react-native-community/netinfo")),J=()=>{let[e,r]=(0,Y.useState)(!0);return(0,Y.useEffect)(()=>{let t=i=>{r(!!i.isConnected)};return mr.default.addEventListener(t)},[]),e};var pr="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Mt="open_in_device_browser",Lt="#FFFFFF",yr="msg_posted_after_inactivity_event",H="lastMessageTime";function Rt(){return Z.StyleSheet.create({"magic-webview":{flex:1,backgroundColor:"transparent"},"webview-container":{flex:1,width:"100%",backgroundColor:"transparent",position:"absolute",top:0,left:0,right:0,bottom:0},show:{zIndex:1e4,elevation:1e4},hide:{zIndex:-1e4,elevation:0}})}var X=class extends Q.ViewController{webView;container;styles;init(){this.webView=null,this.container=null,this.styles=Rt()}Relayer=r=>{let[t,i]=(0,g.useState)(!1),[a,u]=(0,g.useState)(!0),f=J();(0,g.useEffect)(()=>{this.isConnectedToInternet=f},[f]),(0,g.useEffect)(()=>(D.default.setItem(H,""),()=>{this.isReadyForRequest=!1}),[]),(0,g.useEffect)(()=>{qe.EventRegister.addEventListener(yr,async _=>{this.isReadyForRequest=!1,u(!1),this.post(_.msgType,_.payload),await D.default.setItem(H,new Date().toISOString())})},[]),(0,g.useEffect)(()=>{a||setTimeout(()=>u(!0),10)},[a]);let m=(0,g.useCallback)(_=>{this.webView=_},[]),y=(0,g.useCallback)(_=>{this.container={..._,showOverlay:A,hideOverlay:C}},[]),A=(0,g.useCallback)(()=>{i(!0)},[]),C=(0,g.useCallback)(()=>{i(!1)},[]),x=(0,g.useMemo)(()=>[this.styles["webview-container"],t?{...this.styles.show,backgroundColor:r??Lt}:this.styles.hide],[t]),te=(0,g.useCallback)(_=>{this.handleReactNativeWebViewMessage(_)},[]);return a?g.default.createElement(_r.SafeAreaView,{ref:y,style:x},g.default.createElement(gr.WebView,{ref:m,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:te,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:_=>new URLSearchParams(_.url.split("?")[1]).get(Mt)?(Z.Linking.openURL(_.url),!1):!0})):null};handleReactNativeWebViewMessage(r){if(r.nativeEvent&&typeof r.nativeEvent.data=="string"&&(r.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||r.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let t=JSON.parse(r.nativeEvent.data,(i,a)=>{try{if(a&&typeof a=="object"&&a.flag&&a.flag===pr)return new global[a.constructor](a.data.split(","))}catch{}return a});if(t&&t.msgType&&this.messageHandlers.size){t.response=t.response??{};let i={data:t};for(let a of this.messageHandlers.values())a(i)}}}async msgPostedAfterInactivity(){let r=await D.default.getItem(H);if(r){let t=new Date(r).getTime(),i=new Date().getTime(),a=5*60*1e3;return i-t>a}return!1}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}async _post(r){if(await this.msgPostedAfterInactivity()){qe.EventRegister.emit(yr,r);return}if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(r,(t,i)=>(0,br.isTypedArray)(i)?{constructor:i.constructor.name,data:i.toString(),flag:pr}:i),this.endpoint),D.default.setItem(H,new Date().toISOString());else throw(0,Q.createModalNotReadyError)()}checkRelayerExistsInDOM(){return Promise.resolve(!0)}reloadRelayer(){return Promise.resolve(void 0)}};var wr=require("@magic-sdk/provider"),$=class extends wr.SDKBase{get Relayer(){return this.overlay.Relayer}};v(h,require("@magic-sdk/commons"),module.exports);global.process=Er.merge(global.process,Tt);global.process.browser=!1;global.Buffer=re.Buffer;global.URL=ee.URL;global.URLSearchParams=ee.URLSearchParams;global.btoa=e=>re.Buffer.from(e,"binary").toString("base64");global.atob=e=>re.Buffer.from(e,"base64").toString("binary");var kt=(0,Ir.createSDK)($,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"30.0.6",bundleId:Or.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:X,configureStorage:async()=>{let e=Sr.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),r=(0,Pr.driverWithoutSerialization)();return await Promise.all([e.defineDriver(r),e.defineDriver(je)]),await e.setDriver([r._driver,je._driver]),e}});0&&(module.exports={Magic,useInternetConnection,...require("@magic-sdk/commons")});
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var yr=Object.create;var Te=Object.defineProperty;var gr=Object.getOwnPropertyDescriptor;var _r=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty;var h=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Ir=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of _r(r))!wr.call(e,a)&&a!==t&&Te(e,a,{get:()=>r[a],enumerable:!(i=gr(r,a))||i.enumerable});return e};var ke=(e,r,t)=>(t=e!=null?yr(br(e)):{},Ir(r||!e||!e.__esModule?Te(t,"default",{value:e,enumerable:!0}):t,e));var Be=h((Dt,re)=>{"use strict";var ee=function(e){"use strict";var r=Object.prototype,t=r.hasOwnProperty,i,a=typeof Symbol=="function"?Symbol:{},u=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",v=a.toStringTag||"@@toStringTag";function m(o,n,s){return Object.defineProperty(o,n,{value:s,enumerable:!0,configurable:!0,writable:!0}),o[n]}try{m({},"")}catch{m=function(n,s,c){return n[s]=c}}function E(o,n,s,c){var l=n&&n.prototype instanceof Y?n:Y,d=Object.create(l.prototype),y=new Z(c||[]);return d._invoke=mr(o,s,y),d}e.wrap=E;function O(o,n,s){try{return{type:"normal",arg:o.call(n,s)}}catch(c){return{type:"throw",arg:c}}}var N="suspendedStart",z="suspendedYield",p="executing",R="completed",w={};function Y(){}function q(){}function A(){}var J={};m(J,u,function(){return this});var H=Object.getPrototypeOf,j=H&&H(H(Q([])));j&&j!==r&&t.call(j,u)&&(J=j);var M=A.prototype=Y.prototype=Object.create(J);q.prototype=A,m(M,"constructor",A),m(A,"constructor",q),q.displayName=m(A,v,"GeneratorFunction");function Me(o){["next","throw","return"].forEach(function(n){m(o,n,function(s){return this._invoke(n,s)})})}e.isGeneratorFunction=function(o){var n=typeof o=="function"&&o.constructor;return n?n===q||(n.displayName||n.name)==="GeneratorFunction":!1},e.mark=function(o){return Object.setPrototypeOf?Object.setPrototypeOf(o,A):(o.__proto__=A,m(o,v,"GeneratorFunction")),o.prototype=Object.create(M),o},e.awrap=function(o){return{__await:o}};function D(o,n){function s(d,y,g,I){var _=O(o[d],o,y);if(_.type==="throw")I(_.arg);else{var $=_.arg,T=$.value;return T&&typeof T=="object"&&t.call(T,"__await")?n.resolve(T.__await).then(function(C){s("next",C,g,I)},function(C){s("throw",C,g,I)}):n.resolve(T).then(function(C){$.value=C,g($)},function(C){return s("throw",C,g,I)})}}var c;function l(d,y){function g(){return new n(function(I,_){s(d,y,I,_)})}return c=c?c.then(g,g):g()}this._invoke=l}Me(D.prototype),m(D.prototype,f,function(){return this}),e.AsyncIterator=D,e.async=function(o,n,s,c,l){l===void 0&&(l=Promise);var d=new D(E(o,n,s,c),l);return e.isGeneratorFunction(n)?d:d.next().then(function(y){return y.done?y.value:d.next()})};function mr(o,n,s){var c=N;return function(d,y){if(c===p)throw new Error("Generator is already running");if(c===R){if(d==="throw")throw y;return Re()}for(s.method=d,s.arg=y;;){var g=s.delegate;if(g){var I=Le(g,s);if(I){if(I===w)continue;return I}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===N)throw c=R,s.arg;s.dispatchException(s.arg)}else s.method==="return"&&s.abrupt("return",s.arg);c=p;var _=O(o,n,s);if(_.type==="normal"){if(c=s.done?R:z,_.arg===w)continue;return{value:_.arg,done:s.done}}else _.type==="throw"&&(c=R,s.method="throw",s.arg=_.arg)}}}function Le(o,n){var s=o.iterator[n.method];if(s===i){if(n.delegate=null,n.method==="throw"){if(o.iterator.return&&(n.method="return",n.arg=i,Le(o,n),n.method==="throw"))return w;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return w}var c=O(s,o.iterator,n.arg);if(c.type==="throw")return n.method="throw",n.arg=c.arg,n.delegate=null,w;var l=c.arg;if(!l)return n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,w;if(l.done)n[o.resultName]=l.value,n.next=o.nextLoc,n.method!=="return"&&(n.method="next",n.arg=i);else return l;return n.delegate=null,w}Me(M),m(M,v,"Generator"),m(M,u,function(){return this}),m(M,"toString",function(){return"[object Generator]"});function pr(o){var n={tryLoc:o[0]};1 in o&&(n.catchLoc=o[1]),2 in o&&(n.finallyLoc=o[2],n.afterLoc=o[3]),this.tryEntries.push(n)}function X(o){var n=o.completion||{};n.type="normal",delete n.arg,o.completion=n}function Z(o){this.tryEntries=[{tryLoc:"root"}],o.forEach(pr,this),this.reset(!0)}e.keys=function(o){var n=[];for(var s in o)n.push(s);return n.reverse(),function c(){for(;n.length;){var l=n.pop();if(l in o)return c.value=l,c.done=!1,c}return c.done=!0,c}};function Q(o){if(o){var n=o[u];if(n)return n.call(o);if(typeof o.next=="function")return o;if(!isNaN(o.length)){var s=-1,c=function l(){for(;++s<o.length;)if(t.call(o,s))return l.value=o[s],l.done=!1,l;return l.value=i,l.done=!0,l};return c.next=c}}return{next:Re}}e.values=Q;function Re(){return{value:i,done:!0}}return Z.prototype={constructor:Z,reset:function(o){if(this.prev=0,this.next=0,this.sent=this._sent=i,this.done=!1,this.delegate=null,this.method="next",this.arg=i,this.tryEntries.forEach(X),!o)for(var n in this)n.charAt(0)==="t"&&t.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=i)},stop:function(){this.done=!0;var o=this.tryEntries[0],n=o.completion;if(n.type==="throw")throw n.arg;return this.rval},dispatchException:function(o){if(this.done)throw o;var n=this;function s(I,_){return d.type="throw",d.arg=o,n.next=I,_&&(n.method="next",n.arg=i),!!_}for(var c=this.tryEntries.length-1;c>=0;--c){var l=this.tryEntries[c],d=l.completion;if(l.tryLoc==="root")return s("end");if(l.tryLoc<=this.prev){var y=t.call(l,"catchLoc"),g=t.call(l,"finallyLoc");if(y&&g){if(this.prev<l.catchLoc)return s(l.catchLoc,!0);if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else if(y){if(this.prev<l.catchLoc)return s(l.catchLoc,!0)}else if(g){if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(o,n){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc<=this.prev&&t.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var l=c;break}}l&&(o==="break"||o==="continue")&&l.tryLoc<=n&&n<=l.finallyLoc&&(l=null);var d=l?l.completion:{};return d.type=o,d.arg=n,l?(this.method="next",this.next=l.finallyLoc,w):this.complete(d)},complete:function(o,n){if(o.type==="throw")throw o.arg;return o.type==="break"||o.type==="continue"?this.next=o.arg:o.type==="return"?(this.rval=this.arg=o.arg,this.method="return",this.next="end"):o.type==="normal"&&n&&(this.next=n),w},finish:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.finallyLoc===o)return this.complete(s.completion,s.afterLoc),X(s),w}},catch:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.tryLoc===o){var c=s.completion;if(c.type==="throw"){var l=c.arg;X(s)}return l}}throw new Error("illegal catch attempt")},delegateYield:function(o,n,s){return this.delegate={iterator:Q(o),resultName:n,nextLoc:s},this.method==="next"&&(this.arg=i),w}},e}(typeof re=="object"?re.exports:{});try{regeneratorRuntime=ee}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ee:Function("r","regeneratorRuntime = r")(ee)}});var Ne=h(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te._driver="localforage-driver-memory"});var qe=h(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});function Sr(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(u){if(u.name!=="TypeError")throw u;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,i=new t,a=0;a<e.length;a+=1)i.append(e[a]);return i.getBlob(r.type)}}ne.createBlob=Sr});var Ve=h(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});var Er=qe(),je=/^~~local_forage_type~([^~]+)~/,oe=9,De=oe+4,xe=Object.prototype.toString;function Ge(e){var r=e.length*.75,t=e.length;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);for(var i=new ArrayBuffer(r),a=new Uint8Array(i),u=0,f=0;u<t;u+=4){var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u]),m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+1]),E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+2]),O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+3]);a[f++]=v<<2|m>>4,a[f++]=(m&15)<<4|E>>2,a[f++]=(E&3)<<6|O&63}return i}L.stringToBuffer=Ge;function ie(e){for(var r=new Uint8Array(e),t="",i=0;i<r.length;i+=3)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i]>>2],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i]&3)<<4|r[i+1]>>4],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i+1]&15)<<2|r[i+2]>>6],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}L.bufferToString=ie;function Or(e,r){var t="";if(e&&(t=xe.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&xe.call(e.buffer)==="[object ArrayBuffer]")){var i=void 0,a="__lfsc__:";e instanceof ArrayBuffer?(i=e,a+="arbf"):(i=e.buffer,t==="[object Int8Array]"?a+="si08":t==="[object Uint8Array]"?a+="ui08":t==="[object Uint8ClampedArray]"?a+="uic8":t==="[object Int16Array]"?a+="si16":t==="[object Uint16Array]"?a+="ur16":t==="[object Int32Array]"?a+="si32":t==="[object Uint32Array]"?a+="ui32":t==="[object Float32Array]"?a+="fl32":t==="[object Float64Array]"?a+="fl64":r(new Error("Failed to get type for BinaryArray"))),r(a+ie(i))}else if(t==="[object Blob]"){var u=new FileReader;u.onload=function(){var f="~~local_forage_type~"+e.type+"~"+ie(this.result);r("__lfsc__:blob"+f)},u.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}L.serialize=Or;function Pr(e){if(e.substring(0,oe)!=="__lfsc__:")return JSON.parse(e);var r=e.substring(De),t=e.substring(oe,De),i;if(t==="blob"&&je.test(r)){var a=r.match(je);i=a[1],r=r.substring(a[0].length)}var u=Ge(r);switch(t){case"arbf":return u;case"blob":return Er.createBlob([u],{type:i});case"si08":return new Int8Array(u);case"ui08":return new Uint8Array(u);case"uic8":return new Uint8ClampedArray(u);case"si16":return new Int16Array(u);case"ur16":return new Uint16Array(u);case"si32":return new Int32Array(u);case"ui32":return new Uint32Array(u);case"fl32":return new Float32Array(u);case"fl64":return new Float64Array(u);default:throw new Error("Unkown type: "+t)}}L.deserialize=Pr});var Ue=h(k=>{"use strict";var Ar=k&&k.__values||function(e){var r=typeof Symbol=="function"&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}};Object.defineProperty(k,"__esModule",{value:!0});function Ke(e){var r,t;if(e===null||typeof e!="object"||"isActiveClone"in e)return e;var i=e instanceof Date?new Date(e):e.constructor();try{for(var a=Ar(Object.keys(e)),u=a.next();!u.done;u=a.next()){var f=u.value;Object.prototype.hasOwnProperty.call(e,f)&&(e.isActiveClone=null,i[f]=Ke(e[f]),delete e.isActiveClone)}}catch(v){r={error:v}}finally{try{u&&!u.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}return i}k.clone=Ke});var se=h(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});function Cr(e,r){return(e.name||r.name)+"/"+(e.storeName||r.storeName)+"/"}ae.getKeyPrefix=Cr});var Fe=h(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});function Mr(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}ue.executeCallback=Mr});var ce=h(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});function Lr(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}le.getCallback=Lr});var We=h(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});var Rr=ce(),Tr=se();function kr(e,r){var t=this;if(r=Rr.getCallback.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var i=this.config();e.name=e.name||i.name,e.storeName=e.storeName||i.storeName}var a;return e.name?a=new Promise(function(u){e.storeName?u(Tr.getKeyPrefix(e,t._defaultConfig)):u(e.name+"/")}):a=Promise.reject("Invalid arguments"),{promise:a,callback:r}}fe.dropInstanceCommon=kr});var ze=h(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});function Br(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}he.normaliseKey=Br});var S=h(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});var x=Ve(),Nr=Ue();P.clone=Nr.clone;var qr=se();P.getKeyPrefix=qr.getKeyPrefix;var jr=Fe();P.executeCallback=jr.executeCallback;var Dr=ce();P.getCallback=Dr.getCallback;var xr=We();P.dropInstanceCommon=xr.dropInstanceCommon;var Gr=ze();P.normaliseKey=Gr.normaliseKey;P.serialiser={bufferToString:x.bufferToString,deserialize:x.deserialize,serialize:x.serialize,stringToBuffer:x.stringToBuffer}});var de=h(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});var G={},Vr=function(){function e(r){this.kp=r,this.data={}}return e.resolve=function(r){return G[r]||(G[r]=new e(r)),G[r]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete G[this.kp]},e.prototype.get=function(r){return this.data[r]},e.prototype.key=function(r){return this.keys()[r]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(r){delete this.data[r]},e.prototype.set=function(r,t){this.data[r]=t},e}();ve.Store=Vr});var Ye=h(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});var me=S(),Kr=de();function Ur(e){var r=e?me.clone(e):{},t=me.getKeyPrefix(r,this._defaultConfig),i=Kr.Store.resolve(t);return this._dbInfo=r,this._dbInfo.serializer=me.serialiser,this._dbInfo.keyPrefix=t,this._dbInfo.mStore=i,Promise.resolve()}pe._initStorage=Ur});var Je=h(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});var Fr=S();function Wr(e){var r=this,t=this.ready().then(function(){r._dbInfo.mStore.clear()});return Fr.executeCallback(t,e),t}ye.clear=Wr});var Xe=h(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});var He=S(),zr=de();function Yr(e,r){var t=He.dropInstanceCommon.apply(this,arguments),i=t.promise,a=t.callback,u=i.then(function(f){zr.Store.resolve(f).drop()});return He.executeCallback(u,a),i}ge.dropInstance=Yr});var Qe=h(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});var Ze=S();function Jr(e,r){var t=this;e=Ze.normaliseKey(e);var i=this.ready().then(function(){var a=t._dbInfo.mStore.get(e);return a==null?null:t._dbInfo.serializer.deserialize(a)});return Ze.executeCallback(i,r),i}_e.getItem=Jr});var $e=h(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});var Hr=S();function Xr(e,r){var t=this,i=this.ready().then(function(){for(var a=t._dbInfo.mStore,u=a.keys(),f=0;f<u.length;f++){var v=a.get(u[f]);if(v&&(v=t._dbInfo.serializer.deserialize(v)),v=e(v,u[f],f+1),v!==void 0)return v}});return Hr.executeCallback(i,r),i}be.iterate=Xr});var er=h(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});var Zr=S();function Qr(e,r){var t=this,i=this.ready().then(function(){var a;try{a=t._dbInfo.mStore.key(e),a===void 0&&(a=null)}catch{a=null}return a});return Zr.executeCallback(i,r),i}we.key=Qr});var rr=h(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});var $r=S();function et(e){var r=this,t=this.ready().then(function(){return r._dbInfo.mStore.keys()});return $r.executeCallback(t,e),t}Ie.keys=et});var tr=h(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});var rt=S();function tt(e){var r=this.keys().then(function(t){return t.length});return rt.executeCallback(r,e),r}Se.length=tt});var or=h(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});var nr=S();function nt(e,r){var t=this;e=nr.normaliseKey(e);var i=this.ready().then(function(){t._dbInfo.mStore.rm(e)});return nr.executeCallback(i,r),i}Ee.removeItem=nt});var ar=h(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});var ir=S();function ot(e,r,t){var i=this;e=ir.normaliseKey(e);var a=this.ready().then(function(){r===void 0&&(r=null);var u=r;return new Promise(function(f,v){i._dbInfo.serializer.serialize(r,function(m,E){if(E)v(E);else try{i._dbInfo.mStore.set(e,m),f(u)}catch(O){v(O)}})})});return ir.executeCallback(a,t),a}Oe.setItem=ot});var sr=h(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b._support=!0;var it=Ne();b._driver=it._driver;var at=Ye();b._initStorage=at._initStorage;var st=Je();b.clear=st.clear;var ut=Xe();b.dropInstance=ut.dropInstance;var lt=Qe();b.getItem=lt.getItem;var ct=$e();b.iterate=ct.iterate;var ft=er();b.key=ft.key;var ht=rr();b.keys=ht.keys;var vt=tr();b.length=vt.length;var dt=or();b.removeItem=dt.removeItem;var mt=ar();b.setItem=mt.setItem});var On=ke(Be()),Ce=ke(sr());import{createSDK as Rt}from"@magic-sdk/provider";import*as Tt from"process";import kt from"localforage";import{URL as Bt,URLSearchParams as Nt}from"whatwg-url";import{Buffer as Ae}from"buffer";import*as vr from"lodash";import*as dr from"expo-application";import{driverWithoutSerialization as qt}from"@aveq-research/localforage-asyncstorage-driver";import ur,{useState as lr,useCallback as B,useMemo as _t,useEffect as V}from"react";import{Linking as bt,StyleSheet as wt}from"react-native";import{WebView as It}from"react-native-webview";import{SafeAreaView as St}from"react-native-safe-area-context";import{ViewController as Et,createModalNotReadyError as Ot}from"@magic-sdk/provider";import{isTypedArray as Pt}from"lodash";import K from"@react-native-async-storage/async-storage";import{EventRegister as cr}from"react-native-event-listeners";import{useEffect as pt,useState as yt}from"react";import gt from"@react-native-community/netinfo";var Pe=()=>{let[e,r]=yt(!0);return pt(()=>{let t=i=>{r(!!i.isConnected)};return gt.addEventListener(t)},[]),e};var fr="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",At="open_in_device_browser",Ct="#FFFFFF",hr="msg_posted_after_inactivity_event",U="lastMessageTime";function Mt(){return wt.create({"magic-webview":{flex:1,backgroundColor:"transparent"},"webview-container":{flex:1,width:"100%",backgroundColor:"transparent",position:"absolute",top:0,left:0,right:0,bottom:0},show:{zIndex:1e4,elevation:1e4},hide:{zIndex:-1e4,elevation:0}})}var F=class extends Et{webView;container;styles;init(){this.webView=null,this.container=null,this.styles=Mt()}Relayer=r=>{let[t,i]=lr(!1),[a,u]=lr(!0),f=Pe();V(()=>{this.isConnectedToInternet=f},[f]),V(()=>(K.setItem(U,""),()=>{this.isReadyForRequest=!1}),[]),V(()=>{cr.addEventListener(hr,async p=>{this.isReadyForRequest=!1,u(!1),this.post(p.msgType,p.payload),await K.setItem(U,new Date().toISOString())})},[]),V(()=>{a||setTimeout(()=>u(!0),10)},[a]);let v=B(p=>{this.webView=p},[]),m=B(p=>{this.container={...p,showOverlay:E,hideOverlay:O}},[]),E=B(()=>{i(!0)},[]),O=B(()=>{i(!1)},[]),N=_t(()=>[this.styles["webview-container"],t?{...this.styles.show,backgroundColor:r??Ct}:this.styles.hide],[t]),z=B(p=>{this.handleReactNativeWebViewMessage(p)},[]);return a?ur.createElement(St,{ref:m,style:N},ur.createElement(It,{ref:v,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:z,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:p=>new URLSearchParams(p.url.split("?")[1]).get(At)?(bt.openURL(p.url),!1):!0})):null};handleReactNativeWebViewMessage(r){if(r.nativeEvent&&typeof r.nativeEvent.data=="string"&&(r.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||r.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let t=JSON.parse(r.nativeEvent.data,(i,a)=>{try{if(a&&typeof a=="object"&&a.flag&&a.flag===fr)return new global[a.constructor](a.data.split(","))}catch{}return a});if(t&&t.msgType&&this.messageHandlers.size){t.response=t.response??{};let i={data:t};for(let a of this.messageHandlers.values())a(i)}}}async msgPostedAfterInactivity(){let r=await K.getItem(U);if(r){let t=new Date(r).getTime(),i=new Date().getTime(),a=5*60*1e3;return i-t>a}return!1}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}async _post(r){if(await this.msgPostedAfterInactivity()){cr.emit(hr,r);return}if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(r,(t,i)=>Pt(i)?{constructor:i.constructor.name,data:i.toString(),flag:fr}:i),this.endpoint),K.setItem(U,new Date().toISOString());else throw Ot()}checkRelayerExistsInDOM(){return Promise.resolve(!0)}reloadRelayer(){return Promise.resolve(void 0)}};import{SDKBase as Lt}from"@magic-sdk/provider";var W=class extends Lt{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=vr.merge(global.process,Tt);global.process.browser=!1;global.Buffer=Ae;global.URL=Bt;global.URLSearchParams=Nt;global.btoa=e=>Ae.from(e,"binary").toString("base64");global.atob=e=>Ae.from(e,"base64").toString("binary");var Nn=Rt(W,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"30.0.5",bundleId:dr.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:F,configureStorage:async()=>{let e=kt.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),r=qt();return await Promise.all([e.defineDriver(r),e.defineDriver(Ce)]),await e.setDriver([r._driver,Ce._driver]),e}});export{Nn as Magic,Pe as useInternetConnection};
|
1
|
+
var yr=Object.create;var Te=Object.defineProperty;var gr=Object.getOwnPropertyDescriptor;var _r=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty;var h=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Ir=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of _r(r))!wr.call(e,a)&&a!==t&&Te(e,a,{get:()=>r[a],enumerable:!(i=gr(r,a))||i.enumerable});return e};var ke=(e,r,t)=>(t=e!=null?yr(br(e)):{},Ir(r||!e||!e.__esModule?Te(t,"default",{value:e,enumerable:!0}):t,e));var Be=h((Dt,re)=>{"use strict";var ee=function(e){"use strict";var r=Object.prototype,t=r.hasOwnProperty,i,a=typeof Symbol=="function"?Symbol:{},u=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",v=a.toStringTag||"@@toStringTag";function m(o,n,s){return Object.defineProperty(o,n,{value:s,enumerable:!0,configurable:!0,writable:!0}),o[n]}try{m({},"")}catch{m=function(n,s,c){return n[s]=c}}function E(o,n,s,c){var l=n&&n.prototype instanceof Y?n:Y,d=Object.create(l.prototype),y=new Z(c||[]);return d._invoke=mr(o,s,y),d}e.wrap=E;function O(o,n,s){try{return{type:"normal",arg:o.call(n,s)}}catch(c){return{type:"throw",arg:c}}}var N="suspendedStart",z="suspendedYield",p="executing",R="completed",w={};function Y(){}function q(){}function A(){}var J={};m(J,u,function(){return this});var H=Object.getPrototypeOf,j=H&&H(H(Q([])));j&&j!==r&&t.call(j,u)&&(J=j);var M=A.prototype=Y.prototype=Object.create(J);q.prototype=A,m(M,"constructor",A),m(A,"constructor",q),q.displayName=m(A,v,"GeneratorFunction");function Me(o){["next","throw","return"].forEach(function(n){m(o,n,function(s){return this._invoke(n,s)})})}e.isGeneratorFunction=function(o){var n=typeof o=="function"&&o.constructor;return n?n===q||(n.displayName||n.name)==="GeneratorFunction":!1},e.mark=function(o){return Object.setPrototypeOf?Object.setPrototypeOf(o,A):(o.__proto__=A,m(o,v,"GeneratorFunction")),o.prototype=Object.create(M),o},e.awrap=function(o){return{__await:o}};function D(o,n){function s(d,y,g,I){var _=O(o[d],o,y);if(_.type==="throw")I(_.arg);else{var $=_.arg,T=$.value;return T&&typeof T=="object"&&t.call(T,"__await")?n.resolve(T.__await).then(function(C){s("next",C,g,I)},function(C){s("throw",C,g,I)}):n.resolve(T).then(function(C){$.value=C,g($)},function(C){return s("throw",C,g,I)})}}var c;function l(d,y){function g(){return new n(function(I,_){s(d,y,I,_)})}return c=c?c.then(g,g):g()}this._invoke=l}Me(D.prototype),m(D.prototype,f,function(){return this}),e.AsyncIterator=D,e.async=function(o,n,s,c,l){l===void 0&&(l=Promise);var d=new D(E(o,n,s,c),l);return e.isGeneratorFunction(n)?d:d.next().then(function(y){return y.done?y.value:d.next()})};function mr(o,n,s){var c=N;return function(d,y){if(c===p)throw new Error("Generator is already running");if(c===R){if(d==="throw")throw y;return Re()}for(s.method=d,s.arg=y;;){var g=s.delegate;if(g){var I=Le(g,s);if(I){if(I===w)continue;return I}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===N)throw c=R,s.arg;s.dispatchException(s.arg)}else s.method==="return"&&s.abrupt("return",s.arg);c=p;var _=O(o,n,s);if(_.type==="normal"){if(c=s.done?R:z,_.arg===w)continue;return{value:_.arg,done:s.done}}else _.type==="throw"&&(c=R,s.method="throw",s.arg=_.arg)}}}function Le(o,n){var s=o.iterator[n.method];if(s===i){if(n.delegate=null,n.method==="throw"){if(o.iterator.return&&(n.method="return",n.arg=i,Le(o,n),n.method==="throw"))return w;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return w}var c=O(s,o.iterator,n.arg);if(c.type==="throw")return n.method="throw",n.arg=c.arg,n.delegate=null,w;var l=c.arg;if(!l)return n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,w;if(l.done)n[o.resultName]=l.value,n.next=o.nextLoc,n.method!=="return"&&(n.method="next",n.arg=i);else return l;return n.delegate=null,w}Me(M),m(M,v,"Generator"),m(M,u,function(){return this}),m(M,"toString",function(){return"[object Generator]"});function pr(o){var n={tryLoc:o[0]};1 in o&&(n.catchLoc=o[1]),2 in o&&(n.finallyLoc=o[2],n.afterLoc=o[3]),this.tryEntries.push(n)}function X(o){var n=o.completion||{};n.type="normal",delete n.arg,o.completion=n}function Z(o){this.tryEntries=[{tryLoc:"root"}],o.forEach(pr,this),this.reset(!0)}e.keys=function(o){var n=[];for(var s in o)n.push(s);return n.reverse(),function c(){for(;n.length;){var l=n.pop();if(l in o)return c.value=l,c.done=!1,c}return c.done=!0,c}};function Q(o){if(o){var n=o[u];if(n)return n.call(o);if(typeof o.next=="function")return o;if(!isNaN(o.length)){var s=-1,c=function l(){for(;++s<o.length;)if(t.call(o,s))return l.value=o[s],l.done=!1,l;return l.value=i,l.done=!0,l};return c.next=c}}return{next:Re}}e.values=Q;function Re(){return{value:i,done:!0}}return Z.prototype={constructor:Z,reset:function(o){if(this.prev=0,this.next=0,this.sent=this._sent=i,this.done=!1,this.delegate=null,this.method="next",this.arg=i,this.tryEntries.forEach(X),!o)for(var n in this)n.charAt(0)==="t"&&t.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=i)},stop:function(){this.done=!0;var o=this.tryEntries[0],n=o.completion;if(n.type==="throw")throw n.arg;return this.rval},dispatchException:function(o){if(this.done)throw o;var n=this;function s(I,_){return d.type="throw",d.arg=o,n.next=I,_&&(n.method="next",n.arg=i),!!_}for(var c=this.tryEntries.length-1;c>=0;--c){var l=this.tryEntries[c],d=l.completion;if(l.tryLoc==="root")return s("end");if(l.tryLoc<=this.prev){var y=t.call(l,"catchLoc"),g=t.call(l,"finallyLoc");if(y&&g){if(this.prev<l.catchLoc)return s(l.catchLoc,!0);if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else if(y){if(this.prev<l.catchLoc)return s(l.catchLoc,!0)}else if(g){if(this.prev<l.finallyLoc)return s(l.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(o,n){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc<=this.prev&&t.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var l=c;break}}l&&(o==="break"||o==="continue")&&l.tryLoc<=n&&n<=l.finallyLoc&&(l=null);var d=l?l.completion:{};return d.type=o,d.arg=n,l?(this.method="next",this.next=l.finallyLoc,w):this.complete(d)},complete:function(o,n){if(o.type==="throw")throw o.arg;return o.type==="break"||o.type==="continue"?this.next=o.arg:o.type==="return"?(this.rval=this.arg=o.arg,this.method="return",this.next="end"):o.type==="normal"&&n&&(this.next=n),w},finish:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.finallyLoc===o)return this.complete(s.completion,s.afterLoc),X(s),w}},catch:function(o){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.tryLoc===o){var c=s.completion;if(c.type==="throw"){var l=c.arg;X(s)}return l}}throw new Error("illegal catch attempt")},delegateYield:function(o,n,s){return this.delegate={iterator:Q(o),resultName:n,nextLoc:s},this.method==="next"&&(this.arg=i),w}},e}(typeof re=="object"?re.exports:{});try{regeneratorRuntime=ee}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ee:Function("r","regeneratorRuntime = r")(ee)}});var Ne=h(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te._driver="localforage-driver-memory"});var qe=h(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});function Sr(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(u){if(u.name!=="TypeError")throw u;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,i=new t,a=0;a<e.length;a+=1)i.append(e[a]);return i.getBlob(r.type)}}ne.createBlob=Sr});var Ve=h(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});var Er=qe(),je=/^~~local_forage_type~([^~]+)~/,oe=9,De=oe+4,xe=Object.prototype.toString;function Ge(e){var r=e.length*.75,t=e.length;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);for(var i=new ArrayBuffer(r),a=new Uint8Array(i),u=0,f=0;u<t;u+=4){var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u]),m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+1]),E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+2]),O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[u+3]);a[f++]=v<<2|m>>4,a[f++]=(m&15)<<4|E>>2,a[f++]=(E&3)<<6|O&63}return i}L.stringToBuffer=Ge;function ie(e){for(var r=new Uint8Array(e),t="",i=0;i<r.length;i+=3)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i]>>2],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i]&3)<<4|r[i+1]>>4],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(r[i+1]&15)<<2|r[i+2]>>6],t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[r[i+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}L.bufferToString=ie;function Or(e,r){var t="";if(e&&(t=xe.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&xe.call(e.buffer)==="[object ArrayBuffer]")){var i=void 0,a="__lfsc__:";e instanceof ArrayBuffer?(i=e,a+="arbf"):(i=e.buffer,t==="[object Int8Array]"?a+="si08":t==="[object Uint8Array]"?a+="ui08":t==="[object Uint8ClampedArray]"?a+="uic8":t==="[object Int16Array]"?a+="si16":t==="[object Uint16Array]"?a+="ur16":t==="[object Int32Array]"?a+="si32":t==="[object Uint32Array]"?a+="ui32":t==="[object Float32Array]"?a+="fl32":t==="[object Float64Array]"?a+="fl64":r(new Error("Failed to get type for BinaryArray"))),r(a+ie(i))}else if(t==="[object Blob]"){var u=new FileReader;u.onload=function(){var f="~~local_forage_type~"+e.type+"~"+ie(this.result);r("__lfsc__:blob"+f)},u.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}L.serialize=Or;function Pr(e){if(e.substring(0,oe)!=="__lfsc__:")return JSON.parse(e);var r=e.substring(De),t=e.substring(oe,De),i;if(t==="blob"&&je.test(r)){var a=r.match(je);i=a[1],r=r.substring(a[0].length)}var u=Ge(r);switch(t){case"arbf":return u;case"blob":return Er.createBlob([u],{type:i});case"si08":return new Int8Array(u);case"ui08":return new Uint8Array(u);case"uic8":return new Uint8ClampedArray(u);case"si16":return new Int16Array(u);case"ur16":return new Uint16Array(u);case"si32":return new Int32Array(u);case"ui32":return new Uint32Array(u);case"fl32":return new Float32Array(u);case"fl64":return new Float64Array(u);default:throw new Error("Unkown type: "+t)}}L.deserialize=Pr});var Ue=h(k=>{"use strict";var Ar=k&&k.__values||function(e){var r=typeof Symbol=="function"&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}};Object.defineProperty(k,"__esModule",{value:!0});function Ke(e){var r,t;if(e===null||typeof e!="object"||"isActiveClone"in e)return e;var i=e instanceof Date?new Date(e):e.constructor();try{for(var a=Ar(Object.keys(e)),u=a.next();!u.done;u=a.next()){var f=u.value;Object.prototype.hasOwnProperty.call(e,f)&&(e.isActiveClone=null,i[f]=Ke(e[f]),delete e.isActiveClone)}}catch(v){r={error:v}}finally{try{u&&!u.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}return i}k.clone=Ke});var se=h(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});function Cr(e,r){return(e.name||r.name)+"/"+(e.storeName||r.storeName)+"/"}ae.getKeyPrefix=Cr});var Fe=h(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});function Mr(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}ue.executeCallback=Mr});var ce=h(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});function Lr(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}le.getCallback=Lr});var We=h(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});var Rr=ce(),Tr=se();function kr(e,r){var t=this;if(r=Rr.getCallback.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var i=this.config();e.name=e.name||i.name,e.storeName=e.storeName||i.storeName}var a;return e.name?a=new Promise(function(u){e.storeName?u(Tr.getKeyPrefix(e,t._defaultConfig)):u(e.name+"/")}):a=Promise.reject("Invalid arguments"),{promise:a,callback:r}}fe.dropInstanceCommon=kr});var ze=h(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});function Br(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}he.normaliseKey=Br});var S=h(P=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});var x=Ve(),Nr=Ue();P.clone=Nr.clone;var qr=se();P.getKeyPrefix=qr.getKeyPrefix;var jr=Fe();P.executeCallback=jr.executeCallback;var Dr=ce();P.getCallback=Dr.getCallback;var xr=We();P.dropInstanceCommon=xr.dropInstanceCommon;var Gr=ze();P.normaliseKey=Gr.normaliseKey;P.serialiser={bufferToString:x.bufferToString,deserialize:x.deserialize,serialize:x.serialize,stringToBuffer:x.stringToBuffer}});var de=h(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});var G={},Vr=function(){function e(r){this.kp=r,this.data={}}return e.resolve=function(r){return G[r]||(G[r]=new e(r)),G[r]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete G[this.kp]},e.prototype.get=function(r){return this.data[r]},e.prototype.key=function(r){return this.keys()[r]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(r){delete this.data[r]},e.prototype.set=function(r,t){this.data[r]=t},e}();ve.Store=Vr});var Ye=h(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});var me=S(),Kr=de();function Ur(e){var r=e?me.clone(e):{},t=me.getKeyPrefix(r,this._defaultConfig),i=Kr.Store.resolve(t);return this._dbInfo=r,this._dbInfo.serializer=me.serialiser,this._dbInfo.keyPrefix=t,this._dbInfo.mStore=i,Promise.resolve()}pe._initStorage=Ur});var Je=h(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});var Fr=S();function Wr(e){var r=this,t=this.ready().then(function(){r._dbInfo.mStore.clear()});return Fr.executeCallback(t,e),t}ye.clear=Wr});var Xe=h(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});var He=S(),zr=de();function Yr(e,r){var t=He.dropInstanceCommon.apply(this,arguments),i=t.promise,a=t.callback,u=i.then(function(f){zr.Store.resolve(f).drop()});return He.executeCallback(u,a),i}ge.dropInstance=Yr});var Qe=h(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});var Ze=S();function Jr(e,r){var t=this;e=Ze.normaliseKey(e);var i=this.ready().then(function(){var a=t._dbInfo.mStore.get(e);return a==null?null:t._dbInfo.serializer.deserialize(a)});return Ze.executeCallback(i,r),i}_e.getItem=Jr});var $e=h(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});var Hr=S();function Xr(e,r){var t=this,i=this.ready().then(function(){for(var a=t._dbInfo.mStore,u=a.keys(),f=0;f<u.length;f++){var v=a.get(u[f]);if(v&&(v=t._dbInfo.serializer.deserialize(v)),v=e(v,u[f],f+1),v!==void 0)return v}});return Hr.executeCallback(i,r),i}be.iterate=Xr});var er=h(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});var Zr=S();function Qr(e,r){var t=this,i=this.ready().then(function(){var a;try{a=t._dbInfo.mStore.key(e),a===void 0&&(a=null)}catch{a=null}return a});return Zr.executeCallback(i,r),i}we.key=Qr});var rr=h(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});var $r=S();function et(e){var r=this,t=this.ready().then(function(){return r._dbInfo.mStore.keys()});return $r.executeCallback(t,e),t}Ie.keys=et});var tr=h(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});var rt=S();function tt(e){var r=this.keys().then(function(t){return t.length});return rt.executeCallback(r,e),r}Se.length=tt});var or=h(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});var nr=S();function nt(e,r){var t=this;e=nr.normaliseKey(e);var i=this.ready().then(function(){t._dbInfo.mStore.rm(e)});return nr.executeCallback(i,r),i}Ee.removeItem=nt});var ar=h(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});var ir=S();function ot(e,r,t){var i=this;e=ir.normaliseKey(e);var a=this.ready().then(function(){r===void 0&&(r=null);var u=r;return new Promise(function(f,v){i._dbInfo.serializer.serialize(r,function(m,E){if(E)v(E);else try{i._dbInfo.mStore.set(e,m),f(u)}catch(O){v(O)}})})});return ir.executeCallback(a,t),a}Oe.setItem=ot});var sr=h(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b._support=!0;var it=Ne();b._driver=it._driver;var at=Ye();b._initStorage=at._initStorage;var st=Je();b.clear=st.clear;var ut=Xe();b.dropInstance=ut.dropInstance;var lt=Qe();b.getItem=lt.getItem;var ct=$e();b.iterate=ct.iterate;var ft=er();b.key=ft.key;var ht=rr();b.keys=ht.keys;var vt=tr();b.length=vt.length;var dt=or();b.removeItem=dt.removeItem;var mt=ar();b.setItem=mt.setItem});var On=ke(Be()),Ce=ke(sr());import{createSDK as Rt}from"@magic-sdk/provider";import*as Tt from"process";import kt from"localforage";import{URL as Bt,URLSearchParams as Nt}from"whatwg-url";import{Buffer as Ae}from"buffer";import*as vr from"lodash";import*as dr from"expo-application";import{driverWithoutSerialization as qt}from"@aveq-research/localforage-asyncstorage-driver";import ur,{useState as lr,useCallback as B,useMemo as _t,useEffect as V}from"react";import{Linking as bt,StyleSheet as wt}from"react-native";import{WebView as It}from"react-native-webview";import{SafeAreaView as St}from"react-native-safe-area-context";import{ViewController as Et,createModalNotReadyError as Ot}from"@magic-sdk/provider";import{isTypedArray as Pt}from"lodash";import K from"@react-native-async-storage/async-storage";import{EventRegister as cr}from"react-native-event-listeners";import{useEffect as pt,useState as yt}from"react";import gt from"@react-native-community/netinfo";var Pe=()=>{let[e,r]=yt(!0);return pt(()=>{let t=i=>{r(!!i.isConnected)};return gt.addEventListener(t)},[]),e};var fr="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",At="open_in_device_browser",Ct="#FFFFFF",hr="msg_posted_after_inactivity_event",U="lastMessageTime";function Mt(){return wt.create({"magic-webview":{flex:1,backgroundColor:"transparent"},"webview-container":{flex:1,width:"100%",backgroundColor:"transparent",position:"absolute",top:0,left:0,right:0,bottom:0},show:{zIndex:1e4,elevation:1e4},hide:{zIndex:-1e4,elevation:0}})}var F=class extends Et{webView;container;styles;init(){this.webView=null,this.container=null,this.styles=Mt()}Relayer=r=>{let[t,i]=lr(!1),[a,u]=lr(!0),f=Pe();V(()=>{this.isConnectedToInternet=f},[f]),V(()=>(K.setItem(U,""),()=>{this.isReadyForRequest=!1}),[]),V(()=>{cr.addEventListener(hr,async p=>{this.isReadyForRequest=!1,u(!1),this.post(p.msgType,p.payload),await K.setItem(U,new Date().toISOString())})},[]),V(()=>{a||setTimeout(()=>u(!0),10)},[a]);let v=B(p=>{this.webView=p},[]),m=B(p=>{this.container={...p,showOverlay:E,hideOverlay:O}},[]),E=B(()=>{i(!0)},[]),O=B(()=>{i(!1)},[]),N=_t(()=>[this.styles["webview-container"],t?{...this.styles.show,backgroundColor:r??Ct}:this.styles.hide],[t]),z=B(p=>{this.handleReactNativeWebViewMessage(p)},[]);return a?ur.createElement(St,{ref:m,style:N},ur.createElement(It,{ref:v,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:z,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:p=>new URLSearchParams(p.url.split("?")[1]).get(At)?(bt.openURL(p.url),!1):!0})):null};handleReactNativeWebViewMessage(r){if(r.nativeEvent&&typeof r.nativeEvent.data=="string"&&(r.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||r.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let t=JSON.parse(r.nativeEvent.data,(i,a)=>{try{if(a&&typeof a=="object"&&a.flag&&a.flag===fr)return new global[a.constructor](a.data.split(","))}catch{}return a});if(t&&t.msgType&&this.messageHandlers.size){t.response=t.response??{};let i={data:t};for(let a of this.messageHandlers.values())a(i)}}}async msgPostedAfterInactivity(){let r=await K.getItem(U);if(r){let t=new Date(r).getTime(),i=new Date().getTime(),a=5*60*1e3;return i-t>a}return!1}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}async _post(r){if(await this.msgPostedAfterInactivity()){cr.emit(hr,r);return}if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(r,(t,i)=>Pt(i)?{constructor:i.constructor.name,data:i.toString(),flag:fr}:i),this.endpoint),K.setItem(U,new Date().toISOString());else throw Ot()}checkRelayerExistsInDOM(){return Promise.resolve(!0)}reloadRelayer(){return Promise.resolve(void 0)}};import{SDKBase as Lt}from"@magic-sdk/provider";var W=class extends Lt{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=vr.merge(global.process,Tt);global.process.browser=!1;global.Buffer=Ae;global.URL=Bt;global.URLSearchParams=Nt;global.btoa=e=>Ae.from(e,"binary").toString("base64");global.atob=e=>Ae.from(e,"base64").toString("binary");var Nn=Rt(W,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"30.0.6",bundleId:dr.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:F,configureStorage:async()=>{let e=kt.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),r=qt();return await Promise.all([e.defineDriver(r),e.defineDriver(Ce)]),await e.setDriver([r._driver,Ce._driver]),e}});export{Nn as Magic,Pe as useInternetConnection};
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@magic-sdk/react-native-expo",
|
3
|
-
"version": "30.0.6
|
3
|
+
"version": "30.0.6",
|
4
4
|
"description": "Passwordless authentication for React Native (Expo).",
|
5
5
|
"author": "Magic Labs <team@magic.link> (https://magic.link/)",
|
6
6
|
"license": "MIT",
|
@@ -18,9 +18,9 @@
|
|
18
18
|
"types": "./dist/types/index.d.ts",
|
19
19
|
"dependencies": {
|
20
20
|
"@aveq-research/localforage-asyncstorage-driver": "^3.0.1",
|
21
|
-
"@magic-sdk/commons": "25.0.6
|
22
|
-
"@magic-sdk/provider": "29.0.6
|
23
|
-
"@magic-sdk/types": "24.18.2
|
21
|
+
"@magic-sdk/commons": "^25.0.6",
|
22
|
+
"@magic-sdk/provider": "^29.0.6",
|
23
|
+
"@magic-sdk/types": "^24.18.2",
|
24
24
|
"@react-native-async-storage/async-storage": "^1.15.5",
|
25
25
|
"@types/lodash": "^4.14.158",
|
26
26
|
"buffer": "~5.6.0",
|
@@ -57,5 +57,5 @@
|
|
57
57
|
"react-native-safe-area-context": ">=4.4.1",
|
58
58
|
"react-native-webview": ">=12.4.0"
|
59
59
|
},
|
60
|
-
"gitHead": "
|
60
|
+
"gitHead": "08b9a70ad19874583402cf744bff1ce406a8659a"
|
61
61
|
}
|