@magic-sdk/react-native-bare 29.4.0-canary.e0a60a1.0 → 29.4.1-canary.781.10390936903.0
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 Ie=Object.create;var M=Object.defineProperty,Ne=Object.defineProperties,Ae=Object.getOwnPropertyDescriptor,Ce=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertyNames,ue=Object.getOwnPropertySymbols,Ve=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var le=(n,a,i)=>a in n?M(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,te=(n,a)=>{for(var i in a||(a={}))he.call(a,i)&&le(n,i,a[i]);if(ue)for(var i of ue(a))Ge.call(a,i)&&le(n,i,a[i]);return n},re=(n,a)=>Ne(n,Ce(a));var Pe=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports),De=(n,a)=>{for(var i in a)M(n,i,{get:a[i],enumerable:!0})},T=(n,a,i,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Me(a))!he.call(n,c)&&c!==i&&M(n,c,{get:()=>a[c],enumerable:!(h=Ae(a,c))||h.enumerable});return n},l=(n,a,i)=>(T(n,a,"default"),i&&T(i,a,"default")),I=(n,a,i)=>(i=n!=null?Ie(Ve(n)):{},T(a||!n||!n.__esModule?M(i,"default",{value:n,enumerable:!0}):i,n)),ke=n=>T(M({},"__esModule",{value:!0}),n);var W=(n,a,i)=>new Promise((h,c)=>{var S=w=>{try{_(i.next(w))}catch(v){c(v)}},p=w=>{try{_(i.throw(w))}catch(v){c(v)}},_=w=>w.done?h(w.value):Promise.resolve(w.value).then(S,p);_((i=i.apply(n,a)).next())});var pe=Pe((Ye,oe)=>{var ne=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,h=Object.defineProperty||function(t,e,r){t[e]=r.value},c,S=typeof Symbol=="function"?Symbol:{},p=S.iterator||"@@iterator",_=S.asyncIterator||"@@asyncIterator",w=S.toStringTag||"@@toStringTag";function v(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{v({},"")}catch{v=function(e,r,s){return e[r]=s}}function V(t,e,r,s){var o=e&&e.prototype instanceof x?e:x,f=Object.create(o.prototype),m=new X(s||[]);return h(f,"_invoke",{value:Re(t,r,m)}),f}n.wrap=V;function A(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(s){return{type:"throw",arg:s}}}var E="suspendedStart",ae="suspendedYield",z="executing",G="completed",L={};function x(){}function P(){}function R(){}var J={};v(J,p,function(){return this});var H=Object.getPrototypeOf,D=H&&H(H(Z([])));D&&D!==a&&i.call(D,p)&&(J=D);var N=R.prototype=x.prototype=Object.create(J);P.prototype=R,h(N,"constructor",{value:R,configurable:!0}),h(R,"constructor",{value:P,configurable:!0}),P.displayName=v(R,w,"GeneratorFunction");function se(t){["next","throw","return"].forEach(function(e){v(t,e,function(r){return this._invoke(e,r)})})}n.isGeneratorFunction=function(t){var e=typeof t=="function"&&t.constructor;return e?e===P||(e.displayName||e.name)==="GeneratorFunction":!1},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,R):(t.__proto__=R,v(t,w,"GeneratorFunction")),t.prototype=Object.create(N),t},n.awrap=function(t){return{__await:t}};function k(t,e){function r(f,m,y,b){var g=A(t[f],t,m);if(g.type==="throw")b(g.arg);else{var ee=g.arg,C=ee.value;return C&&typeof C=="object"&&i.call(C,"__await")?e.resolve(C.__await).then(function(O){r("next",O,y,b)},function(O){r("throw",O,y,b)}):e.resolve(C).then(function(O){ee.value=O,y(ee)},function(O){return r("throw",O,y,b)})}}var s;function o(f,m){function y(){return new e(function(b,g){r(f,m,b,g)})}return s=s?s.then(y,y):y()}h(this,"_invoke",{value:o})}se(k.prototype),v(k.prototype,_,function(){return this}),n.AsyncIterator=k,n.async=function(t,e,r,s,o){o===void 0&&(o=Promise);var f=new k(V(t,e,r,s),o);return n.isGeneratorFunction(e)?f:f.next().then(function(m){return m.done?m.value:f.next()})};function Re(t,e,r){var s=E;return function(f,m){if(s===z)throw new Error("Generator is already running");if(s===G){if(f==="throw")throw m;return fe()}for(r.method=f,r.arg=m;;){var y=r.delegate;if(y){var b=ce(y,r);if(b){if(b===L)continue;return b}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(s===E)throw s=G,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=z;var g=A(t,e,r);if(g.type==="normal"){if(s=r.done?G:ae,g.arg===L)continue;return{value:g.arg,done:r.done}}else g.type==="throw"&&(s=G,r.method="throw",r.arg=g.arg)}}}function ce(t,e){var r=e.method,s=t.iterator[r];if(s===c)return e.delegate=null,r==="throw"&&t.iterator.return&&(e.method="return",e.arg=c,ce(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),L;var o=A(s,t.iterator,e.arg);if(o.type==="throw")return e.method="throw",e.arg=o.arg,e.delegate=null,L;var f=o.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,L;if(f.done)e[t.resultName]=f.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=c);else return f;return e.delegate=null,L}se(N),v(N,w,"Generator"),v(N,p,function(){return this}),v(N,"toString",function(){return"[object Generator]"});function Oe(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function Q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function X(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(Oe,this),this.reset(!0)}n.keys=function(t){var e=Object(t),r=[];for(var s in e)r.push(s);return r.reverse(),function o(){for(;r.length;){var f=r.pop();if(f in e)return o.value=f,o.done=!1,o}return o.done=!0,o}};function Z(t){if(t){var e=t[p];if(e)return e.call(t);if(typeof t.next=="function")return t;if(!isNaN(t.length)){var r=-1,s=function o(){for(;++r<t.length;)if(i.call(t,r))return o.value=t[r],o.done=!1,o;return o.value=c,o.done=!0,o};return s.next=s}}return{next:fe}}n.values=Z;function fe(){return{value:c,done:!0}}return X.prototype={constructor:X,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method="next",this.arg=c,this.tryEntries.forEach(Q),!t)for(var e in this)e.charAt(0)==="t"&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=c)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if(e.type==="throw")throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(b,g){return f.type="throw",f.arg=t,e.next=b,g&&(e.method="next",e.arg=c),!!g}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],f=o.completion;if(o.tryLoc==="root")return r("end");if(o.tryLoc<=this.prev){var m=i.call(o,"catchLoc"),y=i.call(o,"finallyLoc");if(m&&y){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(m){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else if(y){if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var s=this.tryEntries[r];if(s.tryLoc<=this.prev&&i.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var o=s;break}}o&&(t==="break"||t==="continue")&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var f=o?o.completion:{};return f.type=t,f.arg=e,o?(this.method="next",this.next=o.finallyLoc,L):this.complete(f)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),L},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),Q(r),L}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var s=r.completion;if(s.type==="throw"){var o=s.arg;Q(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:Z(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),L}},n}(typeof oe=="object"?oe.exports:{});try{regeneratorRuntime=ne}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ne:Function("r","regeneratorRuntime = r")(ne)}});var u={};De(u,{Magic:()=>Ue,useInternetConnection:()=>B});module.exports=ke(u);var He=I(pe()),be=require("@magic-sdk/provider"),Be=I(require("process")),Se=I(require("localforage")),$=require("whatwg-url"),q=require("buffer"),Ee=I(require("lodash")),Le=require("react-native-device-info"),_e=require("@aveq-research/localforage-asyncstorage-driver"),ie=I(require("localforage-driver-memory"));var d=I(require("react")),F=require("react-native"),me=require("react-native-webview"),ye=require("react-native-safe-area-context"),Y=require("@magic-sdk/provider"),ge=require("lodash");var j=require("react"),ve=I(require("@react-native-community/netinfo")),B=()=>{let[n,a]=(0,j.useState)(!0);return(0,j.useEffect)(()=>{let i=h=>{a(!!h.isConnected)};return ve.default.addEventListener(i)},[]),n};var de="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Te="open_in_device_browser",We="#FFFFFF";function je(){return F.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 U=class extends Y.ViewController{constructor(){super(...arguments);this.Relayer=i=>{let[h,c]=(0,d.useState)(!1),S=B();(0,d.useEffect)(()=>{this.isConnectedToInternet=S},[S]),(0,d.useEffect)(()=>()=>{this.isReadyForRequest=!1},[]);let p=(0,d.useCallback)(E=>{this.webView=E},[]),_=(0,d.useCallback)(E=>{this.container=re(te({},E),{showOverlay:w,hideOverlay:v})},[]),w=(0,d.useCallback)(()=>{c(!0)},[]),v=(0,d.useCallback)(()=>{c(!1)},[]),V=(0,d.useMemo)(()=>[this.styles["webview-container"],h?re(te({},this.styles.show),{backgroundColor:i!=null?i:We}):this.styles.hide],[h]),A=(0,d.useCallback)(E=>{this.handleReactNativeWebViewMessage(E)},[]);return d.default.createElement(ye.SafeAreaView,{ref:_,style:V},d.default.createElement(me.WebView,{ref:p,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:A,style:this.styles["magic-webview"],webviewDebuggingEnabled:!0,autoManageStatusBarEnabled:!1,onShouldStartLoadWithRequest:E=>new URLSearchParams(E.url.split("?")[1]).get(Te)?(F.Linking.openURL(E.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=je()}handleReactNativeWebViewMessage(i){var h;if(i.nativeEvent&&typeof i.nativeEvent.data=="string"&&(i.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||i.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(i.nativeEvent.data,(S,p)=>{try{if(p&&typeof p=="object"&&p.flag&&p.flag===de)return new global[p.constructor](p.data.split(","))}catch(_){}return p});if(c&&c.msgType&&this.messageHandlers.size){c.response=(h=c.response)!=null?h:{};let S={data:c};for(let p of this.messageHandlers.values())p(S)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return W(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(h,c)=>(0,ge.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:de}:c),this.endpoint);else throw(0,Y.createModalNotReadyError)()})}};var we=require("@magic-sdk/provider"),K=class extends we.SDKBase{get Relayer(){return this.overlay.Relayer}};l(u,require("@magic-sdk/commons"),module.exports);global.process=Ee.merge(global.process,Be);global.process.browser=!1;global.Buffer=q.Buffer;global.URL=$.URL;global.URLSearchParams=$.URLSearchParams;global.btoa=n=>q.Buffer.from(n,"binary").toString("base64");global.atob=n=>q.Buffer.from(n,"base64").toString("binary");var Ue=(0,be.createSDK)(K,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"29.3.0",bundleId:(0,Le.getBundleId)(),defaultEndpoint:"https://box.magic.link/",ViewController:U,configureStorage:()=>W(void 0,null,function*(){let n=Se.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),a=(0,_e.driverWithoutSerialization)();return yield Promise.all([n.defineDriver(a),n.defineDriver(ie)]),yield n.setDriver([a._driver,ie._driver]),n})});0&&(module.exports={Magic,useInternetConnection});
|
1
|
+
"use strict";var Ie=Object.create;var M=Object.defineProperty,Ne=Object.defineProperties,Ae=Object.getOwnPropertyDescriptor,Ce=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertyNames,ue=Object.getOwnPropertySymbols,Ve=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var le=(n,a,i)=>a in n?M(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,te=(n,a)=>{for(var i in a||(a={}))he.call(a,i)&&le(n,i,a[i]);if(ue)for(var i of ue(a))Ge.call(a,i)&&le(n,i,a[i]);return n},re=(n,a)=>Ne(n,Ce(a));var Pe=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports),De=(n,a)=>{for(var i in a)M(n,i,{get:a[i],enumerable:!0})},T=(n,a,i,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Me(a))!he.call(n,c)&&c!==i&&M(n,c,{get:()=>a[c],enumerable:!(h=Ae(a,c))||h.enumerable});return n},l=(n,a,i)=>(T(n,a,"default"),i&&T(i,a,"default")),I=(n,a,i)=>(i=n!=null?Ie(Ve(n)):{},T(a||!n||!n.__esModule?M(i,"default",{value:n,enumerable:!0}):i,n)),ke=n=>T(M({},"__esModule",{value:!0}),n);var W=(n,a,i)=>new Promise((h,c)=>{var S=w=>{try{_(i.next(w))}catch(v){c(v)}},p=w=>{try{_(i.throw(w))}catch(v){c(v)}},_=w=>w.done?h(w.value):Promise.resolve(w.value).then(S,p);_((i=i.apply(n,a)).next())});var pe=Pe((Ye,oe)=>{var ne=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,h=Object.defineProperty||function(t,e,r){t[e]=r.value},c,S=typeof Symbol=="function"?Symbol:{},p=S.iterator||"@@iterator",_=S.asyncIterator||"@@asyncIterator",w=S.toStringTag||"@@toStringTag";function v(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{v({},"")}catch{v=function(e,r,s){return e[r]=s}}function V(t,e,r,s){var o=e&&e.prototype instanceof x?e:x,f=Object.create(o.prototype),m=new X(s||[]);return h(f,"_invoke",{value:Re(t,r,m)}),f}n.wrap=V;function A(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(s){return{type:"throw",arg:s}}}var E="suspendedStart",ae="suspendedYield",z="executing",G="completed",L={};function x(){}function P(){}function R(){}var J={};v(J,p,function(){return this});var H=Object.getPrototypeOf,D=H&&H(H(Z([])));D&&D!==a&&i.call(D,p)&&(J=D);var N=R.prototype=x.prototype=Object.create(J);P.prototype=R,h(N,"constructor",{value:R,configurable:!0}),h(R,"constructor",{value:P,configurable:!0}),P.displayName=v(R,w,"GeneratorFunction");function se(t){["next","throw","return"].forEach(function(e){v(t,e,function(r){return this._invoke(e,r)})})}n.isGeneratorFunction=function(t){var e=typeof t=="function"&&t.constructor;return e?e===P||(e.displayName||e.name)==="GeneratorFunction":!1},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,R):(t.__proto__=R,v(t,w,"GeneratorFunction")),t.prototype=Object.create(N),t},n.awrap=function(t){return{__await:t}};function k(t,e){function r(f,m,y,b){var g=A(t[f],t,m);if(g.type==="throw")b(g.arg);else{var ee=g.arg,C=ee.value;return C&&typeof C=="object"&&i.call(C,"__await")?e.resolve(C.__await).then(function(O){r("next",O,y,b)},function(O){r("throw",O,y,b)}):e.resolve(C).then(function(O){ee.value=O,y(ee)},function(O){return r("throw",O,y,b)})}}var s;function o(f,m){function y(){return new e(function(b,g){r(f,m,b,g)})}return s=s?s.then(y,y):y()}h(this,"_invoke",{value:o})}se(k.prototype),v(k.prototype,_,function(){return this}),n.AsyncIterator=k,n.async=function(t,e,r,s,o){o===void 0&&(o=Promise);var f=new k(V(t,e,r,s),o);return n.isGeneratorFunction(e)?f:f.next().then(function(m){return m.done?m.value:f.next()})};function Re(t,e,r){var s=E;return function(f,m){if(s===z)throw new Error("Generator is already running");if(s===G){if(f==="throw")throw m;return fe()}for(r.method=f,r.arg=m;;){var y=r.delegate;if(y){var b=ce(y,r);if(b){if(b===L)continue;return b}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(s===E)throw s=G,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=z;var g=A(t,e,r);if(g.type==="normal"){if(s=r.done?G:ae,g.arg===L)continue;return{value:g.arg,done:r.done}}else g.type==="throw"&&(s=G,r.method="throw",r.arg=g.arg)}}}function ce(t,e){var r=e.method,s=t.iterator[r];if(s===c)return e.delegate=null,r==="throw"&&t.iterator.return&&(e.method="return",e.arg=c,ce(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),L;var o=A(s,t.iterator,e.arg);if(o.type==="throw")return e.method="throw",e.arg=o.arg,e.delegate=null,L;var f=o.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,L;if(f.done)e[t.resultName]=f.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=c);else return f;return e.delegate=null,L}se(N),v(N,w,"Generator"),v(N,p,function(){return this}),v(N,"toString",function(){return"[object Generator]"});function Oe(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function Q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function X(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(Oe,this),this.reset(!0)}n.keys=function(t){var e=Object(t),r=[];for(var s in e)r.push(s);return r.reverse(),function o(){for(;r.length;){var f=r.pop();if(f in e)return o.value=f,o.done=!1,o}return o.done=!0,o}};function Z(t){if(t){var e=t[p];if(e)return e.call(t);if(typeof t.next=="function")return t;if(!isNaN(t.length)){var r=-1,s=function o(){for(;++r<t.length;)if(i.call(t,r))return o.value=t[r],o.done=!1,o;return o.value=c,o.done=!0,o};return s.next=s}}return{next:fe}}n.values=Z;function fe(){return{value:c,done:!0}}return X.prototype={constructor:X,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method="next",this.arg=c,this.tryEntries.forEach(Q),!t)for(var e in this)e.charAt(0)==="t"&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=c)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if(e.type==="throw")throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(b,g){return f.type="throw",f.arg=t,e.next=b,g&&(e.method="next",e.arg=c),!!g}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],f=o.completion;if(o.tryLoc==="root")return r("end");if(o.tryLoc<=this.prev){var m=i.call(o,"catchLoc"),y=i.call(o,"finallyLoc");if(m&&y){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(m){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else if(y){if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var s=this.tryEntries[r];if(s.tryLoc<=this.prev&&i.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var o=s;break}}o&&(t==="break"||t==="continue")&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var f=o?o.completion:{};return f.type=t,f.arg=e,o?(this.method="next",this.next=o.finallyLoc,L):this.complete(f)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),L},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),Q(r),L}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var s=r.completion;if(s.type==="throw"){var o=s.arg;Q(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:Z(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),L}},n}(typeof oe=="object"?oe.exports:{});try{regeneratorRuntime=ne}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=ne:Function("r","regeneratorRuntime = r")(ne)}});var u={};De(u,{Magic:()=>Ue,useInternetConnection:()=>B});module.exports=ke(u);var He=I(pe()),be=require("@magic-sdk/provider"),Be=I(require("process")),Se=I(require("localforage")),$=require("whatwg-url"),q=require("buffer"),Ee=I(require("lodash")),Le=require("react-native-device-info"),_e=require("@aveq-research/localforage-asyncstorage-driver"),ie=I(require("localforage-driver-memory"));var d=I(require("react")),F=require("react-native"),me=require("react-native-webview"),ye=require("react-native-safe-area-context"),Y=require("@magic-sdk/provider"),ge=require("lodash");var j=require("react"),ve=I(require("@react-native-community/netinfo")),B=()=>{let[n,a]=(0,j.useState)(!0);return(0,j.useEffect)(()=>{let i=h=>{a(!!h.isConnected)};return ve.default.addEventListener(i)},[]),n};var de="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Te="open_in_device_browser",We="#FFFFFF";function je(){return F.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 U=class extends Y.ViewController{constructor(){super(...arguments);this.Relayer=i=>{let[h,c]=(0,d.useState)(!1),S=B();(0,d.useEffect)(()=>{this.isConnectedToInternet=S},[S]),(0,d.useEffect)(()=>()=>{this.isReadyForRequest=!1},[]);let p=(0,d.useCallback)(E=>{this.webView=E},[]),_=(0,d.useCallback)(E=>{this.container=re(te({},E),{showOverlay:w,hideOverlay:v})},[]),w=(0,d.useCallback)(()=>{c(!0)},[]),v=(0,d.useCallback)(()=>{c(!1)},[]),V=(0,d.useMemo)(()=>[this.styles["webview-container"],h?re(te({},this.styles.show),{backgroundColor:i!=null?i:We}):this.styles.hide],[h]),A=(0,d.useCallback)(E=>{this.handleReactNativeWebViewMessage(E)},[]);return d.default.createElement(ye.SafeAreaView,{ref:_,style:V},d.default.createElement(me.WebView,{ref:p,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:A,style:this.styles["magic-webview"],webviewDebuggingEnabled:!0,autoManageStatusBarEnabled:!1,onShouldStartLoadWithRequest:E=>new URLSearchParams(E.url.split("?")[1]).get(Te)?(F.Linking.openURL(E.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=je()}handleReactNativeWebViewMessage(i){var h;if(i.nativeEvent&&typeof i.nativeEvent.data=="string"&&(i.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||i.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(i.nativeEvent.data,(S,p)=>{try{if(p&&typeof p=="object"&&p.flag&&p.flag===de)return new global[p.constructor](p.data.split(","))}catch(_){}return p});if(c&&c.msgType&&this.messageHandlers.size){c.response=(h=c.response)!=null?h:{};let S={data:c};for(let p of this.messageHandlers.values())p(S)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return W(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(h,c)=>(0,ge.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:de}:c),this.endpoint);else throw(0,Y.createModalNotReadyError)()})}};var we=require("@magic-sdk/provider"),K=class extends we.SDKBase{get Relayer(){return this.overlay.Relayer}};l(u,require("@magic-sdk/commons"),module.exports);global.process=Ee.merge(global.process,Be);global.process.browser=!1;global.Buffer=q.Buffer;global.URL=$.URL;global.URLSearchParams=$.URLSearchParams;global.btoa=n=>q.Buffer.from(n,"binary").toString("base64");global.atob=n=>q.Buffer.from(n,"base64").toString("binary");var Ue=(0,be.createSDK)(K,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"29.4.0",bundleId:(0,Le.getBundleId)(),defaultEndpoint:"https://box.magic.link/",ViewController:U,configureStorage:()=>W(void 0,null,function*(){let n=Se.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),a=(0,_e.driverWithoutSerialization)();return yield Promise.all([n.defineDriver(a),n.defineDriver(ie)]),yield n.setDriver([a._driver,ie._driver]),n})});0&&(module.exports={Magic,useInternetConnection});
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var he=Object.create;var K=Object.defineProperty,pe=Object.defineProperties,ve=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,re=Object.getOwnPropertySymbols,ye=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var ne=(o,s,i)=>s in o?K(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,$=(o,s)=>{for(var i in s||(s={}))oe.call(s,i)&&ne(o,i,s[i]);if(re)for(var i of re(s))ge.call(s,i)&&ne(o,i,s[i]);return o},q=(o,s)=>pe(o,de(s));var we=(o,s)=>()=>(s||o((s={exports:{}}).exports,s),s.exports);var be=(o,s,i,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of me(s))!oe.call(o,c)&&c!==i&&K(o,c,{get:()=>s[c],enumerable:!(u=ve(s,c))||u.enumerable});return o};var Se=(o,s,i)=>(i=o!=null?he(ye(o)):{},be(s||!o||!o.__esModule?K(i,"default",{value:o,enumerable:!0}):i,o));var G=(o,s,i)=>new Promise((u,c)=>{var g=m=>{try{S(i.next(m))}catch(h){c(h)}},l=m=>{try{S(i.throw(m))}catch(h){c(h)}},S=m=>m.done?u(m.value):Promise.resolve(m.value).then(g,l);S((i=i.apply(o,s)).next())});var ie=we((qe,x)=>{var z=function(o){"use strict";var s=Object.prototype,i=s.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c,g=typeof Symbol=="function"?Symbol:{},l=g.iterator||"@@iterator",S=g.asyncIterator||"@@asyncIterator",m=g.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch{h=function(e,r,a){return e[r]=a}}function N(t,e,r,a){var n=e&&e.prototype instanceof T?e:T,f=Object.create(n.prototype),p=new U(a||[]);return u(f,"_invoke",{value:ue(t,r,p)}),f}o.wrap=N;function R(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(a){return{type:"throw",arg:a}}}var w="suspendedStart",X="suspendedYield",k="executing",A="completed",b={};function T(){}function C(){}function E(){}var W={};h(W,l,function(){return this});var j=Object.getPrototypeOf,M=j&&j(j(F([])));M&&M!==s&&i.call(M,l)&&(W=M);var _=E.prototype=T.prototype=Object.create(W);C.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:C,configurable:!0}),C.displayName=h(E,m,"GeneratorFunction");function Z(t){["next","throw","return"].forEach(function(e){h(t,e,function(r){return this._invoke(e,r)})})}o.isGeneratorFunction=function(t){var e=typeof t=="function"&&t.constructor;return e?e===C||(e.displayName||e.name)==="GeneratorFunction":!1},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,E):(t.__proto__=E,h(t,m,"GeneratorFunction")),t.prototype=Object.create(_),t},o.awrap=function(t){return{__await:t}};function V(t,e){function r(f,p,v,y){var d=R(t[f],t,p);if(d.type==="throw")y(d.arg);else{var Y=d.arg,O=Y.value;return O&&typeof O=="object"&&i.call(O,"__await")?e.resolve(O.__await).then(function(L){r("next",L,v,y)},function(L){r("throw",L,v,y)}):e.resolve(O).then(function(L){Y.value=L,v(Y)},function(L){return r("throw",L,v,y)})}}var a;function n(f,p){function v(){return new e(function(y,d){r(f,p,y,d)})}return a=a?a.then(v,v):v()}u(this,"_invoke",{value:n})}Z(V.prototype),h(V.prototype,S,function(){return this}),o.AsyncIterator=V,o.async=function(t,e,r,a,n){n===void 0&&(n=Promise);var f=new V(N(t,e,r,a),n);return o.isGeneratorFunction(e)?f:f.next().then(function(p){return p.done?p.value:f.next()})};function ue(t,e,r){var a=w;return function(f,p){if(a===k)throw new Error("Generator is already running");if(a===A){if(f==="throw")throw p;return te()}for(r.method=f,r.arg=p;;){var v=r.delegate;if(v){var y=ee(v,r);if(y){if(y===b)continue;return y}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(a===w)throw a=A,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=k;var d=R(t,e,r);if(d.type==="normal"){if(a=r.done?A:X,d.arg===b)continue;return{value:d.arg,done:r.done}}else d.type==="throw"&&(a=A,r.method="throw",r.arg=d.arg)}}}function ee(t,e){var r=e.method,a=t.iterator[r];if(a===c)return e.delegate=null,r==="throw"&&t.iterator.return&&(e.method="return",e.arg=c,ee(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var n=R(a,t.iterator,e.arg);if(n.type==="throw")return e.method="throw",e.arg=n.arg,e.delegate=null,b;var f=n.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b;if(f.done)e[t.resultName]=f.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=c);else return f;return e.delegate=null,b}Z(_),h(_,m,"Generator"),h(_,l,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function le(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function B(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function U(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(le,this),this.reset(!0)}o.keys=function(t){var e=Object(t),r=[];for(var a in e)r.push(a);return r.reverse(),function n(){for(;r.length;){var f=r.pop();if(f in e)return n.value=f,n.done=!1,n}return n.done=!0,n}};function F(t){if(t){var e=t[l];if(e)return e.call(t);if(typeof t.next=="function")return t;if(!isNaN(t.length)){var r=-1,a=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=c,n.done=!0,n};return a.next=a}}return{next:te}}o.values=F;function te(){return{value:c,done:!0}}return U.prototype={constructor:U,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method="next",this.arg=c,this.tryEntries.forEach(B),!t)for(var e in this)e.charAt(0)==="t"&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=c)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if(e.type==="throw")throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(y,d){return f.type="throw",f.arg=t,e.next=y,d&&(e.method="next",e.arg=c),!!d}for(var a=this.tryEntries.length-1;a>=0;--a){var n=this.tryEntries[a],f=n.completion;if(n.tryLoc==="root")return r("end");if(n.tryLoc<=this.prev){var p=i.call(n,"catchLoc"),v=i.call(n,"finallyLoc");if(p&&v){if(this.prev<n.catchLoc)return r(n.catchLoc,!0);if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else if(p){if(this.prev<n.catchLoc)return r(n.catchLoc,!0)}else if(v){if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&i.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var n=a;break}}n&&(t==="break"||t==="continue")&&n.tryLoc<=e&&e<=n.finallyLoc&&(n=null);var f=n?n.completion:{};return f.type=t,f.arg=e,n?(this.method="next",this.next=n.finallyLoc,b):this.complete(f)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),B(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var a=r.completion;if(a.type==="throw"){var n=a.arg;B(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:F(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),b}},o}(typeof x=="object"?x.exports:{});try{regeneratorRuntime=z}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=z:Function("r","regeneratorRuntime = r")(z)}});var ct=Se(ie());import{createSDK as We}from"@magic-sdk/provider";import*as je from"process";import Be from"localforage";import{URL as Ue,URLSearchParams as Fe}from"whatwg-url";import{Buffer as H}from"buffer";import*as fe from"lodash";import{getBundleId as Ye}from"react-native-device-info";import{driverWithoutSerialization as Ke}from"@aveq-research/localforage-asyncstorage-driver";import*as Q from"localforage-driver-memory";import ae,{useState as Re,useCallback as I,useMemo as Oe,useEffect as se}from"react";import{Linking as Ie,StyleSheet as Ne}from"react-native";import{WebView as Ae}from"react-native-webview";import{SafeAreaView as Ce}from"react-native-safe-area-context";import{ViewController as Me,createModalNotReadyError as Ve}from"@magic-sdk/provider";import{isTypedArray as Ge}from"lodash";import{useEffect as Ee,useState as Le}from"react";import _e from"@react-native-community/netinfo";var J=()=>{let[o,s]=Le(!0);return Ee(()=>{let i=u=>{s(!!u.isConnected)};return _e.addEventListener(i)},[]),o};var ce="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Pe="open_in_device_browser",De="#FFFFFF";function ke(){return Ne.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 P=class extends Me{constructor(){super(...arguments);this.Relayer=i=>{let[u,c]=Re(!1),g=J();se(()=>{this.isConnectedToInternet=g},[g]),se(()=>()=>{this.isReadyForRequest=!1},[]);let l=I(w=>{this.webView=w},[]),S=I(w=>{this.container=q($({},w),{showOverlay:m,hideOverlay:h})},[]),m=I(()=>{c(!0)},[]),h=I(()=>{c(!1)},[]),N=Oe(()=>[this.styles["webview-container"],u?q($({},this.styles.show),{backgroundColor:i!=null?i:De}):this.styles.hide],[u]),R=I(w=>{this.handleReactNativeWebViewMessage(w)},[]);return ae.createElement(Ce,{ref:S,style:N},ae.createElement(Ae,{ref:l,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:R,style:this.styles["magic-webview"],webviewDebuggingEnabled:!0,autoManageStatusBarEnabled:!1,onShouldStartLoadWithRequest:w=>new URLSearchParams(w.url.split("?")[1]).get(Pe)?(Ie.openURL(w.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=ke()}handleReactNativeWebViewMessage(i){var u;if(i.nativeEvent&&typeof i.nativeEvent.data=="string"&&(i.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||i.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(i.nativeEvent.data,(g,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag===ce)return new global[l.constructor](l.data.split(","))}catch(S){}return l});if(c&&c.msgType&&this.messageHandlers.size){c.response=(u=c.response)!=null?u:{};let g={data:c};for(let l of this.messageHandlers.values())l(g)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return G(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(u,c)=>Ge(c)?{constructor:c.constructor.name,data:c.toString(),flag:ce}:c),this.endpoint);else throw Ve()})}};import{SDKBase as Te}from"@magic-sdk/provider";var D=class extends Te{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=fe.merge(global.process,je);global.process.browser=!1;global.Buffer=H;global.URL=Ue;global.URLSearchParams=Fe;global.btoa=o=>H.from(o,"binary").toString("base64");global.atob=o=>H.from(o,"base64").toString("binary");var wt=We(D,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"29.3.0",bundleId:Ye(),defaultEndpoint:"https://box.magic.link/",ViewController:P,configureStorage:()=>G(void 0,null,function*(){let o=Be.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Ke();return yield Promise.all([o.defineDriver(s),o.defineDriver(Q)]),yield o.setDriver([s._driver,Q._driver]),o})});export{wt as Magic,J as useInternetConnection};
|
1
|
+
var he=Object.create;var K=Object.defineProperty,pe=Object.defineProperties,ve=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,re=Object.getOwnPropertySymbols,ye=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var ne=(o,s,i)=>s in o?K(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,$=(o,s)=>{for(var i in s||(s={}))oe.call(s,i)&&ne(o,i,s[i]);if(re)for(var i of re(s))ge.call(s,i)&&ne(o,i,s[i]);return o},q=(o,s)=>pe(o,de(s));var we=(o,s)=>()=>(s||o((s={exports:{}}).exports,s),s.exports);var be=(o,s,i,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of me(s))!oe.call(o,c)&&c!==i&&K(o,c,{get:()=>s[c],enumerable:!(u=ve(s,c))||u.enumerable});return o};var Se=(o,s,i)=>(i=o!=null?he(ye(o)):{},be(s||!o||!o.__esModule?K(i,"default",{value:o,enumerable:!0}):i,o));var G=(o,s,i)=>new Promise((u,c)=>{var g=m=>{try{S(i.next(m))}catch(h){c(h)}},l=m=>{try{S(i.throw(m))}catch(h){c(h)}},S=m=>m.done?u(m.value):Promise.resolve(m.value).then(g,l);S((i=i.apply(o,s)).next())});var ie=we((qe,x)=>{var z=function(o){"use strict";var s=Object.prototype,i=s.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c,g=typeof Symbol=="function"?Symbol:{},l=g.iterator||"@@iterator",S=g.asyncIterator||"@@asyncIterator",m=g.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch{h=function(e,r,a){return e[r]=a}}function N(t,e,r,a){var n=e&&e.prototype instanceof T?e:T,f=Object.create(n.prototype),p=new U(a||[]);return u(f,"_invoke",{value:ue(t,r,p)}),f}o.wrap=N;function R(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(a){return{type:"throw",arg:a}}}var w="suspendedStart",X="suspendedYield",k="executing",A="completed",b={};function T(){}function C(){}function E(){}var W={};h(W,l,function(){return this});var j=Object.getPrototypeOf,M=j&&j(j(F([])));M&&M!==s&&i.call(M,l)&&(W=M);var _=E.prototype=T.prototype=Object.create(W);C.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:C,configurable:!0}),C.displayName=h(E,m,"GeneratorFunction");function Z(t){["next","throw","return"].forEach(function(e){h(t,e,function(r){return this._invoke(e,r)})})}o.isGeneratorFunction=function(t){var e=typeof t=="function"&&t.constructor;return e?e===C||(e.displayName||e.name)==="GeneratorFunction":!1},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,E):(t.__proto__=E,h(t,m,"GeneratorFunction")),t.prototype=Object.create(_),t},o.awrap=function(t){return{__await:t}};function V(t,e){function r(f,p,v,y){var d=R(t[f],t,p);if(d.type==="throw")y(d.arg);else{var Y=d.arg,O=Y.value;return O&&typeof O=="object"&&i.call(O,"__await")?e.resolve(O.__await).then(function(L){r("next",L,v,y)},function(L){r("throw",L,v,y)}):e.resolve(O).then(function(L){Y.value=L,v(Y)},function(L){return r("throw",L,v,y)})}}var a;function n(f,p){function v(){return new e(function(y,d){r(f,p,y,d)})}return a=a?a.then(v,v):v()}u(this,"_invoke",{value:n})}Z(V.prototype),h(V.prototype,S,function(){return this}),o.AsyncIterator=V,o.async=function(t,e,r,a,n){n===void 0&&(n=Promise);var f=new V(N(t,e,r,a),n);return o.isGeneratorFunction(e)?f:f.next().then(function(p){return p.done?p.value:f.next()})};function ue(t,e,r){var a=w;return function(f,p){if(a===k)throw new Error("Generator is already running");if(a===A){if(f==="throw")throw p;return te()}for(r.method=f,r.arg=p;;){var v=r.delegate;if(v){var y=ee(v,r);if(y){if(y===b)continue;return y}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(a===w)throw a=A,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=k;var d=R(t,e,r);if(d.type==="normal"){if(a=r.done?A:X,d.arg===b)continue;return{value:d.arg,done:r.done}}else d.type==="throw"&&(a=A,r.method="throw",r.arg=d.arg)}}}function ee(t,e){var r=e.method,a=t.iterator[r];if(a===c)return e.delegate=null,r==="throw"&&t.iterator.return&&(e.method="return",e.arg=c,ee(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var n=R(a,t.iterator,e.arg);if(n.type==="throw")return e.method="throw",e.arg=n.arg,e.delegate=null,b;var f=n.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b;if(f.done)e[t.resultName]=f.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=c);else return f;return e.delegate=null,b}Z(_),h(_,m,"Generator"),h(_,l,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function le(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function B(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function U(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(le,this),this.reset(!0)}o.keys=function(t){var e=Object(t),r=[];for(var a in e)r.push(a);return r.reverse(),function n(){for(;r.length;){var f=r.pop();if(f in e)return n.value=f,n.done=!1,n}return n.done=!0,n}};function F(t){if(t){var e=t[l];if(e)return e.call(t);if(typeof t.next=="function")return t;if(!isNaN(t.length)){var r=-1,a=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=c,n.done=!0,n};return a.next=a}}return{next:te}}o.values=F;function te(){return{value:c,done:!0}}return U.prototype={constructor:U,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=c,this.done=!1,this.delegate=null,this.method="next",this.arg=c,this.tryEntries.forEach(B),!t)for(var e in this)e.charAt(0)==="t"&&i.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=c)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if(e.type==="throw")throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(y,d){return f.type="throw",f.arg=t,e.next=y,d&&(e.method="next",e.arg=c),!!d}for(var a=this.tryEntries.length-1;a>=0;--a){var n=this.tryEntries[a],f=n.completion;if(n.tryLoc==="root")return r("end");if(n.tryLoc<=this.prev){var p=i.call(n,"catchLoc"),v=i.call(n,"finallyLoc");if(p&&v){if(this.prev<n.catchLoc)return r(n.catchLoc,!0);if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else if(p){if(this.prev<n.catchLoc)return r(n.catchLoc,!0)}else if(v){if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&i.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var n=a;break}}n&&(t==="break"||t==="continue")&&n.tryLoc<=e&&e<=n.finallyLoc&&(n=null);var f=n?n.completion:{};return f.type=t,f.arg=e,n?(this.method="next",this.next=n.finallyLoc,b):this.complete(f)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),B(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var a=r.completion;if(a.type==="throw"){var n=a.arg;B(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:F(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),b}},o}(typeof x=="object"?x.exports:{});try{regeneratorRuntime=z}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=z:Function("r","regeneratorRuntime = r")(z)}});var ct=Se(ie());import{createSDK as We}from"@magic-sdk/provider";import*as je from"process";import Be from"localforage";import{URL as Ue,URLSearchParams as Fe}from"whatwg-url";import{Buffer as H}from"buffer";import*as fe from"lodash";import{getBundleId as Ye}from"react-native-device-info";import{driverWithoutSerialization as Ke}from"@aveq-research/localforage-asyncstorage-driver";import*as Q from"localforage-driver-memory";import ae,{useState as Re,useCallback as I,useMemo as Oe,useEffect as se}from"react";import{Linking as Ie,StyleSheet as Ne}from"react-native";import{WebView as Ae}from"react-native-webview";import{SafeAreaView as Ce}from"react-native-safe-area-context";import{ViewController as Me,createModalNotReadyError as Ve}from"@magic-sdk/provider";import{isTypedArray as Ge}from"lodash";import{useEffect as Ee,useState as Le}from"react";import _e from"@react-native-community/netinfo";var J=()=>{let[o,s]=Le(!0);return Ee(()=>{let i=u=>{s(!!u.isConnected)};return _e.addEventListener(i)},[]),o};var ce="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Pe="open_in_device_browser",De="#FFFFFF";function ke(){return Ne.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 P=class extends Me{constructor(){super(...arguments);this.Relayer=i=>{let[u,c]=Re(!1),g=J();se(()=>{this.isConnectedToInternet=g},[g]),se(()=>()=>{this.isReadyForRequest=!1},[]);let l=I(w=>{this.webView=w},[]),S=I(w=>{this.container=q($({},w),{showOverlay:m,hideOverlay:h})},[]),m=I(()=>{c(!0)},[]),h=I(()=>{c(!1)},[]),N=Oe(()=>[this.styles["webview-container"],u?q($({},this.styles.show),{backgroundColor:i!=null?i:De}):this.styles.hide],[u]),R=I(w=>{this.handleReactNativeWebViewMessage(w)},[]);return ae.createElement(Ce,{ref:S,style:N},ae.createElement(Ae,{ref:l,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:R,style:this.styles["magic-webview"],webviewDebuggingEnabled:!0,autoManageStatusBarEnabled:!1,onShouldStartLoadWithRequest:w=>new URLSearchParams(w.url.split("?")[1]).get(Pe)?(Ie.openURL(w.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=ke()}handleReactNativeWebViewMessage(i){var u;if(i.nativeEvent&&typeof i.nativeEvent.data=="string"&&(i.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||i.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(i.nativeEvent.data,(g,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag===ce)return new global[l.constructor](l.data.split(","))}catch(S){}return l});if(c&&c.msgType&&this.messageHandlers.size){c.response=(u=c.response)!=null?u:{};let g={data:c};for(let l of this.messageHandlers.values())l(g)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return G(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(u,c)=>Ge(c)?{constructor:c.constructor.name,data:c.toString(),flag:ce}:c),this.endpoint);else throw Ve()})}};import{SDKBase as Te}from"@magic-sdk/provider";var D=class extends Te{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=fe.merge(global.process,je);global.process.browser=!1;global.Buffer=H;global.URL=Ue;global.URLSearchParams=Fe;global.btoa=o=>H.from(o,"binary").toString("base64");global.atob=o=>H.from(o,"base64").toString("binary");var wt=We(D,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"29.4.0",bundleId:Ye(),defaultEndpoint:"https://box.magic.link/",ViewController:P,configureStorage:()=>G(void 0,null,function*(){let o=Be.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Ke();return yield Promise.all([o.defineDriver(s),o.defineDriver(Q)]),yield o.setDriver([s._driver,Q._driver]),o})});export{wt as Magic,J 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-bare",
|
3
|
-
"version": "29.4.
|
3
|
+
"version": "29.4.1-canary.781.10390936903.0",
|
4
4
|
"description": "Passwordless authentication for React Native (Bare).",
|
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": "24.4.
|
22
|
-
"@magic-sdk/provider": "28.4.
|
23
|
-
"@magic-sdk/types": "24.2.
|
21
|
+
"@magic-sdk/commons": "24.4.1-canary.781.10390936903.0",
|
22
|
+
"@magic-sdk/provider": "28.4.1-canary.781.10390936903.0",
|
23
|
+
"@magic-sdk/types": "24.2.1-canary.781.10390936903.0",
|
24
24
|
"@react-native-async-storage/async-storage": "^1.15.5",
|
25
25
|
"@types/lodash": "^4.14.158",
|
26
26
|
"buffer": "~5.6.0",
|
@@ -56,5 +56,5 @@
|
|
56
56
|
"react-native-safe-area-context": ">=4.4.1",
|
57
57
|
"react-native-webview": ">=12.4.0"
|
58
58
|
},
|
59
|
-
"gitHead": "
|
59
|
+
"gitHead": "517bc14cfeed5cbd316adba2fd5788ae33f48e96"
|
60
60
|
}
|