@quiltt/react-native 3.5.3 → 3.5.5

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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # @quiltt/react-native
2
2
 
3
+ ## 3.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#218](https://github.com/quiltt/quiltt-js/pull/218) [`7dd42db`](https://github.com/quiltt/quiltt-js/commit/7dd42dbc744805d68fbff8fbed73a4bd68022b44) Thanks [@tom-quiltt](https://github.com/tom-quiltt)! - Fix changeset md to release packages
8
+
9
+ - [#213](https://github.com/quiltt/quiltt-js/pull/213) [`5648e3c`](https://github.com/quiltt/quiltt-js/commit/5648e3c91d572d97ad88115710ab840b98e1d469) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Add exported files to '@quiltt/react-native'"
10
+
11
+ - [#210](https://github.com/quiltt/quiltt-js/pull/210) [`e57fdb8`](https://github.com/quiltt/quiltt-js/commit/e57fdb8c21e90b6a3492bc7a0c858031384caebf) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Migrate bundler to 'bunchee'
12
+
13
+ - [#215](https://github.com/quiltt/quiltt-js/pull/215) [`c36abb4`](https://github.com/quiltt/quiltt-js/commit/c36abb47cffea3d754fd243b321f2ae50518c297) Thanks [@tom-quiltt](https://github.com/tom-quiltt)! - Remove React Native SDK about:srcdoc warning
14
+
15
+ - [#216](https://github.com/quiltt/quiltt-js/pull/216) [`2895899`](https://github.com/quiltt/quiltt-js/commit/289589913c55f8dad2e818d71c4be39c93e5a52a) Thanks [@tom-quiltt](https://github.com/tom-quiltt)! - Fix release changeset command
16
+
17
+ - Updated dependencies [[`7dd42db`](https://github.com/quiltt/quiltt-js/commit/7dd42dbc744805d68fbff8fbed73a4bd68022b44), [`5648e3c`](https://github.com/quiltt/quiltt-js/commit/5648e3c91d572d97ad88115710ab840b98e1d469), [`e57fdb8`](https://github.com/quiltt/quiltt-js/commit/e57fdb8c21e90b6a3492bc7a0c858031384caebf), [`c36abb4`](https://github.com/quiltt/quiltt-js/commit/c36abb47cffea3d754fd243b321f2ae50518c297), [`2895899`](https://github.com/quiltt/quiltt-js/commit/289589913c55f8dad2e818d71c4be39c93e5a52a)]:
18
+ - @quiltt/core@3.5.5
19
+ - @quiltt/react@3.5.5
20
+
21
+ ## 3.5.4
22
+
23
+ ### Patch Changes
24
+
25
+ - [#209](https://github.com/quiltt/quiltt-js/pull/209) [`6c5aa5f`](https://github.com/quiltt/quiltt-js/commit/6c5aa5fb0212f9dce84e71fe91e2182f463f7318) Thanks [@tom-quiltt](https://github.com/tom-quiltt)! - Expose Institutions to React Native API
26
+
27
+ - Updated dependencies [[`6c5aa5f`](https://github.com/quiltt/quiltt-js/commit/6c5aa5fb0212f9dce84e71fe91e2182f463f7318)]:
28
+ - @quiltt/react@3.5.4
29
+ - @quiltt/core@3.5.4
30
+
3
31
  ## 3.5.3
4
32
 
5
33
  ### Patch Changes
package/README.md CHANGED
@@ -27,7 +27,7 @@ Launch the [Quiltt Connector](https://www.quiltt.dev/connector) in a webview.
27
27
 
28
28
  `@quiltt/react-native` does not include any navigation library, you might want to navigate to a new "page" when using QuilttConnector to get the best result.
29
29
 
30
- For simple usage of `react-navigation`, please see [App.tsx](example/App.tsx) and [ConnectorScreen.tsx](example/screens/ConnectorScreen.tsx).
30
+ For simple usage of `react-navigation`, please see [App.tsx](examples/expo/App.tsx) and [ConnectorScreen.tsx](examples/expo/screens/ConnectorScreen.tsx).
31
31
 
32
32
  #### Example
33
33
 
package/dist/index.d.ts CHANGED
@@ -1,11 +1,17 @@
1
+ export * from '@quiltt/core';
2
+ import { ConnectorSDKCallbacks } from '@quiltt/react';
3
+ export { QuilttAuthProvider, QuilttProvider, QuilttSettingsProvider, useQuilttClient, useQuilttConnector, useQuilttSession, useQuilttSettings, useSession, useStorage } from '@quiltt/react';
1
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ConnectorSDKCallbacks } from '@quiltt/core';
3
5
 
4
6
  type QuilttConnectorProps = {
5
7
  connectorId: string;
6
8
  connectionId?: string;
9
+ institution?: string;
7
10
  oauthRedirectUrl: string;
8
11
  } & ConnectorSDKCallbacks;
9
- declare const QuilttConnector: ({ connectorId, connectionId, oauthRedirectUrl, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, }: QuilttConnectorProps) => react_jsx_runtime.JSX.Element;
12
+ declare const QuilttConnector: {
13
+ ({ connectorId, connectionId, institution, oauthRedirectUrl, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, }: QuilttConnectorProps): react_jsx_runtime.JSX.Element;
14
+ displayName: string;
15
+ };
10
16
 
11
- export { QuilttConnector, QuilttConnector as default };
17
+ export { QuilttConnector };
package/dist/index.js CHANGED
@@ -1,3 +1,443 @@
1
- "use strict";var D=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var ce=(r,e,i)=>e in r?D(r,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[e]=i;var le=(r,e)=>{for(var i in e)D(r,i,{get:e[i],enumerable:!0})},pe=(r,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ie(e))!ne.call(r,o)&&o!==i&&D(r,o,{get:()=>e[o],enumerable:!(n=se(e,o))||n.enumerable});return r};var de=r=>pe(D({},"__esModule",{value:!0}),r);var g=(r,e,i)=>(ce(r,typeof e!="symbol"?e+"":e,i),i);var w=(r,e,i)=>new Promise((n,o)=>{var l=s=>{try{d(i.next(s))}catch(b){o(b)}},h=s=>{try{d(i.throw(s))}catch(b){o(b)}},d=s=>s.done?n(s.value):Promise.resolve(s.value).then(l,h);d((i=i.apply(r,e)).next())});var be={};le(be,{QuilttConnector:()=>I,default:()=>me});module.exports=de(be);var ee=require("base-64");var m=require("@quiltt/core"),c=require("react"),U=require("react-native"),Z=require("react-native-webview"),_=require("react-native-url-polyfill");var u=require("react-native"),J=require("react/jsx-runtime"),A=({children:r})=>(0,J.jsx)(u.SafeAreaView,{style:fe.AndroidSafeArea,children:r}),fe=u.StyleSheet.create({AndroidSafeArea:{flex:1,backgroundColor:"white",paddingTop:u.Platform.OS==="android"?u.StatusBar.currentHeight:0}});var E=require("@quiltt/react");var R=require("@honeybadger-io/core/build/src/util");var B={honeybadger_api_key:"undefined"};var C="3.5.3";var he={name:"Quiltt React Native SDK Reporter",url:"https://www.quiltt.dev/guides/connector/react-native",version:C},O=class{constructor(e){g(this,"noticeUrl");g(this,"apiKey");g(this,"clientName");g(this,"clientVersion");g(this,"platform");g(this,"logger");g(this,"userAgent");this.noticeUrl="https://api.honeybadger.io/v1/notices",this.apiKey=B.honeybadger_api_key,this.clientName="react-native-sdk",this.clientVersion=C,this.platform=e,this.logger=console,this.userAgent=`${this.clientName} ${this.clientVersion}; ${this.platform}`}send(e,i){return w(this,null,function*(){let n={"X-API-Key":this.apiKey,"Content-Type":"application/json",Accept:"application/json","User-Agent":`${this.clientName} ${this.clientVersion}; ${this.platform}`},o=yield this.buildPayload(e,i),l="POST",h=JSON.stringify(o),d="cors";fetch(this.noticeUrl,{headers:n,method:l,body:h,mode:d}).then(s=>{if(s.status!==201){this.logger.warn(`Error report failed: unknown response from server. code=${s.status}`);return}return s.json()}).then(s=>{s&&this.logger.info(`Error report sent \u26A1 https://app.honeybadger.io/notice/${s==null?void 0:s.id}`)})})}buildPayload(n){return w(this,arguments,function*(e,i={}){let o=e;return o.stack=(0,R.generateStackTrace)(),o.backtrace=(0,R.makeBacktrace)(o.stack),{notifier:he,error:{class:o.name,message:o.message,backtrace:o.backtrace,tags:o.tags||[],causes:(0,R.getCauses)(o,this.logger)},request:{url:o.url,component:o.component,action:o.action,context:i||{},cgi_data:{},params:{},session:{}},server:{project_root:o.projectRoot,environment_name:this.userAgent,revision:C,hostname:this.platform,time:new Date().toUTCString()},details:o.details||{}}})}};var G=(r,e)=>e?`An error occurred while checking the connector URL: ${e==null?void 0:e.name}
2
- ${e==null?void 0:e.message}`:r?`The URL is not routable. Response status: ${r}`:"An error occurred while checking the connector URL";var N=require("react-native");var q=require("react/jsx-runtime"),X=()=>(0,q.jsx)(A,{children:(0,q.jsx)(N.View,{style:{flex:1,justifyContent:"center",alignItems:"center"},children:(0,q.jsx)(N.ActivityIndicator,{size:"large",color:"#0000ff"})})});var p=require("react-native");var f=require("react/jsx-runtime"),Y=({error:r,cta:e})=>(0,f.jsx)(A,{children:(0,f.jsxs)(p.View,{style:[P.container,P.padding],children:[(0,f.jsxs)(p.View,{style:{flex:1,justifyContent:"center"},children:[(0,f.jsx)(p.View,{style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginVertical:10},children:(0,f.jsx)(p.Text,{style:[P.title],children:"Cannot connect to the internet."})}),(0,f.jsx)(p.Text,{style:[P.subtitle],children:r})]}),(0,f.jsx)(p.Pressable,{style:[P.pressable],onPress:e,children:(0,f.jsx)(p.Text,{style:[P.pressableText],children:"Exit"})})]})}),P=p.StyleSheet.create({container:{flex:1,flexDirection:"column",justifyContent:"flex-start",alignItems:"stretch",backgroundColor:"#F3F4F6"},title:{color:"#1F2937",fontSize:30,fontWeight:"bold"},subtitle:{color:"rgba(107, 114, 128, 1)"},padding:{paddingHorizontal:16,paddingVertical:24},pressable:{marginTop:20,backgroundColor:"#1F2937",padding:10,paddingHorizontal:25,borderRadius:5},pressableText:{color:"#fff",textAlign:"center"}});var $=require("react/jsx-runtime"),x=new O(`${U.Platform.OS} ${U.Platform.Version}`),ge=3,ue=({connectorId:r,connectionId:e,oauthRedirectUrl:i,onEvent:n,onLoad:o,onExit:l,onExitSuccess:h,onExitAbort:d,onExitError:s})=>{let b=(0,c.useRef)(null),{session:k}=(0,E.useQuilttSession)();i=encodeURIComponent(i);let y=`https://${r}.quiltt.app/?mode=webview&oauth_redirect_url=${i}&agent=react-native-${C}`;console.log("connectorUrl",y);let[T,te]=(0,c.useState)({checked:!1}),j=(0,c.useCallback)((a=0)=>w(void 0,null,function*(){let t,V,K=!1;try{let S=yield fetch(y);if(!S.ok)console.error(`The URL ${y} is not routable.`),t=S.status,K=!0;else return console.log(`The URL ${y} is routable.`),{checked:!0}}catch(S){V=S,console.error(`An error occurred while checking the connector URL: ${V}`),K=!0}if(K&&a<ge)return yield new Promise(S=>setTimeout(S,50*a)),console.log(`Retrying... Attempt number ${a+1}`),j(a+1);let z=G(t,V),oe=V||new Error(z),ae={connectorUrl:y,responseStatus:t};return t!==404&&x.send(oe,ae),{checked:!0,error:z}}),[y]);(0,c.useEffect)(()=>{if(T.checked)return;(()=>w(void 0,null,function*(){let t=yield j();te(t)}))()},[j,T]);let Q=(0,c.useCallback)(()=>{var t;let a=` const options = { source: 'quiltt', type: 'Options', token: '${k==null?void 0:k.token}', connectorId: '${r}', connectionId: '${e}', }; const compactedOptions = Object.keys(options).reduce((acc, key) => { if (options[key] !== 'undefined') { acc[key] = options[key]; } return acc; }, {}); window.postMessage(compactedOptions); `;(t=b.current)==null||t.injectJavaScript(a)},[e,r,k==null?void 0:k.token]),W=(0,c.useMemo)(()=>["quiltt.app","quiltt.dev","moneydesktop.com","cdn.plaid.com/link/v2/stable/link.html"],[]),v=(0,c.useCallback)(a=>a.protocol==="quilttconnector:",[]),H=(0,c.useCallback)(a=>{if(v(a))return!1;if(a.protocol!=="https:"){let t=new Error(`Invalid url leaked ${a.href}`);return x.send(t),!1}return W.some(t=>a.href.includes(t))},[W,v]),F=()=>{var t;let a="localStorage.clear();";(t=b.current)==null||t.injectJavaScript(a)},L=(0,c.useCallback)(a=>{if(a.protocol!=="https:"){console.log(`handleOAuthUrl - Skipping non https url - ${a.href}`);return}U.Linking.openURL(a.href)},[]),M=(0,c.useCallback)(a=>{a.searchParams.delete("source"),a.searchParams.append("connectorId",r);let t=Object.fromEntries(a.searchParams);switch(a.host){case"Load":Q(),n==null||n(m.ConnectorSDKEventType.Load,t),o==null||o(t);break;case"ExitAbort":F(),n==null||n(m.ConnectorSDKEventType.ExitAbort,t),l==null||l(m.ConnectorSDKEventType.ExitAbort,t),d==null||d(t);break;case"ExitError":F(),n==null||n(m.ConnectorSDKEventType.ExitError,t),l==null||l(m.ConnectorSDKEventType.ExitError,t),s==null||s(t);break;case"ExitSuccess":F(),n==null||n(m.ConnectorSDKEventType.ExitSuccess,t),l==null||l(m.ConnectorSDKEventType.ExitSuccess,t),h==null||h(t);break;case"Authenticate":break;case"OauthRequested":L(new _.URL(a.searchParams.get("oauthUrl")));break;default:console.log("unhandled event",a);break}},[r,L,Q,n,l,d,s,h,o]),re=(0,c.useCallback)(a=>{let t=new _.URL(a.url);return v(t)?(M(t),!1):H(t)?!0:(L(t),!1)},[L,M,v,H]);return T.checked?T.error?(0,$.jsx)(Y,{error:T.error,cta:()=>s==null?void 0:s({connectorId:r})}):(0,$.jsx)(A,{children:(0,$.jsx)(Z.WebView,{ref:b,originWhitelist:["https://*","quilttconnector://*"],source:{uri:y},onShouldStartLoadWithRequest:re,javaScriptEnabled:!0,domStorageEnabled:!0,webviewDebuggingEnabled:!0})}):(0,$.jsx)(X,{})},I=ue;global.atob||(global.atob=ee.decode);var me=I;0&&(module.exports={QuilttConnector});
3
- //# sourceMappingURL=index.js.map
1
+ import { decode } from 'base-64';
2
+ export * from '@quiltt/core';
3
+ import { useQuilttSession, ConnectorSDKEventType } from '@quiltt/react';
4
+ export { QuilttAuthProvider, QuilttProvider, QuilttSettingsProvider, useQuilttClient, useQuilttConnector, useQuilttSession, useQuilttSettings, useSession, useStorage } from '@quiltt/react';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+ import { useRef, useMemo, useState, useCallback, useEffect } from 'react';
7
+ import { StyleSheet, Platform, StatusBar, SafeAreaView, View, Text, Pressable, ActivityIndicator, Linking } from 'react-native';
8
+ import { URL } from 'react-native-url-polyfill';
9
+ import { WebView } from 'react-native-webview';
10
+ import { generateStackTrace, makeBacktrace, getCauses } from '@honeybadger-io/core/build/src/util';
11
+
12
+ const ErrorReporterConfig = {
13
+ honeybadger_api_key: 'undefined'
14
+ };
15
+
16
+ // Generated by genversion.
17
+ const version = '3.5.5';
18
+
19
+ // Quick hack to send error to Honeybadger to debug why the connector is not routable
20
+ const notifier = {
21
+ name: 'Quiltt React Native SDK Reporter',
22
+ url: 'https://www.quiltt.dev/guides/connector/react-native',
23
+ version: version
24
+ };
25
+ class ErrorReporter {
26
+ constructor(platform){
27
+ this.noticeUrl = 'https://api.honeybadger.io/v1/notices';
28
+ this.apiKey = ErrorReporterConfig.honeybadger_api_key;
29
+ this.clientName = 'react-native-sdk';
30
+ this.clientVersion = version;
31
+ this.platform = platform;
32
+ this.logger = console;
33
+ this.userAgent = `${this.clientName} ${this.clientVersion}; ${this.platform}`;
34
+ }
35
+ async send(error, context) {
36
+ const headers = {
37
+ 'X-API-Key': this.apiKey,
38
+ 'Content-Type': 'application/json',
39
+ Accept: 'application/json',
40
+ 'User-Agent': `${this.clientName} ${this.clientVersion}; ${this.platform}`
41
+ };
42
+ const payload = await this.buildPayload(error, context);
43
+ const method = 'POST';
44
+ const body = JSON.stringify(payload);
45
+ const mode = 'cors';
46
+ fetch(this.noticeUrl, {
47
+ headers,
48
+ method,
49
+ body,
50
+ mode
51
+ }).then((response)=>{
52
+ if (response.status !== 201) {
53
+ this.logger.warn(`Error report failed: unknown response from server. code=${response.status}`);
54
+ return;
55
+ }
56
+ return response.json();
57
+ }).then((data)=>{
58
+ if (data) {
59
+ this.logger.info(`Error report sent ⚡ https://app.honeybadger.io/notice/${data?.id}`);
60
+ }
61
+ });
62
+ }
63
+ async buildPayload(error, localContext = {}) {
64
+ const notice = error;
65
+ notice.stack = generateStackTrace();
66
+ notice.backtrace = makeBacktrace(notice.stack);
67
+ return {
68
+ notifier,
69
+ error: {
70
+ class: notice.name,
71
+ message: notice.message,
72
+ backtrace: notice.backtrace,
73
+ // fingerprint: this.calculateFingerprint(notice),
74
+ tags: notice.tags || [],
75
+ causes: getCauses(notice, this.logger)
76
+ },
77
+ request: {
78
+ url: notice.url,
79
+ component: notice.component,
80
+ action: notice.action,
81
+ context: localContext || {},
82
+ cgi_data: {},
83
+ params: {},
84
+ session: {}
85
+ },
86
+ server: {
87
+ project_root: notice.projectRoot,
88
+ environment_name: this.userAgent,
89
+ revision: version,
90
+ hostname: this.platform,
91
+ time: new Date().toUTCString()
92
+ },
93
+ details: notice.details || {}
94
+ };
95
+ }
96
+ }
97
+
98
+ const getErrorMessage = (responseStatus, error)=>{
99
+ if (error) return `An error occurred while checking the connector URL: ${error?.name} \n${error?.message}`;
100
+ return responseStatus ? `The URL is not routable. Response status: ${responseStatus}` : 'An error occurred while checking the connector URL';
101
+ };
102
+
103
+ const AndroidSafeAreaView = ({ children })=>/*#__PURE__*/ jsx(SafeAreaView, {
104
+ style: styles$1.AndroidSafeArea,
105
+ children: children
106
+ });
107
+ const styles$1 = StyleSheet.create({
108
+ AndroidSafeArea: {
109
+ flex: 1,
110
+ backgroundColor: 'white',
111
+ paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0
112
+ }
113
+ });
114
+
115
+ const ErrorScreen = ({ error, cta })=>/*#__PURE__*/ jsx(AndroidSafeAreaView, {
116
+ children: /*#__PURE__*/ jsxs(View, {
117
+ style: [
118
+ styles.container,
119
+ styles.padding
120
+ ],
121
+ children: [
122
+ /*#__PURE__*/ jsxs(View, {
123
+ style: {
124
+ flex: 1,
125
+ justifyContent: 'center'
126
+ },
127
+ children: [
128
+ /*#__PURE__*/ jsx(View, {
129
+ style: {
130
+ flexDirection: 'row',
131
+ justifyContent: 'space-between',
132
+ alignItems: 'center',
133
+ marginVertical: 10
134
+ },
135
+ children: /*#__PURE__*/ jsx(Text, {
136
+ style: [
137
+ styles.title
138
+ ],
139
+ children: "Cannot connect to the internet."
140
+ })
141
+ }),
142
+ /*#__PURE__*/ jsx(Text, {
143
+ style: [
144
+ styles.subtitle
145
+ ],
146
+ children: error
147
+ })
148
+ ]
149
+ }),
150
+ /*#__PURE__*/ jsx(Pressable, {
151
+ style: [
152
+ styles.pressable
153
+ ],
154
+ onPress: cta,
155
+ children: /*#__PURE__*/ jsx(Text, {
156
+ style: [
157
+ styles.pressableText
158
+ ],
159
+ children: "Exit"
160
+ })
161
+ })
162
+ ]
163
+ })
164
+ });
165
+ const styles = StyleSheet.create({
166
+ container: {
167
+ flex: 1,
168
+ flexDirection: 'column',
169
+ justifyContent: 'flex-start',
170
+ alignItems: 'stretch',
171
+ backgroundColor: '#F3F4F6'
172
+ },
173
+ title: {
174
+ color: '#1F2937',
175
+ fontSize: 30,
176
+ fontWeight: 'bold'
177
+ },
178
+ subtitle: {
179
+ color: 'rgba(107, 114, 128, 1)'
180
+ },
181
+ padding: {
182
+ paddingHorizontal: 16,
183
+ paddingVertical: 24
184
+ },
185
+ pressable: {
186
+ marginTop: 20,
187
+ backgroundColor: '#1F2937',
188
+ padding: 10,
189
+ paddingHorizontal: 25,
190
+ borderRadius: 5
191
+ },
192
+ pressableText: {
193
+ color: '#fff',
194
+ textAlign: 'center'
195
+ }
196
+ });
197
+
198
+ const LoadingScreen = ()=>/*#__PURE__*/ jsx(AndroidSafeAreaView, {
199
+ children: /*#__PURE__*/ jsx(View, {
200
+ style: {
201
+ flex: 1,
202
+ justifyContent: 'center',
203
+ alignItems: 'center'
204
+ },
205
+ children: /*#__PURE__*/ jsx(ActivityIndicator, {
206
+ size: "large",
207
+ color: "#0000ff"
208
+ })
209
+ })
210
+ });
211
+
212
+ const errorReporter = new ErrorReporter(`${Platform.OS} ${Platform.Version}`);
213
+ const PREFLIGHT_RETRY_COUNT = 3;
214
+ const QuilttConnector = ({ connectorId, connectionId, institution, oauthRedirectUrl, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError })=>{
215
+ const webViewRef = useRef(null);
216
+ const { session } = useQuilttSession();
217
+ const encodedOAuthRedirectUrl = useMemo(()=>encodeURIComponent(oauthRedirectUrl), [
218
+ oauthRedirectUrl
219
+ ]);
220
+ const connectorUrl = useMemo(()=>{
221
+ const url = new URL(`https://${connectorId}.quiltt.app`);
222
+ url.searchParams.append('mode', 'webview');
223
+ url.searchParams.append('oauth_redirect_url', encodedOAuthRedirectUrl);
224
+ url.searchParams.append('agent', `react-native-${version}`);
225
+ return url.toString();
226
+ }, [
227
+ connectorId,
228
+ encodedOAuthRedirectUrl
229
+ ]);
230
+ const [preFlightCheck, setPreFlightCheck] = useState({
231
+ checked: false
232
+ });
233
+ const checkConnectorUrl = useCallback(async (retryCount = 0)=>{
234
+ let responseStatus;
235
+ let error;
236
+ let errorOccurred = false;
237
+ try {
238
+ const response = await fetch(connectorUrl);
239
+ if (!response.ok) {
240
+ console.error(`The URL ${connectorUrl} is not routable.`);
241
+ responseStatus = response.status;
242
+ errorOccurred = true;
243
+ } else {
244
+ console.log(`The URL ${connectorUrl} is routable.`);
245
+ return {
246
+ checked: true
247
+ };
248
+ }
249
+ } catch (e) {
250
+ error = e;
251
+ console.error(`An error occurred while checking the connector URL: ${error}`);
252
+ errorOccurred = true;
253
+ }
254
+ // Retry logic in case of error or response not OK
255
+ if (errorOccurred && retryCount < PREFLIGHT_RETRY_COUNT) {
256
+ const delay = 50 * Math.pow(2, retryCount) // Exponential back-off
257
+ ;
258
+ await new Promise((resolve)=>setTimeout(resolve, delay)) // delay with exponential back-off for each retry
259
+ ;
260
+ console.log(`Retrying... Attempt number ${retryCount + 1}`);
261
+ return checkConnectorUrl(retryCount + 1);
262
+ }
263
+ const errorMessage = getErrorMessage(responseStatus, error);
264
+ const errorToSend = error || new Error(errorMessage);
265
+ const context = {
266
+ connectorUrl,
267
+ responseStatus
268
+ };
269
+ if (responseStatus !== 404) errorReporter.send(errorToSend, context);
270
+ return {
271
+ checked: true,
272
+ error: errorMessage
273
+ };
274
+ }, [
275
+ connectorUrl
276
+ ]);
277
+ useEffect(()=>{
278
+ if (preFlightCheck.checked) return;
279
+ const fetchDataAndSetState = async ()=>{
280
+ const connectorUrlStatus = await checkConnectorUrl();
281
+ setPreFlightCheck(connectorUrlStatus);
282
+ };
283
+ fetchDataAndSetState();
284
+ }, [
285
+ checkConnectorUrl,
286
+ preFlightCheck
287
+ ]);
288
+ const initInjectedJavaScript = useCallback(()=>{
289
+ const script = `\
290
+ const options = {\
291
+ source: 'quiltt',\
292
+ type: 'Options',\
293
+ token: '${session?.token}',\
294
+ connectorId: '${connectorId}',\
295
+ connectionId: '${connectionId}',\
296
+ institution: '${institution}', \
297
+ };\
298
+ const compactedOptions = Object.keys(options).reduce((acc, key) => {\
299
+ if (options[key] !== 'undefined') {\
300
+ acc[key] = options[key];\
301
+ }\
302
+ return acc;\
303
+ }, {});\
304
+ window.postMessage(compactedOptions);\
305
+ `;
306
+ webViewRef.current?.injectJavaScript(script);
307
+ }, [
308
+ connectionId,
309
+ connectorId,
310
+ institution,
311
+ session?.token
312
+ ]);
313
+ // allowedListUrl & shouldRender ensure we are only rendering Quiltt, MX and Plaid content in Webview
314
+ // For other urls, we assume those are bank urls, which needs to be handle in external browser.
315
+ // @todo Convert it to a list from Quiltt Server to prevent MX/ Plaid changes.
316
+ const allowedListUrl = useMemo(()=>[
317
+ 'quiltt.app',
318
+ 'quiltt.dev',
319
+ 'moneydesktop.com',
320
+ 'cdn.plaid.com/link/v2/stable/link.html'
321
+ ], []);
322
+ const isQuilttEvent = useCallback((url)=>url.protocol === 'quilttconnector:', []);
323
+ const shouldRender = useCallback((url)=>{
324
+ if (isQuilttEvent(url)) return false;
325
+ if (url.protocol !== 'https:') {
326
+ return false;
327
+ }
328
+ return allowedListUrl.some((href)=>url.href.includes(href));
329
+ }, [
330
+ allowedListUrl,
331
+ isQuilttEvent
332
+ ]);
333
+ const clearLocalStorage = ()=>{
334
+ const script = 'localStorage.clear();';
335
+ webViewRef.current?.injectJavaScript(script);
336
+ };
337
+ const handleOAuthUrl = useCallback((oauthUrl)=>{
338
+ if (oauthUrl.protocol !== 'https:') {
339
+ console.log(`handleOAuthUrl - Skipping non https url - ${oauthUrl.href}`);
340
+ return;
341
+ }
342
+ Linking.openURL(oauthUrl.href);
343
+ }, []);
344
+ const handleQuilttEvent = useCallback((url)=>{
345
+ url.searchParams.delete('source');
346
+ url.searchParams.append('connectorId', connectorId);
347
+ const metadata = Object.fromEntries(url.searchParams);
348
+ const eventType = url.host;
349
+ switch(eventType){
350
+ case 'Load':
351
+ initInjectedJavaScript();
352
+ onEvent?.(ConnectorSDKEventType.Load, metadata);
353
+ onLoad?.(metadata);
354
+ break;
355
+ case 'ExitAbort':
356
+ clearLocalStorage();
357
+ onEvent?.(ConnectorSDKEventType.ExitAbort, metadata);
358
+ onExit?.(ConnectorSDKEventType.ExitAbort, metadata);
359
+ onExitAbort?.(metadata);
360
+ break;
361
+ case 'ExitError':
362
+ clearLocalStorage();
363
+ onEvent?.(ConnectorSDKEventType.ExitError, metadata);
364
+ onExit?.(ConnectorSDKEventType.ExitError, metadata);
365
+ onExitError?.(metadata);
366
+ break;
367
+ case 'ExitSuccess':
368
+ clearLocalStorage();
369
+ onEvent?.(ConnectorSDKEventType.ExitSuccess, metadata);
370
+ onExit?.(ConnectorSDKEventType.ExitSuccess, metadata);
371
+ onExitSuccess?.(metadata);
372
+ break;
373
+ case 'Authenticate':
374
+ break;
375
+ case 'OauthRequested':
376
+ handleOAuthUrl(new URL(url.searchParams.get('oauthUrl')));
377
+ break;
378
+ default:
379
+ console.log('unhandled event', url);
380
+ break;
381
+ }
382
+ }, [
383
+ connectorId,
384
+ handleOAuthUrl,
385
+ initInjectedJavaScript,
386
+ onEvent,
387
+ onExit,
388
+ onExitAbort,
389
+ onExitError,
390
+ onExitSuccess,
391
+ onLoad
392
+ ]);
393
+ const requestHandler = useCallback((request)=>{
394
+ const url = new URL(request.url);
395
+ if (isQuilttEvent(url)) {
396
+ handleQuilttEvent(url);
397
+ return false;
398
+ }
399
+ if (shouldRender(url)) return true;
400
+ // Plaid set oauth url by doing window.location.href = url
401
+ // So we use `handleOAuthUrl` as a catch all and assume all url got to this step is Plaid OAuth url
402
+ handleOAuthUrl(url);
403
+ return false;
404
+ }, [
405
+ handleOAuthUrl,
406
+ handleQuilttEvent,
407
+ isQuilttEvent,
408
+ shouldRender
409
+ ]);
410
+ if (!preFlightCheck.checked) return /*#__PURE__*/ jsx(LoadingScreen, {});
411
+ if (preFlightCheck.error) return /*#__PURE__*/ jsx(ErrorScreen, {
412
+ error: preFlightCheck.error,
413
+ cta: ()=>onExitError?.({
414
+ connectorId
415
+ })
416
+ });
417
+ return /*#__PURE__*/ jsx(AndroidSafeAreaView, {
418
+ children: /*#__PURE__*/ jsx(WebView, {
419
+ ref: webViewRef,
420
+ // Plaid keep sending window.location = 'about:srcdoc' and causes some noise in RN
421
+ // All whitelists are now handled in requestHandler, handleQuilttEvent and handleOAuthUrl
422
+ originWhitelist: [
423
+ '*'
424
+ ],
425
+ source: {
426
+ uri: connectorUrl
427
+ },
428
+ onShouldStartLoadWithRequest: requestHandler,
429
+ javaScriptEnabled: true,
430
+ domStorageEnabled: true,
431
+ webviewDebuggingEnabled: true
432
+ })
433
+ });
434
+ };
435
+ QuilttConnector.displayName = 'QuilttConnector';
436
+
437
+ // Hermes doesn't have atob
438
+ // https://github.com/facebook/hermes/issues/1178
439
+ if (!global.atob) {
440
+ global.atob = decode;
441
+ }
442
+
443
+ export { QuilttConnector };
package/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "@quiltt/react-native",
3
- "version": "3.5.3",
3
+ "version": "3.5.5",
4
4
  "description": "React Native components for Quiltt Connector",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "types": "./dist/index.d.ts"
10
+ }
11
+ },
5
12
  "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
13
+ "module": "./dist/index.js",
7
14
  "types": "./dist/index.d.ts",
8
15
  "files": [
9
16
  "dist/**",
@@ -13,30 +20,24 @@
13
20
  "repository": {
14
21
  "type": "git",
15
22
  "url": "https://github.com/quiltt/quiltt-public.git",
16
- "directory": "ECMAScript/react-native"
17
- },
18
- "homepage": "https://github.com/quiltt/quiltt-public/tree/main/ECMAScript/react-native#readme",
19
- "peerDependencies": {
20
- "react": "^18.2.0",
21
- "react-native": "^0.72.5",
22
- "react-native-webview": "^13.0.0",
23
- "base-64": "*",
24
- "react-native-url-polyfill": "*"
23
+ "directory": "packages/react-native"
25
24
  },
25
+ "homepage": "https://github.com/quiltt/quiltt-public/tree/main/packages/react-native#readme",
26
26
  "dependencies": {
27
27
  "@honeybadger-io/core": "6.5.1",
28
- "@quiltt/react": "3.5.3",
29
- "@quiltt/core": "3.5.3"
28
+ "@quiltt/core": "3.5.5",
29
+ "@quiltt/react": "3.5.5"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@apollo/client": "3.7.16",
33
33
  "@trivago/prettier-plugin-sort-imports": "4.1.1",
34
34
  "@types/base-64": "0.1.0",
35
- "@types/node": "20.11.4",
36
- "@types/react": "18.2.7",
35
+ "@types/node": "20.11.25",
36
+ "@types/react": "18.2.64",
37
37
  "@types/react-native": "0.72.5",
38
38
  "@typescript-eslint/eslint-plugin": "5.60.1",
39
39
  "@typescript-eslint/parser": "5.60.1",
40
+ "bunchee": "4.4.8",
40
41
  "eslint": "8.43.0",
41
42
  "eslint-config-prettier": "8.8.0",
42
43
  "eslint-plugin-jsx-a11y": "6.7.1",
@@ -45,17 +46,24 @@
45
46
  "eslint-plugin-react-hooks": "4.6.0",
46
47
  "prettier": "2.8.8",
47
48
  "react": "18.2.0",
48
- "tsup": "6.7.0",
49
- "typescript": "5.1.3"
49
+ "rimraf": "5.0.5",
50
+ "typescript": "5.4.2"
51
+ },
52
+ "peerDependencies": {
53
+ "react": "^18.2.0",
54
+ "react-native": "^0.72.5",
55
+ "react-native-webview": "^13.0.0",
56
+ "base-64": "*",
57
+ "react-native-url-polyfill": "*"
50
58
  },
51
59
  "license": "MIT",
52
60
  "publishConfig": {
53
61
  "access": "public"
54
62
  },
55
63
  "scripts": {
56
- "build": "pnpm run addApiKey && pnpm run addVersion && tsup",
64
+ "build": "pnpm run addApiKey && pnpm run addVersion && bunchee",
57
65
  "clean": "rimraf .turbo dist",
58
- "dev": "tsup --watch",
66
+ "dev": "bunchee --watch",
59
67
  "addVersion": "genversion --esm -f src/version.ts",
60
68
  "addApiKey": "node scripts/addApiKey.js",
61
69
  "lint": "TIMING=1 eslint --ext .js,.jsx,.ts,.tsx src/ --fix",
@@ -1,6 +1,7 @@
1
- import { SafeAreaView, StyleSheet, Platform, StatusBar } from 'react-native'
2
1
  import { PropsWithChildren } from 'react'
3
2
 
3
+ import { SafeAreaView, StyleSheet, Platform, StatusBar } from 'react-native'
4
+
4
5
  export const AndroidSafeAreaView = ({ children }: PropsWithChildren) => (
5
6
  <SafeAreaView style={styles.AndroidSafeArea}>{children}</SafeAreaView>
6
7
  )
@@ -1,4 +1,5 @@
1
1
  import { View, Text, Pressable, StyleSheet } from 'react-native'
2
+
2
3
  import { AndroidSafeAreaView } from './AndroidSafeAreaView'
3
4
 
4
5
  type ErrorScreenProp = {
@@ -1,4 +1,5 @@
1
1
  import { ActivityIndicator, View } from 'react-native'
2
+
2
3
  import { AndroidSafeAreaView } from './AndroidSafeAreaView'
3
4
 
4
5
  export const LoadingScreen = () => (
@@ -1,28 +1,31 @@
1
- import {
2
- ConnectorSDKCallbackMetadata,
3
- ConnectorSDKCallbacks,
4
- ConnectorSDKEventType,
5
- } from '@quiltt/core'
6
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
2
+
7
3
  import { Linking, Platform } from 'react-native'
8
- import { WebView } from 'react-native-webview'
9
4
  // React Native's URL implementation is incomplete
10
5
  // https://github.com/facebook/react-native/issues/16434
11
6
  import { URL } from 'react-native-url-polyfill'
12
- import { AndroidSafeAreaView } from './AndroidSafeAreaView'
7
+ import { WebView } from 'react-native-webview'
13
8
  import type { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes'
14
- import { useQuilttSession } from '@quiltt/react'
15
- import { ErrorReporter, getErrorMessage } from '../utils/'
16
9
 
10
+ import {
11
+ ConnectorSDKCallbackMetadata,
12
+ ConnectorSDKCallbacks,
13
+ ConnectorSDKEventType,
14
+ useQuilttSession,
15
+ } from '@quiltt/react'
16
+
17
+ import { ErrorReporter, getErrorMessage } from '../utils'
17
18
  import { version } from '../version'
18
- import { LoadingScreen } from './LoadingScreen'
19
+ import { AndroidSafeAreaView } from './AndroidSafeAreaView'
19
20
  import { ErrorScreen } from './ErrorScreen'
21
+ import { LoadingScreen } from './LoadingScreen'
20
22
 
21
23
  const errorReporter = new ErrorReporter(`${Platform.OS} ${Platform.Version}`)
22
24
 
23
25
  type QuilttConnectorProps = {
24
26
  connectorId: string
25
27
  connectionId?: string
28
+ institution?: string
26
29
  oauthRedirectUrl: string
27
30
  } & ConnectorSDKCallbacks
28
31
 
@@ -33,9 +36,10 @@ type PreFlightCheck = {
33
36
 
34
37
  const PREFLIGHT_RETRY_COUNT = 3
35
38
 
36
- export const QuilttConnector = ({
39
+ const QuilttConnector = ({
37
40
  connectorId,
38
41
  connectionId,
42
+ institution,
39
43
  oauthRedirectUrl,
40
44
  onEvent,
41
45
  onLoad,
@@ -46,9 +50,17 @@ export const QuilttConnector = ({
46
50
  }: QuilttConnectorProps) => {
47
51
  const webViewRef = useRef<WebView>(null)
48
52
  const { session } = useQuilttSession()
49
- oauthRedirectUrl = encodeURIComponent(oauthRedirectUrl)
50
- const connectorUrl = `https://${connectorId}.quiltt.app/?mode=webview&oauth_redirect_url=${oauthRedirectUrl}&agent=react-native-${version}`
51
- console.log('connectorUrl', connectorUrl)
53
+ const encodedOAuthRedirectUrl = useMemo(
54
+ () => encodeURIComponent(oauthRedirectUrl),
55
+ [oauthRedirectUrl]
56
+ )
57
+ const connectorUrl = useMemo(() => {
58
+ const url: URL = new URL(`https://${connectorId}.quiltt.app`)
59
+ url.searchParams.append('mode', 'webview')
60
+ url.searchParams.append('oauth_redirect_url', encodedOAuthRedirectUrl)
61
+ url.searchParams.append('agent', `react-native-${version}`)
62
+ return url.toString()
63
+ }, [connectorId, encodedOAuthRedirectUrl])
52
64
  const [preFlightCheck, setPreFlightCheck] = useState<PreFlightCheck>({ checked: false })
53
65
 
54
66
  const checkConnectorUrl = useCallback(
@@ -74,7 +86,8 @@ export const QuilttConnector = ({
74
86
 
75
87
  // Retry logic in case of error or response not OK
76
88
  if (errorOccurred && retryCount < PREFLIGHT_RETRY_COUNT) {
77
- await new Promise((resolve) => setTimeout(resolve, 50 * retryCount)) // delay for 50ms for each retry
89
+ const delay = 50 * Math.pow(2, retryCount) // Exponential back-off
90
+ await new Promise((resolve) => setTimeout(resolve, delay)) // delay with exponential back-off for each retry
78
91
  console.log(`Retrying... Attempt number ${retryCount + 1}`)
79
92
  return checkConnectorUrl(retryCount + 1)
80
93
  }
@@ -105,6 +118,7 @@ export const QuilttConnector = ({
105
118
  token: '${session?.token}',\
106
119
  connectorId: '${connectorId}',\
107
120
  connectionId: '${connectionId}',\
121
+ institution: '${institution}', \
108
122
  };\
109
123
  const compactedOptions = Object.keys(options).reduce((acc, key) => {\
110
124
  if (options[key] !== 'undefined') {\
@@ -115,7 +129,7 @@ export const QuilttConnector = ({
115
129
  window.postMessage(compactedOptions);\
116
130
  `
117
131
  webViewRef.current?.injectJavaScript(script)
118
- }, [connectionId, connectorId, session?.token])
132
+ }, [connectionId, connectorId, institution, session?.token])
119
133
 
120
134
  // allowedListUrl & shouldRender ensure we are only rendering Quiltt, MX and Plaid content in Webview
121
135
  // For other urls, we assume those are bank urls, which needs to be handle in external browser.
@@ -136,8 +150,6 @@ export const QuilttConnector = ({
136
150
  (url: URL) => {
137
151
  if (isQuilttEvent(url)) return false
138
152
  if (url.protocol !== 'https:') {
139
- const err = new Error(`Invalid url leaked ${url.href}`)
140
- errorReporter.send(err)
141
153
  return false
142
154
  }
143
155
  return allowedListUrl.some((href) => url.href.includes(href))
@@ -238,7 +250,9 @@ export const QuilttConnector = ({
238
250
  <AndroidSafeAreaView>
239
251
  <WebView
240
252
  ref={webViewRef}
241
- originWhitelist={['https://*', 'quilttconnector://*']} // Guard against other non SDK needed url
253
+ // Plaid keep sending window.location = 'about:srcdoc' and causes some noise in RN
254
+ // All whitelists are now handled in requestHandler, handleQuilttEvent and handleOAuthUrl
255
+ originWhitelist={['*']}
242
256
  source={{ uri: connectorUrl }}
243
257
  onShouldStartLoadWithRequest={requestHandler}
244
258
  javaScriptEnabled
@@ -249,4 +263,6 @@ export const QuilttConnector = ({
249
263
  )
250
264
  }
251
265
 
252
- export default QuilttConnector
266
+ QuilttConnector.displayName = 'QuilttConnector'
267
+
268
+ export { QuilttConnector }
@@ -0,0 +1 @@
1
+ export * from './QuilttConnector'
package/src/index.ts CHANGED
@@ -1,10 +1,36 @@
1
1
  // Hermes doesn't have atob
2
2
  // https://github.com/facebook/hermes/issues/1178
3
3
  import { decode } from 'base-64'
4
+
4
5
  if (!global.atob) {
5
6
  global.atob = decode
6
7
  }
7
- import QuilttConnector from './components/QuilttConnector'
8
8
 
9
- export { QuilttConnector }
10
- export default QuilttConnector
9
+ /* export type {
10
+ ConnectorSDK,
11
+ ConnectorSDKCallbacks,
12
+ ConnectorSDKOnEventCallback,
13
+ ConnectorSDKOnLoadCallback,
14
+ ConnectorSDKOnExitSuccessCallback,
15
+ ConnectorSDKOnExitAbortCallback,
16
+ ConnectorSDKOnExitErrorCallback,
17
+ ConnectorSDKEventType,
18
+ ConnectorSDKCallbackMetadata,
19
+ ConnectorSDKConnectOptions,
20
+ } */
21
+
22
+ export * from '@quiltt/core'
23
+
24
+ export {
25
+ QuilttAuthProvider,
26
+ QuilttProvider,
27
+ QuilttSettingsProvider,
28
+ useQuilttClient,
29
+ useQuilttConnector,
30
+ useQuilttSession,
31
+ useQuilttSettings,
32
+ useSession,
33
+ useStorage,
34
+ } from '@quiltt/react'
35
+
36
+ export * from './components'
@@ -102,4 +102,4 @@ class ErrorReporter {
102
102
  }
103
103
  }
104
104
 
105
- export { ErrorReporter }
105
+ export { ErrorReporter }
@@ -1,5 +1,6 @@
1
1
  const getErrorMessage = (responseStatus?: number, error?: Error): string => {
2
- if (error) return `An error occurred while checking the connector URL: ${error?.name} \n${error?.message}`
2
+ if (error)
3
+ return `An error occurred while checking the connector URL: ${error?.name} \n${error?.message}`
3
4
  return responseStatus
4
5
  ? `The URL is not routable. Response status: ${responseStatus}`
5
6
  : 'An error occurred while checking the connector URL'
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '3.5.3'
2
+ export const version = '3.5.5'
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/components/QuilttConnector.tsx","../src/components/AndroidSafeAreaView.tsx","../src/utils/ErrorReporter.ts","../src/utils/ErrorReporterConfig.ts","../src/version.ts","../src/utils/getErrorMessage.ts","../src/components/LoadingScreen.tsx","../src/components/ErrorScreen.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, useEffect, useMemo, useRef, useState } from 'react'\nimport { Linking, Platform } 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 { ErrorReporter, getErrorMessage } from '../utils/'\n\nimport { version } from '../version'\nimport { LoadingScreen } from './LoadingScreen'\nimport { ErrorScreen } from './ErrorScreen'\n\nconst errorReporter = new ErrorReporter(`${Platform.OS} ${Platform.Version}`)\n\ntype QuilttConnectorProps = {\n connectorId: string\n connectionId?: string\n oauthRedirectUrl: string\n} & ConnectorSDKCallbacks\n\ntype PreFlightCheck = {\n checked: boolean\n error?: string\n}\n\nconst PREFLIGHT_RETRY_COUNT = 3\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 console.log('connectorUrl', connectorUrl)\n const [preFlightCheck, setPreFlightCheck] = useState<PreFlightCheck>({ checked: false })\n\n const checkConnectorUrl = useCallback(\n async (retryCount = 0): Promise<PreFlightCheck> => {\n let responseStatus\n let error\n let errorOccurred = false\n try {\n const response = await fetch(connectorUrl)\n if (!response.ok) {\n console.error(`The URL ${connectorUrl} is not routable.`)\n responseStatus = response.status\n errorOccurred = true\n } else {\n console.log(`The URL ${connectorUrl} is routable.`)\n return { checked: true }\n }\n } catch (e) {\n error = e\n console.error(`An error occurred while checking the connector URL: ${error}`)\n errorOccurred = true\n }\n\n // Retry logic in case of error or response not OK\n if (errorOccurred && retryCount < PREFLIGHT_RETRY_COUNT) {\n await new Promise((resolve) => setTimeout(resolve, 50 * retryCount)) // delay for 50ms for each retry\n console.log(`Retrying... Attempt number ${retryCount + 1}`)\n return checkConnectorUrl(retryCount + 1)\n }\n\n const errorMessage = getErrorMessage(responseStatus, error as Error)\n const errorToSend = (error as Error) || new Error(errorMessage)\n const context = { connectorUrl, responseStatus }\n if (responseStatus !== 404) errorReporter.send(errorToSend, context)\n return { checked: true, error: errorMessage }\n },\n [connectorUrl]\n )\n\n useEffect(() => {\n if (preFlightCheck.checked) return\n const fetchDataAndSetState = async () => {\n const connectorUrlStatus = await checkConnectorUrl()\n setPreFlightCheck(connectorUrlStatus)\n }\n fetchDataAndSetState()\n }, [checkConnectorUrl, preFlightCheck])\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 = useMemo(\n () => [\n 'quiltt.app',\n 'quiltt.dev',\n 'moneydesktop.com',\n 'cdn.plaid.com/link/v2/stable/link.html',\n ],\n []\n )\n\n const isQuilttEvent = useCallback((url: URL) => url.protocol === 'quilttconnector:', [])\n\n const shouldRender = useCallback(\n (url: URL) => {\n if (isQuilttEvent(url)) return false\n if (url.protocol !== 'https:') {\n const err = new Error(`Invalid url leaked ${url.href}`)\n errorReporter.send(err)\n return false\n }\n return allowedListUrl.some((href) => url.href.includes(href))\n },\n [allowedListUrl, isQuilttEvent]\n )\n\n const clearLocalStorage = () => {\n const script = 'localStorage.clear();'\n webViewRef.current?.injectJavaScript(script)\n }\n\n const handleOAuthUrl = useCallback((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 const handleQuilttEvent = useCallback(\n (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 connectorId,\n handleOAuthUrl,\n initInjectedJavaScript,\n onEvent,\n onExit,\n onExitAbort,\n onExitError,\n onExitSuccess,\n onLoad,\n ]\n )\n\n const requestHandler = useCallback(\n (request: ShouldStartLoadRequest) => {\n const url = new URL(request.url)\n\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 // So we use `handleOAuthUrl` as a catch all and assume all url got to this step is Plaid OAuth url\n handleOAuthUrl(url)\n return false\n },\n [handleOAuthUrl, handleQuilttEvent, isQuilttEvent, shouldRender]\n )\n\n if (!preFlightCheck.checked) return <LoadingScreen />\n if (preFlightCheck.error)\n return <ErrorScreen error={preFlightCheck.error} cta={() => onExitError?.({ connectorId })} />\n\n return (\n <AndroidSafeAreaView>\n <WebView\n ref={webViewRef}\n originWhitelist={['https://*', 'quilttconnector://*']} // Guard against other non SDK needed url\n source={{ uri: connectorUrl }}\n onShouldStartLoadWithRequest={requestHandler}\n javaScriptEnabled\n domStorageEnabled // To enable localStorage in Android webview\n webviewDebuggingEnabled\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","// Quick hack to send error to Honeybadger to debug why the connector is not routable\n\nimport type { Notice, NoticeTransportPayload } from '@honeybadger-io/core/build/src/types'\nimport { generateStackTrace, getCauses, makeBacktrace } from '@honeybadger-io/core/build/src/util'\n\nimport { ErrorReporterConfig } from './ErrorReporterConfig'\nimport { version } from '../version'\n\nconst notifier = {\n name: 'Quiltt React Native SDK Reporter',\n url: 'https://www.quiltt.dev/guides/connector/react-native',\n version: version,\n}\n\ntype HoneybadgerResponseData = {\n id: string\n}\n\nclass ErrorReporter {\n private noticeUrl: string\n private apiKey: string\n private clientName: string\n private clientVersion: string\n private platform: string\n private logger: Console\n private userAgent: string\n\n constructor(platform: string) {\n this.noticeUrl = 'https://api.honeybadger.io/v1/notices'\n this.apiKey = ErrorReporterConfig.honeybadger_api_key\n this.clientName = 'react-native-sdk'\n this.clientVersion = version\n this.platform = platform\n this.logger = console\n this.userAgent = `${this.clientName} ${this.clientVersion}; ${this.platform}`\n }\n\n async send(error: Error, context?: any): Promise<void> {\n const headers = {\n 'X-API-Key': this.apiKey,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'User-Agent': `${this.clientName} ${this.clientVersion}; ${this.platform}`,\n }\n\n const payload = await this.buildPayload(error, context)\n const method = 'POST'\n const body = JSON.stringify(payload)\n const mode = 'cors'\n\n fetch(this.noticeUrl, { headers, method, body, mode })\n .then((response) => {\n if (response.status !== 201) {\n this.logger.warn(\n `Error report failed: unknown response from server. code=${response.status}`\n )\n return\n }\n return response.json()\n })\n .then((data: HoneybadgerResponseData) => {\n if (data) {\n this.logger.info(`Error report sent ⚡ https://app.honeybadger.io/notice/${data?.id}`)\n }\n })\n }\n\n async buildPayload(error: Error, localContext = {}): Promise<Partial<NoticeTransportPayload>> {\n const notice: Notice = error as Notice\n notice.stack = generateStackTrace()\n\n notice.backtrace = makeBacktrace(notice.stack)\n\n return {\n notifier,\n error: {\n class: notice.name as string,\n message: notice.message as string,\n backtrace: notice.backtrace,\n // fingerprint: this.calculateFingerprint(notice),\n tags: notice.tags || [],\n causes: getCauses(notice, this.logger),\n },\n request: {\n url: notice.url,\n component: notice.component,\n action: notice.action,\n context: localContext || {},\n cgi_data: {},\n params: {},\n session: {},\n },\n server: {\n project_root: notice.projectRoot,\n environment_name: this.userAgent,\n revision: version,\n hostname: this.platform,\n time: new Date().toUTCString(),\n },\n details: notice.details || {},\n }\n }\n}\n\nexport { ErrorReporter }","\nexport const ErrorReporterConfig = {\n honeybadger_api_key: 'undefined',\n}\n","// Generated by genversion.\nexport const version = '3.5.3'\n","const getErrorMessage = (responseStatus?: number, error?: Error): string => {\n if (error) return `An error occurred while checking the connector URL: ${error?.name} \\n${error?.message}`\n return responseStatus\n ? `The URL is not routable. Response status: ${responseStatus}`\n : 'An error occurred while checking the connector URL'\n}\n\nexport { getErrorMessage }\n","import { ActivityIndicator, View } from 'react-native'\nimport { AndroidSafeAreaView } from './AndroidSafeAreaView'\n\nexport const LoadingScreen = () => (\n <AndroidSafeAreaView>\n <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>\n <ActivityIndicator size=\"large\" color=\"#0000ff\" />\n </View>\n </AndroidSafeAreaView>\n)\n","import { View, Text, Pressable, StyleSheet } from 'react-native'\nimport { AndroidSafeAreaView } from './AndroidSafeAreaView'\n\ntype ErrorScreenProp = {\n error: string\n cta: () => void\n}\n\nexport const ErrorScreen = ({ error, cta }: ErrorScreenProp) => (\n <AndroidSafeAreaView>\n <View style={[styles.container, styles.padding]}>\n <View style={{ flex: 1, justifyContent: 'center' }}>\n <View\n style={{\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n marginVertical: 10,\n }}\n >\n <Text style={[styles.title]}>Cannot connect to the internet.</Text>\n </View>\n <Text style={[styles.subtitle]}>{error}</Text>\n </View>\n <Pressable style={[styles.pressable]} onPress={cta}>\n <Text style={[styles.pressableText]}>Exit</Text>\n </Pressable>\n </View>\n </AndroidSafeAreaView>\n)\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n flexDirection: 'column',\n justifyContent: 'flex-start',\n alignItems: 'stretch',\n backgroundColor: '#F3F4F6',\n },\n title: {\n color: '#1F2937',\n fontSize: 30,\n fontWeight: 'bold',\n },\n subtitle: {\n color: 'rgba(107, 114, 128, 1)',\n },\n padding: {\n paddingHorizontal: 16, // sm:px-4\n paddingVertical: 24, // sm:py-6\n },\n pressable: {\n marginTop: 20,\n backgroundColor: '#1F2937',\n padding: 10,\n paddingHorizontal: 25,\n borderRadius: 5,\n },\n pressableText: {\n color: '#fff',\n textAlign: 'center',\n },\n})\n"],"mappings":"8wBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,qBAAAE,EAAA,YAAAC,KAAA,eAAAC,GAAAJ,IAEA,IAAAK,GAAuB,mBCFvB,IAAAC,EAIO,wBACPC,EAAkE,iBAClEC,EAAkC,wBAClCC,EAAwB,gCAGxBC,EAAoB,qCCVpB,IAAAC,EAA8D,wBAI5DC,EAAA,6BADWC,EAAsB,CAAC,CAAE,SAAAC,CAAS,OAC7C,OAAC,gBAAa,MAAOC,GAAO,gBAAkB,SAAAD,EAAS,EAGnDC,GAAS,aAAW,OAAO,CAC/B,gBAAiB,CACf,KAAM,EACN,gBAAiB,QACjB,WAAY,WAAS,KAAO,UAAY,YAAU,cAAgB,CACpE,CACF,CAAC,EDAD,IAAAC,EAAiC,yBEVjC,IAAAC,EAA6D,+CCFtD,IAAMC,EAAsB,CACjC,oBAAqB,WACvB,ECFO,IAAMC,EAAU,QFOvB,IAAMC,GAAW,CACf,KAAM,mCACN,IAAK,uDACL,QAASC,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ClC,KACJ,CACF,EACA,CACElC,EACAuC,EACAV,EACA1B,EACAE,EACAE,EACAC,EACAF,EACAF,CACF,CACF,EAEMuC,MAAiB,eACpBC,GAAoC,CACnC,IAAMV,EAAM,IAAI,MAAIU,EAAQ,GAAG,EAE/B,OAAIX,EAAcC,CAAG,GACnBO,EAAkBP,CAAG,EACd,IAELC,EAAaD,CAAG,EAAU,IAG9BK,EAAeL,CAAG,EACX,GACT,EACA,CAACK,EAAgBE,EAAmBR,EAAeE,CAAY,CACjE,EAEA,OAAKtB,EAAe,QAChBA,EAAe,SACV,OAACgC,EAAA,CAAY,MAAOhC,EAAe,MAAO,IAAK,IAAML,GAAA,YAAAA,EAAc,CAAE,YAAAR,CAAY,GAAI,KAG5F,OAAC8C,EAAA,CACC,mBAAC,WACC,IAAKrC,EACL,gBAAiB,CAAC,YAAa,qBAAqB,EACpD,OAAQ,CAAE,IAAKE,CAAa,EAC5B,6BAA8BgC,GAC9B,kBAAiB,GACjB,kBAAiB,GACjB,wBAAuB,GACzB,EACF,KAfkC,OAACI,EAAA,EAAc,CAiBrD,EAEOC,EAAQjD,GDxPV,OAAO,OACV,OAAO,KAAO,WAKhB,IAAOkD,GAAQC","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","import_util","ErrorReporterConfig","version","notifier","version","ErrorReporter","platform","__publicField","ErrorReporterConfig","error","context","__async","headers","payload","method","body","mode","response","data","_0","localContext","notice","getErrorMessage","responseStatus","error","import_react_native","import_jsx_runtime","LoadingScreen","AndroidSafeAreaView","import_react_native","import_jsx_runtime","ErrorScreen","error","cta","AndroidSafeAreaView","styles","import_jsx_runtime","errorReporter","ErrorReporter","PREFLIGHT_RETRY_COUNT","QuilttConnector","connectorId","connectionId","oauthRedirectUrl","onEvent","onLoad","onExit","onExitSuccess","onExitAbort","onExitError","webViewRef","session","connectorUrl","version","preFlightCheck","setPreFlightCheck","checkConnectorUrl","retryCount","__async","responseStatus","error","errorOccurred","response","e","resolve","errorMessage","getErrorMessage","errorToSend","context","connectorUrlStatus","initInjectedJavaScript","_a","script","allowedListUrl","isQuilttEvent","url","shouldRender","err","href","clearLocalStorage","handleOAuthUrl","oauthUrl","handleQuilttEvent","metadata","requestHandler","request","ErrorScreen","AndroidSafeAreaView","LoadingScreen","QuilttConnector_default","src_default","QuilttConnector_default"]}
package/dist/index.mjs DELETED
@@ -1,3 +0,0 @@
1
- var E=Object.defineProperty;var ee=(s,r,i)=>r in s?E(s,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[r]=i;var d=(s,r,i)=>(ee(s,typeof r!="symbol"?r+"":r,i),i);var y=(s,r,i)=>new Promise((n,a)=>{var c=o=>{try{l(i.next(o))}catch(f){a(f)}},p=o=>{try{l(i.throw(o))}catch(f){a(f)}},l=o=>o.done?n(o.value):Promise.resolve(o.value).then(c,p);l((i=i.apply(s,r)).next())});import{decode as Re}from"base-64";import{ConnectorSDKEventType as g}from"@quiltt/core";import{useCallback as u,useEffect as ue,useMemo as me,useRef as be,useState as ye}from"react";import{Linking as ke,Platform as z}from"react-native";import{WebView as Se}from"react-native-webview";import{URL as J}from"react-native-url-polyfill";import{SafeAreaView as te,StyleSheet as re,Platform as oe,StatusBar as ae}from"react-native";import{jsx as ie}from"react/jsx-runtime";var k=({children:s})=>ie(te,{style:se.AndroidSafeArea,children:s}),se=re.create({AndroidSafeArea:{flex:1,backgroundColor:"white",paddingTop:oe.OS==="android"?ae.currentHeight:0}});import{useQuilttSession as we}from"@quiltt/react";import{generateStackTrace as ne,getCauses as ce,makeBacktrace as le}from"@honeybadger-io/core/build/src/util";var I={honeybadger_api_key:"undefined"};var S="3.5.3";var pe={name:"Quiltt React Native SDK Reporter",url:"https://www.quiltt.dev/guides/connector/react-native",version:S},V=class{constructor(r){d(this,"noticeUrl");d(this,"apiKey");d(this,"clientName");d(this,"clientVersion");d(this,"platform");d(this,"logger");d(this,"userAgent");this.noticeUrl="https://api.honeybadger.io/v1/notices",this.apiKey=I.honeybadger_api_key,this.clientName="react-native-sdk",this.clientVersion=S,this.platform=r,this.logger=console,this.userAgent=`${this.clientName} ${this.clientVersion}; ${this.platform}`}send(r,i){return y(this,null,function*(){let n={"X-API-Key":this.apiKey,"Content-Type":"application/json",Accept:"application/json","User-Agent":`${this.clientName} ${this.clientVersion}; ${this.platform}`},a=yield this.buildPayload(r,i),c="POST",p=JSON.stringify(a),l="cors";fetch(this.noticeUrl,{headers:n,method:c,body:p,mode:l}).then(o=>{if(o.status!==201){this.logger.warn(`Error report failed: unknown response from server. code=${o.status}`);return}return o.json()}).then(o=>{o&&this.logger.info(`Error report sent \u26A1 https://app.honeybadger.io/notice/${o==null?void 0:o.id}`)})})}buildPayload(n){return y(this,arguments,function*(r,i={}){let a=r;return a.stack=ne(),a.backtrace=le(a.stack),{notifier:pe,error:{class:a.name,message:a.message,backtrace:a.backtrace,tags:a.tags||[],causes:ce(a,this.logger)},request:{url:a.url,component:a.component,action:a.action,context:i||{},cgi_data:{},params:{},session:{}},server:{project_root:a.projectRoot,environment_name:this.userAgent,revision:S,hostname:this.platform,time:new Date().toUTCString()},details:a.details||{}}})}};var Q=(s,r)=>r?`An error occurred while checking the connector URL: ${r==null?void 0:r.name}
2
- ${r==null?void 0:r.message}`:s?`The URL is not routable. Response status: ${s}`:"An error occurred while checking the connector URL";import{ActivityIndicator as de,View as fe}from"react-native";import{jsx as D}from"react/jsx-runtime";var W=()=>D(k,{children:D(fe,{style:{flex:1,justifyContent:"center",alignItems:"center"},children:D(de,{size:"large",color:"#0000ff"})})});import{View as O,Text as q,Pressable as he,StyleSheet as ge}from"react-native";import{jsx as A,jsxs as H}from"react/jsx-runtime";var M=({error:s,cta:r})=>A(k,{children:H(O,{style:[w.container,w.padding],children:[H(O,{style:{flex:1,justifyContent:"center"},children:[A(O,{style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginVertical:10},children:A(q,{style:[w.title],children:"Cannot connect to the internet."})}),A(q,{style:[w.subtitle],children:s})]}),A(he,{style:[w.pressable],onPress:r,children:A(q,{style:[w.pressableText],children:"Exit"})})]})}),w=ge.create({container:{flex:1,flexDirection:"column",justifyContent:"flex-start",alignItems:"stretch",backgroundColor:"#F3F4F6"},title:{color:"#1F2937",fontSize:30,fontWeight:"bold"},subtitle:{color:"rgba(107, 114, 128, 1)"},padding:{paddingHorizontal:16,paddingVertical:24},pressable:{marginTop:20,backgroundColor:"#1F2937",padding:10,paddingHorizontal:25,borderRadius:5},pressableText:{color:"#fff",textAlign:"center"}});import{jsx as $}from"react/jsx-runtime";var B=new V(`${z.OS} ${z.Version}`),Ae=3,Ce=({connectorId:s,connectionId:r,oauthRedirectUrl:i,onEvent:n,onLoad:a,onExit:c,onExitSuccess:p,onExitAbort:l,onExitError:o})=>{let f=be(null),{session:m}=we();i=encodeURIComponent(i);let h=`https://${s}.quiltt.app/?mode=webview&oauth_redirect_url=${i}&agent=react-native-${S}`;console.log("connectorUrl",h);let[C,X]=ye({checked:!1}),U=u((t=0)=>y(void 0,null,function*(){let e,R,L=!1;try{let b=yield fetch(h);if(!b.ok)console.error(`The URL ${h} is not routable.`),e=b.status,L=!0;else return console.log(`The URL ${h} is routable.`),{checked:!0}}catch(b){R=b,console.error(`An error occurred while checking the connector URL: ${R}`),L=!0}if(L&&t<Ae)return yield new Promise(b=>setTimeout(b,50*t)),console.log(`Retrying... Attempt number ${t+1}`),U(t+1);let _=Q(e,R),x=R||new Error(_),Z={connectorUrl:h,responseStatus:e};return e!==404&&B.send(x,Z),{checked:!0,error:_}}),[h]);ue(()=>{if(C.checked)return;(()=>y(void 0,null,function*(){let e=yield U();X(e)}))()},[U,C]);let N=u(()=>{var e;let t=` const options = { source: 'quiltt', type: 'Options', token: '${m==null?void 0:m.token}', connectorId: '${s}', connectionId: '${r}', }; const compactedOptions = Object.keys(options).reduce((acc, key) => { if (options[key] !== 'undefined') { acc[key] = options[key]; } return acc; }, {}); window.postMessage(compactedOptions); `;(e=f.current)==null||e.injectJavaScript(t)},[r,s,m==null?void 0:m.token]),j=me(()=>["quiltt.app","quiltt.dev","moneydesktop.com","cdn.plaid.com/link/v2/stable/link.html"],[]),P=u(t=>t.protocol==="quilttconnector:",[]),F=u(t=>{if(P(t))return!1;if(t.protocol!=="https:"){let e=new Error(`Invalid url leaked ${t.href}`);return B.send(e),!1}return j.some(e=>t.href.includes(e))},[j,P]),v=()=>{var e;let t="localStorage.clear();";(e=f.current)==null||e.injectJavaScript(t)},T=u(t=>{if(t.protocol!=="https:"){console.log(`handleOAuthUrl - Skipping non https url - ${t.href}`);return}ke.openURL(t.href)},[]),K=u(t=>{t.searchParams.delete("source"),t.searchParams.append("connectorId",s);let e=Object.fromEntries(t.searchParams);switch(t.host){case"Load":N(),n==null||n(g.Load,e),a==null||a(e);break;case"ExitAbort":v(),n==null||n(g.ExitAbort,e),c==null||c(g.ExitAbort,e),l==null||l(e);break;case"ExitError":v(),n==null||n(g.ExitError,e),c==null||c(g.ExitError,e),o==null||o(e);break;case"ExitSuccess":v(),n==null||n(g.ExitSuccess,e),c==null||c(g.ExitSuccess,e),p==null||p(e);break;case"Authenticate":break;case"OauthRequested":T(new J(t.searchParams.get("oauthUrl")));break;default:console.log("unhandled event",t);break}},[s,T,N,n,c,l,o,p,a]),Y=u(t=>{let e=new J(t.url);return P(e)?(K(e),!1):F(e)?!0:(T(e),!1)},[T,K,P,F]);return C.checked?C.error?$(M,{error:C.error,cta:()=>o==null?void 0:o({connectorId:s})}):$(k,{children:$(Se,{ref:f,originWhitelist:["https://*","quilttconnector://*"],source:{uri:h},onShouldStartLoadWithRequest:Y,javaScriptEnabled:!0,domStorageEnabled:!0,webviewDebuggingEnabled:!0})}):$(W,{})},G=Ce;global.atob||(global.atob=Re);var ft=G;export{G as QuilttConnector,ft as default};
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/components/QuilttConnector.tsx","../src/components/AndroidSafeAreaView.tsx","../src/utils/ErrorReporter.ts","../src/utils/ErrorReporterConfig.ts","../src/version.ts","../src/utils/getErrorMessage.ts","../src/components/LoadingScreen.tsx","../src/components/ErrorScreen.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, useEffect, useMemo, useRef, useState } from 'react'\nimport { Linking, Platform } 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 { ErrorReporter, getErrorMessage } from '../utils/'\n\nimport { version } from '../version'\nimport { LoadingScreen } from './LoadingScreen'\nimport { ErrorScreen } from './ErrorScreen'\n\nconst errorReporter = new ErrorReporter(`${Platform.OS} ${Platform.Version}`)\n\ntype QuilttConnectorProps = {\n connectorId: string\n connectionId?: string\n oauthRedirectUrl: string\n} & ConnectorSDKCallbacks\n\ntype PreFlightCheck = {\n checked: boolean\n error?: string\n}\n\nconst PREFLIGHT_RETRY_COUNT = 3\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 console.log('connectorUrl', connectorUrl)\n const [preFlightCheck, setPreFlightCheck] = useState<PreFlightCheck>({ checked: false })\n\n const checkConnectorUrl = useCallback(\n async (retryCount = 0): Promise<PreFlightCheck> => {\n let responseStatus\n let error\n let errorOccurred = false\n try {\n const response = await fetch(connectorUrl)\n if (!response.ok) {\n console.error(`The URL ${connectorUrl} is not routable.`)\n responseStatus = response.status\n errorOccurred = true\n } else {\n console.log(`The URL ${connectorUrl} is routable.`)\n return { checked: true }\n }\n } catch (e) {\n error = e\n console.error(`An error occurred while checking the connector URL: ${error}`)\n errorOccurred = true\n }\n\n // Retry logic in case of error or response not OK\n if (errorOccurred && retryCount < PREFLIGHT_RETRY_COUNT) {\n await new Promise((resolve) => setTimeout(resolve, 50 * retryCount)) // delay for 50ms for each retry\n console.log(`Retrying... Attempt number ${retryCount + 1}`)\n return checkConnectorUrl(retryCount + 1)\n }\n\n const errorMessage = getErrorMessage(responseStatus, error as Error)\n const errorToSend = (error as Error) || new Error(errorMessage)\n const context = { connectorUrl, responseStatus }\n if (responseStatus !== 404) errorReporter.send(errorToSend, context)\n return { checked: true, error: errorMessage }\n },\n [connectorUrl]\n )\n\n useEffect(() => {\n if (preFlightCheck.checked) return\n const fetchDataAndSetState = async () => {\n const connectorUrlStatus = await checkConnectorUrl()\n setPreFlightCheck(connectorUrlStatus)\n }\n fetchDataAndSetState()\n }, [checkConnectorUrl, preFlightCheck])\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 = useMemo(\n () => [\n 'quiltt.app',\n 'quiltt.dev',\n 'moneydesktop.com',\n 'cdn.plaid.com/link/v2/stable/link.html',\n ],\n []\n )\n\n const isQuilttEvent = useCallback((url: URL) => url.protocol === 'quilttconnector:', [])\n\n const shouldRender = useCallback(\n (url: URL) => {\n if (isQuilttEvent(url)) return false\n if (url.protocol !== 'https:') {\n const err = new Error(`Invalid url leaked ${url.href}`)\n errorReporter.send(err)\n return false\n }\n return allowedListUrl.some((href) => url.href.includes(href))\n },\n [allowedListUrl, isQuilttEvent]\n )\n\n const clearLocalStorage = () => {\n const script = 'localStorage.clear();'\n webViewRef.current?.injectJavaScript(script)\n }\n\n const handleOAuthUrl = useCallback((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 const handleQuilttEvent = useCallback(\n (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 connectorId,\n handleOAuthUrl,\n initInjectedJavaScript,\n onEvent,\n onExit,\n onExitAbort,\n onExitError,\n onExitSuccess,\n onLoad,\n ]\n )\n\n const requestHandler = useCallback(\n (request: ShouldStartLoadRequest) => {\n const url = new URL(request.url)\n\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 // So we use `handleOAuthUrl` as a catch all and assume all url got to this step is Plaid OAuth url\n handleOAuthUrl(url)\n return false\n },\n [handleOAuthUrl, handleQuilttEvent, isQuilttEvent, shouldRender]\n )\n\n if (!preFlightCheck.checked) return <LoadingScreen />\n if (preFlightCheck.error)\n return <ErrorScreen error={preFlightCheck.error} cta={() => onExitError?.({ connectorId })} />\n\n return (\n <AndroidSafeAreaView>\n <WebView\n ref={webViewRef}\n originWhitelist={['https://*', 'quilttconnector://*']} // Guard against other non SDK needed url\n source={{ uri: connectorUrl }}\n onShouldStartLoadWithRequest={requestHandler}\n javaScriptEnabled\n domStorageEnabled // To enable localStorage in Android webview\n webviewDebuggingEnabled\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","// Quick hack to send error to Honeybadger to debug why the connector is not routable\n\nimport type { Notice, NoticeTransportPayload } from '@honeybadger-io/core/build/src/types'\nimport { generateStackTrace, getCauses, makeBacktrace } from '@honeybadger-io/core/build/src/util'\n\nimport { ErrorReporterConfig } from './ErrorReporterConfig'\nimport { version } from '../version'\n\nconst notifier = {\n name: 'Quiltt React Native SDK Reporter',\n url: 'https://www.quiltt.dev/guides/connector/react-native',\n version: version,\n}\n\ntype HoneybadgerResponseData = {\n id: string\n}\n\nclass ErrorReporter {\n private noticeUrl: string\n private apiKey: string\n private clientName: string\n private clientVersion: string\n private platform: string\n private logger: Console\n private userAgent: string\n\n constructor(platform: string) {\n this.noticeUrl = 'https://api.honeybadger.io/v1/notices'\n this.apiKey = ErrorReporterConfig.honeybadger_api_key\n this.clientName = 'react-native-sdk'\n this.clientVersion = version\n this.platform = platform\n this.logger = console\n this.userAgent = `${this.clientName} ${this.clientVersion}; ${this.platform}`\n }\n\n async send(error: Error, context?: any): Promise<void> {\n const headers = {\n 'X-API-Key': this.apiKey,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'User-Agent': `${this.clientName} ${this.clientVersion}; ${this.platform}`,\n }\n\n const payload = await this.buildPayload(error, context)\n const method = 'POST'\n const body = JSON.stringify(payload)\n const mode = 'cors'\n\n fetch(this.noticeUrl, { headers, method, body, mode })\n .then((response) => {\n if (response.status !== 201) {\n this.logger.warn(\n `Error report failed: unknown response from server. code=${response.status}`\n )\n return\n }\n return response.json()\n })\n .then((data: HoneybadgerResponseData) => {\n if (data) {\n this.logger.info(`Error report sent ⚡ https://app.honeybadger.io/notice/${data?.id}`)\n }\n })\n }\n\n async buildPayload(error: Error, localContext = {}): Promise<Partial<NoticeTransportPayload>> {\n const notice: Notice = error as Notice\n notice.stack = generateStackTrace()\n\n notice.backtrace = makeBacktrace(notice.stack)\n\n return {\n notifier,\n error: {\n class: notice.name as string,\n message: notice.message as string,\n backtrace: notice.backtrace,\n // fingerprint: this.calculateFingerprint(notice),\n tags: notice.tags || [],\n causes: getCauses(notice, this.logger),\n },\n request: {\n url: notice.url,\n component: notice.component,\n action: notice.action,\n context: localContext || {},\n cgi_data: {},\n params: {},\n session: {},\n },\n server: {\n project_root: notice.projectRoot,\n environment_name: this.userAgent,\n revision: version,\n hostname: this.platform,\n time: new Date().toUTCString(),\n },\n details: notice.details || {},\n }\n }\n}\n\nexport { ErrorReporter }","\nexport const ErrorReporterConfig = {\n honeybadger_api_key: 'undefined',\n}\n","// Generated by genversion.\nexport const version = '3.5.3'\n","const getErrorMessage = (responseStatus?: number, error?: Error): string => {\n if (error) return `An error occurred while checking the connector URL: ${error?.name} \\n${error?.message}`\n return responseStatus\n ? `The URL is not routable. Response status: ${responseStatus}`\n : 'An error occurred while checking the connector URL'\n}\n\nexport { getErrorMessage }\n","import { ActivityIndicator, View } from 'react-native'\nimport { AndroidSafeAreaView } from './AndroidSafeAreaView'\n\nexport const LoadingScreen = () => (\n <AndroidSafeAreaView>\n <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>\n <ActivityIndicator size=\"large\" color=\"#0000ff\" />\n </View>\n </AndroidSafeAreaView>\n)\n","import { View, Text, Pressable, StyleSheet } from 'react-native'\nimport { AndroidSafeAreaView } from './AndroidSafeAreaView'\n\ntype ErrorScreenProp = {\n error: string\n cta: () => void\n}\n\nexport const ErrorScreen = ({ error, cta }: ErrorScreenProp) => (\n <AndroidSafeAreaView>\n <View style={[styles.container, styles.padding]}>\n <View style={{ flex: 1, justifyContent: 'center' }}>\n <View\n style={{\n flexDirection: 'row',\n justifyContent: 'space-between',\n alignItems: 'center',\n marginVertical: 10,\n }}\n >\n <Text style={[styles.title]}>Cannot connect to the internet.</Text>\n </View>\n <Text style={[styles.subtitle]}>{error}</Text>\n </View>\n <Pressable style={[styles.pressable]} onPress={cta}>\n <Text style={[styles.pressableText]}>Exit</Text>\n </Pressable>\n </View>\n </AndroidSafeAreaView>\n)\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n flexDirection: 'column',\n justifyContent: 'flex-start',\n alignItems: 'stretch',\n backgroundColor: '#F3F4F6',\n },\n title: {\n color: '#1F2937',\n fontSize: 30,\n fontWeight: 'bold',\n },\n subtitle: {\n color: 'rgba(107, 114, 128, 1)',\n },\n padding: {\n paddingHorizontal: 16, // sm:px-4\n paddingVertical: 24, // sm:py-6\n },\n pressable: {\n marginTop: 20,\n backgroundColor: '#1F2937',\n padding: 10,\n paddingHorizontal: 25,\n borderRadius: 5,\n },\n pressableText: {\n color: '#fff',\n textAlign: 'center',\n },\n})\n"],"mappings":"uXAEA,OAAS,UAAAA,OAAc,UCFvB,OAGE,yBAAAC,MACK,eACP,OAAS,eAAAC,EAAa,aAAAC,GAAW,WAAAC,GAAS,UAAAC,GAAQ,YAAAC,OAAgB,QAClE,OAAS,WAAAC,GAAS,YAAAC,MAAgB,eAClC,OAAS,WAAAC,OAAe,uBAGxB,OAAS,OAAAC,MAAW,4BCVpB,OAAS,gBAAAC,GAAc,cAAAC,GAAY,YAAAC,GAAU,aAAAC,OAAiB,eAI5D,cAAAC,OAAA,oBADK,IAAMC,EAAsB,CAAC,CAAE,SAAAC,CAAS,IAC7CF,GAACJ,GAAA,CAAa,MAAOO,GAAO,gBAAkB,SAAAD,EAAS,EAGnDC,GAASN,GAAW,OAAO,CAC/B,gBAAiB,CACf,KAAM,EACN,gBAAiB,QACjB,WAAYC,GAAS,KAAO,UAAYC,GAAU,cAAgB,CACpE,CACF,CAAC,EDAD,OAAS,oBAAAK,OAAwB,gBEVjC,OAAS,sBAAAC,GAAoB,aAAAC,GAAW,iBAAAC,OAAqB,sCCFtD,IAAMC,EAAsB,CACjC,oBAAqB,WACvB,ECFO,IAAMC,EAAU,QFOvB,IAAMC,GAAW,CACf,KAAM,mCACN,IAAK,uDACL,QAASC,CACX,EAMMC,EAAN,KAAoB,CASlB,YAAYC,EAAkB,CAR9BC,EAAA,KAAQ,aACRA,EAAA,KAAQ,UACRA,EAAA,KAAQ,cACRA,EAAA,KAAQ,iBACRA,EAAA,KAAQ,YAC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M,EAAIX,EAAI,aAAa,IAAI,UAAU,CAAW,CAAC,EAClE,MACF,QACE,QAAQ,IAAI,kBAAmBA,CAAG,EAClC,KACJ,CACF,EACA,CACExC,EACA6C,EACAX,EACA/B,EACAE,EACAE,EACAC,EACAF,EACAF,CACF,CACF,EAEMgD,EAAiBjC,EACpBkC,GAAoC,CACnC,IAAMb,EAAM,IAAIW,EAAIE,EAAQ,GAAG,EAE/B,OAAId,EAAcC,CAAG,GACnBQ,EAAkBR,CAAG,EACd,IAELC,EAAaD,CAAG,EAAU,IAG9BK,EAAeL,CAAG,EACX,GACT,EACA,CAACK,EAAgBG,EAAmBT,EAAeE,CAAY,CACjE,EAEA,OAAK1B,EAAe,QAChBA,EAAe,MACVrB,EAAC4D,EAAA,CAAY,MAAOvC,EAAe,MAAO,IAAK,IAAMP,GAAA,YAAAA,EAAc,CAAE,YAAAR,CAAY,GAAI,EAG5FN,EAAC6D,EAAA,CACC,SAAA7D,EAAC8D,GAAA,CACC,IAAK/C,EACL,gBAAiB,CAAC,YAAa,qBAAqB,EACpD,OAAQ,CAAE,IAAKI,CAAa,EAC5B,6BAA8BuC,EAC9B,kBAAiB,GACjB,kBAAiB,GACjB,wBAAuB,GACzB,EACF,EAfkC1D,EAAC+D,EAAA,EAAc,CAiBrD,EAEOC,EAAQ3D,GDxPV,OAAO,OACV,OAAO,KAAO4D,IAKhB,IAAOC,GAAQC","names":["decode","ConnectorSDKEventType","useCallback","useEffect","useMemo","useRef","useState","Linking","Platform","WebView","URL","SafeAreaView","StyleSheet","Platform","StatusBar","jsx","AndroidSafeAreaView","children","styles","useQuilttSession","generateStackTrace","getCauses","makeBacktrace","ErrorReporterConfig","version","notifier","version","ErrorReporter","platform","__publicField","ErrorReporterConfig","error","context","__async","headers","payload","method","body","mode","response","data","_0","localContext","notice","generateStackTrace","makeBacktrace","getCauses","getErrorMessage","responseStatus","error","ActivityIndicator","View","jsx","LoadingScreen","AndroidSafeAreaView","View","ActivityIndicator","View","Text","Pressable","StyleSheet","jsx","jsxs","ErrorScreen","error","cta","AndroidSafeAreaView","View","styles","Text","Pressable","StyleSheet","jsx","errorReporter","ErrorReporter","Platform","PREFLIGHT_RETRY_COUNT","QuilttConnector","connectorId","connectionId","oauthRedirectUrl","onEvent","onLoad","onExit","onExitSuccess","onExitAbort","onExitError","webViewRef","useRef","session","useQuilttSession","connectorUrl","version","preFlightCheck","setPreFlightCheck","useState","checkConnectorUrl","useCallback","retryCount","__async","responseStatus","error","errorOccurred","response","e","resolve","errorMessage","getErrorMessage","errorToSend","context","useEffect","connectorUrlStatus","initInjectedJavaScript","_a","script","allowedListUrl","useMemo","isQuilttEvent","url","shouldRender","err","href","clearLocalStorage","handleOAuthUrl","oauthUrl","Linking","handleQuilttEvent","metadata","ConnectorSDKEventType","URL","requestHandler","request","ErrorScreen","AndroidSafeAreaView","WebView","LoadingScreen","QuilttConnector_default","decode","src_default","QuilttConnector_default"]}
@@ -1,18 +0,0 @@
1
- import { NoticeTransportPayload } from '@honeybadger-io/core/build/src/types';
2
-
3
- declare class ErrorReporter {
4
- private noticeUrl;
5
- private apiKey;
6
- private clientName;
7
- private clientVersion;
8
- private platform;
9
- private logger;
10
- private userAgent;
11
- constructor(platform: string);
12
- send(error: Error, context?: any): Promise<void>;
13
- buildPayload(error: Error, localContext?: {}): Promise<Partial<NoticeTransportPayload>>;
14
- }
15
-
16
- declare const getErrorMessage: (responseStatus?: number, error?: Error) => string;
17
-
18
- export { ErrorReporter, getErrorMessage };
@@ -1,3 +0,0 @@
1
- "use strict";var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var k=(o,e,r)=>e in o?p(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var N=(o,e)=>{for(var r in e)p(o,r,{get:e[r],enumerable:!0})},$=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of v(e))!b.call(o,t)&&t!==r&&p(o,t,{get:()=>e[t],enumerable:!(s=f(e,t))||s.enumerable});return o};var R=o=>$(p({},"__esModule",{value:!0}),o);var n=(o,e,r)=>(k(o,typeof e!="symbol"?e+"":e,r),r);var d=(o,e,r)=>new Promise((s,t)=>{var l=i=>{try{c(r.next(i))}catch(m){t(m)}},h=i=>{try{c(r.throw(i))}catch(m){t(m)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(l,h);c((r=r.apply(o,e)).next())});var A={};N(A,{ErrorReporter:()=>u,getErrorMessage:()=>P});module.exports=R(A);var a=require("@honeybadger-io/core/build/src/util");var y={honeybadger_api_key:"undefined"};var g="3.5.3";var w={name:"Quiltt React Native SDK Reporter",url:"https://www.quiltt.dev/guides/connector/react-native",version:g},u=class{constructor(e){n(this,"noticeUrl");n(this,"apiKey");n(this,"clientName");n(this,"clientVersion");n(this,"platform");n(this,"logger");n(this,"userAgent");this.noticeUrl="https://api.honeybadger.io/v1/notices",this.apiKey=y.honeybadger_api_key,this.clientName="react-native-sdk",this.clientVersion=g,this.platform=e,this.logger=console,this.userAgent=`${this.clientName} ${this.clientVersion}; ${this.platform}`}send(e,r){return d(this,null,function*(){let s={"X-API-Key":this.apiKey,"Content-Type":"application/json",Accept:"application/json","User-Agent":`${this.clientName} ${this.clientVersion}; ${this.platform}`},t=yield this.buildPayload(e,r),l="POST",h=JSON.stringify(t),c="cors";fetch(this.noticeUrl,{headers:s,method:l,body:h,mode:c}).then(i=>{if(i.status!==201){this.logger.warn(`Error report failed: unknown response from server. code=${i.status}`);return}return i.json()}).then(i=>{i&&this.logger.info(`Error report sent \u26A1 https://app.honeybadger.io/notice/${i==null?void 0:i.id}`)})})}buildPayload(s){return d(this,arguments,function*(e,r={}){let t=e;return t.stack=(0,a.generateStackTrace)(),t.backtrace=(0,a.makeBacktrace)(t.stack),{notifier:w,error:{class:t.name,message:t.message,backtrace:t.backtrace,tags:t.tags||[],causes:(0,a.getCauses)(t,this.logger)},request:{url:t.url,component:t.component,action:t.action,context:r||{},cgi_data:{},params:{},session:{}},server:{project_root:t.projectRoot,environment_name:this.userAgent,revision:g,hostname:this.platform,time:new Date().toUTCString()},details:t.details||{}}})}};var P=(o,e)=>e?`An error occurred while checking the connector URL: ${e==null?void 0:e.name}
2
- ${e==null?void 0:e.message}`:o?`The URL is not routable. Response status: ${o}`:"An error occurred while checking the connector URL";0&&(module.exports={ErrorReporter,getErrorMessage});
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/index.ts","../../src/utils/ErrorReporter.ts","../../src/utils/ErrorReporterConfig.ts","../../src/version.ts","../../src/utils/getErrorMessage.ts"],"sourcesContent":["export * from './ErrorReporter'\nexport * from './getErrorMessage'\n","// Quick hack to send error to Honeybadger to debug why the connector is not routable\n\nimport type { Notice, NoticeTransportPayload } from '@honeybadger-io/core/build/src/types'\nimport { generateStackTrace, getCauses, makeBacktrace } from '@honeybadger-io/core/build/src/util'\n\nimport { ErrorReporterConfig } from './ErrorReporterConfig'\nimport { version } from '../version'\n\nconst notifier = {\n name: 'Quiltt React Native SDK Reporter',\n url: 'https://www.quiltt.dev/guides/connector/react-native',\n version: version,\n}\n\ntype HoneybadgerResponseData = {\n id: string\n}\n\nclass ErrorReporter {\n private noticeUrl: string\n private apiKey: string\n private clientName: string\n private clientVersion: string\n private platform: string\n private logger: Console\n private userAgent: string\n\n constructor(platform: string) {\n this.noticeUrl = 'https://api.honeybadger.io/v1/notices'\n this.apiKey = ErrorReporterConfig.honeybadger_api_key\n this.clientName = 'react-native-sdk'\n this.clientVersion = version\n this.platform = platform\n this.logger = console\n this.userAgent = `${this.clientName} ${this.clientVersion}; ${this.platform}`\n }\n\n async send(error: Error, context?: any): Promise<void> {\n const headers = {\n 'X-API-Key': this.apiKey,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'User-Agent': `${this.clientName} ${this.clientVersion}; ${this.platform}`,\n }\n\n const payload = await this.buildPayload(error, context)\n const method = 'POST'\n const body = JSON.stringify(payload)\n const mode = 'cors'\n\n fetch(this.noticeUrl, { headers, method, body, mode })\n .then((response) => {\n if (response.status !== 201) {\n this.logger.warn(\n `Error report failed: unknown response from server. code=${response.status}`\n )\n return\n }\n return response.json()\n })\n .then((data: HoneybadgerResponseData) => {\n if (data) {\n this.logger.info(`Error report sent ⚡ https://app.honeybadger.io/notice/${data?.id}`)\n }\n })\n }\n\n async buildPayload(error: Error, localContext = {}): Promise<Partial<NoticeTransportPayload>> {\n const notice: Notice = error as Notice\n notice.stack = generateStackTrace()\n\n notice.backtrace = makeBacktrace(notice.stack)\n\n return {\n notifier,\n error: {\n class: notice.name as string,\n message: notice.message as string,\n backtrace: notice.backtrace,\n // fingerprint: this.calculateFingerprint(notice),\n tags: notice.tags || [],\n causes: getCauses(notice, this.logger),\n },\n request: {\n url: notice.url,\n component: notice.component,\n action: notice.action,\n context: localContext || {},\n cgi_data: {},\n params: {},\n session: {},\n },\n server: {\n project_root: notice.projectRoot,\n environment_name: this.userAgent,\n revision: version,\n hostname: this.platform,\n time: new Date().toUTCString(),\n },\n details: notice.details || {},\n }\n }\n}\n\nexport { ErrorReporter }","\nexport const ErrorReporterConfig = {\n honeybadger_api_key: 'undefined',\n}\n","// Generated by genversion.\nexport const version = '3.5.3'\n","const getErrorMessage = (responseStatus?: number, error?: Error): string => {\n if (error) return `An error occurred while checking the connector URL: ${error?.name} \\n${error?.message}`\n return responseStatus\n ? `The URL is not routable. Response status: ${responseStatus}`\n : 'An error occurred while checking the connector URL'\n}\n\nexport { getErrorMessage }\n"],"mappings":"kwBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GCGA,IAAAK,EAA6D,+CCFtD,IAAMC,EAAsB,CACjC,oBAAqB,WACvB,ECFO,IAAMC,EAAU,QFOvB,IAAMC,EAAW,CACf,KAAM,mCACN,IAAK,uDACL,QAASC,CACX,EAMMC,EAAN,KAAoB,CASlB,YAAYC,EAAkB,CAR9BC,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AK,MAAM,CACvC,EACA,QAAS,CACP,IAAKA,EAAO,IACZ,UAAWA,EAAO,UAClB,OAAQA,EAAO,OACf,QAASD,GAAgB,CAAC,EAC1B,SAAU,CAAC,EACX,OAAQ,CAAC,EACT,QAAS,CAAC,CACZ,EACA,OAAQ,CACN,aAAcC,EAAO,YACrB,iBAAkB,KAAK,UACvB,SAAUjB,EACV,SAAU,KAAK,SACf,KAAM,IAAI,KAAK,EAAE,YAAY,CAC/B,EACA,QAASiB,EAAO,SAAW,CAAC,CAC9B,CACF,GACF,EGtGA,IAAMC,EAAkB,CAACC,EAAyBC,IAC5CA,EAAc,uDAAuDA,GAAA,YAAAA,EAAO;AAAA,EAAUA,GAAA,YAAAA,EAAO,UAC1FD,EACH,6CAA6CA,IAC7C","names":["utils_exports","__export","ErrorReporter","getErrorMessage","__toCommonJS","import_util","ErrorReporterConfig","version","notifier","version","ErrorReporter","platform","__publicField","ErrorReporterConfig","error","context","__async","headers","payload","method","body","mode","response","data","_0","localContext","notice","getErrorMessage","responseStatus","error"]}
@@ -1,3 +0,0 @@
1
- var u=Object.defineProperty;var y=(i,e,r)=>e in i?u(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var n=(i,e,r)=>(y(i,typeof e!="symbol"?e+"":e,r),r);var h=(i,e,r)=>new Promise((c,t)=>{var p=o=>{try{s(r.next(o))}catch(l){t(l)}},g=o=>{try{s(r.throw(o))}catch(l){t(l)}},s=o=>o.done?c(o.value):Promise.resolve(o.value).then(p,g);s((r=r.apply(i,e)).next())});import{generateStackTrace as f,getCauses as v,makeBacktrace as b}from"@honeybadger-io/core/build/src/util";var m={honeybadger_api_key:"undefined"};var a="3.5.3";var k={name:"Quiltt React Native SDK Reporter",url:"https://www.quiltt.dev/guides/connector/react-native",version:a},d=class{constructor(e){n(this,"noticeUrl");n(this,"apiKey");n(this,"clientName");n(this,"clientVersion");n(this,"platform");n(this,"logger");n(this,"userAgent");this.noticeUrl="https://api.honeybadger.io/v1/notices",this.apiKey=m.honeybadger_api_key,this.clientName="react-native-sdk",this.clientVersion=a,this.platform=e,this.logger=console,this.userAgent=`${this.clientName} ${this.clientVersion}; ${this.platform}`}send(e,r){return h(this,null,function*(){let c={"X-API-Key":this.apiKey,"Content-Type":"application/json",Accept:"application/json","User-Agent":`${this.clientName} ${this.clientVersion}; ${this.platform}`},t=yield this.buildPayload(e,r),p="POST",g=JSON.stringify(t),s="cors";fetch(this.noticeUrl,{headers:c,method:p,body:g,mode:s}).then(o=>{if(o.status!==201){this.logger.warn(`Error report failed: unknown response from server. code=${o.status}`);return}return o.json()}).then(o=>{o&&this.logger.info(`Error report sent \u26A1 https://app.honeybadger.io/notice/${o==null?void 0:o.id}`)})})}buildPayload(c){return h(this,arguments,function*(e,r={}){let t=e;return t.stack=f(),t.backtrace=b(t.stack),{notifier:k,error:{class:t.name,message:t.message,backtrace:t.backtrace,tags:t.tags||[],causes:v(t,this.logger)},request:{url:t.url,component:t.component,action:t.action,context:r||{},cgi_data:{},params:{},session:{}},server:{project_root:t.projectRoot,environment_name:this.userAgent,revision:a,hostname:this.platform,time:new Date().toUTCString()},details:t.details||{}}})}};var E=(i,e)=>e?`An error occurred while checking the connector URL: ${e==null?void 0:e.name}
2
- ${e==null?void 0:e.message}`:i?`The URL is not routable. Response status: ${i}`:"An error occurred while checking the connector URL";export{d as ErrorReporter,E as getErrorMessage};
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/ErrorReporter.ts","../../src/utils/ErrorReporterConfig.ts","../../src/version.ts","../../src/utils/getErrorMessage.ts"],"sourcesContent":["// Quick hack to send error to Honeybadger to debug why the connector is not routable\n\nimport type { Notice, NoticeTransportPayload } from '@honeybadger-io/core/build/src/types'\nimport { generateStackTrace, getCauses, makeBacktrace } from '@honeybadger-io/core/build/src/util'\n\nimport { ErrorReporterConfig } from './ErrorReporterConfig'\nimport { version } from '../version'\n\nconst notifier = {\n name: 'Quiltt React Native SDK Reporter',\n url: 'https://www.quiltt.dev/guides/connector/react-native',\n version: version,\n}\n\ntype HoneybadgerResponseData = {\n id: string\n}\n\nclass ErrorReporter {\n private noticeUrl: string\n private apiKey: string\n private clientName: string\n private clientVersion: string\n private platform: string\n private logger: Console\n private userAgent: string\n\n constructor(platform: string) {\n this.noticeUrl = 'https://api.honeybadger.io/v1/notices'\n this.apiKey = ErrorReporterConfig.honeybadger_api_key\n this.clientName = 'react-native-sdk'\n this.clientVersion = version\n this.platform = platform\n this.logger = console\n this.userAgent = `${this.clientName} ${this.clientVersion}; ${this.platform}`\n }\n\n async send(error: Error, context?: any): Promise<void> {\n const headers = {\n 'X-API-Key': this.apiKey,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n 'User-Agent': `${this.clientName} ${this.clientVersion}; ${this.platform}`,\n }\n\n const payload = await this.buildPayload(error, context)\n const method = 'POST'\n const body = JSON.stringify(payload)\n const mode = 'cors'\n\n fetch(this.noticeUrl, { headers, method, body, mode })\n .then((response) => {\n if (response.status !== 201) {\n this.logger.warn(\n `Error report failed: unknown response from server. code=${response.status}`\n )\n return\n }\n return response.json()\n })\n .then((data: HoneybadgerResponseData) => {\n if (data) {\n this.logger.info(`Error report sent ⚡ https://app.honeybadger.io/notice/${data?.id}`)\n }\n })\n }\n\n async buildPayload(error: Error, localContext = {}): Promise<Partial<NoticeTransportPayload>> {\n const notice: Notice = error as Notice\n notice.stack = generateStackTrace()\n\n notice.backtrace = makeBacktrace(notice.stack)\n\n return {\n notifier,\n error: {\n class: notice.name as string,\n message: notice.message as string,\n backtrace: notice.backtrace,\n // fingerprint: this.calculateFingerprint(notice),\n tags: notice.tags || [],\n causes: getCauses(notice, this.logger),\n },\n request: {\n url: notice.url,\n component: notice.component,\n action: notice.action,\n context: localContext || {},\n cgi_data: {},\n params: {},\n session: {},\n },\n server: {\n project_root: notice.projectRoot,\n environment_name: this.userAgent,\n revision: version,\n hostname: this.platform,\n time: new Date().toUTCString(),\n },\n details: notice.details || {},\n }\n }\n}\n\nexport { ErrorReporter }","\nexport const ErrorReporterConfig = {\n honeybadger_api_key: 'undefined',\n}\n","// Generated by genversion.\nexport const version = '3.5.3'\n","const getErrorMessage = (responseStatus?: number, error?: Error): string => {\n if (error) return `An error occurred while checking the connector URL: ${error?.name} \\n${error?.message}`\n return responseStatus\n ? `The URL is not routable. Response status: ${responseStatus}`\n : 'An error occurred while checking the connector URL'\n}\n\nexport { getErrorMessage }\n"],"mappings":"qXAGA,OAAS,sBAAAA,EAAoB,aAAAC,EAAW,iBAAAC,MAAqB,sCCFtD,IAAMC,EAAsB,CACjC,oBAAqB,WACvB,ECFO,IAAMC,EAAU,QFOvB,IAAMC,EAAW,CACf,KAAM,mCACN,IAAK,uDACL,QAASC,CACX,EAMMC,EAAN,KAAoB,CASlB,YAAYC,EAAkB,CAR9BC,EAAA,KAAQ,aACRA,EAAA,KAAQ,UACRA,EAAA,KAAQ,cACRA,EAAA,KAAQ,iBACRA,EAAA,KAAQ,YACRA,EAAA,KAAQ,UACRA,EAAA,KAAQ,aAGN,KAAK,UAAY,wCACjB,KAAK,OAASC,EAAoB,oBAClC,KAAK,WAAa,mBAClB,KAAK,cAAgBJ,EACrB,KAAK,SAAWE,EAChB,KAAK,OAAS,QACd,KAAK,UAAY,GAAG,KAAK,cAAc,KAAK,kBAAkB,KAAK,UACrE,CAEM,KAAKG,EAAcC,EAA8B,QAAAC,EAAA,sBACrD,IAAMC,EAAU,CACd,YAAa,KAAK,OAClB,eAAgB,mBAChB,OAAQ,mBACR,aAAc,GAAG,KAAK,cAAc,KAAK,kBAAkB,KAAK,UAClE,EAEMC,EAAU,MAAM,KAAK,aAAaJ,EAAOC,CAAO,EAChDI,EAAS,OACTC,EAAO,KAAK,UAAUF,CAAO,EAC7BG,EAAO,OAEb,MAAM,KAAK,UAAW,CAAE,QAAAJ,EAAS,OAAAE,EAAQ,KAAAC,EAAM,KAAAC,CAAK,CAAC,EAClD,KAAMC,GAAa,CAClB,GAAIA,EAAS,SAAW,IAAK,CAC3B,KAAK,OAAO,KACV,2DAA2DA,EAAS,QACtE,EACA,OAEF,OAAOA,EAAS,KAAK,CACvB,CAAC,EACA,KAAMC,GAAkC,CACnCA,GACF,KAAK,OAAO,KAAK,8DAAyDA,GAAA,YAAAA,EAAM,IAAI,CAExF,CAAC,CACL,GAEM,aAAaC,EAA2E,QAAAR,EAAA,yBAA3EF,EAAcW,EAAe,CAAC,EAA6C,CAC5F,IAAMC,EAAiBZ,EACvB,OAAAY,EAAO,MAAQC,EAAmB,EAElCD,EAAO,UAAYE,EAAcF,EAAO,KAAK,EAEtC,CACL,SAAAlB,EACA,MAAO,CACL,MAAOkB,EAAO,KACd,QAASA,EAAO,QAChB,UAAWA,EAAO,UAElB,KAAMA,EAAO,MAAQ,CAAC,EACtB,OAAQG,EAAUH,EAAQ,KAAK,MAAM,CACvC,EACA,QAAS,CACP,IAAKA,EAAO,IACZ,UAAWA,EAAO,UAClB,OAAQA,EAAO,OACf,QAASD,GAAgB,CAAC,EAC1B,SAAU,CAAC,EACX,OAAQ,CAAC,EACT,QAAS,CAAC,CACZ,EACA,OAAQ,CACN,aAAcC,EAAO,YACrB,iBAAkB,KAAK,UACvB,SAAUjB,EACV,SAAU,KAAK,SACf,KAAM,IAAI,KAAK,EAAE,YAAY,CAC/B,EACA,QAASiB,EAAO,SAAW,CAAC,CAC9B,CACF,GACF,EGtGA,IAAMI,EAAkB,CAACC,EAAyBC,IAC5CA,EAAc,uDAAuDA,GAAA,YAAAA,EAAO;AAAA,EAAUA,GAAA,YAAAA,EAAO,UAC1FD,EACH,6CAA6CA,IAC7C","names":["generateStackTrace","getCauses","makeBacktrace","ErrorReporterConfig","version","notifier","version","ErrorReporter","platform","__publicField","ErrorReporterConfig","error","context","__async","headers","payload","method","body","mode","response","data","_0","localContext","notice","generateStackTrace","makeBacktrace","getCauses","getErrorMessage","responseStatus","error"]}