@rownd/react-native 0.2.5 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/README.md +34 -52
- package/android/build.gradle +127 -37
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/reactnativerowndplugin/RowndPluginModule.kt +98 -0
- package/android/src/main/java/com/reactnativerowndplugin/RowndPluginPackage.kt +16 -0
- package/ios/{ReactNative.xcodeproj → Rownd.xcodeproj}/project.pbxproj +13 -12
- package/ios/RowndPlugin-Bridging-Header.h +3 -0
- package/ios/RowndPlugin.m +26 -0
- package/ios/RowndPlugin.swift +83 -0
- package/ios/RowndPluginEventEmitter.m +12 -0
- package/ios/RowndPluginEventEmitter.swift +19 -0
- package/lib/commonjs/components/GlobalContext.js +32 -298
- package/lib/commonjs/components/GlobalContext.js.map +1 -1
- package/lib/commonjs/components/{BottomSheetTextInput/types.js → GlobalContext.types.js} +1 -1
- package/lib/commonjs/components/GlobalContext.types.js.map +1 -0
- package/lib/commonjs/constants/action.js +13 -0
- package/lib/commonjs/constants/action.js.map +1 -0
- package/lib/commonjs/hooks/rownd.js +15 -146
- package/lib/commonjs/hooks/rownd.js.map +1 -1
- package/lib/commonjs/index.js +2 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/reducer/rowndReducer.js +89 -0
- package/lib/commonjs/reducer/rowndReducer.js.map +1 -0
- package/lib/commonjs/utils/config.js +0 -26
- package/lib/commonjs/utils/config.js.map +1 -1
- package/lib/commonjs/utils/nativeModule.js +72 -0
- package/lib/commonjs/utils/nativeModule.js.map +1 -0
- package/lib/module/components/GlobalContext.js +30 -293
- package/lib/module/components/GlobalContext.js.map +1 -1
- package/lib/module/components/GlobalContext.types.js +2 -0
- package/lib/module/components/GlobalContext.types.js.map +1 -0
- package/lib/module/constants/action.js +6 -0
- package/lib/module/constants/action.js.map +1 -0
- package/lib/module/hooks/rownd.js +12 -137
- package/lib/module/hooks/rownd.js.map +1 -1
- package/lib/module/index.js +2 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/reducer/rowndReducer.js +78 -0
- package/lib/module/reducer/rowndReducer.js.map +1 -0
- package/lib/module/utils/config.js +1 -16
- package/lib/module/utils/config.js.map +1 -1
- package/lib/module/utils/nativeModule.js +48 -0
- package/lib/module/utils/nativeModule.js.map +1 -0
- package/lib/typescript/components/GlobalContext.d.ts +13 -0
- package/lib/typescript/{src/components/GlobalContext.d.ts → components/GlobalContext.types.d.ts} +9 -35
- package/lib/typescript/constants/action.d.ts +7 -0
- package/lib/typescript/{src/hooks → hooks}/rownd.d.ts +10 -13
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/reducer/rowndReducer.d.ts +4 -0
- package/lib/typescript/utils/config.d.ts +10 -0
- package/lib/typescript/utils/nativeModule.d.ts +10 -0
- package/package.json +36 -56
- package/rownd-react-native.podspec +36 -0
- package/src/components/GlobalContext.tsx +47 -457
- package/src/components/GlobalContext.types.ts +105 -0
- package/src/constants/action.ts +8 -0
- package/src/hooks/rownd.ts +29 -147
- package/src/index.tsx +2 -4
- package/src/reducer/rowndReducer.ts +78 -0
- package/src/utils/config.ts +0 -27
- package/src/utils/nativeModule.ts +69 -0
- package/android/src/main/java/com/reactnative/ReactNativePackage.java +0 -22
- package/android/src/main/java/com/reactnative/ReactNativeViewManager.java +0 -31
- package/ios/ReactNativeViewManager.m +0 -34
- package/lib/commonjs/assets/images/checkmark--filled.svg +0 -12
- package/lib/commonjs/assets/images/email-verify-waiting.svg +0 -36
- package/lib/commonjs/assets/images/error-icon-material.svg +0 -1
- package/lib/commonjs/assets/images/phone-verify-waiting.svg +0 -26
- package/lib/commonjs/components/AuthenticatedComponent.js +0 -35
- package/lib/commonjs/components/AuthenticatedComponent.js.map +0 -1
- package/lib/commonjs/components/AutoSigninDialog.js +0 -132
- package/lib/commonjs/components/AutoSigninDialog.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js +0 -65
- package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/index.js +0 -24
- package/lib/commonjs/components/BottomSheetTextInput/index.js.map +0 -1
- package/lib/commonjs/components/BottomSheetTextInput/types.js.map +0 -1
- package/lib/commonjs/components/DarkText.js +0 -35
- package/lib/commonjs/components/DarkText.js.map +0 -1
- package/lib/commonjs/components/DefaultContext.js +0 -266
- package/lib/commonjs/components/DefaultContext.js.map +0 -1
- package/lib/commonjs/components/RowndComponents.js +0 -25
- package/lib/commonjs/components/RowndComponents.js.map +0 -1
- package/lib/commonjs/components/RowndProvider.js +0 -55
- package/lib/commonjs/components/RowndProvider.js.map +0 -1
- package/lib/commonjs/components/SignIn.js +0 -644
- package/lib/commonjs/components/SignIn.js.map +0 -1
- package/lib/commonjs/components/images/CheckmarkFilled.js +0 -40
- package/lib/commonjs/components/images/CheckmarkFilled.js.map +0 -1
- package/lib/commonjs/components/images/EmailVerifyWaiting.js +0 -100
- package/lib/commonjs/components/images/EmailVerifyWaiting.js.map +0 -1
- package/lib/commonjs/components/images/ErrorIcon.js +0 -31
- package/lib/commonjs/components/images/ErrorIcon.js.map +0 -1
- package/lib/commonjs/components/images/PhoneVerifyWaiting.js +0 -91
- package/lib/commonjs/components/images/PhoneVerifyWaiting.js.map +0 -1
- package/lib/commonjs/data/actions.js +0 -26
- package/lib/commonjs/data/actions.js.map +0 -1
- package/lib/commonjs/hooks/api.js +0 -155
- package/lib/commonjs/hooks/api.js.map +0 -1
- package/lib/commonjs/hooks/debounce.js +0 -38
- package/lib/commonjs/hooks/debounce.js.map +0 -1
- package/lib/commonjs/hooks/fingerprint.js +0 -176
- package/lib/commonjs/hooks/fingerprint.js.map +0 -1
- package/lib/commonjs/hooks/index.js +0 -48
- package/lib/commonjs/hooks/index.js.map +0 -1
- package/lib/commonjs/hooks/interval.js +0 -31
- package/lib/commonjs/hooks/interval.js.map +0 -1
- package/lib/commonjs/hooks/nav.js +0 -39
- package/lib/commonjs/hooks/nav.js.map +0 -1
- package/lib/commonjs/index.tsx.bak +0 -26
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/events.js +0 -57
- package/lib/commonjs/utils/events.js.map +0 -1
- package/lib/commonjs/utils/form.js +0 -46
- package/lib/commonjs/utils/form.js.map +0 -1
- package/lib/commonjs/utils/queue.js +0 -117
- package/lib/commonjs/utils/queue.js.map +0 -1
- package/lib/commonjs/utils/storage.js +0 -15
- package/lib/commonjs/utils/storage.js.map +0 -1
- package/lib/commonjs/utils/tokens.js +0 -35
- package/lib/commonjs/utils/tokens.js.map +0 -1
- package/lib/commonjs/utils/user-data.js +0 -21
- package/lib/commonjs/utils/user-data.js.map +0 -1
- package/lib/module/assets/images/checkmark--filled.svg +0 -12
- package/lib/module/assets/images/email-verify-waiting.svg +0 -36
- package/lib/module/assets/images/error-icon-material.svg +0 -1
- package/lib/module/assets/images/phone-verify-waiting.svg +0 -26
- package/lib/module/components/AuthenticatedComponent.js +0 -24
- package/lib/module/components/AuthenticatedComponent.js.map +0 -1
- package/lib/module/components/AutoSigninDialog.js +0 -110
- package/lib/module/components/AutoSigninDialog.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js +0 -52
- package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/index.js +0 -5
- package/lib/module/components/BottomSheetTextInput/index.js.map +0 -1
- package/lib/module/components/BottomSheetTextInput/types.js +0 -2
- package/lib/module/components/BottomSheetTextInput/types.js.map +0 -1
- package/lib/module/components/DarkText.js +0 -24
- package/lib/module/components/DarkText.js.map +0 -1
- package/lib/module/components/DefaultContext.js +0 -244
- package/lib/module/components/DefaultContext.js.map +0 -1
- package/lib/module/components/RowndComponents.js +0 -12
- package/lib/module/components/RowndComponents.js.map +0 -1
- package/lib/module/components/RowndProvider.js +0 -39
- package/lib/module/components/RowndProvider.js.map +0 -1
- package/lib/module/components/SignIn.js +0 -616
- package/lib/module/components/SignIn.js.map +0 -1
- package/lib/module/components/images/CheckmarkFilled.js +0 -27
- package/lib/module/components/images/CheckmarkFilled.js.map +0 -1
- package/lib/module/components/images/EmailVerifyWaiting.js +0 -87
- package/lib/module/components/images/EmailVerifyWaiting.js.map +0 -1
- package/lib/module/components/images/ErrorIcon.js +0 -18
- package/lib/module/components/images/ErrorIcon.js.map +0 -1
- package/lib/module/components/images/PhoneVerifyWaiting.js +0 -78
- package/lib/module/components/images/PhoneVerifyWaiting.js.map +0 -1
- package/lib/module/data/actions.js +0 -19
- package/lib/module/data/actions.js.map +0 -1
- package/lib/module/hooks/api.js +0 -135
- package/lib/module/hooks/api.js.map +0 -1
- package/lib/module/hooks/debounce.js +0 -29
- package/lib/module/hooks/debounce.js.map +0 -1
- package/lib/module/hooks/fingerprint.js +0 -157
- package/lib/module/hooks/fingerprint.js.map +0 -1
- package/lib/module/hooks/index.js +0 -7
- package/lib/module/hooks/index.js.map +0 -1
- package/lib/module/hooks/interval.js +0 -23
- package/lib/module/hooks/interval.js.map +0 -1
- package/lib/module/hooks/nav.js +0 -30
- package/lib/module/hooks/nav.js.map +0 -1
- package/lib/module/index.tsx.bak +0 -26
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/events.js +0 -45
- package/lib/module/utils/events.js.map +0 -1
- package/lib/module/utils/form.js +0 -34
- package/lib/module/utils/form.js.map +0 -1
- package/lib/module/utils/queue.js +0 -109
- package/lib/module/utils/queue.js.map +0 -1
- package/lib/module/utils/storage.js +0 -6
- package/lib/module/utils/storage.js.map +0 -1
- package/lib/module/utils/tokens.js +0 -24
- package/lib/module/utils/tokens.js.map +0 -1
- package/lib/module/utils/user-data.js +0 -14
- package/lib/module/utils/user-data.js.map +0 -1
- package/lib/package.json +0 -173
- package/lib/typescript/src/components/AuthenticatedComponent.d.ts +0 -7
- package/lib/typescript/src/components/AutoSigninDialog.d.ts +0 -2
- package/lib/typescript/src/components/BottomSheetTextInput/BottomSheetTextInput.d.ts +0 -4
- package/lib/typescript/src/components/BottomSheetTextInput/index.d.ts +0 -2
- package/lib/typescript/src/components/BottomSheetTextInput/types.d.ts +0 -3
- package/lib/typescript/src/components/DarkText.d.ts +0 -3
- package/lib/typescript/src/components/DefaultContext.d.ts +0 -12
- package/lib/typescript/src/components/RowndComponents.d.ts +0 -2
- package/lib/typescript/src/components/RowndProvider.d.ts +0 -8
- package/lib/typescript/src/components/SignIn.d.ts +0 -2
- package/lib/typescript/src/components/images/CheckmarkFilled.d.ts +0 -4
- package/lib/typescript/src/components/images/EmailVerifyWaiting.d.ts +0 -4
- package/lib/typescript/src/components/images/ErrorIcon.d.ts +0 -4
- package/lib/typescript/src/components/images/PhoneVerifyWaiting.d.ts +0 -4
- package/lib/typescript/src/data/actions.d.ts +0 -20
- package/lib/typescript/src/hooks/api.d.ts +0 -12
- package/lib/typescript/src/hooks/debounce.d.ts +0 -5
- package/lib/typescript/src/hooks/fingerprint.d.ts +0 -12
- package/lib/typescript/src/hooks/index.d.ts +0 -6
- package/lib/typescript/src/hooks/interval.d.ts +0 -2
- package/lib/typescript/src/hooks/nav.d.ts +0 -6
- package/lib/typescript/src/index.d.ts +0 -4
- package/lib/typescript/src/types.d.ts +0 -26
- package/lib/typescript/src/utils/config.d.ts +0 -18
- package/lib/typescript/src/utils/events.d.ts +0 -22
- package/lib/typescript/src/utils/form.d.ts +0 -18
- package/lib/typescript/src/utils/queue.d.ts +0 -21
- package/lib/typescript/src/utils/storage.d.ts +0 -3
- package/lib/typescript/src/utils/tokens.d.ts +0 -4
- package/lib/typescript/src/utils/user-data.d.ts +0 -3
- package/react-native.podspec +0 -19
- package/src/assets/images/checkmark--filled.svg +0 -12
- package/src/assets/images/email-verify-waiting.svg +0 -36
- package/src/assets/images/error-icon-material.svg +0 -1
- package/src/assets/images/phone-verify-waiting.svg +0 -26
- package/src/components/AuthenticatedComponent.tsx +0 -30
- package/src/components/AutoSigninDialog.tsx +0 -131
- package/src/components/BottomSheetTextInput/BottomSheetTextInput.tsx +0 -57
- package/src/components/BottomSheetTextInput/index.ts +0 -5
- package/src/components/BottomSheetTextInput/types.ts +0 -3
- package/src/components/DarkText.tsx +0 -16
- package/src/components/DefaultContext.tsx +0 -278
- package/src/components/RowndComponents.tsx +0 -18
- package/src/components/RowndProvider.tsx +0 -56
- package/src/components/SignIn.tsx +0 -797
- package/src/components/images/CheckmarkFilled.tsx +0 -30
- package/src/components/images/EmailVerifyWaiting.tsx +0 -95
- package/src/components/images/ErrorIcon.tsx +0 -11
- package/src/components/images/PhoneVerifyWaiting.tsx +0 -74
- package/src/data/actions.ts +0 -21
- package/src/hooks/api.ts +0 -162
- package/src/hooks/debounce.ts +0 -36
- package/src/hooks/fingerprint.ts +0 -217
- package/src/hooks/index.ts +0 -7
- package/src/hooks/interval.ts +0 -25
- package/src/hooks/nav.tsx +0 -29
- package/src/index.tsx.bak +0 -26
- package/src/types.ts +0 -27
- package/src/utils/events.ts +0 -54
- package/src/utils/form.tsx +0 -64
- package/src/utils/queue.ts +0 -75
- package/src/utils/storage.ts +0 -7
- package/src/utils/tokens.ts +0 -26
- package/src/utils/user-data.ts +0 -15
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { useEffect, useCallback, useRef } from 'react';
|
|
2
|
-
import isEqual from 'lodash-es/isEqual';
|
|
3
|
-
import { useDebounce, useApi, useDeviceFingerprint } from '../hooks';
|
|
4
|
-
import { DEFAULT_USER_AGENT } from '../hooks/api';
|
|
5
|
-
import { useGlobalContext } from './GlobalContext';
|
|
6
|
-
import { ActionType } from '../data/actions';
|
|
7
|
-
import ky from 'ky';
|
|
8
|
-
import Clipboard from '@react-native-clipboard/clipboard';
|
|
9
|
-
import base64 from 'react-native-base64';
|
|
10
|
-
import { Linking } from 'react-native';
|
|
11
|
-
import { events, EventType } from '../utils/events';
|
|
12
|
-
export function DefaultContext(_ref) {
|
|
13
|
-
let {
|
|
14
|
-
config
|
|
15
|
-
} = _ref;
|
|
16
|
-
const {
|
|
17
|
-
state,
|
|
18
|
-
dispatch
|
|
19
|
-
} = useGlobalContext();
|
|
20
|
-
const {
|
|
21
|
-
client: api
|
|
22
|
-
} = useApi();
|
|
23
|
-
useDeviceFingerprint(); // Fetch app schema and config
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
(async () => {
|
|
27
|
-
try {
|
|
28
|
-
var _resp$app;
|
|
29
|
-
|
|
30
|
-
const resp = await api.get('hub/app-config', {
|
|
31
|
-
headers: {
|
|
32
|
-
'x-rownd-app-key': config.appKey
|
|
33
|
-
}
|
|
34
|
-
}).json();
|
|
35
|
-
|
|
36
|
-
if (resp !== null && resp !== void 0 && (_resp$app = resp.app) !== null && _resp$app !== void 0 && _resp$app.icon) {
|
|
37
|
-
const iconMeta = await ky.get(resp.app.icon);
|
|
38
|
-
resp.app.icon_content_type = iconMeta.headers.get('content-type');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
dispatch({
|
|
42
|
-
type: ActionType.SET_APP_CONFIG,
|
|
43
|
-
payload: resp.app
|
|
44
|
-
});
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error('Failed to fetch app config:', err);
|
|
47
|
-
}
|
|
48
|
-
})();
|
|
49
|
-
}, [api, config.appKey, dispatch]);
|
|
50
|
-
/**
|
|
51
|
-
* If not signed in, check the clipboard for an init hash or auth link we can use to auto-auth the user
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (state.auth.access_token || !state.app.id) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
(async () => {
|
|
60
|
-
try {
|
|
61
|
-
let authData = null;
|
|
62
|
-
let authLink = (await Linking.getInitialURL()) || (await Clipboard.getString());
|
|
63
|
-
|
|
64
|
-
if (authLink.includes('rownd.link')) {
|
|
65
|
-
dispatch({
|
|
66
|
-
type: ActionType.CHANGE_ROUTE,
|
|
67
|
-
payload: {
|
|
68
|
-
route: '/account/auto-signin',
|
|
69
|
-
opts: {
|
|
70
|
-
type: 'sign-in'
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
authData = await ky.get(authLink, {
|
|
75
|
-
headers: {
|
|
76
|
-
'User-Agent': DEFAULT_USER_AGENT
|
|
77
|
-
}
|
|
78
|
-
}).json();
|
|
79
|
-
} else if (authLink.startsWith('rph_init=')) {
|
|
80
|
-
const authStr = authLink.split('rph_init=')[1];
|
|
81
|
-
authData = JSON.parse(base64.decode(authStr));
|
|
82
|
-
} else {
|
|
83
|
-
return;
|
|
84
|
-
} // Clear the clipboard value so we don't leak any creds
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
Clipboard.setString('');
|
|
88
|
-
dispatch({
|
|
89
|
-
type: ActionType.LOGIN_SUCCESS,
|
|
90
|
-
payload: authData
|
|
91
|
-
});
|
|
92
|
-
} catch (err) {
|
|
93
|
-
console.error('We found an auth link or string, but failed to authenticate with it because:', err);
|
|
94
|
-
}
|
|
95
|
-
})();
|
|
96
|
-
}, [state.auth.access_token, state.app.id, dispatch]);
|
|
97
|
-
const retrieveUserInfo = useCallback(() => {
|
|
98
|
-
if (!state.auth.access_token || !state.app.id) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
(async () => {
|
|
103
|
-
const userInfo = await api.get(`me/applications/${state.app.id}/data`, {
|
|
104
|
-
headers: {
|
|
105
|
-
Authorization: `Bearer ${state.auth.access_token}`
|
|
106
|
-
}
|
|
107
|
-
}).json();
|
|
108
|
-
dispatch({
|
|
109
|
-
type: ActionType.LOAD_USER,
|
|
110
|
-
payload: userInfo
|
|
111
|
-
});
|
|
112
|
-
dispatch({
|
|
113
|
-
type: ActionType.UPDATE_LOCAL_ACLS,
|
|
114
|
-
payload: userInfo.redacted.reduce((acc, field) => {
|
|
115
|
-
acc[field] = {
|
|
116
|
-
shared: false
|
|
117
|
-
};
|
|
118
|
-
return acc;
|
|
119
|
-
}, {})
|
|
120
|
-
});
|
|
121
|
-
})();
|
|
122
|
-
}, [api, dispatch, state.app.id, state.auth.access_token]);
|
|
123
|
-
const retrieveAcls = useCallback(() => {
|
|
124
|
-
if (!state.app.id || !state.auth.access_token) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
(async () => {
|
|
129
|
-
try {
|
|
130
|
-
const appUserAcls = await api.get(`me/applications/${state.app.id}/acls`, {
|
|
131
|
-
headers: {
|
|
132
|
-
Authorization: `Bearer ${state.auth.access_token}`
|
|
133
|
-
}
|
|
134
|
-
}).json();
|
|
135
|
-
dispatch({
|
|
136
|
-
type: ActionType.UPDATE_LOCAL_ACLS,
|
|
137
|
-
payload: appUserAcls.acls
|
|
138
|
-
});
|
|
139
|
-
} catch (err) {
|
|
140
|
-
if (err instanceof Error) {
|
|
141
|
-
// const unsharedAcls = reduceSchemaToUnsharedAcls();
|
|
142
|
-
dispatch({
|
|
143
|
-
type: ActionType.UPDATE_LOCAL_ACLS,
|
|
144
|
-
payload: {}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
})();
|
|
149
|
-
}, [api, dispatch, state.app.id, state.auth.access_token]);
|
|
150
|
-
useEffect(retrieveUserInfo, [retrieveUserInfo]);
|
|
151
|
-
useEffect(retrieveAcls, [retrieveAcls]);
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (!state.user.needs_refresh) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
retrieveUserInfo();
|
|
158
|
-
dispatch({
|
|
159
|
-
type: ActionType.SET_REFRESH_USER_DATA,
|
|
160
|
-
payload: {
|
|
161
|
-
needs_refresh: false
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}, [dispatch, retrieveUserInfo, state.user.needs_refresh]);
|
|
165
|
-
const saveAclsDebounced = useDebounce(saveAcls, 2000); // 2s
|
|
166
|
-
|
|
167
|
-
async function saveAcls() {
|
|
168
|
-
if (state.app.id && state.local_acls) {
|
|
169
|
-
await api.put(`me/applications/${state.app.id}/acls`, {
|
|
170
|
-
headers: {
|
|
171
|
-
Authorization: `Bearer ${state.auth.access_token}`
|
|
172
|
-
},
|
|
173
|
-
json: {
|
|
174
|
-
acls: state.local_acls
|
|
175
|
-
}
|
|
176
|
-
}).json();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const localAclsRef = useRef(state.local_acls);
|
|
181
|
-
useEffect(() => {
|
|
182
|
-
// Don't save acls if they were just loaded for the first time or they haven't changed
|
|
183
|
-
if (!localAclsRef.current || isEqual(localAclsRef.current, state.local_acls)) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
saveAclsDebounced();
|
|
188
|
-
}, [saveAclsDebounced, state.local_acls]);
|
|
189
|
-
const saveUserDataDebounced = useDebounce(saveUserData, 2000); // 2s
|
|
190
|
-
// Save user data in the application state to the API server
|
|
191
|
-
|
|
192
|
-
async function saveUserData() {
|
|
193
|
-
if (state.app.id && state.user.data && state.auth.access_token) {
|
|
194
|
-
dispatch({
|
|
195
|
-
type: ActionType.SET_IS_SAVING_USER_DATA,
|
|
196
|
-
payload: {
|
|
197
|
-
saving: true
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
const eventDetails = {};
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
eventDetails.data = await api.put(`me/applications/${state.app.id}/data`, {
|
|
204
|
-
headers: {
|
|
205
|
-
Authorization: `Bearer ${state.auth.access_token}`
|
|
206
|
-
},
|
|
207
|
-
json: {
|
|
208
|
-
data: state.user.data
|
|
209
|
-
}
|
|
210
|
-
}).json();
|
|
211
|
-
} catch (err) {
|
|
212
|
-
eventDetails.error = err; // Get the latest user info from Rownd. Something was probably bad
|
|
213
|
-
// with the data we just tried to save.
|
|
214
|
-
// This is a bit hacky. We should be able to reset the state without
|
|
215
|
-
// calling rownd again by rolling back to a previously good state...
|
|
216
|
-
|
|
217
|
-
retrieveUserInfo(); // TODO: Set some error state
|
|
218
|
-
} finally {
|
|
219
|
-
events.dispatch(EventType.USER_DATA_SAVED, eventDetails);
|
|
220
|
-
dispatch({
|
|
221
|
-
type: ActionType.SET_IS_SAVING_USER_DATA,
|
|
222
|
-
payload: {
|
|
223
|
-
saving: false
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const userDataRef = useRef(state.user.data);
|
|
231
|
-
useEffect(() => {
|
|
232
|
-
var _state$user$data;
|
|
233
|
-
|
|
234
|
-
// Don't update the user data in the API server if the email is unknown or the data hasn't changed
|
|
235
|
-
if (!((_state$user$data = state.user.data) !== null && _state$user$data !== void 0 && _state$user$data.email) && !state.user.data.phone_number || isEqual(userDataRef.current, state.user.data)) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
saveUserDataDebounced();
|
|
240
|
-
userDataRef.current = state.user.data;
|
|
241
|
-
}, [dispatch, saveUserDataDebounced, state.user.data]);
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
//# sourceMappingURL=DefaultContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useCallback","useRef","isEqual","useDebounce","useApi","useDeviceFingerprint","DEFAULT_USER_AGENT","useGlobalContext","ActionType","ky","Clipboard","base64","Linking","events","EventType","DefaultContext","config","state","dispatch","client","api","resp","get","headers","appKey","json","app","icon","iconMeta","icon_content_type","type","SET_APP_CONFIG","payload","err","console","error","auth","access_token","id","authData","authLink","getInitialURL","getString","includes","CHANGE_ROUTE","route","opts","startsWith","authStr","split","JSON","parse","decode","setString","LOGIN_SUCCESS","retrieveUserInfo","userInfo","Authorization","LOAD_USER","UPDATE_LOCAL_ACLS","redacted","reduce","acc","field","shared","retrieveAcls","appUserAcls","acls","Error","user","needs_refresh","SET_REFRESH_USER_DATA","saveAclsDebounced","saveAcls","local_acls","put","localAclsRef","current","saveUserDataDebounced","saveUserData","data","SET_IS_SAVING_USER_DATA","saving","eventDetails","USER_DATA_SAVED","userDataRef","email","phone_number"],"sources":["DefaultContext.tsx"],"sourcesContent":["import { useEffect, useCallback, useRef } from 'react';\nimport isEqual from 'lodash-es/isEqual';\nimport { useDebounce, useApi, useDeviceFingerprint } from '../hooks';\nimport { DEFAULT_USER_AGENT } from '../hooks/api';\nimport { IConfig } from '../utils/config';\nimport { useGlobalContext } from './GlobalContext';\nimport { ActionType } from '../data/actions';\nimport ky from 'ky';\nimport Clipboard from '@react-native-clipboard/clipboard';\nimport base64 from 'react-native-base64';\nimport { Linking } from 'react-native';\nimport { events, EventType } from '../utils/events';\n\nexport type UserInfoResp = {\n data: {\n [key: string]: any;\n };\n redacted: string[];\n};\n\ninterface UserAclsResponse {\n acls: Record<string, { shared: boolean }>;\n}\n\ntype DefaultContextProps = {\n config: IConfig;\n};\n\nexport function DefaultContext({ config }: DefaultContextProps) {\n const { state, dispatch } = useGlobalContext();\n const { client: api } = useApi();\n useDeviceFingerprint();\n\n // Fetch app schema and config\n useEffect(() => {\n (async () => {\n try {\n const resp: any = await api\n .get('hub/app-config', {\n headers: {\n 'x-rownd-app-key': config.appKey,\n },\n })\n .json();\n\n if (resp?.app?.icon) {\n const iconMeta = await ky.get(resp.app.icon);\n resp.app.icon_content_type = iconMeta.headers.get('content-type');\n }\n\n dispatch({\n type: ActionType.SET_APP_CONFIG,\n payload: resp.app,\n });\n } catch (err) {\n console.error('Failed to fetch app config:', err);\n }\n })();\n }, [api, config.appKey, dispatch]);\n\n /**\n * If not signed in, check the clipboard for an init hash or auth link we can use to auto-auth the user\n */\n useEffect(() => {\n if (state.auth.access_token || !state.app.id) {\n return;\n }\n\n (async () => {\n try {\n let authData = null;\n\n let authLink =\n (await Linking.getInitialURL()) || (await Clipboard.getString());\n if (authLink.includes('rownd.link')) {\n dispatch({\n type: ActionType.CHANGE_ROUTE,\n payload: {\n route: '/account/auto-signin',\n opts: {\n type: 'sign-in',\n },\n },\n });\n\n authData = await ky\n .get(authLink, {\n headers: {\n 'User-Agent': DEFAULT_USER_AGENT,\n },\n })\n .json();\n } else if (authLink.startsWith('rph_init=')) {\n const authStr = authLink.split('rph_init=')[1];\n authData = JSON.parse(base64.decode(authStr));\n } else {\n return;\n }\n\n // Clear the clipboard value so we don't leak any creds\n Clipboard.setString('');\n\n dispatch({\n type: ActionType.LOGIN_SUCCESS,\n payload: authData,\n });\n } catch (err) {\n console.error(\n 'We found an auth link or string, but failed to authenticate with it because:',\n err\n );\n }\n })();\n }, [state.auth.access_token, state.app.id, dispatch]);\n\n const retrieveUserInfo = useCallback(() => {\n if (!state.auth.access_token || !state.app.id) {\n return;\n }\n\n (async () => {\n const userInfo: UserInfoResp = await api\n .get(`me/applications/${state.app.id}/data`, {\n headers: {\n Authorization: `Bearer ${state.auth.access_token}`,\n },\n })\n .json();\n dispatch({\n type: ActionType.LOAD_USER,\n payload: userInfo,\n });\n\n dispatch({\n type: ActionType.UPDATE_LOCAL_ACLS,\n payload: userInfo.redacted.reduce(\n (acc: Record<string, any>, field: string) => {\n acc[field] = { shared: false };\n return acc;\n },\n {}\n ),\n });\n })();\n }, [api, dispatch, state.app.id, state.auth.access_token]);\n\n const retrieveAcls = useCallback(() => {\n if (!state.app.id || !state.auth.access_token) {\n return;\n }\n\n (async () => {\n try {\n const appUserAcls: UserAclsResponse = await api\n .get(`me/applications/${state.app.id}/acls`, {\n headers: {\n Authorization: `Bearer ${state.auth.access_token}`,\n },\n })\n .json();\n dispatch({\n type: ActionType.UPDATE_LOCAL_ACLS,\n payload: appUserAcls.acls,\n });\n } catch (err) {\n if (err instanceof Error) {\n // const unsharedAcls = reduceSchemaToUnsharedAcls();\n dispatch({\n type: ActionType.UPDATE_LOCAL_ACLS,\n payload: {},\n });\n }\n }\n })();\n }, [api, dispatch, state.app.id, state.auth.access_token]);\n\n useEffect(retrieveUserInfo, [retrieveUserInfo]);\n useEffect(retrieveAcls, [retrieveAcls]);\n\n useEffect(() => {\n if (!state.user.needs_refresh) {\n return;\n }\n retrieveUserInfo();\n dispatch({\n type: ActionType.SET_REFRESH_USER_DATA,\n payload: { needs_refresh: false },\n });\n }, [dispatch, retrieveUserInfo, state.user.needs_refresh]);\n\n const saveAclsDebounced = useDebounce(saveAcls, 2000); // 2s\n\n async function saveAcls() {\n if (state.app.id && state.local_acls) {\n await api\n .put(`me/applications/${state.app.id}/acls`, {\n headers: {\n Authorization: `Bearer ${state.auth.access_token}`,\n },\n json: {\n acls: state.local_acls,\n },\n })\n .json();\n }\n }\n\n const localAclsRef = useRef(state.local_acls);\n useEffect(() => {\n // Don't save acls if they were just loaded for the first time or they haven't changed\n if (\n !localAclsRef.current ||\n isEqual(localAclsRef.current, state.local_acls)\n ) {\n return;\n }\n saveAclsDebounced();\n }, [saveAclsDebounced, state.local_acls]);\n\n const saveUserDataDebounced = useDebounce(saveUserData, 2000); // 2s\n\n // Save user data in the application state to the API server\n async function saveUserData() {\n if (state.app.id && state.user.data && state.auth.access_token) {\n dispatch({\n type: ActionType.SET_IS_SAVING_USER_DATA,\n payload: {\n saving: true,\n },\n });\n\n const eventDetails: Record<string, any> = {};\n try {\n eventDetails.data = await api\n .put(`me/applications/${state.app.id}/data`, {\n headers: {\n Authorization: `Bearer ${state.auth.access_token}`,\n },\n json: {\n data: state.user.data,\n },\n })\n .json();\n } catch (err) {\n eventDetails.error = err;\n // Get the latest user info from Rownd. Something was probably bad\n // with the data we just tried to save.\n // This is a bit hacky. We should be able to reset the state without\n // calling rownd again by rolling back to a previously good state...\n retrieveUserInfo();\n // TODO: Set some error state\n } finally {\n events.dispatch(EventType.USER_DATA_SAVED, eventDetails);\n dispatch({\n type: ActionType.SET_IS_SAVING_USER_DATA,\n payload: {\n saving: false,\n },\n });\n }\n }\n }\n\n const userDataRef = useRef(state.user.data);\n useEffect(() => {\n // Don't update the user data in the API server if the email is unknown or the data hasn't changed\n if (\n (!state.user.data?.email && !state.user.data.phone_number) ||\n isEqual(userDataRef.current, state.user.data)\n ) {\n return;\n }\n saveUserDataDebounced();\n userDataRef.current = state.user.data;\n }, [dispatch, saveUserDataDebounced, state.user.data]);\n\n return null;\n}\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,WAApB,EAAiCC,MAAjC,QAA+C,OAA/C;AACA,OAAOC,OAAP,MAAoB,mBAApB;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,oBAA9B,QAA0D,UAA1D;AACA,SAASC,kBAAT,QAAmC,cAAnC;AAEA,SAASC,gBAAT,QAAiC,iBAAjC;AACA,SAASC,UAAT,QAA2B,iBAA3B;AACA,OAAOC,EAAP,MAAe,IAAf;AACA,OAAOC,SAAP,MAAsB,mCAAtB;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AACA,SAASC,OAAT,QAAwB,cAAxB;AACA,SAASC,MAAT,EAAiBC,SAAjB,QAAkC,iBAAlC;AAiBA,OAAO,SAASC,cAAT,OAAyD;EAAA,IAAjC;IAAEC;EAAF,CAAiC;EAC9D,MAAM;IAAEC,KAAF;IAASC;EAAT,IAAsBX,gBAAgB,EAA5C;EACA,MAAM;IAAEY,MAAM,EAAEC;EAAV,IAAkBhB,MAAM,EAA9B;EACAC,oBAAoB,GAH0C,CAK9D;;EACAN,SAAS,CAAC,MAAM;IACd,CAAC,YAAY;MACX,IAAI;QAAA;;QACF,MAAMsB,IAAS,GAAG,MAAMD,GAAG,CACxBE,GADqB,CACjB,gBADiB,EACC;UACrBC,OAAO,EAAE;YACP,mBAAmBP,MAAM,CAACQ;UADnB;QADY,CADD,EAMrBC,IANqB,EAAxB;;QAQA,IAAIJ,IAAJ,aAAIA,IAAJ,4BAAIA,IAAI,CAAEK,GAAV,sCAAI,UAAWC,IAAf,EAAqB;UACnB,MAAMC,QAAQ,GAAG,MAAMnB,EAAE,CAACa,GAAH,CAAOD,IAAI,C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;IAAA;;IACd;IACA,IACG,sBAACkB,KAAK,CAACoD,IAAN,CAAWW,IAAZ,6CAAC,iBAAiBM,KAAlB,KAA2B,CAACrE,KAAK,CAACoD,IAAN,CAAWW,IAAX,CAAgBO,YAA7C,IACArF,OAAO,CAACmF,WAAW,CAACR,OAAb,EAAsB5D,KAAK,CAACoD,IAAN,CAAWW,IAAjC,CAFT,EAGE;MACA;IACD;;IACDF,qBAAqB;IACrBO,WAAW,CAACR,OAAZ,GAAsB5D,KAAK,CAACoD,IAAN,CAAWW,IAAjC;EACD,CAVQ,EAUN,CAAC9D,QAAD,EAAW4D,qBAAX,EAAkC7D,KAAK,CAACoD,IAAN,CAAWW,IAA7C,CAVM,CAAT;EAYA,OAAO,IAAP;AACD"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SignIn } from './SignIn';
|
|
3
|
-
import { AutoSigninDialog } from './AutoSigninDialog';
|
|
4
|
-
import { useGlobalContext } from './GlobalContext';
|
|
5
|
-
export function RowndComponents() {
|
|
6
|
-
const {
|
|
7
|
-
state
|
|
8
|
-
} = useGlobalContext(); // useDeviceContext(tw);
|
|
9
|
-
|
|
10
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, state.nav.current_route === '/account/login' && /*#__PURE__*/React.createElement(SignIn, null), state.nav.current_route === '/account/auto-signin' && /*#__PURE__*/React.createElement(AutoSigninDialog, null));
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=RowndComponents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","SignIn","AutoSigninDialog","useGlobalContext","RowndComponents","state","nav","current_route"],"sources":["RowndComponents.tsx"],"sourcesContent":["import React from 'react';\nimport { SignIn } from './SignIn';\nimport { AutoSigninDialog } from './AutoSigninDialog';\nimport { useGlobalContext } from './GlobalContext';\n\nexport function RowndComponents() {\n const { state } = useGlobalContext();\n // useDeviceContext(tw);\n\n return (\n <>\n {state.nav.current_route === '/account/login' && <SignIn />}\n {state.nav.current_route === '/account/auto-signin' && (\n <AutoSigninDialog />\n )}\n </>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,MAAT,QAAuB,UAAvB;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,gBAAT,QAAiC,iBAAjC;AAEA,OAAO,SAASC,eAAT,GAA2B;EAChC,MAAM;IAAEC;EAAF,IAAYF,gBAAgB,EAAlC,CADgC,CAEhC;;EAEA,oBACE,0CACGE,KAAK,CAACC,GAAN,CAAUC,aAAV,KAA4B,gBAA5B,iBAAgD,oBAAC,MAAD,OADnD,EAEGF,KAAK,CAACC,GAAN,CAAUC,aAAV,KAA4B,sBAA5B,iBACC,oBAAC,gBAAD,OAHJ,CADF;AAQD"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, StyleSheet } from 'react-native';
|
|
3
|
-
import { GlobalContextProvider } from './GlobalContext';
|
|
4
|
-
import { DefaultContext } from './DefaultContext';
|
|
5
|
-
import { createConfig } from '../utils/config';
|
|
6
|
-
import { RowndComponents } from './RowndComponents';
|
|
7
|
-
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet'; // const RowndContext = createContext<TRowndContext | undefined>(undefined);
|
|
8
|
-
|
|
9
|
-
export function RowndProvider(_ref) {
|
|
10
|
-
let {
|
|
11
|
-
appKey,
|
|
12
|
-
apiUrl,
|
|
13
|
-
children
|
|
14
|
-
} = _ref;
|
|
15
|
-
// const [isSigningIn, setIsSigningIn] = useState<boolean>(false);
|
|
16
|
-
// const requestSignIn = useRef(function () {
|
|
17
|
-
// setIsSigningIn(true);
|
|
18
|
-
// });
|
|
19
|
-
// const [rowndState, setRowndState] = useState<any>({
|
|
20
|
-
// requestSignIn: requestSignIn.current,
|
|
21
|
-
// });
|
|
22
|
-
const config = createConfig({
|
|
23
|
-
appKey,
|
|
24
|
-
apiUrl
|
|
25
|
-
});
|
|
26
|
-
return /*#__PURE__*/React.createElement(GlobalContextProvider, {
|
|
27
|
-
config: config
|
|
28
|
-
}, /*#__PURE__*/React.createElement(DefaultContext, {
|
|
29
|
-
config: config
|
|
30
|
-
}), /*#__PURE__*/React.createElement(BottomSheetModalProvider, null, /*#__PURE__*/React.createElement(View, {
|
|
31
|
-
style: styles.container
|
|
32
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(RowndComponents, null)))));
|
|
33
|
-
}
|
|
34
|
-
const styles = StyleSheet.create({
|
|
35
|
-
container: {
|
|
36
|
-
flex: 1
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=RowndProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","StyleSheet","GlobalContextProvider","DefaultContext","createConfig","RowndComponents","BottomSheetModalProvider","RowndProvider","appKey","apiUrl","children","config","styles","container","create","flex"],"sources":["RowndProvider.tsx"],"sourcesContent":["import React from 'react';\nimport { View, StyleSheet } from 'react-native';\nimport { GlobalContextProvider } from './GlobalContext';\nimport { DefaultContext } from './DefaultContext';\nimport { createConfig } from '../utils/config';\nimport { RowndComponents } from './RowndComponents';\nimport { BottomSheetModalProvider } from '@gorhom/bottom-sheet';\n\n// const RowndContext = createContext<TRowndContext | undefined>(undefined);\n\ninterface IRowndProviderProps {\n appKey: string;\n apiUrl?: string;\n children: React.ReactNode;\n}\n\nexport function RowndProvider({\n appKey,\n apiUrl,\n children,\n}: IRowndProviderProps) {\n // const [isSigningIn, setIsSigningIn] = useState<boolean>(false);\n\n // const requestSignIn = useRef(function () {\n // setIsSigningIn(true);\n // });\n\n // const [rowndState, setRowndState] = useState<any>({\n // requestSignIn: requestSignIn.current,\n // });\n\n const config = createConfig({\n appKey,\n apiUrl,\n });\n\n return (\n <GlobalContextProvider config={config}>\n <DefaultContext config={config} />\n <BottomSheetModalProvider>\n <View style={styles.container}>\n <>\n {children}\n <RowndComponents />\n </>\n </View>\n </BottomSheetModalProvider>\n </GlobalContextProvider>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,cAAjC;AACA,SAASC,qBAAT,QAAsC,iBAAtC;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,wBAAT,QAAyC,sBAAzC,C,CAEA;;AAQA,OAAO,SAASC,aAAT,OAIiB;EAAA,IAJM;IAC5BC,MAD4B;IAE5BC,MAF4B;IAG5BC;EAH4B,CAIN;EACtB;EAEA;EACA;EACA;EAEA;EACA;EACA;EAEA,MAAMC,MAAM,GAAGP,YAAY,CAAC;IAC1BI,MAD0B;IAE1BC;EAF0B,CAAD,CAA3B;EAKA,oBACE,oBAAC,qBAAD;IAAuB,MAAM,EAAEE;EAA/B,gBACE,oBAAC,cAAD;IAAgB,MAAM,EAAEA;EAAxB,EADF,eAEE,oBAAC,wBAAD,qBACE,oBAAC,IAAD;IAAM,KAAK,EAAEC,MAAM,CAACC;EAApB,gBACE,0CACGH,QADH,eAEE,oBAAC,eAAD,OAFF,CADF,CADF,CAFF,CADF;AAaD;AAED,MAAME,MAAM,GAAGX,UAAU,CAACa,MAAX,CAAkB;EAC/BD,SAAS,EAAE;IACTE,IAAI,EAAE;EADG;AADoB,CAAlB,CAAf"}
|