@magic-sdk/react-native-expo 18.1.2-canary.500.4789316256.0 → 18.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/index.js +1 -1
- package/dist/es/index.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# v18.1.2 (Tue Apr 25 2023)
|
2
|
+
|
3
|
+
#### 🐛 Bug Fix
|
4
|
+
|
5
|
+
- update MIT license to apache [#500](https://github.com/magiclabs/magic-js/pull/500) ([@Dizigen](https://github.com/Dizigen))
|
6
|
+
|
7
|
+
#### Authors: 1
|
8
|
+
|
9
|
+
- David He ([@Dizigen](https://github.com/Dizigen))
|
10
|
+
|
11
|
+
---
|
12
|
+
|
1
13
|
# v18.1.1 (Fri Apr 21 2023)
|
2
14
|
|
3
15
|
#### 🐛 Bug Fix
|
package/dist/cjs/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var Lt=Object.create;var V=Object.defineProperty,_t=Object.defineProperties,Ot=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,Rt=Object.getOwnPropertyNames,ot=Object.getOwnPropertySymbols,Mt=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var it=(n,a,i)=>a in n?V(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,st=(n,a)=>{for(var i in a||(a={}))at.call(a,i)&&it(n,i,a[i]);if(ot)for(var i of ot(a))Gt.call(a,i)&&it(n,i,a[i]);return n},ct=(n,a)=>_t(n,At(a));var Vt=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports),Nt=(n,a)=>{for(var i in a)V(n,i,{get:a[i],enumerable:!0})},D=(n,a,i,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Rt(a))!at.call(n,c)&&c!==i&&V(n,c,{get:()=>a[c],enumerable:!(p=Ot(a,c))||p.enumerable});return n},u=(n,a,i)=>(D(n,a,"default"),i&&D(i,a,"default")),R=(n,a,i)=>(i=n!=null?Lt(Mt(n)):{},D(a||!n||!n.__esModule?V(i,"default",{value:n,enumerable:!0}):i,n)),Pt=n=>D(V({},"__esModule",{value:!0}),n);var T=(n,a,i)=>new Promise((p,c)=>{var E=g=>{try{L(i.next(g))}catch(v){c(v)}},h=g=>{try{L(i.throw(g))}catch(v){c(v)}},L=g=>g.done?p(g.value):Promise.resolve(g.value).then(E,h);L((i=i.apply(n,a)).next())});var lt=Vt((Wt,X)=>{var q=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,p=Object.defineProperty||function(e,t,r){e[t]=r.value},c,E=typeof Symbol=="function"?Symbol:{},h=E.iterator||"@@iterator",L=E.asyncIterator||"@@asyncIterator",g=E.toStringTag||"@@toStringTag";function v(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{v({},"")}catch{v=function(t,r,s){return t[r]=s}}function _(e,t,r,s){var o=t&&t.prototype instanceof B?t:B,l=Object.create(o.prototype),m=new J(s||[]);return p(l,"_invoke",{value:St(e,r,m)}),l}n.wrap=_;function $(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(s){return{type:"throw",arg:s}}}var Z="suspendedStart",bt="suspendedYield",tt="executing",N="completed",S={};function B(){}function P(){}function O(){}var K={};v(K,h,function(){return this});var z=Object.getPrototypeOf,k=z&&z(z(x([])));k&&k!==a&&i.call(k,h)&&(K=k);var M=O.prototype=B.prototype=Object.create(K);P.prototype=O,p(M,"constructor",{value:O,configurable:!0}),p(O,"constructor",{value:P,configurable:!0}),P.displayName=v(O,g,"GeneratorFunction");function et(e){["next","throw","return"].forEach(function(t){v(e,t,function(r){return this._invoke(t,r)})})}n.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===P||(t.displayName||t.name)==="GeneratorFunction":!1},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,O):(e.__proto__=O,v(e,g,"GeneratorFunction")),e.prototype=Object.create(M),e},n.awrap=function(e){return{__await:e}};function I(e,t){function r(l,m,d,b){var y=$(e[l],e,m);if(y.type==="throw")b(y.arg);else{var H=y.arg,G=H.value;return G&&typeof G=="object"&&i.call(G,"__await")?t.resolve(G.__await).then(function(A){r("next",A,d,b)},function(A){r("throw",A,d,b)}):t.resolve(G).then(function(A){H.value=A,d(H)},function(A){return r("throw",A,d,b)})}}var s;function o(l,m){function d(){return new t(function(b,y){r(l,m,b,y)})}return s=s?s.then(d,d):d()}p(this,"_invoke",{value:o})}et(I.prototype),v(I.prototype,L,function(){return this}),n.AsyncIterator=I,n.async=function(e,t,r,s,o){o===void 0&&(o=Promise);var l=new I(_(e,t,r,s),o);return n.isGeneratorFunction(t)?l:l.next().then(function(m){return m.done?m.value:l.next()})};function St(e,t,r){var s=Z;return function(l,m){if(s===tt)throw new Error("Generator is already running");if(s===N){if(l==="throw")throw m;return nt()}for(r.method=l,r.arg=m;;){var d=r.delegate;if(d){var b=rt(d,r);if(b){if(b===S)continue;return b}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(s===Z)throw s=N,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=tt;var y=$(e,t,r);if(y.type==="normal"){if(s=r.done?N:bt,y.arg===S)continue;return{value:y.arg,done:r.done}}else y.type==="throw"&&(s=N,r.method="throw",r.arg=y.arg)}}}function rt(e,t){var r=t.method,s=e.iterator[r];if(s===c)return t.delegate=null,r==="throw"&&e.iterator.return&&(t.method="return",t.arg=c,rt(e,t),t.method==="throw")||r!=="return"&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),S;var o=$(s,e.iterator,t.arg);if(o.type==="throw")return t.method="throw",t.arg=o.arg,t.delegate=null,S;var l=o.arg;if(!l)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,S;if(l.done)t[e.resultName]=l.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=c);else return l;return t.delegate=null,S}et(M),v(M,g,"Generator"),v(M,h,function(){return this}),v(M,"toString",function(){return"[object Generator]"});function Et(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 F(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function J(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(Et,this),this.reset(!0)}n.keys=function(e){var t=Object(e),r=[];for(var s in t)r.push(s);return r.reverse(),function o(){for(;r.length;){var l=r.pop();if(l in t)return o.value=l,o.done=!1,o}return o.done=!0,o}};function x(e){if(e){var t=e[h];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var r=-1,s=function o(){for(;++r<e.length;)if(i.call(e,r))return o.value=e[r],o.done=!1,o;return o.value=c,o.done=!0,o};return s.next=s}}return{next:nt}}n.values=x;function nt(){return{value:c,done:!0}}return J.prototype={constructor:J,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(F),!e)for(var t in this)t.charAt(0)==="t"&&i.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,y){return l.type="throw",l.arg=e,t.next=b,y&&(t.method="next",t.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 m=i.call(o,"catchLoc"),d=i.call(o,"finallyLoc");if(m&&d){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(m){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else if(d){if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){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&&(e==="break"||e==="continue")&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var l=o?o.completion:{};return l.type=e,l.arg=t,o?(this.method="next",this.next=o.finallyLoc,S):this.complete(l)},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),F(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 s=r.completion;if(s.type==="throw"){var o=s.arg;F(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},this.method==="next"&&(this.arg=c),S}},n}(typeof X=="object"?X.exports:{});try{regeneratorRuntime=q}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=q:Function("r","regeneratorRuntime = r")(q)}});var f={};Nt(f,{Magic:()=>Tt});module.exports=Pt(f);var $t=R(lt()),mt=require("@magic-sdk/provider"),Dt=R(require("process")),dt=R(require("localforage")),Y=require("whatwg-url"),U=require("buffer"),yt=R(require("lodash")),gt=R(require("expo-application")),wt=require("@aveq-research/localforage-asyncstorage-driver"),Q=R(require("localforage-driver-memory"));var w=R(require("react")),ft=require("react-native"),ut=require("react-native-webview"),ht=require("react-native-safe-area-context"),W=require("@magic-sdk/provider"),pt=require("lodash");var kt="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function It(){return ft.StyleSheet.create({"magic-webview":{flex:1,backgroundColor:"transparent"},"webview-container":{flex:1,width:"100%",backgroundColor:"transparent",position:"absolute",top:0,left:0,right:0,bottom:0},show:{zIndex:1e4,elevation:1e4},hide:{zIndex:-1e4,elevation:0}})}var C=class extends W.ViewController{constructor(){super(...arguments);this.Relayer=()=>{let[i,p]=(0,w.useState)(!1),c=(0,w.useCallback)(_=>{this.webView=_},[]),E=(0,w.useCallback)(_=>{this.container=ct(st({},_),{showOverlay:h,hideOverlay:L})},[]),h=(0,w.useCallback)(()=>{p(!0)},[]),L=(0,w.useCallback)(()=>{p(!1)},[]),g=(0,w.useMemo)(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),v=(0,w.useCallback)(_=>{this.handleReactNativeWebViewMessage(_)},[]);return w.default.createElement(ht.SafeAreaView,{ref:E,style:g},w.default.createElement(ut.WebView,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:v,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1}))}}init(){this.webView=null,this.container=null,this.styles=It()}handleReactNativeWebViewMessage(i){var p;if(i.nativeEvent&&typeof i.nativeEvent.data=="string"&&(i.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||i.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(i.nativeEvent.data,(E,h)=>{try{if(h&&typeof h=="object"&&h.flag&&h.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return new global[h.constructor](h.data.split(","))}catch(L){}return h});if(c&&c.msgType&&this.messageHandlers.size){c.response=(p=c.response)!=null?p:{};let E={data:c};for(let h of this.messageHandlers.values())h(E)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return T(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(p,c)=>(0,pt.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:kt}:c),this.endpoint);else throw(0,W.createModalNotReadyError)()})}};var vt=require("@magic-sdk/provider"),j=class extends vt.SDKBase{get Relayer(){return this.overlay.Relayer}};u(f,require("@magic-sdk/commons"),module.exports);global.process=yt.merge(global.process,Dt);global.process.browser=!1;global.Buffer=U.Buffer;global.URL=Y.URL;global.URLSearchParams=Y.URLSearchParams;global.btoa=n=>U.Buffer.from(n,"binary").toString("base64");global.atob=n=>U.Buffer.from(n,"base64").toString("binary");var Tt=(0,mt.createSDK)(j,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"18.1.1",bundleId:gt.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:C,configureStorage:()=>T(void 0,null,function*(){let n=dt.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),a=(0,wt.driverWithoutSerialization)();return yield Promise.all([n.defineDriver(a),n.defineDriver(Q)]),yield n.setDriver([a._driver,Q._driver]),n})});0&&(module.exports={Magic});
|
1
|
+
"use strict";var Lt=Object.create;var V=Object.defineProperty,_t=Object.defineProperties,Ot=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,Rt=Object.getOwnPropertyNames,ot=Object.getOwnPropertySymbols,Mt=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var it=(n,a,i)=>a in n?V(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,st=(n,a)=>{for(var i in a||(a={}))at.call(a,i)&&it(n,i,a[i]);if(ot)for(var i of ot(a))Gt.call(a,i)&&it(n,i,a[i]);return n},ct=(n,a)=>_t(n,At(a));var Vt=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports),Nt=(n,a)=>{for(var i in a)V(n,i,{get:a[i],enumerable:!0})},D=(n,a,i,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Rt(a))!at.call(n,c)&&c!==i&&V(n,c,{get:()=>a[c],enumerable:!(p=Ot(a,c))||p.enumerable});return n},u=(n,a,i)=>(D(n,a,"default"),i&&D(i,a,"default")),R=(n,a,i)=>(i=n!=null?Lt(Mt(n)):{},D(a||!n||!n.__esModule?V(i,"default",{value:n,enumerable:!0}):i,n)),Pt=n=>D(V({},"__esModule",{value:!0}),n);var T=(n,a,i)=>new Promise((p,c)=>{var E=g=>{try{L(i.next(g))}catch(v){c(v)}},h=g=>{try{L(i.throw(g))}catch(v){c(v)}},L=g=>g.done?p(g.value):Promise.resolve(g.value).then(E,h);L((i=i.apply(n,a)).next())});var lt=Vt((Wt,X)=>{var q=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,p=Object.defineProperty||function(e,t,r){e[t]=r.value},c,E=typeof Symbol=="function"?Symbol:{},h=E.iterator||"@@iterator",L=E.asyncIterator||"@@asyncIterator",g=E.toStringTag||"@@toStringTag";function v(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{v({},"")}catch{v=function(t,r,s){return t[r]=s}}function _(e,t,r,s){var o=t&&t.prototype instanceof B?t:B,l=Object.create(o.prototype),m=new J(s||[]);return p(l,"_invoke",{value:St(e,r,m)}),l}n.wrap=_;function $(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(s){return{type:"throw",arg:s}}}var Z="suspendedStart",bt="suspendedYield",tt="executing",N="completed",S={};function B(){}function P(){}function O(){}var K={};v(K,h,function(){return this});var z=Object.getPrototypeOf,k=z&&z(z(x([])));k&&k!==a&&i.call(k,h)&&(K=k);var M=O.prototype=B.prototype=Object.create(K);P.prototype=O,p(M,"constructor",{value:O,configurable:!0}),p(O,"constructor",{value:P,configurable:!0}),P.displayName=v(O,g,"GeneratorFunction");function et(e){["next","throw","return"].forEach(function(t){v(e,t,function(r){return this._invoke(t,r)})})}n.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===P||(t.displayName||t.name)==="GeneratorFunction":!1},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,O):(e.__proto__=O,v(e,g,"GeneratorFunction")),e.prototype=Object.create(M),e},n.awrap=function(e){return{__await:e}};function I(e,t){function r(l,m,d,b){var y=$(e[l],e,m);if(y.type==="throw")b(y.arg);else{var H=y.arg,G=H.value;return G&&typeof G=="object"&&i.call(G,"__await")?t.resolve(G.__await).then(function(A){r("next",A,d,b)},function(A){r("throw",A,d,b)}):t.resolve(G).then(function(A){H.value=A,d(H)},function(A){return r("throw",A,d,b)})}}var s;function o(l,m){function d(){return new t(function(b,y){r(l,m,b,y)})}return s=s?s.then(d,d):d()}p(this,"_invoke",{value:o})}et(I.prototype),v(I.prototype,L,function(){return this}),n.AsyncIterator=I,n.async=function(e,t,r,s,o){o===void 0&&(o=Promise);var l=new I(_(e,t,r,s),o);return n.isGeneratorFunction(t)?l:l.next().then(function(m){return m.done?m.value:l.next()})};function St(e,t,r){var s=Z;return function(l,m){if(s===tt)throw new Error("Generator is already running");if(s===N){if(l==="throw")throw m;return nt()}for(r.method=l,r.arg=m;;){var d=r.delegate;if(d){var b=rt(d,r);if(b){if(b===S)continue;return b}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(s===Z)throw s=N,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=tt;var y=$(e,t,r);if(y.type==="normal"){if(s=r.done?N:bt,y.arg===S)continue;return{value:y.arg,done:r.done}}else y.type==="throw"&&(s=N,r.method="throw",r.arg=y.arg)}}}function rt(e,t){var r=t.method,s=e.iterator[r];if(s===c)return t.delegate=null,r==="throw"&&e.iterator.return&&(t.method="return",t.arg=c,rt(e,t),t.method==="throw")||r!=="return"&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),S;var o=$(s,e.iterator,t.arg);if(o.type==="throw")return t.method="throw",t.arg=o.arg,t.delegate=null,S;var l=o.arg;if(!l)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,S;if(l.done)t[e.resultName]=l.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=c);else return l;return t.delegate=null,S}et(M),v(M,g,"Generator"),v(M,h,function(){return this}),v(M,"toString",function(){return"[object Generator]"});function Et(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 F(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function J(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(Et,this),this.reset(!0)}n.keys=function(e){var t=Object(e),r=[];for(var s in t)r.push(s);return r.reverse(),function o(){for(;r.length;){var l=r.pop();if(l in t)return o.value=l,o.done=!1,o}return o.done=!0,o}};function x(e){if(e){var t=e[h];if(t)return t.call(e);if(typeof e.next=="function")return e;if(!isNaN(e.length)){var r=-1,s=function o(){for(;++r<e.length;)if(i.call(e,r))return o.value=e[r],o.done=!1,o;return o.value=c,o.done=!0,o};return s.next=s}}return{next:nt}}n.values=x;function nt(){return{value:c,done:!0}}return J.prototype={constructor:J,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(F),!e)for(var t in this)t.charAt(0)==="t"&&i.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,y){return l.type="throw",l.arg=e,t.next=b,y&&(t.method="next",t.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 m=i.call(o,"catchLoc"),d=i.call(o,"finallyLoc");if(m&&d){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(m){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else if(d){if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(e,t){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&&(e==="break"||e==="continue")&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var l=o?o.completion:{};return l.type=e,l.arg=t,o?(this.method="next",this.next=o.finallyLoc,S):this.complete(l)},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),F(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 s=r.completion;if(s.type==="throw"){var o=s.arg;F(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:x(e),resultName:t,nextLoc:r},this.method==="next"&&(this.arg=c),S}},n}(typeof X=="object"?X.exports:{});try{regeneratorRuntime=q}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=q:Function("r","regeneratorRuntime = r")(q)}});var f={};Nt(f,{Magic:()=>Tt});module.exports=Pt(f);var $t=R(lt()),mt=require("@magic-sdk/provider"),Dt=R(require("process")),dt=R(require("localforage")),Y=require("whatwg-url"),U=require("buffer"),yt=R(require("lodash")),gt=R(require("expo-application")),wt=require("@aveq-research/localforage-asyncstorage-driver"),Q=R(require("localforage-driver-memory"));var w=R(require("react")),ft=require("react-native"),ut=require("react-native-webview"),ht=require("react-native-safe-area-context"),W=require("@magic-sdk/provider"),pt=require("lodash");var kt="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function It(){return ft.StyleSheet.create({"magic-webview":{flex:1,backgroundColor:"transparent"},"webview-container":{flex:1,width:"100%",backgroundColor:"transparent",position:"absolute",top:0,left:0,right:0,bottom:0},show:{zIndex:1e4,elevation:1e4},hide:{zIndex:-1e4,elevation:0}})}var C=class extends W.ViewController{constructor(){super(...arguments);this.Relayer=()=>{let[i,p]=(0,w.useState)(!1),c=(0,w.useCallback)(_=>{this.webView=_},[]),E=(0,w.useCallback)(_=>{this.container=ct(st({},_),{showOverlay:h,hideOverlay:L})},[]),h=(0,w.useCallback)(()=>{p(!0)},[]),L=(0,w.useCallback)(()=>{p(!1)},[]),g=(0,w.useMemo)(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),v=(0,w.useCallback)(_=>{this.handleReactNativeWebViewMessage(_)},[]);return w.default.createElement(ht.SafeAreaView,{ref:E,style:g},w.default.createElement(ut.WebView,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:v,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1}))}}init(){this.webView=null,this.container=null,this.styles=It()}handleReactNativeWebViewMessage(i){var p;if(i.nativeEvent&&typeof i.nativeEvent.data=="string"&&(i.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||i.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(i.nativeEvent.data,(E,h)=>{try{if(h&&typeof h=="object"&&h.flag&&h.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return new global[h.constructor](h.data.split(","))}catch(L){}return h});if(c&&c.msgType&&this.messageHandlers.size){c.response=(p=c.response)!=null?p:{};let E={data:c};for(let h of this.messageHandlers.values())h(E)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return T(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(p,c)=>(0,pt.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:kt}:c),this.endpoint);else throw(0,W.createModalNotReadyError)()})}};var vt=require("@magic-sdk/provider"),j=class extends vt.SDKBase{get Relayer(){return this.overlay.Relayer}};u(f,require("@magic-sdk/commons"),module.exports);global.process=yt.merge(global.process,Dt);global.process.browser=!1;global.Buffer=U.Buffer;global.URL=Y.URL;global.URLSearchParams=Y.URLSearchParams;global.btoa=n=>U.Buffer.from(n,"binary").toString("base64");global.atob=n=>U.Buffer.from(n,"base64").toString("binary");var Tt=(0,mt.createSDK)(j,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"18.1.2",bundleId:gt.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:C,configureStorage:()=>T(void 0,null,function*(){let n=dt.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),a=(0,wt.driverWithoutSerialization)();return yield Promise.all([n.defineDriver(a),n.defineDriver(Q)]),yield n.setDriver([a._driver,Q._driver]),n})});0&&(module.exports={Magic});
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var ft=Object.create;var $=Object.defineProperty,ut=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,mt=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable;var Z=(o,s,i)=>s in o?$(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,et=(o,s)=>{for(var i in s||(s={}))tt.call(s,i)&&Z(o,i,s[i]);if(Q)for(var i of Q(s))dt.call(s,i)&&Z(o,i,s[i]);return o},rt=(o,s)=>ut(o,pt(s));var yt=(o,s)=>()=>(s||o((s={exports:{}}).exports,s),s.exports);var gt=(o,s,i,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of vt(s))!tt.call(o,c)&&c!==i&&$(o,c,{get:()=>s[c],enumerable:!(u=ht(s,c))||u.enumerable});return o};var wt=(o,s,i)=>(i=o!=null?ft(mt(o)):{},gt(s||!o||!o.__esModule?$(i,"default",{value:o,enumerable:!0}):i,o));var N=(o,s,i)=>new Promise((u,c)=>{var w=d=>{try{b(i.next(d))}catch(h){c(h)}},f=d=>{try{b(i.throw(d))}catch(h){c(h)}},b=d=>d.done?u(d.value):Promise.resolve(d.value).then(w,f);b((i=i.apply(o,s)).next())});var nt=yt((Wt,K)=>{var B=function(o){"use strict";var s=Object.prototype,i=s.hasOwnProperty,u=Object.defineProperty||function(e,t,r){e[t]=r.value},c,w=typeof Symbol=="function"?Symbol:{},f=w.iterator||"@@iterator",b=w.asyncIterator||"@@asyncIterator",d=w.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch{h=function(t,r,a){return t[r]=a}}function S(e,t,r,a){var n=t&&t.prototype instanceof D?t:D,l=Object.create(n.prototype),p=new j(a||[]);return u(l,"_invoke",{value:ct(e,r,p)}),l}o.wrap=S;function I(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(a){return{type:"throw",arg:a}}}var J="suspendedStart",st="suspendedYield",x="executing",R="completed",g={};function D(){}function M(){}function E(){}var T={};h(T,f,function(){return this});var C=Object.getPrototypeOf,G=C&&C(C(Y([])));G&&G!==s&&i.call(G,f)&&(T=G);var _=E.prototype=D.prototype=Object.create(T);M.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:M,configurable:!0}),M.displayName=h(E,d,"GeneratorFunction");function H(e){["next","throw","return"].forEach(function(t){h(e,t,function(r){return this._invoke(t,r)})})}o.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===M||(t.displayName||t.name)==="GeneratorFunction":!1},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,h(e,d,"GeneratorFunction")),e.prototype=Object.create(_),e},o.awrap=function(e){return{__await:e}};function V(e,t){function r(l,p,v,y){var m=I(e[l],e,p);if(m.type==="throw")y(m.arg);else{var U=m.arg,O=U.value;return O&&typeof O=="object"&&i.call(O,"__await")?t.resolve(O.__await).then(function(L){r("next",L,v,y)},function(L){r("throw",L,v,y)}):t.resolve(O).then(function(L){U.value=L,v(U)},function(L){return r("throw",L,v,y)})}}var a;function n(l,p){function v(){return new t(function(y,m){r(l,p,y,m)})}return a=a?a.then(v,v):v()}u(this,"_invoke",{value:n})}H(V.prototype),h(V.prototype,b,function(){return this}),o.AsyncIterator=V,o.async=function(e,t,r,a,n){n===void 0&&(n=Promise);var l=new V(S(e,t,r,a),n);return o.isGeneratorFunction(t)?l:l.next().then(function(p){return p.done?p.value:l.next()})};function ct(e,t,r){var a=J;return function(l,p){if(a===x)throw new Error("Generator is already running");if(a===R){if(l==="throw")throw p;return X()}for(r.method=l,r.arg=p;;){var v=r.delegate;if(v){var y=q(v,r);if(y){if(y===g)continue;return y}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(a===J)throw a=R,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=x;var m=I(e,t,r);if(m.type==="normal"){if(a=r.done?R:st,m.arg===g)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=R,r.method="throw",r.arg=m.arg)}}}function q(e,t){var r=t.method,a=e.iterator[r];if(a===c)return t.delegate=null,r==="throw"&&e.iterator.return&&(t.method="return",t.arg=c,q(e,t),t.method==="throw")||r!=="return"&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var n=I(a,e.iterator,t.arg);if(n.type==="throw")return t.method="throw",t.arg=n.arg,t.delegate=null,g;var l=n.arg;if(!l)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g;if(l.done)t[e.resultName]=l.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=c);else return l;return t.delegate=null,g}H(_),h(_,d,"Generator"),h(_,f,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function lt(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 W(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(lt,this),this.reset(!0)}o.keys=function(e){var t=Object(e),r=[];for(var a in t)r.push(a);return r.reverse(),function n(){for(;r.length;){var l=r.pop();if(l in t)return n.value=l,n.done=!1,n}return n.done=!0,n}};function Y(e){if(e){var t=e[f];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(i.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:X}}o.values=Y;function X(){return{value:c,done:!0}}return j.prototype={constructor:j,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(W),!e)for(var t in this)t.charAt(0)==="t"&&i.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,m){return l.type="throw",l.arg=e,t.next=y,m&&(t.method="next",t.arg=c),!!m}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(e,t){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&&(e==="break"||e==="continue")&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var l=n?n.completion:{};return l.type=e,l.arg=t,n?(this.method="next",this.next=n.finallyLoc,g):this.complete(l)},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),W(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;W(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:Y(e),resultName:t,nextLoc:r},this.method==="next"&&(this.arg=c),g}},o}(typeof K=="object"?K.exports:{});try{regeneratorRuntime=B}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=B:Function("r","regeneratorRuntime = r")(B)}});var Ht=wt(nt());import{createSDK as Nt}from"@magic-sdk/provider";import*as Pt from"process";import kt from"localforage";import{URL as It,URLSearchParams as Dt}from"whatwg-url";import{Buffer as z}from"buffer";import*as it from"lodash";import*as at from"expo-application";import{driverWithoutSerialization as Tt}from"@aveq-research/localforage-asyncstorage-driver";import*as F from"localforage-driver-memory";import ot,{useState as bt,useCallback as A,useMemo as St}from"react";import{StyleSheet as Et}from"react-native";import{WebView as Lt}from"react-native-webview";import{SafeAreaView as _t}from"react-native-safe-area-context";import{ViewController as Ot,createModalNotReadyError as At}from"@magic-sdk/provider";import{isTypedArray as Rt}from"lodash";var Mt="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function Gt(){return Et.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 Ot{constructor(){super(...arguments);this.Relayer=()=>{let[i,u]=bt(!1),c=A(S=>{this.webView=S},[]),w=A(S=>{this.container=rt(et({},S),{showOverlay:f,hideOverlay:b})},[]),f=A(()=>{u(!0)},[]),b=A(()=>{u(!1)},[]),d=St(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),h=A(S=>{this.handleReactNativeWebViewMessage(S)},[]);return ot.createElement(_t,{ref:w,style:d},ot.createElement(Lt,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:h,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1}))}}init(){this.webView=null,this.container=null,this.styles=Gt()}handleReactNativeWebViewMessage(i){var u;if(i.nativeEvent&&typeof i.nativeEvent.data=="string"&&(i.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||i.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(i.nativeEvent.data,(w,f)=>{try{if(f&&typeof f=="object"&&f.flag&&f.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return new global[f.constructor](f.data.split(","))}catch(b){}return f});if(c&&c.msgType&&this.messageHandlers.size){c.response=(u=c.response)!=null?u:{};let w={data:c};for(let f of this.messageHandlers.values())f(w)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return N(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(u,c)=>Rt(c)?{constructor:c.constructor.name,data:c.toString(),flag:Mt}:c),this.endpoint);else throw At()})}};import{SDKBase as Vt}from"@magic-sdk/provider";var k=class extends Vt{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=it.merge(global.process,Pt);global.process.browser=!1;global.Buffer=z;global.URL=It;global.URLSearchParams=Dt;global.btoa=o=>z.from(o,"binary").toString("base64");global.atob=o=>z.from(o,"base64").toString("binary");var ie=Nt(k,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"18.1.1",bundleId:at.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:P,configureStorage:()=>N(void 0,null,function*(){let o=kt.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Tt();return yield Promise.all([o.defineDriver(s),o.defineDriver(F)]),yield o.setDriver([s._driver,F._driver]),o})});export{ie as Magic};
|
1
|
+
var ft=Object.create;var $=Object.defineProperty,ut=Object.defineProperties,ht=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,mt=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable;var Z=(o,s,i)=>s in o?$(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,et=(o,s)=>{for(var i in s||(s={}))tt.call(s,i)&&Z(o,i,s[i]);if(Q)for(var i of Q(s))dt.call(s,i)&&Z(o,i,s[i]);return o},rt=(o,s)=>ut(o,pt(s));var yt=(o,s)=>()=>(s||o((s={exports:{}}).exports,s),s.exports);var gt=(o,s,i,u)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of vt(s))!tt.call(o,c)&&c!==i&&$(o,c,{get:()=>s[c],enumerable:!(u=ht(s,c))||u.enumerable});return o};var wt=(o,s,i)=>(i=o!=null?ft(mt(o)):{},gt(s||!o||!o.__esModule?$(i,"default",{value:o,enumerable:!0}):i,o));var N=(o,s,i)=>new Promise((u,c)=>{var w=d=>{try{b(i.next(d))}catch(h){c(h)}},f=d=>{try{b(i.throw(d))}catch(h){c(h)}},b=d=>d.done?u(d.value):Promise.resolve(d.value).then(w,f);b((i=i.apply(o,s)).next())});var nt=yt((Wt,K)=>{var B=function(o){"use strict";var s=Object.prototype,i=s.hasOwnProperty,u=Object.defineProperty||function(e,t,r){e[t]=r.value},c,w=typeof Symbol=="function"?Symbol:{},f=w.iterator||"@@iterator",b=w.asyncIterator||"@@asyncIterator",d=w.toStringTag||"@@toStringTag";function h(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch{h=function(t,r,a){return t[r]=a}}function S(e,t,r,a){var n=t&&t.prototype instanceof D?t:D,l=Object.create(n.prototype),p=new j(a||[]);return u(l,"_invoke",{value:ct(e,r,p)}),l}o.wrap=S;function I(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(a){return{type:"throw",arg:a}}}var J="suspendedStart",st="suspendedYield",x="executing",R="completed",g={};function D(){}function M(){}function E(){}var T={};h(T,f,function(){return this});var C=Object.getPrototypeOf,G=C&&C(C(Y([])));G&&G!==s&&i.call(G,f)&&(T=G);var _=E.prototype=D.prototype=Object.create(T);M.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:M,configurable:!0}),M.displayName=h(E,d,"GeneratorFunction");function H(e){["next","throw","return"].forEach(function(t){h(e,t,function(r){return this._invoke(t,r)})})}o.isGeneratorFunction=function(e){var t=typeof e=="function"&&e.constructor;return t?t===M||(t.displayName||t.name)==="GeneratorFunction":!1},o.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,h(e,d,"GeneratorFunction")),e.prototype=Object.create(_),e},o.awrap=function(e){return{__await:e}};function V(e,t){function r(l,p,v,y){var m=I(e[l],e,p);if(m.type==="throw")y(m.arg);else{var U=m.arg,O=U.value;return O&&typeof O=="object"&&i.call(O,"__await")?t.resolve(O.__await).then(function(L){r("next",L,v,y)},function(L){r("throw",L,v,y)}):t.resolve(O).then(function(L){U.value=L,v(U)},function(L){return r("throw",L,v,y)})}}var a;function n(l,p){function v(){return new t(function(y,m){r(l,p,y,m)})}return a=a?a.then(v,v):v()}u(this,"_invoke",{value:n})}H(V.prototype),h(V.prototype,b,function(){return this}),o.AsyncIterator=V,o.async=function(e,t,r,a,n){n===void 0&&(n=Promise);var l=new V(S(e,t,r,a),n);return o.isGeneratorFunction(t)?l:l.next().then(function(p){return p.done?p.value:l.next()})};function ct(e,t,r){var a=J;return function(l,p){if(a===x)throw new Error("Generator is already running");if(a===R){if(l==="throw")throw p;return X()}for(r.method=l,r.arg=p;;){var v=r.delegate;if(v){var y=q(v,r);if(y){if(y===g)continue;return y}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(a===J)throw a=R,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);a=x;var m=I(e,t,r);if(m.type==="normal"){if(a=r.done?R:st,m.arg===g)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=R,r.method="throw",r.arg=m.arg)}}}function q(e,t){var r=t.method,a=e.iterator[r];if(a===c)return t.delegate=null,r==="throw"&&e.iterator.return&&(t.method="return",t.arg=c,q(e,t),t.method==="throw")||r!=="return"&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var n=I(a,e.iterator,t.arg);if(n.type==="throw")return t.method="throw",t.arg=n.arg,t.delegate=null,g;var l=n.arg;if(!l)return t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g;if(l.done)t[e.resultName]=l.value,t.next=e.nextLoc,t.method!=="return"&&(t.method="next",t.arg=c);else return l;return t.delegate=null,g}H(_),h(_,d,"Generator"),h(_,f,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function lt(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 W(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(lt,this),this.reset(!0)}o.keys=function(e){var t=Object(e),r=[];for(var a in t)r.push(a);return r.reverse(),function n(){for(;r.length;){var l=r.pop();if(l in t)return n.value=l,n.done=!1,n}return n.done=!0,n}};function Y(e){if(e){var t=e[f];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(i.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:X}}o.values=Y;function X(){return{value:c,done:!0}}return j.prototype={constructor:j,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(W),!e)for(var t in this)t.charAt(0)==="t"&&i.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,m){return l.type="throw",l.arg=e,t.next=y,m&&(t.method="next",t.arg=c),!!m}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(e,t){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&&(e==="break"||e==="continue")&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var l=n?n.completion:{};return l.type=e,l.arg=t,n?(this.method="next",this.next=n.finallyLoc,g):this.complete(l)},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),W(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;W(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:Y(e),resultName:t,nextLoc:r},this.method==="next"&&(this.arg=c),g}},o}(typeof K=="object"?K.exports:{});try{regeneratorRuntime=B}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=B:Function("r","regeneratorRuntime = r")(B)}});var Ht=wt(nt());import{createSDK as Nt}from"@magic-sdk/provider";import*as Pt from"process";import kt from"localforage";import{URL as It,URLSearchParams as Dt}from"whatwg-url";import{Buffer as z}from"buffer";import*as it from"lodash";import*as at from"expo-application";import{driverWithoutSerialization as Tt}from"@aveq-research/localforage-asyncstorage-driver";import*as F from"localforage-driver-memory";import ot,{useState as bt,useCallback as A,useMemo as St}from"react";import{StyleSheet as Et}from"react-native";import{WebView as Lt}from"react-native-webview";import{SafeAreaView as _t}from"react-native-safe-area-context";import{ViewController as Ot,createModalNotReadyError as At}from"@magic-sdk/provider";import{isTypedArray as Rt}from"lodash";var Mt="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY";function Gt(){return Et.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 Ot{constructor(){super(...arguments);this.Relayer=()=>{let[i,u]=bt(!1),c=A(S=>{this.webView=S},[]),w=A(S=>{this.container=rt(et({},S),{showOverlay:f,hideOverlay:b})},[]),f=A(()=>{u(!0)},[]),b=A(()=>{u(!1)},[]),d=St(()=>[this.styles["webview-container"],i?this.styles.show:this.styles.hide],[i]),h=A(S=>{this.handleReactNativeWebViewMessage(S)},[]);return ot.createElement(_t,{ref:w,style:d},ot.createElement(Lt,{ref:c,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:h,style:this.styles["magic-webview"],autoManageStatusBarEnabled:!1}))}}init(){this.webView=null,this.container=null,this.styles=Gt()}handleReactNativeWebViewMessage(i){var u;if(i.nativeEvent&&typeof i.nativeEvent.data=="string"&&(i.nativeEvent.url===`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`||i.nativeEvent.url===`${this.endpoint}/send/?params=${this.parameters}`)){let c=JSON.parse(i.nativeEvent.data,(w,f)=>{try{if(f&&typeof f=="object"&&f.flag&&f.flag==="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY")return new global[f.constructor](f.data.split(","))}catch(b){}return f});if(c&&c.msgType&&this.messageHandlers.size){c.response=(u=c.response)!=null?u:{};let w={data:c};for(let f of this.messageHandlers.values())f(w)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return N(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(u,c)=>Rt(c)?{constructor:c.constructor.name,data:c.toString(),flag:Mt}:c),this.endpoint);else throw At()})}};import{SDKBase as Vt}from"@magic-sdk/provider";var k=class extends Vt{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";global.process=it.merge(global.process,Pt);global.process.browser=!1;global.Buffer=z;global.URL=It;global.URLSearchParams=Dt;global.btoa=o=>z.from(o,"binary").toString("base64");global.atob=o=>z.from(o,"base64").toString("binary");var ie=Nt(k,{platform:"react-native",sdkName:"@magic-sdk/react-native-expo",version:"18.1.2",bundleId:at.applicationId,defaultEndpoint:"https://box.magic.link/",ViewController:P,configureStorage:()=>N(void 0,null,function*(){let o=kt.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Tt();return yield Promise.all([o.defineDriver(s),o.defineDriver(F)]),yield o.setDriver([s._driver,F._driver]),o})});export{ie 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-expo",
|
3
|
-
"version": "18.1.2
|
3
|
+
"version": "18.1.2",
|
4
4
|
"description": "Passwordless authentication for React Native (Expo).",
|
5
5
|
"author": "Magic Labs <team@magic.link> (https://magic.link/)",
|
6
6
|
"license": "MIT",
|
@@ -18,9 +18,9 @@
|
|
18
18
|
"types": "./dist/types/index.d.ts",
|
19
19
|
"dependencies": {
|
20
20
|
"@aveq-research/localforage-asyncstorage-driver": "^3.0.1",
|
21
|
-
"@magic-sdk/commons": "13.1.2
|
22
|
-
"@magic-sdk/provider": "17.1.2
|
23
|
-
"@magic-sdk/types": "15.1.2
|
21
|
+
"@magic-sdk/commons": "^13.1.2",
|
22
|
+
"@magic-sdk/provider": "^17.1.2",
|
23
|
+
"@magic-sdk/types": "^15.1.2",
|
24
24
|
"@react-native-async-storage/async-storage": "^1.15.5",
|
25
25
|
"@types/lodash": "^4.14.158",
|
26
26
|
"buffer": "~5.6.0",
|
@@ -50,5 +50,5 @@
|
|
50
50
|
"react-native-safe-area-context": ">=4.4.1",
|
51
51
|
"react-native-webview": ">=11.0.0"
|
52
52
|
},
|
53
|
-
"gitHead": "
|
53
|
+
"gitHead": "1609b16b343c0567328982fb57091dbe3b7e43c2"
|
54
54
|
}
|