cactus-react-native 1.5.0 → 1.10.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/Cactus.podspec +1 -1
- package/README.md +347 -241
- package/android/CMakeLists.txt +24 -5
- package/android/src/main/jniLibs/arm64-v8a/libcactus.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libcurl.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedcrypto.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedtls.a +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libmbedx509.a +0 -0
- package/cpp/HybridCactus.cpp +197 -117
- package/cpp/HybridCactus.hpp +18 -9
- package/cpp/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus.h +0 -1
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_cloud.h +48 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_utils.h +568 -135
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +148 -17
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +145 -36
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +187 -6
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel_utils.h +49 -149
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus.h +0 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_cloud.h +48 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +66 -42
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_utils.h +568 -135
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +148 -17
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +145 -36
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +187 -6
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel_utils.h +49 -149
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Info.plist +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/_CodeSignature/CodeResources +1 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
- package/lib/module/classes/CactusLM.js +16 -49
- package/lib/module/classes/CactusLM.js.map +1 -1
- package/lib/module/classes/CactusSTT.js +41 -75
- package/lib/module/classes/CactusSTT.js.map +1 -1
- package/lib/module/classes/CactusVAD.js +95 -0
- package/lib/module/classes/CactusVAD.js.map +1 -0
- package/lib/module/hooks/useCactusLM.js +10 -11
- package/lib/module/hooks/useCactusLM.js.map +1 -1
- package/lib/module/hooks/useCactusSTT.js +23 -62
- package/lib/module/hooks/useCactusSTT.js.map +1 -1
- package/lib/module/hooks/useCactusVAD.js +171 -0
- package/lib/module/hooks/useCactusVAD.js.map +1 -0
- package/lib/module/index.js +2 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/modelRegistry.js +52 -0
- package/lib/module/modelRegistry.js.map +1 -0
- package/lib/module/native/Cactus.js +103 -23
- package/lib/module/native/Cactus.js.map +1 -1
- package/lib/module/native/CactusIndex.js.map +1 -1
- package/lib/module/native/index.js +0 -3
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/types/CactusVAD.js +4 -0
- package/lib/module/{specs/CactusUtil.nitro.js.map → types/CactusVAD.js.map} +1 -1
- package/lib/typescript/src/classes/CactusLM.d.ts +5 -7
- package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusSTT.d.ts +9 -12
- package/lib/typescript/src/classes/CactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusVAD.d.ts +20 -0
- package/lib/typescript/src/classes/CactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCactusLM.d.ts +2 -2
- package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusSTT.d.ts +6 -8
- package/lib/typescript/src/hooks/useCactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusVAD.d.ts +15 -0
- package/lib/typescript/src/hooks/useCactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/modelRegistry.d.ts +5 -0
- package/lib/typescript/src/modelRegistry.d.ts.map +1 -0
- package/lib/typescript/src/native/Cactus.d.ts +13 -11
- package/lib/typescript/src/native/Cactus.d.ts.map +1 -1
- package/lib/typescript/src/native/CactusIndex.d.ts +2 -2
- package/lib/typescript/src/native/CactusIndex.d.ts.map +1 -1
- package/lib/typescript/src/native/index.d.ts +0 -3
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/Cactus.nitro.d.ts +7 -6
- package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusIndex.d.ts +2 -2
- package/lib/typescript/src/types/CactusIndex.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusLM.d.ts +19 -11
- package/lib/typescript/src/types/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusSTT.d.ts +44 -12
- package/lib/typescript/src/types/CactusSTT.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusVAD.d.ts +34 -0
- package/lib/typescript/src/types/CactusVAD.d.ts.map +1 -0
- package/lib/typescript/src/types/common.d.ts +1 -6
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/nitro.json +0 -11
- package/nitrogen/generated/android/cactus+autolinking.cmake +0 -5
- package/nitrogen/generated/android/cactusOnLoad.cpp +0 -30
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +0 -50
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +9 -147
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +0 -13
- package/nitrogen/generated/ios/CactusAutolinking.mm +0 -26
- package/nitrogen/generated/ios/CactusAutolinking.swift +0 -30
- package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +5 -4
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +7 -6
- package/package.json +3 -3
- package/src/classes/CactusLM.ts +18 -65
- package/src/classes/CactusSTT.ts +52 -90
- package/src/classes/CactusVAD.ts +129 -0
- package/src/hooks/useCactusLM.ts +14 -17
- package/src/hooks/useCactusSTT.ts +47 -98
- package/src/hooks/useCactusVAD.ts +215 -0
- package/src/index.tsx +21 -12
- package/src/modelRegistry.ts +65 -0
- package/src/native/Cactus.ts +131 -38
- package/src/native/CactusIndex.ts +2 -2
- package/src/native/index.ts +0 -3
- package/src/specs/Cactus.nitro.ts +16 -7
- package/src/types/CactusIndex.ts +2 -2
- package/src/types/CactusLM.ts +19 -11
- package/src/types/CactusSTT.ts +47 -13
- package/src/types/CactusVAD.ts +39 -0
- package/src/types/common.ts +1 -6
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +0 -46
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +0 -27
- package/android/src/main/jniLibs/arm64-v8a/libcactus_util.a +0 -0
- package/cpp/HybridCactusUtil.cpp +0 -47
- package/cpp/HybridCactusUtil.hpp +0 -27
- package/cpp/cactus_util.h +0 -25
- package/ios/HybridCactusCrypto.swift +0 -37
- package/ios/HybridCactusDeviceInfo.swift +0 -32
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_telemetry.h +0 -656
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_telemetry.h +0 -656
- package/ios/cactus_util.xcframework/Info.plist +0 -39
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/cactus_util.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/database.h +0 -27
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/ios_utils.h +0 -10
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Headers/logging.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/Info.plist +0 -0
- package/ios/cactus_util.xcframework/ios-arm64/cactus_util.framework/cactus_util +0 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/cactus_util.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/database.h +0 -27
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/ios_utils.h +0 -10
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Headers/logging.h +0 -25
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/Info.plist +0 -0
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/_CodeSignature/CodeResources +0 -135
- package/ios/cactus_util.xcframework/ios-arm64-simulator/cactus_util.framework/cactus_util +0 -0
- package/lib/module/api/Database.js +0 -45
- package/lib/module/api/Database.js.map +0 -1
- package/lib/module/api/RemoteLM.js +0 -201
- package/lib/module/api/RemoteLM.js.map +0 -1
- package/lib/module/config/CactusConfig.js +0 -12
- package/lib/module/config/CactusConfig.js.map +0 -1
- package/lib/module/models.js +0 -336
- package/lib/module/models.js.map +0 -1
- package/lib/module/native/CactusCrypto.js +0 -10
- package/lib/module/native/CactusCrypto.js.map +0 -1
- package/lib/module/native/CactusDeviceInfo.js +0 -13
- package/lib/module/native/CactusDeviceInfo.js.map +0 -1
- package/lib/module/native/CactusUtil.js +0 -36
- package/lib/module/native/CactusUtil.js.map +0 -1
- package/lib/module/specs/CactusCrypto.nitro.js +0 -4
- package/lib/module/specs/CactusCrypto.nitro.js.map +0 -1
- package/lib/module/specs/CactusDeviceInfo.nitro.js +0 -4
- package/lib/module/specs/CactusDeviceInfo.nitro.js.map +0 -1
- package/lib/module/specs/CactusUtil.nitro.js +0 -4
- package/lib/module/telemetry/Telemetry.js +0 -154
- package/lib/module/telemetry/Telemetry.js.map +0 -1
- package/lib/typescript/src/api/Database.d.ts +0 -12
- package/lib/typescript/src/api/Database.d.ts.map +0 -1
- package/lib/typescript/src/api/RemoteLM.d.ts +0 -14
- package/lib/typescript/src/api/RemoteLM.d.ts.map +0 -1
- package/lib/typescript/src/config/CactusConfig.d.ts +0 -7
- package/lib/typescript/src/config/CactusConfig.d.ts.map +0 -1
- package/lib/typescript/src/models.d.ts +0 -6
- package/lib/typescript/src/models.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusCrypto.d.ts +0 -5
- package/lib/typescript/src/native/CactusCrypto.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts +0 -7
- package/lib/typescript/src/native/CactusDeviceInfo.d.ts.map +0 -1
- package/lib/typescript/src/native/CactusUtil.d.ts +0 -6
- package/lib/typescript/src/native/CactusUtil.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts +0 -8
- package/lib/typescript/src/specs/CactusCrypto.nitro.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts +0 -16
- package/lib/typescript/src/specs/CactusDeviceInfo.nitro.d.ts.map +0 -1
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts +0 -10
- package/lib/typescript/src/specs/CactusUtil.nitro.d.ts.map +0 -1
- package/lib/typescript/src/telemetry/Telemetry.d.ts +0 -34
- package/lib/typescript/src/telemetry/Telemetry.d.ts.map +0 -1
- package/nitrogen/generated/android/c++/JDeviceInfo.hpp +0 -74
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp +0 -65
- package/nitrogen/generated/android/c++/JHybridCactusCryptoSpec.hpp +0 -65
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp +0 -85
- package/nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.hpp +0 -66
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/DeviceInfo.kt +0 -50
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusCryptoSpec.kt +0 -58
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusDeviceInfoSpec.kt +0 -62
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridCactusCryptoSpecSwift.hpp +0 -77
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridCactusDeviceInfoSpecSwift.hpp +0 -88
- package/nitrogen/generated/ios/swift/DeviceInfo.swift +0 -98
- package/nitrogen/generated/ios/swift/Func_void_DeviceInfo.swift +0 -47
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +0 -54
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec.swift +0 -57
- package/nitrogen/generated/ios/swift/HybridCactusCryptoSpec_cxx.swift +0 -139
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec.swift +0 -58
- package/nitrogen/generated/ios/swift/HybridCactusDeviceInfoSpec_cxx.swift +0 -164
- package/nitrogen/generated/shared/c++/DeviceInfo.hpp +0 -92
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp +0 -21
- package/nitrogen/generated/shared/c++/HybridCactusCryptoSpec.hpp +0 -63
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp +0 -22
- package/nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.hpp +0 -67
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp +0 -23
- package/nitrogen/generated/shared/c++/HybridCactusUtilSpec.hpp +0 -66
- package/src/api/Database.ts +0 -55
- package/src/api/RemoteLM.ts +0 -273
- package/src/config/CactusConfig.ts +0 -11
- package/src/models.ts +0 -344
- package/src/native/CactusCrypto.ts +0 -11
- package/src/native/CactusDeviceInfo.ts +0 -18
- package/src/native/CactusUtil.ts +0 -43
- package/src/specs/CactusCrypto.nitro.ts +0 -6
- package/src/specs/CactusDeviceInfo.nitro.ts +0 -15
- package/src/specs/CactusUtil.nitro.ts +0 -8
- package/src/telemetry/Telemetry.ts +0 -236
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridCactusDeviceInfoSpec_cxx.swift
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
import NitroModules
|
|
10
|
-
import NitroModules
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A class implementation that bridges HybridCactusDeviceInfoSpec over to C++.
|
|
14
|
-
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
15
|
-
*
|
|
16
|
-
* Also, some Swift types need to be bridged with special handling:
|
|
17
|
-
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
18
|
-
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
19
|
-
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
20
|
-
*/
|
|
21
|
-
open class HybridCactusDeviceInfoSpec_cxx {
|
|
22
|
-
/**
|
|
23
|
-
* The Swift <> C++ bridge's namespace (`margelo::nitro::cactus::bridge::swift`)
|
|
24
|
-
* from `Cactus-Swift-Cxx-Bridge.hpp`.
|
|
25
|
-
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
26
|
-
*/
|
|
27
|
-
public typealias bridge = margelo.nitro.cactus.bridge.swift
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Holds an instance of the `HybridCactusDeviceInfoSpec` Swift protocol.
|
|
31
|
-
*/
|
|
32
|
-
private var __implementation: any HybridCactusDeviceInfoSpec
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
36
|
-
*/
|
|
37
|
-
private var __cxxPart: bridge.std__weak_ptr_HybridCactusDeviceInfoSpec_
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Create a new `HybridCactusDeviceInfoSpec_cxx` that wraps the given `HybridCactusDeviceInfoSpec`.
|
|
41
|
-
* All properties and methods bridge to C++ types.
|
|
42
|
-
*/
|
|
43
|
-
public init(_ implementation: any HybridCactusDeviceInfoSpec) {
|
|
44
|
-
self.__implementation = implementation
|
|
45
|
-
self.__cxxPart = .init()
|
|
46
|
-
/* no base class */
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Get the actual `HybridCactusDeviceInfoSpec` instance this class wraps.
|
|
51
|
-
*/
|
|
52
|
-
@inline(__always)
|
|
53
|
-
public func getHybridCactusDeviceInfoSpec() -> any HybridCactusDeviceInfoSpec {
|
|
54
|
-
return __implementation
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Casts this instance to a retained unsafe raw pointer.
|
|
59
|
-
* This acquires one additional strong reference on the object!
|
|
60
|
-
*/
|
|
61
|
-
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
62
|
-
return Unmanaged.passRetained(self).toOpaque()
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Casts an unsafe pointer to a `HybridCactusDeviceInfoSpec_cxx`.
|
|
67
|
-
* The pointer has to be a retained opaque `Unmanaged<HybridCactusDeviceInfoSpec_cxx>`.
|
|
68
|
-
* This removes one strong reference from the object!
|
|
69
|
-
*/
|
|
70
|
-
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridCactusDeviceInfoSpec_cxx {
|
|
71
|
-
return Unmanaged<HybridCactusDeviceInfoSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
76
|
-
* The C++ part is a `std::shared_ptr<HybridCactusDeviceInfoSpec>`.
|
|
77
|
-
*/
|
|
78
|
-
public func getCxxPart() -> bridge.std__shared_ptr_HybridCactusDeviceInfoSpec_ {
|
|
79
|
-
let cachedCxxPart = self.__cxxPart.lock()
|
|
80
|
-
if Bool(fromCxx: cachedCxxPart) {
|
|
81
|
-
return cachedCxxPart
|
|
82
|
-
} else {
|
|
83
|
-
let newCxxPart = bridge.create_std__shared_ptr_HybridCactusDeviceInfoSpec_(self.toUnsafe())
|
|
84
|
-
__cxxPart = bridge.weakify_std__shared_ptr_HybridCactusDeviceInfoSpec_(newCxxPart)
|
|
85
|
-
return newCxxPart
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
93
|
-
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
94
|
-
*/
|
|
95
|
-
@inline(__always)
|
|
96
|
-
public var memorySize: Int {
|
|
97
|
-
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Call dispose() on the Swift class.
|
|
102
|
-
* This _may_ be called manually from JS.
|
|
103
|
-
*/
|
|
104
|
-
@inline(__always)
|
|
105
|
-
public func dispose() {
|
|
106
|
-
self.__implementation.dispose()
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Call toString() on the Swift class.
|
|
111
|
-
*/
|
|
112
|
-
@inline(__always)
|
|
113
|
-
public func toString() -> String {
|
|
114
|
-
return self.__implementation.toString()
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Properties
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// Methods
|
|
121
|
-
@inline(__always)
|
|
122
|
-
public final func getAppIdentifier() -> bridge.Result_std__shared_ptr_Promise_std__optional_std__string____ {
|
|
123
|
-
do {
|
|
124
|
-
let __result = try self.__implementation.getAppIdentifier()
|
|
125
|
-
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__optional_std__string___ in
|
|
126
|
-
let __promise = bridge.create_std__shared_ptr_Promise_std__optional_std__string___()
|
|
127
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__optional_std__string___(__promise)
|
|
128
|
-
__result
|
|
129
|
-
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__optional_std__string_ in
|
|
130
|
-
if let __unwrappedValue = __result {
|
|
131
|
-
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
132
|
-
} else {
|
|
133
|
-
return .init()
|
|
134
|
-
}
|
|
135
|
-
}()) })
|
|
136
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
137
|
-
return __promise
|
|
138
|
-
}()
|
|
139
|
-
return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__string____(__resultCpp)
|
|
140
|
-
} catch (let __error) {
|
|
141
|
-
let __exceptionPtr = __error.toCpp()
|
|
142
|
-
return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__string____(__exceptionPtr)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
@inline(__always)
|
|
147
|
-
public final func getDeviceInfo() -> bridge.Result_std__shared_ptr_Promise_DeviceInfo___ {
|
|
148
|
-
do {
|
|
149
|
-
let __result = try self.__implementation.getDeviceInfo()
|
|
150
|
-
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_DeviceInfo__ in
|
|
151
|
-
let __promise = bridge.create_std__shared_ptr_Promise_DeviceInfo__()
|
|
152
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_DeviceInfo__(__promise)
|
|
153
|
-
__result
|
|
154
|
-
.then({ __result in __promiseHolder.resolve(__result) })
|
|
155
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
156
|
-
return __promise
|
|
157
|
-
}()
|
|
158
|
-
return bridge.create_Result_std__shared_ptr_Promise_DeviceInfo___(__resultCpp)
|
|
159
|
-
} catch (let __error) {
|
|
160
|
-
let __exceptionPtr = __error.toCpp()
|
|
161
|
-
return bridge.create_Result_std__shared_ptr_Promise_DeviceInfo___(__exceptionPtr)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// DeviceInfo.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#pragma once
|
|
9
|
-
|
|
10
|
-
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
-
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
-
#else
|
|
13
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
-
#endif
|
|
15
|
-
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
-
#else
|
|
18
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
-
#endif
|
|
20
|
-
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
-
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
-
#else
|
|
23
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
-
#endif
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
#include <string>
|
|
29
|
-
#include <optional>
|
|
30
|
-
|
|
31
|
-
namespace margelo::nitro::cactus {
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* A struct which can be represented as a JavaScript object (DeviceInfo).
|
|
35
|
-
*/
|
|
36
|
-
struct DeviceInfo {
|
|
37
|
-
public:
|
|
38
|
-
std::string brand SWIFT_PRIVATE;
|
|
39
|
-
std::string model SWIFT_PRIVATE;
|
|
40
|
-
std::optional<std::string> device_id SWIFT_PRIVATE;
|
|
41
|
-
std::string os SWIFT_PRIVATE;
|
|
42
|
-
std::string os_version SWIFT_PRIVATE;
|
|
43
|
-
|
|
44
|
-
public:
|
|
45
|
-
DeviceInfo() = default;
|
|
46
|
-
explicit DeviceInfo(std::string brand, std::string model, std::optional<std::string> device_id, std::string os, std::string os_version): brand(brand), model(model), device_id(device_id), os(os), os_version(os_version) {}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
} // namespace margelo::nitro::cactus
|
|
50
|
-
|
|
51
|
-
namespace margelo::nitro {
|
|
52
|
-
|
|
53
|
-
// C++ DeviceInfo <> JS DeviceInfo (object)
|
|
54
|
-
template <>
|
|
55
|
-
struct JSIConverter<margelo::nitro::cactus::DeviceInfo> final {
|
|
56
|
-
static inline margelo::nitro::cactus::DeviceInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
57
|
-
jsi::Object obj = arg.asObject(runtime);
|
|
58
|
-
return margelo::nitro::cactus::DeviceInfo(
|
|
59
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "brand")),
|
|
60
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "model")),
|
|
61
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "device_id")),
|
|
62
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "os")),
|
|
63
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "os_version"))
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::cactus::DeviceInfo& arg) {
|
|
67
|
-
jsi::Object obj(runtime);
|
|
68
|
-
obj.setProperty(runtime, "brand", JSIConverter<std::string>::toJSI(runtime, arg.brand));
|
|
69
|
-
obj.setProperty(runtime, "model", JSIConverter<std::string>::toJSI(runtime, arg.model));
|
|
70
|
-
obj.setProperty(runtime, "device_id", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.device_id));
|
|
71
|
-
obj.setProperty(runtime, "os", JSIConverter<std::string>::toJSI(runtime, arg.os));
|
|
72
|
-
obj.setProperty(runtime, "os_version", JSIConverter<std::string>::toJSI(runtime, arg.os_version));
|
|
73
|
-
return obj;
|
|
74
|
-
}
|
|
75
|
-
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
76
|
-
if (!value.isObject()) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
jsi::Object obj = value.getObject(runtime);
|
|
80
|
-
if (!nitro::isPlainObject(runtime, obj)) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "brand"))) return false;
|
|
84
|
-
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "model"))) return false;
|
|
85
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "device_id"))) return false;
|
|
86
|
-
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "os"))) return false;
|
|
87
|
-
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "os_version"))) return false;
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
} // namespace margelo::nitro
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridCactusCryptoSpec.cpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#include "HybridCactusCryptoSpec.hpp"
|
|
9
|
-
|
|
10
|
-
namespace margelo::nitro::cactus {
|
|
11
|
-
|
|
12
|
-
void HybridCactusCryptoSpec::loadHybridMethods() {
|
|
13
|
-
// load base methods/properties
|
|
14
|
-
HybridObject::loadHybridMethods();
|
|
15
|
-
// load custom methods/properties
|
|
16
|
-
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridMethod("uuidv5", &HybridCactusCryptoSpec::uuidv5);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
} // namespace margelo::nitro::cactus
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridCactusCryptoSpec.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#pragma once
|
|
9
|
-
|
|
10
|
-
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
-
#include <NitroModules/HybridObject.hpp>
|
|
12
|
-
#else
|
|
13
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#include <string>
|
|
19
|
-
#include <NitroModules/Promise.hpp>
|
|
20
|
-
|
|
21
|
-
namespace margelo::nitro::cactus {
|
|
22
|
-
|
|
23
|
-
using namespace margelo::nitro;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* An abstract base class for `CactusCrypto`
|
|
27
|
-
* Inherit this class to create instances of `HybridCactusCryptoSpec` in C++.
|
|
28
|
-
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
29
|
-
* @example
|
|
30
|
-
* ```cpp
|
|
31
|
-
* class HybridCactusCrypto: public HybridCactusCryptoSpec {
|
|
32
|
-
* public:
|
|
33
|
-
* HybridCactusCrypto(...): HybridObject(TAG) { ... }
|
|
34
|
-
* // ...
|
|
35
|
-
* };
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
class HybridCactusCryptoSpec: public virtual HybridObject {
|
|
39
|
-
public:
|
|
40
|
-
// Constructor
|
|
41
|
-
explicit HybridCactusCryptoSpec(): HybridObject(TAG) { }
|
|
42
|
-
|
|
43
|
-
// Destructor
|
|
44
|
-
~HybridCactusCryptoSpec() override = default;
|
|
45
|
-
|
|
46
|
-
public:
|
|
47
|
-
// Properties
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
public:
|
|
51
|
-
// Methods
|
|
52
|
-
virtual std::shared_ptr<Promise<std::string>> uuidv5(const std::string& namespaceUuid, const std::string& name) = 0;
|
|
53
|
-
|
|
54
|
-
protected:
|
|
55
|
-
// Hybrid Setup
|
|
56
|
-
void loadHybridMethods() override;
|
|
57
|
-
|
|
58
|
-
protected:
|
|
59
|
-
// Tag for logging
|
|
60
|
-
static constexpr auto TAG = "CactusCrypto";
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
} // namespace margelo::nitro::cactus
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridCactusDeviceInfoSpec.cpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#include "HybridCactusDeviceInfoSpec.hpp"
|
|
9
|
-
|
|
10
|
-
namespace margelo::nitro::cactus {
|
|
11
|
-
|
|
12
|
-
void HybridCactusDeviceInfoSpec::loadHybridMethods() {
|
|
13
|
-
// load base methods/properties
|
|
14
|
-
HybridObject::loadHybridMethods();
|
|
15
|
-
// load custom methods/properties
|
|
16
|
-
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridMethod("getAppIdentifier", &HybridCactusDeviceInfoSpec::getAppIdentifier);
|
|
18
|
-
prototype.registerHybridMethod("getDeviceInfo", &HybridCactusDeviceInfoSpec::getDeviceInfo);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
} // namespace margelo::nitro::cactus
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridCactusDeviceInfoSpec.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#pragma once
|
|
9
|
-
|
|
10
|
-
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
-
#include <NitroModules/HybridObject.hpp>
|
|
12
|
-
#else
|
|
13
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
// Forward declaration of `DeviceInfo` to properly resolve imports.
|
|
17
|
-
namespace margelo::nitro::cactus { struct DeviceInfo; }
|
|
18
|
-
|
|
19
|
-
#include <string>
|
|
20
|
-
#include <optional>
|
|
21
|
-
#include <NitroModules/Promise.hpp>
|
|
22
|
-
#include "DeviceInfo.hpp"
|
|
23
|
-
|
|
24
|
-
namespace margelo::nitro::cactus {
|
|
25
|
-
|
|
26
|
-
using namespace margelo::nitro;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* An abstract base class for `CactusDeviceInfo`
|
|
30
|
-
* Inherit this class to create instances of `HybridCactusDeviceInfoSpec` in C++.
|
|
31
|
-
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
32
|
-
* @example
|
|
33
|
-
* ```cpp
|
|
34
|
-
* class HybridCactusDeviceInfo: public HybridCactusDeviceInfoSpec {
|
|
35
|
-
* public:
|
|
36
|
-
* HybridCactusDeviceInfo(...): HybridObject(TAG) { ... }
|
|
37
|
-
* // ...
|
|
38
|
-
* };
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
class HybridCactusDeviceInfoSpec: public virtual HybridObject {
|
|
42
|
-
public:
|
|
43
|
-
// Constructor
|
|
44
|
-
explicit HybridCactusDeviceInfoSpec(): HybridObject(TAG) { }
|
|
45
|
-
|
|
46
|
-
// Destructor
|
|
47
|
-
~HybridCactusDeviceInfoSpec() override = default;
|
|
48
|
-
|
|
49
|
-
public:
|
|
50
|
-
// Properties
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
public:
|
|
54
|
-
// Methods
|
|
55
|
-
virtual std::shared_ptr<Promise<std::optional<std::string>>> getAppIdentifier() = 0;
|
|
56
|
-
virtual std::shared_ptr<Promise<DeviceInfo>> getDeviceInfo() = 0;
|
|
57
|
-
|
|
58
|
-
protected:
|
|
59
|
-
// Hybrid Setup
|
|
60
|
-
void loadHybridMethods() override;
|
|
61
|
-
|
|
62
|
-
protected:
|
|
63
|
-
// Tag for logging
|
|
64
|
-
static constexpr auto TAG = "CactusDeviceInfo";
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
} // namespace margelo::nitro::cactus
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridCactusUtilSpec.cpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#include "HybridCactusUtilSpec.hpp"
|
|
9
|
-
|
|
10
|
-
namespace margelo::nitro::cactus {
|
|
11
|
-
|
|
12
|
-
void HybridCactusUtilSpec::loadHybridMethods() {
|
|
13
|
-
// load base methods/properties
|
|
14
|
-
HybridObject::loadHybridMethods();
|
|
15
|
-
// load custom methods/properties
|
|
16
|
-
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridMethod("registerApp", &HybridCactusUtilSpec::registerApp);
|
|
18
|
-
prototype.registerHybridMethod("getDeviceId", &HybridCactusUtilSpec::getDeviceId);
|
|
19
|
-
prototype.registerHybridMethod("setAndroidDataDirectory", &HybridCactusUtilSpec::setAndroidDataDirectory);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
} // namespace margelo::nitro::cactus
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridCactusUtilSpec.hpp
|
|
3
|
-
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
-
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
-
///
|
|
7
|
-
|
|
8
|
-
#pragma once
|
|
9
|
-
|
|
10
|
-
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
-
#include <NitroModules/HybridObject.hpp>
|
|
12
|
-
#else
|
|
13
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
#include <string>
|
|
19
|
-
#include <NitroModules/Promise.hpp>
|
|
20
|
-
#include <optional>
|
|
21
|
-
|
|
22
|
-
namespace margelo::nitro::cactus {
|
|
23
|
-
|
|
24
|
-
using namespace margelo::nitro;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* An abstract base class for `CactusUtil`
|
|
28
|
-
* Inherit this class to create instances of `HybridCactusUtilSpec` in C++.
|
|
29
|
-
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
30
|
-
* @example
|
|
31
|
-
* ```cpp
|
|
32
|
-
* class HybridCactusUtil: public HybridCactusUtilSpec {
|
|
33
|
-
* public:
|
|
34
|
-
* HybridCactusUtil(...): HybridObject(TAG) { ... }
|
|
35
|
-
* // ...
|
|
36
|
-
* };
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
class HybridCactusUtilSpec: public virtual HybridObject {
|
|
40
|
-
public:
|
|
41
|
-
// Constructor
|
|
42
|
-
explicit HybridCactusUtilSpec(): HybridObject(TAG) { }
|
|
43
|
-
|
|
44
|
-
// Destructor
|
|
45
|
-
~HybridCactusUtilSpec() override = default;
|
|
46
|
-
|
|
47
|
-
public:
|
|
48
|
-
// Properties
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
public:
|
|
52
|
-
// Methods
|
|
53
|
-
virtual std::shared_ptr<Promise<std::string>> registerApp(const std::string& encryptedData) = 0;
|
|
54
|
-
virtual std::shared_ptr<Promise<std::optional<std::string>>> getDeviceId(const std::optional<std::string>& token) = 0;
|
|
55
|
-
virtual std::shared_ptr<Promise<void>> setAndroidDataDirectory(const std::string& dataDir) = 0;
|
|
56
|
-
|
|
57
|
-
protected:
|
|
58
|
-
// Hybrid Setup
|
|
59
|
-
void loadHybridMethods() override;
|
|
60
|
-
|
|
61
|
-
protected:
|
|
62
|
-
// Tag for logging
|
|
63
|
-
static constexpr auto TAG = "CactusUtil";
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
} // namespace margelo::nitro::cactus
|
package/src/api/Database.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { CactusUtil } from '../native';
|
|
2
|
-
import type { DeviceInfo } from '../specs/CactusDeviceInfo.nitro';
|
|
3
|
-
import type { LogRecord } from '../telemetry/Telemetry';
|
|
4
|
-
import { CactusConfig } from '../config/CactusConfig';
|
|
5
|
-
|
|
6
|
-
export class Database {
|
|
7
|
-
private static readonly url = 'https://vlqqczxwyaodtcdmdmlw.supabase.co';
|
|
8
|
-
private static readonly key =
|
|
9
|
-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZscXFjenh3eWFvZHRjZG1kbWx3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTE1MTg2MzIsImV4cCI6MjA2NzA5NDYzMn0.nBzqGuK9j6RZ6mOPWU2boAC_5H9XDs-fPpo5P3WZYbI';
|
|
10
|
-
|
|
11
|
-
public static async sendLogRecords(records: LogRecord[]): Promise<void> {
|
|
12
|
-
const response = await fetch(`${this.url}/rest/v1/logs`, {
|
|
13
|
-
method: 'POST',
|
|
14
|
-
headers: {
|
|
15
|
-
'apikey': this.key,
|
|
16
|
-
'Authorization': `Bearer ${this.key}`,
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
'Content-Profile': 'cactus',
|
|
19
|
-
'Prefer': 'return=minimal',
|
|
20
|
-
},
|
|
21
|
-
body: JSON.stringify(records),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (!response.ok) {
|
|
25
|
-
throw new Error('Sending logs failed');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public static async registerDevice({
|
|
30
|
-
deviceData,
|
|
31
|
-
deviceId,
|
|
32
|
-
}: {
|
|
33
|
-
deviceData?: DeviceInfo;
|
|
34
|
-
deviceId?: string;
|
|
35
|
-
}): Promise<string> {
|
|
36
|
-
const response = await fetch(
|
|
37
|
-
`${this.url}/functions/v1/device-registration`,
|
|
38
|
-
{
|
|
39
|
-
method: 'POST',
|
|
40
|
-
body: JSON.stringify({
|
|
41
|
-
device_data: deviceData,
|
|
42
|
-
device_id: deviceId,
|
|
43
|
-
cactus_pro_key: CactusConfig.cactusProKey,
|
|
44
|
-
}),
|
|
45
|
-
headers: { 'Content-Type': 'application/json' },
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
if (!response.ok) {
|
|
50
|
-
throw new Error('Registering device failed');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return await CactusUtil.registerApp(await response.text());
|
|
54
|
-
}
|
|
55
|
-
}
|