@magic-sdk/react-native-bare 13.0.0 → 13.0.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/README.md +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/es/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
</p>
|
12
12
|
|
13
13
|
## ⚠️ Major Change: Package Split Beta ⚠️
|
14
|
-
Please note that splitting the `Expo` and `Bare React Native` Magic packages is a part of a **beta** release. Take whatever precautions necessary to verify use before installing on your production application. As always, in the case something goes awry, you may open an issue and revert your package to the previous stable version `magic-sdk/react-native
|
14
|
+
Please note that splitting the `Expo` and `Bare React Native` Magic packages is a part of a **beta** release. Take whatever precautions necessary to verify use before installing on your production application. As always, in the case something goes awry, you may open an issue and revert your package to the previous pre-split stable bare react native version `magic-sdk/react-native@^8.0.0`.
|
15
15
|
|
16
16
|
## 📖 Documentation
|
17
17
|
|
package/dist/cjs/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var bt=Object.create;var G=Object.defineProperty,St=Object.defineProperties,Et=Object.getOwnPropertyDescriptor,Lt=Object.getOwnPropertyDescriptors,_t=Object.getOwnPropertyNames,et=Object.getOwnPropertySymbols,Rt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable;var ot=(o,n,s)=>n in o?G(o,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[n]=s,nt=(o,n)=>{for(var s in n||(n={}))rt.call(n,s)&&ot(o,s,n[s]);if(et)for(var s of et(n))Ot.call(n,s)&&ot(o,s,n[s]);return o},it=(o,n)=>St(o,Lt(n)),at=o=>G(o,"__esModule",{value:!0});var At=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports),Mt=(o,n)=>{for(var s in n)G(o,s,{get:n[s],enumerable:!0})},f=(o,n,s,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of _t(n))!rt.call(o,p)&&(s||p!=="default")&&G(o,p,{get:()=>n[p],enumerable:!(c=Et(n,p))||c.enumerable});return o},A=(o,n)=>f(at(G(o!=null?bt(Rt(o)):{},"default",!n&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o),Gt=(o=>(n,s)=>o&&o.get(n)||(s=f(at({}),n,1),o&&o.set(n,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var D=(o,n,s)=>new Promise((c,p)=>{var u=w=>{try{E(s.next(w))}catch(y){p(y)}},_=w=>{try{E(s.throw(w))}catch(y){p(y)}},E=w=>w.done?c(w.value):Promise.resolve(w.value).then(u,_);E((s=s.apply(o,n)).next())});var ct=At((Pt,F)=>{var st=function(o){"use strict";var n=Object.prototype,s=n.hasOwnProperty,c,p=typeof Symbol=="function"?Symbol:{},u=p.iterator||"@@iterator",_=p.asyncIterator||"@@asyncIterator",E=p.toStringTag||"@@toStringTag";function w(e,t,r,a){var i=t&&t.prototype instanceof Y?t:Y,h=Object.create(i.prototype),v=new K(a||[]);return h._invoke=gt(e,r,v),h}o.wrap=w;function y(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(a){return{type:"throw",arg:a}}}var x="suspendedStart",yt="suspendedYield",Q="executing",V="completed",S={};function Y(){}function N(){}function R(){}var j={};j[u]=function(){return this};var B=Object.getPrototypeOf,k=B&&B(B($([])));k&&k!==n&&s.call(k,u)&&(j=k);var O=R.prototype=Y.prototype=Object.create(j);N.prototype=O.constructor=R,R.constructor=N,R[E]=N.displayName="GeneratorFunction";function X(e){["next","throw","return"].forEach(function(t){e[t]=function(r){return this._invoke(t,r)}})}o.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===N||(t.displayName||t.name)==="GeneratorFunction":!1},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,R):(e.__proto__=R,E in e||(e[E]="GeneratorFunction")),e.prototype=Object.create(O),e},o.awrap=function(e){return{__await:e}};function I(e,t){function r(h,v,m,b){var d=y(e[h],e,v);if(d.type==="throw")b(d.arg);else{var z=d.arg,M=z.value;return M&&typeof M=="object"&&s.call(M,"__await")?t.resolve(M.__await).then(function(L){r("next",L,m,b)},function(L){r("throw",L,m,b)}):t.resolve(M).then(function(L){z.value=L,m(z)},function(L){return r("throw",L,m,b)})}}var a;function i(h,v){function m(){return new t(function(b,d){r(h,v,b,d)})}return a=a?a.then(m,m):m()}this._invoke=i}X(I.prototype),I.prototype[_]=function(){return this},o.AsyncIterator=I,o.async=function(e,t,r,a,i){i===void 0&&(i=Promise);var h=new I(w(e,t,r,a),i);return o.isGeneratorFunction(t)?h:h.next().then(function(v){return v.done?v.value:h.next()})};function gt(e,t,r){var a=x;return function(h,v){if(a===Q)throw new Error("Generator is already running");if(a===V){if(h==="throw")throw v;return tt()}for(r.method=h,r.arg=v;;){var m=r.delegate;if(m){var b=Z(m,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(a===x)throw a=V,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=Q;var d=y(e,t,r);if(d.type==="normal"){if(a=r.done?V:yt,d.arg===S)continue;return{value:d.arg,done:r.done}}else d.type==="throw"&&(a=V,r.method="throw",r.arg=d.arg)}}}function Z(e,t){var r=e.iterator[t.method];if(r===c){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=c,Z(e,t),t.method==="throw"))return S;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return S}var a=y(r,e.iterator,t.arg);if(a.type==="throw")return t.method="throw",t.arg=a.arg,t.delegate=null,S;var i=a.arg;if(!i)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,S;if(i.done)t[e.resultName]=i.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=c);else return i;return t.delegate=null,S}X(O),O[E]="Generator",O[u]=function(){return this},O.toString=function(){return"[object Generator]"};function wt(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function U(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function K(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(wt,this),this.reset(!0)}o.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function a(){for(;t.length;){var i=t.pop();if(i in e)return a.value=i,a.done=!1,a}return a.done=!0,a}};function $(e){if(e){var t=e[u];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var r=-1,a=function i(){for(;++r<e.length;)if(s.call(e,r))return i.value=e[r],i.done=!1,i;return i.value=c,i.done=!0,i};return a.next=a}}return{next:tt}}o.values=$;function tt(){return{value:c,done:!0}}return K.prototype={constructor:K,reset:function(e){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(U),!e)for(var t in this)t.charAt(0)==="t"&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=c)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(b,d){return h.type="throw",h.arg=e,t.next=b,d&&(t.method="next",t.arg=c),!!d}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],h=i.completion;if(i.tryLoc==="root")return r("end");if(i.tryLoc<=this.prev){var v=s.call(i,"catchLoc"),m=s.call(i,"finallyLoc");if(v&&m){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(v){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else if(m){if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&s.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&(e==="break"||e==="continue")&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var h=i?i.completion:{};return h.type=e,h.arg=t,i?(this.method="next",this.next=i.finallyLoc,S):this.complete(h)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),S},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),U(r),S}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var a=r.completion;if(a.type==="throw"){var i=a.arg;U(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:$(e),resultName:t,nextLoc:r},this.method==="next"&&(this.arg=c),S}},o}(typeof F=="object"?F.exports:{});try{regeneratorRuntime=st}catch{Function("r","regeneratorRuntime = r")(st)}});var l={};Mt(l,{Magic:()=>It});var Wt=A(ct()),ut=require("@magic-sdk/provider"),kt=A(require("process")),pt=A(require("localforage")),T=require("whatwg-url"),W=require("buffer"),vt=A(require("lodash")),mt=require("react-native-device-info"),dt=require("@aveq-research/localforage-asyncstorage-driver"),q=A(require("localforage-driver-memory"));var g=A(require("react")),P=require("react-native"),ft=require("react-native-webview"),C=require("@magic-sdk/provider"),lt=require("lodash"),Vt="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function Nt(){return P.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 J=class extends C.ViewController{constructor(){super(...arguments);this.Relayer=()=>{let[n,s]=(0,g.useState)(!1),c=(0,g.useCallback)(y=>{this.webView=y},[]),p=(0,g.useCallback)(y=>{this.container=it(nt({},y),{showOverlay:u,hideOverlay:_})},[]),u=(0,g.useCallback)(()=>{s(!0)},[]),_=(0,g.useCallback)(()=>{s(!1)},[]),E=(0,g.useMemo)(()=>[this.styles["webview-container"],n?this.styles.show:this.styles.hide],[n]),w=(0,g.useCallback)(y=>{this.handleReactNativeWebViewMessage(y)},[]);return g.default.createElement(P.View,{ref:p,style:E},g.default.createElement(ft.WebView,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:w,style:this.styles["magic-webview"]}))}}init(){this.webView=null,this.container=null,this.styles=Nt()}handleReactNativeWebViewMessage(n){var s;if(n.nativeEvent&&typeof n.nativeEvent.data=="string"&&(n.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||n.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(n.nativeEvent.data,(p,u)=>{try{if(u&&typeof u=="object"&&u.flag&&u.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return global[u.constructor](u.data.split(","))}catch(_){}return u});if(c&&c.msgType&&this.messageHandlers.size){c.response=(s=c.response)!=null?s:{};let p={data:c};for(let u of this.messageHandlers.values())u(p)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(n){return D(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(n,(s,c)=>(0,lt.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:Vt}:c),this.endpoint);else throw(0,C.createModalNotReadyError)()})}};var ht=require("@magic-sdk/provider"),H=class extends ht.SDKBase{get Relayer(){return this.overlay.Relayer}};f(l,require("@magic-sdk/commons"));global.process=vt.merge(global.process,kt);global.process.browser=!1;global.Buffer=W.Buffer;global.URL=T.URL;global.URLSearchParams=T.URLSearchParams;global.btoa=o=>W.Buffer.from(o,"binary").toString("base64");global.atob=o=>W.Buffer.from(o,"base64").toString("binary");var It=(0,ut.createSDK)(H,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"13.0.0",bundleId:(0,mt.getBundleId)(),defaultEndpoint:"https://box.magic.link/",ViewController:J,configureStorage:()=>D(void 0,null,function*(){let o=pt.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),n=(0,dt.driverWithoutSerialization)();return yield Promise.all([o.defineDriver(n),o.defineDriver(q)]),yield o.setDriver([n._driver,q._driver]),o})});module.exports=Gt(l);0&&(module.exports={Magic});
|
1
|
+
var bt=Object.create;var G=Object.defineProperty,St=Object.defineProperties,Et=Object.getOwnPropertyDescriptor,Lt=Object.getOwnPropertyDescriptors,_t=Object.getOwnPropertyNames,et=Object.getOwnPropertySymbols,Rt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty,Ot=Object.prototype.propertyIsEnumerable;var ot=(o,n,s)=>n in o?G(o,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[n]=s,nt=(o,n)=>{for(var s in n||(n={}))rt.call(n,s)&&ot(o,s,n[s]);if(et)for(var s of et(n))Ot.call(n,s)&&ot(o,s,n[s]);return o},it=(o,n)=>St(o,Lt(n)),at=o=>G(o,"__esModule",{value:!0});var At=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports),Mt=(o,n)=>{for(var s in n)G(o,s,{get:n[s],enumerable:!0})},f=(o,n,s,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of _t(n))!rt.call(o,p)&&(s||p!=="default")&&G(o,p,{get:()=>n[p],enumerable:!(c=Et(n,p))||c.enumerable});return o},A=(o,n)=>f(at(G(o!=null?bt(Rt(o)):{},"default",!n&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o),Gt=(o=>(n,s)=>o&&o.get(n)||(s=f(at({}),n,1),o&&o.set(n,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var D=(o,n,s)=>new Promise((c,p)=>{var u=w=>{try{E(s.next(w))}catch(y){p(y)}},_=w=>{try{E(s.throw(w))}catch(y){p(y)}},E=w=>w.done?c(w.value):Promise.resolve(w.value).then(u,_);E((s=s.apply(o,n)).next())});var ct=At((Pt,F)=>{var st=function(o){"use strict";var n=Object.prototype,s=n.hasOwnProperty,c,p=typeof Symbol=="function"?Symbol:{},u=p.iterator||"@@iterator",_=p.asyncIterator||"@@asyncIterator",E=p.toStringTag||"@@toStringTag";function w(e,t,r,a){var i=t&&t.prototype instanceof Y?t:Y,h=Object.create(i.prototype),v=new K(a||[]);return h._invoke=gt(e,r,v),h}o.wrap=w;function y(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(a){return{type:"throw",arg:a}}}var x="suspendedStart",yt="suspendedYield",Q="executing",V="completed",S={};function Y(){}function N(){}function R(){}var j={};j[u]=function(){return this};var B=Object.getPrototypeOf,k=B&&B(B($([])));k&&k!==n&&s.call(k,u)&&(j=k);var O=R.prototype=Y.prototype=Object.create(j);N.prototype=O.constructor=R,R.constructor=N,R[E]=N.displayName="GeneratorFunction";function X(e){["next","throw","return"].forEach(function(t){e[t]=function(r){return this._invoke(t,r)}})}o.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===N||(t.displayName||t.name)==="GeneratorFunction":!1},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,R):(e.__proto__=R,E in e||(e[E]="GeneratorFunction")),e.prototype=Object.create(O),e},o.awrap=function(e){return{__await:e}};function I(e,t){function r(h,v,m,b){var d=y(e[h],e,v);if(d.type==="throw")b(d.arg);else{var z=d.arg,M=z.value;return M&&typeof M=="object"&&s.call(M,"__await")?t.resolve(M.__await).then(function(L){r("next",L,m,b)},function(L){r("throw",L,m,b)}):t.resolve(M).then(function(L){z.value=L,m(z)},function(L){return r("throw",L,m,b)})}}var a;function i(h,v){function m(){return new t(function(b,d){r(h,v,b,d)})}return a=a?a.then(m,m):m()}this._invoke=i}X(I.prototype),I.prototype[_]=function(){return this},o.AsyncIterator=I,o.async=function(e,t,r,a,i){i===void 0&&(i=Promise);var h=new I(w(e,t,r,a),i);return o.isGeneratorFunction(t)?h:h.next().then(function(v){return v.done?v.value:h.next()})};function gt(e,t,r){var a=x;return function(h,v){if(a===Q)throw new Error("Generator is already running");if(a===V){if(h==="throw")throw v;return tt()}for(r.method=h,r.arg=v;;){var m=r.delegate;if(m){var b=Z(m,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(a===x)throw a=V,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=Q;var d=y(e,t,r);if(d.type==="normal"){if(a=r.done?V:yt,d.arg===S)continue;return{value:d.arg,done:r.done}}else d.type==="throw"&&(a=V,r.method="throw",r.arg=d.arg)}}}function Z(e,t){var r=e.iterator[t.method];if(r===c){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=c,Z(e,t),t.method==="throw"))return S;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return S}var a=y(r,e.iterator,t.arg);if(a.type==="throw")return t.method="throw",t.arg=a.arg,t.delegate=null,S;var i=a.arg;if(!i)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,S;if(i.done)t[e.resultName]=i.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=c);else return i;return t.delegate=null,S}X(O),O[E]="Generator",O[u]=function(){return this},O.toString=function(){return"[object Generator]"};function wt(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function U(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function K(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(wt,this),this.reset(!0)}o.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function a(){for(;t.length;){var i=t.pop();if(i in e)return a.value=i,a.done=!1,a}return a.done=!0,a}};function $(e){if(e){var t=e[u];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var r=-1,a=function i(){for(;++r<e.length;)if(s.call(e,r))return i.value=e[r],i.done=!1,i;return i.value=c,i.done=!0,i};return a.next=a}}return{next:tt}}o.values=$;function tt(){return{value:c,done:!0}}return K.prototype={constructor:K,reset:function(e){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(U),!e)for(var t in this)t.charAt(0)==="t"&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=c)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(b,d){return h.type="throw",h.arg=e,t.next=b,d&&(t.method="next",t.arg=c),!!d}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],h=i.completion;if(i.tryLoc==="root")return r("end");if(i.tryLoc<=this.prev){var v=s.call(i,"catchLoc"),m=s.call(i,"finallyLoc");if(v&&m){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(v){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else if(m){if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&s.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&(e==="break"||e==="continue")&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var h=i?i.completion:{};return h.type=e,h.arg=t,i?(this.method="next",this.next=i.finallyLoc,S):this.complete(h)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),S},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),U(r),S}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var a=r.completion;if(a.type==="throw"){var i=a.arg;U(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:$(e),resultName:t,nextLoc:r},this.method==="next"&&(this.arg=c),S}},o}(typeof F=="object"?F.exports:{});try{regeneratorRuntime=st}catch{Function("r","regeneratorRuntime = r")(st)}});var l={};Mt(l,{Magic:()=>It});var Wt=A(ct()),ut=require("@magic-sdk/provider"),kt=A(require("process")),pt=A(require("localforage")),T=require("whatwg-url"),W=require("buffer"),vt=A(require("lodash")),mt=require("react-native-device-info"),dt=require("@aveq-research/localforage-asyncstorage-driver"),q=A(require("localforage-driver-memory"));var g=A(require("react")),P=require("react-native"),ft=require("react-native-webview"),C=require("@magic-sdk/provider"),lt=require("lodash"),Vt="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function Nt(){return P.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 J=class extends C.ViewController{constructor(){super(...arguments);this.Relayer=()=>{let[n,s]=(0,g.useState)(!1),c=(0,g.useCallback)(y=>{this.webView=y},[]),p=(0,g.useCallback)(y=>{this.container=it(nt({},y),{showOverlay:u,hideOverlay:_})},[]),u=(0,g.useCallback)(()=>{s(!0)},[]),_=(0,g.useCallback)(()=>{s(!1)},[]),E=(0,g.useMemo)(()=>[this.styles["webview-container"],n?this.styles.show:this.styles.hide],[n]),w=(0,g.useCallback)(y=>{this.handleReactNativeWebViewMessage(y)},[]);return g.default.createElement(P.View,{ref:p,style:E},g.default.createElement(ft.WebView,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:w,style:this.styles["magic-webview"]}))}}init(){this.webView=null,this.container=null,this.styles=Nt()}handleReactNativeWebViewMessage(n){var s;if(n.nativeEvent&&typeof n.nativeEvent.data=="string"&&(n.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||n.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(n.nativeEvent.data,(p,u)=>{try{if(u&&typeof u=="object"&&u.flag&&u.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return global[u.constructor](u.data.split(","))}catch(_){}return u});if(c&&c.msgType&&this.messageHandlers.size){c.response=(s=c.response)!=null?s:{};let p={data:c};for(let u of this.messageHandlers.values())u(p)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(n){return D(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(n,(s,c)=>(0,lt.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:Vt}:c),this.endpoint);else throw(0,C.createModalNotReadyError)()})}};var ht=require("@magic-sdk/provider"),H=class extends ht.SDKBase{get Relayer(){return this.overlay.Relayer}};f(l,require("@magic-sdk/commons"));global.process=vt.merge(global.process,kt);global.process.browser=!1;global.Buffer=W.Buffer;global.URL=T.URL;global.URLSearchParams=T.URLSearchParams;global.btoa=o=>W.Buffer.from(o,"binary").toString("base64");global.atob=o=>W.Buffer.from(o,"base64").toString("binary");var It=(0,ut.createSDK)(H,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"13.0.1",bundleId:(0,mt.getBundleId)(),defaultEndpoint:"https://box.magic.link/",ViewController:J,configureStorage:()=>D(void 0,null,function*(){let o=pt.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),n=(0,dt.driverWithoutSerialization)();return yield Promise.all([o.defineDriver(n),o.defineDriver(q)]),yield o.setDriver([n._driver,q._driver]),o})});module.exports=Gt(l);0&&(module.exports={Magic});
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var st=Object.create;var V=Object.defineProperty,ct=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,lt=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols,ut=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var Q=(o,i,s)=>i in o?V(o,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[i]=s,X=(o,i)=>{for(var s in i||(i={}))x.call(i,s)&&Q(o,s,i[s]);if(q)for(var s of q(i))pt.call(i,s)&&Q(o,s,i[s]);return o},Z=(o,i)=>ct(o,lt(i)),vt=o=>V(o,"__esModule",{value:!0});var mt=(o,i)=>()=>(i||o((i={exports:{}}).exports,i),i.exports);var dt=(o,i,s,c)=>{if(i&&typeof i=="object"||typeof i=="function")for(let h of ht(i))!x.call(o,h)&&(s||h!=="default")&&V(o,h,{get:()=>i[h],enumerable:!(c=ft(i,h))||c.enumerable});return o},yt=(o,i)=>dt(vt(V(o!=null?st(ut(o)):{},"default",!i&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o);var N=(o,i,s)=>new Promise((c,h)=>{var l=d=>{try{w(s.next(d))}catch(m){h(m)}},S=d=>{try{w(s.throw(d))}catch(m){h(m)}},w=d=>d.done?c(d.value):Promise.resolve(d.value).then(l,S);w((s=s.apply(o,i)).next())});var et=mt((Tt,Y)=>{var tt=function(o){"use strict";var i=Object.prototype,s=i.hasOwnProperty,c,h=typeof Symbol=="function"?Symbol:{},l=h.iterator||"@@iterator",S=h.asyncIterator||"@@asyncIterator",w=h.toStringTag||"@@toStringTag";function d(e,t,r,a){var n=t&&t.prototype instanceof k?t:k,f=Object.create(n.prototype),u=new C(a||[]);return f._invoke=it(e,r,u),f}o.wrap=d;function m(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(a){return{type:"throw",arg:a}}}var $="suspendedStart",nt="suspendedYield",z="executing",O="completed",g={};function k(){}function A(){}function E(){}var I={};I[l]=function(){return this};var D=Object.getPrototypeOf,M=D&&D(D(T([])));M&&M!==i&&s.call(M,l)&&(I=M);var L=E.prototype=k.prototype=Object.create(I);A.prototype=L.constructor=E,E.constructor=A,E[w]=A.displayName="GeneratorFunction";function F(e){["next","throw","return"].forEach(function(t){e[t]=function(r){return this._invoke(t,r)}})}o.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===A||(t.displayName||t.name)==="GeneratorFunction":!1},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,w in e||(e[w]="GeneratorFunction")),e.prototype=Object.create(L),e},o.awrap=function(e){return{__await:e}};function G(e,t){function r(f,u,p,y){var v=m(e[f],e,u);if(v.type==="throw")y(v.arg);else{var W=v.arg,_=W.value;return _&&typeof _=="object"&&s.call(_,"__await")?t.resolve(_.__await).then(function(b){r("next",b,p,y)},function(b){r("throw",b,p,y)}):t.resolve(_).then(function(b){W.value=b,p(W)},function(b){return r("throw",b,p,y)})}}var a;function n(f,u){function p(){return new t(function(y,v){r(f,u,y,v)})}return a=a?a.then(p,p):p()}this._invoke=n}F(G.prototype),G.prototype[S]=function(){return this},o.AsyncIterator=G,o.async=function(e,t,r,a,n){n===void 0&&(n=Promise);var f=new G(d(e,t,r,a),n);return o.isGeneratorFunction(t)?f:f.next().then(function(u){return u.done?u.value:f.next()})};function it(e,t,r){var a=$;return function(f,u){if(a===z)throw new Error("Generator is already running");if(a===O){if(f==="throw")throw u;return H()}for(r.method=f,r.arg=u;;){var p=r.delegate;if(p){var y=J(p,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===$)throw a=O,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=z;var v=m(e,t,r);if(v.type==="normal"){if(a=r.done?O:nt,v.arg===g)continue;return{value:v.arg,done:r.done}}else v.type==="throw"&&(a=O,r.method="throw",r.arg=v.arg)}}}function J(e,t){var r=e.iterator[t.method];if(r===c){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=c,J(e,t),t.method==="throw"))return g;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return g}var a=m(r,e.iterator,t.arg);if(a.type==="throw")return t.method="throw",t.arg=a.arg,t.delegate=null,g;var n=a.arg;if(!n)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g;if(n.done)t[e.resultName]=n.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=c);else return n;return t.delegate=null,g}F(L),L[w]="Generator",L[l]=function(){return this},L.toString=function(){return"[object Generator]"};function at(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(at,this),this.reset(!0)}o.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function a(){for(;t.length;){var n=t.pop();if(n in e)return a.value=n,a.done=!1,a}return a.done=!0,a}};function T(e){if(e){var t=e[l];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var r=-1,a=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=c,n.done=!0,n};return a.next=a}}return{next:H}}o.values=T;function H(){return{value:c,done:!0}}return C.prototype={constructor:C,reset:function(e){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(P),!e)for(var t in this)t.charAt(0)==="t"&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=c)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(y,v){return f.type="throw",f.arg=e,t.next=y,v&&(t.method="next",t.arg=c),!!v}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 u=s.call(n,"catchLoc"),p=s.call(n,"finallyLoc");if(u&&p){if(this.prev<n.catchLoc)return r(n.catchLoc,!0);if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else if(u){if(this.prev<n.catchLoc)return r(n.catchLoc,!0)}else if(p){if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&s.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var n=a;break}}n&&(e==="break"||e==="continue")&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var f=n?n.completion:{};return f.type=e,f.arg=t,n?(this.method="next",this.next=n.finallyLoc,g):this.complete(f)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var a=r.completion;if(a.type==="throw"){var n=a.arg;P(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},this.method==="next"&&(this.arg=c),g}},o}(typeof Y=="object"?Y.exports:{});try{regeneratorRuntime=tt}catch{Function("r","regeneratorRuntime = r")(tt)}});var Ft=yt(et());import{createSDK as Gt}from"@magic-sdk/provider";import*as Vt from"process";import Nt from"localforage";import{URL as kt,URLSearchParams as It}from"whatwg-url";import{Buffer as U}from"buffer";import*as ot from"lodash";import{getBundleId as Dt}from"react-native-device-info";import{driverWithoutSerialization as Pt}from"@aveq-research/localforage-asyncstorage-driver";import*as K from"localforage-driver-memory";import rt,{useState as gt,useCallback as R,useMemo as wt}from"react";import{StyleSheet as bt,View as St}from"react-native";import{WebView as Et}from"react-native-webview";import{ViewController as Lt,createModalNotReadyError as _t}from"@magic-sdk/provider";import{isTypedArray as Rt}from"lodash";var Ot="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function At(){return bt.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 j=class extends Lt{constructor(){super(...arguments);this.Relayer=()=>{let[i,s]=gt(!1),c=R(m=>{this.webView=m},[]),h=R(m=>{this.container=Z(X({},m),{showOverlay:l,hideOverlay:S})},[]),l=R(()=>{s(!0)},[]),S=R(()=>{s(!1)},[]),w=wt(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),d=R(m=>{this.handleReactNativeWebViewMessage(m)},[]);return rt.createElement(St,{ref:h,style:w},rt.createElement(Et,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:d,style:this.styles["magic-webview"]}))}}init(){this.webView=null,this.container=null,this.styles=At()}handleReactNativeWebViewMessage(i){var s;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,(h,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return global[l.constructor](l.data.split(","))}catch(S){}return l});if(c&&c.msgType&&this.messageHandlers.size){c.response=(s=c.response)!=null?s:{};let h={data:c};for(let l of this.messageHandlers.values())l(h)}}}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,(s,c)=>Rt(c)?{constructor:c.constructor.name,data:c.toString(),flag:Ot}:c),this.endpoint);else throw _t()})}};import{SDKBase as Mt}from"@magic-sdk/provider";var B=class extends Mt{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=ot.merge(global.process,Vt);global.process.browser=!1;global.Buffer=U;global.URL=kt;global.URLSearchParams=It;global.btoa=o=>U.from(o,"binary").toString("base64");global.atob=o=>U.from(o,"base64").toString("binary");var oe=Gt(B,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"13.0.0",bundleId:Dt(),defaultEndpoint:"https://box.magic.link/",ViewController:j,configureStorage:()=>N(void 0,null,function*(){let o=Nt.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),i=Pt();return yield Promise.all([o.defineDriver(i),o.defineDriver(K)]),yield o.setDriver([i._driver,K._driver]),o})});export{oe as Magic};
|
1
|
+
var st=Object.create;var V=Object.defineProperty,ct=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,lt=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols,ut=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty,pt=Object.prototype.propertyIsEnumerable;var Q=(o,i,s)=>i in o?V(o,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[i]=s,X=(o,i)=>{for(var s in i||(i={}))x.call(i,s)&&Q(o,s,i[s]);if(q)for(var s of q(i))pt.call(i,s)&&Q(o,s,i[s]);return o},Z=(o,i)=>ct(o,lt(i)),vt=o=>V(o,"__esModule",{value:!0});var mt=(o,i)=>()=>(i||o((i={exports:{}}).exports,i),i.exports);var dt=(o,i,s,c)=>{if(i&&typeof i=="object"||typeof i=="function")for(let h of ht(i))!x.call(o,h)&&(s||h!=="default")&&V(o,h,{get:()=>i[h],enumerable:!(c=ft(i,h))||c.enumerable});return o},yt=(o,i)=>dt(vt(V(o!=null?st(ut(o)):{},"default",!i&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o);var N=(o,i,s)=>new Promise((c,h)=>{var l=d=>{try{w(s.next(d))}catch(m){h(m)}},S=d=>{try{w(s.throw(d))}catch(m){h(m)}},w=d=>d.done?c(d.value):Promise.resolve(d.value).then(l,S);w((s=s.apply(o,i)).next())});var et=mt((Tt,Y)=>{var tt=function(o){"use strict";var i=Object.prototype,s=i.hasOwnProperty,c,h=typeof Symbol=="function"?Symbol:{},l=h.iterator||"@@iterator",S=h.asyncIterator||"@@asyncIterator",w=h.toStringTag||"@@toStringTag";function d(e,t,r,a){var n=t&&t.prototype instanceof k?t:k,f=Object.create(n.prototype),u=new C(a||[]);return f._invoke=it(e,r,u),f}o.wrap=d;function m(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(a){return{type:"throw",arg:a}}}var $="suspendedStart",nt="suspendedYield",z="executing",O="completed",g={};function k(){}function A(){}function E(){}var I={};I[l]=function(){return this};var D=Object.getPrototypeOf,M=D&&D(D(T([])));M&&M!==i&&s.call(M,l)&&(I=M);var L=E.prototype=k.prototype=Object.create(I);A.prototype=L.constructor=E,E.constructor=A,E[w]=A.displayName="GeneratorFunction";function F(e){["next","throw","return"].forEach(function(t){e[t]=function(r){return this._invoke(t,r)}})}o.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===A||(t.displayName||t.name)==="GeneratorFunction":!1},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,w in e||(e[w]="GeneratorFunction")),e.prototype=Object.create(L),e},o.awrap=function(e){return{__await:e}};function G(e,t){function r(f,u,p,y){var v=m(e[f],e,u);if(v.type==="throw")y(v.arg);else{var W=v.arg,_=W.value;return _&&typeof _=="object"&&s.call(_,"__await")?t.resolve(_.__await).then(function(b){r("next",b,p,y)},function(b){r("throw",b,p,y)}):t.resolve(_).then(function(b){W.value=b,p(W)},function(b){return r("throw",b,p,y)})}}var a;function n(f,u){function p(){return new t(function(y,v){r(f,u,y,v)})}return a=a?a.then(p,p):p()}this._invoke=n}F(G.prototype),G.prototype[S]=function(){return this},o.AsyncIterator=G,o.async=function(e,t,r,a,n){n===void 0&&(n=Promise);var f=new G(d(e,t,r,a),n);return o.isGeneratorFunction(t)?f:f.next().then(function(u){return u.done?u.value:f.next()})};function it(e,t,r){var a=$;return function(f,u){if(a===z)throw new Error("Generator is already running");if(a===O){if(f==="throw")throw u;return H()}for(r.method=f,r.arg=u;;){var p=r.delegate;if(p){var y=J(p,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===$)throw a=O,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=z;var v=m(e,t,r);if(v.type==="normal"){if(a=r.done?O:nt,v.arg===g)continue;return{value:v.arg,done:r.done}}else v.type==="throw"&&(a=O,r.method="throw",r.arg=v.arg)}}}function J(e,t){var r=e.iterator[t.method];if(r===c){if(t.delegate=null,t.method==="throw"){if(e.iterator.return&&(t.method="return",t.arg=c,J(e,t),t.method==="throw"))return g;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return g}var a=m(r,e.iterator,t.arg);if(a.type==="throw")return t.method="throw",t.arg=a.arg,t.delegate=null,g;var n=a.arg;if(!n)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g;if(n.done)t[e.resultName]=n.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=c);else return n;return t.delegate=null,g}F(L),L[w]="Generator",L[l]=function(){return this},L.toString=function(){return"[object Generator]"};function at(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(at,this),this.reset(!0)}o.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function a(){for(;t.length;){var n=t.pop();if(n in e)return a.value=n,a.done=!1,a}return a.done=!0,a}};function T(e){if(e){var t=e[l];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var r=-1,a=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=c,n.done=!0,n};return a.next=a}}return{next:H}}o.values=T;function H(){return{value:c,done:!0}}return C.prototype={constructor:C,reset:function(e){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(P),!e)for(var t in this)t.charAt(0)==="t"&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=c)},stop:function(){this.done=!0;var e=this.tryEntries[0],t=e.completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(y,v){return f.type="throw",f.arg=e,t.next=y,v&&(t.method="next",t.arg=c),!!v}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 u=s.call(n,"catchLoc"),p=s.call(n,"finallyLoc");if(u&&p){if(this.prev<n.catchLoc)return r(n.catchLoc,!0);if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else if(u){if(this.prev<n.catchLoc)return r(n.catchLoc,!0)}else if(p){if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&s.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var n=a;break}}n&&(e==="break"||e==="continue")&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var f=n?n.completion:{};return f.type=e,f.arg=t,n?(this.method="next",this.next=n.finallyLoc,g):this.complete(f)},complete:function(e,t){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var a=r.completion;if(a.type==="throw"){var n=a.arg;P(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},this.method==="next"&&(this.arg=c),g}},o}(typeof Y=="object"?Y.exports:{});try{regeneratorRuntime=tt}catch{Function("r","regeneratorRuntime = r")(tt)}});var Ft=yt(et());import{createSDK as Gt}from"@magic-sdk/provider";import*as Vt from"process";import Nt from"localforage";import{URL as kt,URLSearchParams as It}from"whatwg-url";import{Buffer as U}from"buffer";import*as ot from"lodash";import{getBundleId as Dt}from"react-native-device-info";import{driverWithoutSerialization as Pt}from"@aveq-research/localforage-asyncstorage-driver";import*as K from"localforage-driver-memory";import rt,{useState as gt,useCallback as R,useMemo as wt}from"react";import{StyleSheet as bt,View as St}from"react-native";import{WebView as Et}from"react-native-webview";import{ViewController as Lt,createModalNotReadyError as _t}from"@magic-sdk/provider";import{isTypedArray as Rt}from"lodash";var Ot="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function At(){return bt.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 j=class extends Lt{constructor(){super(...arguments);this.Relayer=()=>{let[i,s]=gt(!1),c=R(m=>{this.webView=m},[]),h=R(m=>{this.container=Z(X({},m),{showOverlay:l,hideOverlay:S})},[]),l=R(()=>{s(!0)},[]),S=R(()=>{s(!1)},[]),w=wt(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),d=R(m=>{this.handleReactNativeWebViewMessage(m)},[]);return rt.createElement(St,{ref:h,style:w},rt.createElement(Et,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:d,style:this.styles["magic-webview"]}))}}init(){this.webView=null,this.container=null,this.styles=At()}handleReactNativeWebViewMessage(i){var s;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,(h,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return global[l.constructor](l.data.split(","))}catch(S){}return l});if(c&&c.msgType&&this.messageHandlers.size){c.response=(s=c.response)!=null?s:{};let h={data:c};for(let l of this.messageHandlers.values())l(h)}}}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,(s,c)=>Rt(c)?{constructor:c.constructor.name,data:c.toString(),flag:Ot}:c),this.endpoint);else throw _t()})}};import{SDKBase as Mt}from"@magic-sdk/provider";var B=class extends Mt{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=ot.merge(global.process,Vt);global.process.browser=!1;global.Buffer=U;global.URL=kt;global.URLSearchParams=It;global.btoa=o=>U.from(o,"binary").toString("base64");global.atob=o=>U.from(o,"base64").toString("binary");var oe=Gt(B,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"13.0.1",bundleId:Dt(),defaultEndpoint:"https://box.magic.link/",ViewController:j,configureStorage:()=>N(void 0,null,function*(){let o=Nt.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),i=Pt();return yield Promise.all([o.defineDriver(i),o.defineDriver(K)]),yield o.setDriver([i._driver,K._driver]),o})});export{oe 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": "13.0.
|
3
|
+
"version": "13.0.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",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"@aveq-research/localforage-asyncstorage-driver": "^3.0.1",
|
21
21
|
"@magic-sdk/commons": "^7.0.1",
|
22
22
|
"@magic-sdk/provider": "^11.1.3",
|
23
|
-
"@magic-sdk/types": "^10.0.
|
23
|
+
"@magic-sdk/types": "^10.0.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",
|