@magic-sdk/react-native-expo 22.3.0-canary.665.6934462457.0 → 22.3.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/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ # v22.3.0 (Mon Nov 20 2023)
2
+
3
+ #### 🚀 Enhancement
4
+
5
+ - Add `useInternetConnection` hook to track internet connectivity changes [#665](https://github.com/magiclabs/magic-js/pull/665) ([@romin-halltari](https://github.com/romin-halltari))
6
+
7
+ #### 🐛 Bug Fix
8
+
9
+ - Use createModalNotReadyError() when modal is not ready on react native ([@romin-halltari](https://github.com/romin-halltari))
10
+ - Update readme ([@romin-halltari](https://github.com/romin-halltari))
11
+ - Merge branch 'master' into rominhalltari-sc-75722-react-native-sdk-add-support-for-general ([@romin-halltari](https://github.com/romin-halltari))
12
+ - Remove unnecessary comments ([@romin-halltari](https://github.com/romin-halltari))
13
+ - add tests for useInternetConnection hook ([@romin-halltari](https://github.com/romin-halltari))
14
+ - Setup testing with react-test-renderer and @testing-library/react-native ([@romin-halltari](https://github.com/romin-halltari))
15
+ - Update readme with installation step for @react-native-community/netinfo ([@romin-halltari](https://github.com/romin-halltari))
16
+ - Add `useInternetConnection` hook to track internet connectivity changes ([@romin-halltari](https://github.com/romin-halltari))
17
+
18
+ #### Authors: 1
19
+
20
+ - [@romin-halltari](https://github.com/romin-halltari)
21
+
22
+ ---
23
+
1
24
  # v22.2.2 (Tue Nov 14 2023)
2
25
 
3
26
  #### 🐛 Bug Fix
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,Me=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols,Ge=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var ue=(n,a,i)=>a in n?M(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,Z=(n,a)=>{for(var i in a||(a={}))le.call(a,i)&&ue(n,i,a[i]);if(fe)for(var i of fe(a))Pe.call(a,i)&&ue(n,i,a[i]);return n},ee=(n,a)=>Ne(n,Me(a));var Ce=(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})},k=(n,a,i,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Ve(a))!le.call(n,c)&&c!==i&&M(n,c,{get:()=>a[c],enumerable:!(h=Ae(a,c))||h.enumerable});return n},l=(n,a,i)=>(k(n,a,"default"),i&&k(i,a,"default")),O=(n,a,i)=>(i=n!=null?Ie(Ge(n)):{},k(a||!n||!n.__esModule?M(i,"default",{value:n,enumerable:!0}):i,n)),ke=n=>k(M({},"__esModule",{value:!0}),n);var T=(n,a,i)=>new Promise((h,c)=>{var L=g=>{try{_(i.next(g))}catch(v){c(v)}},p=g=>{try{_(i.throw(g))}catch(v){c(v)}},_=g=>g.done?h(g.value):Promise.resolve(g.value).then(L,p);_((i=i.apply(n,a)).next())});var he=Ce((Ye,re)=>{var te=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,h=Object.defineProperty||function(t,e,r){t[e]=r.value},c,L=typeof Symbol=="function"?Symbol:{},p=L.iterator||"@@iterator",_=L.asyncIterator||"@@asyncIterator",g=L.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 q?e:q,f=Object.create(o.prototype),m=new H(s||[]);return h(f,"_invoke",{value:Oe(t,r,m)}),f}n.wrap=V;function b(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(s){return{type:"throw",arg:s}}}var $="suspendedStart",oe="suspendedYield",ie="executing",G="completed",E={};function q(){}function P(){}function R(){}var x={};v(x,p,function(){return this});var z=Object.getPrototypeOf,C=z&&z(z(X([])));C&&C!==a&&i.call(C,p)&&(x=C);var N=R.prototype=q.prototype=Object.create(x);P.prototype=R,h(N,"constructor",{value:R,configurable:!0}),h(R,"constructor",{value:P,configurable:!0}),P.displayName=v(R,g,"GeneratorFunction");function ae(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,g,"GeneratorFunction")),t.prototype=Object.create(N),t},n.awrap=function(t){return{__await:t}};function D(t,e){function r(f,m,d,S){var y=b(t[f],t,m);if(y.type==="throw")S(y.arg);else{var Q=y.arg,A=Q.value;return A&&typeof A=="object"&&i.call(A,"__await")?e.resolve(A.__await).then(function(I){r("next",I,d,S)},function(I){r("throw",I,d,S)}):e.resolve(A).then(function(I){Q.value=I,d(Q)},function(I){return r("throw",I,d,S)})}}var s;function o(f,m){function d(){return new e(function(S,y){r(f,m,S,y)})}return s=s?s.then(d,d):d()}h(this,"_invoke",{value:o})}ae(D.prototype),v(D.prototype,_,function(){return this}),n.AsyncIterator=D,n.async=function(t,e,r,s,o){o===void 0&&(o=Promise);var f=new D(V(t,e,r,s),o);return n.isGeneratorFunction(e)?f:f.next().then(function(m){return m.done?m.value:f.next()})};function Oe(t,e,r){var s=$;return function(f,m){if(s===ie)throw new Error("Generator is already running");if(s===G){if(f==="throw")throw m;return ce()}for(r.method=f,r.arg=m;;){var d=r.delegate;if(d){var S=se(d,r);if(S){if(S===E)continue;return S}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(s===$)throw s=G,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=ie;var y=b(t,e,r);if(y.type==="normal"){if(s=r.done?G:oe,y.arg===E)continue;return{value:y.arg,done:r.done}}else y.type==="throw"&&(s=G,r.method="throw",r.arg=y.arg)}}}function se(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,se(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),E;var o=b(s,t.iterator,e.arg);if(o.type==="throw")return e.method="throw",e.arg=o.arg,e.delegate=null,E;var f=o.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,E;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,E}ae(N),v(N,g,"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 J(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function H(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 X(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:ce}}n.values=X;function ce(){return{value:c,done:!0}}return H.prototype={constructor:H,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(J),!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(S,y){return f.type="throw",f.arg=t,e.next=S,y&&(e.method="next",e.arg=c),!!y}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"),d=i.call(o,"finallyLoc");if(m&&d){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(d){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,E):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),E},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),J(r),E}},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;J(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:X(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),E}},n}(typeof re=="object"?re.exports:{});try{regeneratorRuntime=te}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=te:Function("r","regeneratorRuntime = r")(te)}});var u={};De(u,{Magic:()=>Be,useInternetConnection:()=>we});module.exports=ke(u);var Je=O(he()),be=require("@magic-sdk/provider"),Ue=O(require("process")),Se=O(require("localforage")),Y=require("whatwg-url"),K=require("buffer"),Ee=O(require("lodash")),Le=O(require("expo-application")),_e=require("@aveq-research/localforage-asyncstorage-driver"),ne=O(require("localforage-driver-memory"));var w=O(require("react")),j=require("react-native"),ve=require("react-native-webview"),me=require("react-native-safe-area-context"),U=require("@magic-sdk/provider"),de=require("lodash");var pe="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Te="open_in_device_browser",We="#FFFFFF";function je(){return j.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 W=class extends U.ViewController{constructor(){super(...arguments);this.Relayer=({backgroundColor:i})=>{let[h,c]=(0,w.useState)(!1),L=(0,w.useCallback)(b=>{this.webView=b},[]),p=(0,w.useCallback)(b=>{this.container=ee(Z({},b),{showOverlay:_,hideOverlay:g})},[]),_=(0,w.useCallback)(()=>{c(!0)},[]),g=(0,w.useCallback)(()=>{c(!1)},[]),v=(0,w.useMemo)(()=>[this.styles["webview-container"],h?ee(Z({},this.styles.show),{backgroundColor:i!=null?i:We}):this.styles.hide],[h]),V=(0,w.useCallback)(b=>{this.handleReactNativeWebViewMessage(b)},[]);return w.default.createElement(me.SafeAreaView,{ref:p,style:v},w.default.createElement(ve.WebView,{ref:L,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:V,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:b=>new URLSearchParams(b.url.split("?")[1]).get(Te)?(j.Linking.openURL(b.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,(L,p)=>{try{if(p&&typeof p=="object"&&p.flag&&p.flag===pe)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 L={data:c};for(let p of this.messageHandlers.values())p(L)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return T(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(h,c)=>(0,de.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:pe}:c),this.endpoint);else throw(0,U.createModalNotReadyError)()})}};var ye=require("@magic-sdk/provider"),B=class extends ye.SDKBase{get Relayer(){return this.overlay.Relayer}};l(u,require("@magic-sdk/commons"),module.exports);var F=require("react"),ge=O(require("@react-native-community/netinfo")),we=()=>{let[n,a]=(0,F.useState)(!0);return(0,F.useEffect)(()=>{let i=h=>{a(!!h.isConnected)};return ge.default.addEventListener(i)},[]),n};global.process=Ee.merge(global.process,Ue);global.process.browser=!1;global.Buffer=K.Buffer;global.URL=Y.URL;global.URLSearchParams=Y.URLSearchParams;global.btoa=n=>K.Buffer.from(n,"binary").toString("base64");global.atob=n=>K.Buffer.from(n,"base64").toString("binary");var Be=(0,be.createSDK)(B,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"22.2.2",bundleId:Le.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:W,configureStorage:()=>T(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(ne)]),yield n.setDriver([a._driver,ne._driver]),n})});0&&(module.exports={Magic,useInternetConnection});
1
+ "use strict";var Ie=Object.create;var M=Object.defineProperty,Ne=Object.defineProperties,Ae=Object.getOwnPropertyDescriptor,Me=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols,Ge=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var ue=(n,a,i)=>a in n?M(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,Z=(n,a)=>{for(var i in a||(a={}))le.call(a,i)&&ue(n,i,a[i]);if(fe)for(var i of fe(a))Pe.call(a,i)&&ue(n,i,a[i]);return n},ee=(n,a)=>Ne(n,Me(a));var Ce=(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})},k=(n,a,i,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Ve(a))!le.call(n,c)&&c!==i&&M(n,c,{get:()=>a[c],enumerable:!(h=Ae(a,c))||h.enumerable});return n},l=(n,a,i)=>(k(n,a,"default"),i&&k(i,a,"default")),O=(n,a,i)=>(i=n!=null?Ie(Ge(n)):{},k(a||!n||!n.__esModule?M(i,"default",{value:n,enumerable:!0}):i,n)),ke=n=>k(M({},"__esModule",{value:!0}),n);var T=(n,a,i)=>new Promise((h,c)=>{var L=g=>{try{_(i.next(g))}catch(v){c(v)}},p=g=>{try{_(i.throw(g))}catch(v){c(v)}},_=g=>g.done?h(g.value):Promise.resolve(g.value).then(L,p);_((i=i.apply(n,a)).next())});var he=Ce((Ye,re)=>{var te=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,h=Object.defineProperty||function(t,e,r){t[e]=r.value},c,L=typeof Symbol=="function"?Symbol:{},p=L.iterator||"@@iterator",_=L.asyncIterator||"@@asyncIterator",g=L.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 q?e:q,f=Object.create(o.prototype),m=new H(s||[]);return h(f,"_invoke",{value:Oe(t,r,m)}),f}n.wrap=V;function b(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(s){return{type:"throw",arg:s}}}var $="suspendedStart",oe="suspendedYield",ie="executing",G="completed",E={};function q(){}function P(){}function R(){}var x={};v(x,p,function(){return this});var z=Object.getPrototypeOf,C=z&&z(z(X([])));C&&C!==a&&i.call(C,p)&&(x=C);var N=R.prototype=q.prototype=Object.create(x);P.prototype=R,h(N,"constructor",{value:R,configurable:!0}),h(R,"constructor",{value:P,configurable:!0}),P.displayName=v(R,g,"GeneratorFunction");function ae(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,g,"GeneratorFunction")),t.prototype=Object.create(N),t},n.awrap=function(t){return{__await:t}};function D(t,e){function r(f,m,d,S){var y=b(t[f],t,m);if(y.type==="throw")S(y.arg);else{var Q=y.arg,A=Q.value;return A&&typeof A=="object"&&i.call(A,"__await")?e.resolve(A.__await).then(function(I){r("next",I,d,S)},function(I){r("throw",I,d,S)}):e.resolve(A).then(function(I){Q.value=I,d(Q)},function(I){return r("throw",I,d,S)})}}var s;function o(f,m){function d(){return new e(function(S,y){r(f,m,S,y)})}return s=s?s.then(d,d):d()}h(this,"_invoke",{value:o})}ae(D.prototype),v(D.prototype,_,function(){return this}),n.AsyncIterator=D,n.async=function(t,e,r,s,o){o===void 0&&(o=Promise);var f=new D(V(t,e,r,s),o);return n.isGeneratorFunction(e)?f:f.next().then(function(m){return m.done?m.value:f.next()})};function Oe(t,e,r){var s=$;return function(f,m){if(s===ie)throw new Error("Generator is already running");if(s===G){if(f==="throw")throw m;return ce()}for(r.method=f,r.arg=m;;){var d=r.delegate;if(d){var S=se(d,r);if(S){if(S===E)continue;return S}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(s===$)throw s=G,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=ie;var y=b(t,e,r);if(y.type==="normal"){if(s=r.done?G:oe,y.arg===E)continue;return{value:y.arg,done:r.done}}else y.type==="throw"&&(s=G,r.method="throw",r.arg=y.arg)}}}function se(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,se(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),E;var o=b(s,t.iterator,e.arg);if(o.type==="throw")return e.method="throw",e.arg=o.arg,e.delegate=null,E;var f=o.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,E;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,E}ae(N),v(N,g,"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 J(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function H(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 X(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:ce}}n.values=X;function ce(){return{value:c,done:!0}}return H.prototype={constructor:H,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(J),!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(S,y){return f.type="throw",f.arg=t,e.next=S,y&&(e.method="next",e.arg=c),!!y}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"),d=i.call(o,"finallyLoc");if(m&&d){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(d){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,E):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),E},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),J(r),E}},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;J(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:X(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),E}},n}(typeof re=="object"?re.exports:{});try{regeneratorRuntime=te}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=te:Function("r","regeneratorRuntime = r")(te)}});var u={};De(u,{Magic:()=>Be,useInternetConnection:()=>we});module.exports=ke(u);var Je=O(he()),be=require("@magic-sdk/provider"),Ue=O(require("process")),Se=O(require("localforage")),Y=require("whatwg-url"),K=require("buffer"),Ee=O(require("lodash")),Le=O(require("expo-application")),_e=require("@aveq-research/localforage-asyncstorage-driver"),ne=O(require("localforage-driver-memory"));var w=O(require("react")),j=require("react-native"),ve=require("react-native-webview"),me=require("react-native-safe-area-context"),U=require("@magic-sdk/provider"),de=require("lodash");var pe="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Te="open_in_device_browser",We="#FFFFFF";function je(){return j.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 W=class extends U.ViewController{constructor(){super(...arguments);this.Relayer=({backgroundColor:i})=>{let[h,c]=(0,w.useState)(!1),L=(0,w.useCallback)(b=>{this.webView=b},[]),p=(0,w.useCallback)(b=>{this.container=ee(Z({},b),{showOverlay:_,hideOverlay:g})},[]),_=(0,w.useCallback)(()=>{c(!0)},[]),g=(0,w.useCallback)(()=>{c(!1)},[]),v=(0,w.useMemo)(()=>[this.styles["webview-container"],h?ee(Z({},this.styles.show),{backgroundColor:i!=null?i:We}):this.styles.hide],[h]),V=(0,w.useCallback)(b=>{this.handleReactNativeWebViewMessage(b)},[]);return w.default.createElement(me.SafeAreaView,{ref:p,style:v},w.default.createElement(ve.WebView,{ref:L,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:V,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:b=>new URLSearchParams(b.url.split("?")[1]).get(Te)?(j.Linking.openURL(b.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,(L,p)=>{try{if(p&&typeof p=="object"&&p.flag&&p.flag===pe)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 L={data:c};for(let p of this.messageHandlers.values())p(L)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return T(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(h,c)=>(0,de.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:pe}:c),this.endpoint);else throw(0,U.createModalNotReadyError)()})}};var ye=require("@magic-sdk/provider"),B=class extends ye.SDKBase{get Relayer(){return this.overlay.Relayer}};l(u,require("@magic-sdk/commons"),module.exports);var F=require("react"),ge=O(require("@react-native-community/netinfo")),we=()=>{let[n,a]=(0,F.useState)(!0);return(0,F.useEffect)(()=>{let i=h=>{a(!!h.isConnected)};return ge.default.addEventListener(i)},[]),n};global.process=Ee.merge(global.process,Ue);global.process.browser=!1;global.Buffer=K.Buffer;global.URL=Y.URL;global.URLSearchParams=Y.URLSearchParams;global.btoa=n=>K.Buffer.from(n,"binary").toString("base64");global.atob=n=>K.Buffer.from(n,"base64").toString("binary");var Be=(0,be.createSDK)(B,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"22.3.0",bundleId:Le.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:W,configureStorage:()=>T(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(ne)]),yield n.setDriver([a._driver,ne._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 Y=Object.defineProperty,he=Object.defineProperties,pe=Object.getOwnPropertyDescriptor,ve=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,te=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var re=(o,s,i)=>s in o?Y(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,K=(o,s)=>{for(var i in s||(s={}))ne.call(s,i)&&re(o,i,s[i]);if(te)for(var i of te(s))ye.call(s,i)&&re(o,i,s[i]);return o},$=(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))!ne.call(o,c)&&c!==i&&Y(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?Y(i,"default",{value:o,enumerable:!0}):i,o));var G=(o,s,i)=>new Promise((u,c)=>{var b=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(b,l);S((i=i.apply(o,s)).next())});var oe=ge(($e,x)=>{var q=function(o){"use strict";var s=Object.prototype,i=s.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c,b=typeof Symbol=="function"?Symbol:{},l=b.iterator||"@@iterator",S=b.asyncIterator||"@@asyncIterator",d=b.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 I(t,e,r,a){var n=e&&e.prototype instanceof k?e:k,f=Object.create(n.prototype),p=new U(a||[]);return u(f,"_invoke",{value:fe(t,r,p)}),f}o.wrap=I;function y(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(a){return{type:"throw",arg:a}}}var D="suspendedStart",H="suspendedYield",X="executing",N="completed",w={};function k(){}function A(){}function E(){}var T={};h(T,l,function(){return this});var W=Object.getPrototypeOf,M=W&&W(W(B([])));M&&M!==s&&i.call(M,l)&&(T=M);var _=E.prototype=k.prototype=Object.create(T);A.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:A,configurable:!0}),A.displayName=h(E,d,"GeneratorFunction");function Q(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===A||(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,g){var m=y(t[f],t,p);if(m.type==="throw")g(m.arg);else{var F=m.arg,O=F.value;return O&&typeof O=="object"&&i.call(O,"__await")?e.resolve(O.__await).then(function(L){r("next",L,v,g)},function(L){r("throw",L,v,g)}):e.resolve(O).then(function(L){F.value=L,v(F)},function(L){return r("throw",L,v,g)})}}var a;function n(f,p){function v(){return new e(function(g,m){r(f,p,g,m)})}return a=a?a.then(v,v):v()}u(this,"_invoke",{value:n})}Q(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(I(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=D;return function(f,p){if(a===X)throw new Error("Generator is already running");if(a===N){if(f==="throw")throw p;return ee()}for(r.method=f,r.arg=p;;){var v=r.delegate;if(v){var g=Z(v,r);if(g){if(g===w)continue;return g}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(a===D)throw a=N,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=X;var m=y(t,e,r);if(m.type==="normal"){if(a=r.done?N:H,m.arg===w)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=N,r.method="throw",r.arg=m.arg)}}}function Z(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,Z(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),w;var n=y(a,t.iterator,e.arg);if(n.type==="throw")return e.method="throw",e.arg=n.arg,e.delegate=null,w;var f=n.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,w;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,w}Q(_),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 j(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 B(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:ee}}o.values=B;function ee(){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(j),!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(g,m){return f.type="throw",f.arg=t,e.next=g,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,w):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),w},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),j(r),w}},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;j(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:B(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),w}},o}(typeof x=="object"?x.exports:{});try{regeneratorRuntime=q}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=q:Function("r","regeneratorRuntime = r")(q)}});var at=be(oe());import{createSDK as We}from"@magic-sdk/provider";import*as je from"process";import Ue from"localforage";import{URL as Be,URLSearchParams as Fe}from"whatwg-url";import{Buffer as z}from"buffer";import*as se from"lodash";import*as ce from"expo-application";import{driverWithoutSerialization as Ye}from"@aveq-research/localforage-asyncstorage-driver";import*as J from"localforage-driver-memory";import ie,{useState as Se,useCallback as R,useMemo as Ee}from"react";import{Linking as Le,StyleSheet as _e}from"react-native";import{WebView as Oe}from"react-native-webview";import{SafeAreaView as Re}from"react-native-safe-area-context";import{ViewController as Ie,createModalNotReadyError as Ne}from"@magic-sdk/provider";import{isTypedArray as Ae}from"lodash";var ae="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Me="open_in_device_browser",Ve="#FFFFFF";function Ge(){return _e.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 Ie{constructor(){super(...arguments);this.Relayer=({backgroundColor:i})=>{let[u,c]=Se(!1),b=R(y=>{this.webView=y},[]),l=R(y=>{this.container=$(K({},y),{showOverlay:S,hideOverlay:d})},[]),S=R(()=>{c(!0)},[]),d=R(()=>{c(!1)},[]),h=Ee(()=>[this.styles["webview-container"],u?$(K({},this.styles.show),{backgroundColor:i!=null?i:Ve}):this.styles.hide],[u]),I=R(y=>{this.handleReactNativeWebViewMessage(y)},[]);return ie.createElement(Re,{ref:l,style:h},ie.createElement(Oe,{ref:b,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:I,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:y=>new URLSearchParams(y.url.split("?")[1]).get(Me)?(Le.openURL(y.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=Ge()}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,(b,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag===ae)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 b={data:c};for(let l of this.messageHandlers.values())l(b)}}}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)=>Ae(c)?{constructor:c.constructor.name,data:c.toString(),flag:ae}:c),this.endpoint);else throw Ne()})}};import{SDKBase as Pe}from"@magic-sdk/provider";var C=class extends Pe{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";import{useEffect as Ce,useState as De}from"react";import ke from"@react-native-community/netinfo";var Te=()=>{let[o,s]=De(!0);return Ce(()=>{let i=u=>{s(!!u.isConnected)};return ke.addEventListener(i)},[]),o};global.process=se.merge(global.process,je);global.process.browser=!1;global.Buffer=z;global.URL=Be;global.URLSearchParams=Fe;global.btoa=o=>z.from(o,"binary").toString("base64");global.atob=o=>z.from(o,"base64").toString("binary");var dt=We(C,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"22.2.2",bundleId:ce.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:P,configureStorage:()=>G(void 0,null,function*(){let o=Ue.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Ye();return yield Promise.all([o.defineDriver(s),o.defineDriver(J)]),yield o.setDriver([s._driver,J._driver]),o})});export{dt as Magic,Te as useInternetConnection};
1
+ var le=Object.create;var Y=Object.defineProperty,he=Object.defineProperties,pe=Object.getOwnPropertyDescriptor,ve=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertyNames,te=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var re=(o,s,i)=>s in o?Y(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,K=(o,s)=>{for(var i in s||(s={}))ne.call(s,i)&&re(o,i,s[i]);if(te)for(var i of te(s))ye.call(s,i)&&re(o,i,s[i]);return o},$=(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))!ne.call(o,c)&&c!==i&&Y(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?Y(i,"default",{value:o,enumerable:!0}):i,o));var G=(o,s,i)=>new Promise((u,c)=>{var b=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(b,l);S((i=i.apply(o,s)).next())});var oe=ge(($e,x)=>{var q=function(o){"use strict";var s=Object.prototype,i=s.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c,b=typeof Symbol=="function"?Symbol:{},l=b.iterator||"@@iterator",S=b.asyncIterator||"@@asyncIterator",d=b.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 I(t,e,r,a){var n=e&&e.prototype instanceof k?e:k,f=Object.create(n.prototype),p=new U(a||[]);return u(f,"_invoke",{value:fe(t,r,p)}),f}o.wrap=I;function y(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(a){return{type:"throw",arg:a}}}var D="suspendedStart",H="suspendedYield",X="executing",N="completed",w={};function k(){}function A(){}function E(){}var T={};h(T,l,function(){return this});var W=Object.getPrototypeOf,M=W&&W(W(B([])));M&&M!==s&&i.call(M,l)&&(T=M);var _=E.prototype=k.prototype=Object.create(T);A.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:A,configurable:!0}),A.displayName=h(E,d,"GeneratorFunction");function Q(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===A||(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,g){var m=y(t[f],t,p);if(m.type==="throw")g(m.arg);else{var F=m.arg,O=F.value;return O&&typeof O=="object"&&i.call(O,"__await")?e.resolve(O.__await).then(function(L){r("next",L,v,g)},function(L){r("throw",L,v,g)}):e.resolve(O).then(function(L){F.value=L,v(F)},function(L){return r("throw",L,v,g)})}}var a;function n(f,p){function v(){return new e(function(g,m){r(f,p,g,m)})}return a=a?a.then(v,v):v()}u(this,"_invoke",{value:n})}Q(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(I(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=D;return function(f,p){if(a===X)throw new Error("Generator is already running");if(a===N){if(f==="throw")throw p;return ee()}for(r.method=f,r.arg=p;;){var v=r.delegate;if(v){var g=Z(v,r);if(g){if(g===w)continue;return g}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(a===D)throw a=N,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=X;var m=y(t,e,r);if(m.type==="normal"){if(a=r.done?N:H,m.arg===w)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=N,r.method="throw",r.arg=m.arg)}}}function Z(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,Z(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),w;var n=y(a,t.iterator,e.arg);if(n.type==="throw")return e.method="throw",e.arg=n.arg,e.delegate=null,w;var f=n.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,w;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,w}Q(_),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 j(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 B(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:ee}}o.values=B;function ee(){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(j),!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(g,m){return f.type="throw",f.arg=t,e.next=g,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,w):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),w},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),j(r),w}},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;j(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:B(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),w}},o}(typeof x=="object"?x.exports:{});try{regeneratorRuntime=q}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=q:Function("r","regeneratorRuntime = r")(q)}});var at=be(oe());import{createSDK as We}from"@magic-sdk/provider";import*as je from"process";import Ue from"localforage";import{URL as Be,URLSearchParams as Fe}from"whatwg-url";import{Buffer as z}from"buffer";import*as se from"lodash";import*as ce from"expo-application";import{driverWithoutSerialization as Ye}from"@aveq-research/localforage-asyncstorage-driver";import*as J from"localforage-driver-memory";import ie,{useState as Se,useCallback as R,useMemo as Ee}from"react";import{Linking as Le,StyleSheet as _e}from"react-native";import{WebView as Oe}from"react-native-webview";import{SafeAreaView as Re}from"react-native-safe-area-context";import{ViewController as Ie,createModalNotReadyError as Ne}from"@magic-sdk/provider";import{isTypedArray as Ae}from"lodash";var ae="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Me="open_in_device_browser",Ve="#FFFFFF";function Ge(){return _e.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 Ie{constructor(){super(...arguments);this.Relayer=({backgroundColor:i})=>{let[u,c]=Se(!1),b=R(y=>{this.webView=y},[]),l=R(y=>{this.container=$(K({},y),{showOverlay:S,hideOverlay:d})},[]),S=R(()=>{c(!0)},[]),d=R(()=>{c(!1)},[]),h=Ee(()=>[this.styles["webview-container"],u?$(K({},this.styles.show),{backgroundColor:i!=null?i:Ve}):this.styles.hide],[u]),I=R(y=>{this.handleReactNativeWebViewMessage(y)},[]);return ie.createElement(Re,{ref:l,style:h},ie.createElement(Oe,{ref:b,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:I,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1,webviewDebuggingEnabled:!0,onShouldStartLoadWithRequest:y=>new URLSearchParams(y.url.split("?")[1]).get(Me)?(Le.openURL(y.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=Ge()}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,(b,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag===ae)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 b={data:c};for(let l of this.messageHandlers.values())l(b)}}}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)=>Ae(c)?{constructor:c.constructor.name,data:c.toString(),flag:ae}:c),this.endpoint);else throw Ne()})}};import{SDKBase as Pe}from"@magic-sdk/provider";var C=class extends Pe{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";import{useEffect as Ce,useState as De}from"react";import ke from"@react-native-community/netinfo";var Te=()=>{let[o,s]=De(!0);return Ce(()=>{let i=u=>{s(!!u.isConnected)};return ke.addEventListener(i)},[]),o};global.process=se.merge(global.process,je);global.process.browser=!1;global.Buffer=z;global.URL=Be;global.URLSearchParams=Fe;global.btoa=o=>z.from(o,"binary").toString("base64");global.atob=o=>z.from(o,"base64").toString("binary");var dt=We(C,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"22.3.0",bundleId:ce.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:P,configureStorage:()=>G(void 0,null,function*(){let o=Ue.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Ye();return yield Promise.all([o.defineDriver(s),o.defineDriver(J)]),yield o.setDriver([s._driver,J._driver]),o})});export{dt as Magic,Te as useInternetConnection};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magic-sdk/react-native-expo",
3
- "version": "22.3.0-canary.665.6934462457.0",
3
+ "version": "22.3.0",
4
4
  "description": "Passwordless authentication for React Native (Expo).",
5
5
  "author": "Magic Labs <team@magic.link> (https://magic.link/)",
6
6
  "license": "MIT",
@@ -18,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.0-canary.665.6934462457.0",
22
- "@magic-sdk/provider": "21.3.0-canary.665.6934462457.0",
21
+ "@magic-sdk/commons": "^17.3.0",
22
+ "@magic-sdk/provider": "^21.3.0",
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",
@@ -54,5 +54,5 @@
54
54
  "react-native-safe-area-context": ">=4.4.1",
55
55
  "react-native-webview": ">=12.4.0"
56
56
  },
57
- "gitHead": "d60013e2446cda47f0d96239cf09fc6a128782a3"
57
+ "gitHead": "d67fd2c32dfc647e5fd01cfbb682f1a5f47bd0d6"
58
58
  }