react-native-okhi 1.2.2 → 1.2.3-beta.2

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.
@@ -1 +1 @@
1
- {"version":3,"names":["React","useState","useEffect","useRef","Modal","SafeAreaView","Platform","WebView","Spinner","getFrameUrl","generateJavaScriptStartScript","generateStartDataPayload","parseOkHiLocation","OkHiException","OkHiAuth","start","sv","getApplicationConfiguration","openProtectedAppsSettings","OkHiNativeModule","OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","startPayload","setStartPaylaod","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","webViewRef","startMessage","mode","phone","then","config","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","auth","anonymousSignInWithPhoneNumber","catch","error","OS","Version","setItem","JSON","stringify","payload","url","console","handleOnMessage","nativeEvent","data","response","parse","UNKNOWN_ERROR_CODE","toString","fcmPushNotificationToken","location","startVerification","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","lat","lon","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","handleModalRequestClose","current","goBack","renderContent","jsAfterLoad","jsBeforeLoad","uri","undefined"],"sources":["OkHiLocationManager.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\nimport { Modal, SafeAreaView, Platform } from 'react-native';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport { Spinner } from './Spinner';\nimport type {\n OkHiLocationManagerResponse,\n OkHiLocationManagerProps,\n OkHiLocationManagerStartDataPayload,\n} from './types';\nimport {\n getFrameUrl,\n generateJavaScriptStartScript,\n generateStartDataPayload,\n parseOkHiLocation,\n} from './Util';\nimport { OkHiException } from '../OkCore/OkHiException';\nimport { OkHiAuth } from '../OkCore/OkHiAuth';\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { start as sv } from '../OkVerify';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\nimport {\n getApplicationConfiguration,\n openProtectedAppsSettings,\n} from '../OkCore';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\n\n/**\n * The OkHiLocationManager React Component is used to display an in app modal, enabling the user to quickly create an accurate OkHi address.\n */\nexport const OkHiLocationManager = (props: OkHiLocationManagerProps) => {\n const [token, setToken] = useState<string | null>(null);\n const [applicationConfiguration, setApplicationConfiguration] =\n useState<AuthApplicationConfig | null>(null);\n const [startPayload, setStartPaylaod] =\n useState<null | OkHiLocationManagerStartDataPayload>(null);\n const defaultStyle = { flex: 1 };\n const style = props.style\n ? { ...props.style, ...defaultStyle }\n : defaultStyle;\n\n const { user, onSuccess, onCloseRequest, onError, loader, launch } = props;\n const webViewRef = useRef<WebView | null>(null);\n const startMessage =\n props.mode === 'create' ? 'start_app' : 'select_location';\n\n useEffect(() => {\n if (applicationConfiguration == null && token == null && user.phone) {\n getApplicationConfiguration()\n .then((config) => {\n if (!config && launch) {\n onError(\n new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n })\n );\n } else if (config) {\n setApplicationConfiguration(config);\n const auth = new OkHiAuth();\n auth\n .anonymousSignInWithPhoneNumber(user.phone, ['verify'], config)\n .then(setToken)\n .catch(onError);\n }\n })\n .catch((error) => {\n if (launch) {\n onError(error);\n }\n });\n }\n }, [onError, user.phone, launch, applicationConfiguration, token]);\n\n useEffect(() => {\n if (token !== null && applicationConfiguration !== null) {\n // TODO: handle faliure\n generateStartDataPayload(props, token, applicationConfiguration)\n .then((startPayload) => {\n setStartPaylaod(startPayload);\n if (Platform.OS === 'android' && Platform.Version > 25) {\n OkHiNativeModule.setItem(\n 'okcollect-launch-payload',\n JSON.stringify({\n message: startMessage,\n payload: startPayload,\n url: getFrameUrl(applicationConfiguration),\n })\n ).catch(console.error);\n }\n })\n .catch(console.error);\n }\n }, [applicationConfiguration, props, token]);\n\n const handleOnMessage = ({ nativeEvent: { data } }: WebViewMessageEvent) => {\n try {\n const response: OkHiLocationManagerResponse = JSON.parse(data);\n if (response.message === 'fatal_exit') {\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: response.payload.toString(),\n })\n );\n } else if (response.message === 'exit_app') {\n onCloseRequest();\n } else if (response.message === 'request_enable_protected_apps') {\n openProtectedAppsSettings();\n } else {\n onSuccess({\n user: {\n ...response.payload.user,\n fcmPushNotificationToken: user.fcmPushNotificationToken,\n },\n location: parseOkHiLocation(response.payload.location),\n startVerification: function (config?: OkVerifyStartConfiguration) {\n const createdUser = { ...this.user };\n const location = { ...this.location };\n return new Promise((resolve, reject) => {\n if (!location.id) {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n } else {\n sv(\n createdUser.phone,\n location.id,\n location.lat,\n location.lon,\n config,\n createdUser.fcmPushNotificationToken\n )\n .then(resolve)\n .catch(reject);\n }\n });\n },\n });\n }\n } catch (error) {\n let errorMessage = 'Something went wrong';\n if (error instanceof Error) {\n errorMessage = error.message;\n }\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: errorMessage,\n })\n );\n }\n };\n\n const handleOnError = () => {\n onError(\n new OkHiException({\n code: OkHiException.NETWORK_ERROR_CODE,\n message: OkHiException.NETWORK_ERROR_MESSAGE,\n })\n );\n };\n\n const handleModalRequestClose = () => {\n webViewRef.current?.goBack();\n };\n\n const renderContent = () => {\n if (token === null || applicationConfiguration == null) {\n return loader || <Spinner />;\n }\n\n if (startPayload === null) {\n return loader || <Spinner />;\n }\n\n const { jsAfterLoad, jsBeforeLoad } = generateJavaScriptStartScript({\n message: startMessage,\n payload: startPayload,\n });\n\n return (\n <SafeAreaView style={style}>\n <WebView\n source={{ uri: getFrameUrl(applicationConfiguration) }}\n injectedJavaScriptBeforeContentLoaded={\n Platform.OS === 'ios' ? jsBeforeLoad : undefined\n }\n injectedJavaScript={Platform.OS === 'ios' ? undefined : jsAfterLoad}\n onMessage={handleOnMessage}\n onError={handleOnError}\n onHttpError={handleOnError}\n geolocationEnabled={true}\n allowsBackForwardNavigationGestures={true}\n ref={webViewRef}\n />\n </SafeAreaView>\n );\n };\n\n return (\n <Modal\n animationType=\"slide\"\n transparent={false}\n visible={launch}\n onRequestClose={handleModalRequestClose}\n >\n {launch ? renderContent() : null}\n </Modal>\n );\n};\n\nexport default OkHiLocationManager;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,KAAT,EAAgBC,YAAhB,EAA8BC,QAA9B,QAA8C,cAA9C;AACA,SAASC,OAAT,QAA6C,sBAA7C;AACA,SAASC,OAAT,QAAwB,WAAxB;AAMA,SACEC,WADF,EAEEC,6BAFF,EAGEC,wBAHF,EAIEC,iBAJF,QAKO,QALP;AAMA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA,SAASC,KAAK,IAAIC,EAAlB,QAA4B,aAA5B;AAEA,SACEC,2BADF,EAEEC,yBAFF,QAGO,WAHP;AAIA,SAASC,gBAAT,QAAiC,qBAAjC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBtB,QAAQ,CAAgB,IAAhB,CAAlC;EACA,MAAM,CAACuB,wBAAD,EAA2BC,2BAA3B,IACJxB,QAAQ,CAA+B,IAA/B,CADV;EAEA,MAAM,CAACyB,YAAD,EAAeC,eAAf,IACJ1B,QAAQ,CAA6C,IAA7C,CADV;EAEA,MAAM2B,YAAY,GAAG;IAAEC,IAAI,EAAE;EAAR,CAArB;EACA,MAAMC,KAAK,GAAGT,KAAK,CAACS,KAAN,GACV,EAAE,GAAGT,KAAK,CAACS,KAAX;IAAkB,GAAGF;EAArB,CADU,GAEVA,YAFJ;EAIA,MAAM;IAAEG,IAAF;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E8C;EAJlB,GAMG9C,MAAM,GAAGiD,aAAa,EAAhB,GAAqB,IAN9B,CADF;AAUD,CAvLM;AAyLP,eAAejE,mBAAf"}
1
+ {"version":3,"names":["React","useState","useEffect","useRef","Modal","SafeAreaView","Platform","WebView","Spinner","getFrameUrl","generateJavaScriptStartScript","generateStartDataPayload","parseOkHiLocation","OkHiException","OkHiAuth","start","sv","getApplicationConfiguration","isBackgroundLocationPermissionGranted","isLocationServicesEnabled","openAppSettings","openProtectedAppsSettings","request","requestLocationPermission","OkHiNativeModule","OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","startPayload","setStartPaylaod","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","webViewRef","startMessage","mode","phone","then","config","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","auth","anonymousSignInWithPhoneNumber","catch","error","OS","Version","setItem","JSON","stringify","payload","url","console","runWebViewCallback","value","current","jsString","injectJavaScript","handleAndroidRequestLocationPermission","level","status","handleIOSRequestLocationPermission","serviceError","SERVICE_UNAVAILABLE_CODE","unknownError","UNKNOWN_ERROR_CODE","isServiceAvailable","granted","handleRequestLocationPermission","handleOnMessage","nativeEvent","data","response","parse","fcmPushNotificationToken","location","startVerification","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","lat","lon","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","handleModalRequestClose","goBack","renderContent","jsAfterLoad","jsBeforeLoad","uri","undefined"],"sources":["OkHiLocationManager.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\nimport { Modal, SafeAreaView, Platform } from 'react-native';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport { Spinner } from './Spinner';\nimport type {\n OkHiLocationManagerResponse,\n OkHiLocationManagerProps,\n OkHiLocationManagerStartDataPayload,\n} from './types';\nimport {\n getFrameUrl,\n generateJavaScriptStartScript,\n generateStartDataPayload,\n parseOkHiLocation,\n} from './Util';\nimport { OkHiException } from '../OkCore/OkHiException';\nimport { OkHiAuth } from '../OkCore/OkHiAuth';\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { start as sv } from '../OkVerify';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\nimport {\n getApplicationConfiguration,\n isBackgroundLocationPermissionGranted,\n isLocationServicesEnabled,\n openAppSettings,\n openProtectedAppsSettings,\n request,\n requestLocationPermission,\n} from '../OkCore';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\n\n/**\n * The OkHiLocationManager React Component is used to display an in app modal, enabling the user to quickly create an accurate OkHi address.\n */\nexport const OkHiLocationManager = (props: OkHiLocationManagerProps) => {\n const [token, setToken] = useState<string | null>(null);\n const [applicationConfiguration, setApplicationConfiguration] =\n useState<AuthApplicationConfig | null>(null);\n const [startPayload, setStartPaylaod] =\n useState<null | OkHiLocationManagerStartDataPayload>(null);\n const defaultStyle = { flex: 1 };\n const style = props.style\n ? { ...props.style, ...defaultStyle }\n : defaultStyle;\n\n const { user, onSuccess, onCloseRequest, onError, loader, launch } = props;\n const webViewRef = useRef<WebView | null>(null);\n const startMessage =\n props.mode === 'create' ? 'start_app' : 'select_location';\n\n useEffect(() => {\n if (applicationConfiguration == null && token == null && user.phone) {\n getApplicationConfiguration()\n .then((config) => {\n if (!config && launch) {\n onError(\n new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n })\n );\n } else if (config) {\n setApplicationConfiguration(config);\n const auth = new OkHiAuth();\n auth\n .anonymousSignInWithPhoneNumber(user.phone, ['verify'], config)\n .then(setToken)\n .catch(onError);\n }\n })\n .catch((error) => {\n if (launch) {\n onError(error);\n }\n });\n }\n }, [onError, user.phone, launch, applicationConfiguration, token]);\n\n useEffect(() => {\n if (token !== null && applicationConfiguration !== null) {\n // TODO: handle faliure\n generateStartDataPayload(props, token, applicationConfiguration)\n .then((startPayload) => {\n setStartPaylaod(startPayload);\n if (Platform.OS === 'android' && Platform.Version > 25) {\n OkHiNativeModule.setItem(\n 'okcollect-launch-payload',\n JSON.stringify({\n message: startMessage,\n payload: startPayload,\n url: getFrameUrl(applicationConfiguration),\n })\n ).catch(console.error);\n }\n })\n .catch(console.error);\n }\n }, [applicationConfiguration, props, token]);\n\n const runWebViewCallback = (value: string) => {\n if (webViewRef.current) {\n const jsString = `(function (){ if (typeof runOkHiLocationManagerCallback === \"function\") { runOkHiLocationManagerCallback(\"${value}\") } })()`;\n webViewRef.current.injectJavaScript(jsString);\n }\n };\n\n const handleAndroidRequestLocationPermission = async (\n level: 'whenInUse' | 'always'\n ) => {\n // using request for android because we can programmatically turn on location services, unlike yucky ios\n request(level, null, (status, error) => {\n if (error) {\n onError(error);\n } else if (level === 'whenInUse' && status === 'authorizedWhenInUse') {\n runWebViewCallback(level);\n } else if (level === 'always' && status === 'authorizedAlways') {\n runWebViewCallback(level);\n }\n });\n };\n\n const handleIOSRequestLocationPermission = async (\n level: 'whenInUse' | 'always'\n ) => {\n const serviceError = new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message:\n 'Location service is currently not available. Please enable in app settings',\n });\n const unknownError = new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message:\n 'Something went wrong while requesting permissions. Please try again later.',\n });\n try {\n const isServiceAvailable = await isLocationServicesEnabled();\n if (!isServiceAvailable) {\n onError(serviceError);\n } else if (level === 'whenInUse' && (await requestLocationPermission())) {\n runWebViewCallback(level);\n } else if (level === 'always') {\n const granted = await isBackgroundLocationPermissionGranted();\n if (granted) {\n runWebViewCallback(level);\n } else {\n openAppSettings();\n }\n }\n } catch (error) {\n onError(unknownError);\n }\n };\n\n const handleRequestLocationPermission = async ({\n level,\n }: {\n level: 'whenInUse' | 'always';\n }) => {\n if (Platform.OS === 'android') {\n handleAndroidRequestLocationPermission(level);\n } else if (Platform.OS === 'ios') {\n handleIOSRequestLocationPermission(level);\n }\n };\n\n const handleOnMessage = ({ nativeEvent: { data } }: WebViewMessageEvent) => {\n try {\n const response: OkHiLocationManagerResponse = JSON.parse(data);\n if (response.message === 'fatal_exit') {\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: 'Something went wrong, please try again later.',\n })\n );\n } else if (response.message === 'exit_app') {\n onCloseRequest();\n } else if (response.message === 'request_enable_protected_apps') {\n openProtectedAppsSettings();\n } else if (\n response.message === 'location_created' ||\n response.message === 'location_selected' ||\n response.message === 'location_updated'\n ) {\n onSuccess({\n user: {\n ...response.payload.user,\n fcmPushNotificationToken: user.fcmPushNotificationToken,\n },\n location: parseOkHiLocation(response.payload.location),\n startVerification: function (config?: OkVerifyStartConfiguration) {\n const createdUser = { ...this.user };\n const location = { ...this.location };\n return new Promise((resolve, reject) => {\n if (!location.id) {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n } else {\n sv(\n createdUser.phone,\n location.id,\n location.lat,\n location.lon,\n config,\n createdUser.fcmPushNotificationToken\n )\n .then(resolve)\n .catch(reject);\n }\n });\n },\n });\n } else if (response.message === 'request_location_permission') {\n handleRequestLocationPermission(response.payload);\n }\n } catch (error) {\n let errorMessage = 'Something went wrong';\n if (error instanceof Error) {\n errorMessage = error.message;\n }\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: errorMessage,\n })\n );\n }\n };\n\n const handleOnError = () => {\n onError(\n new OkHiException({\n code: OkHiException.NETWORK_ERROR_CODE,\n message: OkHiException.NETWORK_ERROR_MESSAGE,\n })\n );\n };\n\n const handleModalRequestClose = () => {\n webViewRef.current?.goBack();\n };\n\n const renderContent = () => {\n if (token === null || applicationConfiguration == null) {\n return loader || <Spinner />;\n }\n\n if (startPayload === null) {\n return loader || <Spinner />;\n }\n\n const { jsAfterLoad, jsBeforeLoad } = generateJavaScriptStartScript({\n message: startMessage,\n payload: startPayload,\n });\n\n return (\n <SafeAreaView style={style}>\n <WebView\n source={{ uri: getFrameUrl(applicationConfiguration) }}\n injectedJavaScriptBeforeContentLoaded={\n Platform.OS === 'ios' ? jsBeforeLoad : undefined\n }\n injectedJavaScript={Platform.OS === 'ios' ? undefined : jsAfterLoad}\n onMessage={handleOnMessage}\n onError={handleOnError}\n onHttpError={handleOnError}\n geolocationEnabled={true}\n allowsBackForwardNavigationGestures={true}\n ref={webViewRef}\n />\n </SafeAreaView>\n );\n };\n\n return (\n <Modal\n animationType=\"slide\"\n transparent={false}\n visible={launch}\n onRequestClose={handleModalRequestClose}\n >\n {launch ? renderContent() : null}\n </Modal>\n );\n};\n\nexport default OkHiLocationManager;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,MAArC,QAAmD,OAAnD;AACA,SAASC,KAAT,EAAgBC,YAAhB,EAA8BC,QAA9B,QAA8C,cAA9C;AACA,SAASC,OAAT,QAA6C,sBAA7C;AACA,SAASC,OAAT,QAAwB,WAAxB;AAMA,SACEC,WADF,EAEEC,6BAFF,EAGEC,wBAHF,EAIEC,iBAJF,QAKO,QALP;AAMA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA,SAASC,KAAK,IAAIC,EAAlB,QAA4B,aAA5B;AAEA,SACEC,2BADF,EAEEC,qCAFF,EAGEC,yBAHF,EAIEC,eAJF,EAKEC,yBALF,EAMEC,OANF,EAOEC,yBAPF,QAQO,WARP;AASA,SAASC,gBAAT,QAAiC,qBAAjC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB3B,QAAQ,CAAgB,IAAhB,CAAlC;EACA,MAAM,CAAC4B,wBAAD,EAA2BC,2BAA3B,IACJ7B,QAAQ,CAA+B,IAA/B,CADV;EAEA,MAAM,CAAC8B,YAAD,EAAeC,eAAf,IACJ/B,QAAQ,CAA6C,IAA7C,CADV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MAAMC,aAAa,GAAG,MAAM;IAC1B,IAAI5E,KAAK,KAAK,IAAV,IAAkBE,wBAAwB,IAAI,IAAlD,EAAwD;MACtD,OAAOW,MAAM,iBAAI,oBAAC,OAAD,OAAjB;IACD;;IAED,IAAIT,YAAY,KAAK,IAArB,EAA2B;MACzB,OAAOS,MAAM,iBAAI,oBAAC,OAAD,OAAjB;IACD;;IAED,MAAM;MAAEgE,WAAF;MAAeC;IAAf,IAAgC/F,6BAA6B,CAAC;MAClEwC,OAAO,EAAEP,YADyD;MAElEkB,OAAO,EAAE9B;IAFyD,CAAD,CAAnE;IAKA,oBACE,oBAAC,YAAD;MAAc,KAAK,EAAEI;IAArB,gBACE,oBAAC,OAAD;MACE,MAAM,EAAE;QAAEuE,GAAG,EAAEjG,WAAW,CAACoB,wBAAD;MAAlB,CADV;MAEE,qCAAqC,EACnCvB,QAAQ,CAACkD,EAAT,KAAgB,KAAhB,GAAwBiD,YAAxB,GAAuCE,SAH3C;MAKE,kBAAkB,EAAErG,QAAQ,CAACkD,EAAT,KAAgB,KAAhB,GAAwBmD,SAAxB,GAAoCH,WAL1D;MAME,SAAS,EAAExB,eANb;MAOE,OAAO,EAAEkB,aAPX;MAQE,WAAW,EAAEA,aARf;MASE,kBAAkB,EAAE,IATtB;MAUE,mCAAmC,EAAE,IAVvC;MAWE,GAAG,EAAExD;IAXP,EADF,CADF;EAiBD,CA/BD;;EAiCA,oBACE,oBAAC,KAAD;IACE,aAAa,EAAC,OADhB;IAEE,WAAW,EAAE,KAFf;IAGE,OAAO,EAAED,MAHX;IAIE,cAAc,EAAE4D;EAJlB,GAMG5D,MAAM,GAAG8D,aAAa,EAAhB,GAAqB,IAN9B,CADF;AAUD,CA/PM;AAiQP,eAAe9E,mBAAf"}
@@ -15,9 +15,15 @@ const fetchCurrentLocation = async () => {
15
15
 
16
16
 
17
17
  export const generateStartDataPayload = async (props, authToken, applicationConfiguration) => {
18
- var _props$theme, _props$theme$colors, _props$theme2, _props$theme2$appBar, _applicationConfigura, _applicationConfigura2, _applicationConfigura3, _props$config, _props$theme3, _props$theme3$appBar, _props$config2, _props$config2$appBar, _props$config3, _props$config3$addres, _props$config4, _props$config4$addres, _props$config5, _props$config5$addres, _props$config6, _props$config6$addres;
18
+ var _props$theme, _props$theme$colors, _props$theme2, _props$theme2$appBar, _applicationConfigura, _applicationConfigura2, _applicationConfigura3, _props$config, _props$theme3, _props$theme3$appBar, _props$config2, _props$config2$appBar, _props$config3, _props$config3$addres, _props$config4, _props$config4$addres, _props$config5, _props$config5$addres, _props$config6, _props$config6$addres, _props$config7;
19
19
 
20
20
  const payload = {};
21
+ const {
22
+ manufacturer,
23
+ model,
24
+ osVersion,
25
+ platform
26
+ } = await OkHiNativeModule.retrieveDeviceInfo();
21
27
  payload.style = !props.theme ? undefined : {
22
28
  base: {
23
29
  color: (_props$theme = props.theme) === null || _props$theme === void 0 ? void 0 : (_props$theme$colors = _props$theme.colors) === null || _props$theme$colors === void 0 ? void 0 : _props$theme$colors.primary,
@@ -48,6 +54,12 @@ export const generateStartDataPayload = async (props, authToken, applicationConf
48
54
  },
49
55
  platform: {
50
56
  name: 'react-native'
57
+ },
58
+ device: {
59
+ manufacturer,
60
+ model,
61
+ platform,
62
+ osVersion
51
63
  }
52
64
  };
53
65
  payload.config = {
@@ -60,29 +72,27 @@ export const generateStartDataPayload = async (props, authToken, applicationConf
60
72
  home: typeof ((_props$config3 = props.config) === null || _props$config3 === void 0 ? void 0 : (_props$config3$addres = _props$config3.addressTypes) === null || _props$config3$addres === void 0 ? void 0 : _props$config3$addres.home) === 'boolean' ? (_props$config4 = props.config) === null || _props$config4 === void 0 ? void 0 : (_props$config4$addres = _props$config4.addressTypes) === null || _props$config4$addres === void 0 ? void 0 : _props$config4$addres.home : true,
61
73
  work: typeof ((_props$config5 = props.config) === null || _props$config5 === void 0 ? void 0 : (_props$config5$addres = _props$config5.addressTypes) === null || _props$config5$addres === void 0 ? void 0 : _props$config5$addres.work) === 'boolean' ? (_props$config6 = props.config) === null || _props$config6 === void 0 ? void 0 : (_props$config6$addres = _props$config6.addressTypes) === null || _props$config6$addres === void 0 ? void 0 : _props$config6$addres.work : true
62
74
  },
63
- protectedApps: Platform.OS === 'android' && (await canOpenProtectedAppsSettings())
75
+ protectedApps: Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),
76
+ permissionsOnboarding: typeof ((_props$config7 = props.config) === null || _props$config7 === void 0 ? void 0 : _props$config7.permissionsOnboarding) === 'boolean' ? props.config.permissionsOnboarding : true
64
77
  };
65
78
 
66
79
  if (Platform.OS === 'ios') {
67
80
  const status = await OkHiNativeModule.fetchIOSLocationPermissionStatus();
81
+ payload.context.permissions = {
82
+ location: status === 'authorizedWhenInUse' ? 'whenInUse' : status === 'authorizedAlways' || status === 'authorized' ? 'always' : 'denied'
83
+ };
68
84
 
69
- if (status !== 'notDetermined') {
70
- payload.context.permissions = {
71
- location: status === 'authorizedWhenInUse' ? 'whenInUse' : status === 'authorizedAlways' || status === 'authorized' ? 'always' : 'denided'
72
- };
73
-
74
- if (status === 'authorized' || status === 'authorizedWhenInUse' || status === 'authorizedAlways') {
75
- const location = await fetchCurrentLocation();
76
-
77
- if (location) {
78
- payload.context.coordinates = {
79
- currentLocation: {
80
- lat: location.lat,
81
- lng: location.lng,
82
- accuracy: location.accuracy
83
- }
84
- };
85
- }
85
+ if (status === 'authorized' || status === 'authorizedWhenInUse' || status === 'authorizedAlways') {
86
+ const location = await fetchCurrentLocation();
87
+
88
+ if (location) {
89
+ payload.context.coordinates = {
90
+ currentLocation: {
91
+ lat: location.lat,
92
+ lng: location.lng,
93
+ accuracy: location.accuracy
94
+ }
95
+ };
86
96
  }
87
97
  }
88
98
  } else if (Platform.OS === 'android') {
@@ -107,15 +117,6 @@ export const generateStartDataPayload = async (props, authToken, applicationConf
107
117
  location: hasBackgroundLocationPermission ? 'always' : hasLocationPermission ? 'whenInUse' : 'denied'
108
118
  };
109
119
  }
110
-
111
- const {
112
- manufacturer,
113
- model
114
- } = await OkHiNativeModule.retrieveDeviceInfo();
115
- payload.context.device = {
116
- manufacturer,
117
- model
118
- };
119
120
  } else {
120
121
  throw new OkHiException({
121
122
  code: OkHiException.UNSUPPORTED_PLATFORM_CODE,
@@ -1 +1 @@
1
- {"version":3,"names":["canOpenProtectedAppsSettings","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","OkHiException","OkHiMode","manifest","Platform","OkHiNativeModule","fetchCurrentLocation","result","generateStartDataPayload","props","authToken","applicationConfiguration","payload","style","theme","undefined","base","color","colors","primary","logo","appBar","name","app","user","phone","firstName","lastName","email","auth","context","container","version","developer","library","platform","config","streetView","backgroundColor","visible","addressTypes","home","work","protectedApps","OS","status","fetchIOSLocationPermissionStatus","permissions","location","coordinates","currentLocation","lat","lng","accuracy","hasLocationPermission","error","console","log","hasBackgroundLocationPermission","manufacturer","model","retrieveDeviceInfo","device","code","UNSUPPORTED_PLATFORM_CODE","message","UNAUTHORIZED_MESSAGE","getFrameUrl","DEV_FRAME_URL","PROD_FRAME_URL","SANDBOX_FRAME_URL","LEGACY_DEV_FRAME_URL","LEGACY_PROD_FRAME_URL","LEGACY_SANDBOX_FRAME_URL","Version","mode","PROD","generateJavaScriptStartScript","startPayload","jsBeforeLoad","JSON","stringify","jsAfterLoad","parseOkHiLocation","id","geo_point","lon","placeId","place_id","plusCode","plus_code","propertyName","property_name","streetName","street_name","title","subtitle","directions","otherInformation","other_information","url","streetViewPanoId","street_view","pano_id","streetViewPanoUrl","userId","user_id","propertyNumber","photo","displayTitle","display_title","country","state","city","countryCode","country_code"],"sources":["Util.ts"],"sourcesContent":["import type { OkHiLocationManagerProps } from './types';\nimport {\n canOpenProtectedAppsSettings,\n isBackgroundLocationPermissionGranted,\n isLocationPermissionGranted,\n OkHiException,\n OkHiLocation,\n} from '../OkCore';\nimport { OkHiMode } from '../OkCore';\nimport type {\n OkHiLocationManagerStartDataPayload,\n OkHiLocationManagerStartMessage,\n} from './types';\nimport manifest from './app.json'; //TODO: fix this\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { Platform } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\n\nconst fetchCurrentLocation = async (): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n}> => {\n const result = await OkHiNativeModule.fetchCurrentLocation();\n return result;\n};\n\n/**\n * @ignore\n */\nexport const generateStartDataPayload = async (\n props: OkHiLocationManagerProps,\n authToken: string,\n applicationConfiguration: AuthApplicationConfig\n): Promise<OkHiLocationManagerStartDataPayload> => {\n const payload: any = {};\n payload.style = !props.theme\n ? undefined\n : {\n base: {\n color: props.theme?.colors?.primary,\n logo: props.theme?.appBar?.logo,\n name: applicationConfiguration.app?.name,\n },\n };\n payload.user = {\n phone: props.user.phone,\n firstName: props.user.firstName,\n lastName: props.user.lastName,\n email: props.user.email,\n };\n payload.auth = {\n authToken,\n };\n payload.context = {\n container: {\n name: applicationConfiguration.app?.name,\n version: applicationConfiguration.app?.version,\n },\n developer: {\n name: applicationConfiguration.context.developer,\n },\n library: {\n name: manifest.name,\n version: manifest.version,\n },\n platform: {\n name: 'react-native',\n },\n };\n payload.config = {\n streetView:\n typeof props.config?.streetView === 'boolean'\n ? props.config.streetView\n : true,\n appBar: {\n color: props.theme?.appBar?.backgroundColor,\n visible: props.config?.appBar?.visible,\n },\n addressTypes: {\n home:\n typeof props.config?.addressTypes?.home === 'boolean'\n ? props.config?.addressTypes?.home\n : true,\n work:\n typeof props.config?.addressTypes?.work === 'boolean'\n ? props.config?.addressTypes?.work\n : true,\n },\n protectedApps:\n Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),\n };\n\n if (Platform.OS === 'ios') {\n const status = await OkHiNativeModule.fetchIOSLocationPermissionStatus();\n if (status !== 'notDetermined') {\n payload.context.permissions = {\n location:\n status === 'authorizedWhenInUse'\n ? 'whenInUse'\n : status === 'authorizedAlways' || status === 'authorized'\n ? 'always'\n : 'denided',\n };\n if (\n status === 'authorized' ||\n status === 'authorizedWhenInUse' ||\n status === 'authorizedAlways'\n ) {\n const location = await fetchCurrentLocation();\n if (location) {\n payload.context.coordinates = {\n currentLocation: {\n lat: location.lat,\n lng: location.lng,\n accuracy: location.accuracy,\n },\n };\n }\n }\n }\n } else if (Platform.OS === 'android') {\n let hasLocationPermission: boolean | undefined;\n try {\n hasLocationPermission = await isLocationPermissionGranted();\n } catch (error) {\n console.log(error);\n }\n\n let hasBackgroundLocationPermission: boolean | undefined;\n try {\n hasBackgroundLocationPermission =\n await isBackgroundLocationPermissionGranted();\n } catch (error) {\n console.log(error);\n }\n\n if (\n typeof hasLocationPermission === 'boolean' &&\n typeof hasBackgroundLocationPermission === 'boolean'\n ) {\n payload.context.permissions = {\n location: hasBackgroundLocationPermission\n ? 'always'\n : hasLocationPermission\n ? 'whenInUse'\n : 'denied',\n };\n }\n const { manufacturer, model } = await OkHiNativeModule.retrieveDeviceInfo();\n payload.context.device = {\n manufacturer,\n model,\n };\n } else {\n throw new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n }\n return payload;\n};\n\n/**\n * @ignore\n */\nexport const getFrameUrl = (\n applicationConfiguration: AuthApplicationConfig\n): string => {\n const DEV_FRAME_URL = 'https://dev-manager-v5.okhi.io';\n const PROD_FRAME_URL = 'https://manager-v5.okhi.io';\n const SANDBOX_FRAME_URL = 'https://sandbox-manager-v5.okhi.io';\n\n const LEGACY_DEV_FRAME_URL = 'https://dev-legacy-manager-v5.okhi.io';\n const LEGACY_PROD_FRAME_URL = 'https://legacy-manager-v5.okhi.io';\n const LEGACY_SANDBOX_FRAME_URL = 'https://sandbox-legacy-manager-v5.okhi.io';\n\n if (Platform.OS === 'android' && Platform.Version < 24) {\n if (applicationConfiguration.context.mode === OkHiMode.PROD) {\n return LEGACY_PROD_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === ('dev' as any)) {\n return LEGACY_DEV_FRAME_URL;\n }\n return LEGACY_SANDBOX_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === OkHiMode.PROD) {\n return PROD_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === ('dev' as any)) {\n return DEV_FRAME_URL;\n }\n return SANDBOX_FRAME_URL;\n};\n\n/**\n * @ignore\n */\nexport const generateJavaScriptStartScript = (startPayload: {\n message: OkHiLocationManagerStartMessage;\n payload: OkHiLocationManagerStartDataPayload;\n}) => {\n const jsBeforeLoad = `\n window.isNativeApp = true;\n window.NativeApp = {\n bridge: {\n receiveMessage: window.ReactNativeWebView.postMessage\n },\n data: ${JSON.stringify(startPayload)}\n }\n true;\n `;\n const jsAfterLoad = `window.startOkHiLocationManager({ receiveMessage: function(data) { window.ReactNativeWebView.postMessage(data) } }, ${JSON.stringify(\n startPayload\n )})`;\n return { jsBeforeLoad, jsAfterLoad };\n};\n\n/**\n * @ignore\n */\nexport const parseOkHiLocation = (location: any): OkHiLocation => {\n return {\n id: location?.id,\n lat: location?.geo_point?.lat,\n lon: location?.geo_point?.lon,\n placeId: location?.place_id,\n plusCode: location?.plus_code,\n propertyName: location?.property_name,\n streetName: location?.street_name,\n title: location?.title,\n subtitle: location?.subtitle,\n directions: location?.directions,\n otherInformation: location?.other_information,\n url: location?.url,\n streetViewPanoId: location?.street_view?.pano_id,\n streetViewPanoUrl: location?.street_view?.url,\n userId: location?.user_id,\n propertyNumber: location?.propertyNumber,\n photo: location?.photo,\n displayTitle: location?.display_title,\n country: location?.country,\n state: location?.state,\n city: location?.city,\n countryCode: location?.country_code,\n };\n};\n"],"mappings":"AACA,SACEA,4BADF,EAEEC,qCAFF,EAGEC,2BAHF,EAIEC,aAJF,QAMO,WANP;AAOA,SAASC,QAAT,QAAyB,WAAzB;AAKA,OAAOC,QAAP,MAAqB,YAArB,C,CAAmC;;AAEnC,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,gBAAT,QAAiC,qBAAjC;;AAEA,MAAMC,oBAAoB,GAAG,YAIvB;EACJ,MAAMC,MAAM,GAAG,MAAMF,gBA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AEA,QAAF,iDAAEA,QAAQ,CAAEsD,WAAZ,2DAAE,uBAAuBF,GAdrC;IAeLK,MAAM,EAAEzD,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAE0D,OAfb;IAgBLC,cAAc,EAAE3D,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAE2D,cAhBrB;IAiBLC,KAAK,EAAE5D,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAE4D,KAjBZ;IAkBLC,YAAY,EAAE7D,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAE8D,aAlBnB;IAmBLC,OAAO,EAAE/D,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAE+D,OAnBd;IAoBLC,KAAK,EAAEhE,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEgE,KApBZ;IAqBLC,IAAI,EAAEjE,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEiE,IArBX;IAsBLC,WAAW,EAAElE,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEmE;EAtBlB,CAAP;AAwBD,CAzBM"}
1
+ {"version":3,"names":["canOpenProtectedAppsSettings","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","OkHiException","OkHiMode","manifest","Platform","OkHiNativeModule","fetchCurrentLocation","result","generateStartDataPayload","props","authToken","applicationConfiguration","payload","manufacturer","model","osVersion","platform","retrieveDeviceInfo","style","theme","undefined","base","color","colors","primary","logo","appBar","name","app","user","phone","firstName","lastName","email","auth","context","container","version","developer","library","device","config","streetView","backgroundColor","visible","addressTypes","home","work","protectedApps","OS","permissionsOnboarding","status","fetchIOSLocationPermissionStatus","permissions","location","coordinates","currentLocation","lat","lng","accuracy","hasLocationPermission","error","console","log","hasBackgroundLocationPermission","code","UNSUPPORTED_PLATFORM_CODE","message","UNAUTHORIZED_MESSAGE","getFrameUrl","DEV_FRAME_URL","PROD_FRAME_URL","SANDBOX_FRAME_URL","LEGACY_DEV_FRAME_URL","LEGACY_PROD_FRAME_URL","LEGACY_SANDBOX_FRAME_URL","Version","mode","PROD","generateJavaScriptStartScript","startPayload","jsBeforeLoad","JSON","stringify","jsAfterLoad","parseOkHiLocation","id","geo_point","lon","placeId","place_id","plusCode","plus_code","propertyName","property_name","streetName","street_name","title","subtitle","directions","otherInformation","other_information","url","streetViewPanoId","street_view","pano_id","streetViewPanoUrl","userId","user_id","propertyNumber","photo","displayTitle","display_title","country","state","city","countryCode","country_code"],"sources":["Util.ts"],"sourcesContent":["import type { OkHiLocationManagerProps } from './types';\nimport {\n canOpenProtectedAppsSettings,\n isBackgroundLocationPermissionGranted,\n isLocationPermissionGranted,\n OkHiException,\n OkHiLocation,\n} from '../OkCore';\nimport { OkHiMode } from '../OkCore';\nimport type {\n OkHiLocationManagerStartDataPayload,\n OkHiLocationManagerStartMessage,\n} from './types';\nimport manifest from './app.json'; //TODO: fix this\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { Platform } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\n\nconst fetchCurrentLocation = async (): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n}> => {\n const result = await OkHiNativeModule.fetchCurrentLocation();\n return result;\n};\n\n/**\n * @ignore\n */\nexport const generateStartDataPayload = async (\n props: OkHiLocationManagerProps,\n authToken: string,\n applicationConfiguration: AuthApplicationConfig\n): Promise<OkHiLocationManagerStartDataPayload> => {\n const payload: any = {};\n const { manufacturer, model, osVersion, platform } =\n await OkHiNativeModule.retrieveDeviceInfo();\n payload.style = !props.theme\n ? undefined\n : {\n base: {\n color: props.theme?.colors?.primary,\n logo: props.theme?.appBar?.logo,\n name: applicationConfiguration.app?.name,\n },\n };\n payload.user = {\n phone: props.user.phone,\n firstName: props.user.firstName,\n lastName: props.user.lastName,\n email: props.user.email,\n };\n payload.auth = {\n authToken,\n };\n payload.context = {\n container: {\n name: applicationConfiguration.app?.name,\n version: applicationConfiguration.app?.version,\n },\n developer: {\n name: applicationConfiguration.context.developer,\n },\n library: {\n name: manifest.name,\n version: manifest.version,\n },\n platform: {\n name: 'react-native',\n },\n device: {\n manufacturer,\n model,\n platform,\n osVersion,\n },\n };\n payload.config = {\n streetView:\n typeof props.config?.streetView === 'boolean'\n ? props.config.streetView\n : true,\n appBar: {\n color: props.theme?.appBar?.backgroundColor,\n visible: props.config?.appBar?.visible,\n },\n addressTypes: {\n home:\n typeof props.config?.addressTypes?.home === 'boolean'\n ? props.config?.addressTypes?.home\n : true,\n work:\n typeof props.config?.addressTypes?.work === 'boolean'\n ? props.config?.addressTypes?.work\n : true,\n },\n protectedApps:\n Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),\n permissionsOnboarding:\n typeof props.config?.permissionsOnboarding === 'boolean'\n ? props.config.permissionsOnboarding\n : true,\n };\n\n if (Platform.OS === 'ios') {\n const status = await OkHiNativeModule.fetchIOSLocationPermissionStatus();\n payload.context.permissions = {\n location:\n status === 'authorizedWhenInUse'\n ? 'whenInUse'\n : status === 'authorizedAlways' || status === 'authorized'\n ? 'always'\n : 'denied',\n };\n if (\n status === 'authorized' ||\n status === 'authorizedWhenInUse' ||\n status === 'authorizedAlways'\n ) {\n const location = await fetchCurrentLocation();\n if (location) {\n payload.context.coordinates = {\n currentLocation: {\n lat: location.lat,\n lng: location.lng,\n accuracy: location.accuracy,\n },\n };\n }\n }\n } else if (Platform.OS === 'android') {\n let hasLocationPermission: boolean | undefined;\n try {\n hasLocationPermission = await isLocationPermissionGranted();\n } catch (error) {\n console.log(error);\n }\n\n let hasBackgroundLocationPermission: boolean | undefined;\n try {\n hasBackgroundLocationPermission =\n await isBackgroundLocationPermissionGranted();\n } catch (error) {\n console.log(error);\n }\n\n if (\n typeof hasLocationPermission === 'boolean' &&\n typeof hasBackgroundLocationPermission === 'boolean'\n ) {\n payload.context.permissions = {\n location: hasBackgroundLocationPermission\n ? 'always'\n : hasLocationPermission\n ? 'whenInUse'\n : 'denied',\n };\n }\n } else {\n throw new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n }\n return payload;\n};\n\n/**\n * @ignore\n */\nexport const getFrameUrl = (\n applicationConfiguration: AuthApplicationConfig\n): string => {\n const DEV_FRAME_URL = 'https://dev-manager-v5.okhi.io';\n const PROD_FRAME_URL = 'https://manager-v5.okhi.io';\n const SANDBOX_FRAME_URL = 'https://sandbox-manager-v5.okhi.io';\n\n const LEGACY_DEV_FRAME_URL = 'https://dev-legacy-manager-v5.okhi.io';\n const LEGACY_PROD_FRAME_URL = 'https://legacy-manager-v5.okhi.io';\n const LEGACY_SANDBOX_FRAME_URL = 'https://sandbox-legacy-manager-v5.okhi.io';\n\n if (Platform.OS === 'android' && Platform.Version < 24) {\n if (applicationConfiguration.context.mode === OkHiMode.PROD) {\n return LEGACY_PROD_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === ('dev' as any)) {\n return LEGACY_DEV_FRAME_URL;\n }\n return LEGACY_SANDBOX_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === OkHiMode.PROD) {\n return PROD_FRAME_URL;\n }\n if (applicationConfiguration.context.mode === ('dev' as any)) {\n return DEV_FRAME_URL;\n }\n return SANDBOX_FRAME_URL;\n};\n\n/**\n * @ignore\n */\nexport const generateJavaScriptStartScript = (startPayload: {\n message: OkHiLocationManagerStartMessage;\n payload: OkHiLocationManagerStartDataPayload;\n}) => {\n const jsBeforeLoad = `\n window.isNativeApp = true;\n window.NativeApp = {\n bridge: {\n receiveMessage: window.ReactNativeWebView.postMessage\n },\n data: ${JSON.stringify(startPayload)}\n }\n true;\n `;\n const jsAfterLoad = `window.startOkHiLocationManager({ receiveMessage: function(data) { window.ReactNativeWebView.postMessage(data) } }, ${JSON.stringify(\n startPayload\n )})`;\n return { jsBeforeLoad, jsAfterLoad };\n};\n\n/**\n * @ignore\n */\nexport const parseOkHiLocation = (location: any): OkHiLocation => {\n return {\n id: location?.id,\n lat: location?.geo_point?.lat,\n lon: location?.geo_point?.lon,\n placeId: location?.place_id,\n plusCode: location?.plus_code,\n propertyName: location?.property_name,\n streetName: location?.street_name,\n title: location?.title,\n subtitle: location?.subtitle,\n directions: location?.directions,\n otherInformation: location?.other_information,\n url: location?.url,\n streetViewPanoId: location?.street_view?.pano_id,\n streetViewPanoUrl: location?.street_view?.url,\n userId: location?.user_id,\n propertyNumber: location?.propertyNumber,\n photo: location?.photo,\n displayTitle: location?.display_title,\n country: location?.country,\n state: location?.state,\n city: location?.city,\n countryCode: location?.country_code,\n };\n};\n"],"mappings":"AACA,SACEA,4BADF,EAEEC,qCAFF,EAGEC,2BAHF,EAIEC,aAJF,QAMO,WANP;AAOA,SAASC,QAAT,QAAyB,WAAzB;AAKA,OAAOC,QAAP,MAAqB,YAArB,C,CAAmC;;AAEnC,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,gBAAT,QAAiC,qBAAjC;;AAEA,MAAMC,oBAAoB,GAAG,YAIvB;EACJ,MAAMC,MAAM,GAAG,MAAMF,gBAAgB,CAACC,oBAAjB,EAArB;EACA,OAAOC,MAAP;AACD,CAPD;AASA;AACA;AACA;;;AACA,OAAO,MAAMC,wBAAwB,GAAG,OACtCC,KADsC,EAEtCC,SAFsC,EAGtCC,wBAHsC,KAIW;EAAA;;EACjD,MAAMC,OAAY,GAAG,EAArB;EACA,MAAM;IAAEC,YAAF;IAAgBC,KAAhB;IAAuBC,SAAvB;IAAkCC;EAAlC,IACJ,MAAMX,gBAAgB,CAACY,kBAAjB,EADR;EAEAL,OAAO,CAACM,KAAR,GAAgB,CAACT,KAAK,CAACU,KAAP,GACZC,SADY,GAEZ;IACEC,IAAI,EAAE;MACJC,KAAK,kBAAEb,KAAK,CAACU,KAAR,wEAAE,aAAaI,MAAf,wDAAE,oBAAqBC,OADxB;MAEJC,IAAI,mBAAEhB,KAAK,CAACU,KAAR,0EAAE,cAAaO,MAAf,yDAAE,qBAAqBD,IAFvB;MAGJE,IAAI,2BAAEhB,wBAAwB,CAACiB,GAA3B,0DAAE,sBA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KApBZ;IAqBLC,IAAI,EAAE7D,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAE6D,IArBX;IAsBLC,WAAW,EAAE9D,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAE+D;EAtBlB,CAAP;AAwBD,CAzBM"}
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "okhiWebReactNative",
3
- "version": "1.2.2"
3
+ "version": "1.2.3-beta.2"
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewStyle } from 'react-native';\nimport type { OkHiException } from '../OkCore/OkHiException';\nimport type { OkHiUser, OkHiLocation } from '../OkCore/types';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\n/**\n * The OkCollect Success Response object contains information about the newly created user and location once an address has been successfully created.\n * It can be used to extract information about the address and/or start address verification process.\n */\nexport interface OkCollectSuccessResponse {\n /**\n * The [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object containing information about the newly created user.\n */\n user: OkHiUser;\n /**\n * The [OkHiLocation](https://okhi.github.io/react-native-core/interfaces/okhilocation.html) object containing information about the newly created user.\n */\n location: OkHiLocation;\n\n /**\n * Starts address verification\n */\n startVerification: (config?: OkVerifyStartConfiguration) => Promise<string>;\n}\n\n/**\n * The OkHiLocationManager exposes props that you can use to customise it's functionality and appearance.\n */\nexport interface OkHiLocationManagerProps {\n /**\n * **Required:** A boolean flag that determines whether or not to show the Location Manager.\n */\n launch: boolean;\n /**\n * **Required:** A defined [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object, with a mandatory \"phone\" key property.\n */\n user: OkHiUser;\n /**\n * **Optional:** A custom JSX.Element that'll be used as a loading indicator.\n */\n loader?: JSX.Element;\n /**\n * **Optional:** Used to customise the appearance of the Container that wraps the location manager.\n */\n style?: ViewStyle;\n /**\n * **Required:** A callback that'll be invoked with an {@link OkCollectSuccessResponse} once an accurate OkHi address has been successfully created.\n */\n onSuccess: (response: OkCollectSuccessResponse) => any;\n /**\n * **Required:** A callback that'll be invoked whenever an error occurs during the address creation process.\n */\n onError: (error: OkHiException) => any;\n /**\n * **Required:** A callback that'll be invoked whenever a user taps on the close button.\n */\n onCloseRequest: () => any;\n /**\n * **Optional:** An object that'll be used to customise the appearance of the Location Manager to better match your branding requirements.\n */\n theme?: {\n appBar?: {\n backgroundColor?: string;\n logo?: string;\n };\n colors?: {\n primary?: string;\n };\n };\n /**\n * **Optional:** An object that'll be used to customise the functionality of the Location Manager. This object dictates whether you want some features on or off.\n */\n config?: {\n streetView?: boolean;\n appBar?: {\n visible?: boolean;\n };\n addressTypes?: {\n home?: boolean;\n work?: boolean;\n };\n };\n\n /**\n * **Optional:** Enable a user to either select an existing address, or force to create a new one\n */\n mode?: 'create' | 'select';\n}\n\n/**\n * @ignore\n */\nexport interface OkHiLocationManagerStartDataPayload {\n style?: {\n base?: {\n color?: string;\n logo?: string;\n name?: string;\n };\n };\n auth: {\n authToken: string;\n };\n context: {\n container?: {\n name?: string;\n version?: string;\n };\n developer: {\n name: string;\n };\n library: {\n name: string;\n version: string;\n };\n platform: {\n name: 'react-native';\n };\n };\n config?: {\n streetView?: boolean;\n appBar?: {\n color?: string;\n visible?: boolean;\n };\n };\n user: OkHiUser;\n}\n\n/**\n * @ignore\n */\nexport type OkHiLocationManagerStartMessage = 'select_location' | 'start_app';\n\n/**\n * @ignore\n */\nexport interface OkHiLocationManagerResponse {\n message:\n | 'location_selected'\n | 'location_created'\n | 'location_updated'\n | 'exit_app'\n | 'request_enable_protected_apps'\n | 'fatal_exit';\n payload: { user: any; location: any };\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewStyle } from 'react-native';\nimport type { OkHiException } from '../OkCore/OkHiException';\nimport type { OkHiUser, OkHiLocation } from '../OkCore/types';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\n/**\n * The OkCollect Success Response object contains information about the newly created user and location once an address has been successfully created.\n * It can be used to extract information about the address and/or start address verification process.\n */\nexport interface OkCollectSuccessResponse {\n /**\n * The [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object containing information about the newly created user.\n */\n user: OkHiUser;\n /**\n * The [OkHiLocation](https://okhi.github.io/react-native-core/interfaces/okhilocation.html) object containing information about the newly created user.\n */\n location: OkHiLocation;\n\n /**\n * Starts address verification\n */\n startVerification: (config?: OkVerifyStartConfiguration) => Promise<string>;\n}\n\n/**\n * The OkHiLocationManager exposes props that you can use to customise it's functionality and appearance.\n */\nexport interface OkHiLocationManagerProps {\n /**\n * **Required:** A boolean flag that determines whether or not to show the Location Manager.\n */\n launch: boolean;\n /**\n * **Required:** A defined [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object, with a mandatory \"phone\" key property.\n */\n user: OkHiUser;\n /**\n * **Optional:** A custom JSX.Element that'll be used as a loading indicator.\n */\n loader?: JSX.Element;\n /**\n * **Optional:** Used to customise the appearance of the Container that wraps the location manager.\n */\n style?: ViewStyle;\n /**\n * **Required:** A callback that'll be invoked with an {@link OkCollectSuccessResponse} once an accurate OkHi address has been successfully created.\n */\n onSuccess: (response: OkCollectSuccessResponse) => any;\n /**\n * **Required:** A callback that'll be invoked whenever an error occurs during the address creation process.\n */\n onError: (error: OkHiException) => any;\n /**\n * **Required:** A callback that'll be invoked whenever a user taps on the close button.\n */\n onCloseRequest: () => any;\n /**\n * **Optional:** An object that'll be used to customise the appearance of the Location Manager to better match your branding requirements.\n */\n theme?: {\n appBar?: {\n backgroundColor?: string;\n logo?: string;\n };\n colors?: {\n primary?: string;\n };\n };\n /**\n * **Optional:** An object that'll be used to customise the functionality of the Location Manager. This object dictates whether you want some features on or off.\n */\n config?: {\n streetView?: boolean;\n appBar?: {\n visible?: boolean;\n };\n addressTypes?: {\n home?: boolean;\n work?: boolean;\n };\n permissionsOnboarding?: boolean;\n };\n\n /**\n * **Optional:** Enable a user to either select an existing address, or force to create a new one\n */\n mode?: 'create' | 'select';\n}\n\n/**\n * @ignore\n */\nexport interface OkHiLocationManagerStartDataPayload {\n style?: {\n base?: {\n color?: string;\n logo?: string;\n name?: string;\n };\n };\n auth: {\n authToken: string;\n };\n context: {\n container?: {\n name?: string;\n version?: string;\n };\n developer: {\n name: string;\n };\n library: {\n name: string;\n version: string;\n };\n platform: {\n name: 'react-native';\n };\n };\n config?: {\n streetView?: boolean;\n appBar?: {\n color?: string;\n visible?: boolean;\n };\n };\n user: OkHiUser;\n}\n\n/**\n * @ignore\n */\nexport type OkHiLocationManagerStartMessage = 'select_location' | 'start_app';\n\n/**\n * @ignore\n */\nexport interface OkHiLocationManagerResponse {\n message:\n | 'location_selected'\n | 'location_created'\n | 'location_updated'\n | 'exit_app'\n | 'request_enable_protected_apps'\n | 'fatal_exit'\n | 'request_location_permission';\n payload: any;\n}\n"],"mappings":""}
@@ -1,2 +1,2 @@
1
-
1
+ export {};
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/**\n * Defines the structure of the user object requried by OkHi services and libraries.\n */\nexport interface OkHiUser {\n /**\n * The user's phone number. Must be MSISDN standard format. e.g +254712345678.\n */\n phone: string;\n /**\n * The user's first name.\n */\n firstName?: string;\n /**\n * The user's last name.\n */\n lastName?: string;\n /**\n * The user's email address.\n */\n email?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n id?: string;\n\n /**\n * The user's device firebase push notification token.\n */\n fcmPushNotificationToken?: string;\n}\n\n/**\n * Defines the current mode you'll be using OkHi's services as well as your application's meta information.\n */\nexport interface OkHiAppContext {\n /**\n * The current mode you'll be using OkHi services.\n */\n mode: 'sandbox' | 'prod' | string;\n /**\n * Your application's meta information.\n */\n app?: {\n /**\n * Your application's name.\n */\n name: string;\n /**\n * Your application's current version.\n */\n version: string;\n /**\n * Your application's current build number.\n */\n build: number;\n };\n /**\n * Meta information about the current developer.\n */\n developer?: string;\n}\n\n/**\n * Defines the structure of the OkHi location object once an address has been successfully created by the user.\n */\nexport interface OkHiLocation {\n /**\n * The latitude of the location.\n */\n lat: number;\n /**\n * The longitude of the location.\n */\n lon: number;\n /**\n * The OkHi's locationId. Usually obtained once an address has been successfully created by the user.\n */\n id?: string;\n /**\n * The id of a common residential or geological space such as apartment building or office block.\n */\n placeId?: string;\n /**\n * Geocode system for identifying an area anywhere on the Earth.\n * See https://plus.codes/\n */\n plusCode?: string;\n /**\n * The location's property name.\n */\n propertyName?: string;\n /**\n * The location's street name.\n */\n streetName?: string;\n /**\n * A string that can be used to render information about the location.\n */\n title?: string;\n /**\n * A string that can be used to render meta information about the location.\n */\n subtitle?: string;\n /**\n * User generated directions to the location.\n */\n directions?: string;\n /**\n * User generated meta information about the location, how to access it and any other relevant notes.\n */\n otherInformation?: string;\n /**\n * A link to the user's address visible on browser or desktop.\n */\n url?: string;\n /**\n * A Google's StreetView Panorama Id, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoId?: string;\n /**\n * A Google's StreetView Panorama Url, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoUrl?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n userId?: string;\n /**\n * The location's property number.\n */\n propertyNumber?: string;\n /**\n * A link to the location's gate photo.\n */\n photo?: string;\n\n /**\n * A user's country\n */\n country?: string;\n\n /**\n * A user's city\n */\n city?: string;\n\n /**\n * A user's state\n */\n state?: string;\n\n /**\n * A formatted location information\n */\n displayTitle?: string;\n\n /**\n * A user's country code\n */\n countryCode?: string;\n}\n\n/**\n * @ignore\n */\nexport interface OkHiError {\n code: string;\n message: string;\n}\n\nexport type OkHiApplicationConfiguration = {\n credentials: {\n branchId: string;\n clientKey: string;\n };\n context: {\n mode: 'sandbox' | 'prod';\n developer?: 'okhi' | 'external';\n };\n app?: {\n name?: string;\n version?: string;\n build?: string;\n };\n notification?: {\n title: string;\n text: string;\n channelId: string;\n channelName: string;\n channelDescription: string;\n };\n};\n\nexport type LocationPermissionStatus =\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown';\n\nexport type LocationPermissionStatusCallback =\n | LocationPermissionStatus\n | 'rationaleDissmissed';\nexport type LocationRequestPermissionType = 'whenInUse' | 'always';\n\nexport type LocationPermissionCallback = (\n status: LocationPermissionStatusCallback | null,\n error: OkHiError | null\n) => any;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { OkHiException } from './OkHiException';\n\n/**\n * Defines the structure of the user object requried by OkHi services and libraries.\n */\nexport interface OkHiUser {\n /**\n * The user's phone number. Must be MSISDN standard format. e.g +254712345678.\n */\n phone: string;\n /**\n * The user's first name.\n */\n firstName?: string;\n /**\n * The user's last name.\n */\n lastName?: string;\n /**\n * The user's email address.\n */\n email?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n id?: string;\n\n /**\n * The user's device firebase push notification token.\n */\n fcmPushNotificationToken?: string;\n}\n\n/**\n * Defines the current mode you'll be using OkHi's services as well as your application's meta information.\n */\nexport interface OkHiAppContext {\n /**\n * The current mode you'll be using OkHi services.\n */\n mode: 'sandbox' | 'prod' | string;\n /**\n * Your application's meta information.\n */\n app?: {\n /**\n * Your application's name.\n */\n name: string;\n /**\n * Your application's current version.\n */\n version: string;\n /**\n * Your application's current build number.\n */\n build: number;\n };\n /**\n * Meta information about the current developer.\n */\n developer?: string;\n}\n\n/**\n * Defines the structure of the OkHi location object once an address has been successfully created by the user.\n */\nexport interface OkHiLocation {\n /**\n * The latitude of the location.\n */\n lat: number;\n /**\n * The longitude of the location.\n */\n lon: number;\n /**\n * The OkHi's locationId. Usually obtained once an address has been successfully created by the user.\n */\n id?: string;\n /**\n * The id of a common residential or geological space such as apartment building or office block.\n */\n placeId?: string;\n /**\n * Geocode system for identifying an area anywhere on the Earth.\n * See https://plus.codes/\n */\n plusCode?: string;\n /**\n * The location's property name.\n */\n propertyName?: string;\n /**\n * The location's street name.\n */\n streetName?: string;\n /**\n * A string that can be used to render information about the location.\n */\n title?: string;\n /**\n * A string that can be used to render meta information about the location.\n */\n subtitle?: string;\n /**\n * User generated directions to the location.\n */\n directions?: string;\n /**\n * User generated meta information about the location, how to access it and any other relevant notes.\n */\n otherInformation?: string;\n /**\n * A link to the user's address visible on browser or desktop.\n */\n url?: string;\n /**\n * A Google's StreetView Panorama Id, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoId?: string;\n /**\n * A Google's StreetView Panorama Url, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoUrl?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n userId?: string;\n /**\n * The location's property number.\n */\n propertyNumber?: string;\n /**\n * A link to the location's gate photo.\n */\n photo?: string;\n\n /**\n * A user's country\n */\n country?: string;\n\n /**\n * A user's city\n */\n city?: string;\n\n /**\n * A user's state\n */\n state?: string;\n\n /**\n * A formatted location information\n */\n displayTitle?: string;\n\n /**\n * A user's country code\n */\n countryCode?: string;\n}\n\n/**\n * @ignore\n */\nexport interface OkHiError {\n code: string;\n message: string;\n}\n\nexport type OkHiApplicationConfiguration = {\n credentials: {\n branchId: string;\n clientKey: string;\n };\n context: {\n mode: 'sandbox' | 'prod';\n developer?: 'okhi' | 'external';\n };\n app?: {\n name?: string;\n version?: string;\n build?: string;\n };\n notification?: {\n title: string;\n text: string;\n channelId: string;\n channelName: string;\n channelDescription: string;\n };\n};\n\nexport type LocationPermissionStatus =\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown';\n\nexport type LocationPermissionStatusCallback =\n | LocationPermissionStatus\n | 'rationaleDissmissed';\nexport type LocationRequestPermissionType = 'whenInUse' | 'always';\n\nexport type LocationPermissionCallback = (\n status: LocationPermissionStatusCallback | null,\n error: OkHiException | null\n) => any;\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","OkHiNativeModule","Okhi","Proxy","get","Error","OkHiNativeEvents","addListener"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, NativeEventEmitter, Platform } from 'react-native';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\nconst LINKING_ERROR =\n `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype OkHiNativeModuleType = {\n isLocationServicesEnabled(): Promise<boolean>;\n isLocationPermissionGranted(): Promise<boolean>;\n isBackgroundLocationPermissionGranted(): Promise<boolean>;\n requestLocationPermission(): Promise<boolean>;\n requestBackgroundLocationPermission(): Promise<boolean>;\n requestEnableLocationServices(): Promise<boolean>;\n isGooglePlayServicesAvailable(): Promise<boolean>;\n requestEnableGooglePlayServices(): Promise<boolean>;\n getSystemVersion(): Promise<number | string>;\n getAuthToken(branchId: string, clientKey: string): Promise<string>;\n initialize(configuration: string): Promise<void>;\n startAddressVerification(\n phoneNumber: string,\n locationId: string,\n lat: Number,\n lon: Number,\n configuration?: OkVerifyStartConfiguration,\n fcmPushNotificationToken?: string\n ): Promise<string>;\n stopAddressVerification(\n phoneNumber: string,\n locationId: string\n ): Promise<string>;\n startForegroundService(): Promise<boolean>;\n stopForegroundService(): Promise<boolean>;\n isForegroundServiceRunning(): Promise<boolean>;\n initializeIOS(\n branchId: string,\n clientKey: string,\n environment: string\n ): Promise<boolean>;\n openAppSettings(): Promise<void>;\n retriveLocationPermissionStatus(): Promise<string>;\n requestTrackingAuthorization(): Promise<string | null>;\n canOpenProtectedAppsSettings(): Promise<boolean>;\n openProtectedAppsSettings(): Promise<boolean>;\n retrieveDeviceInfo(): Promise<{ manufacturer: string; model: string }>;\n setItem(key: string, value: string): Promise<boolean>;\n onNewToken(fcmPushNotificationToken: string): Promise<boolean>;\n onMessageReceived(): Promise<boolean>;\n isNotificationPermissionGranted(): Promise<boolean>;\n requestNotificationPermission(): Promise<boolean>;\n fetchCurrentLocation(): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n }>;\n fetchIOSLocationPermissionStatus(): Promise<\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown'\n >;\n};\n\nexport const OkHiNativeModule: OkHiNativeModuleType = NativeModules.Okhi\n ? NativeModules.Okhi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const OkHiNativeEvents = new NativeEventEmitter(NativeModules.Okhi);\n\nOkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,kBAAxB,EAA4CC,QAA5C,QAA4D,cAA5D;AAGA,MAAMC,aAAa,GAChB,4EAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAiEA,OAAO,MAAMC,gBAAsC,GAAGP,aAAa,CAACQ,IAAd,GAClDR,aAAa,CAACQ,IADoC,GAElD,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUR,aAAV,CAAN;EACD;;AAHH,CAFF,CAFG;AAWP,OAAO,MAAMS,gBAAgB,GAAG,IAAIX,kBAAJ,CAAuBD,aAAa,CAACQ,IAArC,CAAzB;AAEPI,gBAAgB,CAACC,WAAjB,CAA6B,kCAA7B,EAAiE,MAAM,IAAvE"}
1
+ {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","OkHiNativeModule","Okhi","Proxy","get","Error","OkHiNativeEvents","addListener"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, NativeEventEmitter, Platform } from 'react-native';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\nconst LINKING_ERROR =\n `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype OkHiNativeModuleType = {\n isLocationServicesEnabled(): Promise<boolean>;\n isLocationPermissionGranted(): Promise<boolean>;\n isBackgroundLocationPermissionGranted(): Promise<boolean>;\n requestLocationPermission(): Promise<boolean>;\n requestBackgroundLocationPermission(): Promise<boolean>;\n requestEnableLocationServices(): Promise<boolean>;\n isGooglePlayServicesAvailable(): Promise<boolean>;\n requestEnableGooglePlayServices(): Promise<boolean>;\n getSystemVersion(): Promise<number | string>;\n getAuthToken(branchId: string, clientKey: string): Promise<string>;\n initialize(configuration: string): Promise<void>;\n startAddressVerification(\n phoneNumber: string,\n locationId: string,\n lat: Number,\n lon: Number,\n configuration?: OkVerifyStartConfiguration,\n fcmPushNotificationToken?: string\n ): Promise<string>;\n stopAddressVerification(\n phoneNumber: string,\n locationId: string\n ): Promise<string>;\n startForegroundService(): Promise<boolean>;\n stopForegroundService(): Promise<boolean>;\n isForegroundServiceRunning(): Promise<boolean>;\n initializeIOS(\n branchId: string,\n clientKey: string,\n environment: string\n ): Promise<boolean>;\n openAppSettings(): Promise<void>;\n retriveLocationPermissionStatus(): Promise<string>;\n requestTrackingAuthorization(): Promise<string | null>;\n canOpenProtectedAppsSettings(): Promise<boolean>;\n openProtectedAppsSettings(): Promise<boolean>;\n retrieveDeviceInfo(): Promise<{\n manufacturer: string;\n model: string;\n osVersion: string;\n platform: 'android' | 'ios';\n }>;\n setItem(key: string, value: string): Promise<boolean>;\n onNewToken(fcmPushNotificationToken: string): Promise<boolean>;\n onMessageReceived(): Promise<boolean>;\n isNotificationPermissionGranted(): Promise<boolean>;\n requestNotificationPermission(): Promise<boolean>;\n fetchCurrentLocation(): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n }>;\n fetchIOSLocationPermissionStatus(): Promise<\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown'\n >;\n};\n\nexport const OkHiNativeModule: OkHiNativeModuleType = NativeModules.Okhi\n ? NativeModules.Okhi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const OkHiNativeEvents = new NativeEventEmitter(NativeModules.Okhi);\n\nOkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,kBAAxB,EAA4CC,QAA5C,QAA4D,cAA5D;AAGA,MAAMC,aAAa,GAChB,4EAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAsEA,OAAO,MAAMC,gBAAsC,GAAGP,aAAa,CAACQ,IAAd,GAClDR,aAAa,CAACQ,IADoC,GAElD,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUR,aAAV,CAAN;EACD;;AAHH,CAFF,CAFG;AAWP,OAAO,MAAMS,gBAAgB,GAAG,IAAIX,kBAAJ,CAAuBD,aAAa,CAACQ,IAArC,CAAzB;AAEPI,gBAAgB,CAACC,WAAjB,CAA6B,kCAA7B,EAAiE,MAAM,IAAvE"}
@@ -76,6 +76,7 @@ export interface OkHiLocationManagerProps {
76
76
  home?: boolean;
77
77
  work?: boolean;
78
78
  };
79
+ permissionsOnboarding?: boolean;
79
80
  };
80
81
  /**
81
82
  * **Optional:** Enable a user to either select an existing address, or force to create a new one
@@ -129,9 +130,6 @@ export declare type OkHiLocationManagerStartMessage = 'select_location' | 'start
129
130
  * @ignore
130
131
  */
131
132
  export interface OkHiLocationManagerResponse {
132
- message: 'location_selected' | 'location_created' | 'location_updated' | 'exit_app' | 'request_enable_protected_apps' | 'fatal_exit';
133
- payload: {
134
- user: any;
135
- location: any;
136
- };
133
+ message: 'location_selected' | 'location_created' | 'location_updated' | 'exit_app' | 'request_enable_protected_apps' | 'fatal_exit' | 'request_location_permission';
134
+ payload: any;
137
135
  }
@@ -1,3 +1,4 @@
1
+ import type { OkHiException } from './OkHiException';
1
2
  /**
2
3
  * Defines the structure of the user object requried by OkHi services and libraries.
3
4
  */
@@ -185,4 +186,4 @@ export declare type OkHiApplicationConfiguration = {
185
186
  export declare type LocationPermissionStatus = 'notDetermined' | 'restricted' | 'denied' | 'authorizedAlways' | 'authorizedWhenInUse' | 'authorized' | 'unknown';
186
187
  export declare type LocationPermissionStatusCallback = LocationPermissionStatus | 'rationaleDissmissed';
187
188
  export declare type LocationRequestPermissionType = 'whenInUse' | 'always';
188
- export declare type LocationPermissionCallback = (status: LocationPermissionStatusCallback | null, error: OkHiError | null) => any;
189
+ export declare type LocationPermissionCallback = (status: LocationPermissionStatusCallback | null, error: OkHiException | null) => any;
@@ -26,6 +26,8 @@ declare type OkHiNativeModuleType = {
26
26
  retrieveDeviceInfo(): Promise<{
27
27
  manufacturer: string;
28
28
  model: string;
29
+ osVersion: string;
30
+ platform: 'android' | 'ios';
29
31
  }>;
30
32
  setItem(key: string, value: string): Promise<boolean>;
31
33
  onNewToken(fcmPushNotificationToken: string): Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-okhi",
3
- "version": "1.2.2",
3
+ "version": "1.2.3-beta.2",
4
4
  "description": "The OkHi React Native library enables you to collect and verify addresses from your users",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -20,7 +20,12 @@ import { start as sv } from '../OkVerify';
20
20
  import type { OkVerifyStartConfiguration } from '../OkVerify/types';
21
21
  import {
22
22
  getApplicationConfiguration,
23
+ isBackgroundLocationPermissionGranted,
24
+ isLocationServicesEnabled,
25
+ openAppSettings,
23
26
  openProtectedAppsSettings,
27
+ request,
28
+ requestLocationPermission,
24
29
  } from '../OkCore';
25
30
  import { OkHiNativeModule } from '../OkHiNativeModule';
26
31
 
@@ -92,6 +97,72 @@ export const OkHiLocationManager = (props: OkHiLocationManagerProps) => {
92
97
  }
93
98
  }, [applicationConfiguration, props, token]);
94
99
 
100
+ const runWebViewCallback = (value: string) => {
101
+ if (webViewRef.current) {
102
+ const jsString = `(function (){ if (typeof runOkHiLocationManagerCallback === "function") { runOkHiLocationManagerCallback("${value}") } })()`;
103
+ webViewRef.current.injectJavaScript(jsString);
104
+ }
105
+ };
106
+
107
+ const handleAndroidRequestLocationPermission = async (
108
+ level: 'whenInUse' | 'always'
109
+ ) => {
110
+ // using request for android because we can programmatically turn on location services, unlike yucky ios
111
+ request(level, null, (status, error) => {
112
+ if (error) {
113
+ onError(error);
114
+ } else if (level === 'whenInUse' && status === 'authorizedWhenInUse') {
115
+ runWebViewCallback(level);
116
+ } else if (level === 'always' && status === 'authorizedAlways') {
117
+ runWebViewCallback(level);
118
+ }
119
+ });
120
+ };
121
+
122
+ const handleIOSRequestLocationPermission = async (
123
+ level: 'whenInUse' | 'always'
124
+ ) => {
125
+ const serviceError = new OkHiException({
126
+ code: OkHiException.SERVICE_UNAVAILABLE_CODE,
127
+ message:
128
+ 'Location service is currently not available. Please enable in app settings',
129
+ });
130
+ const unknownError = new OkHiException({
131
+ code: OkHiException.UNKNOWN_ERROR_CODE,
132
+ message:
133
+ 'Something went wrong while requesting permissions. Please try again later.',
134
+ });
135
+ try {
136
+ const isServiceAvailable = await isLocationServicesEnabled();
137
+ if (!isServiceAvailable) {
138
+ onError(serviceError);
139
+ } else if (level === 'whenInUse' && (await requestLocationPermission())) {
140
+ runWebViewCallback(level);
141
+ } else if (level === 'always') {
142
+ const granted = await isBackgroundLocationPermissionGranted();
143
+ if (granted) {
144
+ runWebViewCallback(level);
145
+ } else {
146
+ openAppSettings();
147
+ }
148
+ }
149
+ } catch (error) {
150
+ onError(unknownError);
151
+ }
152
+ };
153
+
154
+ const handleRequestLocationPermission = async ({
155
+ level,
156
+ }: {
157
+ level: 'whenInUse' | 'always';
158
+ }) => {
159
+ if (Platform.OS === 'android') {
160
+ handleAndroidRequestLocationPermission(level);
161
+ } else if (Platform.OS === 'ios') {
162
+ handleIOSRequestLocationPermission(level);
163
+ }
164
+ };
165
+
95
166
  const handleOnMessage = ({ nativeEvent: { data } }: WebViewMessageEvent) => {
96
167
  try {
97
168
  const response: OkHiLocationManagerResponse = JSON.parse(data);
@@ -99,14 +170,18 @@ export const OkHiLocationManager = (props: OkHiLocationManagerProps) => {
99
170
  onError(
100
171
  new OkHiException({
101
172
  code: OkHiException.UNKNOWN_ERROR_CODE,
102
- message: response.payload.toString(),
173
+ message: 'Something went wrong, please try again later.',
103
174
  })
104
175
  );
105
176
  } else if (response.message === 'exit_app') {
106
177
  onCloseRequest();
107
178
  } else if (response.message === 'request_enable_protected_apps') {
108
179
  openProtectedAppsSettings();
109
- } else {
180
+ } else if (
181
+ response.message === 'location_created' ||
182
+ response.message === 'location_selected' ||
183
+ response.message === 'location_updated'
184
+ ) {
110
185
  onSuccess({
111
186
  user: {
112
187
  ...response.payload.user,
@@ -139,6 +214,8 @@ export const OkHiLocationManager = (props: OkHiLocationManagerProps) => {
139
214
  });
140
215
  },
141
216
  });
217
+ } else if (response.message === 'request_location_permission') {
218
+ handleRequestLocationPermission(response.payload);
142
219
  }
143
220
  } catch (error) {
144
221
  let errorMessage = 'Something went wrong';
@@ -34,6 +34,8 @@ export const generateStartDataPayload = async (
34
34
  applicationConfiguration: AuthApplicationConfig
35
35
  ): Promise<OkHiLocationManagerStartDataPayload> => {
36
36
  const payload: any = {};
37
+ const { manufacturer, model, osVersion, platform } =
38
+ await OkHiNativeModule.retrieveDeviceInfo();
37
39
  payload.style = !props.theme
38
40
  ? undefined
39
41
  : {
@@ -67,6 +69,12 @@ export const generateStartDataPayload = async (
67
69
  platform: {
68
70
  name: 'react-native',
69
71
  },
72
+ device: {
73
+ manufacturer,
74
+ model,
75
+ platform,
76
+ osVersion,
77
+ },
70
78
  };
71
79
  payload.config = {
72
80
  streetView:
@@ -89,34 +97,36 @@ export const generateStartDataPayload = async (
89
97
  },
90
98
  protectedApps:
91
99
  Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),
100
+ permissionsOnboarding:
101
+ typeof props.config?.permissionsOnboarding === 'boolean'
102
+ ? props.config.permissionsOnboarding
103
+ : true,
92
104
  };
93
105
 
94
106
  if (Platform.OS === 'ios') {
95
107
  const status = await OkHiNativeModule.fetchIOSLocationPermissionStatus();
96
- if (status !== 'notDetermined') {
97
- payload.context.permissions = {
98
- location:
99
- status === 'authorizedWhenInUse'
100
- ? 'whenInUse'
101
- : status === 'authorizedAlways' || status === 'authorized'
102
- ? 'always'
103
- : 'denided',
104
- };
105
- if (
106
- status === 'authorized' ||
107
- status === 'authorizedWhenInUse' ||
108
- status === 'authorizedAlways'
109
- ) {
110
- const location = await fetchCurrentLocation();
111
- if (location) {
112
- payload.context.coordinates = {
113
- currentLocation: {
114
- lat: location.lat,
115
- lng: location.lng,
116
- accuracy: location.accuracy,
117
- },
118
- };
119
- }
108
+ payload.context.permissions = {
109
+ location:
110
+ status === 'authorizedWhenInUse'
111
+ ? 'whenInUse'
112
+ : status === 'authorizedAlways' || status === 'authorized'
113
+ ? 'always'
114
+ : 'denied',
115
+ };
116
+ if (
117
+ status === 'authorized' ||
118
+ status === 'authorizedWhenInUse' ||
119
+ status === 'authorizedAlways'
120
+ ) {
121
+ const location = await fetchCurrentLocation();
122
+ if (location) {
123
+ payload.context.coordinates = {
124
+ currentLocation: {
125
+ lat: location.lat,
126
+ lng: location.lng,
127
+ accuracy: location.accuracy,
128
+ },
129
+ };
120
130
  }
121
131
  }
122
132
  } else if (Platform.OS === 'android') {
@@ -147,11 +157,6 @@ export const generateStartDataPayload = async (
147
157
  : 'denied',
148
158
  };
149
159
  }
150
- const { manufacturer, model } = await OkHiNativeModule.retrieveDeviceInfo();
151
- payload.context.device = {
152
- manufacturer,
153
- model,
154
- };
155
160
  } else {
156
161
  throw new OkHiException({
157
162
  code: OkHiException.UNSUPPORTED_PLATFORM_CODE,
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "okhiWebReactNative",
3
- "version": "1.2.2"
3
+ "version": "1.2.3-beta.2"
4
4
  }