react-native-fpay 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Fpay.podspec +20 -0
- package/LICENSE +20 -0
- package/README.md +37 -0
- package/android/build.gradle +67 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/fpay/FpayModule.kt +15 -0
- package/android/src/main/java/com/fpay/FpayPackage.kt +31 -0
- package/ios/Fpay.h +5 -0
- package/ios/Fpay.mm +21 -0
- package/lib/module/FountainPayProvider.js +18 -0
- package/lib/module/FountainPayProvider.js.map +1 -0
- package/lib/module/core/api/client.js +47 -0
- package/lib/module/core/api/client.js.map +1 -0
- package/lib/module/core/api/index.js +35 -0
- package/lib/module/core/api/index.js.map +1 -0
- package/lib/module/core/types/index.js +4 -0
- package/lib/module/core/types/index.js.map +1 -0
- package/lib/module/engine/BLEReceiverService.js +190 -0
- package/lib/module/engine/BLEReceiverService.js.map +1 -0
- package/lib/module/engine/BLESenderService.js +259 -0
- package/lib/module/engine/BLESenderService.js.map +1 -0
- package/lib/module/engine/FPEngine.js +340 -0
- package/lib/module/engine/FPEngine.js.map +1 -0
- package/lib/module/engine/NearbyUsersService.js +87 -0
- package/lib/module/engine/NearbyUsersService.js.map +1 -0
- package/lib/module/index.js +16 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/ui/components/FPButton.js +71 -0
- package/lib/module/ui/components/FPButton.js.map +1 -0
- package/lib/module/ui/components/LoadingAnimation/InLoading.js +74 -0
- package/lib/module/ui/components/LoadingAnimation/InLoading.js.map +1 -0
- package/lib/module/ui/components/LoadingAnimation/index.js +82 -0
- package/lib/module/ui/components/LoadingAnimation/index.js.map +1 -0
- package/lib/module/ui/components/OtpInput/OTPInputView.js +290 -0
- package/lib/module/ui/components/OtpInput/OTPInputView.js.map +1 -0
- package/lib/module/ui/components/OtpInput/Styles.js +20 -0
- package/lib/module/ui/components/OtpInput/Styles.js.map +1 -0
- package/lib/module/ui/components/OtpInput/helpers/codeToArray.js +7 -0
- package/lib/module/ui/components/OtpInput/helpers/codeToArray.js.map +1 -0
- package/lib/module/ui/components/OtpInput/helpers/device.js +9 -0
- package/lib/module/ui/components/OtpInput/helpers/device.js.map +1 -0
- package/lib/module/ui/components/OtpInput/helpers/styles.js +17 -0
- package/lib/module/ui/components/OtpInput/helpers/styles.js.map +1 -0
- package/lib/module/ui/components/OtpInput/helpers/types.js +4 -0
- package/lib/module/ui/components/OtpInput/helpers/types.js.map +1 -0
- package/lib/module/ui/components/OtpInput/index.js +45 -0
- package/lib/module/ui/components/OtpInput/index.js.map +1 -0
- package/lib/module/ui/components/PulseAnimation.js +61 -0
- package/lib/module/ui/components/PulseAnimation.js.map +1 -0
- package/lib/module/ui/modals/FPPaymentRequestModal.js +253 -0
- package/lib/module/ui/modals/FPPaymentRequestModal.js.map +1 -0
- package/lib/module/ui/modals/FPShell.js +180 -0
- package/lib/module/ui/modals/FPShell.js.map +1 -0
- package/lib/module/ui/screens/ReceiveScreen.js +291 -0
- package/lib/module/ui/screens/ReceiveScreen.js.map +1 -0
- package/lib/module/ui/screens/SendScreen.js +216 -0
- package/lib/module/ui/screens/SendScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/BluetoothSubScreen.js +403 -0
- package/lib/module/ui/screens/sub/BluetoothSubScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/NFCSubScreen.js +169 -0
- package/lib/module/ui/screens/sub/NFCSubScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/NQRSubScreen.js +136 -0
- package/lib/module/ui/screens/sub/NQRSubScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/ProximitySubScreen.js +501 -0
- package/lib/module/ui/screens/sub/ProximitySubScreen.js.map +1 -0
- package/lib/module/ui/screens/sub/TransferSubScreen.js +361 -0
- package/lib/module/ui/screens/sub/TransferSubScreen.js.map +1 -0
- package/lib/module/ui/theme/index.js +64 -0
- package/lib/module/ui/theme/index.js.map +1 -0
- package/lib/module/useFountainPay.js +82 -0
- package/lib/module/useFountainPay.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/FountainPayProvider.d.ts +7 -0
- package/lib/typescript/src/FountainPayProvider.d.ts.map +1 -0
- package/lib/typescript/src/core/api/client.d.ts +7 -0
- package/lib/typescript/src/core/api/client.d.ts.map +1 -0
- package/lib/typescript/src/core/api/index.d.ts +67 -0
- package/lib/typescript/src/core/api/index.d.ts.map +1 -0
- package/lib/typescript/src/core/types/index.d.ts +130 -0
- package/lib/typescript/src/core/types/index.d.ts.map +1 -0
- package/lib/typescript/src/engine/BLEReceiverService.d.ts +43 -0
- package/lib/typescript/src/engine/BLEReceiverService.d.ts.map +1 -0
- package/lib/typescript/src/engine/BLESenderService.d.ts +39 -0
- package/lib/typescript/src/engine/BLESenderService.d.ts.map +1 -0
- package/lib/typescript/src/engine/FPEngine.d.ts +24 -0
- package/lib/typescript/src/engine/FPEngine.d.ts.map +1 -0
- package/lib/typescript/src/engine/NearbyUsersService.d.ts +19 -0
- package/lib/typescript/src/engine/NearbyUsersService.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/FPButton.d.ts +12 -0
- package/lib/typescript/src/ui/components/FPButton.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/LoadingAnimation/InLoading.d.ts +7 -0
- package/lib/typescript/src/ui/components/LoadingAnimation/InLoading.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/LoadingAnimation/index.d.ts +6 -0
- package/lib/typescript/src/ui/components/LoadingAnimation/index.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/OtpInput/OTPInputView.d.ts +29 -0
- package/lib/typescript/src/ui/components/OtpInput/OTPInputView.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/OtpInput/Styles.d.ts +330 -0
- package/lib/typescript/src/ui/components/OtpInput/Styles.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/OtpInput/helpers/codeToArray.d.ts +6 -0
- package/lib/typescript/src/ui/components/OtpInput/helpers/codeToArray.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/OtpInput/helpers/device.d.ts +6 -0
- package/lib/typescript/src/ui/components/OtpInput/helpers/device.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/OtpInput/helpers/styles.d.ts +6 -0
- package/lib/typescript/src/ui/components/OtpInput/helpers/styles.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/OtpInput/helpers/types.d.ts +84 -0
- package/lib/typescript/src/ui/components/OtpInput/helpers/types.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/OtpInput/index.d.ts +9 -0
- package/lib/typescript/src/ui/components/OtpInput/index.d.ts.map +1 -0
- package/lib/typescript/src/ui/components/PulseAnimation.d.ts +2 -0
- package/lib/typescript/src/ui/components/PulseAnimation.d.ts.map +1 -0
- package/lib/typescript/src/ui/modals/FPPaymentRequestModal.d.ts +2 -0
- package/lib/typescript/src/ui/modals/FPPaymentRequestModal.d.ts.map +1 -0
- package/lib/typescript/src/ui/modals/FPShell.d.ts +2 -0
- package/lib/typescript/src/ui/modals/FPShell.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/ReceiveScreen.d.ts +10 -0
- package/lib/typescript/src/ui/screens/ReceiveScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/SendScreen.d.ts +9 -0
- package/lib/typescript/src/ui/screens/SendScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/sub/BluetoothSubScreen.d.ts +552 -0
- package/lib/typescript/src/ui/screens/sub/BluetoothSubScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/sub/NFCSubScreen.d.ts +19 -0
- package/lib/typescript/src/ui/screens/sub/NFCSubScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/sub/NQRSubScreen.d.ts +13 -0
- package/lib/typescript/src/ui/screens/sub/NQRSubScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/sub/ProximitySubScreen.d.ts +552 -0
- package/lib/typescript/src/ui/screens/sub/ProximitySubScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/screens/sub/TransferSubScreen.d.ts +12 -0
- package/lib/typescript/src/ui/screens/sub/TransferSubScreen.d.ts.map +1 -0
- package/lib/typescript/src/ui/theme/index.d.ts +62 -0
- package/lib/typescript/src/ui/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/useFountainPay.d.ts +3 -0
- package/lib/typescript/src/useFountainPay.d.ts.map +1 -0
- package/package.json +217 -0
- package/src/FountainPayProvider.tsx +21 -0
- package/src/core/api/client.ts +47 -0
- package/src/core/api/index.ts +61 -0
- package/src/core/types/index.ts +144 -0
- package/src/engine/BLEReceiverService.ts +244 -0
- package/src/engine/BLESenderService.ts +314 -0
- package/src/engine/FPEngine.ts +370 -0
- package/src/engine/NearbyUsersService.ts +106 -0
- package/src/index.ts +30 -0
- package/src/ui/components/FPButton.tsx +42 -0
- package/src/ui/components/LoadingAnimation/InLoading.tsx +88 -0
- package/src/ui/components/LoadingAnimation/index.tsx +93 -0
- package/src/ui/components/OtpInput/OTPInputView.tsx +243 -0
- package/src/ui/components/OtpInput/Styles.ts +19 -0
- package/src/ui/components/OtpInput/helpers/codeToArray.ts +3 -0
- package/src/ui/components/OtpInput/helpers/device.ts +6 -0
- package/src/ui/components/OtpInput/helpers/styles.ts +17 -0
- package/src/ui/components/OtpInput/helpers/types.ts +88 -0
- package/src/ui/components/OtpInput/index.tsx +51 -0
- package/src/ui/components/PulseAnimation.tsx +78 -0
- package/src/ui/modals/FPPaymentRequestModal.tsx +158 -0
- package/src/ui/modals/FPShell.tsx +107 -0
- package/src/ui/screens/ReceiveScreen.tsx +119 -0
- package/src/ui/screens/SendScreen.tsx +86 -0
- package/src/ui/screens/sub/BluetoothSubScreen.tsx +433 -0
- package/src/ui/screens/sub/NFCSubScreen.tsx +83 -0
- package/src/ui/screens/sub/NQRSubScreen.tsx +61 -0
- package/src/ui/screens/sub/ProximitySubScreen.tsx +390 -0
- package/src/ui/screens/sub/TransferSubScreen.tsx +146 -0
- package/src/ui/theme/index.ts +24 -0
- package/src/useFountainPay.ts +95 -0
package/Fpay.podspec
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "Fpay"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/adewumiadedeji/react-native-fpay.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
|
|
19
|
+
install_modules_dependencies(s)
|
|
20
|
+
end
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Adedeji RIchards
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# react-native-fpay
|
|
2
|
+
|
|
3
|
+
Fountain Pay react-native sdk library
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install react-native-fpay
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { multiply } from 'react-native-fpay';
|
|
18
|
+
|
|
19
|
+
// ...
|
|
20
|
+
|
|
21
|
+
const result = multiply(3, 7);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
- [Development workflow](CONTRIBUTING.md#development-workflow)
|
|
28
|
+
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
29
|
+
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.Fpay = [
|
|
3
|
+
kotlinVersion: "2.0.21",
|
|
4
|
+
minSdkVersion: 24,
|
|
5
|
+
compileSdkVersion: 36,
|
|
6
|
+
targetSdkVersion: 36
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
ext.getExtOrDefault = { prop ->
|
|
10
|
+
if (rootProject.ext.has(prop)) {
|
|
11
|
+
return rootProject.ext.get(prop)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return Fpay[prop]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
repositories {
|
|
18
|
+
google()
|
|
19
|
+
mavenCentral()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
dependencies {
|
|
23
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
24
|
+
// noinspection DifferentKotlinGradleVersion
|
|
25
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
apply plugin: "com.android.library"
|
|
31
|
+
apply plugin: "kotlin-android"
|
|
32
|
+
|
|
33
|
+
apply plugin: "com.facebook.react"
|
|
34
|
+
|
|
35
|
+
android {
|
|
36
|
+
namespace "com.fpay"
|
|
37
|
+
|
|
38
|
+
compileSdkVersion getExtOrDefault("compileSdkVersion")
|
|
39
|
+
|
|
40
|
+
defaultConfig {
|
|
41
|
+
minSdkVersion getExtOrDefault("minSdkVersion")
|
|
42
|
+
targetSdkVersion getExtOrDefault("targetSdkVersion")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
buildFeatures {
|
|
46
|
+
buildConfig true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
buildTypes {
|
|
50
|
+
release {
|
|
51
|
+
minifyEnabled false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
lint {
|
|
56
|
+
disable "GradleCompatible"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
compileOptions {
|
|
60
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
61
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
dependencies {
|
|
66
|
+
implementation "com.facebook.react:react-android"
|
|
67
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.fpay
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
|
|
5
|
+
class FpayModule(reactContext: ReactApplicationContext) :
|
|
6
|
+
NativeFpaySpec(reactContext) {
|
|
7
|
+
|
|
8
|
+
override fun multiply(a: Double, b: Double): Double {
|
|
9
|
+
return a * b
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
companion object {
|
|
13
|
+
const val NAME = NativeFpaySpec.NAME
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.fpay
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class FpayPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == FpayModule.NAME) {
|
|
13
|
+
FpayModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
|
|
20
|
+
mapOf(
|
|
21
|
+
FpayModule.NAME to ReactModuleInfo(
|
|
22
|
+
name = FpayModule.NAME,
|
|
23
|
+
className = FpayModule.NAME,
|
|
24
|
+
canOverrideExistingModule = false,
|
|
25
|
+
needsEagerInit = false,
|
|
26
|
+
isCxxModule = false,
|
|
27
|
+
isTurboModule = true
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
package/ios/Fpay.h
ADDED
package/ios/Fpay.mm
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#import "Fpay.h"
|
|
2
|
+
|
|
3
|
+
@implementation Fpay
|
|
4
|
+
- (NSNumber *)multiply:(double)a b:(double)b {
|
|
5
|
+
NSNumber *result = @(a * b);
|
|
6
|
+
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
11
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
12
|
+
{
|
|
13
|
+
return std::make_shared<facebook::react::NativeFpaySpecJSI>(params);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
+ (NSString *)moduleName
|
|
17
|
+
{
|
|
18
|
+
return @"Fpay";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// ─────────────────────────────────────────────
|
|
4
|
+
// FountainPayProvider
|
|
5
|
+
// The ONLY thing the host app mounts.
|
|
6
|
+
// Wraps children and mounts the invisible shell.
|
|
7
|
+
// ─────────────────────────────────────────────
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { FPShell } from "./ui/modals/FPShell.js";
|
|
10
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
export function FountainPayProvider({
|
|
12
|
+
children
|
|
13
|
+
}) {
|
|
14
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
15
|
+
children: [children, /*#__PURE__*/_jsx(FPShell, {})]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=FountainPayProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","FPShell","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","FountainPayProvider","children"],"sourceRoot":"../../src","sources":["FountainPayProvider.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAA0B,OAAO;AAC7C,SAASC,OAAO,QAAQ,wBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAM9C,OAAO,SAASC,mBAAmBA,CAAC;EAAEC;AAAgB,CAAC,EAAE;EACvD,oBACEF,KAAA,CAAAF,SAAA;IAAAI,QAAA,GACGA,QAAQ,eAETN,IAAA,CAACF,OAAO,IAAE,CAAC;EAAA,CACX,CAAC;AAEP","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// FountainPay SDK — HTTP Client
|
|
4
|
+
// All API communication goes through here.
|
|
5
|
+
// The host app never touches this directly.
|
|
6
|
+
|
|
7
|
+
import axios from 'axios';
|
|
8
|
+
const DEFAULT_BASE_URL = 'https://api.fountainpay.ng/sdk/detect/';
|
|
9
|
+
let _client = null;
|
|
10
|
+
export function initClient(apiKey, options = {}) {
|
|
11
|
+
_client = axios.create({
|
|
12
|
+
baseURL: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
13
|
+
timeout: 30000,
|
|
14
|
+
headers: {
|
|
15
|
+
'Content-Type': 'application/json',
|
|
16
|
+
'x-api-key': apiKey,
|
|
17
|
+
'x-sdk': 'react-native-fountainpay-sdk',
|
|
18
|
+
'x-sdk-version': '1.0.0',
|
|
19
|
+
'x-env': options.environment ?? 'production'
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
_client.interceptors.response.use(r => r, err => {
|
|
23
|
+
const e = {
|
|
24
|
+
code: 'UNKNOWN',
|
|
25
|
+
message: 'An error occurred'
|
|
26
|
+
};
|
|
27
|
+
if (!err.response) {
|
|
28
|
+
e.code = 'NETWORK_ERROR';
|
|
29
|
+
e.message = 'Network error. Check your connection.';
|
|
30
|
+
} else {
|
|
31
|
+
const d = err.response.data ?? {};
|
|
32
|
+
e.code = d.code ?? `HTTP_${err.response.status}`;
|
|
33
|
+
e.message = d.message ?? err.message;
|
|
34
|
+
e.statusCode = err.response.status;
|
|
35
|
+
if (err.response.status === 401) {
|
|
36
|
+
e.code = 'INVALID_API_KEY';
|
|
37
|
+
e.message = 'Invalid API key.';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return Promise.reject(e);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function http() {
|
|
44
|
+
if (!_client) throw new Error('[FountainPay] SDK not initialized. Call pay.initializeSDK() first.');
|
|
45
|
+
return _client;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["axios","DEFAULT_BASE_URL","_client","initClient","apiKey","options","create","baseURL","baseUrl","timeout","headers","environment","interceptors","response","use","r","err","e","code","message","d","data","status","statusCode","Promise","reject","http","Error"],"sourceRoot":"../../../../src","sources":["core/api/client.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA,OAAOA,KAAK,MAA8B,OAAO;AAGjD,MAAMC,gBAAgB,GAAG,wCAAwC;AAEjE,IAAIC,OAA6B,GAAG,IAAI;AAExC,OAAO,SAASC,UAAUA,CAACC,MAAc,EAAEC,OAAmD,GAAG,CAAC,CAAC,EAAQ;EACzGH,OAAO,GAAGF,KAAK,CAACM,MAAM,CAAC;IACrBC,OAAO,EAAEF,OAAO,CAACG,OAAO,IAAIP,gBAAgB;IAC5CQ,OAAO,EAAE,KAAK;IACdC,OAAO,EAAE;MACP,cAAc,EAAE,kBAAkB;MAClC,WAAW,EAAEN,MAAM;MACnB,OAAO,EAAE,8BAA8B;MACvC,eAAe,EAAE,OAAO;MACxB,OAAO,EAAEC,OAAO,CAACM,WAAW,IAAI;IAClC;EACF,CAAC,CAAC;EAEFT,OAAO,CAACU,YAAY,CAACC,QAAQ,CAACC,GAAG,CAC9BC,CAAC,IAAKA,CAAC,EACPC,GAAG,IAAK;IACP,MAAMC,CAAU,GAAG;MAAEC,IAAI,EAAE,SAAS;MAAEC,OAAO,EAAE;IAAoB,CAAC;IACpE,IAAI,CAACH,GAAG,CAACH,QAAQ,EAAE;MACjBI,CAAC,CAACC,IAAI,GAAG,eAAe;MACxBD,CAAC,CAACE,OAAO,GAAG,uCAAuC;IACrD,CAAC,MAAM;MACL,MAAMC,CAAC,GAAGJ,GAAG,CAACH,QAAQ,CAACQ,IAAI,IAAI,CAAC,CAAC;MACjCJ,CAAC,CAACC,IAAI,GAAGE,CAAC,CAACF,IAAI,IAAI,QAAQF,GAAG,CAACH,QAAQ,CAACS,MAAM,EAAE;MAChDL,CAAC,CAACE,OAAO,GAAGC,CAAC,CAACD,OAAO,IAAIH,GAAG,CAACG,OAAO;MACpCF,CAAC,CAACM,UAAU,GAAGP,GAAG,CAACH,QAAQ,CAACS,MAAM;MAClC,IAAIN,GAAG,CAACH,QAAQ,CAACS,MAAM,KAAK,GAAG,EAAE;QAAEL,CAAC,CAACC,IAAI,GAAG,iBAAiB;QAAED,CAAC,CAACE,OAAO,GAAG,kBAAkB;MAAE;IACjG;IACA,OAAOK,OAAO,CAACC,MAAM,CAACR,CAAC,CAAC;EAC1B,CACF,CAAC;AACH;AAEA,OAAO,SAASS,IAAIA,CAAA,EAAkB;EACpC,IAAI,CAACxB,OAAO,EAAE,MAAM,IAAIyB,KAAK,CAAC,oEAAoE,CAAC;EACnG,OAAOzB,OAAO;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// FountainPay SDK — All API calls
|
|
4
|
+
import { http } from "./client.js";
|
|
5
|
+
export const walletAPI = {
|
|
6
|
+
generate: req => http().post("/v1/wallet/generate", req).then(r => r.data),
|
|
7
|
+
getBalance: walletId => http().get("/v1/wallet/" + walletId + "/balance").then(r => r.data)
|
|
8
|
+
};
|
|
9
|
+
export const transferAPI = {
|
|
10
|
+
getBanks: () => http().get("/v1/banks").then(r => r.data),
|
|
11
|
+
verifyAccount: (accountNumber, bankCode) => http().post("/v1/transfer/verify-account", {
|
|
12
|
+
accountNumber,
|
|
13
|
+
bankCode
|
|
14
|
+
}).then(r => r.data),
|
|
15
|
+
send: payload => http().post("/v1/transfer/initiate", payload).then(r => r.data),
|
|
16
|
+
status: reference => http().get("/v1/transfer/" + reference + "/status").then(r => r.data)
|
|
17
|
+
};
|
|
18
|
+
export const nqrAPI = {
|
|
19
|
+
generate: payload => http().post("/v1/payment/nqr/generate", payload).then(r => r.data),
|
|
20
|
+
pay: payload => http().post("/v1/payment/nqr/pay", payload).then(r => r.data)
|
|
21
|
+
};
|
|
22
|
+
export const proximityAPI = {
|
|
23
|
+
broadcast: payload => http().post("/v1/proximity/broadcast", payload).then(r => r.data),
|
|
24
|
+
heartbeat: (sessionId, lat, lng) => http().patch("/v1/proximity/broadcast/" + sessionId, {
|
|
25
|
+
latitude: lat,
|
|
26
|
+
longitude: lng
|
|
27
|
+
}),
|
|
28
|
+
unregister: sessionId => http().delete("/v1/proximity/broadcast/" + sessionId),
|
|
29
|
+
discover: (lat, lng, radiusMeters) => http().post("/v1/proximity/discover", {
|
|
30
|
+
latitude: lat,
|
|
31
|
+
longitude: lng,
|
|
32
|
+
radiusMeters
|
|
33
|
+
}).then(r => r.data.peers)
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["http","walletAPI","generate","req","post","then","r","data","getBalance","walletId","get","transferAPI","getBanks","verifyAccount","accountNumber","bankCode","send","payload","status","reference","nqrAPI","pay","proximityAPI","broadcast","heartbeat","sessionId","lat","lng","patch","latitude","longitude","unregister","delete","discover","radiusMeters","peers"],"sourceRoot":"../../../../src","sources":["core/api/index.ts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AO,CAAC,CAACZ,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,IAAI,CAAC;EAE/Ec,GAAG,EAAGJ,OAA+D,IACnEjB,IAAI,CAAC,CAAC,CAACI,IAAI,CAAgB,qBAAqB,EAAEa,OAAO,CAAC,CAACZ,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,IAAI;AAC/E,CAAC;AAED,OAAO,MAAMe,YAAY,GAAG;EAC1BC,SAAS,EAAGN,OAAgI,IAC1IjB,IAAI,CAAC,CAAC,CAACI,IAAI,CAAwB,yBAAyB,EAAEa,OAAO,CAAC,CAACZ,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,IAAI,CAAC;EAE1FiB,SAAS,EAAEA,CAACC,SAAiB,EAAEC,GAAW,EAAEC,GAAW,KACrD3B,IAAI,CAAC,CAAC,CAAC4B,KAAK,CAAC,0BAA0B,GAAGH,SAAS,EAAE;IAAEI,QAAQ,EAAEH,GAAG;IAAEI,SAAS,EAAEH;EAAI,CAAC,CAAC;EAEzFI,UAAU,EAAGN,SAAiB,IAC5BzB,IAAI,CAAC,CAAC,CAACgC,MAAM,CAAC,0BAA0B,GAAGP,SAAS,CAAC;EAEvDQ,QAAQ,EAAEA,CAACP,GAAW,EAAEC,GAAW,EAAEO,YAAoB,KACvDlC,IAAI,CAAC,CAAC,CAACI,IAAI,CACT,wBAAwB,EAAE;IAAEyB,QAAQ,EAAEH,GAAG;IAAEI,SAAS,EAAEH,GAAG;IAAEO;EAAa,CAC1E,CAAC,CAAC7B,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACC,IAAI,CAAC4B,KAAK;AAC5B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["core/types/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// FPay SDK — BLEReceiverService (Peripheral)
|
|
4
|
+
// Ported directly from your BLEReceiverService.ts.
|
|
5
|
+
// Same UUIDs, same event ordering, same write handler, same response flow.
|
|
6
|
+
// Only changes: removed useBoundStore dependency, appName is 'FountainPay'.
|
|
7
|
+
|
|
8
|
+
import { PermissionsAndroid, Platform } from 'react-native';
|
|
9
|
+
import Peripheral, { Permission, Property } from 'react-native-multi-ble-peripheral';
|
|
10
|
+
import { Buffer } from 'buffer';
|
|
11
|
+
|
|
12
|
+
// ── UUIDs — shared with BLESenderService ─────────────────────
|
|
13
|
+
export const FP_SERVICE_UUID = 'E8E66D12-C217-425A-AB36-DDBA22F22A5D';
|
|
14
|
+
export const FP_REQUEST_CHAR_UUID = 'E1CC0349-343A-4E12-A4EF-CF69A681EE86';
|
|
15
|
+
export const FP_RESPONSE_CHAR_UUID = 'DA9318CA-C740-4951-9C7C-5747FE002EF9';
|
|
16
|
+
export const FP_USERINFO_CHAR_UUID = '933CA5AE-4D53-4CF4-864A-2FF51AFA05E9';
|
|
17
|
+
|
|
18
|
+
// ── Types ─────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
// ── Class ─────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
class BLEReceiverService {
|
|
23
|
+
peripheral = null;
|
|
24
|
+
isAdvertising = false;
|
|
25
|
+
onRequestCallback = null;
|
|
26
|
+
userInfo = {
|
|
27
|
+
appName: 'FountainPay',
|
|
28
|
+
userName: '',
|
|
29
|
+
userId: ''
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// ── Init ───────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
async initializeWithUserInfo(userId, userName, appName = 'FountainPay') {
|
|
35
|
+
this.userInfo = {
|
|
36
|
+
userId,
|
|
37
|
+
userName,
|
|
38
|
+
appName
|
|
39
|
+
};
|
|
40
|
+
await this._requestPermissions();
|
|
41
|
+
}
|
|
42
|
+
async _requestPermissions() {
|
|
43
|
+
if (Platform.OS !== 'android') return true;
|
|
44
|
+
if (Platform.Version >= 31) {
|
|
45
|
+
const results = await PermissionsAndroid.requestMultiple([PermissionsAndroid.PERMISSIONS.BLUETOOTH_ADVERTISE, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION]);
|
|
46
|
+
return Object.values(results).every(r => r === PermissionsAndroid.RESULTS.GRANTED);
|
|
47
|
+
}
|
|
48
|
+
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
|
|
49
|
+
return granted === PermissionsAndroid.RESULTS.GRANTED;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ── Advertising ────────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
async startAdvertising() {
|
|
55
|
+
if (this.isAdvertising) {
|
|
56
|
+
console.log('[FPay BLE Receiver] Already advertising');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.peripheral = new Peripheral();
|
|
60
|
+
|
|
61
|
+
// CRITICAL: Register event listeners BEFORE the 'ready' event fires.
|
|
62
|
+
// This mirrors your original code exactly — if you set up listeners
|
|
63
|
+
// inside the 'ready' callback, write events that fire immediately after
|
|
64
|
+
// setup can be missed.
|
|
65
|
+
this._setupEventListeners();
|
|
66
|
+
await new Promise((resolve, reject) => {
|
|
67
|
+
const timeout = setTimeout(() => reject(new Error('[FPay BLE Receiver] Setup timeout (10s)')), 10000);
|
|
68
|
+
this.peripheral.on('ready', async () => {
|
|
69
|
+
try {
|
|
70
|
+
clearTimeout(timeout);
|
|
71
|
+
console.log('[FPay BLE Receiver] Peripheral ready');
|
|
72
|
+
await Peripheral.setDeviceName(this.userInfo.userName);
|
|
73
|
+
console.log('[FPay BLE Receiver] Device name set:', this.userInfo.userName);
|
|
74
|
+
await this.peripheral.addService(FP_SERVICE_UUID, true);
|
|
75
|
+
|
|
76
|
+
// User info characteristic — READ only.
|
|
77
|
+
// Sender reads this to get display name and userId.
|
|
78
|
+
const userInfoPayload = JSON.stringify({
|
|
79
|
+
appName: this.userInfo.appName,
|
|
80
|
+
userName: this.userInfo.userName,
|
|
81
|
+
userId: this.userInfo.userId
|
|
82
|
+
});
|
|
83
|
+
await this.peripheral.addCharacteristic(FP_SERVICE_UUID, FP_USERINFO_CHAR_UUID, Property.READ, Permission.READABLE);
|
|
84
|
+
await this.peripheral.updateValue(FP_SERVICE_UUID, FP_USERINFO_CHAR_UUID, Buffer.from(userInfoPayload));
|
|
85
|
+
|
|
86
|
+
// Payment request characteristic — WRITE / WRITE_NO_RESPONSE.
|
|
87
|
+
// Sender writes the payment request JSON here.
|
|
88
|
+
await this.peripheral.addCharacteristic(FP_SERVICE_UUID, FP_REQUEST_CHAR_UUID, Property.WRITE | Property.WRITE_NO_RESPONSE, Permission.WRITEABLE);
|
|
89
|
+
|
|
90
|
+
// Payment response characteristic — READ + NOTIFY.
|
|
91
|
+
// Receiver writes accept/decline here; sender polls or subscribes.
|
|
92
|
+
await this.peripheral.addCharacteristic(FP_SERVICE_UUID, FP_RESPONSE_CHAR_UUID, Property.READ | Property.NOTIFY, Permission.READABLE);
|
|
93
|
+
// Seed a default value so the characteristic is always readable
|
|
94
|
+
// (prevents "characteristic not found" errors on first poll)
|
|
95
|
+
await this.peripheral.updateValue(FP_SERVICE_UUID, FP_RESPONSE_CHAR_UUID, Buffer.from(JSON.stringify({
|
|
96
|
+
accepted: false,
|
|
97
|
+
timestamp: 0
|
|
98
|
+
})));
|
|
99
|
+
await this.peripheral.startAdvertising({
|
|
100
|
+
serviceUuids: [FP_SERVICE_UUID],
|
|
101
|
+
includeDeviceName: true
|
|
102
|
+
});
|
|
103
|
+
this.isAdvertising = true;
|
|
104
|
+
console.log('[FPay BLE Receiver] Advertising as "' + this.userInfo.userName + '"');
|
|
105
|
+
resolve();
|
|
106
|
+
} catch (err) {
|
|
107
|
+
clearTimeout(timeout);
|
|
108
|
+
console.error('[FPay BLE Receiver] Setup error:', err);
|
|
109
|
+
reject(err);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ── Event handling ─────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
_setupEventListeners() {
|
|
118
|
+
if (!this.peripheral) return;
|
|
119
|
+
this.peripheral.on('write', data => {
|
|
120
|
+
console.log('[FPay BLE Receiver] Write event received');
|
|
121
|
+
if (data?.value) {
|
|
122
|
+
this._handlePaymentRequest(data);
|
|
123
|
+
} else {
|
|
124
|
+
console.warn('[FPay BLE Receiver] Write event had no value');
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
this.peripheral.on('read', () => console.log('[FPay BLE Receiver] Read event'));
|
|
128
|
+
this.peripheral.on('subscribe', () => console.log('[FPay BLE Receiver] Central subscribed'));
|
|
129
|
+
this.peripheral.on('unsubscribe', () => console.log('[FPay BLE Receiver] Central unsubscribed'));
|
|
130
|
+
}
|
|
131
|
+
_handlePaymentRequest(data) {
|
|
132
|
+
try {
|
|
133
|
+
let decoded;
|
|
134
|
+
|
|
135
|
+
// Handle all value formats the peripheral library may return
|
|
136
|
+
if (typeof data.value === 'string') {
|
|
137
|
+
decoded = Buffer.from(data.value, 'base64').toString('utf8');
|
|
138
|
+
} else if (Buffer.isBuffer(data.value)) {
|
|
139
|
+
decoded = data.value.toString('utf8');
|
|
140
|
+
} else if (Array.isArray(data.value)) {
|
|
141
|
+
decoded = Buffer.from(data.value).toString('utf8');
|
|
142
|
+
} else {
|
|
143
|
+
console.warn('[FPay BLE Receiver] Unknown value format:', typeof data.value);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const request = JSON.parse(decoded);
|
|
147
|
+
const deviceId = request.senderId?.toString() ?? 'unknown';
|
|
148
|
+
console.log('[FPay BLE Receiver] Payment request parsed:', request.senderName, request.currency + request.amount);
|
|
149
|
+
if (this.onRequestCallback) {
|
|
150
|
+
this.onRequestCallback(request, deviceId);
|
|
151
|
+
} else {
|
|
152
|
+
console.warn('[FPay BLE Receiver] No callback registered — request dropped');
|
|
153
|
+
}
|
|
154
|
+
} catch (err) {
|
|
155
|
+
console.error('[FPay BLE Receiver] Failed to parse payment request:', err);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ── Public API ─────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
listenForPaymentRequests(callback) {
|
|
162
|
+
this.onRequestCallback = callback;
|
|
163
|
+
console.log('[FPay BLE Receiver] Payment request listener registered');
|
|
164
|
+
}
|
|
165
|
+
async sendPaymentResponse(response) {
|
|
166
|
+
if (!this.peripheral || !this.isAdvertising) {
|
|
167
|
+
throw new Error('[FPay BLE Receiver] Cannot send response — not advertising');
|
|
168
|
+
}
|
|
169
|
+
const buffer = Buffer.from(JSON.stringify(response));
|
|
170
|
+
await this.peripheral.updateValue(FP_SERVICE_UUID, FP_RESPONSE_CHAR_UUID, buffer);
|
|
171
|
+
console.log('[FPay BLE Receiver] Response sent:', response.accepted ? 'ACCEPTED' : 'DECLINED');
|
|
172
|
+
}
|
|
173
|
+
async stopAdvertising() {
|
|
174
|
+
if (this.peripheral && this.isAdvertising) {
|
|
175
|
+
await this.peripheral.stopAdvertising();
|
|
176
|
+
this.isAdvertising = false;
|
|
177
|
+
console.log('[FPay BLE Receiver] Stopped advertising');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
getIsAdvertising() {
|
|
181
|
+
return this.isAdvertising;
|
|
182
|
+
}
|
|
183
|
+
destroy() {
|
|
184
|
+
this.stopAdvertising();
|
|
185
|
+
this.peripheral = null;
|
|
186
|
+
this.onRequestCallback = null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
export default new BLEReceiverService();
|
|
190
|
+
//# sourceMappingURL=BLEReceiverService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PermissionsAndroid","Platform","Peripheral","Permission","Property","Buffer","FP_SERVICE_UUID","FP_REQUEST_CHAR_UUID","FP_RESPONSE_CHAR_UUID","FP_USERINFO_CHAR_UUID","BLEReceiverService","peripheral","isAdvertising","onRequestCallback","userInfo","appName","userName","userId","initializeWithUserInfo","_requestPermissions","OS","Version","results","requestMultiple","PERMISSIONS","BLUETOOTH_ADVERTISE","BLUETOOTH_CONNECT","ACCESS_FINE_LOCATION","Object","values","every","r","RESULTS","GRANTED","granted","request","startAdvertising","console","log","_setupEventListeners","Promise","resolve","reject","timeout","setTimeout","Error","on","clearTimeout","setDeviceName","addService","userInfoPayload","JSON","stringify","addCharacteristic","READ","READABLE","updateValue","from","WRITE","WRITE_NO_RESPONSE","WRITEABLE","NOTIFY","accepted","timestamp","serviceUuids","includeDeviceName","err","error","data","value","_handlePaymentRequest","warn","decoded","toString","isBuffer","Array","isArray","parse","deviceId","senderId","senderName","currency","amount","listenForPaymentRequests","callback","sendPaymentResponse","response","buffer","stopAdvertising","getIsAdvertising","destroy"],"sourceRoot":"../../../src","sources":["engine/BLEReceiverService.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA,SAASA,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAC3D,OAAOC,UAAU,IAAIC,UAAU,EAAEC,QAAQ,QAAQ,mCAAmC;AACpF,SAASC,MAAM,QAAQ,QAAQ;;AAE/B;AACA,OAAO,MAAMC,eAAe,GAAS,sCAAsC;AAC3E,OAAO,MAAMC,oBAAoB,GAAI,sCAAsC;AAC3E,OAAO,MAAMC,qBAAqB,GAAG,sCAAsC;AAC3E,OAAO,MAAMC,qBAAqB,GAAG,sCAAsC;;AAE3E;;AA6BA;;AAEA,MAAMC,kBAAkB,CAAC;EACfC,UAAU,GAAQ,IAAI;EACtBC,aAAa,GAAG,KAAK;EACrBC,iBAAiB,GAAkC,IAAI;EACvDC,QAAQ,GAAG;IAAEC,OAAO,EAAE,aAAa;IAAEC,QAAQ,EAAE,EAAE;IAAEC,MAAM,EAAE;EAAG,CAAC;;EAEvE;;EAEA,MAAMC,sBAAsBA,CAACD,MAAc,EAAED,QAAgB,EAAED,O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