Skip to content

Commit

Permalink
chore(release): 6.0.0 [skip ci]
Browse files Browse the repository at this point in the history
# [6.0.0](v5.6.2...v6.0.0) (2022-08-21)

### Features

* Add complete server/client TLS support ([#158](#158)) ([3264f44](3264f44))

### BREAKING CHANGES

* TLS client API now matches NodeJS official tls API.
  • Loading branch information
semantic-release-bot committed Aug 21, 2022
1 parent 3264f44 commit 3cf5a1a
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 17 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,15 @@
# [6.0.0](https://github.com/Rapsssito/react-native-tcp-socket/compare/v5.6.2...v6.0.0) (2022-08-21)


### Features

* 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))


### BREAKING CHANGES

* TLS client API now matches NodeJS official tls API.

## [5.6.2](https://github.com/Rapsssito/react-native-tcp-socket/compare/v5.6.1...v5.6.2) (2022-04-26)


Expand Down
7 changes: 7 additions & 0 deletions coverage/coverage-final.json

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions lib/types/Server.d.ts
Expand Up @@ -88,11 +88,19 @@ export default class Server extends EventEmitter<ServerEvents, any> {
*/
private _setDisconnected;
/**
* @private
* @protected
* @param {Socket} socket
*/
protected _addConnection(socket: Socket): void;
/**
* @protected
* @param {{ id: number; connection: import('./Socket').NativeConnectionInfo; }} info
* @returns {Socket}
*/
private _buildSocket;
protected _buildSocket(info: {
id: number;
connection: import('./Socket').NativeConnectionInfo;
}): Socket;
}
export type TLSSocket = import("./TLSSocket").default;
export type ServerEvents = {
Expand Down
10 changes: 6 additions & 4 deletions lib/types/Socket.d.ts
Expand Up @@ -31,12 +31,13 @@
* @property {() => void} drain
* @property {(err: Error) => void} error
* @property {() => void} timeout
* @property {() => void} secureConnect
*
* @extends {EventEmitter<SocketEvents & ReadableEvents, any>}
*/
export default class Socket extends EventEmitter<SocketEvents & ReadableEvents, any> {
/** @private */
private _id;
/** @package */
_id: number;
/** @private */
private _eventEmitter;
/** @type {EventEmitter<'written', any>} @private */
Expand Down Expand Up @@ -216,9 +217,9 @@ export default class Socket extends EventEmitter<SocketEvents & ReadableEvents,
_connectListener: import("react-native").EmitterSubscription | undefined;
_writtenListener: import("react-native").EmitterSubscription | undefined;
/**
* @private
* @package
*/
private _unregisterEvents;
_unregisterEvents(): void;
/**
* @private
* @param {string | Buffer | Uint8Array} buffer
Expand Down Expand Up @@ -267,6 +268,7 @@ export type SocketEvents = {
drain: () => void;
error: (err: Error) => void;
timeout: () => void;
secureConnect: () => void;
};
import EventEmitter from "eventemitter3";
import { Buffer } from "buffer";
6 changes: 2 additions & 4 deletions lib/types/TLSServer.d.ts
@@ -1,7 +1,6 @@
/**
* @typedef {object} TLSServerOptions
* @property {string} cert
* @property {string} key
* @property {any} keystore
*
* @extends {Server}
*/
Expand All @@ -23,8 +22,7 @@ export default class TLSServer extends Server {
_secureConnectionListener: import("react-native").EmitterSubscription | undefined;
}
export type TLSServerOptions = {
cert: string;
key: string;
keystore: any;
};
import Server from "./Server";
import TLSSocket from "./TLSSocket";
22 changes: 20 additions & 2 deletions lib/types/TLSSocket.d.ts
@@ -1,11 +1,29 @@
/**
* @typedef {object} TLSSocketOptions
* @property {any} [ca]
*
* @extends {Socket}
*/
export default class TLSSocket extends Socket {
/**
* @param {Socket} socket Any instance of `Socket`.
* @param {object} options Options for the TLS socket.
* @param {TLSSocketOptions} [options] Options for the TLS socket.
*/
constructor(socket: Socket, options: object);
constructor(socket: Socket, options?: TLSSocketOptions | undefined);
/** @private */
private _options;
/** @private */
private _socket;
/**
* @private
*/
private _initialize;
/**
* @private
*/
private _startTLS;
}
export type TLSSocketOptions = {
ca?: any;
};
import Socket from "./Socket";
25 changes: 21 additions & 4 deletions lib/types/index.d.ts
@@ -1,6 +1,9 @@
declare namespace _default {
export { createConnection as connect };
export { createServer };
export { createConnection };
export { createTLSServer };
export { connectTLS };
export { isIP };
export { isIPv4 };
export { isIPv6 };
Expand All @@ -10,17 +13,31 @@ declare namespace _default {
export { TLSSocket };
}
export default _default;
/**
* @param {import('./Socket').ConnectionOptions} options
* @param {() => void} callback
* @returns {Socket}
*/
declare function createConnection(options: import('./Socket').ConnectionOptions, callback: () => void): Socket;
/**
* @param {(socket: Socket) => void} connectionListener
* @returns {Server}
*/
declare function createServer(connectionListener: (socket: Socket) => void): Server;
/**
* @param {import('./Socket').ConnectionOptions} options
* @param {() => void} callback
* @returns {Socket}
* @param {import('./TLSServer').TLSServerOptions} options
* @param {(socket: TLSSocket) => void} connectionListener
* @returns {TLSServer}
*/
declare function createConnection(options: import('./Socket').ConnectionOptions, callback: () => void): Socket;
declare function createTLSServer(options: import('./TLSServer').TLSServerOptions, connectionListener: (socket: TLSSocket) => void): TLSServer;
/**
* The `callback` function, if specified, will be added as a listener for the `'secureConnect'` event.
*
* @param {import('./TLSSocket').TLSSocketOptions & import('./Socket').ConnectionOptions} options
* @param {() => void} [callback]
* @returns {TLSSocket}
*/
declare function connectTLS(options: import('./TLSSocket').TLSSocketOptions & import('./Socket').ConnectionOptions, callback?: (() => void) | undefined): TLSSocket;
/**
* 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.
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "react-native-tcp-socket",
"title": "React Native Tcp Socket",
"version": "5.6.2",
"version": "6.0.0",
"description": "React Native TCP socket API for Android & iOS with SSL/TLS support",
"main": "src/index.js",
"types": "lib/types/index.d.ts",
Expand Down

0 comments on commit 3cf5a1a

Please sign in to comment.