@rownd/react-native 0.1.10 → 0.2.1
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/README.md +17 -6
- package/lib/commonjs/assets/images/error-icon-material.svg +1 -0
- package/lib/commonjs/components/AutoSigninDialog.js +29 -16
- package/lib/commonjs/components/AutoSigninDialog.js.map +1 -1
- package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js +65 -0
- package/lib/commonjs/components/BottomSheetTextInput/BottomSheetTextInput.js.map +1 -0
- package/lib/commonjs/components/BottomSheetTextInput/index.js +24 -0
- package/lib/commonjs/components/BottomSheetTextInput/index.js.map +1 -0
- package/lib/commonjs/components/BottomSheetTextInput/types.js +6 -0
- package/lib/commonjs/components/BottomSheetTextInput/types.js.map +1 -0
- package/lib/commonjs/components/DefaultContext.js.map +1 -1
- package/lib/commonjs/components/GlobalContext.js.map +1 -1
- package/lib/commonjs/components/RowndComponents.js +4 -6
- package/lib/commonjs/components/RowndComponents.js.map +1 -1
- package/lib/commonjs/components/SignIn.js +55 -51
- package/lib/commonjs/components/SignIn.js.map +1 -1
- package/lib/commonjs/components/images/ErrorIcon.js +31 -0
- package/lib/commonjs/components/images/ErrorIcon.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/assets/images/error-icon-material.svg +1 -0
- package/lib/module/components/AutoSigninDialog.js +25 -15
- package/lib/module/components/AutoSigninDialog.js.map +1 -1
- package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js +52 -0
- package/lib/module/components/BottomSheetTextInput/BottomSheetTextInput.js.map +1 -0
- package/lib/module/components/BottomSheetTextInput/index.js +5 -0
- package/lib/module/components/BottomSheetTextInput/index.js.map +1 -0
- package/lib/module/components/BottomSheetTextInput/types.js +2 -0
- package/lib/module/components/BottomSheetTextInput/types.js.map +1 -0
- package/lib/module/components/DefaultContext.js.map +1 -1
- package/lib/module/components/GlobalContext.js.map +1 -1
- package/lib/module/components/RowndComponents.js +5 -5
- package/lib/module/components/RowndComponents.js.map +1 -1
- package/lib/module/components/SignIn.js +41 -37
- package/lib/module/components/SignIn.js.map +1 -1
- package/lib/module/components/images/ErrorIcon.js +18 -0
- package/lib/module/components/images/ErrorIcon.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/package.json +3 -5
- package/lib/typescript/src/components/BottomSheetTextInput/BottomSheetTextInput.d.ts +4 -0
- package/lib/typescript/src/components/BottomSheetTextInput/index.d.ts +2 -0
- package/lib/typescript/src/components/BottomSheetTextInput/types.d.ts +3 -0
- package/lib/typescript/src/components/DefaultContext.d.ts +1 -1
- package/lib/typescript/src/components/GlobalContext.d.ts +2 -2
- package/lib/typescript/src/components/images/ErrorIcon.d.ts +4 -0
- package/package.json +3 -5
- package/src/assets/images/error-icon-material.svg +1 -0
- package/src/components/AutoSigninDialog.tsx +19 -13
- package/src/components/BottomSheetTextInput/BottomSheetTextInput.tsx +57 -0
- package/src/components/BottomSheetTextInput/index.ts +5 -0
- package/src/components/BottomSheetTextInput/types.ts +3 -0
- package/src/components/DefaultContext.tsx +1 -1
- package/src/components/GlobalContext.tsx +2 -2
- package/src/components/RowndComponents.tsx +3 -3
- package/src/components/SignIn.tsx +47 -37
- package/src/components/images/ErrorIcon.tsx +11 -0
- package/src/types.ts +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { memo, useCallback, forwardRef } from 'react';
|
|
4
|
+
import { TextInput } from 'react-native-gesture-handler';
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
const {
|
|
8
|
+
useBottomSheetInternal
|
|
9
|
+
} = require('@gorhom/bottom-sheet/src/hooks/useBottomSheetInternal');
|
|
10
|
+
|
|
11
|
+
const BottomSheetTextInputComponent = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
12
|
+
let {
|
|
13
|
+
onFocus,
|
|
14
|
+
onBlur,
|
|
15
|
+
...rest
|
|
16
|
+
} = _ref;
|
|
17
|
+
//#region hooks
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
let {
|
|
20
|
+
shouldHandleKeyboardEvents
|
|
21
|
+
} = useBottomSheetInternal(); //#endregion
|
|
22
|
+
|
|
23
|
+
if (!shouldHandleKeyboardEvents) {
|
|
24
|
+
shouldHandleKeyboardEvents = {};
|
|
25
|
+
} //#region callbacks
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const handleOnFocus = useCallback(args => {
|
|
29
|
+
shouldHandleKeyboardEvents.value = true;
|
|
30
|
+
|
|
31
|
+
if (onFocus) {
|
|
32
|
+
onFocus(args);
|
|
33
|
+
}
|
|
34
|
+
}, [onFocus, shouldHandleKeyboardEvents]);
|
|
35
|
+
const handleOnBlur = useCallback(args => {
|
|
36
|
+
shouldHandleKeyboardEvents.value = false;
|
|
37
|
+
|
|
38
|
+
if (onBlur) {
|
|
39
|
+
onBlur(args);
|
|
40
|
+
}
|
|
41
|
+
}, [onBlur, shouldHandleKeyboardEvents]); //#endregion
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React.createElement(TextInput, _extends({
|
|
44
|
+
ref: ref,
|
|
45
|
+
onFocus: handleOnFocus,
|
|
46
|
+
onBlur: handleOnBlur
|
|
47
|
+
}, rest));
|
|
48
|
+
});
|
|
49
|
+
const BottomSheetTextInput = /*#__PURE__*/memo(BottomSheetTextInputComponent);
|
|
50
|
+
BottomSheetTextInput.displayName = 'BottomSheetTextInput';
|
|
51
|
+
export default BottomSheetTextInput;
|
|
52
|
+
//# sourceMappingURL=BottomSheetTextInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","memo","useCallback","forwardRef","TextInput","useBottomSheetInternal","require","BottomSheetTextInputComponent","ref","onFocus","onBlur","rest","shouldHandleKeyboardEvents","handleOnFocus","args","value","handleOnBlur","BottomSheetTextInput","displayName"],"sources":["BottomSheetTextInput.tsx"],"sourcesContent":["import React, { memo, useCallback, forwardRef } from 'react';\nimport { TextInput } from 'react-native-gesture-handler';\nimport { BottomSheetTextInputProps } from './types';\n\n// @ts-ignore\nconst {\n useBottomSheetInternal,\n} = require('@gorhom/bottom-sheet/src/hooks/useBottomSheetInternal');\n\nconst BottomSheetTextInputComponent = forwardRef<\n TextInput,\n BottomSheetTextInputProps\n>(({ onFocus, onBlur, ...rest }, ref) => {\n //#region hooks\n // @ts-ignore\n let { shouldHandleKeyboardEvents } = useBottomSheetInternal();\n //#endregion\n\n if (!shouldHandleKeyboardEvents) {\n shouldHandleKeyboardEvents = {};\n }\n\n //#region callbacks\n const handleOnFocus = useCallback(\n (args) => {\n shouldHandleKeyboardEvents.value = true;\n if (onFocus) {\n onFocus(args);\n }\n },\n [onFocus, shouldHandleKeyboardEvents]\n );\n const handleOnBlur = useCallback(\n (args) => {\n shouldHandleKeyboardEvents.value = false;\n if (onBlur) {\n onBlur(args);\n }\n },\n [onBlur, shouldHandleKeyboardEvents]\n );\n //#endregion\n\n return (\n <TextInput\n ref={ref}\n onFocus={handleOnFocus}\n onBlur={handleOnBlur}\n {...rest}\n />\n );\n});\n\nconst BottomSheetTextInput = memo(BottomSheetTextInputComponent);\nBottomSheetTextInput.displayName = 'BottomSheetTextInput';\n\nexport default BottomSheetTextInput;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,IAAhB,EAAsBC,WAAtB,EAAmCC,UAAnC,QAAqD,OAArD;AACA,SAASC,SAAT,QAA0B,8BAA1B;;AAGA;AACA,MAAM;EACJC;AADI,IAEFC,OAAO,CAAC,uDAAD,CAFX;;AAIA,MAAMC,6BAA6B,gBAAGJ,UAAU,CAG9C,OAA+BK,GAA/B,KAAuC;EAAA,IAAtC;IAAEC,OAAF;IAAWC,MAAX;IAAmB,GAAGC;EAAtB,CAAsC;EACvC;EACA;EACA,IAAI;IAAEC;EAAF,IAAiCP,sBAAsB,EAA3D,CAHuC,CAIvC;;EAEA,IAAI,CAACO,0BAAL,EAAiC;IAC/BA,0BAA0B,GAAG,EAA7B;EACD,CARsC,CAUvC;;;EACA,MAAMC,aAAa,GAAGX,WAAW,CAC9BY,IAAD,IAAU;IACRF,0BAA0B,CAACG,KAA3B,GAAmC,IAAnC;;IACA,IAAIN,OAAJ,EAAa;MACXA,OAAO,CAACK,IAAD,CAAP;IACD;EACF,CAN8B,EAO/B,CAACL,OAAD,EAAUG,0BAAV,CAP+B,CAAjC;EASA,MAAMI,YAAY,GAAGd,WAAW,CAC7BY,IAAD,IAAU;IACRF,0BAA0B,CAACG,KAA3B,GAAmC,KAAnC;;IACA,IAAIL,MAAJ,EAAY;MACVA,MAAM,CAACI,IAAD,CAAN;IACD;EACF,CAN6B,EAO9B,CAACJ,MAAD,EAASE,0BAAT,CAP8B,CAAhC,CApBuC,CA6BvC;;EAEA,oBACE,oBAAC,SAAD;IACE,GAAG,EAAEJ,GADP;IAEE,OAAO,EAAEK,aAFX;IAGE,MAAM,EAAEG;EAHV,GAIML,IAJN,EADF;AAQD,CA1C+C,CAAhD;AA4CA,MAAMM,oBAAoB,gBAAGhB,IAAI,CAACM,6BAAD,CAAjC;AACAU,oBAAoB,CAACC,WAArB,GAAmC,sBAAnC;AAEA,eAAeD,oBAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","BottomSheetTextInputProps"],"sources":["index.ts"],"sourcesContent":["// @ts-ignore\nexport { default } from './BottomSheetTextInput';\n\n// @ts-ignore\nexport { BottomSheetTextInputProps } from './types';\n"],"mappings":"AAAA;AACA,SAASA,OAAT,QAAwB,wBAAxB,C,CAEA;;AACA,SAASC,yBAAT,QAA0C,SAA1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { TextInputProps } from 'react-native';\n\nexport interface BottomSheetTextInputProps extends TextInputProps {}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
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","head","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 type { 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.head(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,IA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ASvBxD,IATuB,EAA1B;MAUD,CAXD,CAWE,OAAOS,GAAP,EAAY;QACZkD,YAAY,CAAChD,KAAb,GAAqBF,GAArB,CADY,CAEZ;QACA;QACA;QACA;;QACAsB,gBAAgB,GANJ,CAOZ;MACD,CAnBD,SAmBU;QACR3C,MAAM,CAACK,QAAP,CAAgBJ,SAAS,CAACuE,eAA1B,EAA2CD,YAA3C;QACAlE,QAAQ,CAAC;UACPa,IAAI,EAAEvB,UAAU,CAAC0E,uBADV;UAEPjD,OAAO,EAAE;YACPkD,MAAM,EAAE;UADD;QAFF,CAAD,CAAR;MAMD;IACF;EACF;;EAED,MAAMG,WAAW,GAAGrF,MAAM,CAACgB,KAAK,CAACqD,IAAN,CAAWW,IAAZ,CAA1B;EACAlF,SAAS,CAAC,MAAM;IAAA;;IACd;IACA,IACG,sBAACkB,KAAK,CAACqD,IAAN,CAAWW,IAAZ,6CAAC,iBAAiBM,KAAlB,KAA2B,CAACtE,KAAK,CAACqD,IAAN,CAAWW,IAAX,CAAgBO,YAA7C,IACAtF,OAAO,CAACoF,WAAW,CAACR,OAAb,EAAsB7D,KAAK,CAACqD,IAAN,CAAWW,IAAjC,CAFT,EAGE;MACA;IACD;;IACDF,qBAAqB;IACrBO,WAAW,CAACR,OAAZ,GAAsB7D,KAAK,CAACqD,IAAN,CAAWW,IAAjC;EACD,CAVQ,EAUN,CAAC/D,QAAD,EAAW6D,qBAAX,EAAkC9D,KAAK,CAACqD,IAAN,CAAWW,IAA7C,CAVM,CAAT;EAYA,OAAO,IAAP;AACD"}
|
|
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","head","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.head(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,aAAI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AFF,CAAD,CAAR;MAMD;IACF;EACF;;EAED,MAAMG,WAAW,GAAGrF,MAAM,CAACgB,KAAK,CAACqD,IAAN,CAAWW,IAAZ,CAA1B;EACAlF,SAAS,CAAC,MAAM;IAAA;;IACd;IACA,IACG,sBAACkB,KAAK,CAACqD,IAAN,CAAWW,IAAZ,6CAAC,iBAAiBM,KAAlB,KAA2B,CAACtE,KAAK,CAACqD,IAAN,CAAWW,IAAX,CAAgBO,YAA7C,IACAtF,OAAO,CAACoF,WAAW,CAACR,OAAb,EAAsB7D,KAAK,CAACqD,IAAN,CAAWW,IAAjC,CAFT,EAGE;MACA;IACD;;IACDF,qBAAqB;IACrBO,WAAW,CAACR,OAAZ,GAAsB7D,KAAK,CAACqD,IAAN,CAAWW,IAAjC;EACD,CAVQ,EAUN,CAAC/D,QAAD,EAAW6D,qBAAX,EAAkC9D,KAAK,CAACqD,IAAN,CAAWW,IAA7C,CAVM,CAAT;EAYA,OAAO,IAAP;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createContext","useReducer","useContext","isEqual","pick","jwt_decode","storage","events","EventType","ActionType","GlobalContext","undefined","handleStateInit","initialState","contains","state","JSON","parse","getString","GlobalContextProvider","children","config","is_initializing","is_container_visible","use_modal","nav","current_route","route_trigger","event_id","section","options","user","data","email","needs_refresh","redacted","auth","access_token","refresh_token","app_id","app","schema","local_acls","is_saving_user_data","mainReducer","action","decodedToken","newState","type","SET_CONTAINER_VISIBLE","payload","isVisible","CHANGE_ROUTE","route","trigger","opts","SET_SECTION","LOGIN_SUCCESS","id","is_verified_user","app_user_id","SIGN_OUT","REFRESH_TOKEN","LOAD_USER","UPDATE_LOCAL_ACLS","SET_USER_DATA_FIELD","field","value","dispatch","USER_DATA_SAVED","SET_USER_DATA","Object","keys","SET_REFRESH_USER_DATA","LOAD_STATE","SET_IS_SAVING_USER_DATA","saving","SET_APP_CONFIG","persistedState","set","stringify","useGlobalContext","context","Error"],"sources":["GlobalContext.tsx"],"sourcesContent":["import React, { createContext, FunctionComponent } from 'react';\nimport { useReducer, useContext } from 'react';\nimport isEqual from 'lodash-es/isEqual';\nimport pick from 'lodash-es/pick';\nimport jwt_decode from 'jwt-decode';\nimport type { IConfig } from '../utils/config';\nimport storage from '../utils/storage';\nimport { events, EventType } from '../utils/events';\n\nimport { type TAction, ActionType } from '../data/actions';\n\ntype Dispatch = (action: TAction) => void;\n\nexport type GlobalState = {\n is_initializing: boolean;\n is_container_visible: boolean;\n use_modal: boolean;\n nav: {\n current_route: string;\n route_trigger: string;\n event_id: string;\n section: string;\n options?: any;\n };\n user: {\n data: {\n id?: string;\n email: string | null;\n [key: string]: any;\n };\n needs_refresh?: boolean;\n redacted: string[];\n };\n auth: {\n access_token: string | null;\n refresh_token: string | null;\n app_id: string | null;\n init_data?: Record<string, any>;\n is_verified_user?: boolean;\n };\n app: {\n id?: string;\n icon?: string;\n icon_content_type?: string;\n config: AppConfig | null;\n schema: AppSchema | null;\n user_verification_field?: string;\n user_verification_fields?: string[];\n };\n local_acls: Record<string, { shared: boolean }> | null;\n is_saving_user_data: boolean;\n config?: IConfig;\n};\n\ntype AppSchema = Record<string, SchemaField>;\n\nexport interface SchemaField {\n display_name: string;\n type: string;\n data_category: string;\n required: boolean;\n owned_by: string;\n user_visible: boolean;\n revoke_after: string;\n required_retention: string;\n collection_justification: string;\n opt_out_warning: string;\n}\n\ninterface AppConfig {\n customizations: {\n primary_color: string;\n };\n default_user_id_format?: string;\n hub: {\n auth: {\n allow_unverified_users?: boolean;\n additional_fields: [\n {\n name: string;\n type: string;\n label: string;\n placeholder?: string;\n options: [\n {\n value: string;\n label: string;\n }\n ];\n }\n ];\n email: {\n from_address: string;\n image: string;\n };\n show_app_icon: boolean;\n };\n customizations: HubCustomizations;\n };\n}\n\nexport interface HubCustomizations {\n rounded_corners: boolean;\n primary_color: string;\n placement: 'bottom-left' | 'hidden';\n offset_x: number;\n offset_y: number;\n property_overrides: Record<string, string>;\n}\n\ntype ContextProps = {\n config: IConfig;\n};\n\nexport const GlobalContext = createContext<\n { state: GlobalState; dispatch: Dispatch } | undefined\n>(undefined);\n\nfunction handleStateInit(initialState: GlobalState) {\n if (storage.contains('state')) {\n const state = JSON.parse(storage.getString('state') || '{}');\n\n return {\n ...initialState,\n ...state,\n };\n }\n\n return initialState;\n}\n\n// async function updateStorage(newState: any) {\n// const oldState = JSON.parse(await storage.getItem('state') || '{}');\n\n// if (!isEqual(oldState, newState)) {\n// console.log('writing new state', newState);\n// await storage.setItem('state', JSON.stringify(newState));\n// }\n// }\n\nconst GlobalContextProvider: FunctionComponent<ContextProps> = ({\n children,\n config,\n}) => {\n const initialState: GlobalState = {\n is_initializing: false,\n is_container_visible: false,\n use_modal: false,\n nav: {\n current_route: '/',\n route_trigger: '',\n event_id: '',\n section: '',\n options: {},\n },\n user: {\n data: {\n email: null,\n },\n needs_refresh: false,\n redacted: [],\n },\n auth: {\n access_token: null,\n refresh_token: null,\n app_id: null,\n },\n app: {\n schema: null,\n config: null,\n },\n local_acls: null,\n is_saving_user_data: false,\n config,\n };\n\n // TODO: There's a better way to do this where we have a set of rules that watch/apply to the state as it changes\n // function dispatchExternalEvents(prevState: GlobalState, nextState: GlobalState) {\n\n // // Log in, get new token, load previous auth state, etc\n // if (prevState.auth.access_token !== nextState.auth.access_token) {\n // events.dispatch(EventType.AUTH, {\n // access_token: nextState.auth.access_token,\n // user_id: nextState.user.data.id,\n // app_id: nextState.auth.app_id,\n // });\n // }\n\n // // User data changes. Also, fire the event when ACLs change since this affects the data\n // // that the application can see.\n // if (!isEqual(prevState.local_acls, nextState.local_acls) ||\n // !isEqual(prevState.user.data, nextState.user.data)) {\n // events.dispatch(EventType.USER_DATA, {\n // // The data is filtered on the local_acls\n // data: redactUserDataWithAcls(nextState.user.data, nextState.local_acls),\n // });\n // }\n\n // // Log out\n // if (nextState.auth.access_token === null) {\n // events.dispatch(EventType.SIGN_OUT, {});\n // }\n // }\n\n function mainReducer(state: GlobalState, action: TAction): GlobalState {\n let decodedToken: any;\n\n let newState;\n // let cachedAuth;\n switch (action.type) {\n case ActionType.SET_CONTAINER_VISIBLE:\n newState = {\n ...state,\n is_container_visible: action.payload.isVisible,\n use_modal:\n action.payload.isVisible === false ? false : state.use_modal,\n nav: {\n ...state.nav,\n current_route: '/',\n },\n };\n break;\n\n case ActionType.CHANGE_ROUTE:\n newState = {\n ...state,\n nav: {\n ...state.nav,\n current_route: action.payload.route,\n route_trigger: action.payload.trigger || '',\n event_id: action.payload.event_id,\n options: action.payload.opts,\n },\n };\n\n break;\n\n case ActionType.SET_SECTION:\n newState = {\n ...state,\n nav: {\n ...state.nav,\n section: action.payload.section,\n },\n };\n break;\n\n case ActionType.LOGIN_SUCCESS:\n // storage.setItem('auth', JSON.stringify(action.payload));\n decodedToken = jwt_decode(action.payload.access_token);\n\n // Ensure this token is for this app\n if (action.payload.app_id !== state.app.id) {\n return {\n ...state,\n };\n }\n\n newState = {\n ...state,\n auth: {\n ...state.auth,\n access_token: action.payload.access_token,\n refresh_token: action.payload.refresh_token,\n app_id: action.payload.app_id,\n is_verified_user:\n decodedToken?.['https://auth.rownd.io/is_verified_user'] !==\n false, // default is `true` if the attribute doesn't exist\n },\n user: {\n ...state.user,\n data: {\n ...state.user.data,\n id: action.payload.app_user_id,\n },\n },\n };\n break;\n\n case ActionType.SIGN_OUT:\n // storage.removeItem('auth');\n newState = {\n ...state,\n user: {\n data: {\n email: null,\n },\n redacted: [],\n },\n auth: {\n access_token: null,\n refresh_token: null,\n app_id: null,\n },\n };\n break;\n\n case ActionType.REFRESH_TOKEN:\n newState = {\n ...state,\n auth: {\n ...state.auth,\n access_token: action.payload.access_token,\n refresh_token: action.payload.refresh_token,\n },\n };\n\n // cachedAuth = storage.getItem('auth');\n // if (cachedAuth) {\n // const cachedAuthObj = JSON.parse(cachedAuth);\n // cachedAuth = {\n // ...cachedAuthObj,\n // ...newState.auth,\n // };\n // storage.setItem('auth', JSON.stringify(newState.auth));\n // }\n\n break;\n\n case ActionType.LOAD_USER:\n newState = {\n ...state,\n user: {\n ...state.user,\n data: {\n ...action.payload.data,\n },\n redacted: action.payload.redacted,\n },\n };\n break;\n\n case ActionType.UPDATE_LOCAL_ACLS:\n newState = {\n ...state,\n local_acls: {\n ...state.local_acls,\n ...action.payload,\n },\n };\n break;\n\n case ActionType.SET_USER_DATA_FIELD:\n // Dispatch a USER_DATA_SAVED event to satisfy event listeners when the data\n // was not changed and no request to Rownd was ever made.\n if (state.user.data[action.payload.field] === action.payload.value) {\n events.dispatch(EventType.USER_DATA_SAVED, state.user.data);\n }\n\n newState = {\n ...state,\n user: {\n ...state.user,\n data: {\n ...state.user.data,\n [action.payload.field]: action.payload.value,\n },\n },\n };\n break;\n\n case ActionType.SET_USER_DATA:\n // Dispatch a USER_DATA_SAVED event to satisfy event listeners when the data\n // was not changed and no request to Rownd was ever made.\n if (\n isEqual(\n pick(state.user.data, Object.keys(action.payload.data)),\n action.payload.data\n )\n ) {\n events.dispatch(EventType.USER_DATA_SAVED, state.user.data);\n }\n\n newState = {\n ...state,\n user: {\n ...state.user,\n data: {\n ...state.user.data,\n ...action.payload.data,\n },\n },\n };\n break;\n\n case ActionType.SET_REFRESH_USER_DATA:\n newState = {\n ...state,\n user: {\n ...state.user,\n needs_refresh: action.payload.needs_refresh,\n },\n };\n break;\n\n case ActionType.LOAD_STATE:\n newState = {\n ...action.payload,\n };\n break;\n\n case ActionType.SET_IS_SAVING_USER_DATA: {\n newState = {\n ...state,\n is_saving_user_data: action.payload.saving,\n };\n break;\n }\n\n case ActionType.SET_APP_CONFIG:\n newState = {\n ...state,\n app: {\n ...state.app,\n ...action.payload,\n },\n };\n break;\n\n default:\n newState = state;\n }\n\n // Write state to local storage, minus a few fields\n const persistedState: any = { ...newState };\n delete persistedState.config;\n delete persistedState.nav;\n delete persistedState.is_container_visible;\n delete persistedState.use_modal;\n delete persistedState.is_initializing;\n delete persistedState.is_saving_user_data;\n\n // updateStorage(persistedState);\n storage.set('state', JSON.stringify(persistedState));\n\n // Fire any events that depend on state updates\n // dispatchExternalEvents(state, newState);\n\n return newState;\n }\n\n const [state, dispatch] = useReducer(\n mainReducer,\n initialState,\n handleStateInit\n );\n\n // Async load cached state from storage\n // useEffect(() => {\n // (async () => {\n // const existingStateStr = await storage.getItem('state');\n\n // if (!existingStateStr) {\n // return;\n // }\n\n // dispatch({\n // type: ActionType.LOAD_STATE,\n // payload: JSON.parse(existingStateStr),\n // });\n // });\n // }, []);\n\n const value = { state, dispatch };\n return (\n <GlobalContext.Provider value={value}>\n {children}\n {/* <ExternalApi config={config} dispatchEvents={(state: GlobalState) => dispatchExternalEvents(initialState, state)} /> */}\n </GlobalContext.Provider>\n );\n};\n\nfunction useGlobalContext() {\n const context = useContext(GlobalContext);\n\n if (context === undefined) {\n throw new Error(\n 'useGlobalContext must be used within a GlobalContext Provider'\n );\n }\n\n return context;\n}\n\nexport { GlobalContextProvider, useGlobalContext };\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAwD,OAAxD;AACA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,OAAvC;AACA,OAAOC,OAAP,MAAoB,mBAApB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,OAAOC,OAAP,MAAoB,kBAApB;AACA,SAASC,MAAT,EAAiBC,SAAjB,QAAkC,iBAAlC;AAEA,SAAuBC,UAAvB,QAAyC,iBAAzC;AAyGA,OAAO,MAAMC,aAAa,gBAAGV,aAAa,CAExCW,SAFwC,CAAnC;;AAIP,SAASC,eAAT,CAAyBC,YAAzB,EAAoD;EAClD,IAAIP,OAAO,CAACQ,QAAR,CAAiB,OAAjB,CAAJ,EAA+B;IAC7B,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAWX,OAAO,CAACY,SAAR,CAAkB,OAAlB,KAA8B,IAAzC,CAAd;IAEA,OAAO,EACL,GAAGL,YADE;MAEL,GAAGE;IAFE,CAAP;EAID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CAApC,CA1SI,CAgTJ;EACA;EACA;EACA;EAEA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;;EAEA,MAAMuD,KAAK,GAAG;IAAEpD,KAAF;IAASqD;EAAT,CAAd;EACA,oBACE,oBAAC,aAAD,CAAe,QAAf;IAAwB,KAAK,EAAED;EAA/B,GACG/C,QADH,CADF;AAMD,CA1UD;;AA4UA,SAAS6D,gBAAT,GAA4B;EAC1B,MAAMC,OAAO,GAAGhF,UAAU,CAACQ,aAAD,CAA1B;;EAEA,IAAIwE,OAAO,KAAKvE,SAAhB,EAA2B;IACzB,MAAM,IAAIwE,KAAJ,CACJ,+DADI,CAAN;EAGD;;EAED,OAAOD,OAAP;AACD;;AAED,SAAS/D,qBAAT,EAAgC8D,gBAAhC"}
|
|
1
|
+
{"version":3,"names":["React","createContext","useReducer","useContext","isEqual","pick","jwt_decode","storage","events","EventType","ActionType","GlobalContext","undefined","handleStateInit","initialState","contains","state","JSON","parse","getString","GlobalContextProvider","children","config","is_initializing","is_container_visible","use_modal","nav","current_route","route_trigger","event_id","section","options","user","data","email","needs_refresh","redacted","auth","access_token","refresh_token","app_id","app","schema","local_acls","is_saving_user_data","mainReducer","action","decodedToken","newState","type","SET_CONTAINER_VISIBLE","payload","isVisible","CHANGE_ROUTE","route","trigger","opts","SET_SECTION","LOGIN_SUCCESS","id","is_verified_user","app_user_id","SIGN_OUT","REFRESH_TOKEN","LOAD_USER","UPDATE_LOCAL_ACLS","SET_USER_DATA_FIELD","field","value","dispatch","USER_DATA_SAVED","SET_USER_DATA","Object","keys","SET_REFRESH_USER_DATA","LOAD_STATE","SET_IS_SAVING_USER_DATA","saving","SET_APP_CONFIG","persistedState","set","stringify","useGlobalContext","context","Error"],"sources":["GlobalContext.tsx"],"sourcesContent":["import React, { createContext, FunctionComponent } from 'react';\nimport { useReducer, useContext } from 'react';\nimport isEqual from 'lodash-es/isEqual';\nimport pick from 'lodash-es/pick';\nimport jwt_decode from 'jwt-decode';\nimport { IConfig } from '../utils/config';\nimport storage from '../utils/storage';\nimport { events, EventType } from '../utils/events';\n\nimport { TAction, ActionType } from '../data/actions';\n\ntype Dispatch = (action: TAction) => void;\n\nexport type GlobalState = {\n is_initializing: boolean;\n is_container_visible: boolean;\n use_modal: boolean;\n nav: {\n current_route: string;\n route_trigger: string;\n event_id: string;\n section: string;\n options?: any;\n };\n user: {\n data: {\n id?: string;\n email: string | null;\n [key: string]: any;\n };\n needs_refresh?: boolean;\n redacted: string[];\n };\n auth: {\n access_token: string | null;\n refresh_token: string | null;\n app_id: string | null;\n init_data?: Record<string, any>;\n is_verified_user?: boolean;\n };\n app: {\n id?: string;\n icon?: string;\n icon_content_type?: string;\n config: AppConfig | null;\n schema: AppSchema | null;\n user_verification_field?: string;\n user_verification_fields?: string[];\n };\n local_acls: Record<string, { shared: boolean }> | null;\n is_saving_user_data: boolean;\n config?: IConfig;\n};\n\ntype AppSchema = Record<string, SchemaField>;\n\nexport interface SchemaField {\n display_name: string;\n type: string;\n data_category: string;\n required: boolean;\n owned_by: string;\n user_visible: boolean;\n revoke_after: string;\n required_retention: string;\n collection_justification: string;\n opt_out_warning: string;\n}\n\ninterface AppConfig {\n customizations: {\n primary_color: string;\n };\n default_user_id_format?: string;\n hub: {\n auth: {\n allow_unverified_users?: boolean;\n additional_fields: [\n {\n name: string;\n type: string;\n label: string;\n placeholder?: string;\n options: [\n {\n value: string;\n label: string;\n }\n ];\n }\n ];\n email: {\n from_address: string;\n image: string;\n };\n show_app_icon: boolean;\n };\n customizations: HubCustomizations;\n };\n}\n\nexport interface HubCustomizations {\n rounded_corners: boolean;\n primary_color: string;\n placement: 'bottom-left' | 'hidden';\n offset_x: number;\n offset_y: number;\n property_overrides: Record<string, string>;\n}\n\ntype ContextProps = {\n config: IConfig;\n};\n\nexport const GlobalContext = createContext<\n { state: GlobalState; dispatch: Dispatch } | undefined\n>(undefined);\n\nfunction handleStateInit(initialState: GlobalState) {\n if (storage.contains('state')) {\n const state = JSON.parse(storage.getString('state') || '{}');\n\n return {\n ...initialState,\n ...state,\n };\n }\n\n return initialState;\n}\n\n// async function updateStorage(newState: any) {\n// const oldState = JSON.parse(await storage.getItem('state') || '{}');\n\n// if (!isEqual(oldState, newState)) {\n// console.log('writing new state', newState);\n// await storage.setItem('state', JSON.stringify(newState));\n// }\n// }\n\nconst GlobalContextProvider: FunctionComponent<ContextProps> = ({\n children,\n config,\n}) => {\n const initialState: GlobalState = {\n is_initializing: false,\n is_container_visible: false,\n use_modal: false,\n nav: {\n current_route: '/',\n route_trigger: '',\n event_id: '',\n section: '',\n options: {},\n },\n user: {\n data: {\n email: null,\n },\n needs_refresh: false,\n redacted: [],\n },\n auth: {\n access_token: null,\n refresh_token: null,\n app_id: null,\n },\n app: {\n schema: null,\n config: null,\n },\n local_acls: null,\n is_saving_user_data: false,\n config,\n };\n\n // TODO: There's a better way to do this where we have a set of rules that watch/apply to the state as it changes\n // function dispatchExternalEvents(prevState: GlobalState, nextState: GlobalState) {\n\n // // Log in, get new token, load previous auth state, etc\n // if (prevState.auth.access_token !== nextState.auth.access_token) {\n // events.dispatch(EventType.AUTH, {\n // access_token: nextState.auth.access_token,\n // user_id: nextState.user.data.id,\n // app_id: nextState.auth.app_id,\n // });\n // }\n\n // // User data changes. Also, fire the event when ACLs change since this affects the data\n // // that the application can see.\n // if (!isEqual(prevState.local_acls, nextState.local_acls) ||\n // !isEqual(prevState.user.data, nextState.user.data)) {\n // events.dispatch(EventType.USER_DATA, {\n // // The data is filtered on the local_acls\n // data: redactUserDataWithAcls(nextState.user.data, nextState.local_acls),\n // });\n // }\n\n // // Log out\n // if (nextState.auth.access_token === null) {\n // events.dispatch(EventType.SIGN_OUT, {});\n // }\n // }\n\n function mainReducer(state: GlobalState, action: TAction): GlobalState {\n let decodedToken: any;\n\n let newState;\n // let cachedAuth;\n switch (action.type) {\n case ActionType.SET_CONTAINER_VISIBLE:\n newState = {\n ...state,\n is_container_visible: action.payload.isVisible,\n use_modal:\n action.payload.isVisible === false ? false : state.use_modal,\n nav: {\n ...state.nav,\n current_route: '/',\n },\n };\n break;\n\n case ActionType.CHANGE_ROUTE:\n newState = {\n ...state,\n nav: {\n ...state.nav,\n current_route: action.payload.route,\n route_trigger: action.payload.trigger || '',\n event_id: action.payload.event_id,\n options: action.payload.opts,\n },\n };\n\n break;\n\n case ActionType.SET_SECTION:\n newState = {\n ...state,\n nav: {\n ...state.nav,\n section: action.payload.section,\n },\n };\n break;\n\n case ActionType.LOGIN_SUCCESS:\n // storage.setItem('auth', JSON.stringify(action.payload));\n decodedToken = jwt_decode(action.payload.access_token);\n\n // Ensure this token is for this app\n if (action.payload.app_id !== state.app.id) {\n return {\n ...state,\n };\n }\n\n newState = {\n ...state,\n auth: {\n ...state.auth,\n access_token: action.payload.access_token,\n refresh_token: action.payload.refresh_token,\n app_id: action.payload.app_id,\n is_verified_user:\n decodedToken?.['https://auth.rownd.io/is_verified_user'] !==\n false, // default is `true` if the attribute doesn't exist\n },\n user: {\n ...state.user,\n data: {\n ...state.user.data,\n id: action.payload.app_user_id,\n },\n },\n };\n break;\n\n case ActionType.SIGN_OUT:\n // storage.removeItem('auth');\n newState = {\n ...state,\n user: {\n data: {\n email: null,\n },\n redacted: [],\n },\n auth: {\n access_token: null,\n refresh_token: null,\n app_id: null,\n },\n };\n break;\n\n case ActionType.REFRESH_TOKEN:\n newState = {\n ...state,\n auth: {\n ...state.auth,\n access_token: action.payload.access_token,\n refresh_token: action.payload.refresh_token,\n },\n };\n\n // cachedAuth = storage.getItem('auth');\n // if (cachedAuth) {\n // const cachedAuthObj = JSON.parse(cachedAuth);\n // cachedAuth = {\n // ...cachedAuthObj,\n // ...newState.auth,\n // };\n // storage.setItem('auth', JSON.stringify(newState.auth));\n // }\n\n break;\n\n case ActionType.LOAD_USER:\n newState = {\n ...state,\n user: {\n ...state.user,\n data: {\n ...action.payload.data,\n },\n redacted: action.payload.redacted,\n },\n };\n break;\n\n case ActionType.UPDATE_LOCAL_ACLS:\n newState = {\n ...state,\n local_acls: {\n ...state.local_acls,\n ...action.payload,\n },\n };\n break;\n\n case ActionType.SET_USER_DATA_FIELD:\n // Dispatch a USER_DATA_SAVED event to satisfy event listeners when the data\n // was not changed and no request to Rownd was ever made.\n if (state.user.data[action.payload.field] === action.payload.value) {\n events.dispatch(EventType.USER_DATA_SAVED, state.user.data);\n }\n\n newState = {\n ...state,\n user: {\n ...state.user,\n data: {\n ...state.user.data,\n [action.payload.field]: action.payload.value,\n },\n },\n };\n break;\n\n case ActionType.SET_USER_DATA:\n // Dispatch a USER_DATA_SAVED event to satisfy event listeners when the data\n // was not changed and no request to Rownd was ever made.\n if (\n isEqual(\n pick(state.user.data, Object.keys(action.payload.data)),\n action.payload.data\n )\n ) {\n events.dispatch(EventType.USER_DATA_SAVED, state.user.data);\n }\n\n newState = {\n ...state,\n user: {\n ...state.user,\n data: {\n ...state.user.data,\n ...action.payload.data,\n },\n },\n };\n break;\n\n case ActionType.SET_REFRESH_USER_DATA:\n newState = {\n ...state,\n user: {\n ...state.user,\n needs_refresh: action.payload.needs_refresh,\n },\n };\n break;\n\n case ActionType.LOAD_STATE:\n newState = {\n ...action.payload,\n };\n break;\n\n case ActionType.SET_IS_SAVING_USER_DATA: {\n newState = {\n ...state,\n is_saving_user_data: action.payload.saving,\n };\n break;\n }\n\n case ActionType.SET_APP_CONFIG:\n newState = {\n ...state,\n app: {\n ...state.app,\n ...action.payload,\n },\n };\n break;\n\n default:\n newState = state;\n }\n\n // Write state to local storage, minus a few fields\n const persistedState: any = { ...newState };\n delete persistedState.config;\n delete persistedState.nav;\n delete persistedState.is_container_visible;\n delete persistedState.use_modal;\n delete persistedState.is_initializing;\n delete persistedState.is_saving_user_data;\n\n // updateStorage(persistedState);\n storage.set('state', JSON.stringify(persistedState));\n\n // Fire any events that depend on state updates\n // dispatchExternalEvents(state, newState);\n\n return newState;\n }\n\n const [state, dispatch] = useReducer(\n mainReducer,\n initialState,\n handleStateInit\n );\n\n // Async load cached state from storage\n // useEffect(() => {\n // (async () => {\n // const existingStateStr = await storage.getItem('state');\n\n // if (!existingStateStr) {\n // return;\n // }\n\n // dispatch({\n // type: ActionType.LOAD_STATE,\n // payload: JSON.parse(existingStateStr),\n // });\n // });\n // }, []);\n\n const value = { state, dispatch };\n return (\n <GlobalContext.Provider value={value}>\n {children}\n {/* <ExternalApi config={config} dispatchEvents={(state: GlobalState) => dispatchExternalEvents(initialState, state)} /> */}\n </GlobalContext.Provider>\n );\n};\n\nfunction useGlobalContext() {\n const context = useContext(GlobalContext);\n\n if (context === undefined) {\n throw new Error(\n 'useGlobalContext must be used within a GlobalContext Provider'\n );\n }\n\n return context;\n}\n\nexport { GlobalContextProvider, useGlobalContext };\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAwD,OAAxD;AACA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,OAAvC;AACA,OAAOC,OAAP,MAAoB,mBAApB;AACA,OAAOC,IAAP,MAAiB,gBAAjB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,OAAOC,OAAP,MAAoB,kBAApB;AACA,SAASC,MAAT,EAAiBC,SAAjB,QAAkC,iBAAlC;AAEA,SAAkBC,UAAlB,QAAoC,iBAApC;AAyGA,OAAO,MAAMC,aAAa,gBAAGV,aAAa,CAExCW,SAFwC,CAAnC;;AAIP,SAASC,eAAT,CAAyBC,YAAzB,EAAoD;EAClD,IAAIP,OAAO,CAACQ,QAAR,CAAiB,OAAjB,CAAJ,EAA+B;IAC7B,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAWX,OAAO,CAACY,SAAR,CAAkB,OAAlB,KAA8B,IAAzC,CAAd;IAEA,OAAO,EACL,GAAGL,YADE;MAEL,GAAGE;IAFE,CAAP;EAID;;EAED,OAAOF,YAAP;AACD,C,CAED;AACA;AAEA;AACA;AACA;AACA;AACA;;;AAEA,MAAMM,qBAAsD,GAAG,QAGzD;EAAA,IAH0D;IAC9DC,QAD8D;IAE9DC;EAF8D,CAG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oBACE,oBAAC,aAAD,CAAe,QAAf;IAAwB,KAAK,EAAED;EAA/B,GACG/C,QADH,CADF;AAMD,CA1UD;;AA4UA,SAAS6D,gBAAT,GAA4B;EAC1B,MAAMC,OAAO,GAAGhF,UAAU,CAACQ,aAAD,CAA1B;;EAEA,IAAIwE,OAAO,KAAKvE,SAAhB,EAA2B;IACzB,MAAM,IAAIwE,KAAJ,CACJ,+DADI,CAAN;EAGD;;EAED,OAAOD,OAAP;AACD;;AAED,SAAS/D,qBAAT,EAAgC8D,gBAAhC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import React from 'react'; // import { useDeviceContext } from 'twrnc';
|
|
2
|
+
// import tw from '../utils/tailwind';
|
|
3
|
+
|
|
4
4
|
import { SignIn } from './SignIn';
|
|
5
5
|
import { AutoSigninDialog } from './AutoSigninDialog';
|
|
6
6
|
import { useGlobalContext } from './GlobalContext';
|
|
7
7
|
export function RowndComponents() {
|
|
8
8
|
const {
|
|
9
9
|
state
|
|
10
|
-
} = useGlobalContext();
|
|
11
|
-
|
|
10
|
+
} = useGlobalContext(); // useDeviceContext(tw);
|
|
11
|
+
|
|
12
12
|
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));
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=RowndComponents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","SignIn","AutoSigninDialog","useGlobalContext","RowndComponents","state","nav","current_route"],"sources":["RowndComponents.tsx"],"sourcesContent":["import React from 'react';\n// import { useDeviceContext } from 'twrnc';\n\n// import tw from '../utils/tailwind';\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,C,CACA;AAEA;;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"}
|
|
@@ -2,13 +2,15 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
|
|
3
3
|
import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
|
4
4
|
import { differenceInMinutes } from 'date-fns';
|
|
5
|
-
import { View, StyleSheet,
|
|
6
|
-
|
|
5
|
+
import { View, StyleSheet, TouchableOpacity, Image, ActivityIndicator, Linking, Text } from 'react-native'; // import Text from './DarkText';
|
|
6
|
+
|
|
7
7
|
import { SvgCssUri } from 'react-native-svg';
|
|
8
8
|
import tw from '../utils/tailwind';
|
|
9
9
|
import phone from 'phone';
|
|
10
10
|
import jwt_decode from 'jwt-decode';
|
|
11
|
-
import { BottomSheetBackdrop, BottomSheetModal
|
|
11
|
+
import { BottomSheetBackdrop, BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
12
|
+
import BottomSheetTextInput from './BottomSheetTextInput';
|
|
13
|
+
import bottomSheetMeta from '@gorhom/bottom-sheet/package.json';
|
|
12
14
|
import { useApi, useInterval, useNav, useDeviceFingerprint } from '../hooks';
|
|
13
15
|
import { useGlobalContext } from './GlobalContext';
|
|
14
16
|
import { ActionType } from '../data/actions';
|
|
@@ -372,17 +374,24 @@ export function SignIn() {
|
|
|
372
374
|
const renderBackdrop = useCallback(cbProps => /*#__PURE__*/React.createElement(BottomSheetBackdrop, _extends({}, cbProps, {
|
|
373
375
|
pressBehavior: "close"
|
|
374
376
|
})), []);
|
|
375
|
-
|
|
377
|
+
let extraBottomSheetProps = {};
|
|
378
|
+
|
|
379
|
+
if (bottomSheetMeta.version.startsWith('4')) {
|
|
380
|
+
var _state$nav, _state$nav$options;
|
|
381
|
+
|
|
382
|
+
extraBottomSheetProps.keyboardBehavior = 'fillParent';
|
|
383
|
+
extraBottomSheetProps.android_keyboardInputMode = 'adjustResize';
|
|
384
|
+
extraBottomSheetProps.enablePanDownToClose = (state === null || state === void 0 ? void 0 : (_state$nav = state.nav) === null || _state$nav === void 0 ? void 0 : (_state$nav$options = _state$nav.options) === null || _state$nav$options === void 0 ? void 0 : _state$nav$options.type) === 'error';
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return /*#__PURE__*/React.createElement(BottomSheetModal, _extends({
|
|
376
388
|
snapPoints: snapPoints,
|
|
377
389
|
index: 1,
|
|
378
390
|
backdropComponent: renderBackdrop,
|
|
379
|
-
keyboardBehavior: "fillParent",
|
|
380
|
-
android_keyboardInputMode: "adjustResize",
|
|
381
|
-
enablePanDownToClose: true,
|
|
382
391
|
onDismiss: handleClose,
|
|
383
392
|
style: styles.bottomSheet,
|
|
384
393
|
ref: bottomSheetModalRef
|
|
385
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
394
|
+
}, extraBottomSheetProps), /*#__PURE__*/React.createElement(View, {
|
|
386
395
|
style: styles.innerContainer
|
|
387
396
|
}, step === LoginStep.INIT && /*#__PURE__*/React.createElement(React.Fragment, null, (app === null || app === void 0 ? void 0 : (_app$config6 = app.config) === null || _app$config6 === void 0 ? void 0 : (_app$config6$hub = _app$config6.hub) === null || _app$config6$hub === void 0 ? void 0 : (_app$config6$hub$auth = _app$config6$hub.auth) === null || _app$config6$hub$auth === void 0 ? void 0 : _app$config6$hub$auth.show_app_icon) && (app === null || app === void 0 ? void 0 : app.icon) && (app.icon_content_type === 'image/svg+xml' ? /*#__PURE__*/React.createElement(SvgCssUri, {
|
|
388
397
|
uri: app.icon,
|
|
@@ -414,25 +423,25 @@ export function SignIn() {
|
|
|
414
423
|
value: addlFieldValues[field.name] || '',
|
|
415
424
|
[['input', 'text', 'tel', 'email'].includes(field.type) ? 'onInput' : 'onChange']: handleAddlFieldChange
|
|
416
425
|
});
|
|
417
|
-
})), /*#__PURE__*/React.createElement(
|
|
418
|
-
style: _ref => {
|
|
419
|
-
let {
|
|
420
|
-
pressed
|
|
421
|
-
} = _ref;
|
|
422
|
-
return [styles.button, !isValidUserIdentifier && styles.buttonDisabled, pressed && styles.buttonPressed, isSubmitting && styles.buttonSubmitting];
|
|
423
|
-
},
|
|
426
|
+
})), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
424
427
|
disabled: !isValidUserIdentifier || isSubmitting,
|
|
425
428
|
onPress: initSignIn
|
|
426
|
-
}, /*#__PURE__*/React.createElement(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
429
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
430
|
+
style: { ...styles.button,
|
|
431
|
+
...(!isValidUserIdentifier && styles.buttonDisabled),
|
|
432
|
+
...(isSubmitting && styles.buttonSubmitting)
|
|
433
|
+
}
|
|
434
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
430
435
|
style: styles.buttonText
|
|
431
436
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
432
437
|
style: isValidUserIdentifier ? styles.buttonContent : { ...styles.buttonContent,
|
|
433
438
|
...styles.buttonDisabledText
|
|
434
439
|
}
|
|
435
|
-
}, isSubmitting
|
|
440
|
+
}, isSubmitting && /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
441
|
+
size: "small",
|
|
442
|
+
color: "#efefef",
|
|
443
|
+
style: styles.loadingIndicator
|
|
444
|
+
}), isSubmitting ? 'Just a sec...' : 'Continue')))), /*#__PURE__*/React.createElement(Text, {
|
|
436
445
|
style: styles.signInNoticeText
|
|
437
446
|
}, "By continuing, you're agreeing to the terms of service that govern this app and to receive email or text messages for verification purposes.")), step === LoginStep.WAITING && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
|
438
447
|
style: styles.dialogHeading
|
|
@@ -445,13 +454,8 @@ export function SignIn() {
|
|
|
445
454
|
onPress: () => setStep(LoginStep.INIT)
|
|
446
455
|
}, "\xA0Re-send message")), /*#__PURE__*/React.createElement(View, {
|
|
447
456
|
style: styles.signInVerificationImage
|
|
448
|
-
}, loginType === 'phone' ? /*#__PURE__*/React.createElement(ImagePhoneVerifyWaiting, null) : /*#__PURE__*/React.createElement(ImageEmailVerifyWaiting, null)), /*#__PURE__*/React.createElement(
|
|
449
|
-
style:
|
|
450
|
-
let {
|
|
451
|
-
pressed
|
|
452
|
-
} = _ref2;
|
|
453
|
-
return [styles.button, pressed && styles.buttonPressed];
|
|
454
|
-
},
|
|
457
|
+
}, loginType === 'phone' ? /*#__PURE__*/React.createElement(ImagePhoneVerifyWaiting, null) : /*#__PURE__*/React.createElement(ImageEmailVerifyWaiting, null)), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
458
|
+
style: [styles.button],
|
|
455
459
|
onPress: () => setStep(LoginStep.INIT)
|
|
456
460
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
457
461
|
style: styles.buttonContent
|
|
@@ -459,7 +463,7 @@ export function SignIn() {
|
|
|
459
463
|
style: styles.signInVerificationImage
|
|
460
464
|
}, /*#__PURE__*/React.createElement(ImageCheckmarkFilled, null))), step === LoginStep.FAILURE && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
|
461
465
|
style: tw.style('text-base')
|
|
462
|
-
}, "Whoops, that didn't work!"), /*#__PURE__*/React.createElement(
|
|
466
|
+
}, "Whoops, that didn't work!"), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
463
467
|
style: styles.button,
|
|
464
468
|
onPress: () => setStep(LoginStep.INIT)
|
|
465
469
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
@@ -468,7 +472,7 @@ export function SignIn() {
|
|
|
468
472
|
style: tw.style('text-base')
|
|
469
473
|
}, "An error occurred while signing you in."), !!error && /*#__PURE__*/React.createElement(Text, {
|
|
470
474
|
style: tw.style('text-rose-800')
|
|
471
|
-
}, error), /*#__PURE__*/React.createElement(
|
|
475
|
+
}, error), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
472
476
|
style: styles.button,
|
|
473
477
|
onPress: () => setStep(LoginStep.INIT)
|
|
474
478
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
@@ -544,9 +548,11 @@ const styles = StyleSheet.create({
|
|
|
544
548
|
marginBottom: 30,
|
|
545
549
|
elevation: 0,
|
|
546
550
|
backgroundColor: '#5b0ae0',
|
|
551
|
+
color: '#fff',
|
|
547
552
|
display: 'flex',
|
|
548
553
|
alignItems: 'center',
|
|
549
|
-
justifyContent: 'center'
|
|
554
|
+
justifyContent: 'center' // height: 45,
|
|
555
|
+
|
|
550
556
|
},
|
|
551
557
|
buttonDisabled: {
|
|
552
558
|
backgroundColor: '#eee'
|
|
@@ -559,10 +565,10 @@ const styles = StyleSheet.create({
|
|
|
559
565
|
fontSize: 18,
|
|
560
566
|
color: '#fff'
|
|
561
567
|
},
|
|
562
|
-
buttonText: {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
568
|
+
buttonText: {// marginHorizontal: 10,
|
|
569
|
+
// paddingHorizontal: 10,
|
|
570
|
+
// fontSize: 18,
|
|
571
|
+
// color: '#fff',
|
|
566
572
|
},
|
|
567
573
|
buttonTextInner: {
|
|
568
574
|
fontSize: 18
|
|
@@ -575,9 +581,7 @@ const styles = StyleSheet.create({
|
|
|
575
581
|
color: '#c7c7c7'
|
|
576
582
|
},
|
|
577
583
|
loadingIndicator: {
|
|
578
|
-
|
|
579
|
-
padding: 20,
|
|
580
|
-
margin: 20
|
|
584
|
+
marginRight: 10
|
|
581
585
|
},
|
|
582
586
|
signInNoticeText: {
|
|
583
587
|
fontSize: 12,
|