Skip to content

Commit 3cf5a1a

Browse files
chore(release): 6.0.0 [skip ci]
# [6.0.0](Rapsssito/react-native-tcp-socket@v5.6.2...v6.0.0) (2022-08-21) ### Features * Add complete server/client TLS support ([Rapsssito#158](Rapsssito#158)) ([3264f44](Rapsssito@3264f44)) ### BREAKING CHANGES * TLS client API now matches NodeJS official tls API.
1 parent 3264f44 commit 3cf5a1a

File tree

8 files changed

+79
-17
lines changed

8 files changed

+79
-17
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# [6.0.0](https://github.com/Rapsssito/react-native-tcp-socket/compare/v5.6.2...v6.0.0) (2022-08-21)
2+
3+
4+
### Features
5+
6+
* Add complete server/client TLS support ([#158](https://github.com/Rapsssito/react-native-tcp-socket/issues/158)) ([3264f44](https://github.com/Rapsssito/react-native-tcp-socket/commit/3264f4455cc0cf04fda643818dc3bed48e2d8f38))
7+
8+
9+
### BREAKING CHANGES
10+
11+
* TLS client API now matches NodeJS official tls API.
12+
113
## [5.6.2](https://github.com/Rapsssito/react-native-tcp-socket/compare/v5.6.1...v5.6.2) (2022-04-26)
214

315

coverage/coverage-final.json

Lines changed: 7 additions & 0 deletions
Large diffs are not rendered by default.

lib/types/Server.d.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ export default class Server extends EventEmitter<ServerEvents, any> {
8888
*/
8989
private _setDisconnected;
9090
/**
91-
* @private
91+
* @protected
92+
* @param {Socket} socket
93+
*/
94+
protected _addConnection(socket: Socket): void;
95+
/**
96+
* @protected
9297
* @param {{ id: number; connection: import('./Socket').NativeConnectionInfo; }} info
9398
* @returns {Socket}
9499
*/
95-
private _buildSocket;
100+
protected _buildSocket(info: {
101+
id: number;
102+
connection: import('./Socket').NativeConnectionInfo;
103+
}): Socket;
96104
}
97105
export type TLSSocket = import("./TLSSocket").default;
98106
export type ServerEvents = {

lib/types/Socket.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
* @property {() => void} drain
3232
* @property {(err: Error) => void} error
3333
* @property {() => void} timeout
34+
* @property {() => void} secureConnect
3435
*
3536
* @extends {EventEmitter<SocketEvents & ReadableEvents, any>}
3637
*/
3738
export default class Socket extends EventEmitter<SocketEvents & ReadableEvents, any> {
38-
/** @private */
39-
private _id;
39+
/** @package */
40+
_id: number;
4041
/** @private */
4142
private _eventEmitter;
4243
/** @type {EventEmitter<'written', any>} @private */
@@ -216,9 +217,9 @@ export default class Socket extends EventEmitter<SocketEvents & ReadableEvents,
216217
_connectListener: import("react-native").EmitterSubscription | undefined;
217218
_writtenListener: import("react-native").EmitterSubscription | undefined;
218219
/**
219-
* @private
220+
* @package
220221
*/
221-
private _unregisterEvents;
222+
_unregisterEvents(): void;
222223
/**
223224
* @private
224225
* @param {string | Buffer | Uint8Array} buffer
@@ -267,6 +268,7 @@ export type SocketEvents = {
267268
drain: () => void;
268269
error: (err: Error) => void;
269270
timeout: () => void;
271+
secureConnect: () => void;
270272
};
271273
import EventEmitter from "eventemitter3";
272274
import { Buffer } from "buffer";

lib/types/TLSServer.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* @typedef {object} TLSServerOptions
3-
* @property {string} cert
4-
* @property {string} key
3+
* @property {any} keystore
54
*
65
* @extends {Server}
76
*/
@@ -23,8 +22,7 @@ export default class TLSServer extends Server {
2322
_secureConnectionListener: import("react-native").EmitterSubscription | undefined;
2423
}
2524
export type TLSServerOptions = {
26-
cert: string;
27-
key: string;
25+
keystore: any;
2826
};
2927
import Server from "./Server";
3028
import TLSSocket from "./TLSSocket";

lib/types/TLSSocket.d.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
/**
2+
* @typedef {object} TLSSocketOptions
3+
* @property {any} [ca]
4+
*
25
* @extends {Socket}
36
*/
47
export default class TLSSocket extends Socket {
58
/**
69
* @param {Socket} socket Any instance of `Socket`.
7-
* @param {object} options Options for the TLS socket.
10+
* @param {TLSSocketOptions} [options] Options for the TLS socket.
811
*/
9-
constructor(socket: Socket, options: object);
12+
constructor(socket: Socket, options?: TLSSocketOptions | undefined);
13+
/** @private */
14+
private _options;
15+
/** @private */
16+
private _socket;
17+
/**
18+
* @private
19+
*/
20+
private _initialize;
21+
/**
22+
* @private
23+
*/
24+
private _startTLS;
1025
}
26+
export type TLSSocketOptions = {
27+
ca?: any;
28+
};
1129
import Socket from "./Socket";

lib/types/index.d.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
declare namespace _default {
2+
export { createConnection as connect };
23
export { createServer };
34
export { createConnection };
5+
export { createTLSServer };
6+
export { connectTLS };
47
export { isIP };
58
export { isIPv4 };
69
export { isIPv6 };
@@ -10,17 +13,31 @@ declare namespace _default {
1013
export { TLSSocket };
1114
}
1215
export default _default;
16+
/**
17+
* @param {import('./Socket').ConnectionOptions} options
18+
* @param {() => void} callback
19+
* @returns {Socket}
20+
*/
21+
declare function createConnection(options: import('./Socket').ConnectionOptions, callback: () => void): Socket;
1322
/**
1423
* @param {(socket: Socket) => void} connectionListener
1524
* @returns {Server}
1625
*/
1726
declare function createServer(connectionListener: (socket: Socket) => void): Server;
1827
/**
19-
* @param {import('./Socket').ConnectionOptions} options
20-
* @param {() => void} callback
21-
* @returns {Socket}
28+
* @param {import('./TLSServer').TLSServerOptions} options
29+
* @param {(socket: TLSSocket) => void} connectionListener
30+
* @returns {TLSServer}
2231
*/
23-
declare function createConnection(options: import('./Socket').ConnectionOptions, callback: () => void): Socket;
32+
declare function createTLSServer(options: import('./TLSServer').TLSServerOptions, connectionListener: (socket: TLSSocket) => void): TLSServer;
33+
/**
34+
* The `callback` function, if specified, will be added as a listener for the `'secureConnect'` event.
35+
*
36+
* @param {import('./TLSSocket').TLSSocketOptions & import('./Socket').ConnectionOptions} options
37+
* @param {() => void} [callback]
38+
* @returns {TLSSocket}
39+
*/
40+
declare function connectTLS(options: import('./TLSSocket').TLSSocketOptions & import('./Socket').ConnectionOptions, callback?: (() => void) | undefined): TLSSocket;
2441
/**
2542
* Tests if input is an IP address. Returns `0` for invalid strings, returns `4` for IP version 4 addresses, and returns `6` for IP version 6 addresses.
2643
*

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-tcp-socket",
33
"title": "React Native Tcp Socket",
4-
"version": "5.6.2",
4+
"version": "6.0.0",
55
"description": "React Native TCP socket API for Android & iOS with SSL/TLS support",
66
"main": "src/index.js",
77
"types": "lib/types/index.d.ts",

0 commit comments

Comments
 (0)