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