@quiltt/react-native 3.3.10 → 3.4.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 +12 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/components/QuilttConnector.tsx +2 -1
- package/src/version.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @quiltt/react-native
|
|
2
2
|
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#191](https://github.com/quiltt/quiltt-public/pull/191) [`58c8f0c`](https://github.com/quiltt/quiltt-public/commit/58c8f0c5265dfa379263225baafb4552067514c6) Thanks [@tom-quiltt](https://github.com/tom-quiltt)! - Add agent QSP for analytic
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`58c8f0c`](https://github.com/quiltt/quiltt-public/commit/58c8f0c5265dfa379263225baafb4552067514c6)]:
|
|
12
|
+
- @quiltt/react@3.4.0
|
|
13
|
+
- @quiltt/core@3.4.0
|
|
14
|
+
|
|
3
15
|
## 3.3.10
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var S=Object.defineProperty;var
|
|
1
|
+
"use strict";var S=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var I=(a,o)=>{for(var i in o)S(a,i,{get:o[i],enumerable:!0})},J=(a,o,i,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of j(o))!M.call(a,c)&&c!==i&&S(a,c,{get:()=>o[c],enumerable:!(r=K(o,c))||r.enumerable});return a};var H=a=>J(S({},"__esModule",{value:!0}),a);var N={};I(N,{QuilttConnector:()=>g,default:()=>B});module.exports=H(N);var U=require("base-64");var n=require("@quiltt/core"),d=require("react"),L=require("react-native"),O=require("react-native-webview"),k=require("react-native-url-polyfill");var l=require("react-native"),R=require("react/jsx-runtime"),A=({children:a})=>(0,R.jsx)(l.SafeAreaView,{style:_.AndroidSafeArea,children:a}),_=l.StyleSheet.create({AndroidSafeArea:{flex:1,backgroundColor:"white",paddingTop:l.Platform.OS==="android"?l.StatusBar.currentHeight:0}});var P=require("@quiltt/react");var q="3.4.0";var w=require("react/jsx-runtime"),v=({connectorId:a,connectionId:o,oauthRedirectUrl:i,onEvent:r,onLoad:c,onExit:s,onExitSuccess:u,onExitAbort:f,onExitError:m})=>{let h=(0,d.useRef)(null),{session:p}=(0,P.useQuilttSession)();i=encodeURIComponent(i);let V=`https://${a}.quiltt.app/?mode=webview&oauth_redirect_url=${i}&agent=react-native-${q}`,Q=(0,d.useCallback)(()=>{var e;let t=` const options = { source: 'quiltt', type: 'Options', token: '${p==null?void 0:p.token}', connectorId: '${a}', connectionId: '${o}', }; const compactedOptions = Object.keys(options).reduce((acc, key) => { if (options[key] !== 'undefined') { acc[key] = options[key]; } return acc; }, {}); window.postMessage(compactedOptions); `;(e=h.current)==null||e.injectJavaScript(t)},[o,a,p==null?void 0:p.token]),W=["quiltt.app","quiltt.dev","moneydesktop.com","cdn.plaid.com/link/v2/stable/link.html"],$=t=>C(t)?!1:W.some(e=>t.href.includes(e)),D=t=>{let e=new k.URL(t.url);return C(e)?(T(e),!1):$(e)?!0:(y(e),!1)},b=()=>{var e;let t="localStorage.clear();";(e=h.current)==null||e.injectJavaScript(t)},C=t=>t.protocol==="quilttconnector:",T=t=>{t.searchParams.delete("source"),t.searchParams.append("connectorId",a);let e=Object.fromEntries(t.searchParams);switch(t.host){case"Load":Q(),r==null||r(n.ConnectorSDKEventType.Load,e),c==null||c(e);break;case"ExitAbort":b(),r==null||r(n.ConnectorSDKEventType.ExitAbort,e),s==null||s(n.ConnectorSDKEventType.ExitAbort,e),f==null||f(e);break;case"ExitError":b(),r==null||r(n.ConnectorSDKEventType.ExitError,e),s==null||s(n.ConnectorSDKEventType.ExitError,e),m==null||m(e);break;case"ExitSuccess":b(),r==null||r(n.ConnectorSDKEventType.ExitSuccess,e),s==null||s(n.ConnectorSDKEventType.ExitSuccess,e),u==null||u(e);break;case"Authenticate":break;case"OauthRequested":y(new k.URL(t.searchParams.get("oauthUrl")));break;default:console.log("unhandled event",t);break}},y=t=>{if(t.protocol!=="https:"){console.log(`handleOAuthUrl - Skipping non https url - ${t.href}`);return}L.Linking.openURL(t.href)};return(0,w.jsx)(A,{children:(0,w.jsx)(O.WebView,{ref:h,originWhitelist:["https://*","quilttconnector://*"],source:{uri:V},onShouldStartLoadWithRequest:D,javaScriptEnabled:!0,domStorageEnabled:!0,webviewDebuggingEnabled:!0})})},g=v;global.atob||(global.atob=U.decode);var B=g;0&&(module.exports={QuilttConnector});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/components/QuilttConnector.tsx","../src/components/AndroidSafeAreaView.tsx"],"sourcesContent":["// Hermes doesn't have atob\n// https://github.com/facebook/hermes/issues/1178\nimport { decode } from 'base-64'\nif (!global.atob) {\n global.atob = decode\n}\nimport QuilttConnector from './components/QuilttConnector'\n\nexport { QuilttConnector }\nexport default QuilttConnector\n","import {\n ConnectorSDKCallbackMetadata,\n ConnectorSDKCallbacks,\n ConnectorSDKEventType,\n} from '@quiltt/core'\nimport { useCallback, useRef } from 'react'\nimport { Linking } from 'react-native'\nimport { WebView } from 'react-native-webview'\n// React Native's URL implementation is incomplete\n// https://github.com/facebook/react-native/issues/16434\nimport { URL } from 'react-native-url-polyfill'\nimport { AndroidSafeAreaView } from './AndroidSafeAreaView'\nimport type { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes'\nimport { useQuilttSession } from '@quiltt/react'\n\ntype QuilttConnectorProps = {\n connectorId: string\n connectionId?: string\n oauthRedirectUrl: string\n} & ConnectorSDKCallbacks\n\nexport const QuilttConnector = ({\n connectorId,\n connectionId,\n oauthRedirectUrl,\n onEvent,\n onLoad,\n onExit,\n onExitSuccess,\n onExitAbort,\n onExitError,\n}: QuilttConnectorProps) => {\n const webViewRef = useRef<WebView>(null)\n const { session } = useQuilttSession()\n oauthRedirectUrl = encodeURIComponent(oauthRedirectUrl)\n const connectorUrl = `https://${connectorId}.quiltt.app/?mode=webview&oauth_redirect_url=${oauthRedirectUrl}&
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/components/QuilttConnector.tsx","../src/components/AndroidSafeAreaView.tsx","../src/version.ts"],"sourcesContent":["// Hermes doesn't have atob\n// https://github.com/facebook/hermes/issues/1178\nimport { decode } from 'base-64'\nif (!global.atob) {\n global.atob = decode\n}\nimport QuilttConnector from './components/QuilttConnector'\n\nexport { QuilttConnector }\nexport default QuilttConnector\n","import {\n ConnectorSDKCallbackMetadata,\n ConnectorSDKCallbacks,\n ConnectorSDKEventType,\n} from '@quiltt/core'\nimport { useCallback, useRef } from 'react'\nimport { Linking } from 'react-native'\nimport { WebView } from 'react-native-webview'\n// React Native's URL implementation is incomplete\n// https://github.com/facebook/react-native/issues/16434\nimport { URL } from 'react-native-url-polyfill'\nimport { AndroidSafeAreaView } from './AndroidSafeAreaView'\nimport type { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes'\nimport { useQuilttSession } from '@quiltt/react'\nimport { version } from '../version'\n\ntype QuilttConnectorProps = {\n connectorId: string\n connectionId?: string\n oauthRedirectUrl: string\n} & ConnectorSDKCallbacks\n\nexport const QuilttConnector = ({\n connectorId,\n connectionId,\n oauthRedirectUrl,\n onEvent,\n onLoad,\n onExit,\n onExitSuccess,\n onExitAbort,\n onExitError,\n}: QuilttConnectorProps) => {\n const webViewRef = useRef<WebView>(null)\n const { session } = useQuilttSession()\n oauthRedirectUrl = encodeURIComponent(oauthRedirectUrl)\n const connectorUrl = `https://${connectorId}.quiltt.app/?mode=webview&oauth_redirect_url=${oauthRedirectUrl}&agent=react-native-${version}`\n\n const initInjectedJavaScript = useCallback(() => {\n const script = `\\\n const options = {\\\n source: 'quiltt',\\\n type: 'Options',\\\n token: '${session?.token}',\\\n connectorId: '${connectorId}',\\\n connectionId: '${connectionId}',\\\n };\\\n const compactedOptions = Object.keys(options).reduce((acc, key) => {\\\n if (options[key] !== 'undefined') {\\\n acc[key] = options[key];\\\n }\\\n return acc;\\\n }, {});\\\n window.postMessage(compactedOptions);\\\n `\n webViewRef.current?.injectJavaScript(script)\n }, [connectionId, connectorId, session?.token])\n\n // allowedListUrl & shouldRender ensure we are only rendering Quiltt, MX and Plaid content in Webview\n // For other urls, we assume those are bank urls, which needs to be handle in external browser.\n // @todo Convert it to a list from Quiltt Server to prevent MX/ Plaid changes.\n const allowedListUrl = [\n 'quiltt.app',\n 'quiltt.dev',\n 'moneydesktop.com',\n 'cdn.plaid.com/link/v2/stable/link.html',\n ]\n const shouldRender = (url: URL) => {\n if (isQuilttEvent(url)) return false\n return allowedListUrl.some((href) => url.href.includes(href))\n }\n\n const requestHandler = (request: ShouldStartLoadRequest) => {\n const url = new URL(request.url)\n if (isQuilttEvent(url)) {\n handleQuilttEvent(url)\n return false\n }\n if (shouldRender(url)) return true\n // Plaid set oauth url by doing window.location.href = url\n // This is the only way I know to handle this.\n handleOAuthUrl(url)\n return false\n }\n\n const clearLocalStorage = () => {\n const script = 'localStorage.clear();'\n webViewRef.current?.injectJavaScript(script)\n }\n\n const isQuilttEvent = (url: URL) => url.protocol === 'quilttconnector:'\n\n const handleQuilttEvent = (url: URL) => {\n url.searchParams.delete('source')\n url.searchParams.append('connectorId', connectorId)\n const metadata = Object.fromEntries(url.searchParams) as ConnectorSDKCallbackMetadata\n\n const eventType = url.host\n switch (eventType) {\n case 'Load':\n initInjectedJavaScript()\n onEvent?.(ConnectorSDKEventType.Load, metadata)\n onLoad?.(metadata)\n break\n case 'ExitAbort':\n clearLocalStorage()\n onEvent?.(ConnectorSDKEventType.ExitAbort, metadata)\n onExit?.(ConnectorSDKEventType.ExitAbort, metadata)\n onExitAbort?.(metadata)\n break\n case 'ExitError':\n clearLocalStorage()\n onEvent?.(ConnectorSDKEventType.ExitError, metadata)\n onExit?.(ConnectorSDKEventType.ExitError, metadata)\n onExitError?.(metadata)\n break\n case 'ExitSuccess':\n clearLocalStorage()\n onEvent?.(ConnectorSDKEventType.ExitSuccess, metadata)\n onExit?.(ConnectorSDKEventType.ExitSuccess, metadata)\n onExitSuccess?.(metadata)\n break\n case 'Authenticate':\n // @todo handle Authenticate\n break\n case 'OauthRequested':\n handleOAuthUrl(new URL(url.searchParams.get('oauthUrl') as string))\n break\n default:\n console.log('unhandled event', url)\n break\n }\n }\n\n const handleOAuthUrl = (oauthUrl: URL) => {\n if (oauthUrl.protocol !== 'https:') {\n console.log(`handleOAuthUrl - Skipping non https url - ${oauthUrl.href}`)\n return\n }\n Linking.openURL(oauthUrl.href)\n }\n\n return (\n <AndroidSafeAreaView>\n <WebView\n ref={webViewRef}\n originWhitelist={['https://*', 'quilttconnector://*']} // Maybe relax this to *?\n source={{ uri: connectorUrl }}\n onShouldStartLoadWithRequest={requestHandler}\n javaScriptEnabled\n domStorageEnabled // To enable localStorage in Android webview\n webviewDebuggingEnabled // Not sure if this works\n />\n </AndroidSafeAreaView>\n )\n}\n\nexport default QuilttConnector\n","import { SafeAreaView, StyleSheet, Platform, StatusBar } from 'react-native'\nimport { PropsWithChildren } from 'react'\n\nexport const AndroidSafeAreaView = ({ children }: PropsWithChildren) => (\n <SafeAreaView style={styles.AndroidSafeArea}>{children}</SafeAreaView>\n)\n\nconst styles = StyleSheet.create({\n AndroidSafeArea: {\n flex: 1,\n backgroundColor: 'white',\n paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,\n },\n})\n","// Generated by genversion.\nexport const version = '3.4.0'\n"],"mappings":"yaAAA,IAAAA,EAAA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AAQ,QAAQA,EAAS,IAAI,CAC/B,EAEA,SACE,OAACC,EAAA,CACC,mBAAC,WACC,IAAKnB,EACL,gBAAiB,CAAC,YAAa,qBAAqB,EACpD,OAAQ,CAAE,IAAKE,CAAa,EAC5B,6BAA8BU,EAC9B,kBAAiB,GACjB,kBAAiB,GACjB,wBAAuB,GACzB,EACF,CAEJ,EAEOQ,EAAQ9B,ED1JV,OAAO,OACV,OAAO,KAAO,UAKhB,IAAO+B,EAAQC","names":["src_exports","__export","QuilttConnector_default","src_default","__toCommonJS","import_base_64","import_core","import_react","import_react_native","import_react_native_webview","import_react_native_url_polyfill","import_react_native","import_jsx_runtime","AndroidSafeAreaView","children","styles","import_react","version","import_jsx_runtime","QuilttConnector","connectorId","connectionId","oauthRedirectUrl","onEvent","onLoad","onExit","onExitSuccess","onExitAbort","onExitError","webViewRef","session","connectorUrl","version","initInjectedJavaScript","_a","script","allowedListUrl","shouldRender","url","isQuilttEvent","href","requestHandler","request","handleQuilttEvent","handleOAuthUrl","clearLocalStorage","metadata","oauthUrl","AndroidSafeAreaView","QuilttConnector_default","src_default","QuilttConnector_default"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{decode as
|
|
1
|
+
import{decode as J}from"base-64";import{ConnectorSDKEventType as o}from"@quiltt/core";import{useCallback as D,useRef as T}from"react";import{Linking as K}from"react-native";import{WebView as j}from"react-native-webview";import{URL as w}from"react-native-url-polyfill";import{SafeAreaView as P,StyleSheet as U,Platform as V,StatusBar as Q}from"react-native";import{jsx as $}from"react/jsx-runtime";var S=({children:c})=>$(P,{style:W.AndroidSafeArea,children:c}),W=U.create({AndroidSafeArea:{flex:1,backgroundColor:"white",paddingTop:V.OS==="android"?Q.currentHeight:0}});import{useQuilttSession as M}from"@quiltt/react";var k="3.4.0";import{jsx as g}from"react/jsx-runtime";var I=({connectorId:c,connectionId:m,oauthRedirectUrl:i,onEvent:r,onLoad:l,onExit:a,onExitSuccess:n,onExitAbort:p,onExitError:d})=>{let u=T(null),{session:s}=M();i=encodeURIComponent(i);let y=`https://${c}.quiltt.app/?mode=webview&oauth_redirect_url=${i}&agent=react-native-${k}`,A=D(()=>{var e;let t=` const options = { source: 'quiltt', type: 'Options', token: '${s==null?void 0:s.token}', connectorId: '${c}', connectionId: '${m}', }; const compactedOptions = Object.keys(options).reduce((acc, key) => { if (options[key] !== 'undefined') { acc[key] = options[key]; } return acc; }, {}); window.postMessage(compactedOptions); `;(e=u.current)==null||e.injectJavaScript(t)},[m,c,s==null?void 0:s.token]),R=["quiltt.app","quiltt.dev","moneydesktop.com","cdn.plaid.com/link/v2/stable/link.html"],q=t=>h(t)?!1:R.some(e=>t.href.includes(e)),L=t=>{let e=new w(t.url);return h(e)?(O(e),!1):q(e)?!0:(b(e),!1)},f=()=>{var e;let t="localStorage.clear();";(e=u.current)==null||e.injectJavaScript(t)},h=t=>t.protocol==="quilttconnector:",O=t=>{t.searchParams.delete("source"),t.searchParams.append("connectorId",c);let e=Object.fromEntries(t.searchParams);switch(t.host){case"Load":A(),r==null||r(o.Load,e),l==null||l(e);break;case"ExitAbort":f(),r==null||r(o.ExitAbort,e),a==null||a(o.ExitAbort,e),p==null||p(e);break;case"ExitError":f(),r==null||r(o.ExitError,e),a==null||a(o.ExitError,e),d==null||d(e);break;case"ExitSuccess":f(),r==null||r(o.ExitSuccess,e),a==null||a(o.ExitSuccess,e),n==null||n(e);break;case"Authenticate":break;case"OauthRequested":b(new w(t.searchParams.get("oauthUrl")));break;default:console.log("unhandled event",t);break}},b=t=>{if(t.protocol!=="https:"){console.log(`handleOAuthUrl - Skipping non https url - ${t.href}`);return}K.openURL(t.href)};return g(S,{children:g(j,{ref:u,originWhitelist:["https://*","quilttconnector://*"],source:{uri:y},onShouldStartLoadWithRequest:L,javaScriptEnabled:!0,domStorageEnabled:!0,webviewDebuggingEnabled:!0})})},C=I;global.atob||(global.atob=J);var se=C;export{C as QuilttConnector,se as default};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/components/QuilttConnector.tsx","../src/components/AndroidSafeAreaView.tsx"],"sourcesContent":["// Hermes doesn't have atob\n// https://github.com/facebook/hermes/issues/1178\nimport { decode } from 'base-64'\nif (!global.atob) {\n global.atob = decode\n}\nimport QuilttConnector from './components/QuilttConnector'\n\nexport { QuilttConnector }\nexport default QuilttConnector\n","import {\n ConnectorSDKCallbackMetadata,\n ConnectorSDKCallbacks,\n ConnectorSDKEventType,\n} from '@quiltt/core'\nimport { useCallback, useRef } from 'react'\nimport { Linking } from 'react-native'\nimport { WebView } from 'react-native-webview'\n// React Native's URL implementation is incomplete\n// https://github.com/facebook/react-native/issues/16434\nimport { URL } from 'react-native-url-polyfill'\nimport { AndroidSafeAreaView } from './AndroidSafeAreaView'\nimport type { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes'\nimport { useQuilttSession } from '@quiltt/react'\n\ntype QuilttConnectorProps = {\n connectorId: string\n connectionId?: string\n oauthRedirectUrl: string\n} & ConnectorSDKCallbacks\n\nexport const QuilttConnector = ({\n connectorId,\n connectionId,\n oauthRedirectUrl,\n onEvent,\n onLoad,\n onExit,\n onExitSuccess,\n onExitAbort,\n onExitError,\n}: QuilttConnectorProps) => {\n const webViewRef = useRef<WebView>(null)\n const { session } = useQuilttSession()\n oauthRedirectUrl = encodeURIComponent(oauthRedirectUrl)\n const connectorUrl = `https://${connectorId}.quiltt.app/?mode=webview&oauth_redirect_url=${oauthRedirectUrl}&
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/components/QuilttConnector.tsx","../src/components/AndroidSafeAreaView.tsx","../src/version.ts"],"sourcesContent":["// Hermes doesn't have atob\n// https://github.com/facebook/hermes/issues/1178\nimport { decode } from 'base-64'\nif (!global.atob) {\n global.atob = decode\n}\nimport QuilttConnector from './components/QuilttConnector'\n\nexport { QuilttConnector }\nexport default QuilttConnector\n","import {\n ConnectorSDKCallbackMetadata,\n ConnectorSDKCallbacks,\n ConnectorSDKEventType,\n} from '@quiltt/core'\nimport { useCallback, useRef } from 'react'\nimport { Linking } from 'react-native'\nimport { WebView } from 'react-native-webview'\n// React Native's URL implementation is incomplete\n// https://github.com/facebook/react-native/issues/16434\nimport { URL } from 'react-native-url-polyfill'\nimport { AndroidSafeAreaView } from './AndroidSafeAreaView'\nimport type { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes'\nimport { useQuilttSession } from '@quiltt/react'\nimport { version } from '../version'\n\ntype QuilttConnectorProps = {\n connectorId: string\n connectionId?: string\n oauthRedirectUrl: string\n} & ConnectorSDKCallbacks\n\nexport const QuilttConnector = ({\n connectorId,\n connectionId,\n oauthRedirectUrl,\n onEvent,\n onLoad,\n onExit,\n onExitSuccess,\n onExitAbort,\n onExitError,\n}: QuilttConnectorProps) => {\n const webViewRef = useRef<WebView>(null)\n const { session } = useQuilttSession()\n oauthRedirectUrl = encodeURIComponent(oauthRedirectUrl)\n const connectorUrl = `https://${connectorId}.quiltt.app/?mode=webview&oauth_redirect_url=${oauthRedirectUrl}&agent=react-native-${version}`\n\n const initInjectedJavaScript = useCallback(() => {\n const script = `\\\n const options = {\\\n source: 'quiltt',\\\n type: 'Options',\\\n token: '${session?.token}',\\\n connectorId: '${connectorId}',\\\n connectionId: '${connectionId}',\\\n };\\\n const compactedOptions = Object.keys(options).reduce((acc, key) => {\\\n if (options[key] !== 'undefined') {\\\n acc[key] = options[key];\\\n }\\\n return acc;\\\n }, {});\\\n window.postMessage(compactedOptions);\\\n `\n webViewRef.current?.injectJavaScript(script)\n }, [connectionId, connectorId, session?.token])\n\n // allowedListUrl & shouldRender ensure we are only rendering Quiltt, MX and Plaid content in Webview\n // For other urls, we assume those are bank urls, which needs to be handle in external browser.\n // @todo Convert it to a list from Quiltt Server to prevent MX/ Plaid changes.\n const allowedListUrl = [\n 'quiltt.app',\n 'quiltt.dev',\n 'moneydesktop.com',\n 'cdn.plaid.com/link/v2/stable/link.html',\n ]\n const shouldRender = (url: URL) => {\n if (isQuilttEvent(url)) return false\n return allowedListUrl.some((href) => url.href.includes(href))\n }\n\n const requestHandler = (request: ShouldStartLoadRequest) => {\n const url = new URL(request.url)\n if (isQuilttEvent(url)) {\n handleQuilttEvent(url)\n return false\n }\n if (shouldRender(url)) return true\n // Plaid set oauth url by doing window.location.href = url\n // This is the only way I know to handle this.\n handleOAuthUrl(url)\n return false\n }\n\n const clearLocalStorage = () => {\n const script = 'localStorage.clear();'\n webViewRef.current?.injectJavaScript(script)\n }\n\n const isQuilttEvent = (url: URL) => url.protocol === 'quilttconnector:'\n\n const handleQuilttEvent = (url: URL) => {\n url.searchParams.delete('source')\n url.searchParams.append('connectorId', connectorId)\n const metadata = Object.fromEntries(url.searchParams) as ConnectorSDKCallbackMetadata\n\n const eventType = url.host\n switch (eventType) {\n case 'Load':\n initInjectedJavaScript()\n onEvent?.(ConnectorSDKEventType.Load, metadata)\n onLoad?.(metadata)\n break\n case 'ExitAbort':\n clearLocalStorage()\n onEvent?.(ConnectorSDKEventType.ExitAbort, metadata)\n onExit?.(ConnectorSDKEventType.ExitAbort, metadata)\n onExitAbort?.(metadata)\n break\n case 'ExitError':\n clearLocalStorage()\n onEvent?.(ConnectorSDKEventType.ExitError, metadata)\n onExit?.(ConnectorSDKEventType.ExitError, metadata)\n onExitError?.(metadata)\n break\n case 'ExitSuccess':\n clearLocalStorage()\n onEvent?.(ConnectorSDKEventType.ExitSuccess, metadata)\n onExit?.(ConnectorSDKEventType.ExitSuccess, metadata)\n onExitSuccess?.(metadata)\n break\n case 'Authenticate':\n // @todo handle Authenticate\n break\n case 'OauthRequested':\n handleOAuthUrl(new URL(url.searchParams.get('oauthUrl') as string))\n break\n default:\n console.log('unhandled event', url)\n break\n }\n }\n\n const handleOAuthUrl = (oauthUrl: URL) => {\n if (oauthUrl.protocol !== 'https:') {\n console.log(`handleOAuthUrl - Skipping non https url - ${oauthUrl.href}`)\n return\n }\n Linking.openURL(oauthUrl.href)\n }\n\n return (\n <AndroidSafeAreaView>\n <WebView\n ref={webViewRef}\n originWhitelist={['https://*', 'quilttconnector://*']} // Maybe relax this to *?\n source={{ uri: connectorUrl }}\n onShouldStartLoadWithRequest={requestHandler}\n javaScriptEnabled\n domStorageEnabled // To enable localStorage in Android webview\n webviewDebuggingEnabled // Not sure if this works\n />\n </AndroidSafeAreaView>\n )\n}\n\nexport default QuilttConnector\n","import { SafeAreaView, StyleSheet, Platform, StatusBar } from 'react-native'\nimport { PropsWithChildren } from 'react'\n\nexport const AndroidSafeAreaView = ({ children }: PropsWithChildren) => (\n <SafeAreaView style={styles.AndroidSafeArea}>{children}</SafeAreaView>\n)\n\nconst styles = StyleSheet.create({\n AndroidSafeArea: {\n flex: 1,\n backgroundColor: 'white',\n paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0,\n },\n})\n","// Generated by genversion.\nexport const version = '3.4.0'\n"],"mappings":"AAEA,OAAS,UAAAA,MAAc,UCFvB,OAGE,yBAAAC,MACK,eACP,OAAS,eAAAC,EAAa,UAAAC,MAAc,QACpC,OAAS,WAAAC,MAAe,eACxB,OAAS,WAAAC,MAAe,uBAGxB,OAAS,OAAAC,MAAW,4BCVpB,OAAS,gBAAAC,EAAc,cAAAC,EAAY,YAAAC,EAAU,aAAAC,MAAiB,eAI5D,cAAAC,MAAA,oBADK,IAAMC,EAAsB,CAAC,CAAE,SAAAC,CAAS,IAC7CF,EAACJ,EAAA,CAAa,MAAOO,EAAO,gBAAkB,SAAAD,EAAS,EAGnDC,EAASN,EAAW,OAAO,CAC/B,gBAAiB,CACf,KAAM,EACN,gBAAiB,QACjB,WAAYC,EAAS,KAAO,UAAYC,EAAU,cAAgB,CACpE,CACF,CAAC,EDAD,OAAS,oBAAAK,MAAwB,gBEZ1B,IAAMC,EAAU,QF+IjB,cAAAC,MAAA,oBA1HC,IAAMC,EAAkB,CAAC,CAC9B,YAAAC,EACA,aAAAC,EACA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ACHD,EAAkB,EAClB1B,GAAA,MAAAA,EAAU4B,EAAsB,UAAWD,GAC3CzB,GAAA,MAAAA,EAAS0B,EAAsB,UAAWD,GAC1CvB,GAAA,MAAAA,EAAcuB,GACd,MACF,IAAK,YACHD,EAAkB,EAClB1B,GAAA,MAAAA,EAAU4B,EAAsB,UAAWD,GAC3CzB,GAAA,MAAAA,EAAS0B,EAAsB,UAAWD,GAC1CtB,GAAA,MAAAA,EAAcsB,GACd,MACF,IAAK,cACHD,EAAkB,EAClB1B,GAAA,MAAAA,EAAU4B,EAAsB,YAAaD,GAC7CzB,GAAA,MAAAA,EAAS0B,EAAsB,YAAaD,GAC5CxB,GAAA,MAAAA,EAAgBwB,GAChB,MACF,IAAK,eAEH,MACF,IAAK,iBACHF,EAAe,IAAIF,EAAIL,EAAI,aAAa,IAAI,UAAU,CAAW,CAAC,EAClE,MACF,QACE,QAAQ,IAAI,kBAAmBA,CAAG,EAClC,KACJ,CACF,EAEMO,EAAkBI,GAAkB,CACxC,GAAIA,EAAS,WAAa,SAAU,CAClC,QAAQ,IAAI,6CAA6CA,EAAS,MAAM,EACxE,OAEFC,EAAQ,QAAQD,EAAS,IAAI,CAC/B,EAEA,OACElC,EAACoC,EAAA,CACC,SAAApC,EAACqC,EAAA,CACC,IAAK1B,EACL,gBAAiB,CAAC,YAAa,qBAAqB,EACpD,OAAQ,CAAE,IAAKI,CAAa,EAC5B,6BAA8BW,EAC9B,kBAAiB,GACjB,kBAAiB,GACjB,wBAAuB,GACzB,EACF,CAEJ,EAEOY,EAAQrC,ED1JV,OAAO,OACV,OAAO,KAAOsC,GAKhB,IAAOC,GAAQC","names":["decode","ConnectorSDKEventType","useCallback","useRef","Linking","WebView","URL","SafeAreaView","StyleSheet","Platform","StatusBar","jsx","AndroidSafeAreaView","children","styles","useQuilttSession","version","jsx","QuilttConnector","connectorId","connectionId","oauthRedirectUrl","onEvent","onLoad","onExit","onExitSuccess","onExitAbort","onExitError","webViewRef","useRef","session","useQuilttSession","connectorUrl","version","initInjectedJavaScript","useCallback","_a","script","allowedListUrl","shouldRender","url","isQuilttEvent","href","requestHandler","request","URL","handleQuilttEvent","handleOAuthUrl","clearLocalStorage","metadata","ConnectorSDKEventType","oauthUrl","Linking","AndroidSafeAreaView","WebView","QuilttConnector_default","decode","src_default","QuilttConnector_default"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quiltt/react-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "React Native components for Quiltt Connector",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"react-native-url-polyfill": "*"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@quiltt/core": "3.
|
|
28
|
-
"@quiltt/react": "3.
|
|
27
|
+
"@quiltt/core": "3.4.0",
|
|
28
|
+
"@quiltt/react": "3.4.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@apollo/client": "3.7.16",
|
|
@@ -52,9 +52,10 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
|
-
"build": "tsup",
|
|
55
|
+
"build": "pnpm run addVersion && tsup",
|
|
56
56
|
"clean": "rimraf .turbo dist",
|
|
57
57
|
"dev": "tsup --watch",
|
|
58
|
+
"addVersion": "genversion --esm -f src/version.ts",
|
|
58
59
|
"lint": "TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix",
|
|
59
60
|
"typecheck": "tsc --project tsconfig.json --noEmit"
|
|
60
61
|
}
|
|
@@ -12,6 +12,7 @@ import { URL } from 'react-native-url-polyfill'
|
|
|
12
12
|
import { AndroidSafeAreaView } from './AndroidSafeAreaView'
|
|
13
13
|
import type { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes'
|
|
14
14
|
import { useQuilttSession } from '@quiltt/react'
|
|
15
|
+
import { version } from '../version'
|
|
15
16
|
|
|
16
17
|
type QuilttConnectorProps = {
|
|
17
18
|
connectorId: string
|
|
@@ -33,7 +34,7 @@ export const QuilttConnector = ({
|
|
|
33
34
|
const webViewRef = useRef<WebView>(null)
|
|
34
35
|
const { session } = useQuilttSession()
|
|
35
36
|
oauthRedirectUrl = encodeURIComponent(oauthRedirectUrl)
|
|
36
|
-
const connectorUrl = `https://${connectorId}.quiltt.app/?mode=webview&oauth_redirect_url=${oauthRedirectUrl}&
|
|
37
|
+
const connectorUrl = `https://${connectorId}.quiltt.app/?mode=webview&oauth_redirect_url=${oauthRedirectUrl}&agent=react-native-${version}`
|
|
37
38
|
|
|
38
39
|
const initInjectedJavaScript = useCallback(() => {
|
|
39
40
|
const script = `\
|
package/src/version.ts
ADDED