react-native-nitro-net 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Driver.d.ts +1 -0
- package/lib/Driver.d.ts.map +1 -0
- package/lib/Driver.js +2 -5
- package/lib/Net.nitro.d.ts +1 -0
- package/lib/Net.nitro.d.ts.map +1 -0
- package/lib/Net.nitro.js +4 -7
- package/lib/http.d.ts +2 -1
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +41 -53
- package/lib/https.d.ts +1 -0
- package/lib/https.d.ts.map +1 -0
- package/lib/https.js +11 -53
- package/lib/index.d.ts +41 -198
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -928
- package/lib/net.d.ts +197 -0
- package/lib/net.d.ts.map +1 -0
- package/lib/net.js +875 -0
- package/lib/tls.d.ts +2 -1
- package/lib/tls.d.ts.map +1 -0
- package/lib/tls.js +35 -51
- package/package.json +7 -5
- package/src/http.ts +3 -4
- package/src/https.ts +0 -2
- package/src/index.ts +13 -1005
- package/src/net.ts +1005 -0
- package/src/tls.ts +1 -1
package/lib/tls.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Socket, Server as NetServer, SocketOptions } from './
|
|
1
|
+
import { Socket, Server as NetServer, SocketOptions } from './net';
|
|
2
2
|
export interface PeerCertificate {
|
|
3
3
|
subject: {
|
|
4
4
|
[key: string]: string;
|
|
@@ -143,3 +143,4 @@ export declare function parseCertString(certString: string): {
|
|
|
143
143
|
* Mock implementation of convertTLSV1CertToPEM.
|
|
144
144
|
*/
|
|
145
145
|
export declare function convertTLSV1CertToPEM(cert: string | Buffer): string;
|
|
146
|
+
//# sourceMappingURL=tls.d.ts.map
|
package/lib/tls.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tls.d.ts","sourceRoot":"","sources":["../src/tls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EA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AE,QAAQ,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,OAAO,GAAG,UAAU,CAEnJ;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAQ7E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAInE"}
|
package/lib/tls.js
CHANGED
|
@@ -1,71 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SecurePair = exports.CryptoStream = exports.Server = exports.TLSSocket = exports.SecureContext = exports.SLAB_BUFFER_SIZE = exports.DEFAULT_ECDH_CURVE = exports.rootCertificates = exports.DEFAULT_MAX_VERSION = exports.DEFAULT_MIN_VERSION = void 0;
|
|
4
|
-
exports.createSecureContext = createSecureContext;
|
|
5
|
-
exports.connect = connect;
|
|
6
|
-
exports.createServer = createServer;
|
|
7
|
-
exports.getCiphers = getCiphers;
|
|
8
|
-
exports.checkServerIdentity = checkServerIdentity;
|
|
9
|
-
exports.createSecurePair = createSecurePair;
|
|
10
|
-
exports.parseCertString = parseCertString;
|
|
11
|
-
exports.convertTLSV1CertToPEM = convertTLSV1CertToPEM;
|
|
12
|
-
const index_1 = require("./index");
|
|
13
|
-
const Driver_1 = require("./Driver");
|
|
1
|
+
import { Socket, Server as NetServer, isVerbose } from './net';
|
|
2
|
+
import { Driver } from './Driver';
|
|
14
3
|
function debugLog(message) {
|
|
15
|
-
if (
|
|
4
|
+
if (isVerbose()) {
|
|
16
5
|
const timestamp = new Date().toISOString().split('T')[1].split('Z')[0];
|
|
17
6
|
console.log(`[NET DEBUG ${timestamp}] ${message}`);
|
|
18
7
|
}
|
|
19
8
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class SecureContext {
|
|
9
|
+
export const DEFAULT_MIN_VERSION = 'TLSv1.2';
|
|
10
|
+
export const DEFAULT_MAX_VERSION = 'TLSv1.3';
|
|
11
|
+
export const rootCertificates = [];
|
|
12
|
+
export const DEFAULT_ECDH_CURVE = 'auto'; // Managed by rustls
|
|
13
|
+
export const SLAB_BUFFER_SIZE = 10 * 1024 * 1024; // 10MB default
|
|
14
|
+
export class SecureContext {
|
|
26
15
|
constructor(options) {
|
|
27
16
|
if (options && options.pfx) {
|
|
28
|
-
this._id =
|
|
17
|
+
this._id = Driver.createEmptySecureContext();
|
|
29
18
|
const pfx = typeof options.pfx === 'string' ? Buffer.from(options.pfx).buffer : options.pfx;
|
|
30
|
-
|
|
19
|
+
Driver.setPFXToSecureContext(this._id, pfx, options.passphrase);
|
|
31
20
|
}
|
|
32
21
|
else if (options && options.cert && options.key) {
|
|
33
22
|
const cert = Array.isArray(options.cert) ? options.cert[0] : options.cert;
|
|
34
23
|
const key = Array.isArray(options.key) ? options.key[0] : options.key;
|
|
35
|
-
this._id =
|
|
24
|
+
this._id = Driver.createSecureContext(cert, key, options.passphrase);
|
|
36
25
|
}
|
|
37
26
|
else {
|
|
38
|
-
this._id =
|
|
27
|
+
this._id = Driver.createEmptySecureContext();
|
|
39
28
|
}
|
|
40
29
|
if (options && options.ca) {
|
|
41
30
|
const cas = Array.isArray(options.ca) ? options.ca : [options.ca];
|
|
42
31
|
for (const ca of cas) {
|
|
43
|
-
|
|
32
|
+
Driver.addCACertToSecureContext(this._id, ca);
|
|
44
33
|
}
|
|
45
34
|
}
|
|
46
35
|
}
|
|
47
36
|
setOCSPResponse(ocsp) {
|
|
48
|
-
|
|
37
|
+
Driver.setOCSPResponseToSecureContext(this._id, ocsp);
|
|
49
38
|
}
|
|
50
39
|
getTicketKeys() {
|
|
51
|
-
return
|
|
40
|
+
return Driver.getTicketKeys(this._id);
|
|
52
41
|
}
|
|
53
42
|
setTicketKeys(keys) {
|
|
54
|
-
|
|
43
|
+
Driver.setTicketKeys(this._id, keys);
|
|
55
44
|
}
|
|
56
45
|
get id() {
|
|
57
46
|
return this._id;
|
|
58
47
|
}
|
|
59
48
|
// Node.js doesn't have these on SecureContext but we might need them
|
|
60
49
|
addCACert(ca) {
|
|
61
|
-
|
|
50
|
+
Driver.addCACertToSecureContext(this._id, ca);
|
|
62
51
|
}
|
|
63
52
|
}
|
|
64
|
-
|
|
65
|
-
function createSecureContext(options) {
|
|
53
|
+
export function createSecureContext(options) {
|
|
66
54
|
return new SecureContext(options);
|
|
67
55
|
}
|
|
68
|
-
class TLSSocket extends
|
|
56
|
+
export class TLSSocket extends Socket {
|
|
69
57
|
get encrypted() {
|
|
70
58
|
return true;
|
|
71
59
|
}
|
|
@@ -181,14 +169,14 @@ class TLSSocket extends index_1.Socket {
|
|
|
181
169
|
}
|
|
182
170
|
constructor(socketOrOptions, options) {
|
|
183
171
|
let opts = {};
|
|
184
|
-
if (socketOrOptions instanceof
|
|
172
|
+
if (socketOrOptions instanceof Socket) {
|
|
185
173
|
opts = { ...options, socketDriver: socketOrOptions._driver };
|
|
186
174
|
}
|
|
187
175
|
else {
|
|
188
176
|
opts = socketOrOptions || {};
|
|
189
177
|
}
|
|
190
178
|
super(opts);
|
|
191
|
-
if (socketOrOptions instanceof
|
|
179
|
+
if (socketOrOptions instanceof Socket) {
|
|
192
180
|
this._servername = socketOrOptions._servername;
|
|
193
181
|
}
|
|
194
182
|
this.on('event', (event, data) => {
|
|
@@ -272,8 +260,7 @@ class TLSSocket extends index_1.Socket {
|
|
|
272
260
|
return this;
|
|
273
261
|
}
|
|
274
262
|
}
|
|
275
|
-
|
|
276
|
-
function connect(...args) {
|
|
263
|
+
export function connect(...args) {
|
|
277
264
|
let port;
|
|
278
265
|
let host = 'localhost';
|
|
279
266
|
let options = {};
|
|
@@ -307,7 +294,7 @@ function connect(...args) {
|
|
|
307
294
|
}, listener);
|
|
308
295
|
return socket;
|
|
309
296
|
}
|
|
310
|
-
class Server extends
|
|
297
|
+
export class Server extends NetServer {
|
|
311
298
|
constructor(options, connectionListener) {
|
|
312
299
|
super(options);
|
|
313
300
|
this._secureContextId = 0;
|
|
@@ -343,18 +330,18 @@ class Server extends index_1.Server {
|
|
|
343
330
|
if (!this._secureContextId) {
|
|
344
331
|
throw new Error("Cannot addContext to a non-TLS server. Provide initial cert/key in constructor.");
|
|
345
332
|
}
|
|
346
|
-
|
|
333
|
+
Driver.addContextToSecureContext(this._secureContextId, hostname, context.cert, context.key);
|
|
347
334
|
}
|
|
348
335
|
setSecureContext(options) {
|
|
349
336
|
this._secureContextId = createSecureContext(options).id;
|
|
350
337
|
}
|
|
351
338
|
getTicketKeys() {
|
|
352
|
-
return this._secureContextId ?
|
|
339
|
+
return this._secureContextId ? Driver.getTicketKeys(this._secureContextId) : undefined;
|
|
353
340
|
}
|
|
354
341
|
setTicketKeys(keys) {
|
|
355
342
|
if (!this._secureContextId)
|
|
356
343
|
throw new Error("Not a TLS server");
|
|
357
|
-
|
|
344
|
+
Driver.setTicketKeys(this._secureContextId, keys);
|
|
358
345
|
}
|
|
359
346
|
listen(port, host, backlog, callback) {
|
|
360
347
|
if (!this._secureContextId) {
|
|
@@ -415,11 +402,10 @@ class Server extends index_1.Server {
|
|
|
415
402
|
return this;
|
|
416
403
|
}
|
|
417
404
|
}
|
|
418
|
-
|
|
419
|
-
function createServer(options, connectionListener) {
|
|
405
|
+
export function createServer(options, connectionListener) {
|
|
420
406
|
return new Server(options, connectionListener);
|
|
421
407
|
}
|
|
422
|
-
function getCiphers() {
|
|
408
|
+
export function getCiphers() {
|
|
423
409
|
return [
|
|
424
410
|
'TLS_AES_128_GCM_SHA256',
|
|
425
411
|
'TLS_AES_256_GCM_SHA384',
|
|
@@ -432,7 +418,7 @@ function getCiphers() {
|
|
|
432
418
|
'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256'
|
|
433
419
|
];
|
|
434
420
|
}
|
|
435
|
-
function checkServerIdentity(hostname, cert) {
|
|
421
|
+
export function checkServerIdentity(hostname, cert) {
|
|
436
422
|
const subject = cert.subject;
|
|
437
423
|
const dnsNames = [];
|
|
438
424
|
// In a real implementation we'd extract SANs from the cert object if available.
|
|
@@ -478,29 +464,27 @@ function checkServerIdentity(hostname, cert) {
|
|
|
478
464
|
* Legacy CryptoStream for Node.js compatibility.
|
|
479
465
|
* In this implementation, it's a simple wrapper around TLSSocket.
|
|
480
466
|
*/
|
|
481
|
-
class CryptoStream extends TLSSocket {
|
|
467
|
+
export class CryptoStream extends TLSSocket {
|
|
482
468
|
constructor(options) {
|
|
483
469
|
super(options || {});
|
|
484
470
|
}
|
|
485
471
|
}
|
|
486
|
-
exports.CryptoStream = CryptoStream;
|
|
487
472
|
/**
|
|
488
473
|
* Legacy SecurePair for Node.js compatibility.
|
|
489
474
|
*/
|
|
490
|
-
class SecurePair {
|
|
475
|
+
export class SecurePair {
|
|
491
476
|
constructor(secureContext, isServer, requestCert, rejectUnauthorized) {
|
|
492
477
|
this.cleartext = new CryptoStream();
|
|
493
478
|
this.encrypted = this.cleartext; // Logically the same in our simplified model
|
|
494
479
|
}
|
|
495
480
|
}
|
|
496
|
-
|
|
497
|
-
function createSecurePair(secureContext, isServer, requestCert, rejectUnauthorized) {
|
|
481
|
+
export function createSecurePair(secureContext, isServer, requestCert, rejectUnauthorized) {
|
|
498
482
|
return new SecurePair(secureContext, isServer, requestCert, rejectUnauthorized);
|
|
499
483
|
}
|
|
500
484
|
/**
|
|
501
485
|
* Legacy certificate string parser.
|
|
502
486
|
*/
|
|
503
|
-
function parseCertString(certString) {
|
|
487
|
+
export function parseCertString(certString) {
|
|
504
488
|
const out = {};
|
|
505
489
|
const parts = certString.split('/');
|
|
506
490
|
for (const part of parts) {
|
|
@@ -513,7 +497,7 @@ function parseCertString(certString) {
|
|
|
513
497
|
/**
|
|
514
498
|
* Mock implementation of convertTLSV1CertToPEM.
|
|
515
499
|
*/
|
|
516
|
-
function convertTLSV1CertToPEM(cert) {
|
|
500
|
+
export function convertTLSV1CertToPEM(cert) {
|
|
517
501
|
if (typeof cert === 'string' && cert.includes('BEGIN CERTIFICATE'))
|
|
518
502
|
return cert;
|
|
519
503
|
const body = (cert instanceof Buffer) ? cert.toString('base64') : Buffer.from(cert).toString('base64');
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-net",
|
|
3
3
|
"description": "Ultra-high-performance networking to React Native by combining a memory-safe Rust core with the zero-overhead Nitro Modules JSI bridge. Provides Node.js-compatible net, tls, http(s) API.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.1",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "./lib/index.js",
|
|
6
7
|
"module": "./lib/index.js",
|
|
7
8
|
"types": "./lib/index.d.ts",
|
|
@@ -28,13 +29,14 @@
|
|
|
28
29
|
"one": "yarn copy-clib && yarn build && yarn pack",
|
|
29
30
|
"build": "npx nitrogen@0.32.0 && tsc",
|
|
30
31
|
"prepare": "npm run build",
|
|
31
|
-
"copy-clib": "
|
|
32
|
-
"copy-clib-android": "cp ../rust_c_net/target/aarch64-linux-android/release/librust_c_net.so android/libs/arm64-v8a/ && cp ../rust_c_net/target/armv7-linux-androideabi/release/librust_c_net.so android/libs/armeabi-v7a/ && cp ../rust_c_net/target/i686-linux-android/release/librust_c_net.so android/libs/x86/ && cp ../rust_c_net/target/x86_64-linux-android/release/librust_c_net.so android/libs/x86_64/ && cp ../rust_c_net/include/NetBindings.hpp cpp/",
|
|
33
|
-
"copy-clib-ios": "rm -rf ios/Frameworks/RustCNet.xcframework && cp -R ../rust_c_net/target/xcframework/RustCNet.xcframework ios/Frameworks/"
|
|
32
|
+
"copy-clib": "npm run copy-clib-android && npm run copy-clib-ios && npm run copy-clib-mac",
|
|
33
|
+
"copy-clib-android": "mkdir -p android/libs/arm64-v8a android/libs/armeabi-v7a android/libs/x86 android/libs/x86_64 && cp ../rust_c_net/target/aarch64-linux-android/release/librust_c_net.so android/libs/arm64-v8a/ && cp ../rust_c_net/target/armv7-linux-androideabi/release/librust_c_net.so android/libs/armeabi-v7a/ && cp ../rust_c_net/target/i686-linux-android/release/librust_c_net.so android/libs/x86/ && cp ../rust_c_net/target/x86_64-linux-android/release/librust_c_net.so android/libs/x86_64/ && cp ../rust_c_net/include/NetBindings.hpp cpp/",
|
|
34
|
+
"copy-clib-ios": "rm -rf ios/Frameworks/RustCNet.xcframework && cp -R ../rust_c_net/target/xcframework/RustCNet.xcframework ios/Frameworks/",
|
|
35
|
+
"copy-clib-mac": "mkdir -p mac && cp ../rust_c_net/target/release/librust_c_net.a mac/ && cp ../rust_c_net/include/NetBindings.hpp cpp/"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
38
|
"eventemitter3": "^5.0.1",
|
|
37
|
-
"react-native-nitro-buffer": "
|
|
39
|
+
"react-native-nitro-buffer": "~0.0.14",
|
|
38
40
|
"readable-stream": "^4.7.0"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
package/src/http.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Writable, Readable } from 'readable-stream'
|
|
2
2
|
import { EventEmitter } from 'eventemitter3'
|
|
3
3
|
import { Driver } from './Driver'
|
|
4
|
-
import { Socket, isVerbose } from './
|
|
4
|
+
import { Socket, isVerbose } from './net'
|
|
5
5
|
import { TLSSocket } from './tls'
|
|
6
6
|
import { Buffer } from 'react-native-nitro-buffer'
|
|
7
|
-
import type { HttpParser } from './Net.nitro'
|
|
8
7
|
|
|
9
8
|
function debugLog(message: string) {
|
|
10
9
|
if (isVerbose()) {
|
|
@@ -418,7 +417,7 @@ export class Server extends EventEmitter {
|
|
|
418
417
|
constructor(options?: ServerOptions | ((req: IncomingMessage, res: ServerResponse) => void), requestListener?: (req: IncomingMessage, res: ServerResponse) => void) {
|
|
419
418
|
super();
|
|
420
419
|
// Use net.Server from index.ts
|
|
421
|
-
const { Server: NetServer } = require('./
|
|
420
|
+
const { Server: NetServer } = require('./net');
|
|
422
421
|
this._netServer = new NetServer();
|
|
423
422
|
|
|
424
423
|
let listener: ((req: IncomingMessage, res: ServerResponse) => void) | undefined;
|