From 07048317cf04d8e8394782ae64c398b7a2cb30d7 Mon Sep 17 00:00:00 2001 From: Vince Ricosti <80467769+vricosti@users.noreply.github.com> Date: Fri, 24 May 2024 16:12:52 +0200 Subject: [PATCH] add missing TLSSocketOptions --- .gitignore | 1 + lib/types/TLSSocket.d.ts | 21 +++++++++++++++++++++ src/TLSSocket.js | 26 ++++++++++++++++---------- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 619e09f..e9fa572 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ android/gradlew.bat node_modules/ npm-debug.log yarn-error.log +.yarn/ # BUCK buck-out/ diff --git a/lib/types/TLSSocket.d.ts b/lib/types/TLSSocket.d.ts index 219d02b..bc1f2b7 100644 --- a/lib/types/TLSSocket.d.ts +++ b/lib/types/TLSSocket.d.ts @@ -1,10 +1,23 @@ /** * @typedef {object} TLSSocketOptions * @property {any} [ca] + * @property {any} [key] + * @property {any} [cert] + * @property {string} [androidKeyStore] + * @property {string} [certAlias] + * @property {string} [keyAlias] + * @property {string[]} [resolvedKeys] * * @extends {Socket} */ export default class TLSSocket extends Socket { + /** + * @private + * Resolves the asset source if necessary and registers the resolved key. + * @param {TLSSocketOptions} options The options object containing the source to be resolved. + * @param {'ca' | 'key' | 'cert'} key The key name being resolved. + */ + private static resolveAssetIfNeeded; /** * @param {Socket} socket Any instance of `Socket`. * @param {TLSSocketOptions} [options] Options for the TLS socket. @@ -22,8 +35,16 @@ export default class TLSSocket extends Socket { * @private */ private _startTLS; + getCertificate(): any; + getPeerCertificate(): any; } export type TLSSocketOptions = { ca?: any; + key?: any; + cert?: any; + androidKeyStore?: string | undefined; + certAlias?: string | undefined; + keyAlias?: string | undefined; + resolvedKeys?: string[] | undefined; }; import Socket from "./Socket"; diff --git a/src/TLSSocket.js b/src/TLSSocket.js index d224d2d..d538638 100644 --- a/src/TLSSocket.js +++ b/src/TLSSocket.js @@ -7,6 +7,12 @@ import Socket from './Socket'; /** * @typedef {object} TLSSocketOptions * @property {any} [ca] + * @property {any} [key] + * @property {any} [cert] + * @property {string} [androidKeyStore] + * @property {string} [certAlias] + * @property {string} [keyAlias] + * @property {string[]} [resolvedKeys] * * @extends {Socket} */ @@ -22,7 +28,7 @@ export default class TLSSocket extends Socket { TLSSocket.resolveAssetIfNeeded(this._options, 'ca'); TLSSocket.resolveAssetIfNeeded(this._options, 'key'); TLSSocket.resolveAssetIfNeeded(this._options, 'cert'); - + /** @private */ this._socket = socket; // @ts-ignore @@ -53,6 +59,13 @@ export default class TLSSocket extends Socket { }); } + /** + * @private + */ + _startTLS() { + Sockets.startTLS(this._id, this._options); + } + getCertificate() { return Sockets.getCertificate(this._id); } @@ -61,18 +74,11 @@ export default class TLSSocket extends Socket { return Sockets.getPeerCertificate(this._id); } - /** - * @private - */ - _startTLS() { - Sockets.startTLS(this._id, this._options); - } - /** * @private * Resolves the asset source if necessary and registers the resolved key. - * @param {object} options The options object containing the source to be resolved. - * @param {string} key The key name being resolved. + * @param {TLSSocketOptions} options The options object containing the source to be resolved. + * @param {'ca' | 'key' | 'cert'} key The key name being resolved. */ static resolveAssetIfNeeded(options, key) { const source = options[key];