react-native-okhi 1.2.3-beta.8 → 1.2.4

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.
Files changed (32) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +0 -2
  3. package/ios/Okhi.m +0 -1
  4. package/ios/Okhi.swift +0 -24
  5. package/lib/commonjs/OkCollect/OkHiLocationManager.js +7 -100
  6. package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +1 -1
  7. package/lib/commonjs/OkCollect/Util.js +25 -29
  8. package/lib/commonjs/OkCollect/Util.js.map +1 -1
  9. package/lib/commonjs/OkCollect/app.json +1 -1
  10. package/lib/commonjs/OkCollect/types.js.map +1 -1
  11. package/lib/commonjs/OkCore/types.js +0 -4
  12. package/lib/commonjs/OkCore/types.js.map +1 -1
  13. package/lib/commonjs/OkHiNativeModule/index.js.map +1 -1
  14. package/lib/module/OkCollect/OkHiLocationManager.js +8 -101
  15. package/lib/module/OkCollect/OkHiLocationManager.js.map +1 -1
  16. package/lib/module/OkCollect/Util.js +25 -29
  17. package/lib/module/OkCollect/Util.js.map +1 -1
  18. package/lib/module/OkCollect/app.json +1 -1
  19. package/lib/module/OkCollect/types.js.map +1 -1
  20. package/lib/module/OkCore/types.js +1 -1
  21. package/lib/module/OkCore/types.js.map +1 -1
  22. package/lib/module/OkHiNativeModule/index.js.map +1 -1
  23. package/lib/typescript/OkCollect/types.d.ts +5 -3
  24. package/lib/typescript/OkCore/types.d.ts +1 -2
  25. package/lib/typescript/OkHiNativeModule/index.d.ts +0 -2
  26. package/package.json +1 -1
  27. package/src/OkCollect/OkHiLocationManager.tsx +5 -127
  28. package/src/OkCollect/Util.ts +29 -37
  29. package/src/OkCollect/app.json +1 -1
  30. package/src/OkCollect/types.ts +2 -4
  31. package/src/OkCore/types.ts +1 -3
  32. package/src/OkHiNativeModule/index.ts +1 -6
@@ -6,7 +6,7 @@ import { getFrameUrl, generateJavaScriptStartScript, generateStartDataPayload, p
6
6
  import { OkHiException } from '../OkCore/OkHiException';
7
7
  import { OkHiAuth } from '../OkCore/OkHiAuth';
8
8
  import { start as sv } from '../OkVerify';
9
- import { getApplicationConfiguration, isBackgroundLocationPermissionGranted, isLocationPermissionGranted, isLocationServicesEnabled, openAppSettings, openProtectedAppsSettings, requestBackgroundLocationPermission, requestLocationPermission } from '../OkCore';
9
+ import { getApplicationConfiguration, openProtectedAppsSettings } from '../OkCore';
10
10
  import { OkHiNativeModule } from '../OkHiNativeModule';
11
11
 
12
12
  /**
@@ -29,12 +29,10 @@ export const OkHiLocationManager = props => {
29
29
  onCloseRequest,
30
30
  onError,
31
31
  loader,
32
- launch,
33
- config
32
+ launch
34
33
  } = props;
35
34
  const webViewRef = useRef(null);
36
35
  const startMessage = props.mode === 'create' ? 'start_app' : 'select_location';
37
- const [ready, setReady] = useState(false);
38
36
  useEffect(() => {
39
37
  if (applicationConfiguration == null && token == null && user.phone) {
40
38
  getApplicationConfiguration().then(config => {
@@ -70,111 +68,24 @@ export const OkHiLocationManager = props => {
70
68
  }).catch(console.error);
71
69
  }
72
70
  }, [applicationConfiguration, props, token]);
73
- useEffect(() => {
74
- if (launch) {
75
- if (typeof (config === null || config === void 0 ? void 0 : config.permissionsOnboarding) === 'boolean' && !config.permissionsOnboarding) {
76
- isBackgroundLocationPermissionGranted().then(result => {
77
- if (!result) {
78
- onError(new OkHiException({
79
- code: OkHiException.PERMISSION_DENIED_CODE,
80
- message: 'Always location permission must be granted to launch OkCollect'
81
- }));
82
- } else {
83
- setReady(true);
84
- }
85
- });
86
- } else {
87
- setReady(true);
88
- }
89
- } else {
90
- setReady(false);
91
- }
92
- }, [launch, config === null || config === void 0 ? void 0 : config.permissionsOnboarding]);
93
- const runWebViewCallback = value => {
94
- if (webViewRef.current) {
95
- const jsString = `(function (){ if (typeof runOkHiLocationManagerCallback === "function") { runOkHiLocationManagerCallback("${value}") } })()`;
96
- webViewRef.current.injectJavaScript(jsString);
97
- }
98
- };
99
- const handleAndroidRequestLocationPermission = async level => {
100
- if (level === 'whenInUse') {
101
- const result = await requestLocationPermission();
102
- runWebViewCallback(result ? 'whenInUse' : 'denied');
103
- } else if (level === 'always') {
104
- const result = await requestBackgroundLocationPermission();
105
- if (result) {
106
- runWebViewCallback('always');
107
- } else {
108
- const isWhenInUseGranted = await isLocationPermissionGranted();
109
- runWebViewCallback(isWhenInUseGranted ? 'whenInUse' : 'denied');
110
- }
111
- }
112
- };
113
- const handleIOSRequestLocationPermission = async level => {
114
- const unknownError = new OkHiException({
115
- code: OkHiException.UNKNOWN_ERROR_CODE,
116
- message: 'Something went wrong while requesting permissions. Please try again later.'
117
- });
118
- try {
119
- const isServiceAvailable = await isLocationServicesEnabled();
120
- if (!isServiceAvailable) {
121
- openAppSettings();
122
- } else if (level === 'whenInUse') {
123
- const result = await requestLocationPermission();
124
- runWebViewCallback(result ? level : 'denied');
125
- } else if (level === 'always') {
126
- const granted = await isBackgroundLocationPermissionGranted();
127
- if (granted) {
128
- runWebViewCallback(level);
129
- } else {
130
- openAppSettings();
131
- }
132
- }
133
- } catch (error) {
134
- onError(unknownError);
135
- }
136
- };
137
- const handleRequestLocationPermission = async _ref => {
138
- let {
139
- level
140
- } = _ref;
141
- if (Platform.OS === 'android') {
142
- handleAndroidRequestLocationPermission(level);
143
- } else if (Platform.OS === 'ios') {
144
- handleIOSRequestLocationPermission(level);
145
- }
146
- };
147
- const handleOpenAppSettings = async () => {
148
- try {
149
- const granted = await isBackgroundLocationPermissionGranted();
150
- if (granted) {
151
- runWebViewCallback('always');
152
- } else {
153
- await openAppSettings();
154
- }
155
- } catch (error) {
156
- const err = error;
157
- onError(err);
158
- }
159
- };
160
- const handleOnMessage = _ref2 => {
71
+ const handleOnMessage = _ref => {
161
72
  let {
162
73
  nativeEvent: {
163
74
  data
164
75
  }
165
- } = _ref2;
76
+ } = _ref;
166
77
  try {
167
78
  const response = JSON.parse(data);
168
79
  if (response.message === 'fatal_exit') {
169
80
  onError(new OkHiException({
170
81
  code: OkHiException.UNKNOWN_ERROR_CODE,
171
- message: 'Something went wrong, please try again later.'
82
+ message: response.payload.toString()
172
83
  }));
173
84
  } else if (response.message === 'exit_app') {
174
85
  onCloseRequest();
175
86
  } else if (response.message === 'request_enable_protected_apps') {
176
87
  openProtectedAppsSettings();
177
- } else if (response.message === 'location_created' || response.message === 'location_selected' || response.message === 'location_updated') {
88
+ } else {
178
89
  onSuccess({
179
90
  user: {
180
91
  ...response.payload.user,
@@ -200,10 +111,6 @@ export const OkHiLocationManager = props => {
200
111
  });
201
112
  }
202
113
  });
203
- } else if (response.message === 'request_location_permission') {
204
- handleRequestLocationPermission(response.payload);
205
- } else if (response.message === 'open_app_settings') {
206
- handleOpenAppSettings();
207
114
  }
208
115
  } catch (error) {
209
116
  let errorMessage = 'Something went wrong';
@@ -259,9 +166,9 @@ export const OkHiLocationManager = props => {
259
166
  return /*#__PURE__*/React.createElement(Modal, {
260
167
  animationType: "slide",
261
168
  transparent: false,
262
- visible: ready,
169
+ visible: launch,
263
170
  onRequestClose: handleModalRequestClose
264
- }, ready ? renderContent() : null);
171
+ }, launch ? renderContent() : null);
265
172
  };
266
173
  export default OkHiLocationManager;
267
174
  //# sourceMappingURL=OkHiLocationManager.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useState","useEffect","useRef","Modal","SafeAreaView","Platform","WebView","Spinner","getFrameUrl","generateJavaScriptStartScript","generateStartDataPayload","parseOkHiLocation","OkHiException","OkHiAuth","start","sv","getApplicationConfiguration","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","isLocationServicesEnabled","openAppSettings","openProtectedAppsSettings","requestBackgroundLocationPermission","requestLocationPermission","OkHiNativeModule","OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","startPayload","setStartPaylaod","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","config","webViewRef","startMessage","mode","ready","setReady","phone","then","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","auth","anonymousSignInWithPhoneNumber","catch","error","OS","Version","setItem","JSON","stringify","payload","url","console","permissionsOnboarding","result","PERMISSION_DENIED_CODE","runWebViewCallback","value","current","jsString","injectJavaScript","handleAndroidRequestLocationPermission","level","isWhenInUseGranted","handleIOSRequestLocationPermission","unknownError","UNKNOWN_ERROR_CODE","isServiceAvailable","granted","handleRequestLocationPermission","_ref","handleOpenAppSettings","err","handleOnMessage","_ref2","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","_webViewRef$current","goBack","renderContent","createElement","jsAfterLoad","jsBeforeLoad","source","uri","injectedJavaScriptBeforeContentLoaded","undefined","injectedJavaScript","onMessage","onHttpError","geolocationEnabled","allowsBackForwardNavigationGestures","ref","animationType","transparent","visible","onRequestClose"],"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 isLocationPermissionGranted,\n isLocationServicesEnabled,\n openAppSettings,\n openProtectedAppsSettings,\n requestBackgroundLocationPermission,\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, config } =\n props;\n const webViewRef = useRef<WebView | null>(null);\n const startMessage =\n props.mode === 'create' ? 'start_app' : 'select_location';\n const [ready, setReady] = useState(false);\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 useEffect(() => {\n if (launch) {\n if (\n typeof config?.permissionsOnboarding === 'boolean' &&\n !config.permissionsOnboarding\n ) {\n isBackgroundLocationPermissionGranted().then((result) => {\n if (!result) {\n onError(\n new OkHiException({\n code: OkHiException.PERMISSION_DENIED_CODE,\n message:\n 'Always location permission must be granted to launch OkCollect',\n })\n );\n } else {\n setReady(true);\n }\n });\n } else {\n setReady(true);\n }\n } else {\n setReady(false);\n }\n }, [launch, config?.permissionsOnboarding]);\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 if (level === 'whenInUse') {\n const result = await requestLocationPermission();\n runWebViewCallback(result ? 'whenInUse' : 'denied');\n } else if (level === 'always') {\n const result = await requestBackgroundLocationPermission();\n if (result) {\n runWebViewCallback('always');\n } else {\n const isWhenInUseGranted = await isLocationPermissionGranted();\n runWebViewCallback(isWhenInUseGranted ? 'whenInUse' : 'denied');\n }\n }\n };\n\n const handleIOSRequestLocationPermission = async (\n level: 'whenInUse' | 'always'\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 openAppSettings();\n } else if (level === 'whenInUse') {\n const result = await requestLocationPermission();\n runWebViewCallback(result ? level : 'denied');\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 handleOpenAppSettings = async () => {\n try {\n const granted = await isBackgroundLocationPermissionGranted();\n if (granted) {\n runWebViewCallback('always');\n } else {\n await openAppSettings();\n }\n } catch (error) {\n const err = error as OkHiException;\n onError(err);\n }\n };\n\n const handleOnMessage = ({ nativeEvent: { data } }: WebViewMessageEvent) => {\n try {\n const response: OkHiLocationManagerResponse = JSON.parse(data);\n\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 } else if (response.message === 'open_app_settings') {\n handleOpenAppSettings();\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={ready}\n onRequestClose={handleModalRequestClose}\n >\n {ready ? renderContent() : null}\n </Modal>\n );\n};\n\nexport default OkHiLocationManager;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAC1D,SAASC,KAAK,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,cAAc;AAC5D,SAASC,OAAO,QAA6B,sBAAsB;AACnE,SAASC,OAAO,QAAQ,WAAW;AAMnC,SACEC,WAAW,EACXC,6BAA6B,EAC7BC,wBAAwB,EACxBC,iBAAiB,QACZ,QAAQ;AACf,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAE7C,SAASC,KAAK,IAAIC,EAAE,QAAQ,aAAa;AAEzC,SACEC,2BAA2B,EAC3BC,qCAAqC,EACrCC,2BAA2B,EAC3BC,yBAAyB,EACzBC,eAAe,EACfC,yBAAyB,EACzBC,mCAAmC,EACnCC,yBAAyB,QACpB,WAAW;AAClB,SAASC,gBAAgB,QAAQ,qBAAqB;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAIC,KAA+B,IAAK;EACtE,MAA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AW,EAAEhB,aAAc;MAC3BiB,kBAAkB,EAAE,IAAK;MACzBC,mCAAmC,EAAE,IAAK;MAC1CC,GAAG,EAAEjF;IAAW,CACjB,CACW,CAAC;EAEnB,CAAC;EAED,oBACE5C,KAAA,CAAAiH,aAAA,CAAC7G,KAAK;IACJ0H,aAAa,EAAC,OAAO;IACrBC,WAAW,EAAE,KAAM;IACnBC,OAAO,EAAEjF,KAAM;IACfkF,cAAc,EAAEpB;EAAwB,GAEvC9D,KAAK,GAAGiE,aAAa,CAAC,CAAC,GAAG,IACtB,CAAC;AAEZ,CAAC;AAED,eAAetF,mBAAmB"}
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","_ref","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","_webViewRef$current","current","goBack","renderContent","createElement","jsAfterLoad","jsBeforeLoad","source","uri","injectedJavaScriptBeforeContentLoaded","undefined","injectedJavaScript","onMessage","onHttpError","geolocationEnabled","allowsBackForwardNavigationGestures","ref","animationType","transparent","visible","onRequestClose"],"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,KAAK,IAAIC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAC1D,SAASC,KAAK,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,cAAc;AAC5D,SAASC,OAAO,QAA6B,sBAAsB;AACnE,SAASC,OAAO,QAAQ,WAAW;AAMnC,SACEC,WAAW,EACXC,6BAA6B,EAC7BC,wBAAwB,EACxBC,iBAAiB,QACZ,QAAQ;AACf,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAE7C,SAASC,KAAK,IAAIC,EAAE,QAAQ,aAAa;AAEzC,SACEC,2BAA2B,EAC3BC,yBAAyB,QACpB,WAAW;AAClB,SAASC,gBAAgB,QAAQ,qBAAqB;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAIC,KAA+B,IAAK;EACtE,MAAM,CAACC,KAAK,EAAEC,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ACE1B,KAAA,CAAAwF,aAAA,CAACnF,YAAY;MAACyB,KAAK,EAAEA;IAAM,gBACzB9B,KAAA,CAAAwF,aAAA,CAACjF,OAAO;MACNoF,MAAM,EAAE;QAAEC,GAAG,EAAEnF,WAAW,CAACe,wBAAwB;MAAE,CAAE;MACvDqE,qCAAqC,EACnCvF,QAAQ,CAAC6C,EAAE,KAAK,KAAK,GAAGuC,YAAY,GAAGI,SACxC;MACDC,kBAAkB,EAAEzF,QAAQ,CAAC6C,EAAE,KAAK,KAAK,GAAG2C,SAAS,GAAGL,WAAY;MACpEO,SAAS,EAAErC,eAAgB;MAC3BzB,OAAO,EAAE8C,aAAc;MACvBiB,WAAW,EAAEjB,aAAc;MAC3BkB,kBAAkB,EAAE,IAAK;MACzBC,mCAAmC,EAAE,IAAK;MAC1CC,GAAG,EAAE/D;IAAW,CACjB,CACW,CAAC;EAEnB,CAAC;EAED,oBACErC,KAAA,CAAAwF,aAAA,CAACpF,KAAK;IACJiG,aAAa,EAAC,OAAO;IACrBC,WAAW,EAAE,KAAM;IACnBC,OAAO,EAAEnE,MAAO;IAChBoE,cAAc,EAAErB;EAAwB,GAEvC/C,MAAM,GAAGmD,aAAa,CAAC,CAAC,GAAG,IACvB,CAAC;AAEZ,CAAC;AAED,eAAenE,mBAAmB"}
@@ -13,14 +13,8 @@ const fetchCurrentLocation = async () => {
13
13
  * @ignore
14
14
  */
15
15
  export const generateStartDataPayload = async (props, authToken, applicationConfiguration) => {
16
- var _props$theme, _props$theme2, _applicationConfigura, _applicationConfigura2, _applicationConfigura3, _props$config, _props$theme3, _props$config2, _props$config3, _props$config4, _props$config5, _props$config6, _props$config7;
16
+ var _props$theme, _props$theme2, _applicationConfigura, _applicationConfigura2, _applicationConfigura3, _props$config, _props$theme3, _props$config2, _props$config3, _props$config4, _props$config5, _props$config6;
17
17
  const payload = {};
18
- const {
19
- manufacturer,
20
- model,
21
- osVersion,
22
- platform
23
- } = await OkHiNativeModule.retrieveDeviceInfo();
24
18
  payload.style = !props.theme ? undefined : {
25
19
  base: {
26
20
  color: (_props$theme = props.theme) === null || _props$theme === void 0 || (_props$theme = _props$theme.colors) === null || _props$theme === void 0 ? void 0 : _props$theme.primary,
@@ -51,12 +45,6 @@ export const generateStartDataPayload = async (props, authToken, applicationConf
51
45
  },
52
46
  platform: {
53
47
  name: 'react-native'
54
- },
55
- device: {
56
- manufacturer,
57
- model,
58
- platform,
59
- osVersion
60
48
  }
61
49
  };
62
50
  payload.config = {
@@ -69,25 +57,25 @@ export const generateStartDataPayload = async (props, authToken, applicationConf
69
57
  home: typeof ((_props$config3 = props.config) === null || _props$config3 === void 0 || (_props$config3 = _props$config3.addressTypes) === null || _props$config3 === void 0 ? void 0 : _props$config3.home) === 'boolean' ? (_props$config4 = props.config) === null || _props$config4 === void 0 || (_props$config4 = _props$config4.addressTypes) === null || _props$config4 === void 0 ? void 0 : _props$config4.home : true,
70
58
  work: typeof ((_props$config5 = props.config) === null || _props$config5 === void 0 || (_props$config5 = _props$config5.addressTypes) === null || _props$config5 === void 0 ? void 0 : _props$config5.work) === 'boolean' ? (_props$config6 = props.config) === null || _props$config6 === void 0 || (_props$config6 = _props$config6.addressTypes) === null || _props$config6 === void 0 ? void 0 : _props$config6.work : true
71
59
  },
72
- protectedApps: Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),
73
- permissionsOnboarding: typeof ((_props$config7 = props.config) === null || _props$config7 === void 0 ? void 0 : _props$config7.permissionsOnboarding) === 'boolean' ? props.config.permissionsOnboarding : true
60
+ protectedApps: Platform.OS === 'android' && (await canOpenProtectedAppsSettings())
74
61
  };
75
62
  if (Platform.OS === 'ios') {
76
63
  const status = await OkHiNativeModule.fetchIOSLocationPermissionStatus();
77
- const locationPermission = status === 'notDetermined' ? 'notDetermined' : status === 'authorizedWhenInUse' ? 'whenInUse' : status === 'authorizedAlways' ? 'always' : 'denied';
78
- payload.context.permissions = {
79
- location: locationPermission
80
- };
81
- if (status === 'authorized' || status === 'authorizedWhenInUse' || status === 'authorizedAlways') {
82
- const location = await fetchCurrentLocation();
83
- if (location) {
84
- payload.context.coordinates = {
85
- currentLocation: {
86
- lat: location.lat,
87
- lng: location.lng,
88
- accuracy: location.accuracy
89
- }
90
- };
64
+ if (status !== 'notDetermined') {
65
+ payload.context.permissions = {
66
+ location: status === 'authorizedWhenInUse' ? 'whenInUse' : status === 'authorizedAlways' || status === 'authorized' ? 'always' : 'denided'
67
+ };
68
+ if (status === 'authorized' || status === 'authorizedWhenInUse' || status === 'authorizedAlways') {
69
+ const location = await fetchCurrentLocation();
70
+ if (location) {
71
+ payload.context.coordinates = {
72
+ currentLocation: {
73
+ lat: location.lat,
74
+ lng: location.lng,
75
+ accuracy: location.accuracy
76
+ }
77
+ };
78
+ }
91
79
  }
92
80
  }
93
81
  } else if (Platform.OS === 'android') {
@@ -108,6 +96,14 @@ export const generateStartDataPayload = async (props, authToken, applicationConf
108
96
  location: hasBackgroundLocationPermission ? 'always' : hasLocationPermission ? 'whenInUse' : 'denied'
109
97
  };
110
98
  }
99
+ const {
100
+ manufacturer,
101
+ model
102
+ } = await OkHiNativeModule.retrieveDeviceInfo();
103
+ payload.context.device = {
104
+ manufacturer,
105
+ model
106
+ };
111
107
  } else {
112
108
  throw new OkHiException({
113
109
  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","_props$theme","_props$theme2","_applicationConfigura","_applicationConfigura2","_applicationConfigura3","_props$config","_props$theme3","_props$config2","_props$config3","_props$config4","_props$config5","_props$config6","_props$config7","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","locationPermission","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","_location$geo_point","_location$geo_point2","_location$street_view","_location$street_view2","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 const locationPermission =\n status === 'notDetermined'\n ? 'notDetermined'\n : status === 'authorizedWhenInUse'\n ? 'whenInUse'\n : status === 'authorizedAlways'\n ? 'always'\n : 'denied';\n payload.context.permissions = {\n location: locationPermission,\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,4BAA4B,EAC5BC,qCAAqC,EACrCC,2BAA2B,EAC3BC,aAAa,QAER,WAAW;AAClB,SAASC,QAAQ,QAAQ,WAAW;AAKpC,OAAOC,QAAQ,MAAM,YAAY,CAAC,CAAC;;AAEnC,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,MAAMC,oBAAoB,GAAG,MAAAA,CAAA,KAIvB;EACJ,MAAMC,MAAM,GAAG,MAAMF,gBAAgB,CAACC,oBAAoB,CAAC,CAAC;EAC5D,OAAOC,MAAM;AACf,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG,MAAAA,CACtCC,KAA+B,EAC/BC,SAAiB,EACjBC,wBAA+C,KACE;EAAA,IAAAC,YAAA,EAAAC,aAAA,EAAAC,qBAAA,EAAAC,sBAAA,EAAAC,sBAAA,EAA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QAAQ,uBAARA,QAAQ,CAAE2D,cAAc;IACxCC,KAAK,EAAE5D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE4D,KAAK;IACtBC,YAAY,EAAE7D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE8D,aAAa;IACrCC,OAAO,EAAE/D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE+D,OAAO;IAC1BC,KAAK,EAAEhE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEgE,KAAK;IACtBC,IAAI,EAAEjE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEiE,IAAI;IACpBC,WAAW,EAAElE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEmE;EACzB,CAAC;AACH,CAAC"}
1
+ {"version":3,"names":["canOpenProtectedAppsSettings","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","OkHiException","OkHiMode","manifest","Platform","OkHiNativeModule","fetchCurrentLocation","result","generateStartDataPayload","props","authToken","applicationConfiguration","_props$theme","_props$theme2","_applicationConfigura","_applicationConfigura2","_applicationConfigura3","_props$config","_props$theme3","_props$config2","_props$config3","_props$config4","_props$config5","_props$config6","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","_location$geo_point","_location$geo_point2","_location$street_view","_location$street_view2","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,4BAA4B,EAC5BC,qCAAqC,EACrCC,2BAA2B,EAC3BC,aAAa,QAER,WAAW;AAClB,SAASC,QAAQ,QAAQ,WAAW;AAKpC,OAAOC,QAAQ,MAAM,YAAY,CAAC,CAAC;;AAEnC,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,MAAMC,oBAAoB,GAAG,MAAAA,CAAA,KAIvB;EACJ,MAAMC,MAAM,GAAG,MAAMF,gBAAgB,CAACC,oBAAoB,CAAC,CAAC;EAC5D,OAAOC,MAAM;AACf,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG,MAAAA,CACtCC,KAA+B,EAC/BC,SAAiB,EACjBC,wBAA+C,KACE;EAAA,IAAAC,YAAA,EAAAC,aAAA,EAAAC,qBAAA,EAAAC,sBAAA,EAAAC,sBAAA,EAAAC,aAAA,EAAAC,aAAA,EAAAC,cAAA,EAAAC,cAAA,EAAAC,cAAA,EAAAC,cAAA,EAAAC,cAAA;EACjD,MAAMC,OAAY,GAAG,CAAC,CAAC;EACvBA,OAAO,CAACC,KAAK,GAAG,CAAChB,KAAK,CAACiB,KAAK,GACxBC,SAAS,GACT;IACEC,IAAI,EAAE;MACJC,KAAK,GAAAjB,YAAA,GAAEH,KAAK,CAACiB,KAAK,cAAAd,YAAA,gBAAAA,YAAA,GAAXA,YAAA,CAAakB,MAAM,cAAAlB,YAAA,uBAAnBA,YAAA,CAAqBmB,OAAO;MACnCC,IAAI,GAAAnB,aAAA,GAAEJ,KAAK,CAACiB,KAAK,cAAAb,aAAA,gBAAAA,aAAA,GAAXA,aAAA,CAAaoB,MAAM,cAAApB,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tD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEuD,iBAAiB;IAC7CC,GAAG,EAAExD,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEwD,GAAG;IAClBC,gBAAgB,EAAEzD,QAAQ,aAARA,QAAQ,gBAAAsC,qBAAA,GAARtC,QAAQ,CAAE0D,WAAW,cAAApB,qBAAA,uBAArBA,qBAAA,CAAuBqB,OAAO;IAChDC,iBAAiB,EAAE5D,QAAQ,aAARA,QAAQ,gBAAAuC,sBAAA,GAARvC,QAAQ,CAAE0D,WAAW,cAAAnB,sBAAA,uBAArBA,sBAAA,CAAuBiB,GAAG;IAC7CK,MAAM,EAAE7D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE8D,OAAO;IACzBC,cAAc,EAAE/D,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAE+D,cAAc;IACxCC,KAAK,EAAEhE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEgE,KAAK;IACtBC,YAAY,EAAEjE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEkE,aAAa;IACrCC,OAAO,EAAEnE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEmE,OAAO;IAC1BC,KAAK,EAAEpE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEoE,KAAK;IACtBC,IAAI,EAAErE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEqE,IAAI;IACpBC,WAAW,EAAEtE,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEuE;EACzB,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "okhiWebReactNative",
3
- "version": "1.2.3-beta.8"
3
+ "version": "1.2.4"
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 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
+ {"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,2 +1,2 @@
1
- export {};
1
+
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
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
+ {"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 +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<{\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,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAG1E,MAAMC,aAAa,GAChB,4EAA2E,GAC5ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAkE/C,OAAO,MAAMC,gBAAsC,GAAGP,aAAa,CAACQ,IAAI,GACpER,aAAa,CAACQ,IAAI,GAClB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMS,gBAAgB,GAAG,IAAIX,kBAAkB,CAACD,aAAa,CAACQ,IAAI,CAAC;AAE1EI,gBAAgB,CAACC,WAAW,CAAC,kCAAkC,EAAE,MAAM,IAAI,CAAC"}
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,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAG1E,MAAMC,aAAa,GAChB,4EAA2E,GAC5ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AA6D/C,OAAO,MAAMC,gBAAsC,GAAGP,aAAa,CAACQ,IAAI,GACpER,aAAa,CAACQ,IAAI,GAClB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMS,gBAAgB,GAAG,IAAIX,kBAAkB,CAACD,aAAa,CAACQ,IAAI,CAAC;AAE1EI,gBAAgB,CAACC,WAAW,CAAC,kCAAkC,EAAE,MAAM,IAAI,CAAC"}
@@ -76,7 +76,6 @@ export interface OkHiLocationManagerProps {
76
76
  home?: boolean;
77
77
  work?: boolean;
78
78
  };
79
- permissionsOnboarding?: boolean;
80
79
  };
81
80
  /**
82
81
  * **Optional:** Enable a user to either select an existing address, or force to create a new one
@@ -130,6 +129,9 @@ export type OkHiLocationManagerStartMessage = 'select_location' | 'start_app';
130
129
  * @ignore
131
130
  */
132
131
  export interface OkHiLocationManagerResponse {
133
- message: 'location_selected' | 'location_created' | 'location_updated' | 'exit_app' | 'request_enable_protected_apps' | 'fatal_exit' | 'request_location_permission';
134
- payload: any;
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
+ };
135
137
  }
@@ -1,4 +1,3 @@
1
- import type { OkHiException } from './OkHiException';
2
1
  /**
3
2
  * Defines the structure of the user object requried by OkHi services and libraries.
4
3
  */
@@ -186,4 +185,4 @@ export type OkHiApplicationConfiguration = {
186
185
  export type LocationPermissionStatus = 'notDetermined' | 'restricted' | 'denied' | 'authorizedAlways' | 'authorizedWhenInUse' | 'authorized' | 'unknown';
187
186
  export type LocationPermissionStatusCallback = LocationPermissionStatus | 'rationaleDissmissed';
188
187
  export type LocationRequestPermissionType = 'whenInUse' | 'always';
189
- export type LocationPermissionCallback = (status: LocationPermissionStatusCallback | null, error: OkHiException | null) => any;
188
+ export type LocationPermissionCallback = (status: LocationPermissionStatusCallback | null, error: OkHiError | null) => any;
@@ -26,8 +26,6 @@ type OkHiNativeModuleType = {
26
26
  retrieveDeviceInfo(): Promise<{
27
27
  manufacturer: string;
28
28
  model: string;
29
- osVersion: string;
30
- platform: 'android' | 'ios';
31
29
  }>;
32
30
  setItem(key: string, value: string): Promise<boolean>;
33
31
  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.3-beta.8",
3
+ "version": "1.2.4",
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",