@quiltt/react-native 3.5.4 → 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,23 @@
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
+
3
21
  ## 3.5.4
4
22
 
5
23
  ### 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,5 +1,7 @@
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;
@@ -7,6 +9,9 @@ type QuilttConnectorProps = {
7
9
  institution?: string;
8
10
  oauthRedirectUrl: string;
9
11
  } & ConnectorSDKCallbacks;
10
- declare const QuilttConnector: ({ connectorId, connectionId, institution, 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
+ };
11
16
 
12
- 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 ne=Object.getOwnPropertyNames;var ce=Object.prototype.hasOwnProperty;var le=(o,e,i)=>e in o?D(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i;var pe=(o,e)=>{for(var i in e)D(o,i,{get:e[i],enumerable:!0})},de=(o,e,i,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of ne(e))!ce.call(o,t)&&t!==i&&D(o,t,{get:()=>e[t],enumerable:!(d=se(e,t))||d.enumerable});return o};var fe=o=>de(D({},"__esModule",{value:!0}),o);var u=(o,e,i)=>(le(o,typeof e!="symbol"?e+"":e,i),i);var w=(o,e,i)=>new Promise((d,t)=>{var h=s=>{try{f(i.next(s))}catch(p){t(p)}},c=s=>{try{f(i.throw(s))}catch(p){t(p)}},f=s=>s.done?d(s.value):Promise.resolve(s.value).then(h,c);f((i=i.apply(o,e)).next())});var ye={};pe(ye,{QuilttConnector:()=>Q,default:()=>be});module.exports=fe(ye);var te=require("base-64");var b=require("@quiltt/core"),n=require("react"),U=require("react-native"),E=require("react-native-webview"),I=require("react-native-url-polyfill");var m=require("react-native"),B=require("react/jsx-runtime"),A=({children:o})=>(0,B.jsx)(m.SafeAreaView,{style:ge.AndroidSafeArea,children:o}),ge=m.StyleSheet.create({AndroidSafeArea:{flex:1,backgroundColor:"white",paddingTop:m.Platform.OS==="android"?m.StatusBar.currentHeight:0}});var ee=require("@quiltt/react");var R=require("@honeybadger-io/core/build/src/util");var G={honeybadger_api_key:"undefined"};var C="3.5.4";var he={name:"Quiltt React Native SDK Reporter",url:"https://www.quiltt.dev/guides/connector/react-native",version:C},O=class{constructor(e){u(this,"noticeUrl");u(this,"apiKey");u(this,"clientName");u(this,"clientVersion");u(this,"platform");u(this,"logger");u(this,"userAgent");this.noticeUrl="https://api.honeybadger.io/v1/notices",this.apiKey=G.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 d={"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,i),h="POST",c=JSON.stringify(t),f="cors";fetch(this.noticeUrl,{headers:d,method:h,body:c,mode:f}).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(d){return w(this,arguments,function*(e,i={}){let t=e;return t.stack=(0,R.generateStackTrace)(),t.backtrace=(0,R.makeBacktrace)(t.stack),{notifier:he,error:{class:t.name,message:t.message,backtrace:t.backtrace,tags:t.tags||[],causes:(0,R.getCauses)(t,this.logger)},request:{url:t.url,component:t.component,action:t.action,context:i||{},cgi_data:{},params:{},session:{}},server:{project_root:t.projectRoot,environment_name:this.userAgent,revision:C,hostname:this.platform,time:new Date().toUTCString()},details:t.details||{}}})}};var X=(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";var N=require("react-native");var q=require("react/jsx-runtime"),Y=()=>(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 l=require("react-native");var g=require("react/jsx-runtime"),x=({error:o,cta:e})=>(0,g.jsx)(A,{children:(0,g.jsxs)(l.View,{style:[P.container,P.padding],children:[(0,g.jsxs)(l.View,{style:{flex:1,justifyContent:"center"},children:[(0,g.jsx)(l.View,{style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginVertical:10},children:(0,g.jsx)(l.Text,{style:[P.title],children:"Cannot connect to the internet."})}),(0,g.jsx)(l.Text,{style:[P.subtitle],children:o})]}),(0,g.jsx)(l.Pressable,{style:[P.pressable],onPress:e,children:(0,g.jsx)(l.Text,{style:[P.pressableText],children:"Exit"})})]})}),P=l.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"),Z=new O(`${U.Platform.OS} ${U.Platform.Version}`),ue=3,me=({connectorId:o,connectionId:e,institution:i,oauthRedirectUrl:d,onEvent:t,onLoad:h,onExit:c,onExitSuccess:f,onExitAbort:s,onExitError:p})=>{let j=(0,n.useRef)(null),{session:k}=(0,ee.useQuilttSession)();d=encodeURIComponent(d);let y=`https://${o}.quiltt.app/?mode=webview&oauth_redirect_url=${d}&agent=react-native-${C}`;console.log("connectorUrl",y);let[T,re]=(0,n.useState)({checked:!1}),F=(0,n.useCallback)((a=0)=>w(void 0,null,function*(){let r,V,_=!1;try{let S=yield fetch(y);if(!S.ok)console.error(`The URL ${y} is not routable.`),r=S.status,_=!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}`),_=!0}if(_&&a<ue)return yield new Promise(S=>setTimeout(S,50*a)),console.log(`Retrying... Attempt number ${a+1}`),F(a+1);let J=X(r,V),ae=V||new Error(J),ie={connectorUrl:y,responseStatus:r};return r!==404&&Z.send(ae,ie),{checked:!0,error:J}}),[y]);(0,n.useEffect)(()=>{if(T.checked)return;(()=>w(void 0,null,function*(){let r=yield F();re(r)}))()},[F,T]);let W=(0,n.useCallback)(()=>{var r;let a=` const options = { source: 'quiltt', type: 'Options', token: '${k==null?void 0:k.token}', connectorId: '${o}', connectionId: '${e}', institution: '${i}', }; const compactedOptions = Object.keys(options).reduce((acc, key) => { if (options[key] !== 'undefined') { acc[key] = options[key]; } return acc; }, {}); window.postMessage(compactedOptions); `;(r=j.current)==null||r.injectJavaScript(a)},[e,o,i,k==null?void 0:k.token]),H=(0,n.useMemo)(()=>["quiltt.app","quiltt.dev","moneydesktop.com","cdn.plaid.com/link/v2/stable/link.html"],[]),v=(0,n.useCallback)(a=>a.protocol==="quilttconnector:",[]),M=(0,n.useCallback)(a=>{if(v(a))return!1;if(a.protocol!=="https:"){let r=new Error(`Invalid url leaked ${a.href}`);return Z.send(r),!1}return H.some(r=>a.href.includes(r))},[H,v]),K=()=>{var r;let a="localStorage.clear();";(r=j.current)==null||r.injectJavaScript(a)},L=(0,n.useCallback)(a=>{if(a.protocol!=="https:"){console.log(`handleOAuthUrl - Skipping non https url - ${a.href}`);return}U.Linking.openURL(a.href)},[]),z=(0,n.useCallback)(a=>{a.searchParams.delete("source"),a.searchParams.append("connectorId",o);let r=Object.fromEntries(a.searchParams);switch(a.host){case"Load":W(),t==null||t(b.ConnectorSDKEventType.Load,r),h==null||h(r);break;case"ExitAbort":K(),t==null||t(b.ConnectorSDKEventType.ExitAbort,r),c==null||c(b.ConnectorSDKEventType.ExitAbort,r),s==null||s(r);break;case"ExitError":K(),t==null||t(b.ConnectorSDKEventType.ExitError,r),c==null||c(b.ConnectorSDKEventType.ExitError,r),p==null||p(r);break;case"ExitSuccess":K(),t==null||t(b.ConnectorSDKEventType.ExitSuccess,r),c==null||c(b.ConnectorSDKEventType.ExitSuccess,r),f==null||f(r);break;case"Authenticate":break;case"OauthRequested":L(new I.URL(a.searchParams.get("oauthUrl")));break;default:console.log("unhandled event",a);break}},[o,L,W,t,c,s,p,f,h]),oe=(0,n.useCallback)(a=>{let r=new I.URL(a.url);return v(r)?(z(r),!1):M(r)?!0:(L(r),!1)},[L,z,v,M]);return T.checked?T.error?(0,$.jsx)(x,{error:T.error,cta:()=>p==null?void 0:p({connectorId:o})}):(0,$.jsx)(A,{children:(0,$.jsx)(E.WebView,{ref:j,originWhitelist:["https://*","quilttconnector://*"],source:{uri:y},onShouldStartLoadWithRequest:oe,javaScriptEnabled:!0,domStorageEnabled:!0,webviewDebuggingEnabled:!0})}):(0,$.jsx)(Y,{})},Q=me;global.atob||(global.atob=te.decode);var be=Q;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.4",
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/**",
@@ -16,27 +23,21 @@
16
23
  "directory": "packages/react-native"
17
24
  },
18
25
  "homepage": "https://github.com/quiltt/quiltt-public/tree/main/packages/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": "*"
25
- },
26
26
  "dependencies": {
27
27
  "@honeybadger-io/core": "6.5.1",
28
- "@quiltt/core": "3.5.4",
29
- "@quiltt/react": "3.5.4"
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,22 +1,24 @@
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
 
@@ -34,7 +36,7 @@ type PreFlightCheck = {
34
36
 
35
37
  const PREFLIGHT_RETRY_COUNT = 3
36
38
 
37
- export const QuilttConnector = ({
39
+ const QuilttConnector = ({
38
40
  connectorId,
39
41
  connectionId,
40
42
  institution,
@@ -48,9 +50,17 @@ export const QuilttConnector = ({
48
50
  }: QuilttConnectorProps) => {
49
51
  const webViewRef = useRef<WebView>(null)
50
52
  const { session } = useQuilttSession()
51
- oauthRedirectUrl = encodeURIComponent(oauthRedirectUrl)
52
- const connectorUrl = `https://${connectorId}.quiltt.app/?mode=webview&oauth_redirect_url=${oauthRedirectUrl}&agent=react-native-${version}`
53
- 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])
54
64
  const [preFlightCheck, setPreFlightCheck] = useState<PreFlightCheck>({ checked: false })
55
65
 
56
66
  const checkConnectorUrl = useCallback(
@@ -76,7 +86,8 @@ export const QuilttConnector = ({
76
86
 
77
87
  // Retry logic in case of error or response not OK
78
88
  if (errorOccurred && retryCount < PREFLIGHT_RETRY_COUNT) {
79
- 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
80
91
  console.log(`Retrying... Attempt number ${retryCount + 1}`)
81
92
  return checkConnectorUrl(retryCount + 1)
82
93
  }
@@ -139,8 +150,6 @@ export const QuilttConnector = ({
139
150
  (url: URL) => {
140
151
  if (isQuilttEvent(url)) return false
141
152
  if (url.protocol !== 'https:') {
142
- const err = new Error(`Invalid url leaked ${url.href}`)
143
- errorReporter.send(err)
144
153
  return false
145
154
  }
146
155
  return allowedListUrl.some((href) => url.href.includes(href))
@@ -241,7 +250,9 @@ export const QuilttConnector = ({
241
250
  <AndroidSafeAreaView>
242
251
  <WebView
243
252
  ref={webViewRef}
244
- 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={['*']}
245
256
  source={{ uri: connectorUrl }}
246
257
  onShouldStartLoadWithRequest={requestHandler}
247
258
  javaScriptEnabled
@@ -252,4 +263,6 @@ export const QuilttConnector = ({
252
263
  )
253
264
  }
254
265
 
255
- 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'
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '3.5.4'
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 institution?: 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 institution,\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 institution: '${institution}', \\\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, institution, 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 }\n","\nexport const ErrorReporterConfig = {\n honeybadger_api_key: 'undefined',\n}\n","// Generated by genversion.\nexport const version = '3.5.4'\n","const getErrorMessage = (responseStatus?: number, error?: Error): string => {\n if (error)\n 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,GAAiC,yBEVjC,IAAAC,EAA6D,+CCFtD,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,E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,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,YAAAT,CAAY,GAAI,KAG5F,OAAC+C,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,EAAQlD,GD3PV,OAAO,OACV,OAAO,KAAO,WAKhB,IAAOmD,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","institution","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 ee=Object.defineProperty;var te=(a,o,s)=>o in a?ee(a,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[o]=s;var d=(a,o,s)=>(te(a,typeof o!="symbol"?o+"":o,s),s);var y=(a,o,s)=>new Promise((f,t)=>{var p=i=>{try{l(s.next(i))}catch(c){t(c)}},n=i=>{try{l(s.throw(i))}catch(c){t(c)}},l=i=>i.done?f(i.value):Promise.resolve(i.value).then(p,n);l((s=s.apply(a,o)).next())});import{decode as Pe}from"base-64";import{ConnectorSDKEventType as h}from"@quiltt/core";import{useCallback as u,useEffect as me,useMemo as be,useRef as ye,useState as ke}from"react";import{Linking as Se,Platform as J}from"react-native";import{WebView as we}from"react-native-webview";import{URL as B}from"react-native-url-polyfill";import{SafeAreaView as re,StyleSheet as oe,Platform as ae,StatusBar as ie}from"react-native";import{jsx as ne}from"react/jsx-runtime";var k=({children:a})=>ne(re,{style:se.AndroidSafeArea,children:a}),se=oe.create({AndroidSafeArea:{flex:1,backgroundColor:"white",paddingTop:ae.OS==="android"?ie.currentHeight:0}});import{useQuilttSession as Ae}from"@quiltt/react";import{generateStackTrace as ce,getCauses as le,makeBacktrace as pe}from"@honeybadger-io/core/build/src/util";var Q={honeybadger_api_key:"undefined"};var S="3.5.4";var de={name:"Quiltt React Native SDK Reporter",url:"https://www.quiltt.dev/guides/connector/react-native",version:S},V=class{constructor(o){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=Q.honeybadger_api_key,this.clientName="react-native-sdk",this.clientVersion=S,this.platform=o,this.logger=console,this.userAgent=`${this.clientName} ${this.clientVersion}; ${this.platform}`}send(o,s){return y(this,null,function*(){let f={"X-API-Key":this.apiKey,"Content-Type":"application/json",Accept:"application/json","User-Agent":`${this.clientName} ${this.clientVersion}; ${this.platform}`},t=yield this.buildPayload(o,s),p="POST",n=JSON.stringify(t),l="cors";fetch(this.noticeUrl,{headers:f,method:p,body:n,mode:l}).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(f){return y(this,arguments,function*(o,s={}){let t=o;return t.stack=ce(),t.backtrace=pe(t.stack),{notifier:de,error:{class:t.name,message:t.message,backtrace:t.backtrace,tags:t.tags||[],causes:le(t,this.logger)},request:{url:t.url,component:t.component,action:t.action,context:s||{},cgi_data:{},params:{},session:{}},server:{project_root:t.projectRoot,environment_name:this.userAgent,revision:S,hostname:this.platform,time:new Date().toUTCString()},details:t.details||{}}})}};var W=(a,o)=>o?`An error occurred while checking the connector URL: ${o==null?void 0:o.name}
2
- ${o==null?void 0:o.message}`:a?`The URL is not routable. Response status: ${a}`:"An error occurred while checking the connector URL";import{ActivityIndicator as fe,View as ge}from"react-native";import{jsx as O}from"react/jsx-runtime";var H=()=>O(k,{children:O(ge,{style:{flex:1,justifyContent:"center",alignItems:"center"},children:O(fe,{size:"large",color:"#0000ff"})})});import{View as q,Text as N,Pressable as he,StyleSheet as ue}from"react-native";import{jsx as A,jsxs as M}from"react/jsx-runtime";var z=({error:a,cta:o})=>A(k,{children:M(q,{style:[w.container,w.padding],children:[M(q,{style:{flex:1,justifyContent:"center"},children:[A(q,{style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginVertical:10},children:A(N,{style:[w.title],children:"Cannot connect to the internet."})}),A(N,{style:[w.subtitle],children:a})]}),A(he,{style:[w.pressable],onPress:o,children:A(N,{style:[w.pressableText],children:"Exit"})})]})}),w=ue.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 G=new V(`${J.OS} ${J.Version}`),Ce=3,Re=({connectorId:a,connectionId:o,institution:s,oauthRedirectUrl:f,onEvent:t,onLoad:p,onExit:n,onExitSuccess:l,onExitAbort:i,onExitError:c})=>{let U=ye(null),{session:m}=Ae();f=encodeURIComponent(f);let g=`https://${a}.quiltt.app/?mode=webview&oauth_redirect_url=${f}&agent=react-native-${S}`;console.log("connectorUrl",g);let[C,Y]=ke({checked:!1}),v=u((r=0)=>y(void 0,null,function*(){let e,R,D=!1;try{let b=yield fetch(g);if(!b.ok)console.error(`The URL ${g} is not routable.`),e=b.status,D=!0;else return console.log(`The URL ${g} is routable.`),{checked:!0}}catch(b){R=b,console.error(`An error occurred while checking the connector URL: ${R}`),D=!0}if(D&&r<Ce)return yield new Promise(b=>setTimeout(b,50*r)),console.log(`Retrying... Attempt number ${r+1}`),v(r+1);let I=W(e,R),Z=R||new Error(I),E={connectorUrl:g,responseStatus:e};return e!==404&&G.send(Z,E),{checked:!0,error:I}}),[g]);me(()=>{if(C.checked)return;(()=>y(void 0,null,function*(){let e=yield v();Y(e)}))()},[v,C]);let j=u(()=>{var e;let r=` const options = { source: 'quiltt', type: 'Options', token: '${m==null?void 0:m.token}', connectorId: '${a}', connectionId: '${o}', institution: '${s}', }; const compactedOptions = Object.keys(options).reduce((acc, key) => { if (options[key] !== 'undefined') { acc[key] = options[key]; } return acc; }, {}); window.postMessage(compactedOptions); `;(e=U.current)==null||e.injectJavaScript(r)},[o,a,s,m==null?void 0:m.token]),F=be(()=>["quiltt.app","quiltt.dev","moneydesktop.com","cdn.plaid.com/link/v2/stable/link.html"],[]),P=u(r=>r.protocol==="quilttconnector:",[]),K=u(r=>{if(P(r))return!1;if(r.protocol!=="https:"){let e=new Error(`Invalid url leaked ${r.href}`);return G.send(e),!1}return F.some(e=>r.href.includes(e))},[F,P]),L=()=>{var e;let r="localStorage.clear();";(e=U.current)==null||e.injectJavaScript(r)},T=u(r=>{if(r.protocol!=="https:"){console.log(`handleOAuthUrl - Skipping non https url - ${r.href}`);return}Se.openURL(r.href)},[]),_=u(r=>{r.searchParams.delete("source"),r.searchParams.append("connectorId",a);let e=Object.fromEntries(r.searchParams);switch(r.host){case"Load":j(),t==null||t(h.Load,e),p==null||p(e);break;case"ExitAbort":L(),t==null||t(h.ExitAbort,e),n==null||n(h.ExitAbort,e),i==null||i(e);break;case"ExitError":L(),t==null||t(h.ExitError,e),n==null||n(h.ExitError,e),c==null||c(e);break;case"ExitSuccess":L(),t==null||t(h.ExitSuccess,e),n==null||n(h.ExitSuccess,e),l==null||l(e);break;case"Authenticate":break;case"OauthRequested":T(new B(r.searchParams.get("oauthUrl")));break;default:console.log("unhandled event",r);break}},[a,T,j,t,n,i,c,l,p]),x=u(r=>{let e=new B(r.url);return P(e)?(_(e),!1):K(e)?!0:(T(e),!1)},[T,_,P,K]);return C.checked?C.error?$(z,{error:C.error,cta:()=>c==null?void 0:c({connectorId:a})}):$(k,{children:$(we,{ref:U,originWhitelist:["https://*","quilttconnector://*"],source:{uri:g},onShouldStartLoadWithRequest:x,javaScriptEnabled:!0,domStorageEnabled:!0,webviewDebuggingEnabled:!0})}):$(H,{})},X=Re;global.atob||(global.atob=Pe);var gt=X;export{X as QuilttConnector,gt 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 institution?: 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 institution,\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 institution: '${institution}', \\\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, institution, 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 }\n","\nexport const ErrorReporterConfig = {\n honeybadger_api_key: 'undefined',\n}\n","// Generated by genversion.\nexport const version = '3.5.4'\n","const getErrorMessage = (responseStatus?: number, error?: Error): string => {\n if (error)\n 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":"yXAEA,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,YACRA,EAAA,KAAQ,UACRA,EAAA,KAAQ,aAGN,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Aa,IAAI,UAAU,CAAW,CAAC,EAClE,MACF,QACE,QAAQ,IAAI,kBAAmBA,CAAG,EAClC,KACJ,CACF,EACA,CACEzC,EACA8C,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,MACVtB,EAAC6D,EAAA,CAAY,MAAOvC,EAAe,MAAO,IAAK,IAAMP,GAAA,YAAAA,EAAc,CAAE,YAAAT,CAAY,GAAI,EAG5FN,EAAC8D,EAAA,CACC,SAAA9D,EAAC+D,GAAA,CACC,IAAK/C,EACL,gBAAiB,CAAC,YAAa,qBAAqB,EACpD,OAAQ,CAAE,IAAKI,CAAa,EAC5B,6BAA8BuC,EAC9B,kBAAiB,GACjB,kBAAiB,GACjB,wBAAuB,GACzB,EACF,EAfkC3D,EAACgE,EAAA,EAAc,CAiBrD,EAEOC,EAAQ5D,GD3PV,OAAO,OACV,OAAO,KAAO6D,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","institution","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.4";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 }\n","\nexport const ErrorReporterConfig = {\n honeybadger_api_key: 'undefined',\n}\n","// Generated by genversion.\nexport const version = '3.5.4'\n","const getErrorMessage = (responseStatus?: number, error?: Error): string => {\n if (error)\n 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,EAAA,KAA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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,EACK,uDAAuDA,GAAA,YAAAA,EAAO;AAAA,EAAUA,GAAA,YAAAA,EAAO,UACjFD,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.4";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 }\n","\nexport const ErrorReporterConfig = {\n honeybadger_api_key: 'undefined',\n}\n","// Generated by genversion.\nexport const version = '3.5.4'\n","const getErrorMessage = (responseStatus?: number, error?: Error): string => {\n if (error)\n 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,EACK,uDAAuDA,GAAA,YAAAA,EAAO;AAAA,EAAUA,GAAA,YAAAA,EAAO,UACjFD,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"]}