@magic-sdk/react-native-bare 22.3.2-canary.673.7023773085.0 β†’ 22.3.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # v22.3.2 (Tue Nov 28 2023)
2
+
3
+ #### πŸ› Bug Fix
4
+
5
+ - Fix: Allow implementers of `view-controller`Β to set if it's connected to the internet, and reject requests when `isConnectedToInternet` is `false` [#673](https://github.com/magiclabs/magic-js/pull/673) ([@romin-halltari](https://github.com/romin-halltari))
6
+ - Bump patch versions ([@romin-halltari](https://github.com/romin-halltari))
7
+ - Set isConnectedToInternet with value coming from @react-native-community/netinfo ([@romin-halltari](https://github.com/romin-halltari))
8
+
9
+ #### Authors: 1
10
+
11
+ - [@romin-halltari](https://github.com/romin-halltari)
12
+
13
+ ---
14
+
1
15
  # v22.3.0 (Mon Nov 20 2023)
2
16
 
3
17
  #### πŸš€ Enhancement
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),d=new X(s||[]);return h(f,"_invoke",{value:Oe(t,r,d)}),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 O(){}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=O.prototype=x.prototype=Object.create(J);P.prototype=O,h(N,"constructor",{value:O,configurable:!0}),h(O,"constructor",{value:P,configurable:!0}),P.displayName=v(O,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,O):(t.__proto__=O,v(t,w,"GeneratorFunction")),t.prototype=Object.create(N),t},n.awrap=function(t){return{__await:t}};function k(t,e){function r(f,d,y,b){var g=A(t[f],t,d);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(R){r("next",R,y,b)},function(R){r("throw",R,y,b)}):e.resolve(C).then(function(R){ee.value=R,y(ee)},function(R){return r("throw",R,y,b)})}}var s;function o(f,d){function y(){return new e(function(b,g){r(f,d,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(d){return d.done?d.value:f.next()})};function Oe(t,e,r){var s=E;return function(f,d){if(s===z)throw new Error("Generator is already running");if(s===G){if(f==="throw")throw d;return fe()}for(r.method=f,r.arg=d;;){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 Re(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(Re,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 d=i.call(o,"catchLoc"),y=i.call(o,"finallyLoc");if(d&&y){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(d){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 m=I(require("react")),F=require("react-native"),de=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 me="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,m.useState)(!1),S=B();(0,m.useEffect)(()=>{this.isConnectedToInternet=S},[S]);let p=(0,m.useCallback)(E=>{this.webView=E},[]),_=(0,m.useCallback)(E=>{this.container=re(te({},E),{showOverlay:w,hideOverlay:v})},[]),w=(0,m.useCallback)(()=>{c(!0)},[]),v=(0,m.useCallback)(()=>{c(!1)},[]),V=(0,m.useMemo)(()=>[this.styles["webview-container"],h?re(te({},this.styles.show),{backgroundColor:i!=null?i:We}):this.styles.hide],[h]),A=(0,m.useCallback)(E=>{this.handleReactNativeWebViewMessage(E)},[]);return m.default.createElement(ye.SafeAreaView,{ref:_,style:V},m.default.createElement(de.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===me)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:me}: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:"22.3.1",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),d=new X(s||[]);return h(f,"_invoke",{value:Oe(t,r,d)}),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 O(){}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=O.prototype=x.prototype=Object.create(J);P.prototype=O,h(N,"constructor",{value:O,configurable:!0}),h(O,"constructor",{value:P,configurable:!0}),P.displayName=v(O,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,O):(t.__proto__=O,v(t,w,"GeneratorFunction")),t.prototype=Object.create(N),t},n.awrap=function(t){return{__await:t}};function k(t,e){function r(f,d,y,b){var g=A(t[f],t,d);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(R){r("next",R,y,b)},function(R){r("throw",R,y,b)}):e.resolve(C).then(function(R){ee.value=R,y(ee)},function(R){return r("throw",R,y,b)})}}var s;function o(f,d){function y(){return new e(function(b,g){r(f,d,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(d){return d.done?d.value:f.next()})};function Oe(t,e,r){var s=E;return function(f,d){if(s===z)throw new Error("Generator is already running");if(s===G){if(f==="throw")throw d;return fe()}for(r.method=f,r.arg=d;;){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 Re(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(Re,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 d=i.call(o,"catchLoc"),y=i.call(o,"finallyLoc");if(d&&y){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(d){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 m=I(require("react")),F=require("react-native"),de=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 me="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,m.useState)(!1),S=B();(0,m.useEffect)(()=>{this.isConnectedToInternet=S},[S]);let p=(0,m.useCallback)(E=>{this.webView=E},[]),_=(0,m.useCallback)(E=>{this.container=re(te({},E),{showOverlay:w,hideOverlay:v})},[]),w=(0,m.useCallback)(()=>{c(!0)},[]),v=(0,m.useCallback)(()=>{c(!1)},[]),V=(0,m.useMemo)(()=>[this.styles["webview-container"],h?re(te({},this.styles.show),{backgroundColor:i!=null?i:We}):this.styles.hide],[h]),A=(0,m.useCallback)(E=>{this.handleReactNativeWebViewMessage(E)},[]);return m.default.createElement(ye.SafeAreaView,{ref:_,style:V},m.default.createElement(de.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===me)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:me}: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:"22.3.2",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 le=Object.create;var K=Object.defineProperty,he=Object.defineProperties,pe=Object.getOwnPropertyDescriptor,ve=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,re=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,ye=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))ye.call(s,i)&&ne(o,i,s[i]);return o},q=(o,s)=>he(o,ve(s));var ge=(o,s)=>()=>(s||o((s={exports:{}}).exports,s),s.exports);var we=(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=pe(s,c))||u.enumerable});return o};var be=(o,s,i)=>(i=o!=null?le(de(o)):{},we(s||!o||!o.__esModule?K(i,"default",{value:o,enumerable:!0}):i,o));var G=(o,s,i)=>new Promise((u,c)=>{var g=d=>{try{S(i.next(d))}catch(h){c(h)}},l=d=>{try{S(i.throw(d))}catch(h){c(h)}},S=d=>d.done?u(d.value):Promise.resolve(d.value).then(g,l);S((i=i.apply(o,s)).next())});var ie=ge((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",d=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:fe(t,r,p)}),f}o.wrap=N;function O(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,d,"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,d,"GeneratorFunction")),t.prototype=Object.create(_),t},o.awrap=function(t){return{__await:t}};function V(t,e){function r(f,p,v,y){var m=O(t[f],t,p);if(m.type==="throw")y(m.arg);else{var Y=m.arg,R=Y.value;return R&&typeof R=="object"&&i.call(R,"__await")?e.resolve(R.__await).then(function(L){r("next",L,v,y)},function(L){r("throw",L,v,y)}):e.resolve(R).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,m){r(f,p,y,m)})}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 fe(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 m=O(t,e,r);if(m.type==="normal"){if(a=r.done?A:X,m.arg===b)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=A,r.method="throw",r.arg=m.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=O(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(_,d,"Generator"),h(_,l,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function ue(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(ue,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,m){return f.type="throw",f.arg=t,e.next=y,m&&(e.method="next",e.arg=c),!!m}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=be(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 ce 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 _e,useCallback as I,useMemo as Oe,useEffect as Re}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 Se,useState as Ee}from"react";import Le from"@react-native-community/netinfo";var J=()=>{let[o,s]=Ee(!0);return Se(()=>{let i=u=>{s(!!u.isConnected)};return Le.addEventListener(i)},[]),o};var se="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]=_e(!1),g=J();Re(()=>{this.isConnectedToInternet=g},[g]);let l=I(w=>{this.webView=w},[]),S=I(w=>{this.container=q($({},w),{showOverlay:d,hideOverlay:h})},[]),d=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]),O=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:O,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===se)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:se}: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=ce.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:"22.3.1",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 le=Object.create;var K=Object.defineProperty,he=Object.defineProperties,pe=Object.getOwnPropertyDescriptor,ve=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,re=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,ye=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))ye.call(s,i)&&ne(o,i,s[i]);return o},q=(o,s)=>he(o,ve(s));var ge=(o,s)=>()=>(s||o((s={exports:{}}).exports,s),s.exports);var we=(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=pe(s,c))||u.enumerable});return o};var be=(o,s,i)=>(i=o!=null?le(de(o)):{},we(s||!o||!o.__esModule?K(i,"default",{value:o,enumerable:!0}):i,o));var G=(o,s,i)=>new Promise((u,c)=>{var g=d=>{try{S(i.next(d))}catch(h){c(h)}},l=d=>{try{S(i.throw(d))}catch(h){c(h)}},S=d=>d.done?u(d.value):Promise.resolve(d.value).then(g,l);S((i=i.apply(o,s)).next())});var ie=ge((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",d=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:fe(t,r,p)}),f}o.wrap=N;function O(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,d,"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,d,"GeneratorFunction")),t.prototype=Object.create(_),t},o.awrap=function(t){return{__await:t}};function V(t,e){function r(f,p,v,y){var m=O(t[f],t,p);if(m.type==="throw")y(m.arg);else{var Y=m.arg,R=Y.value;return R&&typeof R=="object"&&i.call(R,"__await")?e.resolve(R.__await).then(function(L){r("next",L,v,y)},function(L){r("throw",L,v,y)}):e.resolve(R).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,m){r(f,p,y,m)})}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 fe(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 m=O(t,e,r);if(m.type==="normal"){if(a=r.done?A:X,m.arg===b)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=A,r.method="throw",r.arg=m.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=O(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(_,d,"Generator"),h(_,l,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function ue(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(ue,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,m){return f.type="throw",f.arg=t,e.next=y,m&&(e.method="next",e.arg=c),!!m}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=be(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 ce 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 _e,useCallback as I,useMemo as Oe,useEffect as Re}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 Se,useState as Ee}from"react";import Le from"@react-native-community/netinfo";var J=()=>{let[o,s]=Ee(!0);return Se(()=>{let i=u=>{s(!!u.isConnected)};return Le.addEventListener(i)},[]),o};var se="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]=_e(!1),g=J();Re(()=>{this.isConnectedToInternet=g},[g]);let l=I(w=>{this.webView=w},[]),S=I(w=>{this.container=q($({},w),{showOverlay:d,hideOverlay:h})},[]),d=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]),O=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:O,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===se)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:se}: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=ce.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:"22.3.2",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": "22.3.2-canary.673.7023773085.0",
3
+ "version": "22.3.2",
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,8 +18,8 @@
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": "17.3.1-canary.673.7023773085.0",
22
- "@magic-sdk/provider": "21.3.1-canary.673.7023773085.0",
21
+ "@magic-sdk/commons": "^17.3.1",
22
+ "@magic-sdk/provider": "^21.3.1",
23
23
  "@magic-sdk/types": "^17.2.0",
24
24
  "@react-native-async-storage/async-storage": "^1.15.5",
25
25
  "@types/lodash": "^4.14.158",
@@ -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": "92af425185861b2e67054bd1ff1d98a538e0539e"
59
+ "gitHead": "0f29f5fffff2493620b574f5be3f7646b13ced97"
60
60
  }