@magic-sdk/react-native-bare 22.3.0-canary.8e76cc6.0 → 22.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -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,25 @@
|
|
1
|
+
# v22.3.0 (Mon Nov 20 2023)
|
2
|
+
|
3
|
+
#### 🚀 Enhancement
|
4
|
+
|
5
|
+
- Add `useInternetConnection` hook to track internet connectivity changes [#665](https://github.com/magiclabs/magic-js/pull/665) ([@romin-halltari](https://github.com/romin-halltari))
|
6
|
+
|
7
|
+
#### 🐛 Bug Fix
|
8
|
+
|
9
|
+
- Use createModalNotReadyError() when modal is not ready on react native ([@romin-halltari](https://github.com/romin-halltari))
|
10
|
+
- Update readme ([@romin-halltari](https://github.com/romin-halltari))
|
11
|
+
- Merge branch 'master' into rominhalltari-sc-75722-react-native-sdk-add-support-for-general ([@romin-halltari](https://github.com/romin-halltari))
|
12
|
+
- Remove unnecessary comments ([@romin-halltari](https://github.com/romin-halltari))
|
13
|
+
- Setup hook testing on @magic/sdk/react-native-bare ([@romin-halltari](https://github.com/romin-halltari))
|
14
|
+
- Update readme with installation step for @react-native-community/netinfo ([@romin-halltari](https://github.com/romin-halltari))
|
15
|
+
- Add `useInternetConnection` hook to track internet connectivity changes ([@romin-halltari](https://github.com/romin-halltari))
|
16
|
+
|
17
|
+
#### Authors: 1
|
18
|
+
|
19
|
+
- [@romin-halltari](https://github.com/romin-halltari)
|
20
|
+
|
21
|
+
---
|
22
|
+
|
1
23
|
# v22.2.2 (Tue Nov 14 2023)
|
2
24
|
|
3
25
|
#### 🐛 Bug Fix
|
package/dist/cjs/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var Ie=Object.create;var M=Object.defineProperty,Ne=Object.defineProperties,Ae=Object.getOwnPropertyDescriptor,Me=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols,Ge=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var ue=(n,a,i)=>a in n?M(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,Z=(n,a)=>{for(var i in a||(a={}))le.call(a,i)&&ue(n,i,a[i]);if(fe)for(var i of fe(a))Ce.call(a,i)&&ue(n,i,a[i]);return n},ee=(n,a)=>Ne(n,Me(a));var Pe=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports),De=(n,a)=>{for(var i in a)M(n,i,{get:a[i],enumerable:!0})},k=(n,a,i,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Ve(a))!le.call(n,c)&&c!==i&&M(n,c,{get:()=>a[c],enumerable:!(h=Ae(a,c))||h.enumerable});return n},l=(n,a,i)=>(k(n,a,"default"),i&&k(i,a,"default")),I=(n,a,i)=>(i=n!=null?Ie(Ge(n)):{},k(a||!n||!n.__esModule?M(i,"default",{value:n,enumerable:!0}):i,n)),ke=n=>k(M({},"__esModule",{value:!0}),n);var T=(n,a,i)=>new Promise((h,c)=>{var L=g=>{try{_(i.next(g))}catch(v){c(v)}},p=g=>{try{_(i.throw(g))}catch(v){c(v)}},_=g=>g.done?h(g.value):Promise.resolve(g.value).then(L,p);_((i=i.apply(n,a)).next())});var he=Pe((Ye,re)=>{var te=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,h=Object.defineProperty||function(t,e,r){t[e]=r.value},c,L=typeof Symbol=="function"?Symbol:{},p=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 V(t,e,r,s){var o=e&&e.prototype instanceof q?e:q,f=Object.create(o.prototype),m=new H(s||[]);return h(f,"_invoke",{value:Oe(t,r,m)}),f}n.wrap=V;function b(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(s){return{type:"throw",arg:s}}}var $="suspendedStart",oe="suspendedYield",ie="executing",G="completed",E={};function q(){}function C(){}function O(){}var z={};v(z,p,function(){return this});var x=Object.getPrototypeOf,P=x&&x(x(Q([])));P&&P!==a&&i.call(P,p)&&(z=P);var N=O.prototype=q.prototype=Object.create(z);C.prototype=O,h(N,"constructor",{value:O,configurable:!0}),h(O,"constructor",{value:C,configurable:!0}),C.displayName=v(O,g,"GeneratorFunction");function ae(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===C||(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(N),t},n.awrap=function(t){return{__await:t}};function D(t,e){function r(f,m,d,S){var y=b(t[f],t,m);if(y.type==="throw")S(y.arg);else{var X=y.arg,A=X.value;return A&&typeof A=="object"&&i.call(A,"__await")?e.resolve(A.__await).then(function(R){r("next",R,d,S)},function(R){r("throw",R,d,S)}):e.resolve(A).then(function(R){X.value=R,d(X)},function(R){return r("throw",R,d,S)})}}var s;function o(f,m){function d(){return new e(function(S,y){r(f,m,S,y)})}return s=s?s.then(d,d):d()}h(this,"_invoke",{value:o})}ae(D.prototype),v(D.prototype,_,function(){return this}),n.AsyncIterator=D,n.async=function(t,e,r,s,o){o===void 0&&(o=Promise);var f=new D(V(t,e,r,s),o);return n.isGeneratorFunction(e)?f:f.next().then(function(m){return m.done?m.value:f.next()})};function Oe(t,e,r){var s=$;return function(f,m){if(s===ie)throw new Error("Generator is already running");if(s===G){if(f==="throw")throw m;return ce()}for(r.method=f,r.arg=m;;){var d=r.delegate;if(d){var S=se(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===$)throw s=G,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=ie;var y=b(t,e,r);if(y.type==="normal"){if(s=r.done?G:oe,y.arg===E)continue;return{value:y.arg,done:r.done}}else y.type==="throw"&&(s=G,r.method="throw",r.arg=y.arg)}}}function se(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,se(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 f=o.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,E;if(f.done)e[t.resultName]=f.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=c);else return f;return e.delegate=null,E}ae(N),v(N,g,"Generator"),v(N,p,function(){return this}),v(N,"toString",function(){return"[object Generator]"});function Re(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(Re,this),this.reset(!0)}n.keys=function(t){var e=Object(t),r=[];for(var s in e)r.push(s);return r.reverse(),function o(){for(;r.length;){var f=r.pop();if(f in e)return o.value=f,o.done=!1,o}return o.done=!0,o}};function Q(t){if(t){var e=t[p];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:ce}}n.values=Q;function ce(){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 f.type="throw",f.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],f=o.completion;if(o.tryLoc==="root")return r("end");if(o.tryLoc<=this.prev){var m=i.call(o,"catchLoc"),d=i.call(o,"finallyLoc");if(m&&d){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(m){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else if(d){if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var s=this.tryEntries[r];if(s.tryLoc<=this.prev&&i.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var o=s;break}}o&&(t==="break"||t==="continue")&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var f=o?o.completion:{};return f.type=t,f.arg=e,o?(this.method="next",this.next=o.finallyLoc,E):this.complete(f)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),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:Q(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),E}},n}(typeof re=="object"?re.exports:{});try{regeneratorRuntime=te}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=te:Function("r","regeneratorRuntime = r")(te)}});var u={};De(u,{Magic:()=>Ue,useInternetConnection:()=>we});module.exports=ke(u);var Je=I(he()),be=require("@magic-sdk/provider"),Be=I(require("process")),Se=I(require("localforage")),Y=require("whatwg-url"),K=require("buffer"),Ee=I(require("lodash")),Le=require("react-native-device-info"),_e=require("@aveq-research/localforage-asyncstorage-driver"),ne=I(require("localforage-driver-memory"));var w=I(require("react")),j=require("react-native"),ve=require("react-native-webview"),me=require("react-native-safe-area-context"),B=require("@magic-sdk/provider"),de=require("lodash");var pe="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Te="open_in_device_browser",We="#FFFFFF";function je(){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[h,c]=(0,w.useState)(!1),L=(0,w.useCallback)(b=>{this.webView=b},[]),p=(0,w.useCallback)(b=>{this.container=ee(Z({},b),{showOverlay:_,hideOverlay:g})},[]),_=(0,w.useCallback)(()=>{c(!0)},[]),g=(0,w.useCallback)(()=>{c(!1)},[]),v=(0,w.useMemo)(()=>[this.styles["webview-container"],h?ee(Z({},this.styles.show),{backgroundColor:i!=null?i:We}):this.styles.hide],[h]),V=(0,w.useCallback)(b=>{this.handleReactNativeWebViewMessage(b)},[]);return w.default.createElement(me.SafeAreaView,{ref:p,style:v},w.default.createElement(ve.WebView,{ref:L,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:V,style:this.styles["magic-webview"],webviewDebuggingEnabled:!0,autoManageStatusBarEnabled:!1,onShouldStartLoadWithRequest:b=>new URLSearchParams(b.url.split("?")[1]).get(Te)?(j.Linking.openURL(b.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=je()}handleReactNativeWebViewMessage(i){var h;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,p)=>{try{if(p&&typeof p=="object"&&p.flag&&p.flag===pe)return new global[p.constructor](p.data.split(","))}catch(_){}return p});if(c&&c.msgType&&this.messageHandlers.size){c.response=(h=c.response)!=null?h:{};let L={data:c};for(let p of this.messageHandlers.values())p(L)}}}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,(h,c)=>(0,de.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:pe}:c),this.endpoint);else throw(0,B.createModalNotReadyError)()})}};var ye=require("@magic-sdk/provider"),U=class extends ye.SDKBase{get Relayer(){return this.overlay.Relayer}};l(u,require("@magic-sdk/commons"),module.exports);var F=require("react"),ge=I(require("@react-native-community/netinfo")),we=()=>{let[n,a]=(0,F.useState)(!0);return(0,F.useEffect)(()=>{let i=h=>{a(!!h.isConnected)};return ge.default.addEventListener(i)},[]),n};global.process=Ee.merge(global.process,Be);global.process.browser=!1;global.Buffer=K.Buffer;global.URL=Y.URL;global.URLSearchParams=Y.URLSearchParams;global.btoa=n=>K.Buffer.from(n,"binary").toString("base64");global.atob=n=>K.Buffer.from(n,"base64").toString("binary");var Ue=(0,be.createSDK)(U,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"22.2.2",bundleId:(0,Le.getBundleId)(),defaultEndpoint:"https://box.magic.link/",ViewController:W,configureStorage:()=>T(void 0,null,function*(){let n=Se.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),a=(0,_e.driverWithoutSerialization)();return yield Promise.all([n.defineDriver(a),n.defineDriver(ne)]),yield n.setDriver([a._driver,ne._driver]),n})});0&&(module.exports={Magic,useInternetConnection});
|
1
|
+
"use strict";var Ie=Object.create;var M=Object.defineProperty,Ne=Object.defineProperties,Ae=Object.getOwnPropertyDescriptor,Me=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols,Ge=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var ue=(n,a,i)=>a in n?M(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,Z=(n,a)=>{for(var i in a||(a={}))le.call(a,i)&&ue(n,i,a[i]);if(fe)for(var i of fe(a))Ce.call(a,i)&&ue(n,i,a[i]);return n},ee=(n,a)=>Ne(n,Me(a));var Pe=(n,a)=>()=>(a||n((a={exports:{}}).exports,a),a.exports),De=(n,a)=>{for(var i in a)M(n,i,{get:a[i],enumerable:!0})},k=(n,a,i,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let c of Ve(a))!le.call(n,c)&&c!==i&&M(n,c,{get:()=>a[c],enumerable:!(h=Ae(a,c))||h.enumerable});return n},l=(n,a,i)=>(k(n,a,"default"),i&&k(i,a,"default")),I=(n,a,i)=>(i=n!=null?Ie(Ge(n)):{},k(a||!n||!n.__esModule?M(i,"default",{value:n,enumerable:!0}):i,n)),ke=n=>k(M({},"__esModule",{value:!0}),n);var T=(n,a,i)=>new Promise((h,c)=>{var L=g=>{try{_(i.next(g))}catch(v){c(v)}},p=g=>{try{_(i.throw(g))}catch(v){c(v)}},_=g=>g.done?h(g.value):Promise.resolve(g.value).then(L,p);_((i=i.apply(n,a)).next())});var he=Pe((Ye,re)=>{var te=function(n){"use strict";var a=Object.prototype,i=a.hasOwnProperty,h=Object.defineProperty||function(t,e,r){t[e]=r.value},c,L=typeof Symbol=="function"?Symbol:{},p=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 V(t,e,r,s){var o=e&&e.prototype instanceof q?e:q,f=Object.create(o.prototype),m=new H(s||[]);return h(f,"_invoke",{value:Oe(t,r,m)}),f}n.wrap=V;function b(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(s){return{type:"throw",arg:s}}}var $="suspendedStart",oe="suspendedYield",ie="executing",G="completed",E={};function q(){}function C(){}function O(){}var z={};v(z,p,function(){return this});var x=Object.getPrototypeOf,P=x&&x(x(Q([])));P&&P!==a&&i.call(P,p)&&(z=P);var N=O.prototype=q.prototype=Object.create(z);C.prototype=O,h(N,"constructor",{value:O,configurable:!0}),h(O,"constructor",{value:C,configurable:!0}),C.displayName=v(O,g,"GeneratorFunction");function ae(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===C||(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(N),t},n.awrap=function(t){return{__await:t}};function D(t,e){function r(f,m,d,S){var y=b(t[f],t,m);if(y.type==="throw")S(y.arg);else{var X=y.arg,A=X.value;return A&&typeof A=="object"&&i.call(A,"__await")?e.resolve(A.__await).then(function(R){r("next",R,d,S)},function(R){r("throw",R,d,S)}):e.resolve(A).then(function(R){X.value=R,d(X)},function(R){return r("throw",R,d,S)})}}var s;function o(f,m){function d(){return new e(function(S,y){r(f,m,S,y)})}return s=s?s.then(d,d):d()}h(this,"_invoke",{value:o})}ae(D.prototype),v(D.prototype,_,function(){return this}),n.AsyncIterator=D,n.async=function(t,e,r,s,o){o===void 0&&(o=Promise);var f=new D(V(t,e,r,s),o);return n.isGeneratorFunction(e)?f:f.next().then(function(m){return m.done?m.value:f.next()})};function Oe(t,e,r){var s=$;return function(f,m){if(s===ie)throw new Error("Generator is already running");if(s===G){if(f==="throw")throw m;return ce()}for(r.method=f,r.arg=m;;){var d=r.delegate;if(d){var S=se(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===$)throw s=G,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);s=ie;var y=b(t,e,r);if(y.type==="normal"){if(s=r.done?G:oe,y.arg===E)continue;return{value:y.arg,done:r.done}}else y.type==="throw"&&(s=G,r.method="throw",r.arg=y.arg)}}}function se(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,se(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 f=o.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,E;if(f.done)e[t.resultName]=f.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=c);else return f;return e.delegate=null,E}ae(N),v(N,g,"Generator"),v(N,p,function(){return this}),v(N,"toString",function(){return"[object Generator]"});function Re(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(Re,this),this.reset(!0)}n.keys=function(t){var e=Object(t),r=[];for(var s in e)r.push(s);return r.reverse(),function o(){for(;r.length;){var f=r.pop();if(f in e)return o.value=f,o.done=!1,o}return o.done=!0,o}};function Q(t){if(t){var e=t[p];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:ce}}n.values=Q;function ce(){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 f.type="throw",f.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],f=o.completion;if(o.tryLoc==="root")return r("end");if(o.tryLoc<=this.prev){var m=i.call(o,"catchLoc"),d=i.call(o,"finallyLoc");if(m&&d){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(m){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else if(d){if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var s=this.tryEntries[r];if(s.tryLoc<=this.prev&&i.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var o=s;break}}o&&(t==="break"||t==="continue")&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var f=o?o.completion:{};return f.type=t,f.arg=e,o?(this.method="next",this.next=o.finallyLoc,E):this.complete(f)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),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:Q(t),resultName:e,nextLoc:r},this.method==="next"&&(this.arg=c),E}},n}(typeof re=="object"?re.exports:{});try{regeneratorRuntime=te}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=te:Function("r","regeneratorRuntime = r")(te)}});var u={};De(u,{Magic:()=>Ue,useInternetConnection:()=>we});module.exports=ke(u);var Je=I(he()),be=require("@magic-sdk/provider"),Be=I(require("process")),Se=I(require("localforage")),Y=require("whatwg-url"),K=require("buffer"),Ee=I(require("lodash")),Le=require("react-native-device-info"),_e=require("@aveq-research/localforage-asyncstorage-driver"),ne=I(require("localforage-driver-memory"));var w=I(require("react")),j=require("react-native"),ve=require("react-native-webview"),me=require("react-native-safe-area-context"),B=require("@magic-sdk/provider"),de=require("lodash");var pe="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Te="open_in_device_browser",We="#FFFFFF";function je(){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[h,c]=(0,w.useState)(!1),L=(0,w.useCallback)(b=>{this.webView=b},[]),p=(0,w.useCallback)(b=>{this.container=ee(Z({},b),{showOverlay:_,hideOverlay:g})},[]),_=(0,w.useCallback)(()=>{c(!0)},[]),g=(0,w.useCallback)(()=>{c(!1)},[]),v=(0,w.useMemo)(()=>[this.styles["webview-container"],h?ee(Z({},this.styles.show),{backgroundColor:i!=null?i:We}):this.styles.hide],[h]),V=(0,w.useCallback)(b=>{this.handleReactNativeWebViewMessage(b)},[]);return w.default.createElement(me.SafeAreaView,{ref:p,style:v},w.default.createElement(ve.WebView,{ref:L,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:V,style:this.styles["magic-webview"],webviewDebuggingEnabled:!0,autoManageStatusBarEnabled:!1,onShouldStartLoadWithRequest:b=>new URLSearchParams(b.url.split("?")[1]).get(Te)?(j.Linking.openURL(b.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=je()}handleReactNativeWebViewMessage(i){var h;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,p)=>{try{if(p&&typeof p=="object"&&p.flag&&p.flag===pe)return new global[p.constructor](p.data.split(","))}catch(_){}return p});if(c&&c.msgType&&this.messageHandlers.size){c.response=(h=c.response)!=null?h:{};let L={data:c};for(let p of this.messageHandlers.values())p(L)}}}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,(h,c)=>(0,de.isTypedArray)(c)?{constructor:c.constructor.name,data:c.toString(),flag:pe}:c),this.endpoint);else throw(0,B.createModalNotReadyError)()})}};var ye=require("@magic-sdk/provider"),U=class extends ye.SDKBase{get Relayer(){return this.overlay.Relayer}};l(u,require("@magic-sdk/commons"),module.exports);var F=require("react"),ge=I(require("@react-native-community/netinfo")),we=()=>{let[n,a]=(0,F.useState)(!0);return(0,F.useEffect)(()=>{let i=h=>{a(!!h.isConnected)};return ge.default.addEventListener(i)},[]),n};global.process=Ee.merge(global.process,Be);global.process.browser=!1;global.Buffer=K.Buffer;global.URL=Y.URL;global.URLSearchParams=Y.URLSearchParams;global.btoa=n=>K.Buffer.from(n,"binary").toString("base64");global.atob=n=>K.Buffer.from(n,"base64").toString("binary");var Ue=(0,be.createSDK)(U,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"22.3.0",bundleId:(0,Le.getBundleId)(),defaultEndpoint:"https://box.magic.link/",ViewController:W,configureStorage:()=>T(void 0,null,function*(){let n=Se.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),a=(0,_e.driverWithoutSerialization)();return yield Promise.all([n.defineDriver(a),n.defineDriver(ne)]),yield n.setDriver([a._driver,ne._driver]),n})});0&&(module.exports={Magic,useInternetConnection});
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var ue=Object.create;var Y=Object.defineProperty,le=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)=>le(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?ue(me(o)):{},ge(s||!o||!o.__esModule?Y(i,"default",{value:o,enumerable:!0}):i,o));var G=(o,s,i)=>new Promise((u,c)=>{var b=d=>{try{S(i.next(d))}catch(h){c(h)}},l=d=>{try{S(i.throw(d))}catch(h){c(h)}},S=d=>d.done?u(d.value):Promise.resolve(d.value).then(b,l);S((i=i.apply(o,s)).next())});var oe=ye(($e,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:{},l=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 I(t,e,r,a){var n=e&&e.prototype instanceof k?e:k,f=Object.create(n.prototype),p=new B(a||[]);return u(f,"_invoke",{value:ce(t,r,p)}),f}o.wrap=I;function y(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(a){return{type:"throw",arg:a}}}var D="suspendedStart",H="suspendedYield",Q="executing",N="completed",w={};function k(){}function A(){}function E(){}var T={};h(T,l,function(){return this});var W=Object.getPrototypeOf,M=W&&W(W(U([])));M&&M!==s&&i.call(M,l)&&(T=M);var _=E.prototype=k.prototype=Object.create(T);A.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:A,configurable:!0}),A.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===A||(e.displayName||e.name)==="GeneratorFunction":!1},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,E):(t.__proto__=E,h(t,d,"GeneratorFunction")),t.prototype=Object.create(_),t},o.awrap=function(t){return{__await:t}};function V(t,e){function r(f,p,v,g){var m=y(t[f],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(f,p){function v(){return new e(function(g,m){r(f,p,g,m)})}return a=a?a.then(v,v):v()}u(this,"_invoke",{value:n})}X(V.prototype),h(V.prototype,S,function(){return this}),o.AsyncIterator=V,o.async=function(t,e,r,a,n){n===void 0&&(n=Promise);var f=new V(I(t,e,r,a),n);return o.isGeneratorFunction(e)?f:f.next().then(function(p){return p.done?p.value:f.next()})};function ce(t,e,r){var a=D;return function(f,p){if(a===Q)throw new Error("Generator is already running");if(a===N){if(f==="throw")throw p;return ee()}for(r.method=f,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===D)throw a=N,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?N:H,m.arg===w)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=N,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 f=n.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,w;if(f.done)e[t.resultName]=f.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=c);else return f;return e.delegate=null,w}X(_),h(_,d,"Generator"),h(_,l,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function fe(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(fe,this),this.reset(!0)}o.keys=function(t){var e=Object(t),r=[];for(var a in e)r.push(a);return r.reverse(),function n(){for(;r.length;){var f=r.pop();if(f in e)return n.value=f,n.done=!1,n}return n.done=!0,n}};function U(t){if(t){var e=t[l];if(e)return e.call(t);if(typeof t.next=="function")return t;if(!isNaN(t.length)){var r=-1,a=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=c,n.done=!0,n};return a.next=a}}return{next: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 f.type="throw",f.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],f=n.completion;if(n.tryLoc==="root")return r("end");if(n.tryLoc<=this.prev){var p=i.call(n,"catchLoc"),v=i.call(n,"finallyLoc");if(p&&v){if(this.prev<n.catchLoc)return r(n.catchLoc,!0);if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else if(p){if(this.prev<n.catchLoc)return r(n.catchLoc,!0)}else if(v){if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&i.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var n=a;break}}n&&(t==="break"||t==="continue")&&n.tryLoc<=e&&e<=n.finallyLoc&&(n=null);var f=n?n.completion:{};return f.type=t,f.arg=e,n?(this.method="next",this.next=n.finallyLoc,w):this.complete(f)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),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 at=we(oe());import{createSDK as Te}from"@magic-sdk/provider";import*as We from"process";import je from"localforage";import{URL as Be,URLSearchParams as Ue}from"whatwg-url";import{Buffer as x}from"buffer";import*as se from"lodash";import{getBundleId as Fe}from"react-native-device-info";import{driverWithoutSerialization as Ye}from"@aveq-research/localforage-asyncstorage-driver";import*as J 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 Ie}from"@magic-sdk/provider";import{isTypedArray as Ne}from"lodash";var ae="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Ae="open_in_device_browser",Me="#FFFFFF";function Ve(){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 C=class extends Re{constructor(){super(...arguments);this.Relayer=i=>{let[u,c]=be(!1),b=R(y=>{this.webView=y},[]),l=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:Me}):this.styles.hide],[u]),I=R(y=>{this.handleReactNativeWebViewMessage(y)},[]);return ie.createElement(Oe,{ref:l,style:h},ie.createElement(_e,{ref:b,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:I,style:this.styles["magic-webview"],webviewDebuggingEnabled:!0,autoManageStatusBarEnabled:!1,onShouldStartLoadWithRequest:y=>new URLSearchParams(y.url.split("?")[1]).get(Ae)?(Ee.openURL(y.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=Ve()}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,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag===ae)return new global[l.constructor](l.data.split(","))}catch(S){}return l});if(c&&c.msgType&&this.messageHandlers.size){c.response=(u=c.response)!=null?u:{};let b={data:c};for(let l of this.messageHandlers.values())l(b)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return G(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(u,c)=>Ne(c)?{constructor:c.constructor.name,data:c.toString(),flag:ae}:c),this.endpoint);else throw Ie()})}};import{SDKBase as Ge}from"@magic-sdk/provider";var P=class extends Ge{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";import{useEffect as Ce,useState as Pe}from"react";import De from"@react-native-community/netinfo";var ke=()=>{let[o,s]=Pe(!0);return Ce(()=>{let i=u=>{s(!!u.isConnected)};return De.addEventListener(i)},[]),o};global.process=se.merge(global.process,We);global.process.browser=!1;global.Buffer=x;global.URL=Be;global.URLSearchParams=Ue;global.btoa=o=>x.from(o,"binary").toString("base64");global.atob=o=>x.from(o,"base64").toString("binary");var yt=Te(P,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"22.2.2",bundleId:Fe(),defaultEndpoint:"https://box.magic.link/",ViewController:C,configureStorage:()=>G(void 0,null,function*(){let o=je.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Ye();return yield Promise.all([o.defineDriver(s),o.defineDriver(J)]),yield o.setDriver([s._driver,J._driver]),o})});export{yt as Magic,ke as useInternetConnection};
|
1
|
+
var ue=Object.create;var Y=Object.defineProperty,le=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)=>le(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?ue(me(o)):{},ge(s||!o||!o.__esModule?Y(i,"default",{value:o,enumerable:!0}):i,o));var G=(o,s,i)=>new Promise((u,c)=>{var b=d=>{try{S(i.next(d))}catch(h){c(h)}},l=d=>{try{S(i.throw(d))}catch(h){c(h)}},S=d=>d.done?u(d.value):Promise.resolve(d.value).then(b,l);S((i=i.apply(o,s)).next())});var oe=ye(($e,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:{},l=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 I(t,e,r,a){var n=e&&e.prototype instanceof k?e:k,f=Object.create(n.prototype),p=new B(a||[]);return u(f,"_invoke",{value:ce(t,r,p)}),f}o.wrap=I;function y(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(a){return{type:"throw",arg:a}}}var D="suspendedStart",H="suspendedYield",Q="executing",N="completed",w={};function k(){}function A(){}function E(){}var T={};h(T,l,function(){return this});var W=Object.getPrototypeOf,M=W&&W(W(U([])));M&&M!==s&&i.call(M,l)&&(T=M);var _=E.prototype=k.prototype=Object.create(T);A.prototype=E,u(_,"constructor",{value:E,configurable:!0}),u(E,"constructor",{value:A,configurable:!0}),A.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===A||(e.displayName||e.name)==="GeneratorFunction":!1},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,E):(t.__proto__=E,h(t,d,"GeneratorFunction")),t.prototype=Object.create(_),t},o.awrap=function(t){return{__await:t}};function V(t,e){function r(f,p,v,g){var m=y(t[f],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(f,p){function v(){return new e(function(g,m){r(f,p,g,m)})}return a=a?a.then(v,v):v()}u(this,"_invoke",{value:n})}X(V.prototype),h(V.prototype,S,function(){return this}),o.AsyncIterator=V,o.async=function(t,e,r,a,n){n===void 0&&(n=Promise);var f=new V(I(t,e,r,a),n);return o.isGeneratorFunction(e)?f:f.next().then(function(p){return p.done?p.value:f.next()})};function ce(t,e,r){var a=D;return function(f,p){if(a===Q)throw new Error("Generator is already running");if(a===N){if(f==="throw")throw p;return ee()}for(r.method=f,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===D)throw a=N,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?N:H,m.arg===w)continue;return{value:m.arg,done:r.done}}else m.type==="throw"&&(a=N,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 f=n.arg;if(!f)return e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,w;if(f.done)e[t.resultName]=f.value,e.next=t.nextLoc,e.method!=="return"&&(e.method="next",e.arg=c);else return f;return e.delegate=null,w}X(_),h(_,d,"Generator"),h(_,l,function(){return this}),h(_,"toString",function(){return"[object Generator]"});function fe(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(fe,this),this.reset(!0)}o.keys=function(t){var e=Object(t),r=[];for(var a in e)r.push(a);return r.reverse(),function n(){for(;r.length;){var f=r.pop();if(f in e)return n.value=f,n.done=!1,n}return n.done=!0,n}};function U(t){if(t){var e=t[l];if(e)return e.call(t);if(typeof t.next=="function")return t;if(!isNaN(t.length)){var r=-1,a=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=c,n.done=!0,n};return a.next=a}}return{next: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 f.type="throw",f.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],f=n.completion;if(n.tryLoc==="root")return r("end");if(n.tryLoc<=this.prev){var p=i.call(n,"catchLoc"),v=i.call(n,"finallyLoc");if(p&&v){if(this.prev<n.catchLoc)return r(n.catchLoc,!0);if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else if(p){if(this.prev<n.catchLoc)return r(n.catchLoc,!0)}else if(v){if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else throw new Error("try statement without catch or finally")}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&i.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var n=a;break}}n&&(t==="break"||t==="continue")&&n.tryLoc<=e&&e<=n.finallyLoc&&(n=null);var f=n?n.completion:{};return f.type=t,f.arg=e,n?(this.method="next",this.next=n.finallyLoc,w):this.complete(f)},complete:function(t,e){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&e&&(this.next=e),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 at=we(oe());import{createSDK as Te}from"@magic-sdk/provider";import*as We from"process";import je from"localforage";import{URL as Be,URLSearchParams as Ue}from"whatwg-url";import{Buffer as x}from"buffer";import*as se from"lodash";import{getBundleId as Fe}from"react-native-device-info";import{driverWithoutSerialization as Ye}from"@aveq-research/localforage-asyncstorage-driver";import*as J 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 Ie}from"@magic-sdk/provider";import{isTypedArray as Ne}from"lodash";var ae="MAGIC_PAYLOAD_FLAG_TYPED_ARRAY",Ae="open_in_device_browser",Me="#FFFFFF";function Ve(){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 C=class extends Re{constructor(){super(...arguments);this.Relayer=i=>{let[u,c]=be(!1),b=R(y=>{this.webView=y},[]),l=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:Me}):this.styles.hide],[u]),I=R(y=>{this.handleReactNativeWebViewMessage(y)},[]);return ie.createElement(Oe,{ref:l,style:h},ie.createElement(_e,{ref:b,source:{uri:`${this.endpoint}/send/?params=${encodeURIComponent(this.parameters)}`},onMessage:I,style:this.styles["magic-webview"],webviewDebuggingEnabled:!0,autoManageStatusBarEnabled:!1,onShouldStartLoadWithRequest:y=>new URLSearchParams(y.url.split("?")[1]).get(Ae)?(Ee.openURL(y.url),!1):!0}))}}init(){this.webView=null,this.container=null,this.styles=Ve()}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,l)=>{try{if(l&&typeof l=="object"&&l.flag&&l.flag===ae)return new global[l.constructor](l.data.split(","))}catch(S){}return l});if(c&&c.msgType&&this.messageHandlers.size){c.response=(u=c.response)!=null?u:{};let b={data:c};for(let l of this.messageHandlers.values())l(b)}}}hideOverlay(){this.container&&this.container.hideOverlay()}showOverlay(){this.container&&this.container.showOverlay()}_post(i){return G(this,null,function*(){if(this.webView&&this.webView.postMessage)this.webView.postMessage(JSON.stringify(i,(u,c)=>Ne(c)?{constructor:c.constructor.name,data:c.toString(),flag:ae}:c),this.endpoint);else throw Ie()})}};import{SDKBase as Ge}from"@magic-sdk/provider";var P=class extends Ge{get Relayer(){return this.overlay.Relayer}};export*from"@magic-sdk/commons";import{useEffect as Ce,useState as Pe}from"react";import De from"@react-native-community/netinfo";var ke=()=>{let[o,s]=Pe(!0);return Ce(()=>{let i=u=>{s(!!u.isConnected)};return De.addEventListener(i)},[]),o};global.process=se.merge(global.process,We);global.process.browser=!1;global.Buffer=x;global.URL=Be;global.URLSearchParams=Ue;global.btoa=o=>x.from(o,"binary").toString("base64");global.atob=o=>x.from(o,"base64").toString("binary");var yt=Te(P,{platform:"react-native",sdkName:"@magic-sdk/react-native-bare",version:"22.3.0",bundleId:Fe(),defaultEndpoint:"https://box.magic.link/",ViewController:C,configureStorage:()=>G(void 0,null,function*(){let o=je.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"}),s=Ye();return yield Promise.all([o.defineDriver(s),o.defineDriver(J)]),yield o.setDriver([s._driver,J._driver]),o})});export{yt as Magic,ke as useInternetConnection};
|
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.3.0
|
3
|
+
"version": "22.3.0",
|
4
4
|
"description": "Passwordless authentication for React Native (Bare).",
|
5
5
|
"author": "Magic Labs <team@magic.link> (https://magic.link/)",
|
6
6
|
"license": "MIT",
|
@@ -18,8 +18,8 @@
|
|
18
18
|
"types": "./dist/types/index.d.ts",
|
19
19
|
"dependencies": {
|
20
20
|
"@aveq-research/localforage-asyncstorage-driver": "^3.0.1",
|
21
|
-
"@magic-sdk/commons": "17.3.0
|
22
|
-
"@magic-sdk/provider": "21.3.0
|
21
|
+
"@magic-sdk/commons": "^17.3.0",
|
22
|
+
"@magic-sdk/provider": "^21.3.0",
|
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",
|
@@ -56,5 +56,5 @@
|
|
56
56
|
"react-native-safe-area-context": ">=4.4.1",
|
57
57
|
"react-native-webview": ">=12.4.0"
|
58
58
|
},
|
59
|
-
"gitHead": "
|
59
|
+
"gitHead": "d67fd2c32dfc647e5fd01cfbb682f1a5f47bd0d6"
|
60
60
|
}
|