@fountispanel/connect-react-native 1.1.0 → 1.2.0
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/CHANGELOG.md +6 -0
- package/README.md +5 -6
- package/android/build.gradle +35 -17
- package/android/src/main/AndroidManifest.xml +5 -16
- package/build/index.js +1 -126
- package/build/index.web.js +1 -57
- package/ios/FountisConnect.xcframework/Info.plist +44 -0
- package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Engine}/engine.html +5 -5
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/FountisConnect +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Info.plist +53 -0
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Modules/FountisConnect.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Modules/FountisConnect.swiftmodule/arm64-apple-ios.swiftinterface +48 -0
- package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework}/Engine/engine.html +5 -5
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/FountisConnect +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Info.plist +49 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Modules/FountisConnect.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Modules/FountisConnect.swiftmodule/arm64-apple-ios-simulator.swiftinterface +48 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Modules/FountisConnect.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/Modules/FountisConnect.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +48 -0
- package/ios/FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework/PrivacyInfo.xcprivacy +23 -0
- package/ios/FountisConnectAppDelegateSubscriber.swift +3 -0
- package/ios/FountisConnectModule.swift +3 -0
- package/ios/FountisConnectReactNative.podspec +27 -6
- package/package.json +14 -12
- package/android/connect-sdk/main/kotlin/org/fountis/connect/ApiClient.kt +0 -179
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Attest.kt +0 -234
- package/android/connect-sdk/main/kotlin/org/fountis/connect/FountisConnect.kt +0 -641
- package/android/connect-sdk/main/kotlin/org/fountis/connect/FountisSurveyActivity.kt +0 -321
- package/android/connect-sdk/main/kotlin/org/fountis/connect/LocalState.kt +0 -143
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Matcher.kt +0 -167
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Models.kt +0 -144
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Notifier.kt +0 -109
- package/android/connect-sdk/main/kotlin/org/fountis/connect/PlayIntegrityAttestor.kt +0 -70
- package/android/connect-sdk/main/kotlin/org/fountis/connect/RequestDeadline.kt +0 -74
- package/android/connect-sdk/main/kotlin/org/fountis/connect/Strings.kt +0 -45
- package/android/connect-sdk/main/kotlin/org/fountis/connect/TokenProviderCall.kt +0 -72
- package/android/connect-sdk/main/res/drawable/fountis_ic_notification.xml +0 -12
- package/android/connect-sdk/main/res/values/fountis_styles.xml +0 -13
- package/android/connect-sdk/main/res/values-v27/fountis_styles.xml +0 -12
- package/build/types.js +0 -1
- package/ios/FountisConnectBundle.swift +0 -15
- package/ios/FountisConnectSDK/ApiClient.swift +0 -137
- package/ios/FountisConnectSDK/Attestation.swift +0 -276
- package/ios/FountisConnectSDK/FountisConnect.swift +0 -441
- package/ios/FountisConnectSDK/LocalState.swift +0 -81
- package/ios/FountisConnectSDK/Matcher.swift +0 -102
- package/ios/FountisConnectSDK/Models.swift +0 -133
- package/ios/FountisConnectSDK/Notifier.swift +0 -63
- package/ios/FountisConnectSDK/RequestDeadline.swift +0 -93
- package/ios/FountisConnectSDK/SheetController.swift +0 -259
- package/ios/FountisConnectSDK/Strings.swift +0 -34
- package/ios/FountisConnectSDK/TokenProviderCall.swift +0 -91
- package/scripts/vendor-native.sh +0 -16
- package/src/index.ts +0 -142
- package/src/index.web.ts +0 -64
- package/src/types.ts +0 -26
- /package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Engine}/i18n/ar.json +0 -0
- /package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Engine}/i18n/en.json +0 -0
- /package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Engine}/i18n/kmr.json +0 -0
- /package/{android/connect-sdk/main/assets/fountis-connect → ios/FountisConnect.xcframework/ios-arm64/FountisConnect.framework/Engine}/i18n/ku.json +0 -0
- /package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64/FountisConnect.framework}/PrivacyInfo.xcprivacy +0 -0
- /package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework}/Engine/i18n/ar.json +0 -0
- /package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework}/Engine/i18n/en.json +0 -0
- /package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework}/Engine/i18n/kmr.json +0 -0
- /package/ios/{FountisConnectSDK → FountisConnect.xcframework/ios-arm64_x86_64-simulator/FountisConnect.framework}/Engine/i18n/ku.json +0 -0
|
Binary file
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>en</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>FountisConnect</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>org.fountis.connect.FountisConnect</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>FountisConnect</string>
|
|
15
|
+
<key>CFBundlePackageType</key>
|
|
16
|
+
<string>FMWK</string>
|
|
17
|
+
<key>CFBundleShortVersionString</key>
|
|
18
|
+
<string>1.2.0</string>
|
|
19
|
+
<key>CFBundleSupportedPlatforms</key>
|
|
20
|
+
<array>
|
|
21
|
+
<string>iPhoneSimulator</string>
|
|
22
|
+
</array>
|
|
23
|
+
<key>CFBundleVersion</key>
|
|
24
|
+
<string>1.2.0</string>
|
|
25
|
+
<key>DTCompiler</key>
|
|
26
|
+
<string>com.apple.compilers.llvm.clang.1_0</string>
|
|
27
|
+
<key>DTPlatformBuild</key>
|
|
28
|
+
<string>22F76</string>
|
|
29
|
+
<key>DTPlatformName</key>
|
|
30
|
+
<string>iphonesimulator</string>
|
|
31
|
+
<key>DTPlatformVersion</key>
|
|
32
|
+
<string>18.5</string>
|
|
33
|
+
<key>DTSDKBuild</key>
|
|
34
|
+
<string>22F76</string>
|
|
35
|
+
<key>DTSDKName</key>
|
|
36
|
+
<string>iphonesimulator18.5</string>
|
|
37
|
+
<key>DTXcode</key>
|
|
38
|
+
<string>1640</string>
|
|
39
|
+
<key>DTXcodeBuild</key>
|
|
40
|
+
<string>16F6</string>
|
|
41
|
+
<key>MinimumOSVersion</key>
|
|
42
|
+
<string>15.0</string>
|
|
43
|
+
<key>UIDeviceFamily</key>
|
|
44
|
+
<array>
|
|
45
|
+
<integer>1</integer>
|
|
46
|
+
<integer>2</integer>
|
|
47
|
+
</array>
|
|
48
|
+
</dict>
|
|
49
|
+
</plist>
|
|
Binary file
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// swift-interface-format-version: 1.0
|
|
2
|
+
// swift-compiler-version: Apple Swift version 6.1.2 effective-5.10 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
|
|
3
|
+
// swift-module-flags: -target arm64-apple-ios15.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-experimental-feature DebugDescriptionMacro -module-name FountisConnect -package-name fountisconnect -module-alias Module___FountisConnect=FountisConnect -module-alias Module____StringProcessing=_StringProcessing -module-alias Module____SwiftConcurrencyShims=_SwiftConcurrencyShims -module-alias Module____Concurrency=_Concurrency -module-alias Module___CryptoKit=CryptoKit -module-alias Module___DeviceCheck=DeviceCheck -module-alias Module___UIKit=UIKit -module-alias Module___UserNotifications=UserNotifications -module-alias Module___os=os -module-alias Module___BackgroundTasks=BackgroundTasks -module-alias Module___WebKit=WebKit
|
|
4
|
+
// swift-module-flags-ignorable: -interface-compiler-version 6.1.2
|
|
5
|
+
import Module___BackgroundTasks
|
|
6
|
+
import Module___CryptoKit
|
|
7
|
+
import Module___DeviceCheck
|
|
8
|
+
import Foundation
|
|
9
|
+
import Swift
|
|
10
|
+
import Module___UIKit
|
|
11
|
+
import Module___UserNotifications
|
|
12
|
+
import Module___WebKit
|
|
13
|
+
import Module____Concurrency
|
|
14
|
+
import Module____StringProcessing
|
|
15
|
+
import Module____SwiftConcurrencyShims
|
|
16
|
+
import Module___os
|
|
17
|
+
@Module____Concurrency.MainActor public enum FountisConnect {
|
|
18
|
+
@Module____Concurrency.MainActor public static let defaultAPIBase: Foundation.URL
|
|
19
|
+
@Module____Concurrency.MainActor public static func start(key: Swift.String, apiBase: Foundation.URL? = nil)
|
|
20
|
+
@Module____Concurrency.MainActor public static func setUserToken(_ provider: @escaping () async throws -> Swift.String?)
|
|
21
|
+
@Module____Concurrency.MainActor public static func enableNotifications()
|
|
22
|
+
@discardableResult
|
|
23
|
+
@Module____Concurrency.MainActor public static func show() async -> Module___FountisConnect.FountisResult
|
|
24
|
+
@discardableResult
|
|
25
|
+
@Module____Concurrency.MainActor public static func handlePush(_ userInfo: [Swift.AnyHashable : Any]) -> Swift.Bool
|
|
26
|
+
@discardableResult
|
|
27
|
+
@Module____Concurrency.MainActor public static func handleNotificationResponse(_ response: Module___UserNotifications.UNNotificationResponse) -> Swift.Bool
|
|
28
|
+
@Module____Concurrency.MainActor public static func setUserConsent(_ granted: Swift.Bool)
|
|
29
|
+
@Module____Concurrency.MainActor public static func signOut()
|
|
30
|
+
@Module____Concurrency.MainActor public static func onEvent(_ listener: @escaping (Module___FountisConnect.FountisEvent) -> Swift.Void)
|
|
31
|
+
}
|
|
32
|
+
@frozen public enum FountisResult : Swift.Equatable, Swift.Sendable {
|
|
33
|
+
case noFill
|
|
34
|
+
case dismissed
|
|
35
|
+
case completed
|
|
36
|
+
public static func == (a: Module___FountisConnect.FountisResult, b: Module___FountisConnect.FountisResult) -> Swift.Bool
|
|
37
|
+
public func hash(into hasher: inout Swift.Hasher)
|
|
38
|
+
public var hashValue: Swift.Int {
|
|
39
|
+
get
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
public struct FountisEvent : Swift.Sendable {
|
|
43
|
+
public let type: Swift.String
|
|
44
|
+
public let offerId: Swift.String?
|
|
45
|
+
}
|
|
46
|
+
extension Module___FountisConnect.FountisConnect : Swift.Sendable {}
|
|
47
|
+
extension Module___FountisConnect.FountisResult : Swift.Hashable {}
|
|
48
|
+
extension Module___FountisConnect.FountisResult : Swift.BitwiseCopyable {}
|
|
Binary file
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// swift-interface-format-version: 1.0
|
|
2
|
+
// swift-compiler-version: Apple Swift version 6.1.2 effective-5.10 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
|
|
3
|
+
// swift-module-flags: -target x86_64-apple-ios15.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-experimental-feature DebugDescriptionMacro -module-name FountisConnect -package-name fountisconnect -module-alias Module___FountisConnect=FountisConnect -module-alias Module____StringProcessing=_StringProcessing -module-alias Module____SwiftConcurrencyShims=_SwiftConcurrencyShims -module-alias Module____Concurrency=_Concurrency -module-alias Module___CryptoKit=CryptoKit -module-alias Module___DeviceCheck=DeviceCheck -module-alias Module___UIKit=UIKit -module-alias Module___UserNotifications=UserNotifications -module-alias Module___os=os -module-alias Module___BackgroundTasks=BackgroundTasks -module-alias Module___WebKit=WebKit
|
|
4
|
+
// swift-module-flags-ignorable: -interface-compiler-version 6.1.2
|
|
5
|
+
import Module___BackgroundTasks
|
|
6
|
+
import Module___CryptoKit
|
|
7
|
+
import Module___DeviceCheck
|
|
8
|
+
import Foundation
|
|
9
|
+
import Swift
|
|
10
|
+
import Module___UIKit
|
|
11
|
+
import Module___UserNotifications
|
|
12
|
+
import Module___WebKit
|
|
13
|
+
import Module____Concurrency
|
|
14
|
+
import Module____StringProcessing
|
|
15
|
+
import Module____SwiftConcurrencyShims
|
|
16
|
+
import Module___os
|
|
17
|
+
@Module____Concurrency.MainActor public enum FountisConnect {
|
|
18
|
+
@Module____Concurrency.MainActor public static let defaultAPIBase: Foundation.URL
|
|
19
|
+
@Module____Concurrency.MainActor public static func start(key: Swift.String, apiBase: Foundation.URL? = nil)
|
|
20
|
+
@Module____Concurrency.MainActor public static func setUserToken(_ provider: @escaping () async throws -> Swift.String?)
|
|
21
|
+
@Module____Concurrency.MainActor public static func enableNotifications()
|
|
22
|
+
@discardableResult
|
|
23
|
+
@Module____Concurrency.MainActor public static func show() async -> Module___FountisConnect.FountisResult
|
|
24
|
+
@discardableResult
|
|
25
|
+
@Module____Concurrency.MainActor public static func handlePush(_ userInfo: [Swift.AnyHashable : Any]) -> Swift.Bool
|
|
26
|
+
@discardableResult
|
|
27
|
+
@Module____Concurrency.MainActor public static func handleNotificationResponse(_ response: Module___UserNotifications.UNNotificationResponse) -> Swift.Bool
|
|
28
|
+
@Module____Concurrency.MainActor public static func setUserConsent(_ granted: Swift.Bool)
|
|
29
|
+
@Module____Concurrency.MainActor public static func signOut()
|
|
30
|
+
@Module____Concurrency.MainActor public static func onEvent(_ listener: @escaping (Module___FountisConnect.FountisEvent) -> Swift.Void)
|
|
31
|
+
}
|
|
32
|
+
@frozen public enum FountisResult : Swift.Equatable, Swift.Sendable {
|
|
33
|
+
case noFill
|
|
34
|
+
case dismissed
|
|
35
|
+
case completed
|
|
36
|
+
public static func == (a: Module___FountisConnect.FountisResult, b: Module___FountisConnect.FountisResult) -> Swift.Bool
|
|
37
|
+
public func hash(into hasher: inout Swift.Hasher)
|
|
38
|
+
public var hashValue: Swift.Int {
|
|
39
|
+
get
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
public struct FountisEvent : Swift.Sendable {
|
|
43
|
+
public let type: Swift.String
|
|
44
|
+
public let offerId: Swift.String?
|
|
45
|
+
}
|
|
46
|
+
extension Module___FountisConnect.FountisConnect : Swift.Sendable {}
|
|
47
|
+
extension Module___FountisConnect.FountisResult : Swift.Hashable {}
|
|
48
|
+
extension Module___FountisConnect.FountisResult : Swift.BitwiseCopyable {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>NSPrivacyTracking</key>
|
|
6
|
+
<false/>
|
|
7
|
+
<key>NSPrivacyTrackingDomains</key>
|
|
8
|
+
<array/>
|
|
9
|
+
<key>NSPrivacyCollectedDataTypes</key>
|
|
10
|
+
<array/>
|
|
11
|
+
<key>NSPrivacyAccessedAPITypes</key>
|
|
12
|
+
<array>
|
|
13
|
+
<dict>
|
|
14
|
+
<key>NSPrivacyAccessedAPIType</key>
|
|
15
|
+
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
|
|
16
|
+
<key>NSPrivacyAccessedAPITypeReasons</key>
|
|
17
|
+
<array>
|
|
18
|
+
<string>CA92.1</string>
|
|
19
|
+
</array>
|
|
20
|
+
</dict>
|
|
21
|
+
</array>
|
|
22
|
+
</dict>
|
|
23
|
+
</plist>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
import UIKit
|
|
3
|
+
#if canImport(FountisConnect)
|
|
4
|
+
import FountisConnect
|
|
5
|
+
#endif
|
|
3
6
|
|
|
4
7
|
/// Starts the SDK while the app is still launching when the config plugin was given a key
|
|
5
8
|
/// (`FountisConnectKey` in Info.plist). iOS only accepts the background refresh registration at that moment.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
import UIKit
|
|
3
|
+
#if canImport(FountisConnect)
|
|
4
|
+
import FountisConnect
|
|
5
|
+
#endif
|
|
3
6
|
|
|
4
7
|
/// JS bridge for the FOUNTIS Connect iOS SDK. All SDK calls run on the main thread, in the order JS made them.
|
|
5
8
|
public final class FountisConnectModule: Module {
|
|
@@ -3,15 +3,31 @@ require 'fileutils'
|
|
|
3
3
|
|
|
4
4
|
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
6
|
+
# Two ways to get the FOUNTIS iOS SDK into the app:
|
|
7
|
+
#
|
|
8
|
+
# 1. Binary (the only mode of a published package): ios/FountisConnect.xcframework is in this folder. It is copied
|
|
9
|
+
# there when the package is packed (scripts/vendor-native.sh) and holds the public API plus the survey engine and
|
|
10
|
+
# privacy manifest. The pod links it and compiles only the two Swift files of this folder.
|
|
11
|
+
# 2. Source (development and CI inside this repository only): the Swift sources are in ../../ios/Sources/FountisConnect.
|
|
12
|
+
# CocoaPods cannot read files outside the pod folder, so they are copied into ios/FountisConnectSDK when
|
|
13
|
+
# `pod install` reads this file (re-run it after changing the SDK) and compiled into this pod. If you packed the
|
|
14
|
+
# package here, delete ios/FountisConnect.xcframework to get back to this mode.
|
|
15
|
+
xcframework = File.join(__dir__, 'FountisConnect.xcframework')
|
|
9
16
|
repo_sdk = File.join(__dir__, '..', '..', 'ios', 'Sources', 'FountisConnect')
|
|
10
17
|
sdk = 'FountisConnectSDK'
|
|
11
|
-
|
|
18
|
+
|
|
19
|
+
if File.directory?(xcframework)
|
|
20
|
+
mode = :binary
|
|
21
|
+
elsif File.directory?(repo_sdk)
|
|
22
|
+
mode = :source
|
|
12
23
|
FileUtils.rm_rf(File.join(__dir__, sdk))
|
|
13
24
|
FileUtils.mkdir_p(File.join(__dir__, sdk))
|
|
14
25
|
FileUtils.cp_r(Dir.glob(File.join(repo_sdk, '*')), File.join(__dir__, sdk))
|
|
26
|
+
else
|
|
27
|
+
raise "FountisConnectReactNative: ios/FountisConnect.xcframework is missing from the package " \
|
|
28
|
+
"(and the SDK sources are not next to it). Reinstall @fountispanel/connect-react-native; " \
|
|
29
|
+
"if this is the FOUNTIS repository, build the XCFramework with ios/scripts/build-xcframework.sh " \
|
|
30
|
+
"and pack the package again."
|
|
15
31
|
end
|
|
16
32
|
|
|
17
33
|
Pod::Spec.new do |s|
|
|
@@ -29,7 +45,12 @@ Pod::Spec.new do |s|
|
|
|
29
45
|
|
|
30
46
|
s.dependency 'ExpoModulesCore'
|
|
31
47
|
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
if mode == :binary
|
|
49
|
+
s.source_files = '*.swift'
|
|
50
|
+
s.vendored_frameworks = 'FountisConnect.xcframework'
|
|
51
|
+
else
|
|
52
|
+
s.source_files = ['*.swift', "#{sdk}/*.swift"]
|
|
53
|
+
s.resource_bundles = { 'FountisConnect' => ["#{sdk}/Engine", "#{sdk}/PrivacyInfo.xcprivacy"] }
|
|
54
|
+
end
|
|
34
55
|
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
|
35
56
|
end
|
package/package.json
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fountispanel/connect-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "FOUNTIS Connect for React Native and Expo (development builds): native iOS and Android SDKs, Web SDK on React Native Web.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"build",
|
|
10
|
-
"
|
|
11
|
-
"ios",
|
|
12
|
-
"
|
|
9
|
+
"build/",
|
|
10
|
+
"ios/*.swift",
|
|
11
|
+
"ios/*.podspec",
|
|
12
|
+
"ios/FountisConnect.xcframework/",
|
|
13
|
+
"android/build.gradle",
|
|
14
|
+
"android/src/",
|
|
13
15
|
"app.plugin.js",
|
|
14
16
|
"expo-module.config.json",
|
|
15
|
-
"scripts",
|
|
16
17
|
"README.md",
|
|
17
18
|
"CHANGELOG.md",
|
|
18
19
|
"LICENSE"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
|
-
"build": "
|
|
22
|
+
"build": "node build.mjs",
|
|
22
23
|
"typecheck": "tsc --noEmit",
|
|
23
24
|
"prepack": "npm run build && sh scripts/vendor-native.sh",
|
|
24
|
-
"
|
|
25
|
+
"postpack": "rm -rf ios/FountisConnect.xcframework",
|
|
26
|
+
"prepublishOnly": "npm run typecheck && npm run build && sh scripts/vendor-native.sh --require"
|
|
25
27
|
},
|
|
26
28
|
"keywords": [
|
|
27
29
|
"fountis",
|
|
@@ -35,7 +37,7 @@
|
|
|
35
37
|
"expo-modules-core": "*",
|
|
36
38
|
"react": "*",
|
|
37
39
|
"react-native": "*",
|
|
38
|
-
"@fountispanel/connect": "^1.
|
|
40
|
+
"@fountispanel/connect": "^1.2.0"
|
|
39
41
|
},
|
|
40
42
|
"peerDependenciesMeta": {
|
|
41
43
|
"@fountispanel/connect": {
|
|
@@ -50,14 +52,14 @@
|
|
|
50
52
|
"react": "19.1.0",
|
|
51
53
|
"react-native": "0.81.5",
|
|
52
54
|
"typescript": "^5",
|
|
53
|
-
"@fountispanel/connect": "file:../web"
|
|
55
|
+
"@fountispanel/connect": "file:../web",
|
|
56
|
+
"esbuild": "0.25.12"
|
|
54
57
|
},
|
|
55
58
|
"author": "FOUNTIS",
|
|
56
59
|
"homepage": "https://github.com/darbaz/fountis-connect#readme",
|
|
57
60
|
"repository": {
|
|
58
61
|
"type": "git",
|
|
59
|
-
"url": "git+https://github.com/darbaz/fountis-connect.git"
|
|
60
|
-
"directory": "react-native"
|
|
62
|
+
"url": "git+https://github.com/darbaz/fountis-connect.git"
|
|
61
63
|
},
|
|
62
64
|
"bugs": {
|
|
63
65
|
"url": "https://github.com/darbaz/fountis-connect/issues",
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
package org.fountis.connect
|
|
2
|
-
|
|
3
|
-
import java.io.ByteArrayOutputStream
|
|
4
|
-
import java.io.IOException
|
|
5
|
-
import java.io.InputStream
|
|
6
|
-
import java.net.HttpURLConnection
|
|
7
|
-
import java.net.URL
|
|
8
|
-
import java.net.URLEncoder
|
|
9
|
-
import kotlinx.coroutines.CoroutineScope
|
|
10
|
-
import kotlinx.coroutines.Dispatchers
|
|
11
|
-
import kotlinx.coroutines.SupervisorJob
|
|
12
|
-
import org.json.JSONObject
|
|
13
|
-
|
|
14
|
-
internal class ApiError(val status: Int, val code: String, override val message: String) : Exception(message) {
|
|
15
|
-
/** Errors that end the attempt for good (the engine shows the matching screen). */
|
|
16
|
-
val isFatal: Boolean get() = code in FATAL
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* FOUNTIS refused this install a guest session because it could not vouch for the device (`attestation_required`: nothing
|
|
20
|
-
* usable was sent; `attestation_failed`: what was sent did not check out). The SDK offers no guest studies then.
|
|
21
|
-
*/
|
|
22
|
-
val isAttestationRefusal: Boolean get() = status == 403 && (code == "attestation_required" || code == "attestation_failed")
|
|
23
|
-
|
|
24
|
-
companion object {
|
|
25
|
-
val FATAL = setOf("invalid_token", "not_eligible", "already_taken", "closed", "quota_full")
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* One request in flight, reachable from the thread that gave up waiting for it: [abandon] closes its connection so the
|
|
31
|
-
* thread blocked on the socket is freed, and the read loop checks it so a body that is still trickling in stops too.
|
|
32
|
-
*/
|
|
33
|
-
internal class Exchange {
|
|
34
|
-
@Volatile private var conn: HttpURLConnection? = null
|
|
35
|
-
@Volatile private var abandoned = false
|
|
36
|
-
|
|
37
|
-
/** Remembers the connection. Throws if the caller has already given up, so the request never starts. */
|
|
38
|
-
fun attach(c: HttpURLConnection) {
|
|
39
|
-
conn = c
|
|
40
|
-
checkNotAbandoned()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
fun checkNotAbandoned() {
|
|
44
|
-
if (abandoned) throw IOException("the request was abandoned")
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** Called on another thread once the caller stopped waiting. Best effort: the caller is already released. */
|
|
48
|
-
fun abandon() {
|
|
49
|
-
abandoned = true
|
|
50
|
-
conn?.disconnect()
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Thin client for the connect-api (HttpURLConnection, no cookies, no cache). Tokens are only ever sent in headers or bodies.
|
|
56
|
-
*
|
|
57
|
-
* Every request has an overall deadline ([deadlineMs], 15 s): connection, request and the whole response body. The
|
|
58
|
-
* per-step limits on the connection alone cannot give that, because a server that sends a byte now and then keeps
|
|
59
|
-
* every single read within its limit. When the deadline passes the call fails with a [RequestTimeoutException], an
|
|
60
|
-
* [IOException] like the read timeout it replaces, so it ends as noFill the same way.
|
|
61
|
-
*/
|
|
62
|
-
internal class ApiClient(base: String, val key: String, private val deadlineMs: Long = REQUEST_DEADLINE_MS) {
|
|
63
|
-
private val base = base.trimEnd('/')
|
|
64
|
-
|
|
65
|
-
/** Where the blocking requests run. A SupervisorJob keeps a failed request in its Deferred. It owns no thread of its own. */
|
|
66
|
-
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
|
67
|
-
|
|
68
|
-
private fun Exchange.request(method: String, path: String, query: Map<String, String> = emptyMap(), body: JSONObject? = null, attemptToken: String? = null): String {
|
|
69
|
-
var url = "$base/$path"
|
|
70
|
-
if (query.isNotEmpty()) url += "?" + query.entries.joinToString("&") { URLEncoder.encode(it.key, "UTF-8") + "=" + URLEncoder.encode(it.value, "UTF-8") }
|
|
71
|
-
val conn = URL(url).openConnection() as HttpURLConnection
|
|
72
|
-
try {
|
|
73
|
-
attach(conn)
|
|
74
|
-
conn.requestMethod = method
|
|
75
|
-
// Second line of defence only: the deadline ends a request first (these are per step, the deadline is the whole).
|
|
76
|
-
conn.connectTimeout = 15_000
|
|
77
|
-
conn.readTimeout = 20_000
|
|
78
|
-
conn.useCaches = false
|
|
79
|
-
conn.instanceFollowRedirects = false
|
|
80
|
-
conn.setRequestProperty("X-Fountis-Key", key)
|
|
81
|
-
conn.setRequestProperty("Accept", "application/json")
|
|
82
|
-
if (attemptToken != null) conn.setRequestProperty("Authorization", "Attempt $attemptToken")
|
|
83
|
-
if (body != null) {
|
|
84
|
-
conn.doOutput = true
|
|
85
|
-
conn.setRequestProperty("Content-Type", "application/json")
|
|
86
|
-
conn.outputStream.use { it.write(body.toString().toByteArray(Charsets.UTF_8)) }
|
|
87
|
-
}
|
|
88
|
-
val status = conn.responseCode
|
|
89
|
-
val stream = if (status in 200..299) conn.inputStream else conn.errorStream
|
|
90
|
-
val text = readBody(stream)
|
|
91
|
-
if (status in 200..299) return text
|
|
92
|
-
var code = "http_$status"
|
|
93
|
-
var message = ""
|
|
94
|
-
try {
|
|
95
|
-
val o = JSONObject(text)
|
|
96
|
-
code = o.optString("error", code)
|
|
97
|
-
message = o.optString("message", "")
|
|
98
|
-
} catch (_: Exception) {
|
|
99
|
-
}
|
|
100
|
-
throw ApiError(status, code, message)
|
|
101
|
-
} finally {
|
|
102
|
-
conn.disconnect()
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** Reads the body in pieces, so an abandoned request stops at the next piece instead of waiting for the whole body. */
|
|
107
|
-
private fun Exchange.readBody(stream: InputStream?): String {
|
|
108
|
-
if (stream == null) return ""
|
|
109
|
-
return stream.use { s ->
|
|
110
|
-
val out = ByteArrayOutputStream()
|
|
111
|
-
val buf = ByteArray(8192)
|
|
112
|
-
var n = s.read(buf)
|
|
113
|
-
while (n >= 0) {
|
|
114
|
-
checkNotAbandoned()
|
|
115
|
-
out.write(buf, 0, n)
|
|
116
|
-
n = s.read(buf)
|
|
117
|
-
}
|
|
118
|
-
out.toString("UTF-8")
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private suspend fun io(work: Exchange.() -> String): String {
|
|
123
|
-
val exchange = Exchange()
|
|
124
|
-
return callWithinDeadline(scope, deadlineMs, abandon = exchange::abandon) { exchange.work() }
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
private fun obj(text: String): JSONObject =
|
|
128
|
-
try {
|
|
129
|
-
JSONObject(text)
|
|
130
|
-
} catch (e: Exception) {
|
|
131
|
-
throw ApiError(0, "bad_response", "unexpected response")
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
suspend fun surveys(lang: String): SurveysResponse =
|
|
135
|
-
parseSurveys(io { request("GET", "surveys", query = mapOf("lang" to lang)) })
|
|
136
|
-
|
|
137
|
-
suspend fun createAttempt(offerId: String, token: String, lang: String): JSONObject =
|
|
138
|
-
obj(io { request("POST", "attempts", body = JSONObject().put("offer_id", offerId).put("token", token).put("lang", lang)) })
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Guests: the install id in, a short-lived guest session token out. 403 `guests_not_allowed` when the app has guests off.
|
|
142
|
-
* [attest] is the device attestation object when the app asks for one (see [GuestAttestation]); null sends the install id alone.
|
|
143
|
-
* 403 `attestation_required` / `attestation_failed` when FOUNTIS requires an attestation it did not get (see [ApiError.isAttestationRefusal]).
|
|
144
|
-
*/
|
|
145
|
-
suspend fun guestSession(installId: String, attest: JSONObject? = null): String {
|
|
146
|
-
val body = JSONObject().put("install_id", installId)
|
|
147
|
-
if (attest != null) body.put("attest", attest)
|
|
148
|
-
val o = obj(io { request("POST", "guest/session", body = body) })
|
|
149
|
-
return o.optString("guest_session", "").ifEmpty { throw ApiError(0, "bad_response", "no session") }
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** Guest attestation: a single-use challenge (32 random bytes, base64url) for the next guest session. Key header only. */
|
|
153
|
-
suspend fun attestChallenge(): String {
|
|
154
|
-
val o = obj(io { request("POST", "attest/challenge", body = JSONObject()) })
|
|
155
|
-
return o.optString("challenge", "").ifEmpty { throw ApiError(0, "bad_response", "no challenge") }
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
suspend fun createGuestAttempt(offerId: String, guestSession: String, lang: String): JSONObject =
|
|
159
|
-
obj(io { request("POST", "attempts", body = JSONObject().put("offer_id", offerId).put("guest_session", guestSession).put("lang", lang)) })
|
|
160
|
-
|
|
161
|
-
suspend fun putAnswer(code: String, value: Any?, attemptToken: String): JSONObject =
|
|
162
|
-
obj(io { request("PUT", "attempt/answers", body = JSONObject().put("code", code).put("value", value ?: JSONObject.NULL), attemptToken = attemptToken) })
|
|
163
|
-
|
|
164
|
-
suspend fun consent(attemptToken: String) {
|
|
165
|
-
io { request("POST", "attempt/consent", body = JSONObject(), attemptToken = attemptToken) }
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
suspend fun complete(attemptToken: String): JSONObject =
|
|
169
|
-
obj(io { request("POST", "attempt/complete", body = JSONObject(), attemptToken = attemptToken) })
|
|
170
|
-
|
|
171
|
-
suspend fun event(offerId: String, type: String) {
|
|
172
|
-
try {
|
|
173
|
-
io { request("POST", "events", body = JSONObject().put("offer_id", offerId).put("type", type)) }
|
|
174
|
-
} catch (_: IOException) {
|
|
175
|
-
} catch (_: ApiError) {
|
|
176
|
-
} catch (_: RuntimeException) {
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|