@magic-sdk/react-native-bare 18.1.0 → 18.1.1

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,15 @@
1
+ # v18.1.1 (Fri Apr 21 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Merge remote-tracking branch 'origin/master' into jerryliu-sc-75641-lazer-request-showsettings-page-mfa ([@Ethella](https://github.com/Ethella))
6
+
7
+ #### Authors: 1
8
+
9
+ - Jerry Liu ([@Ethella](https://github.com/Ethella))
10
+
11
+ ---
12
+
1
13
  # v18.1.0 (Thu Apr 20 2023)
2
14
 
3
15
  #### 🐛 Bug Fix
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Le=Object.create;var V=Object.defineProperty,_e=Object.defineProperties,Oe=Object.getOwnPropertyDescriptor,Ae=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertyNames,oe=Object.getOwnPropertySymbols,Me=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var ie=(n,a,i)=>a in n?V(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,se=(n,a)=>{for(var i in a||(a={}))ae.call(a,i)&&ie(n,i,a[i]);if(oe)for(var i of oe(a))Ge.call(a,i)&&ie(n,i,a[i]);return n},ce=(n,a)=>_e(n,Ae(a));var Ve=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports),Ne=(n,a)=>{for(var i in a)V(n,i,{get:a[i],enumerable:!0})},D=(n,a,i,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Re(a))!ae.call(n,c)&&c!==i&&V(n,c,{get:()=>a[c],enumerable:!(p=Oe(a,c))||p.enumerable});return n},u=(n,a,i)=>(D(n,a,"default"),i&&D(i,a,"default")),M=(n,a,i)=>(i=n!=null?Le(Me(n)):{},D(a||!n||!n.__esModule?V(i,"default",{value:n,enumerable:!0}):i,n)),ke=n=>D(V({},"__esModule",{value:!0}),n);var T=(n,a,i)=>new Promise((p,c)=>{var E=g=>{try{L(i.next(g))}catch(v){c(v)}},h=g=>{try{L(i.throw(g))}catch(v){c(v)}},L=g=>g.done?p(g.value):Promise.resolve(g.value).then(E,h);L((i=i.apply(n,a)).next())});var fe=Ve((We,Q)=>{var x=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,p=Object.defineProperty||function(t,e,r){t[e]=r.value},c,E=typeof Symbol=="function"?Symbol:{},h=E.iterator||"@@iterator",L=E.asyncIterator||"@@asyncIterator",g=E.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 _(t,e,r,s){var o=e&&e.prototype instanceof $?e:$,f=Object.create(o.prototype),m=new J(s||[]);return p(f,"_invoke",{value:Se(t,r,m)}),f}n.wrap=_;function U(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(s){return{type:"throw",arg:s}}}var Z="suspendedStart",be="suspendedYield",ee="executing",N="completed",S={};function $(){}function k(){}function O(){}var K={};v(K,h,function(){return this});var z=Object.getPrototypeOf,P=z&&z(z(H([])));P&&P!==a&&i.call(P,h)&&(K=P);var R=O.prototype=$.prototype=Object.create(K);k.prototype=O,p(R,"constructor",{value:O,configurable:!0}),p(O,"constructor",{value:k,configurable:!0}),k.displayName=v(O,g,"GeneratorFunction");function te(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===k||(e.displayName||e.name)==="GeneratorFunction":!1},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,O):(t.__proto__=O,v(t,g,"GeneratorFunction")),t.prototype=Object.create(R),t},n.awrap=function(t){return{__await:t}};function I(t,e){function r(f,m,d,b){var y=U(t[f],t,m);if(y.type==="throw")b(y.arg);else{var q=y.arg,G=q.value;return G&&typeof G=="object"&&i.call(G,"__await")?e.resolve(G.__await).then(function(A){r("next",A,d,b)},function(A){r("throw",A,d,b)}):e.resolve(G).then(function(A){q.value=A,d(q)},function(A){return r("throw",A,d,b)})}}var s;function o(f,m){function d(){return new e(function(b,y){r(f,m,b,y)})}return s=s?s.then(d,d):d()}p(this,"_invoke",{value:o})}te(I.prototype),v(I.prototype,L,function(){return this}),n.AsyncIterator=I,n.async=function(t,e,r,s,o){o===void 0&&(o=Promise);var f=new I(_(t,e,r,s),o);return n.isGeneratorFunction(e)?f:f.next().then(function(m){return m.done?m.value:f.next()})};function Se(t,e,r){var s=Z;return function(f,m){if(s===ee)throw new Error("Generator is already running");if(s===N){if(f==="throw")throw m;return ne()}for(r.method=f,r.arg=m;;){var d=r.delegate;if(d){var b=re(d,r);if(b){if(b===S)continue;return b}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(s===Z)throw s=N,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=ee;var y=U(t,e,r);if(y.type==="normal"){if(s=r.done?N:be,y.arg===S)continue;return{value:y.arg,done:r.done}}else y.type==="throw"&&(s=N,r.method="throw",r.arg=y.arg)}}}function re(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,re(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),S;var o=U(s,t.iterator,e.arg);if(o.type==="throw")return e.method="throw",e.arg=o.arg,e.delegate=null,S;var f=o.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,S;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,S}te(R),v(R,g,"Generator"),v(R,h,function(){return this}),v(R,"toString",function(){return"[object Generator]"});function Ee(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 F(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function J(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(Ee,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 H(t){if(t){var e=t[h];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:ne}}n.values=H;function ne(){return{value:c,done:!0}}return J.prototype={constructor:J,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(F),!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,y){return f.type="throw",f.arg=t,e.next=b,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,S):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),S},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),F(r),S}},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;F(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:H(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),S}},n}(typeof Q=="object"?Q.exports:{});try{regeneratorRuntime=x}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=x:Function("r","regeneratorRuntime = r")(x)}});var l={};Ne(l,{Magic:()=>Te});module.exports=ke(l);var Ue=M(fe()),me=require("@magic-sdk/provider"),De=M(require("process")),de=M(require("localforage")),Y=require("whatwg-url"),B=require("buffer"),ye=M(require("lodash")),ge=require("react-native-device-info"),we=require("@aveq-research/localforage-asyncstorage-driver"),X=M(require("localforage-driver-memory"));var w=M(require("react")),le=require("react-native"),ue=require("react-native-webview"),he=require("react-native-safe-area-context"),W=require("@magic-sdk/provider"),pe=require("lodash");var Pe="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function Ie(){return le.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 C=class extends W.ViewController{constructor(){super(...arguments);this.Relayer=()=>{let[i,p]=(0,w.useState)(!1),c=(0,w.useCallback)(_=>{this.webView=_},[]),E=(0,w.useCallback)(_=>{this.container=ce(se({},_),{showOverlay:h,hideOverlay:L})},[]),h=(0,w.useCallback)(()=>{p(!0)},[]),L=(0,w.useCallback)(()=>{p(!1)},[]),g=(0,w.useMemo)(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),v=(0,w.useCallback)(_=>{this.handleReactNativeWebViewMessage(_)},[]);return w.default.createElement(he.SafeAreaView,{ref:E,style:g},w.default.createElement(ue.WebView,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:v,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1}))}}init(){this.webView=null,this.container=null,this.styles=Ie()}handleReactNativeWebViewMessage(i){var p;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,(E,h)=>{try{if(h&&typeof h=="object"&&h.flag&&h.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return new global[h.constructor](h.data.split(","))}catch(L){}return h});if(c&&c.msgType&&this.messageHandlers.size){c.response=(p=c.response)!=null?p:{};let E={data:c};for(let h of this.messageHandlers.values())h(E)}}}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,(p,c)=>(0,pe.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:Pe}:c),this.endpoint);else throw(0,W.createModalNotReadyError)()})}};var ve=require("@magic-sdk/provider"),j=class extends ve.SDKBase{get Relayer(){return this.overlay.Relayer}};u(l,require("@magic-sdk/commons"),module.exports);global.process=ye.merge(global.process,De);global.process.browser=!1;global.Buffer=B.Buffer;global.URL=Y.URL;global.URLSearchParams=Y.URLSearchParams;global.btoa=n=>B.Buffer.from(n,"binary").toString("base64");global.atob=n=>B.Buffer.from(n,"base64").toString("binary");var Te=(0,me.createSDK)(j,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"18.1.0",bundleId:(0,ge.getBundleId)(),defaultEndpoint:"https://box.magic.link/",ViewController:C,configureStorage:()=>T(void 0,null,function*(){let n=de.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),a=(0,we.driverWithoutSerialization)();return yield Promise.all([n.defineDriver(a),n.defineDriver(X)]),yield n.setDriver([a._driver,X._driver]),n})});0&&(module.exports={Magic});
1
+ "use strict";var Le=Object.create;var V=Object.defineProperty,_e=Object.defineProperties,Oe=Object.getOwnPropertyDescriptor,Ae=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertyNames,oe=Object.getOwnPropertySymbols,Me=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var ie=(n,a,i)=>a in n?V(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,se=(n,a)=>{for(var i in a||(a={}))ae.call(a,i)&&ie(n,i,a[i]);if(oe)for(var i of oe(a))Ge.call(a,i)&&ie(n,i,a[i]);return n},ce=(n,a)=>_e(n,Ae(a));var Ve=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports),Ne=(n,a)=>{for(var i in a)V(n,i,{get:a[i],enumerable:!0})},D=(n,a,i,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Re(a))!ae.call(n,c)&&c!==i&&V(n,c,{get:()=>a[c],enumerable:!(p=Oe(a,c))||p.enumerable});return n},u=(n,a,i)=>(D(n,a,"default"),i&&D(i,a,"default")),M=(n,a,i)=>(i=n!=null?Le(Me(n)):{},D(a||!n||!n.__esModule?V(i,"default",{value:n,enumerable:!0}):i,n)),ke=n=>D(V({},"__esModule",{value:!0}),n);var T=(n,a,i)=>new Promise((p,c)=>{var E=g=>{try{L(i.next(g))}catch(v){c(v)}},h=g=>{try{L(i.throw(g))}catch(v){c(v)}},L=g=>g.done?p(g.value):Promise.resolve(g.value).then(E,h);L((i=i.apply(n,a)).next())});var fe=Ve((We,Q)=>{var x=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,p=Object.defineProperty||function(t,e,r){t[e]=r.value},c,E=typeof Symbol=="function"?Symbol:{},h=E.iterator||"@@iterator",L=E.asyncIterator||"@@asyncIterator",g=E.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 _(t,e,r,s){var o=e&&e.prototype instanceof $?e:$,f=Object.create(o.prototype),m=new J(s||[]);return p(f,"_invoke",{value:Se(t,r,m)}),f}n.wrap=_;function U(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(s){return{type:"throw",arg:s}}}var Z="suspendedStart",be="suspendedYield",ee="executing",N="completed",S={};function $(){}function k(){}function O(){}var K={};v(K,h,function(){return this});var z=Object.getPrototypeOf,P=z&&z(z(H([])));P&&P!==a&&i.call(P,h)&&(K=P);var R=O.prototype=$.prototype=Object.create(K);k.prototype=O,p(R,"constructor",{value:O,configurable:!0}),p(O,"constructor",{value:k,configurable:!0}),k.displayName=v(O,g,"GeneratorFunction");function te(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===k||(e.displayName||e.name)==="GeneratorFunction":!1},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,O):(t.__proto__=O,v(t,g,"GeneratorFunction")),t.prototype=Object.create(R),t},n.awrap=function(t){return{__await:t}};function I(t,e){function r(f,m,d,b){var y=U(t[f],t,m);if(y.type==="throw")b(y.arg);else{var q=y.arg,G=q.value;return G&&typeof G=="object"&&i.call(G,"__await")?e.resolve(G.__await).then(function(A){r("next",A,d,b)},function(A){r("throw",A,d,b)}):e.resolve(G).then(function(A){q.value=A,d(q)},function(A){return r("throw",A,d,b)})}}var s;function o(f,m){function d(){return new e(function(b,y){r(f,m,b,y)})}return s=s?s.then(d,d):d()}p(this,"_invoke",{value:o})}te(I.prototype),v(I.prototype,L,function(){return this}),n.AsyncIterator=I,n.async=function(t,e,r,s,o){o===void 0&&(o=Promise);var f=new I(_(t,e,r,s),o);return n.isGeneratorFunction(e)?f:f.next().then(function(m){return m.done?m.value:f.next()})};function Se(t,e,r){var s=Z;return function(f,m){if(s===ee)throw new Error("Generator is already running");if(s===N){if(f==="throw")throw m;return ne()}for(r.method=f,r.arg=m;;){var d=r.delegate;if(d){var b=re(d,r);if(b){if(b===S)continue;return b}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(s===Z)throw s=N,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=ee;var y=U(t,e,r);if(y.type==="normal"){if(s=r.done?N:be,y.arg===S)continue;return{value:y.arg,done:r.done}}else y.type==="throw"&&(s=N,r.method="throw",r.arg=y.arg)}}}function re(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,re(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),S;var o=U(s,t.iterator,e.arg);if(o.type==="throw")return e.method="throw",e.arg=o.arg,e.delegate=null,S;var f=o.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,S;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,S}te(R),v(R,g,"Generator"),v(R,h,function(){return this}),v(R,"toString",function(){return"[object Generator]"});function Ee(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 F(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function J(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(Ee,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 H(t){if(t){var e=t[h];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:ne}}n.values=H;function ne(){return{value:c,done:!0}}return J.prototype={constructor:J,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(F),!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,y){return f.type="throw",f.arg=t,e.next=b,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,S):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),S},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),F(r),S}},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;F(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:H(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),S}},n}(typeof Q=="object"?Q.exports:{});try{regeneratorRuntime=x}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=x:Function("r","regeneratorRuntime = r")(x)}});var l={};Ne(l,{Magic:()=>Te});module.exports=ke(l);var Ue=M(fe()),me=require("@magic-sdk/provider"),De=M(require("process")),de=M(require("localforage")),Y=require("whatwg-url"),B=require("buffer"),ye=M(require("lodash")),ge=require("react-native-device-info"),we=require("@aveq-research/localforage-asyncstorage-driver"),X=M(require("localforage-driver-memory"));var w=M(require("react")),le=require("react-native"),ue=require("react-native-webview"),he=require("react-native-safe-area-context"),W=require("@magic-sdk/provider"),pe=require("lodash");var Pe="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function Ie(){return le.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 C=class extends W.ViewController{constructor(){super(...arguments);this.Relayer=()=>{let[i,p]=(0,w.useState)(!1),c=(0,w.useCallback)(_=>{this.webView=_},[]),E=(0,w.useCallback)(_=>{this.container=ce(se({},_),{showOverlay:h,hideOverlay:L})},[]),h=(0,w.useCallback)(()=>{p(!0)},[]),L=(0,w.useCallback)(()=>{p(!1)},[]),g=(0,w.useMemo)(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),v=(0,w.useCallback)(_=>{this.handleReactNativeWebViewMessage(_)},[]);return w.default.createElement(he.SafeAreaView,{ref:E,style:g},w.default.createElement(ue.WebView,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:v,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1}))}}init(){this.webView=null,this.container=null,this.styles=Ie()}handleReactNativeWebViewMessage(i){var p;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,(E,h)=>{try{if(h&&typeof h=="object"&&h.flag&&h.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return new global[h.constructor](h.data.split(","))}catch(L){}return h});if(c&&c.msgType&&this.messageHandlers.size){c.response=(p=c.response)!=null?p:{};let E={data:c};for(let h of this.messageHandlers.values())h(E)}}}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,(p,c)=>(0,pe.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:Pe}:c),this.endpoint);else throw(0,W.createModalNotReadyError)()})}};var ve=require("@magic-sdk/provider"),j=class extends ve.SDKBase{get Relayer(){return this.overlay.Relayer}};u(l,require("@magic-sdk/commons"),module.exports);global.process=ye.merge(global.process,De);global.process.browser=!1;global.Buffer=B.Buffer;global.URL=Y.URL;global.URLSearchParams=Y.URLSearchParams;global.btoa=n=>B.Buffer.from(n,"binary").toString("base64");global.atob=n=>B.Buffer.from(n,"base64").toString("binary");var Te=(0,me.createSDK)(j,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"18.1.1",bundleId:(0,ge.getBundleId)(),defaultEndpoint:"https://box.magic.link/",ViewController:C,configureStorage:()=>T(void 0,null,function*(){let n=de.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),a=(0,we.driverWithoutSerialization)();return yield Promise.all([n.defineDriver(a),n.defineDriver(X)]),yield n.setDriver([a._driver,X._driver]),n})});0&&(module.exports={Magic});
2
2
  //# sourceMappingURL=index.js.map
package/dist/es/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var fe=Object.create;var U=Object.defineProperty,le=Object.defineProperties,ue=Object.getOwnPropertyDescriptor,he=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols,ve=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var Z=(o,s,i)=>s in o?U(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,te=(o,s)=>{for(var i in s||(s={}))ee.call(s,i)&&Z(o,i,s[i]);if(X)for(var i of X(s))me.call(s,i)&&Z(o,i,s[i]);return o},re=(o,s)=>le(o,he(s));var de=(o,s)=>()=>(s||o((s={exports:{}}).exports,s),s.exports);var ye=(o,s,i,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of pe(s))!ee.call(o,c)&&c!==i&&U(o,c,{get:()=>s[c],enumerable:!(u=ue(s,c))||u.enumerable});return o};var ge=(o,s,i)=>(i=o!=null?fe(ve(o)):{},ye(s||!o||!o.__esModule?U(i,"default",{value:o,enumerable:!0}):i,o));var N=(o,s,i)=>new Promise((u,c)=>{var w=d=>{try{b(i.next(d))}catch(h){c(h)}},l=d=>{try{b(i.throw(d))}catch(h){c(h)}},b=d=>d.done?u(d.value):Promise.resolve(d.value).then(w,l);b((i=i.apply(o,s)).next())});var ne=de((We,K)=>{var $=function(o){"use strict";var s=Object.prototype,i=s.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c,w=typeof Symbol=="function"?Symbol:{},l=w.iterator||"@@iterator",b=w.asyncIterator||"@@asyncIterator",d=w.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 S(t,e,r,a){var n=e&&e.prototype instanceof D?e:D,f=Object.create(n.prototype),p=new j(a||[]);return u(f,"_invoke",{value:se(t,r,p)}),f}o.wrap=S;function I(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(a){return{type:"throw",arg:a}}}var J="suspendedStart",ae="suspendedYield",H="executing",R="completed",g={};function D(){}function M(){}function E(){}var T={};h(T,l,function(){return this});var C=Object.getPrototypeOf,G=C&&C(C(Y([])));G&&G!==s&&i.call(G,l)&&(T=G);var _=E.prototype=D.prototype=Object.create(T);M.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:M,configurable:!0}),M.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===M||(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=I(t[f],t,p);if(m.type==="throw")y(m.arg);else{var B=m.arg,O=B.value;return O&&typeof O=="object"&&i.call(O,"__await")?e.resolve(O.__await).then(function(L){r("next",L,v,y)},function(L){r("throw",L,v,y)}):e.resolve(O).then(function(L){B.value=L,v(B)},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})}q(V.prototype),h(V.prototype,b,function(){return this}),o.AsyncIterator=V,o.async=function(t,e,r,a,n){n===void 0&&(n=Promise);var f=new V(S(t,e,r,a),n);return o.isGeneratorFunction(e)?f:f.next().then(function(p){return p.done?p.value:f.next()})};function se(t,e,r){var a=J;return function(f,p){if(a===H)throw new Error("Generator is already running");if(a===R){if(f==="throw")throw p;return Q()}for(r.method=f,r.arg=p;;){var v=r.delegate;if(v){var y=x(v,r);if(y){if(y===g)continue;return y}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(a===J)throw a=R,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=H;var m=I(t,e,r);if(m.type==="normal"){if(a=r.done?R:ae,m.arg===g)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=R,r.method="throw",r.arg=m.arg)}}}function x(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,x(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var n=I(a,t.iterator,e.arg);if(n.type==="throw")return e.method="throw",e.arg=n.arg,e.delegate=null,g;var f=n.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g;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,g}q(_),h(_,d,"Generator"),h(_,l,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function ce(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 W(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(ce,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 Y(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:Q}}o.values=Y;function Q(){return{value:c,done:!0}}return j.prototype={constructor:j,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(W),!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,g):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),g},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),W(r),g}},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;W(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:Y(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),g}},o}(typeof K=="object"?K.exports:{});try{regeneratorRuntime=$}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=$:Function("r","regeneratorRuntime = r")($)}});var qe=ge(ne());import{createSDK as Ve}from"@magic-sdk/provider";import*as Ne from"process";import ke from"localforage";import{URL as Pe,URLSearchParams as Ie}from"whatwg-url";import{Buffer as z}from"buffer";import*as ie from"lodash";import{getBundleId as De}from"react-native-device-info";import{driverWithoutSerialization as Te}from"@aveq-research/localforage-asyncstorage-driver";import*as F from"localforage-driver-memory";import oe,{useState as we,useCallback as A,useMemo as be}from"react";import{StyleSheet as Se}from"react-native";import{WebView as Ee}from"react-native-webview";import{SafeAreaView as Le}from"react-native-safe-area-context";import{ViewController as _e,createModalNotReadyError as Oe}from"@magic-sdk/provider";import{isTypedArray as Ae}from"lodash";var Re="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function Me(){return Se.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 k=class extends _e{constructor(){super(...arguments);this.Relayer=()=>{let[i,u]=we(!1),c=A(S=>{this.webView=S},[]),w=A(S=>{this.container=re(te({},S),{showOverlay:l,hideOverlay:b})},[]),l=A(()=>{u(!0)},[]),b=A(()=>{u(!1)},[]),d=be(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),h=A(S=>{this.handleReactNativeWebViewMessage(S)},[]);return oe.createElement(Le,{ref:w,style:d},oe.createElement(Ee,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:h,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1}))}}init(){this.webView=null,this.container=null,this.styles=Me()}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,(w,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return new global[l.constructor](l.data.split(","))}catch(b){}return l});if(c&&c.msgType&&this.messageHandlers.size){c.response=(u=c.response)!=null?u:{};let w={data:c};for(let l of this.messageHandlers.values())l(w)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return N(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:Re}:c),this.endpoint);else throw Oe()})}};import{SDKBase as Ge}from"@magic-sdk/provider";var P=class extends Ge{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=ie.merge(global.process,Ne);global.process.browser=!1;global.Buffer=z;global.URL=Pe;global.URLSearchParams=Ie;global.btoa=o=>z.from(o,"binary").toString("base64");global.atob=o=>z.from(o,"base64").toString("binary");var at=Ve(P,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"18.1.0",bundleId:De(),defaultEndpoint:"https://box.magic.link/",ViewController:k,configureStorage:()=>N(void 0,null,function*(){let o=ke.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Te();return yield Promise.all([o.defineDriver(s),o.defineDriver(F)]),yield o.setDriver([s._driver,F._driver]),o})});export{at as Magic};
1
+ var fe=Object.create;var U=Object.defineProperty,le=Object.defineProperties,ue=Object.getOwnPropertyDescriptor,he=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols,ve=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var Z=(o,s,i)=>s in o?U(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,te=(o,s)=>{for(var i in s||(s={}))ee.call(s,i)&&Z(o,i,s[i]);if(X)for(var i of X(s))me.call(s,i)&&Z(o,i,s[i]);return o},re=(o,s)=>le(o,he(s));var de=(o,s)=>()=>(s||o((s={exports:{}}).exports,s),s.exports);var ye=(o,s,i,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of pe(s))!ee.call(o,c)&&c!==i&&U(o,c,{get:()=>s[c],enumerable:!(u=ue(s,c))||u.enumerable});return o};var ge=(o,s,i)=>(i=o!=null?fe(ve(o)):{},ye(s||!o||!o.__esModule?U(i,"default",{value:o,enumerable:!0}):i,o));var N=(o,s,i)=>new Promise((u,c)=>{var w=d=>{try{b(i.next(d))}catch(h){c(h)}},l=d=>{try{b(i.throw(d))}catch(h){c(h)}},b=d=>d.done?u(d.value):Promise.resolve(d.value).then(w,l);b((i=i.apply(o,s)).next())});var ne=de((We,K)=>{var $=function(o){"use strict";var s=Object.prototype,i=s.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},c,w=typeof Symbol=="function"?Symbol:{},l=w.iterator||"@@iterator",b=w.asyncIterator||"@@asyncIterator",d=w.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 S(t,e,r,a){var n=e&&e.prototype instanceof D?e:D,f=Object.create(n.prototype),p=new j(a||[]);return u(f,"_invoke",{value:se(t,r,p)}),f}o.wrap=S;function I(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(a){return{type:"throw",arg:a}}}var J="suspendedStart",ae="suspendedYield",H="executing",R="completed",g={};function D(){}function M(){}function E(){}var T={};h(T,l,function(){return this});var C=Object.getPrototypeOf,G=C&&C(C(Y([])));G&&G!==s&&i.call(G,l)&&(T=G);var _=E.prototype=D.prototype=Object.create(T);M.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:M,configurable:!0}),M.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===M||(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=I(t[f],t,p);if(m.type==="throw")y(m.arg);else{var B=m.arg,O=B.value;return O&&typeof O=="object"&&i.call(O,"__await")?e.resolve(O.__await).then(function(L){r("next",L,v,y)},function(L){r("throw",L,v,y)}):e.resolve(O).then(function(L){B.value=L,v(B)},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})}q(V.prototype),h(V.prototype,b,function(){return this}),o.AsyncIterator=V,o.async=function(t,e,r,a,n){n===void 0&&(n=Promise);var f=new V(S(t,e,r,a),n);return o.isGeneratorFunction(e)?f:f.next().then(function(p){return p.done?p.value:f.next()})};function se(t,e,r){var a=J;return function(f,p){if(a===H)throw new Error("Generator is already running");if(a===R){if(f==="throw")throw p;return Q()}for(r.method=f,r.arg=p;;){var v=r.delegate;if(v){var y=x(v,r);if(y){if(y===g)continue;return y}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(a===J)throw a=R,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=H;var m=I(t,e,r);if(m.type==="normal"){if(a=r.done?R:ae,m.arg===g)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=R,r.method="throw",r.arg=m.arg)}}}function x(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,x(t,e),e.method==="throw")||r!=="return"&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var n=I(a,t.iterator,e.arg);if(n.type==="throw")return e.method="throw",e.arg=n.arg,e.delegate=null,g;var f=n.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g;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,g}q(_),h(_,d,"Generator"),h(_,l,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function ce(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 W(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(ce,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 Y(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:Q}}o.values=Y;function Q(){return{value:c,done:!0}}return j.prototype={constructor:j,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(W),!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,g):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),g},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),W(r),g}},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;W(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:Y(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),g}},o}(typeof K=="object"?K.exports:{});try{regeneratorRuntime=$}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=$:Function("r","regeneratorRuntime = r")($)}});var qe=ge(ne());import{createSDK as Ve}from"@magic-sdk/provider";import*as Ne from"process";import ke from"localforage";import{URL as Pe,URLSearchParams as Ie}from"whatwg-url";import{Buffer as z}from"buffer";import*as ie from"lodash";import{getBundleId as De}from"react-native-device-info";import{driverWithoutSerialization as Te}from"@aveq-research/localforage-asyncstorage-driver";import*as F from"localforage-driver-memory";import oe,{useState as we,useCallback as A,useMemo as be}from"react";import{StyleSheet as Se}from"react-native";import{WebView as Ee}from"react-native-webview";import{SafeAreaView as Le}from"react-native-safe-area-context";import{ViewController as _e,createModalNotReadyError as Oe}from"@magic-sdk/provider";import{isTypedArray as Ae}from"lodash";var Re="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function Me(){return Se.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 k=class extends _e{constructor(){super(...arguments);this.Relayer=()=>{let[i,u]=we(!1),c=A(S=>{this.webView=S},[]),w=A(S=>{this.container=re(te({},S),{showOverlay:l,hideOverlay:b})},[]),l=A(()=>{u(!0)},[]),b=A(()=>{u(!1)},[]),d=be(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),h=A(S=>{this.handleReactNativeWebViewMessage(S)},[]);return oe.createElement(Le,{ref:w,style:d},oe.createElement(Ee,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:h,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1}))}}init(){this.webView=null,this.container=null,this.styles=Me()}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,(w,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return new global[l.constructor](l.data.split(","))}catch(b){}return l});if(c&&c.msgType&&this.messageHandlers.size){c.response=(u=c.response)!=null?u:{};let w={data:c};for(let l of this.messageHandlers.values())l(w)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return N(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:Re}:c),this.endpoint);else throw Oe()})}};import{SDKBase as Ge}from"@magic-sdk/provider";var P=class extends Ge{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=ie.merge(global.process,Ne);global.process.browser=!1;global.Buffer=z;global.URL=Pe;global.URLSearchParams=Ie;global.btoa=o=>z.from(o,"binary").toString("base64");global.atob=o=>z.from(o,"base64").toString("binary");var at=Ve(P,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"18.1.1",bundleId:De(),defaultEndpoint:"https://box.magic.link/",ViewController:k,configureStorage:()=>N(void 0,null,function*(){let o=ke.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Te();return yield Promise.all([o.defineDriver(s),o.defineDriver(F)]),yield o.setDriver([s._driver,F._driver]),o})});export{at as Magic};
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": "18.1.0",
3
+ "version": "18.1.1",
4
4
  "description": "Passwordless authentication for React Native (Bare).",
5
5
  "author": "Magic Labs <team@magic.link> (https://magic.link/)",
6
6
  "license": "MIT",
@@ -18,9 +18,9 @@
18
18
  "types": "./dist/types/index.d.ts",
19
19
  "dependencies": {
20
20
  "@aveq-research/localforage-asyncstorage-driver": "^3.0.1",
21
- "@magic-sdk/commons": "^13.1.0",
22
- "@magic-sdk/provider": "^17.1.0",
23
- "@magic-sdk/types": "^15.1.0",
21
+ "@magic-sdk/commons": "^13.1.1",
22
+ "@magic-sdk/provider": "^17.1.1",
23
+ "@magic-sdk/types": "^15.1.1",
24
24
  "@react-native-async-storage/async-storage": "^1.15.5",
25
25
  "@types/lodash": "^4.14.158",
26
26
  "buffer": "~5.6.0",
@@ -52,5 +52,5 @@
52
52
  "react-native-safe-area-context": ">=4.4.1",
53
53
  "react-native-webview": ">=11.0.0"
54
54
  },
55
- "gitHead": "f076c68cad06c009224003bd1e141c0f41939f46"
55
+ "gitHead": "f5ed7173063e8f197bbad44f17d0543906167854"
56
56
  }