Skip to content

Commit d3401bb

Browse files
committed
add hasIdentity to TLSSocket.js
1 parent e2e5907 commit d3401bb

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

ios/TcpSocketClient.m

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,6 @@ - (id)initWithClientId:(NSNumber *)clientID
122122
return self;
123123
}
124124

125-
- (void)dealloc {
126-
if (_clientIdentity) {
127-
CFRelease(_clientIdentity);
128-
_clientIdentity = NULL;
129-
}
130-
if (_peerTrust) {
131-
CFRelease(_peerTrust);
132-
_peerTrust = NULL;
133-
}
134-
}
135-
136125
- (BOOL)connect:(NSString *)host
137126
port:(int)port
138127
withOptions:(NSDictionary *)options

lib/types/TLSSocket.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
* @extends {Socket}
1212
*/
1313
export default class TLSSocket extends Socket {
14+
/**
15+
* Checks if a certificate identity exists in the keychain
16+
* @param {object} options Object containing the identity aliases
17+
* @param {string} [options.androidKeyStore] The android keystore type
18+
* @param {string} [options.certAlias] The certificate alias
19+
* @param {string} [options.keyAlias] The key alias
20+
* @returns {Promise<boolean>} Promise resolving to true if identity exists
21+
*/
22+
static hasIdentity(options?: {
23+
androidKeyStore: string | undefined;
24+
certAlias: string | undefined;
25+
keyAlias: string | undefined;
26+
}): Promise<boolean>;
1427
/**
1528
* @private
1629
* Resolves the asset source if necessary and registers the resolved key.

lib/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ declare namespace _default {
1111
export { Socket };
1212
export { TLSServer };
1313
export { TLSSocket };
14+
export const hasIdentity: typeof import("./TLSSocket").default.hasIdentity;
1415
}
1516
export default _default;
1617
/**

src/TLSSocket.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ export default class TLSSocket extends Socket {
6969
/**
7070
* Checks if a certificate identity exists in the keychain
7171
* @param {object} options Object containing the identity aliases
72+
* @param {string} [options.androidKeyStore] The android keystore type
7273
* @param {string} [options.certAlias] The certificate alias
7374
* @param {string} [options.keyAlias] The key alias
7475
* @returns {Promise<boolean>} Promise resolving to true if identity exists
7576
*/
7677
static hasIdentity(options = {}) {
7778
return Sockets.hasIdentity({
79+
androidKeyStore: options.androidKeyStore,
7880
certAlias: options.certAlias,
79-
keyAlias: options.keyAlias
81+
keyAlias: options.keyAlias,
8082
});
8183
}
8284

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export default {
112112
Socket,
113113
TLSServer,
114114
TLSSocket,
115+
hasIdentity: TLSSocket.hasIdentity,
115116
};
116117

117118
// @ts-ignore
@@ -128,4 +129,5 @@ module.exports = {
128129
Socket,
129130
TLSServer,
130131
TLSSocket,
132+
hasIdentity: TLSSocket.hasIdentity,
131133
};

0 commit comments

Comments
 (0)