Skip to content

Commit

Permalink
add missing TLSSocketOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
vricosti committed May 28, 2024
1 parent b3698e4 commit 0704831
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ android/gradlew.bat
node_modules/
npm-debug.log
yarn-error.log
.yarn/

# BUCK
buck-out/
Expand Down
21 changes: 21 additions & 0 deletions lib/types/TLSSocket.d.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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";
26 changes: 16 additions & 10 deletions src/TLSSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand All @@ -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
Expand Down Expand Up @@ -53,6 +59,13 @@ export default class TLSSocket extends Socket {
});
}

/**
* @private
*/
_startTLS() {
Sockets.startTLS(this._id, this._options);
}

getCertificate() {
return Sockets.getCertificate(this._id);
}
Expand All @@ -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];
Expand Down

0 comments on commit 0704831

Please sign in to comment.