bridgefy-react-native 1.1.7 → 1.1.9
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/LICENSE +1 -1
- package/README.md +137 -76
- package/android/build.gradle +37 -56
- package/android/gradle.properties +4 -4
- package/android/src/main/AndroidManifest.xml +1 -11
- package/android/src/main/java/me/bridgefy/plugin/react_native/BridgefyReactNativeModule.kt +590 -333
- package/android/src/main/java/me/bridgefy/plugin/react_native/BridgefyReactNativePackage.kt +25 -8
- package/android/src/main/java/me/bridgefy/plugin/react_native/service/BridgefyService.kt +625 -0
- package/android/src/main/java/me/bridgefy/plugin/react_native/util/BridgefyOperationModeManager.kt +193 -0
- package/android/src/main/java/me/bridgefy/plugin/react_native/util/BridgefyServiceManager.kt +123 -0
- package/android/src/main/java/me/bridgefy/plugin/react_native/util/Utils.kt +172 -0
- package/bridgefy-react-native.podspec +5 -25
- package/ios/BridgefyReactNativeModule.m +88 -0
- package/ios/BridgefyReactNativeModule.swift +524 -0
- package/lib/module/NativeBridgefy.js +117 -0
- package/lib/module/NativeBridgefy.js.map +1 -0
- package/lib/module/index.js +172 -207
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeBridgefy.d.ts +250 -0
- package/lib/typescript/src/NativeBridgefy.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +146 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +77 -72
- package/src/NativeBridgefy.ts +321 -0
- package/src/index.tsx +283 -225
- package/ios/BridgefyReactNative.m +0 -56
- package/ios/BridgefyReactNative.swift +0 -368
- package/ios/BridgefyReactNative.xcodeproj/project.pbxproj +0 -293
- package/ios/BridgefyReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/BridgefyReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/BridgefyReactNative.xcodeproj/project.xcworkspace/xcuserdata/bridgefy.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/BridgefyReactNative.xcodeproj/xcuserdata/bridgefy.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/Frameworks/BridgefySDK.xcframework/Info.plist +0 -48
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/BridgefySDK +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Headers/BridgefySDK-Swift.h +0 -313
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Headers/BridgefySDK.h +0 -15
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Info.plist +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.abi.json +0 -7020
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.private.swiftinterface +0 -115
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.swiftinterface +0 -115
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/module.modulemap +0 -11
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/_CodeSignature/CodeResources +0 -190
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/dSYMs/BridgefySDK.framework.dSYM/Contents/Info.plist +0 -20
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/DWARF/BridgefySDK +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/Relocations/aarch64/BridgefySDK.yml +0 -13549
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/BridgefySDK +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Headers/BridgefySDK-Swift.h +0 -622
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Headers/BridgefySDK.h +0 -15
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Info.plist +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -7020
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +0 -115
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +0 -115
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -7020
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +0 -115
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +0 -115
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/module.modulemap +0 -11
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/_CodeSignature/CodeResources +0 -245
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Info.plist +0 -20
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/DWARF/BridgefySDK +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/Relocations/aarch64/BridgefySDK.yml +0 -13237
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/Relocations/x86_64/BridgefySDK.yml +0 -12858
- package/lib/commonjs/index.js +0 -278
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/infraestructure/index.js +0 -28
- package/lib/commonjs/infraestructure/index.js.map +0 -1
- package/lib/commonjs/infraestructure/interfaces/ibridgefy.js +0 -6
- package/lib/commonjs/infraestructure/interfaces/ibridgefy.js.map +0 -1
- package/lib/commonjs/infraestructure/interfaces/index.js +0 -17
- package/lib/commonjs/infraestructure/interfaces/index.js.map +0 -1
- package/lib/commonjs/infraestructure/services/bridgefy_service.js +0 -6
- package/lib/commonjs/infraestructure/services/bridgefy_service.js.map +0 -1
- package/lib/commonjs/infraestructure/services/index.js +0 -17
- package/lib/commonjs/infraestructure/services/index.js.map +0 -1
- package/lib/module/infraestructure/index.js +0 -3
- package/lib/module/infraestructure/index.js.map +0 -1
- package/lib/module/infraestructure/interfaces/ibridgefy.js +0 -2
- package/lib/module/infraestructure/interfaces/ibridgefy.js.map +0 -1
- package/lib/module/infraestructure/interfaces/index.js +0 -2
- package/lib/module/infraestructure/interfaces/index.js.map +0 -1
- package/lib/module/infraestructure/services/bridgefy_service.js +0 -2
- package/lib/module/infraestructure/services/bridgefy_service.js.map +0 -1
- package/lib/module/infraestructure/services/index.js +0 -2
- package/lib/module/infraestructure/services/index.js.map +0 -1
- package/lib/typescript/index.d.ts +0 -219
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/infraestructure/index.d.ts +0 -3
- package/lib/typescript/infraestructure/index.d.ts.map +0 -1
- package/lib/typescript/infraestructure/interfaces/ibridgefy.d.ts +0 -10
- package/lib/typescript/infraestructure/interfaces/ibridgefy.d.ts.map +0 -1
- package/lib/typescript/infraestructure/interfaces/index.d.ts +0 -2
- package/lib/typescript/infraestructure/interfaces/index.d.ts.map +0 -1
- package/lib/typescript/infraestructure/services/bridgefy_service.d.ts +0 -17
- package/lib/typescript/infraestructure/services/bridgefy_service.d.ts.map +0 -1
- package/lib/typescript/infraestructure/services/index.d.ts +0 -2
- package/lib/typescript/infraestructure/services/index.d.ts.map +0 -1
- package/src/infraestructure/index.tsx +0 -2
- package/src/infraestructure/interfaces/ibridgefy.tsx +0 -10
- package/src/infraestructure/interfaces/index.tsx +0 -1
- package/src/infraestructure/services/bridgefy_service.tsx +0 -20
- package/src/infraestructure/services/index.tsx +0 -1
package/src/index.tsx
CHANGED
|
@@ -1,230 +1,178 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/** Profile that defines a series of properties and rules for the propagation of messages. */
|
|
26
|
-
export enum BridgefyPropagationProfile {
|
|
27
|
-
standard = 'standard',
|
|
28
|
-
highDensityNetwork = 'highDensityNetwork',
|
|
29
|
-
sparseNetwork = 'sparseNetwork',
|
|
30
|
-
longReach = 'longReach',
|
|
31
|
-
shortReach = 'shortReach',
|
|
32
|
-
}
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
+
import BridgefyReactNative, {
|
|
3
|
+
BridgefyPropagationProfile,
|
|
4
|
+
BridgefyTransmissionModeType,
|
|
5
|
+
BridgefyEvents,
|
|
6
|
+
BridgefyErrorCode,
|
|
7
|
+
BridgefyOperationMode,
|
|
8
|
+
type BridgefyInitConfig,
|
|
9
|
+
type BridgefyTransmissionMode,
|
|
10
|
+
type BridgefyError,
|
|
11
|
+
type BridgefyMessageData,
|
|
12
|
+
type BridgefyStartEvent,
|
|
13
|
+
type BridgefyConnectEvent,
|
|
14
|
+
type BridgefyDisconnectEvent,
|
|
15
|
+
type BridgefySendMessageEvent,
|
|
16
|
+
type BridgefyReceiveDataEvent,
|
|
17
|
+
type BridgefySecureConnectionEvent,
|
|
18
|
+
type BridgefyLicenseInfo,
|
|
19
|
+
type BridgefyUpdatedConnectedEvent,
|
|
20
|
+
type BridgefyDidSendDataProgress,
|
|
21
|
+
type BridgefyOperationModeConfig,
|
|
22
|
+
type BridgefyOperationModeStatus,
|
|
23
|
+
} from './NativeBridgefy';
|
|
33
24
|
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/** Propagate a message readable by every device that receives it. */
|
|
41
|
-
broadcast = 'broadcast',
|
|
42
|
-
}
|
|
25
|
+
/**
|
|
26
|
+
* index.ts
|
|
27
|
+
*
|
|
28
|
+
* Main export file for Bridgefy React Native TurboModule
|
|
29
|
+
* Provides a clean JavaScript/TypeScript wrapper around the native TurboModule
|
|
30
|
+
*/
|
|
43
31
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/** (iOS) The Bridgefy SDK service is not started */
|
|
68
|
-
serviceNotStarted = 'serviceNotStarted',
|
|
69
|
-
/** (iOS) Cannot get app's bundle id */
|
|
70
|
-
missingBundleID = 'missingBundleID',
|
|
71
|
-
/** (iOS) An internet connection is required to validate the license */
|
|
72
|
-
internetConnectionRequired = 'internetConnectionRequired',
|
|
73
|
-
/** (iOS) The device's time has been modified */
|
|
74
|
-
inconsistentDeviceTime = 'inconsistentDeviceTime',
|
|
75
|
-
/** (iOS) The user does not allow the use of BLE */
|
|
76
|
-
BLEUsageNotGranted = 'BLEUsageNotGranted',
|
|
77
|
-
/** (iOS) The use of BLE in this device is restricted */
|
|
78
|
-
BLEUsageRestricted = 'BLEUsageRestricted',
|
|
79
|
-
/** (iOS) The BLE antenna has been turned off */
|
|
80
|
-
BLEPoweredOff = 'BLEPoweredOff',
|
|
81
|
-
/** (iOS) The usage of BLE is not supported in the device */
|
|
82
|
-
BLEUnsupported = 'BLEUnsupported',
|
|
83
|
-
/** (iOS) BLE usage failed with an unknown error */
|
|
84
|
-
BLEUnknownError = 'BLEUnknownError',
|
|
85
|
-
/** (iOS) Inconsistent connection */
|
|
86
|
-
inconsistentConnection = 'inconsistentConnection',
|
|
87
|
-
/** (iOS) Connection is already secure */
|
|
88
|
-
connectionIsAlreadySecure = 'connectionIsAlreadySecure',
|
|
89
|
-
/** (iOS) Cannot create secure connection */
|
|
90
|
-
cannotCreateSecureConnection = 'cannotCreateSecureConnection',
|
|
91
|
-
/** (iOS) The length of the data exceed the maximum limit */
|
|
92
|
-
dataLengthExceeded = 'dataLengthExceeded',
|
|
93
|
-
/** (iOS) The data to send is empty */
|
|
94
|
-
dataValueIsEmpty = 'dataValueIsEmpty',
|
|
95
|
-
/** (iOS) The requested peer is not connected */
|
|
96
|
-
peerIsNotConnected = 'peerIsNotConnected',
|
|
97
|
-
/** (iOS) An internal error occurred */
|
|
98
|
-
internalError = 'internalError',
|
|
99
|
-
/** (iOS) An error occurred while validating the license */
|
|
100
|
-
licenseError = 'licenseError',
|
|
101
|
-
/** (iOS) An error occurred while storing data */
|
|
102
|
-
storageError = 'storageError',
|
|
103
|
-
/** (iOS) An error occurred while encoding the message */
|
|
104
|
-
encodingError = 'encodingError',
|
|
105
|
-
/** (iOS) An error occurred while encrypting the message */
|
|
106
|
-
encryptionError = 'encryptionError',
|
|
107
|
-
/** (Android) Missing application ID */
|
|
108
|
-
missingApplicationId = 'missingApplicationId',
|
|
109
|
-
/** (Android) Permission exception */
|
|
110
|
-
permissionException = 'permissionException',
|
|
111
|
-
/** (Android) Registration exception */
|
|
112
|
-
registrationException = 'registrationException',
|
|
113
|
-
/** (Android) Size limit exceeded */
|
|
114
|
-
sizeLimitExceeded = 'sizeLimitExceeded',
|
|
115
|
-
/** (Android) Device capabilities error */
|
|
116
|
-
deviceCapabilities = 'deviceCapabilities',
|
|
117
|
-
/** (Android) Generic exception */
|
|
118
|
-
genericException = 'genericException',
|
|
119
|
-
/** (Android) Inconsistent device time */
|
|
120
|
-
inconsistentDeviceTimeException = 'inconsistentDeviceTimeException',
|
|
121
|
-
/** (Android) Internet connection required */
|
|
122
|
-
internetConnectionRequiredException = 'internetConnectionRequiredException',
|
|
123
|
-
/** (Android) Unknown exception */
|
|
124
|
-
unknownException = 'unknownException',
|
|
125
|
-
}
|
|
32
|
+
// Export types and enums
|
|
33
|
+
export {
|
|
34
|
+
BridgefyPropagationProfile,
|
|
35
|
+
BridgefyTransmissionModeType,
|
|
36
|
+
BridgefyEvents,
|
|
37
|
+
BridgefyErrorCode,
|
|
38
|
+
BridgefyOperationMode,
|
|
39
|
+
type BridgefyInitConfig,
|
|
40
|
+
type BridgefyTransmissionMode,
|
|
41
|
+
type BridgefyError,
|
|
42
|
+
type BridgefyMessageData,
|
|
43
|
+
type BridgefyStartEvent,
|
|
44
|
+
type BridgefyConnectEvent,
|
|
45
|
+
type BridgefyDisconnectEvent,
|
|
46
|
+
type BridgefySendMessageEvent,
|
|
47
|
+
type BridgefyReceiveDataEvent,
|
|
48
|
+
type BridgefySecureConnectionEvent,
|
|
49
|
+
type BridgefyLicenseInfo,
|
|
50
|
+
type BridgefyUpdatedConnectedEvent,
|
|
51
|
+
type BridgefyDidSendDataProgress,
|
|
52
|
+
type BridgefyOperationModeConfig,
|
|
53
|
+
type BridgefyOperationModeStatus,
|
|
54
|
+
};
|
|
126
55
|
|
|
127
56
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
57
|
+
* Bridgefy class - JavaScript wrapper for the native TurboModule
|
|
58
|
+
* Provides event emitter capabilities and clean API
|
|
130
59
|
*/
|
|
131
|
-
export
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* This function is called when the BridgefySDK has been stopped.
|
|
142
|
-
*/
|
|
143
|
-
bridgefyDidStop = 'bridgefyDidStop',
|
|
144
|
-
/**
|
|
145
|
-
* This function is called when an error occurred while stopping the BridgefySDK.
|
|
146
|
-
*/
|
|
147
|
-
bridgefyDidFailToStop = 'bridgefyDidFailToStop',
|
|
148
|
-
/**
|
|
149
|
-
* The current session was destroyed
|
|
150
|
-
*/
|
|
151
|
-
bridgefyDidDestroySession = 'bridgefyDidDestroySession',
|
|
152
|
-
/**
|
|
153
|
-
* An error occurred while destroying the current session
|
|
154
|
-
*/
|
|
155
|
-
bridgefyDidFailToDestroySession = 'bridgefyDidFailToDestroySession',
|
|
60
|
+
export class Bridgefy {
|
|
61
|
+
private eventEmitter: NativeEventEmitter;
|
|
62
|
+
|
|
63
|
+
constructor() {
|
|
64
|
+
// Create event emitter for native events
|
|
65
|
+
const module = BridgefyReactNative || NativeModules.BridgefyReactNative;
|
|
66
|
+
this.eventEmitter = new NativeEventEmitter(module);
|
|
67
|
+
}
|
|
68
|
+
|
|
156
69
|
/**
|
|
157
|
-
*
|
|
70
|
+
* Initialize the Bridgefy SDK
|
|
158
71
|
*/
|
|
159
|
-
|
|
72
|
+
async initialize(
|
|
73
|
+
apiKey: string,
|
|
74
|
+
verboseLogging: boolean = false,
|
|
75
|
+
operationMode?: BridgefyOperationMode
|
|
76
|
+
): Promise<void> {
|
|
77
|
+
const config: BridgefyInitConfig = {
|
|
78
|
+
apiKey,
|
|
79
|
+
verboseLogging,
|
|
80
|
+
operationMode,
|
|
81
|
+
};
|
|
82
|
+
return BridgefyReactNative.initialize(config);
|
|
83
|
+
}
|
|
84
|
+
|
|
160
85
|
/**
|
|
161
|
-
*
|
|
86
|
+
* Start the Bridgefy SDK
|
|
162
87
|
*/
|
|
163
|
-
|
|
88
|
+
async start(
|
|
89
|
+
userId?: string,
|
|
90
|
+
propagationProfile: BridgefyPropagationProfile = BridgefyPropagationProfile.REALTIME
|
|
91
|
+
): Promise<void> {
|
|
92
|
+
return BridgefyReactNative.start(userId, propagationProfile);
|
|
93
|
+
}
|
|
94
|
+
|
|
164
95
|
/**
|
|
165
|
-
*
|
|
96
|
+
* Stop the Bridgefy SDK
|
|
166
97
|
*/
|
|
167
|
-
|
|
98
|
+
async stop(): Promise<void> {
|
|
99
|
+
return BridgefyReactNative.stop();
|
|
100
|
+
}
|
|
101
|
+
|
|
168
102
|
/**
|
|
169
|
-
*
|
|
103
|
+
* Destroy the current session
|
|
170
104
|
*/
|
|
171
|
-
|
|
105
|
+
async destroySession(): Promise<void> {
|
|
106
|
+
return BridgefyReactNative.destroySession();
|
|
107
|
+
}
|
|
108
|
+
|
|
172
109
|
/**
|
|
173
|
-
*
|
|
110
|
+
* Send data through the mesh network
|
|
174
111
|
*/
|
|
175
|
-
|
|
112
|
+
async send(
|
|
113
|
+
data: string,
|
|
114
|
+
transmissionMode: BridgefyTransmissionMode
|
|
115
|
+
): Promise<string> {
|
|
116
|
+
return BridgefyReactNative.send(data, transmissionMode);
|
|
117
|
+
}
|
|
118
|
+
|
|
176
119
|
/**
|
|
177
|
-
*
|
|
120
|
+
* Send broadcast message (convenience method)
|
|
178
121
|
*/
|
|
179
|
-
|
|
122
|
+
async sendBroadcast(data: string): Promise<string> {
|
|
123
|
+
const userId = await this.currentUserId();
|
|
124
|
+
return this.send(data, {
|
|
125
|
+
type: BridgefyTransmissionModeType.BROADCAST,
|
|
126
|
+
uuid: userId,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
180
130
|
/**
|
|
181
|
-
*
|
|
131
|
+
* Send P2P message (convenience method)
|
|
182
132
|
*/
|
|
183
|
-
|
|
133
|
+
async sendP2P(data: string, recipientId: string): Promise<string> {
|
|
134
|
+
return this.send(data, {
|
|
135
|
+
type: BridgefyTransmissionModeType.P2P,
|
|
136
|
+
uuid: recipientId,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
184
140
|
/**
|
|
185
|
-
*
|
|
141
|
+
* Send mesh message (convenience method)
|
|
186
142
|
*/
|
|
187
|
-
|
|
188
|
-
|
|
143
|
+
async sendMesh(data: string, recipientId: string): Promise<string> {
|
|
144
|
+
return this.send(data, {
|
|
145
|
+
type: BridgefyTransmissionModeType.MESH,
|
|
146
|
+
uuid: recipientId,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
189
149
|
|
|
190
|
-
/**
|
|
191
|
-
* Bridgefy
|
|
192
|
-
*/
|
|
193
|
-
export class Bridgefy implements BridgefyService {
|
|
194
150
|
/**
|
|
195
|
-
*
|
|
196
|
-
* @param apiKey API key
|
|
197
|
-
* @param verboseLogging The log level.
|
|
151
|
+
* Establish secure connection with a peer
|
|
198
152
|
*/
|
|
199
|
-
async
|
|
200
|
-
|
|
201
|
-
verboseLogging = false,
|
|
202
|
-
}: IInitializeIn): Promise<void> {
|
|
203
|
-
await BridgefyReactNative.initialize(apiKey, verboseLogging);
|
|
153
|
+
async establishSecureConnection(userId: string): Promise<void> {
|
|
154
|
+
return BridgefyReactNative.establishSecureConnection(userId);
|
|
204
155
|
}
|
|
205
156
|
|
|
206
157
|
/**
|
|
207
|
-
*
|
|
158
|
+
* Get current user ID
|
|
208
159
|
*/
|
|
209
|
-
async
|
|
210
|
-
|
|
211
|
-
const propagationProfile =
|
|
212
|
-
params?.propagationProfile ?? BridgefyPropagationProfile.standard;
|
|
213
|
-
return await BridgefyReactNative.start(userId, propagationProfile);
|
|
160
|
+
async currentUserId(): Promise<string> {
|
|
161
|
+
return BridgefyReactNative.currentUserId();
|
|
214
162
|
}
|
|
215
163
|
|
|
216
164
|
/**
|
|
217
|
-
*
|
|
165
|
+
* Get list of connected peers
|
|
218
166
|
*/
|
|
219
|
-
async
|
|
220
|
-
return
|
|
167
|
+
async connectedPeers(): Promise<string[]> {
|
|
168
|
+
return BridgefyReactNative.connectedPeers();
|
|
221
169
|
}
|
|
222
170
|
|
|
223
171
|
/**
|
|
224
|
-
*
|
|
172
|
+
* Get license expiration info
|
|
225
173
|
*/
|
|
226
|
-
async
|
|
227
|
-
return BridgefyReactNative.
|
|
174
|
+
async licenseExpirationDate(): Promise<BridgefyLicenseInfo> {
|
|
175
|
+
return BridgefyReactNative.licenseExpirationDate();
|
|
228
176
|
}
|
|
229
177
|
|
|
230
178
|
/**
|
|
@@ -235,60 +183,170 @@ export class Bridgefy implements BridgefyService {
|
|
|
235
183
|
}
|
|
236
184
|
|
|
237
185
|
/**
|
|
238
|
-
*
|
|
239
|
-
* the message sent.
|
|
240
|
-
* @param data The message data
|
|
241
|
-
* @param transmissionMode The mode used to propagate a message through nearby devices.
|
|
242
|
-
* @returns The id of the message that was sent.
|
|
186
|
+
* Check if SDK is initialized
|
|
243
187
|
*/
|
|
244
|
-
async
|
|
245
|
-
|
|
246
|
-
transmissionMode: BridgefyTransmissionMode
|
|
247
|
-
): Promise<string> {
|
|
248
|
-
const result = await BridgefyReactNative.send(data, transmissionMode);
|
|
249
|
-
return result.messageId;
|
|
188
|
+
async isInitialized(): Promise<boolean> {
|
|
189
|
+
return BridgefyReactNative.isInitialized();
|
|
250
190
|
}
|
|
251
191
|
|
|
252
192
|
/**
|
|
253
|
-
*
|
|
254
|
-
* @param userId The UUID of the user with whom a secure connection should be established.
|
|
193
|
+
* Check if SDK is started
|
|
255
194
|
*/
|
|
256
|
-
async
|
|
257
|
-
return BridgefyReactNative.
|
|
195
|
+
async isStarted(): Promise<boolean> {
|
|
196
|
+
return BridgefyReactNative.isStarted();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async setOperationMode(
|
|
200
|
+
config: BridgefyOperationModeConfig
|
|
201
|
+
): Promise<BridgefyOperationModeConfig> {
|
|
202
|
+
return BridgefyReactNative.setOperationMode(config);
|
|
203
|
+
}
|
|
204
|
+
async getOperationMode(): Promise<BridgefyOperationModeConfig> {
|
|
205
|
+
return BridgefyReactNative.getOperationMode();
|
|
206
|
+
}
|
|
207
|
+
async switchToBackground(): Promise<void> {
|
|
208
|
+
return BridgefyReactNative.switchToBackground();
|
|
209
|
+
}
|
|
210
|
+
async switchToForeground(): Promise<void> {
|
|
211
|
+
return BridgefyReactNative.switchToForeground();
|
|
212
|
+
}
|
|
213
|
+
async getOperationStatus(): Promise<BridgefyOperationModeStatus> {
|
|
214
|
+
return BridgefyReactNative.getOperationStatus();
|
|
258
215
|
}
|
|
259
216
|
|
|
260
217
|
/**
|
|
261
|
-
*
|
|
262
|
-
* @returns User Id
|
|
218
|
+
* Add event listener
|
|
263
219
|
*/
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
220
|
+
addEventListener(
|
|
221
|
+
eventName: BridgefyEvents,
|
|
222
|
+
listener: (event: any) => void
|
|
223
|
+
): { remove: () => void } {
|
|
224
|
+
const subscription = this.eventEmitter.addListener(eventName, listener);
|
|
225
|
+
return {
|
|
226
|
+
remove: () => subscription.remove(),
|
|
227
|
+
};
|
|
267
228
|
}
|
|
268
229
|
|
|
269
230
|
/**
|
|
270
|
-
*
|
|
271
|
-
* @returns List of connected peers
|
|
231
|
+
* Remove all listeners for an event
|
|
272
232
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
233
|
+
removeAllListeners(eventName?: BridgefyEvents): void {
|
|
234
|
+
if (eventName) {
|
|
235
|
+
this.eventEmitter.removeAllListeners(eventName);
|
|
236
|
+
} else {
|
|
237
|
+
// Remove all listeners for all events
|
|
238
|
+
Object.values(BridgefyEvents).forEach((event) => {
|
|
239
|
+
this.eventEmitter.removeAllListeners(event);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
276
242
|
}
|
|
277
243
|
|
|
278
244
|
/**
|
|
279
|
-
*
|
|
280
|
-
* @returns Expiration date
|
|
245
|
+
* Event listener helpers for common events
|
|
281
246
|
*/
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
return
|
|
247
|
+
|
|
248
|
+
onStart(listener: (event: BridgefyStartEvent) => void) {
|
|
249
|
+
return this.addEventListener(BridgefyEvents.BRIDGEFY_DID_START, listener);
|
|
285
250
|
}
|
|
286
251
|
|
|
287
|
-
|
|
288
|
-
return
|
|
252
|
+
onStop(listener: () => void) {
|
|
253
|
+
return this.addEventListener(BridgefyEvents.BRIDGEFY_DID_STOP, listener);
|
|
289
254
|
}
|
|
290
255
|
|
|
291
|
-
|
|
292
|
-
return
|
|
256
|
+
onFailToStart(listener: (error: BridgefyError) => void) {
|
|
257
|
+
return this.addEventListener(
|
|
258
|
+
BridgefyEvents.BRIDGEFY_DID_FAIL_TO_START,
|
|
259
|
+
listener
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
onFailToStop(listener: (error: BridgefyError) => void) {
|
|
264
|
+
return this.addEventListener(
|
|
265
|
+
BridgefyEvents.BRIDGEFY_DID_FAIL_TO_STOP,
|
|
266
|
+
listener
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
onConnect(listener: (event: BridgefyConnectEvent) => void) {
|
|
271
|
+
return this.addEventListener(BridgefyEvents.BRIDGEFY_DID_CONNECT, listener);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
onConnectedPeers(listener: (event: BridgefyUpdatedConnectedEvent) => void) {
|
|
275
|
+
return this.addEventListener(
|
|
276
|
+
BridgefyEvents.BRIDGEFY_DID_UPDATE_CONNECTED_PEERS,
|
|
277
|
+
listener
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
onDisconnect(listener: (event: BridgefyDisconnectEvent) => void) {
|
|
282
|
+
return this.addEventListener(
|
|
283
|
+
BridgefyEvents.BRIDGEFY_DID_DISCONNECT,
|
|
284
|
+
listener
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
onSendMessage(listener: (event: BridgefySendMessageEvent) => void) {
|
|
289
|
+
return this.addEventListener(
|
|
290
|
+
BridgefyEvents.BRIDGEFY_DID_SEND_MESSAGE,
|
|
291
|
+
listener
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
onSendDataProgress(listener: (event: BridgefyDidSendDataProgress) => void) {
|
|
296
|
+
return this.addEventListener(
|
|
297
|
+
BridgefyEvents.BRIDGEFY_DID_SEND_DATA_PROGRESS,
|
|
298
|
+
listener
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
onFailSendingMessage(
|
|
303
|
+
listener: (error: BridgefyError & { messageId: string }) => void
|
|
304
|
+
) {
|
|
305
|
+
return this.addEventListener(
|
|
306
|
+
BridgefyEvents.BRIDGEFY_DID_FAIL_SENDING_MESSAGE,
|
|
307
|
+
listener
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
onReceiveData(listener: (event: BridgefyReceiveDataEvent) => void) {
|
|
312
|
+
return this.addEventListener(
|
|
313
|
+
BridgefyEvents.BRIDGEFY_DID_RECEIVE_DATA,
|
|
314
|
+
listener
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
onEstablishSecureConnection(
|
|
319
|
+
listener: (event: BridgefySecureConnectionEvent) => void
|
|
320
|
+
) {
|
|
321
|
+
return this.addEventListener(
|
|
322
|
+
BridgefyEvents.BRIDGEFY_DID_ESTABLISH_SECURE_CONNECTION,
|
|
323
|
+
listener
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
onFailToEstablishSecureConnection(
|
|
328
|
+
listener: (error: BridgefyError & { userId: string }) => void
|
|
329
|
+
) {
|
|
330
|
+
return this.addEventListener(
|
|
331
|
+
BridgefyEvents.BRIDGEFY_DID_FAIL_TO_ESTABLISH_SECURE_CONNECTION,
|
|
332
|
+
listener
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
onUpdateLicense(listener: () => void) {
|
|
337
|
+
return this.addEventListener(
|
|
338
|
+
BridgefyEvents.BRIDGEFY_DID_UPDATE_LICENSE,
|
|
339
|
+
listener
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
onFailToUpdateLicense(listener: (error: BridgefyError) => void) {
|
|
344
|
+
return this.addEventListener(
|
|
345
|
+
BridgefyEvents.BRIDGEFY_DID_FAIL_TO_UPDATE_LICENSE,
|
|
346
|
+
listener
|
|
347
|
+
);
|
|
293
348
|
}
|
|
294
349
|
}
|
|
350
|
+
|
|
351
|
+
// Export default instance for convenience
|
|
352
|
+
export default new Bridgefy();
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
#import <React/RCTEventEmitter.h>
|
|
3
|
-
|
|
4
|
-
@interface RCT_EXTERN_MODULE(BridgefyReactNative, RCTEventEmitter)
|
|
5
|
-
|
|
6
|
-
RCT_EXTERN_METHOD(initialize:(NSString *)apiKey
|
|
7
|
-
verboseLogging:(BOOL)verboseLogging
|
|
8
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
9
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
10
|
-
|
|
11
|
-
RCT_EXTERN_METHOD(start:(NSString *)userId
|
|
12
|
-
propagationProfile:(NSString *)propagationProfile
|
|
13
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
14
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
15
|
-
|
|
16
|
-
RCT_EXTERN_METHOD(send:(NSString *)data
|
|
17
|
-
transmissionMode:(NSDictionary *)transmissionMode
|
|
18
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
19
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
20
|
-
|
|
21
|
-
RCT_EXTERN_METHOD(stop:(RCTPromiseResolveBlock)resolve
|
|
22
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
23
|
-
|
|
24
|
-
RCT_EXTERN_METHOD(connectedPeers:(RCTPromiseResolveBlock)resolve
|
|
25
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
26
|
-
|
|
27
|
-
RCT_EXTERN_METHOD(currentUserId:(RCTPromiseResolveBlock)resolve
|
|
28
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
29
|
-
|
|
30
|
-
RCT_EXTERN_METHOD(establishSecureConnection:(NSString *)userId
|
|
31
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
32
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
33
|
-
|
|
34
|
-
RCT_EXTERN_METHOD(licenseExpirationDate:(RCTPromiseResolveBlock)resolve
|
|
35
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
36
|
-
|
|
37
|
-
RCT_EXTERN_METHOD(destroySession:(RCTPromiseResolveBlock)resolve
|
|
38
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
39
|
-
|
|
40
|
-
RCT_EXTERN_METHOD(updateLicense:(RCTPromiseResolveBlock)resolve
|
|
41
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
42
|
-
|
|
43
|
-
RCT_EXTERN_METHOD(isInitialized:(RCTPromiseResolveBlock)resolve
|
|
44
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
45
|
-
|
|
46
|
-
RCT_EXTERN_METHOD(isStarted:(RCTPromiseResolveBlock)resolve
|
|
47
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
48
|
-
|
|
49
|
-
RCT_EXTERN_METHOD(supportedEvents)
|
|
50
|
-
|
|
51
|
-
+ (BOOL)requiresMainQueueSetup
|
|
52
|
-
{
|
|
53
|
-
return NO;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@end
|