react-native-nitro-net 0.1.5 → 0.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.
Files changed (48) hide show
  1. package/README.md +56 -4
  2. package/android/libs/arm64-v8a/librust_c_net.so +0 -0
  3. package/android/libs/armeabi-v7a/librust_c_net.so +0 -0
  4. package/android/libs/x86/librust_c_net.so +0 -0
  5. package/android/libs/x86_64/librust_c_net.so +0 -0
  6. package/cpp/HybridNetDriver.hpp +68 -0
  7. package/cpp/HybridNetServerDriver.hpp +9 -0
  8. package/cpp/HybridNetSocketDriver.hpp +149 -0
  9. package/cpp/NetBindings.hpp +52 -1
  10. package/ios/Frameworks/RustCNet.xcframework/Info.plist +5 -5
  11. package/ios/Frameworks/RustCNet.xcframework/ios-arm64/RustCNet.framework/RustCNet +0 -0
  12. package/ios/Frameworks/RustCNet.xcframework/ios-arm64_x86_64-simulator/RustCNet.framework/RustCNet +0 -0
  13. package/lib/Net.nitro.d.ts +27 -1
  14. package/lib/Net.nitro.js +3 -1
  15. package/lib/index.d.ts +4 -3
  16. package/lib/index.js +47 -6
  17. package/lib/tls.d.ts +124 -0
  18. package/lib/tls.js +451 -0
  19. package/nitrogen/generated/android/c++/JHybridNetDriverSpec.cpp +38 -1
  20. package/nitrogen/generated/android/c++/JHybridNetDriverSpec.hpp +8 -0
  21. package/nitrogen/generated/android/c++/JHybridNetServerDriverSpec.cpp +4 -0
  22. package/nitrogen/generated/android/c++/JHybridNetServerDriverSpec.hpp +1 -0
  23. package/nitrogen/generated/android/c++/JHybridNetSocketDriverSpec.cpp +70 -0
  24. package/nitrogen/generated/android/c++/JHybridNetSocketDriverSpec.hpp +15 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridNetDriverSpec.kt +33 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridNetServerDriverSpec.kt +4 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridNetSocketDriverSpec.kt +60 -0
  28. package/nitrogen/generated/ios/RustCNet-Swift-Cxx-Bridge.hpp +95 -44
  29. package/nitrogen/generated/ios/c++/HybridNetDriverSpecSwift.hpp +58 -0
  30. package/nitrogen/generated/ios/c++/HybridNetServerDriverSpecSwift.hpp +6 -0
  31. package/nitrogen/generated/ios/c++/HybridNetSocketDriverSpecSwift.hpp +109 -0
  32. package/nitrogen/generated/ios/swift/HybridNetDriverSpec.swift +8 -0
  33. package/nitrogen/generated/ios/swift/HybridNetDriverSpec_cxx.swift +118 -0
  34. package/nitrogen/generated/ios/swift/HybridNetServerDriverSpec.swift +1 -0
  35. package/nitrogen/generated/ios/swift/HybridNetServerDriverSpec_cxx.swift +25 -0
  36. package/nitrogen/generated/ios/swift/HybridNetSocketDriverSpec.swift +15 -0
  37. package/nitrogen/generated/ios/swift/HybridNetSocketDriverSpec_cxx.swift +278 -0
  38. package/nitrogen/generated/shared/c++/HybridNetDriverSpec.cpp +8 -0
  39. package/nitrogen/generated/shared/c++/HybridNetDriverSpec.hpp +9 -0
  40. package/nitrogen/generated/shared/c++/HybridNetServerDriverSpec.cpp +1 -0
  41. package/nitrogen/generated/shared/c++/HybridNetServerDriverSpec.hpp +1 -0
  42. package/nitrogen/generated/shared/c++/HybridNetSocketDriverSpec.cpp +15 -0
  43. package/nitrogen/generated/shared/c++/HybridNetSocketDriverSpec.hpp +16 -0
  44. package/package.json +5 -3
  45. package/react-native-nitro-net.podspec +1 -3
  46. package/src/Net.nitro.ts +27 -1
  47. package/src/index.ts +18 -9
  48. package/src/tls.ts +532 -0
@@ -19,6 +19,7 @@ namespace NitroModules { class ArrayBufferHolder; }
19
19
  #include <functional>
20
20
  #include <NitroModules/ArrayBufferHolder.hpp>
21
21
  #include <string>
22
+ #include <optional>
22
23
 
23
24
  #include "RustCNet-Swift-Cxx-Umbrella.hpp"
24
25
 
@@ -79,12 +80,114 @@ namespace margelo::nitro::net {
79
80
  std::rethrow_exception(__result.error());
80
81
  }
81
82
  }
83
+ inline void connectTLS(const std::string& host, double port, const std::optional<std::string>& serverName, std::optional<bool> rejectUnauthorized) override {
84
+ auto __result = _swiftPart.connectTLS(host, std::forward<decltype(port)>(port), serverName, rejectUnauthorized);
85
+ if (__result.hasError()) [[unlikely]] {
86
+ std::rethrow_exception(__result.error());
87
+ }
88
+ }
89
+ inline void connectTLSWithContext(const std::string& host, double port, const std::optional<std::string>& serverName, std::optional<bool> rejectUnauthorized, std::optional<double> secureContextId) override {
90
+ auto __result = _swiftPart.connectTLSWithContext(host, std::forward<decltype(port)>(port), serverName, rejectUnauthorized, secureContextId);
91
+ if (__result.hasError()) [[unlikely]] {
92
+ std::rethrow_exception(__result.error());
93
+ }
94
+ }
95
+ inline std::optional<std::string> getAuthorizationError() override {
96
+ auto __result = _swiftPart.getAuthorizationError();
97
+ if (__result.hasError()) [[unlikely]] {
98
+ std::rethrow_exception(__result.error());
99
+ }
100
+ auto __value = std::move(__result.value());
101
+ return __value;
102
+ }
103
+ inline std::optional<std::string> getProtocol() override {
104
+ auto __result = _swiftPart.getProtocol();
105
+ if (__result.hasError()) [[unlikely]] {
106
+ std::rethrow_exception(__result.error());
107
+ }
108
+ auto __value = std::move(__result.value());
109
+ return __value;
110
+ }
111
+ inline std::optional<std::string> getCipher() override {
112
+ auto __result = _swiftPart.getCipher();
113
+ if (__result.hasError()) [[unlikely]] {
114
+ std::rethrow_exception(__result.error());
115
+ }
116
+ auto __value = std::move(__result.value());
117
+ return __value;
118
+ }
119
+ inline std::optional<std::string> getALPN() override {
120
+ auto __result = _swiftPart.getALPN();
121
+ if (__result.hasError()) [[unlikely]] {
122
+ std::rethrow_exception(__result.error());
123
+ }
124
+ auto __value = std::move(__result.value());
125
+ return __value;
126
+ }
127
+ inline std::optional<std::string> getPeerCertificateJSON() override {
128
+ auto __result = _swiftPart.getPeerCertificateJSON();
129
+ if (__result.hasError()) [[unlikely]] {
130
+ std::rethrow_exception(__result.error());
131
+ }
132
+ auto __value = std::move(__result.value());
133
+ return __value;
134
+ }
135
+ inline std::optional<std::string> getEphemeralKeyInfo() override {
136
+ auto __result = _swiftPart.getEphemeralKeyInfo();
137
+ if (__result.hasError()) [[unlikely]] {
138
+ std::rethrow_exception(__result.error());
139
+ }
140
+ auto __value = std::move(__result.value());
141
+ return __value;
142
+ }
143
+ inline std::optional<std::string> getSharedSigalgs() override {
144
+ auto __result = _swiftPart.getSharedSigalgs();
145
+ if (__result.hasError()) [[unlikely]] {
146
+ std::rethrow_exception(__result.error());
147
+ }
148
+ auto __value = std::move(__result.value());
149
+ return __value;
150
+ }
151
+ inline bool isSessionReused() override {
152
+ auto __result = _swiftPart.isSessionReused();
153
+ if (__result.hasError()) [[unlikely]] {
154
+ std::rethrow_exception(__result.error());
155
+ }
156
+ auto __value = std::move(__result.value());
157
+ return __value;
158
+ }
159
+ inline std::optional<std::shared_ptr<ArrayBuffer>> getSession() override {
160
+ auto __result = _swiftPart.getSession();
161
+ if (__result.hasError()) [[unlikely]] {
162
+ std::rethrow_exception(__result.error());
163
+ }
164
+ auto __value = std::move(__result.value());
165
+ return __value;
166
+ }
167
+ inline void setSession(const std::shared_ptr<ArrayBuffer>& session) override {
168
+ auto __result = _swiftPart.setSession(ArrayBufferHolder(session));
169
+ if (__result.hasError()) [[unlikely]] {
170
+ std::rethrow_exception(__result.error());
171
+ }
172
+ }
82
173
  inline void connectUnix(const std::string& path) override {
83
174
  auto __result = _swiftPart.connectUnix(path);
84
175
  if (__result.hasError()) [[unlikely]] {
85
176
  std::rethrow_exception(__result.error());
86
177
  }
87
178
  }
179
+ inline void connectUnixTLS(const std::string& path, const std::optional<std::string>& serverName, std::optional<bool> rejectUnauthorized) override {
180
+ auto __result = _swiftPart.connectUnixTLS(path, serverName, rejectUnauthorized);
181
+ if (__result.hasError()) [[unlikely]] {
182
+ std::rethrow_exception(__result.error());
183
+ }
184
+ }
185
+ inline void connectUnixTLSWithContext(const std::string& path, const std::optional<std::string>& serverName, std::optional<bool> rejectUnauthorized, std::optional<double> secureContextId) override {
186
+ auto __result = _swiftPart.connectUnixTLSWithContext(path, serverName, rejectUnauthorized, secureContextId);
187
+ if (__result.hasError()) [[unlikely]] {
188
+ std::rethrow_exception(__result.error());
189
+ }
190
+ }
88
191
  inline void write(const std::shared_ptr<ArrayBuffer>& data) override {
89
192
  auto __result = _swiftPart.write(ArrayBufferHolder(data));
90
193
  if (__result.hasError()) [[unlikely]] {
@@ -127,6 +230,12 @@ namespace margelo::nitro::net {
127
230
  std::rethrow_exception(__result.error());
128
231
  }
129
232
  }
233
+ inline void enableKeylog() override {
234
+ auto __result = _swiftPart.enableKeylog();
235
+ if (__result.hasError()) [[unlikely]] {
236
+ std::rethrow_exception(__result.error());
237
+ }
238
+ }
130
239
  inline void setNoDelay(bool enable) override {
131
240
  auto __result = _swiftPart.setNoDelay(std::forward<decltype(enable)>(enable));
132
241
  if (__result.hasError()) [[unlikely]] {
@@ -16,6 +16,14 @@ public protocol HybridNetDriverSpec_protocol: HybridObject {
16
16
  // Methods
17
17
  func createSocket(id: String?) throws -> (any HybridNetSocketDriverSpec)
18
18
  func createServer() throws -> (any HybridNetServerDriverSpec)
19
+ func createSecureContext(cert: String, key: String, passphrase: String?) throws -> Double
20
+ func createEmptySecureContext() throws -> Double
21
+ func addCACertToSecureContext(scId: Double, ca: String) throws -> Void
22
+ func addContextToSecureContext(scId: Double, hostname: String, cert: String, key: String, passphrase: String?) throws -> Void
23
+ func setPFXToSecureContext(scId: Double, pfx: ArrayBuffer, passphrase: String?) throws -> Void
24
+ func setOCSPResponseToSecureContext(scId: Double, ocsp: ArrayBuffer) throws -> Void
25
+ func getTicketKeys(scId: Double) throws -> ArrayBuffer?
26
+ func setTicketKeys(scId: Double, keys: ArrayBuffer) throws -> Void
19
27
  func initWithConfig(config: NetConfig) throws -> Void
20
28
  }
21
29
 
@@ -154,6 +154,124 @@ open class HybridNetDriverSpec_cxx {
154
154
  }
155
155
  }
156
156
 
157
+ @inline(__always)
158
+ public final func createSecureContext(cert: std.string, key: std.string, passphrase: bridge.std__optional_std__string_) -> bridge.Result_double_ {
159
+ do {
160
+ let __result = try self.__implementation.createSecureContext(cert: String(cert), key: String(key), passphrase: { () -> String? in
161
+ if bridge.has_value_std__optional_std__string_(passphrase) {
162
+ let __unwrapped = bridge.get_std__optional_std__string_(passphrase)
163
+ return String(__unwrapped)
164
+ } else {
165
+ return nil
166
+ }
167
+ }())
168
+ let __resultCpp = __result
169
+ return bridge.create_Result_double_(__resultCpp)
170
+ } catch (let __error) {
171
+ let __exceptionPtr = __error.toCpp()
172
+ return bridge.create_Result_double_(__exceptionPtr)
173
+ }
174
+ }
175
+
176
+ @inline(__always)
177
+ public final func createEmptySecureContext() -> bridge.Result_double_ {
178
+ do {
179
+ let __result = try self.__implementation.createEmptySecureContext()
180
+ let __resultCpp = __result
181
+ return bridge.create_Result_double_(__resultCpp)
182
+ } catch (let __error) {
183
+ let __exceptionPtr = __error.toCpp()
184
+ return bridge.create_Result_double_(__exceptionPtr)
185
+ }
186
+ }
187
+
188
+ @inline(__always)
189
+ public final func addCACertToSecureContext(scId: Double, ca: std.string) -> bridge.Result_void_ {
190
+ do {
191
+ try self.__implementation.addCACertToSecureContext(scId: scId, ca: String(ca))
192
+ return bridge.create_Result_void_()
193
+ } catch (let __error) {
194
+ let __exceptionPtr = __error.toCpp()
195
+ return bridge.create_Result_void_(__exceptionPtr)
196
+ }
197
+ }
198
+
199
+ @inline(__always)
200
+ public final func addContextToSecureContext(scId: Double, hostname: std.string, cert: std.string, key: std.string, passphrase: bridge.std__optional_std__string_) -> bridge.Result_void_ {
201
+ do {
202
+ try self.__implementation.addContextToSecureContext(scId: scId, hostname: String(hostname), cert: String(cert), key: String(key), passphrase: { () -> String? in
203
+ if bridge.has_value_std__optional_std__string_(passphrase) {
204
+ let __unwrapped = bridge.get_std__optional_std__string_(passphrase)
205
+ return String(__unwrapped)
206
+ } else {
207
+ return nil
208
+ }
209
+ }())
210
+ return bridge.create_Result_void_()
211
+ } catch (let __error) {
212
+ let __exceptionPtr = __error.toCpp()
213
+ return bridge.create_Result_void_(__exceptionPtr)
214
+ }
215
+ }
216
+
217
+ @inline(__always)
218
+ public final func setPFXToSecureContext(scId: Double, pfx: ArrayBuffer, passphrase: bridge.std__optional_std__string_) -> bridge.Result_void_ {
219
+ do {
220
+ try self.__implementation.setPFXToSecureContext(scId: scId, pfx: pfx, passphrase: { () -> String? in
221
+ if bridge.has_value_std__optional_std__string_(passphrase) {
222
+ let __unwrapped = bridge.get_std__optional_std__string_(passphrase)
223
+ return String(__unwrapped)
224
+ } else {
225
+ return nil
226
+ }
227
+ }())
228
+ return bridge.create_Result_void_()
229
+ } catch (let __error) {
230
+ let __exceptionPtr = __error.toCpp()
231
+ return bridge.create_Result_void_(__exceptionPtr)
232
+ }
233
+ }
234
+
235
+ @inline(__always)
236
+ public final func setOCSPResponseToSecureContext(scId: Double, ocsp: ArrayBuffer) -> bridge.Result_void_ {
237
+ do {
238
+ try self.__implementation.setOCSPResponseToSecureContext(scId: scId, ocsp: ocsp)
239
+ return bridge.create_Result_void_()
240
+ } catch (let __error) {
241
+ let __exceptionPtr = __error.toCpp()
242
+ return bridge.create_Result_void_(__exceptionPtr)
243
+ }
244
+ }
245
+
246
+ @inline(__always)
247
+ public final func getTicketKeys(scId: Double) -> bridge.Result_std__optional_std__shared_ptr_ArrayBuffer___ {
248
+ do {
249
+ let __result = try self.__implementation.getTicketKeys(scId: scId)
250
+ let __resultCpp = { () -> bridge.std__optional_std__shared_ptr_ArrayBuffer__ in
251
+ if let __unwrappedValue = __result {
252
+ return bridge.create_std__optional_std__shared_ptr_ArrayBuffer__(__unwrappedValue.getArrayBuffer())
253
+ } else {
254
+ return .init()
255
+ }
256
+ }()
257
+ return bridge.create_Result_std__optional_std__shared_ptr_ArrayBuffer___(__resultCpp)
258
+ } catch (let __error) {
259
+ let __exceptionPtr = __error.toCpp()
260
+ return bridge.create_Result_std__optional_std__shared_ptr_ArrayBuffer___(__exceptionPtr)
261
+ }
262
+ }
263
+
264
+ @inline(__always)
265
+ public final func setTicketKeys(scId: Double, keys: ArrayBuffer) -> bridge.Result_void_ {
266
+ do {
267
+ try self.__implementation.setTicketKeys(scId: scId, keys: keys)
268
+ return bridge.create_Result_void_()
269
+ } catch (let __error) {
270
+ let __exceptionPtr = __error.toCpp()
271
+ return bridge.create_Result_void_(__exceptionPtr)
272
+ }
273
+ }
274
+
157
275
  @inline(__always)
158
276
  public final func initWithConfig(config: NetConfig) -> bridge.Result_void_ {
159
277
  do {
@@ -16,6 +16,7 @@ public protocol HybridNetServerDriverSpec_protocol: HybridObject {
16
16
 
17
17
  // Methods
18
18
  func listen(port: Double, backlog: Double?, ipv6Only: Bool?, reusePort: Bool?) throws -> Void
19
+ func listenTLS(port: Double, secureContextId: Double, backlog: Double?, ipv6Only: Bool?, reusePort: Bool?) throws -> Void
19
20
  func listenUnix(path: String, backlog: Double?) throws -> Void
20
21
  func listenHandle(fd: Double, backlog: Double?) throws -> Void
21
22
  func getLocalAddress() throws -> String
@@ -170,6 +170,31 @@ open class HybridNetServerDriverSpec_cxx {
170
170
  }
171
171
  }
172
172
 
173
+ @inline(__always)
174
+ public final func listenTLS(port: Double, secureContextId: Double, backlog: bridge.std__optional_double_, ipv6Only: bridge.std__optional_bool_, reusePort: bridge.std__optional_bool_) -> bridge.Result_void_ {
175
+ do {
176
+ try self.__implementation.listenTLS(port: port, secureContextId: secureContextId, backlog: backlog.value, ipv6Only: { () -> Bool? in
177
+ if bridge.has_value_std__optional_bool_(ipv6Only) {
178
+ let __unwrapped = bridge.get_std__optional_bool_(ipv6Only)
179
+ return __unwrapped
180
+ } else {
181
+ return nil
182
+ }
183
+ }(), reusePort: { () -> Bool? in
184
+ if bridge.has_value_std__optional_bool_(reusePort) {
185
+ let __unwrapped = bridge.get_std__optional_bool_(reusePort)
186
+ return __unwrapped
187
+ } else {
188
+ return nil
189
+ }
190
+ }())
191
+ return bridge.create_Result_void_()
192
+ } catch (let __error) {
193
+ let __exceptionPtr = __error.toCpp()
194
+ return bridge.create_Result_void_(__exceptionPtr)
195
+ }
196
+ }
197
+
173
198
  @inline(__always)
174
199
  public final func listenUnix(path: std.string, backlog: bridge.std__optional_double_) -> bridge.Result_void_ {
175
200
  do {
@@ -16,7 +16,21 @@ public protocol HybridNetSocketDriverSpec_protocol: HybridObject {
16
16
 
17
17
  // Methods
18
18
  func connect(host: String, port: Double) throws -> Void
19
+ func connectTLS(host: String, port: Double, serverName: String?, rejectUnauthorized: Bool?) throws -> Void
20
+ func connectTLSWithContext(host: String, port: Double, serverName: String?, rejectUnauthorized: Bool?, secureContextId: Double?) throws -> Void
21
+ func getAuthorizationError() throws -> String?
22
+ func getProtocol() throws -> String?
23
+ func getCipher() throws -> String?
24
+ func getALPN() throws -> String?
25
+ func getPeerCertificateJSON() throws -> String?
26
+ func getEphemeralKeyInfo() throws -> String?
27
+ func getSharedSigalgs() throws -> String?
28
+ func isSessionReused() throws -> Bool
29
+ func getSession() throws -> ArrayBuffer?
30
+ func setSession(session: ArrayBuffer) throws -> Void
19
31
  func connectUnix(path: String) throws -> Void
32
+ func connectUnixTLS(path: String, serverName: String?, rejectUnauthorized: Bool?) throws -> Void
33
+ func connectUnixTLSWithContext(path: String, serverName: String?, rejectUnauthorized: Bool?, secureContextId: Double?) throws -> Void
20
34
  func write(data: ArrayBuffer) throws -> Void
21
35
  func pause() throws -> Void
22
36
  func resume() throws -> Void
@@ -24,6 +38,7 @@ public protocol HybridNetSocketDriverSpec_protocol: HybridObject {
24
38
  func setTimeout(timeout: Double) throws -> Void
25
39
  func destroy() throws -> Void
26
40
  func resetAndDestroy() throws -> Void
41
+ func enableKeylog() throws -> Void
27
42
  func setNoDelay(enable: Bool) throws -> Void
28
43
  func setKeepAlive(enable: Bool, delay: Double) throws -> Void
29
44
  func getLocalAddress() throws -> String
@@ -152,6 +152,223 @@ open class HybridNetSocketDriverSpec_cxx {
152
152
  }
153
153
  }
154
154
 
155
+ @inline(__always)
156
+ public final func connectTLS(host: std.string, port: Double, serverName: bridge.std__optional_std__string_, rejectUnauthorized: bridge.std__optional_bool_) -> bridge.Result_void_ {
157
+ do {
158
+ try self.__implementation.connectTLS(host: String(host), port: port, serverName: { () -> String? in
159
+ if bridge.has_value_std__optional_std__string_(serverName) {
160
+ let __unwrapped = bridge.get_std__optional_std__string_(serverName)
161
+ return String(__unwrapped)
162
+ } else {
163
+ return nil
164
+ }
165
+ }(), rejectUnauthorized: { () -> Bool? in
166
+ if bridge.has_value_std__optional_bool_(rejectUnauthorized) {
167
+ let __unwrapped = bridge.get_std__optional_bool_(rejectUnauthorized)
168
+ return __unwrapped
169
+ } else {
170
+ return nil
171
+ }
172
+ }())
173
+ return bridge.create_Result_void_()
174
+ } catch (let __error) {
175
+ let __exceptionPtr = __error.toCpp()
176
+ return bridge.create_Result_void_(__exceptionPtr)
177
+ }
178
+ }
179
+
180
+ @inline(__always)
181
+ public final func connectTLSWithContext(host: std.string, port: Double, serverName: bridge.std__optional_std__string_, rejectUnauthorized: bridge.std__optional_bool_, secureContextId: bridge.std__optional_double_) -> bridge.Result_void_ {
182
+ do {
183
+ try self.__implementation.connectTLSWithContext(host: String(host), port: port, serverName: { () -> String? in
184
+ if bridge.has_value_std__optional_std__string_(serverName) {
185
+ let __unwrapped = bridge.get_std__optional_std__string_(serverName)
186
+ return String(__unwrapped)
187
+ } else {
188
+ return nil
189
+ }
190
+ }(), rejectUnauthorized: { () -> Bool? in
191
+ if bridge.has_value_std__optional_bool_(rejectUnauthorized) {
192
+ let __unwrapped = bridge.get_std__optional_bool_(rejectUnauthorized)
193
+ return __unwrapped
194
+ } else {
195
+ return nil
196
+ }
197
+ }(), secureContextId: secureContextId.value)
198
+ return bridge.create_Result_void_()
199
+ } catch (let __error) {
200
+ let __exceptionPtr = __error.toCpp()
201
+ return bridge.create_Result_void_(__exceptionPtr)
202
+ }
203
+ }
204
+
205
+ @inline(__always)
206
+ public final func getAuthorizationError() -> bridge.Result_std__optional_std__string__ {
207
+ do {
208
+ let __result = try self.__implementation.getAuthorizationError()
209
+ let __resultCpp = { () -> bridge.std__optional_std__string_ in
210
+ if let __unwrappedValue = __result {
211
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
212
+ } else {
213
+ return .init()
214
+ }
215
+ }()
216
+ return bridge.create_Result_std__optional_std__string__(__resultCpp)
217
+ } catch (let __error) {
218
+ let __exceptionPtr = __error.toCpp()
219
+ return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
220
+ }
221
+ }
222
+
223
+ @inline(__always)
224
+ public final func getProtocol() -> bridge.Result_std__optional_std__string__ {
225
+ do {
226
+ let __result = try self.__implementation.getProtocol()
227
+ let __resultCpp = { () -> bridge.std__optional_std__string_ in
228
+ if let __unwrappedValue = __result {
229
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
230
+ } else {
231
+ return .init()
232
+ }
233
+ }()
234
+ return bridge.create_Result_std__optional_std__string__(__resultCpp)
235
+ } catch (let __error) {
236
+ let __exceptionPtr = __error.toCpp()
237
+ return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
238
+ }
239
+ }
240
+
241
+ @inline(__always)
242
+ public final func getCipher() -> bridge.Result_std__optional_std__string__ {
243
+ do {
244
+ let __result = try self.__implementation.getCipher()
245
+ let __resultCpp = { () -> bridge.std__optional_std__string_ in
246
+ if let __unwrappedValue = __result {
247
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
248
+ } else {
249
+ return .init()
250
+ }
251
+ }()
252
+ return bridge.create_Result_std__optional_std__string__(__resultCpp)
253
+ } catch (let __error) {
254
+ let __exceptionPtr = __error.toCpp()
255
+ return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
256
+ }
257
+ }
258
+
259
+ @inline(__always)
260
+ public final func getALPN() -> bridge.Result_std__optional_std__string__ {
261
+ do {
262
+ let __result = try self.__implementation.getALPN()
263
+ let __resultCpp = { () -> bridge.std__optional_std__string_ in
264
+ if let __unwrappedValue = __result {
265
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
266
+ } else {
267
+ return .init()
268
+ }
269
+ }()
270
+ return bridge.create_Result_std__optional_std__string__(__resultCpp)
271
+ } catch (let __error) {
272
+ let __exceptionPtr = __error.toCpp()
273
+ return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
274
+ }
275
+ }
276
+
277
+ @inline(__always)
278
+ public final func getPeerCertificateJSON() -> bridge.Result_std__optional_std__string__ {
279
+ do {
280
+ let __result = try self.__implementation.getPeerCertificateJSON()
281
+ let __resultCpp = { () -> bridge.std__optional_std__string_ in
282
+ if let __unwrappedValue = __result {
283
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
284
+ } else {
285
+ return .init()
286
+ }
287
+ }()
288
+ return bridge.create_Result_std__optional_std__string__(__resultCpp)
289
+ } catch (let __error) {
290
+ let __exceptionPtr = __error.toCpp()
291
+ return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
292
+ }
293
+ }
294
+
295
+ @inline(__always)
296
+ public final func getEphemeralKeyInfo() -> bridge.Result_std__optional_std__string__ {
297
+ do {
298
+ let __result = try self.__implementation.getEphemeralKeyInfo()
299
+ let __resultCpp = { () -> bridge.std__optional_std__string_ in
300
+ if let __unwrappedValue = __result {
301
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
302
+ } else {
303
+ return .init()
304
+ }
305
+ }()
306
+ return bridge.create_Result_std__optional_std__string__(__resultCpp)
307
+ } catch (let __error) {
308
+ let __exceptionPtr = __error.toCpp()
309
+ return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
310
+ }
311
+ }
312
+
313
+ @inline(__always)
314
+ public final func getSharedSigalgs() -> bridge.Result_std__optional_std__string__ {
315
+ do {
316
+ let __result = try self.__implementation.getSharedSigalgs()
317
+ let __resultCpp = { () -> bridge.std__optional_std__string_ in
318
+ if let __unwrappedValue = __result {
319
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
320
+ } else {
321
+ return .init()
322
+ }
323
+ }()
324
+ return bridge.create_Result_std__optional_std__string__(__resultCpp)
325
+ } catch (let __error) {
326
+ let __exceptionPtr = __error.toCpp()
327
+ return bridge.create_Result_std__optional_std__string__(__exceptionPtr)
328
+ }
329
+ }
330
+
331
+ @inline(__always)
332
+ public final func isSessionReused() -> bridge.Result_bool_ {
333
+ do {
334
+ let __result = try self.__implementation.isSessionReused()
335
+ let __resultCpp = __result
336
+ return bridge.create_Result_bool_(__resultCpp)
337
+ } catch (let __error) {
338
+ let __exceptionPtr = __error.toCpp()
339
+ return bridge.create_Result_bool_(__exceptionPtr)
340
+ }
341
+ }
342
+
343
+ @inline(__always)
344
+ public final func getSession() -> bridge.Result_std__optional_std__shared_ptr_ArrayBuffer___ {
345
+ do {
346
+ let __result = try self.__implementation.getSession()
347
+ let __resultCpp = { () -> bridge.std__optional_std__shared_ptr_ArrayBuffer__ in
348
+ if let __unwrappedValue = __result {
349
+ return bridge.create_std__optional_std__shared_ptr_ArrayBuffer__(__unwrappedValue.getArrayBuffer())
350
+ } else {
351
+ return .init()
352
+ }
353
+ }()
354
+ return bridge.create_Result_std__optional_std__shared_ptr_ArrayBuffer___(__resultCpp)
355
+ } catch (let __error) {
356
+ let __exceptionPtr = __error.toCpp()
357
+ return bridge.create_Result_std__optional_std__shared_ptr_ArrayBuffer___(__exceptionPtr)
358
+ }
359
+ }
360
+
361
+ @inline(__always)
362
+ public final func setSession(session: ArrayBuffer) -> bridge.Result_void_ {
363
+ do {
364
+ try self.__implementation.setSession(session: session)
365
+ return bridge.create_Result_void_()
366
+ } catch (let __error) {
367
+ let __exceptionPtr = __error.toCpp()
368
+ return bridge.create_Result_void_(__exceptionPtr)
369
+ }
370
+ }
371
+
155
372
  @inline(__always)
156
373
  public final func connectUnix(path: std.string) -> bridge.Result_void_ {
157
374
  do {
@@ -163,6 +380,56 @@ open class HybridNetSocketDriverSpec_cxx {
163
380
  }
164
381
  }
165
382
 
383
+ @inline(__always)
384
+ public final func connectUnixTLS(path: std.string, serverName: bridge.std__optional_std__string_, rejectUnauthorized: bridge.std__optional_bool_) -> bridge.Result_void_ {
385
+ do {
386
+ try self.__implementation.connectUnixTLS(path: String(path), serverName: { () -> String? in
387
+ if bridge.has_value_std__optional_std__string_(serverName) {
388
+ let __unwrapped = bridge.get_std__optional_std__string_(serverName)
389
+ return String(__unwrapped)
390
+ } else {
391
+ return nil
392
+ }
393
+ }(), rejectUnauthorized: { () -> Bool? in
394
+ if bridge.has_value_std__optional_bool_(rejectUnauthorized) {
395
+ let __unwrapped = bridge.get_std__optional_bool_(rejectUnauthorized)
396
+ return __unwrapped
397
+ } else {
398
+ return nil
399
+ }
400
+ }())
401
+ return bridge.create_Result_void_()
402
+ } catch (let __error) {
403
+ let __exceptionPtr = __error.toCpp()
404
+ return bridge.create_Result_void_(__exceptionPtr)
405
+ }
406
+ }
407
+
408
+ @inline(__always)
409
+ public final func connectUnixTLSWithContext(path: std.string, serverName: bridge.std__optional_std__string_, rejectUnauthorized: bridge.std__optional_bool_, secureContextId: bridge.std__optional_double_) -> bridge.Result_void_ {
410
+ do {
411
+ try self.__implementation.connectUnixTLSWithContext(path: String(path), serverName: { () -> String? in
412
+ if bridge.has_value_std__optional_std__string_(serverName) {
413
+ let __unwrapped = bridge.get_std__optional_std__string_(serverName)
414
+ return String(__unwrapped)
415
+ } else {
416
+ return nil
417
+ }
418
+ }(), rejectUnauthorized: { () -> Bool? in
419
+ if bridge.has_value_std__optional_bool_(rejectUnauthorized) {
420
+ let __unwrapped = bridge.get_std__optional_bool_(rejectUnauthorized)
421
+ return __unwrapped
422
+ } else {
423
+ return nil
424
+ }
425
+ }(), secureContextId: secureContextId.value)
426
+ return bridge.create_Result_void_()
427
+ } catch (let __error) {
428
+ let __exceptionPtr = __error.toCpp()
429
+ return bridge.create_Result_void_(__exceptionPtr)
430
+ }
431
+ }
432
+
166
433
  @inline(__always)
167
434
  public final func write(data: ArrayBuffer) -> bridge.Result_void_ {
168
435
  do {
@@ -240,6 +507,17 @@ open class HybridNetSocketDriverSpec_cxx {
240
507
  }
241
508
  }
242
509
 
510
+ @inline(__always)
511
+ public final func enableKeylog() -> bridge.Result_void_ {
512
+ do {
513
+ try self.__implementation.enableKeylog()
514
+ return bridge.create_Result_void_()
515
+ } catch (let __error) {
516
+ let __exceptionPtr = __error.toCpp()
517
+ return bridge.create_Result_void_(__exceptionPtr)
518
+ }
519
+ }
520
+
243
521
  @inline(__always)
244
522
  public final func setNoDelay(enable: Bool) -> bridge.Result_void_ {
245
523
  do {
@@ -16,6 +16,14 @@ namespace margelo::nitro::net {
16
16
  registerHybrids(this, [](Prototype& prototype) {
17
17
  prototype.registerHybridMethod("createSocket", &HybridNetDriverSpec::createSocket);
18
18
  prototype.registerHybridMethod("createServer", &HybridNetDriverSpec::createServer);
19
+ prototype.registerHybridMethod("createSecureContext", &HybridNetDriverSpec::createSecureContext);
20
+ prototype.registerHybridMethod("createEmptySecureContext", &HybridNetDriverSpec::createEmptySecureContext);
21
+ prototype.registerHybridMethod("addCACertToSecureContext", &HybridNetDriverSpec::addCACertToSecureContext);
22
+ prototype.registerHybridMethod("addContextToSecureContext", &HybridNetDriverSpec::addContextToSecureContext);
23
+ prototype.registerHybridMethod("setPFXToSecureContext", &HybridNetDriverSpec::setPFXToSecureContext);
24
+ prototype.registerHybridMethod("setOCSPResponseToSecureContext", &HybridNetDriverSpec::setOCSPResponseToSecureContext);
25
+ prototype.registerHybridMethod("getTicketKeys", &HybridNetDriverSpec::getTicketKeys);
26
+ prototype.registerHybridMethod("setTicketKeys", &HybridNetDriverSpec::setTicketKeys);
19
27
  prototype.registerHybridMethod("initWithConfig", &HybridNetDriverSpec::initWithConfig);
20
28
  });
21
29
  }
@@ -25,6 +25,7 @@ namespace margelo::nitro::net { struct NetConfig; }
25
25
  #include <string>
26
26
  #include <optional>
27
27
  #include "HybridNetServerDriverSpec.hpp"
28
+ #include <NitroModules/ArrayBuffer.hpp>
28
29
  #include "NetConfig.hpp"
29
30
 
30
31
  namespace margelo::nitro::net {
@@ -60,6 +61,14 @@ namespace margelo::nitro::net {
60
61
  // Methods
61
62
  virtual std::shared_ptr<HybridNetSocketDriverSpec> createSocket(const std::optional<std::string>& id) = 0;
62
63
  virtual std::shared_ptr<HybridNetServerDriverSpec> createServer() = 0;
64
+ virtual double createSecureContext(const std::string& cert, const std::string& key, const std::optional<std::string>& passphrase) = 0;
65
+ virtual double createEmptySecureContext() = 0;
66
+ virtual void addCACertToSecureContext(double scId, const std::string& ca) = 0;
67
+ virtual void addContextToSecureContext(double scId, const std::string& hostname, const std::string& cert, const std::string& key, const std::optional<std::string>& passphrase) = 0;
68
+ virtual void setPFXToSecureContext(double scId, const std::shared_ptr<ArrayBuffer>& pfx, const std::optional<std::string>& passphrase) = 0;
69
+ virtual void setOCSPResponseToSecureContext(double scId, const std::shared_ptr<ArrayBuffer>& ocsp) = 0;
70
+ virtual std::optional<std::shared_ptr<ArrayBuffer>> getTicketKeys(double scId) = 0;
71
+ virtual void setTicketKeys(double scId, const std::shared_ptr<ArrayBuffer>& keys) = 0;
63
72
  virtual void initWithConfig(const NetConfig& config) = 0;
64
73
 
65
74
  protected: