react-native-okhi 1.0.22-beta → 1.0.25

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 (69) hide show
  1. package/LICENSE +1 -2
  2. package/android/build.gradle +117 -40
  3. package/android/gradle.properties +5 -0
  4. package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +12 -20
  5. package/ios/OkHiExtension.swift +1 -2
  6. package/ios/OkHiStruct.swift +2 -2
  7. package/ios/Okhi.xcodeproj/project.pbxproj +5 -53
  8. package/ios/Okhi.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -3
  9. package/lib/commonjs/OkCollect/Helpers.js.map +1 -1
  10. package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +1 -1
  11. package/lib/commonjs/OkCollect/Spinner.js.map +1 -1
  12. package/lib/commonjs/OkCollect/Util.js.map +1 -1
  13. package/lib/commonjs/OkCollect/app.json +1 -1
  14. package/lib/commonjs/OkCollect/index.js.map +1 -1
  15. package/lib/commonjs/OkCollect/types.js.map +1 -1
  16. package/lib/commonjs/OkCore/Helpers.js.map +1 -1
  17. package/lib/commonjs/OkCore/OkHiAuth.js.map +1 -1
  18. package/lib/commonjs/OkCore/OkHiException.js.map +1 -1
  19. package/lib/commonjs/OkCore/OkHiMode.js.map +1 -1
  20. package/lib/commonjs/OkCore/_helpers.js.map +1 -1
  21. package/lib/commonjs/OkCore/_types.js.map +1 -1
  22. package/lib/commonjs/OkCore/index.js.map +1 -1
  23. package/lib/commonjs/OkCore/types.js.map +1 -1
  24. package/lib/commonjs/OkHiNativeModule/index.js +10 -1
  25. package/lib/commonjs/OkHiNativeModule/index.js.map +1 -1
  26. package/lib/commonjs/OkVerify/index.js.map +1 -1
  27. package/lib/commonjs/OkVerify/types.js.map +1 -1
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/module/OkCollect/Helpers.js.map +1 -1
  30. package/lib/module/OkCollect/OkHiLocationManager.js.map +1 -1
  31. package/lib/module/OkCollect/Spinner.js.map +1 -1
  32. package/lib/module/OkCollect/Util.js.map +1 -1
  33. package/lib/module/OkCollect/app.json +1 -1
  34. package/lib/module/OkCollect/index.js.map +1 -1
  35. package/lib/module/OkCollect/types.js.map +1 -1
  36. package/lib/module/OkCore/Helpers.js.map +1 -1
  37. package/lib/module/OkCore/OkHiAuth.js.map +1 -1
  38. package/lib/module/OkCore/OkHiException.js.map +1 -1
  39. package/lib/module/OkCore/OkHiMode.js.map +1 -1
  40. package/lib/module/OkCore/_helpers.js.map +1 -1
  41. package/lib/module/OkCore/_types.js.map +1 -1
  42. package/lib/module/OkCore/index.js.map +1 -1
  43. package/lib/module/OkCore/types.js.map +1 -1
  44. package/lib/module/OkHiNativeModule/index.js +11 -2
  45. package/lib/module/OkHiNativeModule/index.js.map +1 -1
  46. package/lib/module/OkVerify/index.js.map +1 -1
  47. package/lib/module/OkVerify/types.js.map +1 -1
  48. package/lib/module/index.js.map +1 -1
  49. package/lib/typescript/OkCollect/Helpers.d.ts +2 -2
  50. package/lib/typescript/OkHiNativeModule/index.d.ts +0 -1
  51. package/lib/typescript/OkVerify/index.d.ts +4 -4
  52. package/package.json +25 -26
  53. package/react-native-okhi.podspec +18 -2
  54. package/src/OkCollect/app.json +1 -1
  55. package/src/OkCollect/{index.tsx → index.ts} +0 -0
  56. package/src/OkCore/Helpers.ts +4 -4
  57. package/src/OkHiNativeModule/index.ts +17 -3
  58. package/android/.classpath +0 -6
  59. package/android/.project +0 -34
  60. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  61. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  62. package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
  63. package/android/gradlew +0 -183
  64. package/android/gradlew.bat +0 -100
  65. package/android/local.properties +0 -8
  66. package/android/src/main/java/com/reactnativeokhi/RNOkHiCore.java +0 -18
  67. package/ios/Okhi.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  68. package/ios/Okhi.xcodeproj/project.xcworkspace/xcuserdata/kiano.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  69. package/ios/Okhi.xcodeproj/xcuserdata/kiano.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -1 +1 @@
1
- {"version":3,"sources":["Helpers.ts"],"names":["isLocationServicesEnabled","OkHiNativeModule","isLocationPermissionGranted","isBackgroundLocationPermissionGrantedAndroid","sdkVersion","getSystemVersion","hasPermission","PermissionsAndroid","check","PERMISSIONS","ACCESS_BACKGROUND_LOCATION","isBackgroundLocationPermissionGrantedIOS","isBackgroundLocationPermissionGranted","fn","Platform","OS","requestLocationPermissionAndroid","status","requestMultiple","ACCESS_FINE_LOCATION","ACCESS_COARSE_LOCATION","requestLocationPermissionIOS","requestLocationPermission","isGranted","requestBackgroundLocationPermissionAndroid","permissions","requestBackgroundLocationPermissionIOS","requestBackgroundLocationPermission","requestEnableLocationServices","isGooglePlayServicesAvailable","requestEnableGooglePlayServices","request","locationPermissionType","rationale","callback","serviceError","OkHiException","code","SERVICE_UNAVAILABLE_CODE","message","googlePlayError","handleError","error","handleGooglePlayServiceRequest","then","googlePlayStatus","handleRationaleRequest","handleRationaleAlert","alertRationale","Promise","resolve","_","Alert","alert","title","text","grantButton","label","onPress","denyButton","style","onDismiss","handlePermissionRequest","OkHiNativeEvents","removeAllListeners","addListener","permissionUpdate","whenInUseResult","initialWhenInUseResult","alwaysResult","currentStatus","retriveLocationPermissionStatus","showRationale","result","serviceStatus","enableResult","catch","openAppSettings","alwaysPerm","whenInUsePerm","requestTrackingAuthorization","canOpenProtectedAppsSettings","openProtectedAppsSettings"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,GAAG,MAAwB;AAC/D,SAAO,8BAAgBC,mCAAiBD,yBAAjC,CAAP;AACD,CAFM;AAIP;AACA;AACA;AACA;;;;;AACO,MAAME,2BAA2B,GAAG,MAAwB;AACjE,SAAO,8BA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8B;AAC/B;AACF;AACF,GArBH,EAsBGiC,KAtBH,CAsBSnC,WAtBT;AAuBD,CAlKM;AAoKP;AACA;AACA;;;;;AACO,MAAMoC,eAAe,GAAG,MAAM;AACnC5E,qCAAiB4E,eAAjB;AACD,CAFM;AAIP;AACA;AACA;;;;;AACO,MAAMN,+BAA+B,GAC1C,YAA+C;AAC7C,MAAIzD,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOd,mCAAiBsE,+BAAjB,EAAP;AACD;;AACD,QAAMO,UAAU,GAAG,MAAMlE,qCAAqC,EAA9D;;AACA,MAAIkE,UAAJ,EAAgB;AACd,WAAO,kBAAP;AACD;;AACD,QAAMC,aAAa,GAAG,MAAM7E,2BAA2B,EAAvD;AACA,SAAO6E,aAAa,GAAG,qBAAH,GAA2B,QAA/C;AACD,CAXI;AAaP;AACA;AACA;AACA;;;;;AACO,MAAMC,4BAA4B,GAAG,YAEvC;AACH,SAAO,8BAAgB,YAAY;AACjC,UAAMP,MAAM,GAAG,MAAMxE,mCAAiB+E,4BAAjB,EAArB;AACA,WAAOP,MAAP;AACD,GAHM,EAGJ,KAHI,CAAP;AAID,CAPM;AASP;AACA;AACA;AACA;;;;;AACO,MAAMQ,4BAA4B,GAAG,MAAwB;AAClE,SAAO,8BAAgB,YAAY;AACjC,UAAMR,MAAM,GAAG,MAAMxE,mCAAiBgF,4BAAjB,EAArB;AACA,WAAOR,MAAP;AACD,GAHM,EAGJ,SAHI,CAAP;AAID,CALM;AAOP;AACA;AACA;AACA;;;;;AACO,MAAMS,yBAAyB,GAAG,MAAwB;AAC/D,SAAO,8BAAgB,YAAY;AACjC,UAAMT,MAAM,GAAG,MAAMxE,mCAAiBiF,yBAAjB,EAArB;AACA,WAAOT,MAAP;AACD,GAHM,EAGJ,SAHI,CAAP;AAID,CALM","sourcesContent":["import { OkHiNativeModule, OkHiNativeEvents } from '../OkHiNativeModule';\nimport { Alert, PermissionsAndroid, Platform } from 'react-native';\nimport { errorHandler, isValidPlatform } from './_helpers';\nimport type {\n LocationPermissionCallback,\n LocationPermissionStatus,\n LocationRequestPermissionType,\n} from './types';\nimport { OkHiException } from './OkHiException';\n\n/**\n * Checks whether location services are enabled\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the service is available\n */\nexport const isLocationServicesEnabled = (): Promise<boolean> => {\n return isValidPlatform(OkHiNativeModule.isLocationServicesEnabled);\n};\n\n/**\n * Checks whether when in use location permission is granted\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const isLocationPermissionGranted = (): Promise<boolean> => {\n return isValidPlatform(OkHiNativeModule.isLocationPermissionGranted);\n};\n\nconst isBackgroundLocationPermissionGrantedAndroid =\n async (): Promise<boolean> => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (sdkVersion < 23) {\n return true;\n }\n if (sdkVersion < 29) {\n return await isLocationPermissionGranted();\n }\n const hasPermission = await PermissionsAndroid.check(\n PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION\n );\n return hasPermission;\n };\n\nconst isBackgroundLocationPermissionGrantedIOS = (): Promise<boolean> => {\n return OkHiNativeModule.isBackgroundLocationPermissionGranted();\n};\n\n/**\n * Checks whether background location permission is granted\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const isBackgroundLocationPermissionGranted = (): Promise<boolean> => {\n const fn =\n Platform.OS === 'android'\n ? isBackgroundLocationPermissionGrantedAndroid\n : isBackgroundLocationPermissionGrantedIOS;\n return isValidPlatform(fn);\n};\n\nconst requestLocationPermissionAndroid = async (): Promise<boolean> => {\n const status: any = await PermissionsAndroid.requestMultiple([\n PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,\n PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,\n ]);\n return status['android.permission.ACCESS_FINE_LOCATION'] === 'granted';\n};\n\nconst requestLocationPermissionIOS = (): Promise<boolean> => {\n return OkHiNativeModule.requestLocationPermission();\n};\n\n/**\n * Requests for when in use location permission\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const requestLocationPermission = async (): Promise<boolean> => {\n const isGranted = await isLocationPermissionGranted();\n if (isGranted) return isGranted;\n return errorHandler(\n Platform.OS === 'android'\n ? requestLocationPermissionAndroid\n : requestLocationPermissionIOS\n );\n};\n\nconst requestBackgroundLocationPermissionAndroid =\n async (): Promise<boolean> => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (sdkVersion < 23) return true;\n if (sdkVersion >= 29) {\n const permissions: any = [\n PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION,\n ];\n const status: any = await PermissionsAndroid.requestMultiple(permissions);\n return (\n status['android.permission.ACCESS_BACKGROUND_LOCATION'] === 'granted'\n );\n } else {\n return await requestLocationPermissionAndroid();\n }\n };\n\nconst requestBackgroundLocationPermissionIOS = (): Promise<boolean> => {\n return OkHiNativeModule.requestBackgroundLocationPermission();\n};\n\n/**\n * Requests for background location permission\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const requestBackgroundLocationPermission =\n async (): Promise<boolean> => {\n const isGranted = await isBackgroundLocationPermissionGranted();\n if (isGranted) return isGranted;\n return errorHandler(\n Platform.OS === 'android'\n ? requestBackgroundLocationPermissionAndroid\n : requestBackgroundLocationPermissionIOS\n );\n };\n\n/**\n * Requests the user to enable location services by showing an in app modal on android and opening location settings on iOS\n * @returns {Promise<boolean>} A promise that resolves to either a boolean value on android or null on iOS\n */\nexport const requestEnableLocationServices = (): Promise<boolean | null> => {\n return isValidPlatform(OkHiNativeModule.requestEnableLocationServices);\n};\n\n/**\n * Android Only - Checks if Google Play Services is available\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is avaialbe\n */\nexport const isGooglePlayServicesAvailable = (): Promise<boolean> => {\n return isValidPlatform(\n OkHiNativeModule.isGooglePlayServicesAvailable,\n 'android'\n );\n};\n\n/**\n * Android Only - Requests user to enable Google Play Services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is avaialbe\n */\nexport const requestEnableGooglePlayServices = (): Promise<boolean> => {\n return isValidPlatform(\n OkHiNativeModule.requestEnableGooglePlayServices,\n 'android'\n );\n};\n\n/**\n * Returns the system version of the current platform\n * @returns {Promise<boolean>} A promise that resolves either a string on iOS or number on Android\n */\nexport const getSystemVersion = (): Promise<string | number> =>\n isValidPlatform(OkHiNativeModule.getSystemVersion);\n\n/**\n * Requests location permission from the user. It'll also attempt to activate any disbaled services (Android Only)\n */\nexport const request = (\n locationPermissionType: LocationRequestPermissionType,\n rationale: {\n title: string;\n text: string;\n successButton?: { label: string };\n denyButton?: { label: string };\n } | null,\n callback: LocationPermissionCallback\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\n const googlePlayError = new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message:\n 'Google Play Services is currently unavailable. Please enable in settings',\n });\n\n const handleError = (error: OkHiException) => {\n callback(null, error);\n };\n\n const handleGooglePlayServiceRequest = () => {\n requestEnableGooglePlayServices().then((googlePlayStatus) => {\n if (!googlePlayStatus) {\n handleError(googlePlayError);\n } else {\n handleRationaleRequest();\n }\n });\n };\n\n const handleRationaleAlert = (alertRationale: {\n title: string;\n text: string;\n grantButton?: { label: string };\n denyButton?: { label: string };\n }) => {\n return new Promise((resolve, _) => {\n Alert.alert(\n alertRationale.title,\n alertRationale.text,\n [\n {\n text: alertRationale.grantButton\n ? alertRationale.grantButton.label\n : 'Grant',\n onPress: () => {\n resolve(true);\n },\n },\n {\n text: alertRationale.denyButton\n ? alertRationale.denyButton.label\n : 'Deny',\n onPress: () => {\n resolve(false);\n },\n style: 'cancel',\n },\n ],\n {\n onDismiss: () => {\n resolve(false);\n },\n }\n );\n });\n };\n\n const handlePermissionRequest = () => {\n if (Platform.OS === 'ios') {\n OkHiNativeEvents.removeAllListeners('onLocationPermissionStatusUpdate');\n OkHiNativeEvents.addListener(\n 'onLocationPermissionStatusUpdate',\n (permissionUpdate) => {\n callback(permissionUpdate, null);\n }\n );\n if (locationPermissionType === 'whenInUse') {\n OkHiNativeModule.requestLocationPermission();\n } else {\n OkHiNativeModule.requestBackgroundLocationPermission();\n }\n } else {\n if (locationPermissionType === 'whenInUse') {\n requestLocationPermissionAndroid().then((whenInUseResult) =>\n callback(whenInUseResult ? 'authorizedWhenInUse' : 'denied', null)\n );\n } else {\n requestLocationPermissionAndroid().then((initialWhenInUseResult) => {\n if (!initialWhenInUseResult) {\n callback('denied', null);\n } else {\n callback('authorizedWhenInUse', null);\n requestBackgroundLocationPermission().then((alwaysResult) => {\n callback(\n alwaysResult ? 'authorizedAlways' : 'authorizedWhenInUse',\n null\n );\n });\n }\n });\n }\n }\n };\n\n const handleRationaleRequest = async () => {\n const currentStatus = await retriveLocationPermissionStatus();\n let showRationale = true;\n if (\n locationPermissionType === 'whenInUse' &&\n (currentStatus === 'authorizedWhenInUse' ||\n currentStatus === 'authorizedAlways')\n ) {\n showRationale = false;\n }\n if (\n locationPermissionType === 'always' &&\n currentStatus === 'authorizedAlways'\n ) {\n showRationale = false;\n }\n if (rationale && showRationale) {\n const result = await handleRationaleAlert(rationale);\n if (!result) {\n callback('rationaleDissmissed', null);\n } else {\n handlePermissionRequest();\n }\n } else {\n handlePermissionRequest();\n }\n };\n\n isLocationServicesEnabled()\n .then((serviceStatus) => {\n if (!serviceStatus && Platform.OS === 'ios') {\n handleError(serviceError);\n } else if (!serviceStatus && Platform.OS === 'android') {\n requestEnableLocationServices()\n .then((enableResult) => {\n if (!enableResult) {\n handleError(serviceError);\n } else {\n handleGooglePlayServiceRequest();\n }\n })\n .catch(handleError);\n } else {\n if (Platform.OS === 'ios') {\n handleRationaleRequest();\n } else {\n handleGooglePlayServiceRequest();\n }\n }\n })\n .catch(handleError);\n};\n\n/**\n * Open the device's app settings.\n */\nexport const openAppSettings = () => {\n OkHiNativeModule.openAppSettings();\n};\n\n/**\n * Retrives the location permission status from the device\n */\nexport const retriveLocationPermissionStatus =\n async (): Promise<LocationPermissionStatus> => {\n if (Platform.OS === 'ios') {\n return OkHiNativeModule.retriveLocationPermissionStatus() as Promise<LocationPermissionStatus>;\n }\n const alwaysPerm = await isBackgroundLocationPermissionGranted();\n if (alwaysPerm) {\n return 'authorizedAlways';\n }\n const whenInUsePerm = await isLocationPermissionGranted();\n return whenInUsePerm ? 'authorizedWhenInUse' : 'denied';\n };\n\n/**\n * Requests tracking authorization from the user. iOS only, iOS version >= 14\n * Read more: https://developer.apple.com/app-store/user-privacy-and-data-use/\n */\nexport const requestTrackingAuthorization = async (): Promise<\n string | null\n> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.requestTrackingAuthorization();\n return result;\n }, 'ios');\n};\n\n/**\n * Checks whether current device can open \"Protected Apps Settings\" available in Transsion Group android devices such as Infinix and Tecno\n * When your application is included in protected apps, verification processes are less likely to be terminated by the OS. Increasing rate of users being verified.\n */\nexport const canOpenProtectedAppsSettings = (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.canOpenProtectedAppsSettings();\n return result;\n }, 'android');\n};\n\n/**\n * Opens \"Protected Apps Settings\" available in Transsion Group android devices such as Infinix and Tecno\n * When your application is included in protected apps, verification processes are less likely to be terminated by the OS. Increasing rate of users being verified.\n */\nexport const openProtectedAppsSettings = (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.openProtectedAppsSettings();\n return result;\n }, 'android');\n};\n"]}
1
+ {"version":3,"names":["isLocationServicesEnabled","isValidPlatform","OkHiNativeModule","isLocationPermissionGranted","isBackgroundLocationPermissionGrantedAndroid","sdkVersion","getSystemVersion","hasPermission","PermissionsAndroid","check","PERMISSIONS","ACCESS_BACKGROUND_LOCATION","isBackgroundLocationPermissionGrantedIOS","isBackgroundLocationPermissionGranted","fn","Platform","OS","requestLocationPermissionAndroid","status","requestMultiple","ACCESS_FINE_LOCATION","ACCESS_COARSE_LOCATION","requestLocationPermissionIOS","requestLocationPermission","isGranted","errorHandler","requestBackgroundLocationPermissionAndroid","permissions","requestBackgroundLocationPermissionIOS","requestBackgroundLocationPermission","requestEnableLocationServices","isGooglePlayServicesAvailable","requestEnableGooglePlayServices","request","locationPermissionType","rationale","callback","serviceError","OkHiException","code","SERVICE_UNAVAILABLE_CODE","message","googlePlayError","handleError","error","handleGooglePlayServiceRequest","then","googlePlayStatus","handleRationaleRequest","handleRationaleAlert","alertRationale","Promise","resolve","_","Alert","alert","title","text","grantButton","label","onPress","denyButton","style","onDismiss","handlePermissionRequest","OkHiNativeEvents","removeAllListeners","addListener","permissionUpdate","whenInUseResult","initialWhenInUseResult","alwaysResult","currentStatus","retriveLocationPermissionStatus","showRationale","result","serviceStatus","enableResult","catch","openAppSettings","alwaysPerm","whenInUsePerm","requestTrackingAuthorization","canOpenProtectedAppsSettings","openProtectedAppsSettings"],"sources":["Helpers.ts"],"sourcesContent":["import { OkHiNativeModule, OkHiNativeEvents } from '../OkHiNativeModule';\nimport { Alert, Permission, PermissionsAndroid, Platform } from 'react-native';\nimport { errorHandler, isValidPlatform } from './_helpers';\nimport type {\n LocationPermissionCallback,\n LocationPermissionStatus,\n LocationRequestPermissionType,\n} from './types';\nimport { OkHiException } from './OkHiException';\n\n/**\n * Checks whether location services are enabled\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the service is available\n */\nexport const isLocationServicesEnabled = (): Promise<boolean> => {\n return isValidPlatform(OkHiNativeModule.isLocationServicesEnabled);\n};\n\n/**\n * Checks whether when in use location permission is granted\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const isLocationPermissionGranted = (): Promise<boolean> => {\n return isValidPlatform(OkHiNativeModule.isLocationPermissionGranted);\n};\n\nconst isBackgroundLocationPermissionGrantedAndroid =\n async (): Promise<boolean> => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (sdkVersion < 23) {\n return true;\n }\n if (sdkVersion < 29) {\n return await isLocationPermissionGranted();\n }\n const hasPermission = await PermissionsAndroid.check(\n PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION as Permission\n );\n return hasPermission;\n };\n\nconst isBackgroundLocationPermissionGrantedIOS = (): Promise<boolean> => {\n return OkHiNativeModule.isBackgroundLocationPermissionGranted();\n};\n\n/**\n * Checks whether background location permission is granted\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const isBackgroundLocationPermissionGranted = (): Promise<boolean> => {\n const fn =\n Platform.OS === 'android'\n ? isBackgroundLocationPermissionGrantedAndroid\n : isBackgroundLocationPermissionGrantedIOS;\n return isValidPlatform(fn);\n};\n\nconst requestLocationPermissionAndroid = async (): Promise<boolean> => {\n const status: any = await PermissionsAndroid.requestMultiple([\n PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION as Permission,\n PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION as Permission,\n ]);\n return status['android.permission.ACCESS_FINE_LOCATION'] === 'granted';\n};\n\nconst requestLocationPermissionIOS = (): Promise<boolean> => {\n return OkHiNativeModule.requestLocationPermission();\n};\n\n/**\n * Requests for when in use location permission\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const requestLocationPermission = async (): Promise<boolean> => {\n const isGranted = await isLocationPermissionGranted();\n if (isGranted) return isGranted;\n return errorHandler(\n Platform.OS === 'android'\n ? requestLocationPermissionAndroid\n : requestLocationPermissionIOS\n );\n};\n\nconst requestBackgroundLocationPermissionAndroid =\n async (): Promise<boolean> => {\n const sdkVersion = await OkHiNativeModule.getSystemVersion();\n if (sdkVersion < 23) return true;\n if (sdkVersion >= 29) {\n const permissions: any = [\n PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION,\n ];\n const status: any = await PermissionsAndroid.requestMultiple(permissions);\n return (\n status['android.permission.ACCESS_BACKGROUND_LOCATION'] === 'granted'\n );\n } else {\n return await requestLocationPermissionAndroid();\n }\n };\n\nconst requestBackgroundLocationPermissionIOS = (): Promise<boolean> => {\n return OkHiNativeModule.requestBackgroundLocationPermission();\n};\n\n/**\n * Requests for background location permission\n * @returns {Promise<boolean>} A promise that resolves to a boolen value indicating whether the permission is granted\n */\nexport const requestBackgroundLocationPermission =\n async (): Promise<boolean> => {\n const isGranted = await isBackgroundLocationPermissionGranted();\n if (isGranted) return isGranted;\n return errorHandler(\n Platform.OS === 'android'\n ? requestBackgroundLocationPermissionAndroid\n : requestBackgroundLocationPermissionIOS\n );\n };\n\n/**\n * Requests the user to enable location services by showing an in app modal on android and opening location settings on iOS\n * @returns {Promise<boolean>} A promise that resolves to either a boolean value on android or null on iOS\n */\nexport const requestEnableLocationServices = (): Promise<boolean | null> => {\n return isValidPlatform(OkHiNativeModule.requestEnableLocationServices);\n};\n\n/**\n * Android Only - Checks if Google Play Services is available\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is avaialbe\n */\nexport const isGooglePlayServicesAvailable = (): Promise<boolean> => {\n return isValidPlatform(\n OkHiNativeModule.isGooglePlayServicesAvailable,\n 'android'\n );\n};\n\n/**\n * Android Only - Requests user to enable Google Play Services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is avaialbe\n */\nexport const requestEnableGooglePlayServices = (): Promise<boolean> => {\n return isValidPlatform(\n OkHiNativeModule.requestEnableGooglePlayServices,\n 'android'\n );\n};\n\n/**\n * Returns the system version of the current platform\n * @returns {Promise<boolean>} A promise that resolves either a string on iOS or number on Android\n */\nexport const getSystemVersion = (): Promise<string | number> =>\n isValidPlatform(OkHiNativeModule.getSystemVersion);\n\n/**\n * Requests location permission from the user. It'll also attempt to activate any disbaled services (Android Only)\n */\nexport const request = (\n locationPermissionType: LocationRequestPermissionType,\n rationale: {\n title: string;\n text: string;\n successButton?: { label: string };\n denyButton?: { label: string };\n } | null,\n callback: LocationPermissionCallback\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\n const googlePlayError = new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message:\n 'Google Play Services is currently unavailable. Please enable in settings',\n });\n\n const handleError = (error: OkHiException) => {\n callback(null, error);\n };\n\n const handleGooglePlayServiceRequest = () => {\n requestEnableGooglePlayServices().then((googlePlayStatus) => {\n if (!googlePlayStatus) {\n handleError(googlePlayError);\n } else {\n handleRationaleRequest();\n }\n });\n };\n\n const handleRationaleAlert = (alertRationale: {\n title: string;\n text: string;\n grantButton?: { label: string };\n denyButton?: { label: string };\n }) => {\n return new Promise((resolve, _) => {\n Alert.alert(\n alertRationale.title,\n alertRationale.text,\n [\n {\n text: alertRationale.grantButton\n ? alertRationale.grantButton.label\n : 'Grant',\n onPress: () => {\n resolve(true);\n },\n },\n {\n text: alertRationale.denyButton\n ? alertRationale.denyButton.label\n : 'Deny',\n onPress: () => {\n resolve(false);\n },\n style: 'cancel',\n },\n ],\n {\n onDismiss: () => {\n resolve(false);\n },\n }\n );\n });\n };\n\n const handlePermissionRequest = () => {\n if (Platform.OS === 'ios') {\n OkHiNativeEvents.removeAllListeners('onLocationPermissionStatusUpdate');\n OkHiNativeEvents.addListener(\n 'onLocationPermissionStatusUpdate',\n (permissionUpdate) => {\n callback(permissionUpdate, null);\n }\n );\n if (locationPermissionType === 'whenInUse') {\n OkHiNativeModule.requestLocationPermission();\n } else {\n OkHiNativeModule.requestBackgroundLocationPermission();\n }\n } else {\n if (locationPermissionType === 'whenInUse') {\n requestLocationPermissionAndroid().then((whenInUseResult) =>\n callback(whenInUseResult ? 'authorizedWhenInUse' : 'denied', null)\n );\n } else {\n requestLocationPermissionAndroid().then((initialWhenInUseResult) => {\n if (!initialWhenInUseResult) {\n callback('denied', null);\n } else {\n callback('authorizedWhenInUse', null);\n requestBackgroundLocationPermission().then((alwaysResult) => {\n callback(\n alwaysResult ? 'authorizedAlways' : 'authorizedWhenInUse',\n null\n );\n });\n }\n });\n }\n }\n };\n\n const handleRationaleRequest = async () => {\n const currentStatus = await retriveLocationPermissionStatus();\n let showRationale = true;\n if (\n locationPermissionType === 'whenInUse' &&\n (currentStatus === 'authorizedWhenInUse' ||\n currentStatus === 'authorizedAlways')\n ) {\n showRationale = false;\n }\n if (\n locationPermissionType === 'always' &&\n currentStatus === 'authorizedAlways'\n ) {\n showRationale = false;\n }\n if (rationale && showRationale) {\n const result = await handleRationaleAlert(rationale);\n if (!result) {\n callback('rationaleDissmissed', null);\n } else {\n handlePermissionRequest();\n }\n } else {\n handlePermissionRequest();\n }\n };\n\n isLocationServicesEnabled()\n .then((serviceStatus) => {\n if (!serviceStatus && Platform.OS === 'ios') {\n handleError(serviceError);\n } else if (!serviceStatus && Platform.OS === 'android') {\n requestEnableLocationServices()\n .then((enableResult) => {\n if (!enableResult) {\n handleError(serviceError);\n } else {\n handleGooglePlayServiceRequest();\n }\n })\n .catch(handleError);\n } else {\n if (Platform.OS === 'ios') {\n handleRationaleRequest();\n } else {\n handleGooglePlayServiceRequest();\n }\n }\n })\n .catch(handleError);\n};\n\n/**\n * Open the device's app settings.\n */\nexport const openAppSettings = () => {\n OkHiNativeModule.openAppSettings();\n};\n\n/**\n * Retrives the location permission status from the device\n */\nexport const retriveLocationPermissionStatus =\n async (): Promise<LocationPermissionStatus> => {\n if (Platform.OS === 'ios') {\n return OkHiNativeModule.retriveLocationPermissionStatus() as Promise<LocationPermissionStatus>;\n }\n const alwaysPerm = await isBackgroundLocationPermissionGranted();\n if (alwaysPerm) {\n return 'authorizedAlways';\n }\n const whenInUsePerm = await isLocationPermissionGranted();\n return whenInUsePerm ? 'authorizedWhenInUse' : 'denied';\n };\n\n/**\n * Requests tracking authorization from the user. iOS only, iOS version >= 14\n * Read more: https://developer.apple.com/app-store/user-privacy-and-data-use/\n */\nexport const requestTrackingAuthorization = async (): Promise<\n string | null\n> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.requestTrackingAuthorization();\n return result;\n }, 'ios');\n};\n\n/**\n * Checks whether current device can open \"Protected Apps Settings\" available in Transsion Group android devices such as Infinix and Tecno\n * When your application is included in protected apps, verification processes are less likely to be terminated by the OS. Increasing rate of users being verified.\n */\nexport const canOpenProtectedAppsSettings = (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.canOpenProtectedAppsSettings();\n return result;\n }, 'android');\n};\n\n/**\n * Opens \"Protected Apps Settings\" available in Transsion Group android devices such as Infinix and Tecno\n * When your application is included in protected apps, verification processes are less likely to be terminated by the OS. Increasing rate of users being verified.\n */\nexport const openProtectedAppsSettings = (): Promise<boolean> => {\n return isValidPlatform(async () => {\n const result = await OkHiNativeModule.openProtectedAppsSettings();\n return result;\n }, 'android');\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAMA;;AAEA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,GAAG,MAAwB;EAC/D,OAAO,IAAAC,wBAAA,EAAgBC,kCAAA,CAAiBF,yBAAjC,CAAP;AACD,CAFM;AAIP;AACA;AACA;AACA;;;;;AACO,MAAMG,2BAA2B,GAAG,MAAwB;EACjE,OAAO,IAAAF,wBAAA,EAAgBC,kCAAA,CAAiBC,2BAAjC,CAAP;AACD,CAFM;;;;AAIP,MAAMC,4CAA4C,GAChD,YAA8B;EAC5B,MAAMC,UAAU,GAAG,MAAMH,kCAAA,CAAiBI,gBAAjB,EAAzB;;EACA,IAAID,UAAU,GAAG,EAAjB,EAAqB;IACnB,OAAO,IAAP;EACD;;EACD,IAAIA,UAAU,GAAG,EAAjB,EAAqB;IACnB,OAAO,MAAMF,2BAA2B,EAAxC;EACD;;EACD,MAAMI,aAAa,GAAG,MAAMC,+BAAA,CAAmBC,KAAnB,CAC1BD,+BAAA,CAAmBE,WAAnB,CAA+BC,0BADL,CAA5B;EAGA,OAAOJ,aAAP;AACD,CAbH;;AAeA,MA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P;EACD;;EACD,MAAMC,aAAa,GAAG,MAAM9E,2BAA2B,EAAvD;EACA,OAAO8E,aAAa,GAAG,qBAAH,GAA2B,QAA/C;AACD,CAXI;AAaP;AACA;AACA;AACA;;;;;AACO,MAAMC,4BAA4B,GAAG,YAEvC;EACH,OAAO,IAAAjF,wBAAA,EAAgB,YAAY;IACjC,MAAM0E,MAAM,GAAG,MAAMzE,kCAAA,CAAiBgF,4BAAjB,EAArB;IACA,OAAOP,MAAP;EACD,CAHM,EAGJ,KAHI,CAAP;AAID,CAPM;AASP;AACA;AACA;AACA;;;;;AACO,MAAMQ,4BAA4B,GAAG,MAAwB;EAClE,OAAO,IAAAlF,wBAAA,EAAgB,YAAY;IACjC,MAAM0E,MAAM,GAAG,MAAMzE,kCAAA,CAAiBiF,4BAAjB,EAArB;IACA,OAAOR,MAAP;EACD,CAHM,EAGJ,SAHI,CAAP;AAID,CALM;AAOP;AACA;AACA;AACA;;;;;AACO,MAAMS,yBAAyB,GAAG,MAAwB;EAC/D,OAAO,IAAAnF,wBAAA,EAAgB,YAAY;IACjC,MAAM0E,MAAM,GAAG,MAAMzE,kCAAA,CAAiBkF,yBAAjB,EAArB;IACA,OAAOT,MAAP;EACD,CAHM,EAGJ,SAHI,CAAP;AAID,CALM"}
@@ -1 +1 @@
1
- {"version":3,"sources":["OkHiAuth.ts"],"names":["OkHiAuth","API_VERSION","ANONYMOUS_SIGN_IN_ENDPOINT","anonymousSignInWithPhoneNumber","phone","scopes","config","anonymousSignIn","anonymousSignInWithUserId","userId","user_id","payload","Promise","resolve","reject","auth","token","OkHiException","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","context","url","SANDBOX_BASE_URL","mode","DEV_BASE_URL","OkHiMode","PROD","PROD_BASE_URL","headers","Authorization","data","axios","post","authorization_token","error","parseRequestError","response","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","status","INVALID_PHONE_CODE","INVALID_PHONE_MESSAGE","UNKNOWN_ERROR_CODE","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yB,kBADG;AAEvBtB,UAAAA,OAAO,EAAEH,6BAAc0B;AAFA,SAAlB,CAAP;;AAIF,WAAK,GAAL;AACE,eAAO,IAAI1B,4BAAJ,CAAkB;AACvBC,UAAAA,IAAI,EAAED,6BAAcE,iBADG;AAEvBC,UAAAA,OAAO,EAAEH,6BAAcI;AAFA,SAAlB,CAAP;;AAIF;AACE,eAAO,IAAIJ,4BAAJ,CAAkB;AACvBC,UAAAA,IAAI,EAAED,6BAAc2B,kBADG;AAEvBxB,UAAAA,OAAO,EAAEgB,KAAK,CAAChB,OAAN,IAAiBH,6BAAc4B;AAFjB,SAAlB,CAAP;AAZJ;AAiBD;;AA/FmB","sourcesContent":["import axios from 'axios';\nimport { OkHiMode } from './OkHiMode';\nimport { OkHiException } from './OkHiException';\nimport type { AuthApplicationConfig, OkHiAccessScope } from './_types';\nimport { getApplicationConfiguration } from './';\n\n/**\n * @ignore\n */\nexport class OkHiAuth {\n private readonly API_VERSION = 'v5';\n private readonly ANONYMOUS_SIGN_IN_ENDPOINT = '/auth/anonymous-signin';\n private readonly DEV_BASE_URL =\n `https://dev-api.okhi.io/${this.API_VERSION}` +\n this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private readonly SANDBOX_BASE_URL =\n `https://sandbox-api.okhi.io/${this.API_VERSION}` +\n this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private readonly PROD_BASE_URL =\n `https://api.okhi.io/${this.API_VERSION}` + this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private config: AuthApplicationConfig | null = null;\n\n anonymousSignInWithPhoneNumber(\n phone: string,\n scopes: Array<OkHiAccessScope>,\n config: AuthApplicationConfig\n ) {\n this.config = config;\n return this.anonymousSignIn({\n scopes,\n phone,\n });\n }\n\n protected anonymousSignInWithUserId(\n userId: string,\n scopes: Array<OkHiAccessScope>\n ) {\n return this.anonymousSignIn({\n scopes,\n user_id: userId,\n });\n }\n\n private async anonymousSignIn(payload: {\n scopes: Array<OkHiAccessScope>;\n [key: string]: any;\n }): Promise<string> {\n return new Promise(async (resolve, reject) => {\n try {\n const config = this.config || (await getApplicationConfiguration());\n if (config === null || !config.auth || !config.auth.token) {\n reject(\n new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n })\n );\n } else {\n const { auth, context } = config;\n let url = this.SANDBOX_BASE_URL;\n if (context?.mode === ('dev' as any)) {\n url = this.DEV_BASE_URL;\n } else if (context?.mode === OkHiMode.PROD) {\n url = this.PROD_BASE_URL;\n } else {\n url = this.SANDBOX_BASE_URL;\n }\n const headers = { Authorization: auth.token };\n const { data } = await axios.post(url, payload, {\n headers,\n });\n resolve(data.authorization_token);\n }\n } catch (error) {\n reject(this.parseRequestError(error));\n }\n });\n }\n\n private parseRequestError(error: any) {\n if (!error.response) {\n return new OkHiException({\n code: OkHiException.NETWORK_ERROR_CODE,\n message: OkHiException.NETWORK_ERROR_MESSAGE,\n });\n }\n switch (error.response.status) {\n case 400:\n return new OkHiException({\n code: OkHiException.INVALID_PHONE_CODE,\n message: OkHiException.INVALID_PHONE_MESSAGE,\n });\n case 401:\n return new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n default:\n return new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"names":["OkHiAuth","API_VERSION","ANONYMOUS_SIGN_IN_ENDPOINT","anonymousSignInWithPhoneNumber","phone","scopes","config","anonymousSignIn","anonymousSignInWithUserId","userId","user_id","payload","Promise","resolve","reject","getApplicationConfiguration","auth","token","OkHiException","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","context","url","SANDBOX_BASE_URL","mode","DEV_BASE_URL","OkHiMode","PROD","PROD_BASE_URL","headers","Authorization","data","axios","post","authorization_token","error","parseRequestError","response","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","status","INVALID_PHONE_CODE","INVALID_PHONE_MESSAGE","UNKNOWN_ERROR_CODE","UNKNOWN_ERROR_MESSAGE"],"sources":["OkHiAuth.ts"],"sourcesContent":["import axios from 'axios';\nimport { OkHiMode } from './OkHiMode';\nimport { OkHiException } from './OkHiException';\nimport type { AuthApplicationConfig, OkHiAccessScope } from './_types';\nimport { getApplicationConfiguration } from './';\n\n/**\n * @ignore\n */\nexport class OkHiAuth {\n private readonly API_VERSION = 'v5';\n private readonly ANONYMOUS_SIGN_IN_ENDPOINT = '/auth/anonymous-signin';\n private readonly DEV_BASE_URL =\n `https://dev-api.okhi.io/${this.API_VERSION}` +\n this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private readonly SANDBOX_BASE_URL =\n `https://sandbox-api.okhi.io/${this.API_VERSION}` +\n this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private readonly PROD_BASE_URL =\n `https://api.okhi.io/${this.API_VERSION}` + this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private config: AuthApplicationConfig | null = null;\n\n anonymousSignInWithPhoneNumber(\n phone: string,\n scopes: Array<OkHiAccessScope>,\n config: AuthApplicationConfig\n ) {\n this.config = config;\n return this.anonymousSignIn({\n scopes,\n phone,\n });\n }\n\n protected anonymousSignInWithUserId(\n userId: string,\n scopes: Array<OkHiAccessScope>\n ) {\n return this.anonymousSignIn({\n scopes,\n user_id: userId,\n });\n }\n\n private async anonymousSignIn(payload: {\n scopes: Array<OkHiAccessScope>;\n [key: string]: any;\n }): Promise<string> {\n return new Promise(async (resolve, reject) => {\n try {\n const config = this.config || (await getApplicationConfiguration());\n if (config === null || !config.auth || !config.auth.token) {\n reject(\n new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n })\n );\n } else {\n const { auth, context } = config;\n let url = this.SANDBOX_BASE_URL;\n if (context?.mode === ('dev' as any)) {\n url = this.DEV_BASE_URL;\n } else if (context?.mode === OkHiMode.PROD) {\n url = this.PROD_BASE_URL;\n } else {\n url = this.SANDBOX_BASE_URL;\n }\n const headers = { Authorization: auth.token };\n const { data } = await axios.post(url, payload, {\n headers,\n });\n resolve(data.authorization_token);\n }\n } catch (error) {\n reject(this.parseRequestError(error));\n }\n });\n }\n\n private parseRequestError(error: any) {\n if (!error.response) {\n return new OkHiException({\n code: OkHiException.NETWORK_ERROR_CODE,\n message: OkHiException.NETWORK_ERROR_MESSAGE,\n });\n }\n switch (error.response.status) {\n case 400:\n return new OkHiException({\n code: OkHiException.INVALID_PHONE_CODE,\n message: OkHiException.INVALID_PHONE_MESSAGE,\n });\n case 401:\n return new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n default:\n return new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n });\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;AACO,MAAMA,QAAN,CAAe;EAAA;IAAA,qCACW,IADX;;IAAA,oDAE0B,wBAF1B;;IAAA,sCAIjB,2BAA0B,KAAKC,WAAY,EAA5C,GACA,KAAKC,0BALa;;IAAA,0CAOjB,+BAA8B,KAAKD,WAAY,EAAhD,GACA,KAAKC,0BARa;;IAAA,uCAUjB,uBAAsB,KAAKD,WAAY,EAAxC,GAA4C,KAAKC,0BAV/B;;IAAA,gCAW2B,IAX3B;EAAA;;EAapBC,8BAA8B,CAC5BC,KAD4B,EAE5BC,MAF4B,EAG5BC,MAH4B,EAI5B;IACA,KAAKA,MAAL,GAAcA,MAAd;IACA,OAAO,KAAKC,eAAL,CAAqB;MAC1BF,MAD0B;MAE1BD;IAF0B,CAArB,CAAP;EAID;;EAESI,yBAAyB,CACjCC,MADiC,EAEjCJ,MAFiC,EAGjC;IACA,OAAO,KAAKE,eAAL,CAAqB;MAC1BF,MAD0B;MAE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AAP,EAAc;QACdvB,MAAM,CAAC,KAAKwB,iBAAL,CAAuBD,KAAvB,CAAD,CAAN;MACD;IACF,CA7BM,CAAP;EA8BD;;EAEOC,iBAAiB,CAACD,KAAD,EAAa;IACpC,IAAI,CAACA,KAAK,CAACE,QAAX,EAAqB;MACnB,OAAO,IAAIrB,4BAAJ,CAAkB;QACvBC,IAAI,EAAED,4BAAA,CAAcsB,kBADG;QAEvBnB,OAAO,EAAEH,4BAAA,CAAcuB;MAFA,CAAlB,CAAP;IAID;;IACD,QAAQJ,KAAK,CAACE,QAAN,CAAeG,MAAvB;MACE,KAAK,GAAL;QACE,OAAO,IAAIxB,4BAAJ,CAAkB;UACvBC,IAAI,EAAED,4BAAA,CAAcyB,kBADG;UAEvBtB,OAAO,EAAEH,4BAAA,CAAc0B;QAFA,CAAlB,CAAP;;MAIF,KAAK,GAAL;QACE,OAAO,IAAI1B,4BAAJ,CAAkB;UACvBC,IAAI,EAAED,4BAAA,CAAcE,iBADG;UAEvBC,OAAO,EAAEH,4BAAA,CAAcI;QAFA,CAAlB,CAAP;;MAIF;QACE,OAAO,IAAIJ,4BAAJ,CAAkB;UACvBC,IAAI,EAAED,4BAAA,CAAc2B,kBADG;UAEvBxB,OAAO,EAAEgB,KAAK,CAAChB,OAAN,IAAiBH,4BAAA,CAAc4B;QAFjB,CAAlB,CAAP;IAZJ;EAiBD;;AA/FmB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["OkHiException.ts"],"names":["OkHiException","Error","constructor","error","message","name","code"],"mappings":";;;;;;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,aAAN,SAA4BC,KAA5B,CAAkC;AACvC;AACF;AACA;;AAGE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAGE;AACF;AACA;;AAEE;AACF;AACA;;AAGE;AACF;AACA;;AAEE;AACF;AACA;;AAGE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAEE;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AACA;AACA;AACEC,EAAAA,WAAW,CAACC,KAAD,EAAmB;AAC5B,UAAMA,KAAK,CAACC,OAAZ;;AAD4B;;AAE5B,SAAKC,IAAL,GAAY,eAAZ;AACA,SAAKD,OAAL,GAAeD,KAAK,CAACC,OAArB;AACA,SAAKE,IAAL,GAAYH,KAAK,CAACG,IAAlB;AACD;;AArFsC;;;;gBAA5BN,a,wCAIiC,+B;;gBAJjCA,a,oCAS6B,2B;;gBAT7BA,a,wBAaiB,e;;gBAbjBA,a,2BAkBT,oD;;gBAlBSA,a,wBAsBiB,e;;gBAtBjBA,a,2BA2BT,qD;;gBA3BSA,a,wBA+BiB,e;;gBA/BjBA,a,2BAoCT,+E;;gBApCSA,a,uBAwCgB,c;;gBAxChBA,a,0BA4CmB,8B;;gBA5CnBA,a,4BAgDqB,mB;;gBAhDrBA,a,8BAoDuB,qB;;gBApDvBA,a,+BAwDwB,sB;;gBAxDxBA,a,kCA4D2B,mC;;gBA5D3BA,a,sBAgEe,a;;gBAhEfA,a,yBAoEkB,6B","sourcesContent":["import type { OkHiError } from './types';\n\n/**\n * The OkHiException class extends the Error class to provide additional information regarding the type of errors thrown while running any OkHiLibraries.\n * It contains static string properties that can be used to evaluate the kind of errors being thrown and handle them appropriately.\n */\nexport class OkHiException extends Error {\n /**\n * Error is thrown when location services is unavailable.\n */\n static LOCATION_SERVICES_UNAVAILABLE_CODE = 'location_services_unavailable';\n\n /**\n * Error is thrown when play services is unavailable.\n */\n static PLAY_SERVICES_UNAVAILABLE_CODE = 'play_services_unavailable';\n /**\n * Error is thrown when the device can't connect to OkHi's servers.\n */\n static NETWORK_ERROR_CODE = 'network_error';\n /**\n * Error is thrown when the device can't connect to OkHi's servers.\n */\n static NETWORK_ERROR_MESSAGE =\n 'Unable to establish a connection with OkHi servers';\n /**\n * Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.\n */\n static UNKNOWN_ERROR_CODE = 'unknown_error';\n /**\n * Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.\n */\n static UNKNOWN_ERROR_MESSAGE =\n 'Unable to process the request. Something went wrong';\n /**\n * Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.\n */\n static INVALID_PHONE_CODE = 'invalid_phone';\n /**\n * Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.\n */\n static INVALID_PHONE_MESSAGE =\n 'Invalid phone number provided. Please make sure its in MSISDN standard format';\n /**\n * Error is thrown whenever there's an issue with the credentials provided.\n */\n static UNAUTHORIZED_CODE = 'unauthorized';\n /**\n * Error is thrown whenever there's an issue with the credentials provided.\n */\n static UNAUTHORIZED_MESSAGE = 'Invalid credentials provided';\n /**\n * Error is thrown whenever a particular permission is required for a service to run and isn't granted by the user.\n */\n static PERMISSION_DENIED_CODE = 'permission_denied';\n /**\n * Error is thrown whenever a particular device service is required for a library to run and isn't granted by the user.\n */\n static SERVICE_UNAVAILABLE_CODE = 'service_unavailable';\n /**\n * Error is thrown whenever an OkHi service is run on an unsupported platform.\n */\n static UNSUPPORTED_PLATFORM_CODE = 'unsupported_platform';\n /**\n * Error is thrown whenever an OkHi service is run on an unsupported platform.\n */\n static UNSUPPORTED_PLATFORM_MESSAGE = 'Current platform is not supported';\n /**\n * Error is thrown whenever bad configuration is provided to an OkHi service.\n */\n static BAD_REQUEST_CODE = 'bad_request';\n /**\n * Error is thrown whenever bad configuration is provided to an OkHi service.\n */\n static BAD_REQUEST_MESSAGE = 'Invalid parameters provided';\n\n /**\n * Specific error code string detailing the kind of error being thrown.\n */\n code: string;\n\n /**\n * @param error An error object with code and respective message.\n * @param error.code Specific error code string detailing the kind of error being thrown.\n * @param error.message Specific error message string detailing the kind of error being thrown.\n */\n constructor(error: OkHiError) {\n super(error.message);\n this.name = 'OkHiException';\n this.message = error.message;\n this.code = error.code;\n }\n}\n"]}
1
+ {"version":3,"names":["OkHiException","Error","constructor","error","message","name","code"],"sources":["OkHiException.ts"],"sourcesContent":["import type { OkHiError } from './types';\n\n/**\n * The OkHiException class extends the Error class to provide additional information regarding the type of errors thrown while running any OkHiLibraries.\n * It contains static string properties that can be used to evaluate the kind of errors being thrown and handle them appropriately.\n */\nexport class OkHiException extends Error {\n /**\n * Error is thrown when location services is unavailable.\n */\n static LOCATION_SERVICES_UNAVAILABLE_CODE = 'location_services_unavailable';\n\n /**\n * Error is thrown when play services is unavailable.\n */\n static PLAY_SERVICES_UNAVAILABLE_CODE = 'play_services_unavailable';\n /**\n * Error is thrown when the device can't connect to OkHi's servers.\n */\n static NETWORK_ERROR_CODE = 'network_error';\n /**\n * Error is thrown when the device can't connect to OkHi's servers.\n */\n static NETWORK_ERROR_MESSAGE =\n 'Unable to establish a connection with OkHi servers';\n /**\n * Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.\n */\n static UNKNOWN_ERROR_CODE = 'unknown_error';\n /**\n * Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.\n */\n static UNKNOWN_ERROR_MESSAGE =\n 'Unable to process the request. Something went wrong';\n /**\n * Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.\n */\n static INVALID_PHONE_CODE = 'invalid_phone';\n /**\n * Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.\n */\n static INVALID_PHONE_MESSAGE =\n 'Invalid phone number provided. Please make sure its in MSISDN standard format';\n /**\n * Error is thrown whenever there's an issue with the credentials provided.\n */\n static UNAUTHORIZED_CODE = 'unauthorized';\n /**\n * Error is thrown whenever there's an issue with the credentials provided.\n */\n static UNAUTHORIZED_MESSAGE = 'Invalid credentials provided';\n /**\n * Error is thrown whenever a particular permission is required for a service to run and isn't granted by the user.\n */\n static PERMISSION_DENIED_CODE = 'permission_denied';\n /**\n * Error is thrown whenever a particular device service is required for a library to run and isn't granted by the user.\n */\n static SERVICE_UNAVAILABLE_CODE = 'service_unavailable';\n /**\n * Error is thrown whenever an OkHi service is run on an unsupported platform.\n */\n static UNSUPPORTED_PLATFORM_CODE = 'unsupported_platform';\n /**\n * Error is thrown whenever an OkHi service is run on an unsupported platform.\n */\n static UNSUPPORTED_PLATFORM_MESSAGE = 'Current platform is not supported';\n /**\n * Error is thrown whenever bad configuration is provided to an OkHi service.\n */\n static BAD_REQUEST_CODE = 'bad_request';\n /**\n * Error is thrown whenever bad configuration is provided to an OkHi service.\n */\n static BAD_REQUEST_MESSAGE = 'Invalid parameters provided';\n\n /**\n * Specific error code string detailing the kind of error being thrown.\n */\n code: string;\n\n /**\n * @param error An error object with code and respective message.\n * @param error.code Specific error code string detailing the kind of error being thrown.\n * @param error.message Specific error message string detailing the kind of error being thrown.\n */\n constructor(error: OkHiError) {\n super(error.message);\n this.name = 'OkHiException';\n this.message = error.message;\n this.code = error.code;\n }\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,aAAN,SAA4BC,KAA5B,CAAkC;EACvC;AACF;AACA;;EAGE;AACF;AACA;;EAEE;AACF;AACA;;EAEE;AACF;AACA;;EAGE;AACF;AACA;;EAEE;AACF;AACA;;EAGE;AACF;AACA;;EAEE;AACF;AACA;;EAGE;AACF;AACA;;EAEE;AACF;AACA;;EAEE;AACF;AACA;;EAEE;AACF;AACA;;EAEE;AACF;AACA;;EAEE;AACF;AACA;;EAEE;AACF;AACA;;EAEE;AACF;AACA;;EAGE;AACF;AACA;;EAGE;AACF;AACA;AACA;AACA;EACEC,WAAW,CAACC,KAAD,EAAmB;IAC5B,MAAMA,KAAK,CAACC,OAAZ;;IAD4B;;IAE5B,KAAKC,IAAL,GAAY,eAAZ;IACA,KAAKD,OAAL,GAAeD,KAAK,CAACC,OAArB;IACA,KAAKE,IAAL,GAAYH,KAAK,CAACG,IAAlB;EACD;;AArFsC;;;;gBAA5BN,a,wCAIiC,+B;;gBAJjCA,a,oCAS6B,2B;;gBAT7BA,a,wBAaiB,e;;gBAbjBA,a,2BAkBT,oD;;gBAlBSA,a,wBAsBiB,e;;gBAtBjBA,a,2BA2BT,qD;;gBA3BSA,a,wBA+BiB,e;;gBA/BjBA,a,2BAoCT,+E;;gBApCSA,a,uBAwCgB,c;;gBAxChBA,a,0BA4CmB,8B;;gBA5CnBA,a,4BAgDqB,mB;;gBAhDrBA,a,8BAoDuB,qB;;gBApDvBA,a,+BAwDwB,sB;;gBAxDxBA,a,kCA4D2B,mC;;gBA5D3BA,a,sBAgEe,a;;gBAhEfA,a,yBAoEkB,6B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["OkHiMode.ts"],"names":["OkHiMode","Object","freeze","SANDBOX","PROD"],"mappings":";;;;;;;AAAA;AACA;AACA;AACO,MAAMA,QAA2C,GAAGC,MAAM,CAACC,MAAP,CAAc;AACvEC,EAAAA,OAAO,EAAE,SAD8D;AAEvEC,EAAAA,IAAI,EAAE;AAFiE,CAAd,CAApD","sourcesContent":["/**\n * Sets the current mode that you'd like to use OkHi's services.\n */\nexport const OkHiMode: { SANDBOX: string; PROD: string } = Object.freeze({\n SANDBOX: 'sandbox',\n PROD: 'prod',\n});\n"]}
1
+ {"version":3,"names":["OkHiMode","Object","freeze","SANDBOX","PROD"],"sources":["OkHiMode.ts"],"sourcesContent":["/**\n * Sets the current mode that you'd like to use OkHi's services.\n */\nexport const OkHiMode: { SANDBOX: string; PROD: string } = Object.freeze({\n SANDBOX: 'sandbox',\n PROD: 'prod',\n});\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACO,MAAMA,QAA2C,GAAGC,MAAM,CAACC,MAAP,CAAc;EACvEC,OAAO,EAAE,SAD8D;EAEvEC,IAAI,EAAE;AAFiE,CAAd,CAApD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["_helpers.ts"],"names":["SUPPORTED_PLATFORMS","isValidPlatform","fn","platform","callingFunc","arguments","callee","caller","name","Promise","resolve","reject","error","OkHiException","code","UNSUPPORTED_PLATFORM_CODE","message","Platform","OS","includes","then","catch","UNKNOWN_ERROR_CODE","UNKNOW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T,IAAAA,EAAE,GACCkB,IADH,CACQV,OADR,EAEGW,KAFH,CAEUT,KAAD,IAAW;AAChBD,MAAAA,MAAM,CACJ,IAAIE,4BAAJ,CAAkB;AAChBC,QAAAA,IAAI,EAAEF,KAAK,CAACE,IAAN,IAAcD,6BAAcS,kBADlB;AAEhBN,QAAAA,OAAO,EAAEJ,KAAK,CAACI,OAAN,IAAiBH,6BAAcU;AAFxB,OAAlB,CADI,CAAN;AAMD,KATH;AAUD,GAXM,CAAP;AAYD","sourcesContent":["import { Platform, PlatformOSType } from 'react-native';\nimport { OkHiException } from './OkHiException';\n\nconst SUPPORTED_PLATFORMS = ['ios', 'android'];\n\nexport function isValidPlatform<T>(\n fn: () => Promise<T>,\n platform?: PlatformOSType\n) {\n const callingFunc = arguments?.callee?.caller?.name || 'function';\n return new Promise<T>((resolve, reject) => {\n const error = new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: callingFunc + ' is not supported in ' + Platform.OS,\n });\n if (platform && Platform.OS !== platform) {\n reject(error);\n } else if (!SUPPORTED_PLATFORMS.includes(Platform.OS)) {\n reject(error);\n } else {\n fn()\n .then(resolve)\n .catch((error) => {\n reject(\n new OkHiException({\n code: error.code || OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n })\n );\n });\n }\n });\n}\n\nexport function errorHandler<T>(fn: () => Promise<T>) {\n return new Promise<T>((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n reject(\n new OkHiException({\n code: error.code || OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n })\n );\n });\n });\n}\n"]}
1
+ {"version":3,"names":["SUPPORTED_PLATFORMS","isValidPlatform","fn","platform","callingFunc","arguments","callee","caller","name","Promise","resolve","reject","error","OkHiException","code","UNSUPPORTED_PLATFORM_CODE","message","Platform","OS","includes","then","catch","UNKNOWN_ERROR_CODE","UNKNOWN_ERROR_MESSAGE","errorHandler"],"sources":["_helpers.ts"],"sourcesContent":["import { Platform, PlatformOSType } from 'react-native';\nimport { OkHiException } from './OkHiException';\n\nconst SUPPORTED_PLATFORMS = ['ios', 'android'];\n\nexport function isValidPlatform<T>(\n fn: () => Promise<T>,\n platform?: PlatformOSType\n) {\n const callingFunc = arguments?.callee?.caller?.name || 'function';\n return new Promise<T>((resolve, reject) => {\n const error = new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: callingFunc + ' is not supported in ' + Platform.OS,\n });\n if (platform && Platform.OS !== platform) {\n reject(error);\n } else if (!SUPPORTED_PLATFORMS.includes(Platform.OS)) {\n reject(error);\n } else {\n fn()\n .then(resolve)\n .catch((error) => {\n reject(\n new OkHiException({\n code: error.code || OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n })\n );\n });\n }\n });\n}\n\nexport function errorHandler<T>(fn: () => Promise<T>) {\n return new Promise<T>((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n reject(\n new OkHiException({\n code: error.code || OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n })\n );\n });\n });\n}\n"],"mappings":";;;;;;;;AAAA;;AACA;;AAEA,MAAMA,mBAAmB,GAAG,CAAC,KAAD,EAAQ,SAAR,CAA5B;;AAEO,SAASC,eAAT,CACLC,EADK,EAELC,QAFK,EAGL;EAAA;;EACA,MAAMC,WAAW,GAAG,CAAAC,SAAS,SAAT,IAAAA,SAAS,WAAT,iCAAAA,SAAS,CAAEC,MAAX,iGAAmBC,MAAnB,gFAA2BC,IAA3B,KAAmC,UAAvD;EACA,OAAO,IAAIC,OAAJ,CAAe,CAACC,OAAD,EAAUC,MAAV,KAAqB;IACzC,MAAMC,KAAK,GAAG,IAAIC,4BAAJ,CAAkB;MAC9BC,IAAI,EAAED,4BAAA,CAAcE,yBADU;MAE9BC,OAAO,EAAEZ,WAAW,GAAG,uBAAd,GAAwCa,qBAAA,CAASC;IAF5B,CAAlB,CAAd;;IAIA,IAAIf,QAAQ,IAAIc,qBAAA,CAASC,EAAT,KAAgBf,QAAhC,EAA0C;MACxCQ,MAAM,CAACC,KAAD,CAAN;IACD,CAFD,MAEO,IAAI,CAACZ,mBAAmB,CAACmB,QAApB,CAA6BF,qBAAA,CAASC,EAAtC,CAAL,EAAgD;MACrDP,MAAM,CAACC,KAAD,CAAN;IACD,CAFM,MAEA;MACLV,EAAE,GACCkB,IADH,CACQV,OADR,EAEGW,KAFH,CAEUT,KAAD,IAAW;QAChBD,MAAM,CACJ,IAAIE,4BAAJ,CAAkB;UAChBC,IAAI,EAAEF,KAAK,CAACE,IAAN,IAAcD,4BAAA,CAAcS,kBADlB;UAEhBN,OAAO,EAAEJ,KAAK,CAACI,OAAN,IAAiBH,4BAAA,CAAcU;QAFxB,CAAlB,CADI,CAAN;MAMD,CATH;IAUD;EACF,CArBM,CAAP;AAsBD;;AAEM,SAASC,YAAT,CAAyBtB,EAAzB,EAA+C;EACpD,OAAO,IAAIO,OAAJ,CAAe,CAACC,OAAD,EAAUC,MAAV,KAAqB;IACzCT,EAAE,GACCkB,IADH,CACQV,OADR,EAEGW,KAFH,CAEUT,KAAD,IAAW;MAChBD,MAAM,CACJ,IAAIE,4BAAJ,CAAkB;QAChBC,IAAI,EAAEF,KAAK,CAACE,IAAN,IAAcD,4BAAA,CAAcS,kBADlB;QAEhBN,OAAO,EAAEJ,KAAK,CAACI,OAAN,IAAiBH,4BAAA,CAAcU;MAFxB,CAAlB,CADI,CAAN;IAMD,CATH;EAUD,CAXM,CAAP;AAYD"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["_types.ts"],"sourcesContent":["/**\n * @ignore\n */\nexport type OkHiAccessScope = 'verify' | 'address' | 'checkout' | 'profile';\n\nexport type OkHiInitializationConfiguration = {\n credentials: { branchId: string; clientKey: string };\n context: {\n mode: string;\n platform: 'react-native';\n developer: 'okhi' | 'external';\n };\n app?: {\n name?: string | null;\n version?: string | null;\n build?: number | null;\n };\n};\n\nexport type AuthApplicationConfig = {\n auth: {\n token: string;\n };\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};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["okhiApplicationConfiguration","initialize","configuration","AppState","currentState","Platform","OS","OkHiNativeModule","JSON","stringify","initializeIOS","credentials","branchId","clientKey","context","mode","getApplicationConfiguration","auth","token","getAuthToken","error"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAIA,4BAAJ;AAEA;AACA;AACA;AACA;AACA;;AACO,SAASC,UAAT,CACLC,aADK,EAEU;AACf,SAAO,2BAAa,YAAY;AAC9BF,IAAAA,4BAA4B,GAAGE,aAA/B;;AACA,QAAIC,sBAASC,YAAT,KAA0B,YAA9B,EAA4C;AAC1C,UAAIC,sBAASC,EAAT,KAAgB,SAApB,EAA+B;AAC7B,cAAMC,mCAAiBN,UAAjB,CAA4BO,IAAI,CAACC,SAAL,CAAeP,aAAf,CAA5B,CAAN;AACD,OAFD,MAEO;AACL,cAAMK,mCAAiBG,aAAjB,CACJR,aAAa,CAACS,WAAd,CAA0BC,QADtB,EAEJV,aAAa,CAACS,WAAd,CAA0BE,SAFtB,EAGJX,aAAa,CAACY,OAAd,CAAsBC,IAHlB,CAAN;AAKD;AACF;AACF,GAbM,CAAP;AAcD;AAED;AACA;AACA;AACA;;;AACO,eAAeC,2BAAf,GAAoF;AACzF,MAAI;AACF,QAAI,OAAOhB,4BAAP,KAAwC,QAA5C,EAAsD;AAAA;;AACpD,aAAO,EACL,GAAGA,4BADE;AAELiB,QAAAA,IAAI,EAAE;AACJC,UAAAA,KAAK,EAAE,MAAMX,mCAAiBY,YAAjB,CACX,0BAAAnB,4BAA4B,UAA5B,sEAA8BW,WAA9B,CAA0CC,QAA1C,KAAsD,EAD3C,EAEX,2BAAAZ,4BAA4B,UAA5B,wEAA8BW,WAA9B,CAA0CE,SAA1C,KAAuD,EAF5C;AADT;AAFD,OAAP;AASD;;AACD,WAAO,IAAP;AACD,GAbD,CAaE,OAAOO,KAAP,EAAc;AACd,UAAMA,KAAN;AACD;AACF","sourcesContent":["import { Platform, AppState } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkHiApplicationConfiguration } from './types';\nimport { errorHandler } from './_helpers';\nimport type { AuthApplicationConfig } from './_types';\n\nexport * from './types';\nexport * from './OkHiException';\nexport * from './OkHiMode';\nexport * from './Helpers';\n\nlet okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;\n\n/**\n * Initializes the OkHi library with provided API keys\n * @param {Object} configuration A configuration object with your OkHi credentials as well as library settings\n * @returns {Promise<void>} A promise that resolves when initialization is successful\n */\nexport function initialize(\n configuration: OkHiApplicationConfiguration\n): Promise<void> {\n return errorHandler(async () => {\n okhiApplicationConfiguration = configuration;\n if (AppState.currentState !== 'background') {\n if (Platform.OS === 'android') {\n await OkHiNativeModule.initialize(JSON.stringify(configuration));\n } else {\n await OkHiNativeModule.initializeIOS(\n configuration.credentials.branchId,\n configuration.credentials.clientKey,\n configuration.context.mode\n );\n }\n }\n });\n}\n\n/**\n * Obtains your current running configuration\n * @returns {Promise<void>} A promise that resolves with your application configuration\n */\nexport async function getApplicationConfiguration(): Promise<AuthApplicationConfig | null> {\n try {\n if (typeof okhiApplicationConfiguration === 'object') {\n return {\n ...okhiApplicationConfiguration,\n auth: {\n token: await OkHiNativeModule.getAuthToken(\n okhiApplicationConfiguration?.credentials.branchId || '',\n okhiApplicationConfiguration?.credentials.clientKey || ''\n ),\n },\n };\n }\n return null;\n } catch (error) {\n throw error;\n }\n}\n"]}
1
+ {"version":3,"names":["okhiApplicationConfiguration","initialize","configuration","errorHandler","AppState","currentState","Platform","OS","OkHiNativeModule","JSON","stringify","initializeIOS","credentials","branchId","clientKey","context","mode","getApplicationConfiguration","auth","token","getAuthToken","error"],"sources":["index.ts"],"sourcesContent":["import { Platform, AppState } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkHiApplicationConfiguration } from './types';\nimport { errorHandler } from './_helpers';\nimport type { AuthApplicationConfig } from './_types';\n\nexport * from './types';\nexport * from './OkHiException';\nexport * from './OkHiMode';\nexport * from './Helpers';\n\nlet okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;\n\n/**\n * Initializes the OkHi library with provided API keys\n * @param {Object} configuration A configuration object with your OkHi credentials as well as library settings\n * @returns {Promise<void>} A promise that resolves when initialization is successful\n */\nexport function initialize(\n configuration: OkHiApplicationConfiguration\n): Promise<void> {\n return errorHandler(async () => {\n okhiApplicationConfiguration = configuration;\n if (AppState.currentState !== 'background') {\n if (Platform.OS === 'android') {\n await OkHiNativeModule.initialize(JSON.stringify(configuration));\n } else {\n await OkHiNativeModule.initializeIOS(\n configuration.credentials.branchId,\n configuration.credentials.clientKey,\n configuration.context.mode\n );\n }\n }\n });\n}\n\n/**\n * Obtains your current running configuration\n * @returns {Promise<void>} A promise that resolves with your application configuration\n */\nexport async function getApplicationConfiguration(): Promise<AuthApplicationConfig | null> {\n try {\n if (typeof okhiApplicationConfiguration === 'object') {\n return {\n ...okhiApplicationConfiguration,\n auth: {\n token: await OkHiNativeModule.getAuthToken(\n okhiApplicationConfiguration?.credentials.branchId || '',\n okhiApplicationConfiguration?.credentials.clientKey || ''\n ),\n },\n };\n }\n return null;\n } catch (error) {\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AAEA;;AAGA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEA,IAAIA,4BAAJ;AAEA;AACA;AACA;AACA;AACA;;AACO,SAASC,UAAT,CACLC,aADK,EAEU;EACf,OAAO,IAAAC,qBAAA,EAAa,YAAY;IAC9BH,4BAA4B,GAAGE,aAA/B;;IACA,IAAIE,qBAAA,CAASC,YAAT,KAA0B,YAA9B,EAA4C;MAC1C,IAAIC,qBAAA,CAASC,EAAT,KAAgB,SAApB,EAA+B;QAC7B,MAAMC,kCAAA,CAAiBP,UAAjB,CAA4BQ,IAAI,CAACC,SAAL,CAAeR,aAAf,CAA5B,CAAN;MACD,CAFD,MAEO;QACL,MAAMM,kCAAA,CAAiBG,aAAjB,CACJT,aAAa,CAACU,WAAd,CAA0BC,QADtB,EAEJX,aAAa,CAACU,WAAd,CAA0BE,SAFtB,EAGJZ,aAAa,CAACa,OAAd,CAAsBC,IAHlB,CAAN;MAKD;IACF;EACF,CAbM,CAAP;AAcD;AAED;AACA;AACA;AACA;;;AACO,eAAeC,2BAAf,GAAoF;EACzF,IAAI;IACF,IAAI,OAAOjB,4BAAP,KAAwC,QAA5C,EAAsD;MAAA;;MACpD,OAAO,EACL,GAAGA,4BADE;QAELkB,IAAI,EAAE;UACJC,KAAK,EAAE,MAAMX,kCAAA,CAAiBY,YAAjB,CACX,0BAAApB,4BAA4B,UAA5B,sEAA8BY,WAA9B,CAA0CC,QAA1C,KAAsD,EAD3C,EAEX,2BAAAb,4BAA4B,UAA5B,wEAA8BY,WAA9B,CAA0CE,SAA1C,KAAuD,EAF5C;QADT;MAFD,CAAP;IASD;;IACD,OAAO,IAAP;EACD,CAbD,CAaE,OAAOO,KAAP,EAAc;IACd,MAAMA,KAAN;EACD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
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 OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n id?: 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/**\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":""}
@@ -7,7 +7,16 @@ exports.OkHiNativeModule = exports.OkHiNativeEvents = void 0;
7
7
 
8
8
  var _reactNative = require("react-native");
9
9
 
10
- const OkHiNativeModule = _reactNative.NativeModules.Okhi;
10
+ const LINKING_ERROR = `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
11
+ ios: "- You have run 'pod install'\n",
12
+ default: ''
13
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
14
+ const OkHiNativeModule = _reactNative.NativeModules.Okhi ? _reactNative.NativeModules.Okhi : new Proxy({}, {
15
+ get() {
16
+ throw new Error(LINKING_ERROR);
17
+ }
18
+
19
+ });
11
20
  exports.OkHiNativeModule = OkHiNativeModule;
12
21
  const OkHiNativeEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Okhi);
13
22
  exports.OkHiNativeEvents = OkHiNativeEvents;
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["OkHiNativeModule","NativeModules","Okhi","OkHiNativeEvents","NativeEventEmitter","addListener"],"mappings":";;;;;;;AAAA;;AA2CO,MAAMA,gBAAsC,GAAGC,2BAAcC,IAA7D;;AAEA,MAAMC,gBAAgB,GAAG,IAAIC,+BAAJ,CAAuBH,2BAAcC,IAArC,CAAzB;;AAEPC,gBAAgB,CAACE,WAAjB,CAA6B,kCAA7B,EAAiE,MAAM,IAAvE","sourcesContent":["import { NativeModules, NativeEventEmitter } from 'react-native';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\n\ntype OkHiNativeModuleType = {\n multiply(a: number, b: number): Promise<number>;\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 ): 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};\n\nexport const OkHiNativeModule: OkHiNativeModuleType = NativeModules.Okhi;\n\nexport const OkHiNativeEvents = new NativeEventEmitter(NativeModules.Okhi);\n\nOkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);\n"]}
1
+ {"version":3,"names":["LINKING_ERROR","Platform","select","ios","default","OkHiNativeModule","NativeModules","Okhi","Proxy","get","Error","OkHiNativeEvents","NativeEventEmitter","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 ): 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};\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;;AAGA,MAAMA,aAAa,GAChB,4EAAD,GACAC,qBAAA,CAASC,MAAT,CAAgB;EAAEC,GAAG,EAAE,gCAAP;EAAyCC,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AA6CO,MAAMC,gBAAsC,GAAGC,0BAAA,CAAcC,IAAd,GAClDD,0BAAA,CAAcC,IADoC,GAElD,IAAIC,KAAJ,CACE,EADF,EAEE;EACEC,GAAG,GAAG;IACJ,MAAM,IAAIC,KAAJ,CAAUV,aAAV,CAAN;EACD;;AAHH,CAFF,CAFG;;AAWA,MAAMW,gBAAgB,GAAG,IAAIC,+BAAJ,CAAuBN,0BAAA,CAAcC,IAArC,CAAzB;;AAEPI,gBAAgB,CAACE,WAAjB,CAA6B,kCAA7B,EAAiE,MAAM,IAAvE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["start","phoneNumber","locationId","lat","lon","configuration","Platform","OS","OkHiNativeModule","startAddressVerification","startVerification","response","Promise","resolve","reject","location","user","id","result","phone","OkHiException","code","BAD_REQUEST_CODE","message","stopVerification","stopAddressVerification","startForegroundService","stopForegroundService","isForegroundServiceRunning","canStartVerification","requestServices","locationServicesStatus","googlePlayServices","backgroundLocationPerm","whenInUseLocationPerm","SERVICE_UNAVAILABLE_CODE","iosPerm","locationServicesRequestStatus","gPlayServices","androidPerm","UNSUPPORTED_PLATFORM_CODE","UNSUPPORTED_PLATFORM_MESSAGE","checkVerificationStartRequirements","isPlayServicesAvailable","PLAY_SERVICES_UNAVAILABLE_CODE","LOCATION_SERVICES_UNAVAILABLE_CODE","PERMISSION_DENIED_CODE"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AAUA;;AACA;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,CACnBC,WADmB,EAEnBC,UAFmB,EAGnBC,GAHmB,EAInBC,GAJmB,EAKnBC,aALmB,KAMhB;AACH,SAAO,8BAAgB,MAAM;AAC3B,QAAIC,sBAASC,EAAT,KAAgB,SAApB,EAA+B;AAC7B,aAAOC,mCAAiBC,wBAAjB,CACLR,WADK,EAELC,UAFK,EAGLC,GAHK,EAILC,GAJK,EAKLC,aALK,CAAP;AAOD,KARD,MAQO;AACL,aAAOG,mCAAiBC,wBAAjB,CACLR,WADK,EAELC,UAFK,EAGLC,GAHK,EAILC,GAJK,CAAP;AAMD;AACF,GAjBM,CAAP;AAkBD,CAzBM;AA2BP;AACA;AACA;AACA;AACA;AACA;AACA;AACA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qDAAR,CAAJ,EAAsD;AACpDT,MAAAA,MAAM,CACJ,IAAIM,4BAAJ,CAAkB;AAChBC,QAAAA,IAAI,EAAED,6BAAc0B,sBADJ;AAEhBvB,QAAAA,OAAO,EAAE;AAFO,OAAlB,CADI,CAAN;AAMA;AACD;;AACDV,IAAAA,OAAO,CAAC,IAAD,CAAP;AACD,GAhCM,CAAP;AAiCD,CAlCM","sourcesContent":["import { Platform } from 'react-native';\nimport {\n isBackgroundLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n isLocationServicesEnabled,\n requestBackgroundLocationPermission,\n requestEnableGooglePlayServices,\n requestEnableLocationServices,\n requestLocationPermission,\n isLocationPermissionGranted,\n} from '../OkCore/Helpers';\nimport { errorHandler, isValidPlatform } from '../OkCore/_helpers';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkVerifyStartConfiguration } from './types';\nimport type { OkCollectSuccessResponse } from '../OkCollect/types';\nimport { OkHiException } from '../OkCore/OkHiException';\nexport * from './types';\n/**\n * Starts verification for a particular address\n * @param {string} phoneNumber A users phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @param {number} lat The latitude of the created address\n * @param {number} lon The longitude of the created address\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification, default is true\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const start = (\n phoneNumber: string,\n locationId: string,\n lat: number,\n lon: number,\n configuration?: OkVerifyStartConfiguration\n) => {\n return isValidPlatform(() => {\n if (Platform.OS === 'android') {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon,\n configuration\n );\n } else {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon\n );\n }\n });\n};\n\n/**\n * Starts verification for a particular address using the response object returned by OkCollect\n * @param {Object} response Response returned by OkCollect\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const startVerification = async (\n response: OkCollectSuccessResponse,\n configuration?: OkVerifyStartConfiguration\n) => {\n return new Promise((resolve, reject) => {\n const { location, user } = response;\n if (location.id) {\n if (Platform.OS === 'android') {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon,\n configuration\n );\n resolve(result);\n } else {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon\n );\n resolve(result);\n }\n } else {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n }\n });\n};\n\n/**\n * Stops verification for a particular address using a user's phonenumber and OkHi location identifier\n * @param {string} phoneNumber The user's phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const stopVerification = (phoneNumber: string, locationId: string) => {\n return isValidPlatform(() =>\n OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)\n );\n};\n\n/**\n * Android Only - Starts a foreground service that speeds up rate of verification\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const startForegroundService = () => {\n return isValidPlatform(\n () => errorHandler(OkHiNativeModule.startForegroundService),\n 'android'\n );\n};\n\n/**\n * Android Only - Stops previously started foreground services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully\n */\nexport const stopForegroundService = () => {\n return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');\n};\n\n/**\n * Android Only - Checks if the foreground service is running\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running\n */\nexport const isForegroundServiceRunning = () => {\n return isValidPlatform(\n OkHiNativeModule.isForegroundServiceRunning,\n 'android'\n );\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address verification process\n */\nexport const canStartVerification = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const backgroundLocationPerm =\n await isBackgroundLocationPermissionGranted();\n const whenInUseLocationPerm = await isLocationPermissionGranted();\n if (!requestServices) {\n resolve(\n locationServicesStatus && googlePlayServices && backgroundLocationPerm\n );\n return;\n }\n if (Platform.OS === 'ios') {\n if (!locationServicesStatus) {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n return;\n }\n if (backgroundLocationPerm) {\n resolve(true);\n return;\n }\n if (whenInUseLocationPerm && !backgroundLocationPerm) {\n resolve(false);\n return;\n }\n const iosPerm = await requestBackgroundLocationPermission();\n resolve(iosPerm);\n return;\n } else if (Platform.OS === 'android') {\n const locationServicesRequestStatus =\n (await requestEnableLocationServices()) as boolean;\n const gPlayServices = await requestEnableGooglePlayServices();\n const androidPerm =\n (await requestLocationPermission()) &&\n (await requestBackgroundLocationPermission());\n resolve(locationServicesRequestStatus && gPlayServices && androidPerm);\n } else {\n reject(\n new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,\n })\n );\n }\n });\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address verification process\n */\nexport const checkVerificationStartRequirements = (): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n if (Platform.OS === 'android') {\n const isPlayServicesAvailable = await isGooglePlayServicesAvailable();\n if (!isPlayServicesAvailable) {\n reject(\n new OkHiException({\n code: OkHiException.PLAY_SERVICES_UNAVAILABLE_CODE,\n message: 'Google Play Services is unavailable',\n })\n );\n return;\n }\n }\n if (!(await isLocationServicesEnabled())) {\n reject(\n new OkHiException({\n code: OkHiException.LOCATION_SERVICES_UNAVAILABLE_CODE,\n message: 'Location services unavailable',\n })\n );\n return;\n }\n if (!(await isBackgroundLocationPermissionGranted())) {\n reject(\n new OkHiException({\n code: OkHiException.PERMISSION_DENIED_CODE,\n message: 'Background Location permission not granted',\n })\n );\n return;\n }\n resolve(true);\n });\n};\n"]}
1
+ {"version":3,"names":["start","phoneNumber","locationId","lat","lon","configuration","isValidPlatform","Platform","OS","OkHiNativeModule","startAddressVerification","startVerification","response","Promise","resolve","reject","location","user","id","result","phone","OkHiException","code","BAD_REQUEST_CODE","message","stopVerification","stopAddressVerification","startForegroundService","errorHandler","stopForegroundService","isForegroundServiceRunning","canStartVerification","requestServices","locationServicesStatus","isLocationServicesEnabled","googlePlayServices","isGooglePlayServicesAvailable","backgroundLocationPerm","isBackgroundLocationPermissionGranted","whenInUseLocationPerm","isLocationPermissionGranted","SERVICE_UNAVAILABLE_CODE","iosPerm","requestBackgroundLocationPermission","locationServicesRequestStatus","requestEnableLocationServices","gPlayServices","requestEnableGooglePlayServices","androidPerm","requestLocationPermission","UNSUPPORTED_PLATFORM_CODE","UNSUPPORTED_PLATFORM_MESSAGE","checkVerificationStartRequirements","isPlayServicesAvailable","PLAY_SERVICES_UNAVAILABLE_CODE","LOCATION_SERVICES_UNAVAILABLE_CODE","PERMISSION_DENIED_CODE"],"sources":["index.ts"],"sourcesContent":["import { Platform } from 'react-native';\nimport {\n isBackgroundLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n isLocationServicesEnabled,\n requestBackgroundLocationPermission,\n requestEnableGooglePlayServices,\n requestEnableLocationServices,\n requestLocationPermission,\n isLocationPermissionGranted,\n} from '../OkCore/Helpers';\nimport { errorHandler, isValidPlatform } from '../OkCore/_helpers';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkVerifyStartConfiguration } from './types';\nimport type { OkCollectSuccessResponse } from '../OkCollect/types';\nimport { OkHiException } from '../OkCore/OkHiException';\nexport * from './types';\n/**\n * Starts verification for a particular address\n * @param {string} phoneNumber A users phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @param {number} lat The latitude of the created address\n * @param {number} lon The longitude of the created address\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification, default is true\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const start = (\n phoneNumber: string,\n locationId: string,\n lat: number,\n lon: number,\n configuration?: OkVerifyStartConfiguration\n) => {\n return isValidPlatform(() => {\n if (Platform.OS === 'android') {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon,\n configuration\n );\n } else {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon\n );\n }\n });\n};\n\n/**\n * Starts verification for a particular address using the response object returned by OkCollect\n * @param {Object} response Response returned by OkCollect\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const startVerification = async (\n response: OkCollectSuccessResponse,\n configuration?: OkVerifyStartConfiguration\n) => {\n return new Promise((resolve, reject) => {\n const { location, user } = response;\n if (location.id) {\n if (Platform.OS === 'android') {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon,\n configuration\n );\n resolve(result);\n } else {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon\n );\n resolve(result);\n }\n } else {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n }\n });\n};\n\n/**\n * Stops verification for a particular address using a user's phonenumber and OkHi location identifier\n * @param {string} phoneNumber The user's phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const stopVerification = (phoneNumber: string, locationId: string) => {\n return isValidPlatform(() =>\n OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)\n );\n};\n\n/**\n * Android Only - Starts a foreground service that speeds up rate of verification\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const startForegroundService = () => {\n return isValidPlatform(\n () => errorHandler(OkHiNativeModule.startForegroundService),\n 'android'\n );\n};\n\n/**\n * Android Only - Stops previously started foreground services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully\n */\nexport const stopForegroundService = () => {\n return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');\n};\n\n/**\n * Android Only - Checks if the foreground service is running\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running\n */\nexport const isForegroundServiceRunning = () => {\n return isValidPlatform(\n OkHiNativeModule.isForegroundServiceRunning,\n 'android'\n );\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address verification process\n */\nexport const canStartVerification = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const backgroundLocationPerm =\n await isBackgroundLocationPermissionGranted();\n const whenInUseLocationPerm = await isLocationPermissionGranted();\n if (!requestServices) {\n resolve(\n locationServicesStatus && googlePlayServices && backgroundLocationPerm\n );\n return;\n }\n if (Platform.OS === 'ios') {\n if (!locationServicesStatus) {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n return;\n }\n if (backgroundLocationPerm) {\n resolve(true);\n return;\n }\n if (whenInUseLocationPerm && !backgroundLocationPerm) {\n resolve(false);\n return;\n }\n const iosPerm = await requestBackgroundLocationPermission();\n resolve(iosPerm);\n return;\n } else if (Platform.OS === 'android') {\n const locationServicesRequestStatus =\n (await requestEnableLocationServices()) as boolean;\n const gPlayServices = await requestEnableGooglePlayServices();\n const androidPerm =\n (await requestLocationPermission()) &&\n (await requestBackgroundLocationPermission());\n resolve(locationServicesRequestStatus && gPlayServices && androidPerm);\n } else {\n reject(\n new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,\n })\n );\n }\n });\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address verification process\n */\nexport const checkVerificationStartRequirements = (): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n if (Platform.OS === 'android') {\n const isPlayServicesAvailable = await isGooglePlayServicesAvailable();\n if (!isPlayServicesAvailable) {\n reject(\n new OkHiException({\n code: OkHiException.PLAY_SERVICES_UNAVAILABLE_CODE,\n message: 'Google Play Services is unavailable',\n })\n );\n return;\n }\n }\n if (!(await isLocationServicesEnabled())) {\n reject(\n new OkHiException({\n code: OkHiException.LOCATION_SERVICES_UNAVAILABLE_CODE,\n message: 'Location services unavailable',\n })\n );\n return;\n }\n if (!(await isBackgroundLocationPermissionGranted())) {\n reject(\n new OkHiException({\n code: OkHiException.PERMISSION_DENIED_CODE,\n message: 'Background Location permission not granted',\n })\n );\n return;\n }\n resolve(true);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AAUA;;AACA;;AAGA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,CACnBC,WADmB,EAEnBC,UAFmB,EAGnBC,GAHmB,EAInBC,GAJmB,EAKnBC,aALmB,KAMhB;EACH,OAAO,IAAAC,wBAAA,EAAgB,MAAM;IAC3B,IAAIC,qBAAA,CAASC,EAAT,KAAgB,SAApB,EAA+B;MAC7B,OAAOC,kCAAA,CAAiBC,wBAAjB,CACLT,WADK,EAELC,UAFK,EAGLC,GAHK,EAILC,GAJK,EAKLC,aALK,CAAP;IAOD,CARD,MAQO;MACL,OAAOI,kCAAA,CAAiBC,wBAAjB,CACLT,WADK,EAELC,UAFK,EAGLC,GAHK,EAILC,GAJK,CAAP;IAMD;EACF,CAjBM,CAAP;AAkBD,CAzBM;AA2BP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,iBAAiB,GAAG,OAC/BC,QAD+B,EAE/BP,aAF+B,KAG5B;EACH,OAAO,IAAIQ,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;IACtC,MAAM;MAAEC,QAAF;MAAYC;IAAZ,IAAqBL,QAA3B;;IACA,IAAII,QAAQ,CAACE,EAAb,EAAiB;MACf,IAAIX,qBAAA,CAASC,EAAT,KAAgB,SAApB,EAA+B;QAC7B,MAAMW,MAAM,GAAGV,kCAAA,CAAiBC,wBAAjB,CACbO,IAAI,CAACG,KADQ,EAEbJ,QAAQ,CAACE,EAFI,EAGbF,QAAQ,CAACb,GAHI,EAIba,QAAQ,CAACZ,GAJI,EAKbC,aALa,CAAf;;QAOAS,OAAO,CA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.ts"],"sourcesContent":["export type OkVerifyStartConfiguration = {\n android: { withForeground: boolean };\n};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './OkCollect';\nexport * from './OkCore';\nexport * from './OkVerify';\n"]}
1
+ {"version":3,"names":[],"sources":["index.tsx"],"sourcesContent":["export * from './OkCollect';\nexport * from './OkCore';\nexport * from './OkVerify';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["Helpers.ts"],"names":["Platform","isLocationServicesEnabled","isLocationPermissionGranted","isGooglePlayServicesAvailable","requestEnableLocationServices","requestEnableGooglePlayServices","requestLocationPermission","OkHiException","canStartAddressCreation","configuration","Promise","resolve","reject","requestServices","locationServicesStatus","googlePlayServices","OS","locationPerm","code","SERVICE_UNAVAILABLE_CODE","message","locationServicesRequestStatus","gPlayServices","locationPermStatus"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AACA,SACEC,yBADF,EAEEC,2BAFF,EAGEC,6BAHF,EAIEC,6BAJF,EAKEC,+BALF,EAMEC,yBANF,QAOO,mBAPP;AAQA,SAASC,aAAT,QAA8B,yBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAIC,aAAD,IAEf;AACtB,SAAO,IAAIC,OAAJ,CAAY,OAAOC,OAAP,EAAgBC,MAAhB,KAA2B;AAC5C,UAAMC,eAAe,GAAGJ,aAAa,IAAIA,aAAa,CAACI,eAAvD;AACA,UAAMC,sBAAsB,GAAG,MAAMb,yBAAyB,EAA9D;AACA,UAAMc,kBAAkB,GACtBf,QAAQ,CAACgB,EAAT,KAAgB,SAAhB,GAA4B,MAAMb,6BAA6B,EAA/D,GAAoE,IADtE;AAEA,UAAMc,YAAY,GAAG,MAAMf,2BAA2B,EAAtD;;AACA,QAAI,CAACW,eAAL,EAAsB;AACpBF,MAAAA,OAAO,CAACG,sBAAsB,IAAIC,kBAA1B,IAAgDE,YAAjD,CAAP;AACA;AACD;;AACD,QAAI,CAACH,sBAAD,IAA2Bd,QAAQ,CAACgB,EAAT,KAAgB,KAA/C,EAAsD;AACpDJ,MAAAA,MAAM,CACJ,IAAIL,aAAJ,CAAkB;AAChBW,QAAAA,IAAI,EAAEX,aAAa,CAACY,wBADJ;AAEhBC,QAAAA,OAAO,EAAE;AAFO,OAAlB,CADI,CAAN;AAMD,KAPD,MAOO;AACL,YAAMC,6BAA6B,GACjCrB,QAAQ,CAACgB,EAAT,KAAgB,KAAhB,GACI,IADJ,GAEM,MAAMZ,6BAA6B,EAH3C;AAIA,YAAMkB,aAAa,GACjBtB,QAAQ,CAACgB,EAAT,KAAgB,SAAhB,GACI,MAAMX,+BAA+B,EADzC,GAEI,IAHN;AAIA,YAAMkB,kBAAkB,GAAG,MAAMjB,yBAAyB,EAA1D;AACAK,MAAAA,OAAO,CACLU,6BAA6B,IAAIC,aAAjC,IAAkDC,kBAD7C,CAAP;AAGD;AACF,GA/BM,CAAP;AAgCD,CAnCM","sourcesContent":["import { Platform } from 'react-native';\nimport {\n isLocationServicesEnabled,\n isLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n requestEnableLocationServices,\n requestEnableGooglePlayServices,\n requestLocationPermission,\n} from '../OkCore/Helpers';\nimport { OkHiException } from '../OkCore/OkHiException';\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address creation process.\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user.\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user.\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address creation process.\n */\nexport const canStartAddressCreation = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const locationPerm = await isLocationPermissionGranted();\n if (!requestServices) {\n resolve(locationServicesStatus && googlePlayServices && locationPerm);\n return;\n }\n if (!locationServicesStatus && Platform.OS === 'ios') {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n } else {\n const locationServicesRequestStatus =\n Platform.OS === 'ios'\n ? true\n : ((await requestEnableLocationServices()) as boolean);\n const gPlayServices =\n Platform.OS === 'android'\n ? await requestEnableGooglePlayServices()\n : true;\n const locationPermStatus = await requestLocationPermission();\n resolve(\n locationServicesRequestStatus && gPlayServices && locationPermStatus\n );\n }\n });\n};\n"]}
1
+ {"version":3,"names":["Platform","isLocationServicesEnabled","isLocationPermissionGranted","isGooglePlayServicesAvailable","requestEnableLocationServices","requestEnableGooglePlayServices","requestLocationPermission","OkHiException","canStartAddressCreation","configuration","Promise","resolve","reject","requestServices","locationServicesStatus","googlePlayServices","OS","locationPerm","code","SERVICE_UNAVAILABLE_CODE","message","locationServicesRequestStatus","gPlayServices","locationPermStatus"],"sources":["Helpers.ts"],"sourcesContent":["import { Platform } from 'react-native';\nimport {\n isLocationServicesEnabled,\n isLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n requestEnableLocationServices,\n requestEnableGooglePlayServices,\n requestLocationPermission,\n} from '../OkCore/Helpers';\nimport { OkHiException } from '../OkCore/OkHiException';\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address creation process.\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user.\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user.\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address creation process.\n */\nexport const canStartAddressCreation = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const locationPerm = await isLocationPermissionGranted();\n if (!requestServices) {\n resolve(locationServicesStatus && googlePlayServices && locationPerm);\n return;\n }\n if (!locationServicesStatus && Platform.OS === 'ios') {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n } else {\n const locationServicesRequestStatus =\n Platform.OS === 'ios'\n ? true\n : ((await requestEnableLocationServices()) as boolean);\n const gPlayServices =\n Platform.OS === 'android'\n ? await requestEnableGooglePlayServices()\n : true;\n const locationPermStatus = await requestLocationPermission();\n resolve(\n locationServicesRequestStatus && gPlayServices && locationPermStatus\n );\n }\n });\n};\n"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AACA,SACEC,yBADF,EAEEC,2BAFF,EAGEC,6BAHF,EAIEC,6BAJF,EAKEC,+BALF,EAMEC,yBANF,QAOO,mBAPP;AAQA,SAASC,aAAT,QAA8B,yBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAIC,aAAD,IAEf;EACtB,OAAO,IAAIC,OAAJ,CAAY,OAAOC,OAAP,EAAgBC,MAAhB,KAA2B;IAC5C,MAAMC,eAAe,GAAGJ,aAAa,IAAIA,aAAa,CAACI,eAAvD;IACA,MAAMC,sBAAsB,GAAG,MAAMb,yBAAyB,EAA9D;IACA,MAAMc,kBAAkB,GACtBf,QAAQ,CAACgB,EAAT,KAAgB,SAAhB,GAA4B,MAAMb,6BAA6B,EAA/D,GAAoE,IADtE;IAEA,MAAMc,YAAY,GAAG,MAAMf,2BAA2B,EAAtD;;IACA,IAAI,CAACW,eAAL,EAAsB;MACpBF,OAAO,CAACG,sBAAsB,IAAIC,kBAA1B,IAAgDE,YAAjD,CAAP;MACA;IACD;;IACD,IAAI,CAACH,sBAAD,IAA2Bd,QAAQ,CAACgB,EAAT,KAAgB,KAA/C,EAAsD;MACpDJ,MAAM,CACJ,IAAIL,aAAJ,CAAkB;QAChBW,IAAI,EAAEX,aAAa,CAACY,wBADJ;QAEhBC,OAAO,EAAE;MAFO,CAAlB,CADI,CAAN;IAMD,CAPD,MAOO;MACL,MAAMC,6BAA6B,GACjCrB,QAAQ,CAACgB,EAAT,KAAgB,KAAhB,GACI,IADJ,GAEM,MAAMZ,6BAA6B,EAH3C;MAIA,MAAMkB,aAAa,GACjBtB,QAAQ,CAACgB,EAAT,KAAgB,SAAhB,GACI,MAAMX,+BAA+B,EADzC,GAEI,IAHN;MAIA,MAAMkB,kBAAkB,GAAG,MAAMjB,yBAAyB,EAA1D;MACAK,OAAO,CACLU,6BAA6B,IAAIC,aAAjC,IAAkDC,kBAD7C,CAAP;IAGD;EACF,CA/BM,CAAP;AAgCD,CAnCM"}
@@ -1 +1 @@
1
- {"version":3,"sources":["OkHiLocationManager.tsx"],"names":["React","useState","useEffect","Modal","SafeAreaView","Platform","WebView","Spinner","getFrameUrl","generateJavaScriptStartScript","generateStartDataPayload","parseOkHiLocation","OkHiException","OkHiAuth","start","sv","getApplicationConfiguration","openProtectedAppsSettings","OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","startPayload","setStartPaylaod","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","phone","then","config","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","auth","anonymousSignInWithPhoneNumber","catch","error","console","handleOnMessage","nativeEvent","data","response","JSON","parse","UNKNOWN_ERROR_CODE","payload","toString","location","startVerification","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","lat","lon","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","renderContent","jsAfterLoad","jsBeforeLoad","uri","OS","undefined"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;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;AAKA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;AACtE,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBpB,QAAQ,CAAgB,IAAhB,CAAlC;AACA,QAAM,CAACqB,wBAAD,EAA2BC,2BAA3B,IACJtB,QAAQ,CAA+B,IAA/B,CADV;AAEA,QAAM,CAACuB,YAAD,EAAeC,eAAf,IACJxB,QAAQ,CAA6C,IAA7C,CADV;AAEA,QAAMyB,YAAY,GAAG;AAAEC,IAAAA,IAAI,EAAE;AAAR,GAArB;AACA,QAAMC,KAAK,GAAGT,KAAK,CAACS,KAAN,GACV,EAAE,GAAGT,KAAK,CAACS,KAAX;AAAkB,OAAGF;AAArB,GADU,GAEVA,YAFJ;AAIA,QAAM;AAAEG,IAAAA,IAAF;AAAQC,IAAAA,SAAR;AAAmBC,IAAAA,cAAnB;AAAmCC,IAAAA,OAAnC;AAA4CC,IAAAA,MAA5C;AA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ElEc,MAAAA,OAAO,EAAE9B;AAFyD,KAAD,CAAnE;AAKA,wBACE,oBAAC,YAAD;AAAc,MAAA,KAAK,EAAEI;AAArB,oBACE,oBAAC,OAAD;AACE,MAAA,MAAM,EAAE;AAAE8C,QAAAA,GAAG,EAAElE,WAAW,CAACc,wBAAD;AAAlB,OADV;AAEE,MAAA,qCAAqC,EACnCjB,QAAQ,CAACsE,EAAT,KAAgB,KAAhB,GAAwBF,YAAxB,GAAuCG,SAH3C;AAKE,MAAA,kBAAkB,EAAEvE,QAAQ,CAACsE,EAAT,KAAgB,KAAhB,GAAwBC,SAAxB,GAAoCJ,WAL1D;AAME,MAAA,SAAS,EAAEzB,eANb;AAOE,MAAA,OAAO,EAAEqB,aAPX;AAQE,MAAA,WAAW,EAAEA,aARf;AASE,MAAA,kBAAkB,EAAE,IATtB;AAUE,MAAA,mCAAmC,EAAE;AAVvC,MADF,CADF;AAgBD,GA9BD;;AAgCA,sBACE,oBAAC,KAAD;AAAO,IAAA,aAAa,EAAC,OAArB;AAA6B,IAAA,WAAW,EAAE,KAA1C;AAAiD,IAAA,OAAO,EAAElC;AAA1D,KACGA,MAAM,GAAGqC,aAAa,EAAhB,GAAqB,IAD9B,CADF;AAKD,CAzJM;AA2JP,eAAerD,mBAAf","sourcesContent":["import React, { useState, useEffect } 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';\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 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, ['address'], 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(setStartPaylaod)\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 ...response.payload,\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 )\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 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: 'select_location',\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 />\n </SafeAreaView>\n );\n };\n\n return (\n <Modal animationType=\"slide\" transparent={false} visible={launch}>\n {launch ? renderContent() : null}\n </Modal>\n );\n};\n\nexport default OkHiLocationManager;\n"]}
1
+ {"version":3,"names":["React","useState","useEffect","Modal","SafeAreaView","Platform","WebView","Spinner","getFrameUrl","generateJavaScriptStartScript","generateStartDataPayload","parseOkHiLocation","OkHiException","OkHiAuth","start","sv","getApplicationConfiguration","openProtectedAppsSettings","OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","startPayload","setStartPaylaod","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","phone","then","config","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","auth","anonymousSignInWithPhoneNumber","catch","error","console","handleOnMessage","nativeEvent","data","response","JSON","parse","UNKNOWN_ERROR_CODE","payload","toString","location","startVerification","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","lat","lon","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","renderContent","jsAfterLoad","jsBeforeLoad","uri","OS","undefined"],"sources":["OkHiLocationManager.tsx"],"sourcesContent":["import React, { useState, useEffect } 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';\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 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, ['address'], 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(setStartPaylaod)\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 ...response.payload,\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 )\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 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: 'select_location',\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 />\n </SafeAreaView>\n );\n };\n\n return (\n <Modal animationType=\"slide\" transparent={false} visible={launch}>\n {launch ? renderContent() : null}\n </Modal>\n );\n};\n\nexport default OkHiLocationManager;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;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;AAKA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;EACtE,MAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBpB,QAAQ,CAAgB,IAAhB,CAAl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AArB,EAA2B;MACzB,OAAOS,MAAM,iBAAI,oBAAC,OAAD,OAAjB;IACD;;IAED,MAAM;MAAEuC,WAAF;MAAeC;IAAf,IAAgChE,6BAA6B,CAAC;MAClE+B,OAAO,EAAE,iBADyD;MAElEc,OAAO,EAAE9B;IAFyD,CAAD,CAAnE;IAKA,oBACE,oBAAC,YAAD;MAAc,KAAK,EAAEI;IAArB,gBACE,oBAAC,OAAD;MACE,MAAM,EAAE;QAAE8C,GAAG,EAAElE,WAAW,CAACc,wBAAD;MAAlB,CADV;MAEE,qCAAqC,EACnCjB,QAAQ,CAACsE,EAAT,KAAgB,KAAhB,GAAwBF,YAAxB,GAAuCG,SAH3C;MAKE,kBAAkB,EAAEvE,QAAQ,CAACsE,EAAT,KAAgB,KAAhB,GAAwBC,SAAxB,GAAoCJ,WAL1D;MAME,SAAS,EAAEzB,eANb;MAOE,OAAO,EAAEqB,aAPX;MAQE,WAAW,EAAEA,aARf;MASE,kBAAkB,EAAE,IATtB;MAUE,mCAAmC,EAAE;IAVvC,EADF,CADF;EAgBD,CA9BD;;EAgCA,oBACE,oBAAC,KAAD;IAAO,aAAa,EAAC,OAArB;IAA6B,WAAW,EAAE,KAA1C;IAAiD,OAAO,EAAElC;EAA1D,GACGA,MAAM,GAAGqC,aAAa,EAAhB,GAAqB,IAD9B,CADF;AAKD,CAzJM;AA2JP,eAAerD,mBAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["Spinner.tsx"],"names":["React","ActivityIndicator","View","Spinner","style","flex","alignItems","justifyContent"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,iBAAT,EAA4BC,IAA5B,QAAmD,cAAnD;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,OAAO,GAAG,MAAM;AAC3B,QAAMC,KAAgB,GAAG;AACvBC,IAAAA,IAAI,EAAE,CADiB;AAEvBC,IAAAA,UAAU,EAAE,QAFW;AAGvBC,IAAAA,cAAc,EAAE;AAHO,GAAzB;AAKA,sBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEH;AAAb,kBACE,oBAAC,iBAAD;AAAmB,IAAA,KAAK,EAAC,MAAzB;AAAgC,IAAA,IAAI,EAAC;AAArC,IADF,CADF;AAKD,CAXM","sourcesContent":["import React from 'react';\nimport { ActivityIndicator, View, ViewStyle } from 'react-native';\n\n/**\n * Default spinner component that'll be used as the initial loading indicator.\n */\nexport const Spinner = () => {\n const style: ViewStyle = {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n };\n return (\n <View style={style}>\n <ActivityIndicator color=\"teal\" size=\"small\" />\n </View>\n );\n};\n"]}
1
+ {"version":3,"names":["React","ActivityIndicator","View","Spinner","style","flex","alignItems","justifyContent"],"sources":["Spinner.tsx"],"sourcesContent":["import React from 'react';\nimport { ActivityIndicator, View, ViewStyle } from 'react-native';\n\n/**\n * Default spinner component that'll be used as the initial loading indicator.\n */\nexport const Spinner = () => {\n const style: ViewStyle = {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n };\n return (\n <View style={style}>\n <ActivityIndicator color=\"teal\" size=\"small\" />\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,iBAAT,EAA4BC,IAA5B,QAAmD,cAAnD;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,OAAO,GAAG,MAAM;EAC3B,MAAMC,KAAgB,GAAG;IACvBC,IAAI,EAAE,CADiB;IAEvBC,UAAU,EAAE,QAFW;IAGvBC,cAAc,EAAE;EAHO,CAAzB;EAKA,oBACE,oBAAC,IAAD;IAAM,KAAK,EAAEH;EAAb,gBACE,oBAAC,iBAAD;IAAmB,KAAK,EAAC,MAAzB;IAAgC,IAAI,EAAC;EAArC,EADF,CADF;AAKD,CAXM"}
@@ -1 +1 @@
1
- {"version":3,"sources":["Util.ts"],"names":["canOpenProtectedAppsSettings","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","OkHiMode","manifest","Platform","OkHiNativeModule","generateStartDataPayload","props","authToken","applicationConfiguration","payload","style","theme","undefined","base","color","colors","primary","logo","appBar","name","app","user","phone","firstName","lastName","auth","context","container","version","developer","library","platform","hasLocationPermission","hasBackgroundLocationPermission","permissions","location","OS","manufacturer","model","retrieveDeviceInfo","device","config","protectedApps","streetView","backgroundColor","visible","addressTypes","home","work","getFrameUrl","DEV_FRAME_URL","PROD_FRAME_URL","SANDBOX_FRAME_URL","mode","PROD","generateJavaScriptStartScript","startPayload","jsBeforeLoad","JSON","stringify","jsAfterLoad","parseOkHiLocation","id","lat","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"],"mappings":"AACA,SACEA,4BADF,EAEEC,qCAFF,EAGEC,2BAHF,QAKO,WALP;AAMA,SAASC,QAAT,QAAyB,WAAzB;AAKA,OAAOC,QAAP,MAAqB,YAArB,C,CAAmC;;AAEnC,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,wBAAwB,GAAG,OACtCC,KADsC,EAEtCC,SAFsC,EAGtCC,wBAHsC,KAIW;AAAA;;AACjD,QAAMC,OAAY,GAAG,EAArB;AACAA,EAAAA,OAAO,CAACC,KAAR,GAAgB,CAACJ,KAAK,CAACK,KAAP,GACZC,SADY,GAEZ;AACEC,IAAAA,IAAI,EAAE;AACJC,MAAAA,KAAK,kBAAER,KAAK,CAACK,KAAR,wEAAE,aAAaI,MAAf,wDAAE,oBAAqBC,OADxB;AAEJC,MAAAA,IAAI,mBAAEX,KAAK,CAACK,KAAR,0EAAE,cAAaO,MAAf,yDAAE,qBAAqBD,IAFvB;AAGJE,MAAAA,IAAI,2BAAEX,wBAAwB,CAACY,GAA3B,0DAAE,sBAA8BD;AAHhC;AADR,GAFJ;AASAV,EAA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Q,CAAEwD,KApBZ;AAqBLC,IAAAA,IAAI,EAAEzD,QAAF,aAAEA,QAAF,uBAAEA,QAAQ,CAAEyD;AArBX,GAAP;AAuBD,CAxBM","sourcesContent":["import type { OkHiLocationManagerProps } from './types';\nimport {\n canOpenProtectedAppsSettings,\n isBackgroundLocationPermissionGranted,\n isLocationPermissionGranted,\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\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 };\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 const hasLocationPermission = await isLocationPermissionGranted();\n const hasBackgroundLocationPermission =\n await isBackgroundLocationPermissionGranted();\n payload.context.permissions = {\n location: hasBackgroundLocationPermission\n ? 'always'\n : hasLocationPermission\n ? 'whenInUse'\n : 'denied',\n };\n if (Platform.OS === 'android') {\n const { manufacturer, model } = await OkHiNativeModule.retrieveDeviceInfo();\n payload.context.device = {\n manufacturer,\n model,\n };\n payload.context.permissions = {\n ...payload.context.permissions,\n };\n }\n payload.config = {\n protectedApps:\n Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),\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 };\n return payload;\n};\n\n/**\n * @ignore\n */\nexport const getFrameUrl = (\n applicationConfiguration: AuthApplicationConfig\n) => {\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 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 = `\n window.startOkHiLocationManager({ \n receiveMessage: function(data) { window.ReactNativeWebView.postMessage(data) } }, \n ${JSON.stringify(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 };\n};\n"]}
1
+ {"version":3,"names":["canOpenProtectedAppsSettings","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","OkHiMode","manifest","Platform","OkHiNativeModule","generateStartDataPayload","props","authToken","applicationConfiguration","payload","style","theme","undefined","base","color","colors","primary","logo","appBar","name","app","user","phone","firstName","lastName","auth","context","container","version","developer","library","platform","hasLocationPermission","hasBackgroundLocationPermission","permissions","location","OS","manufacturer","model","retrieveDeviceInfo","device","config","protectedApps","streetView","backgroundColor","visible","addressTypes","home","work","getFrameUrl","DEV_FRAME_URL","PROD_FRAME_URL","SANDBOX_FRAME_URL","mode","PROD","generateJavaScriptStartScript","startPayload","jsBeforeLoad","JSON","stringify","jsAfterLoad","parseOkHiLocation","id","lat","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"],"sources":["Util.ts"],"sourcesContent":["import type { OkHiLocationManagerProps } from './types';\nimport {\n canOpenProtectedAppsSettings,\n isBackgroundLocationPermissionGranted,\n isLocationPermissionGranted,\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\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 };\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 const hasLocationPermission = await isLocationPermissionGranted();\n const hasBackgroundLocationPermission =\n await isBackgroundLocationPermissionGranted();\n payload.context.permissions = {\n location: hasBackgroundLocationPermission\n ? 'always'\n : hasLocationPermission\n ? 'whenInUse'\n : 'denied',\n };\n if (Platform.OS === 'android') {\n const { manufacturer, model } = await OkHiNativeModule.retrieveDeviceInfo();\n payload.context.device = {\n manufacturer,\n model,\n };\n payload.context.permissions = {\n ...payload.context.permissions,\n };\n }\n payload.config = {\n protectedApps:\n Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),\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 };\n return payload;\n};\n\n/**\n * @ignore\n */\nexport const getFrameUrl = (\n applicationConfiguration: AuthApplicationConfig\n) => {\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 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 = `\n window.startOkHiLocationManager({ \n receiveMessage: function(data) { window.ReactNativeWebView.postMessage(data) } }, \n ${JSON.stringify(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 };\n};\n"],"mappings":"AACA,SACEA,4BADF,EAEEC,qCAFF,EAGEC,2BAHF,QAKO,WALP;AAMA,SAASC,QAAT,QAAyB,WAAzB;AAKA,OAAOC,QAAP,MAAqB,YAArB,C,CAAmC;;AAEnC,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,wBAAwB,GAAG,OACtCC,KADsC,EAEtCC,SAFsC,EAGtCC,wBAHsC,KAIW;EAAA;;EACjD,MAAMC,OAAY,GAAG,EAArB;EACAA,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AAEA,QAAQ,CAAEyD;EArBX,CAAP;AAuBD,CAxBM"}
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "okhiWebReactNative",
3
- "version": "1.0.19"
3
+ "version": "1.0.25"
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["OkHiLocationManagerProps","OkCollectSuccessResponse"],"mappings":"AAAA,cAAc,WAAd;AACA,cAAc,uBAAd;AACA,SAASA,wBAAT,EAAmCC,wBAAnC,QAAmE,SAAnE","sourcesContent":["export * from './Helpers';\nexport * from './OkHiLocationManager';\nexport { OkHiLocationManagerProps, OkCollectSuccessResponse } from './types';\n"]}
1
+ {"version":3,"names":["OkHiLocationManagerProps","OkCollectSuccessResponse"],"sources":["index.ts"],"sourcesContent":["export * from './Helpers';\nexport * from './OkHiLocationManager';\nexport { OkHiLocationManagerProps, OkCollectSuccessResponse } from './types';\n"],"mappings":"AAAA,cAAc,WAAd;AACA,cAAc,uBAAd;AACA,SAASA,wBAAT,EAAmCC,wBAAnC,QAAmE,SAAnE"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
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/**\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":""}