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