Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._isOpened = false;
this._transport = null;
this._lastRequestId = 0;
this.parent = options.parent;
this.clientNonce = null; // will be created when needed
this.protocolVersion = 0;
this.messageChunker = new MessageChunker({
derivedKeys: null
});
this.defaultSecureTokenLifetime = options.defaultSecureTokenLifetime || 30000;
this.tokenRenewalInterval = options.tokenRenewalInterval || 0;
this.securityMode = coerceMessageSecurityMode(options.securityMode);
this.securityPolicy = coerceSecurityPolicy(options.securityPolicy);
this.serverCertificate = options.serverCertificate ? options.serverCertificate : null;
if (this.securityMode !== MessageSecurityMode.None) {
assert(this.serverCertificate as any instanceof Buffer,
"Expecting a valid certificate when security mode is not None");
assert(this.securityPolicy !== SecurityPolicy.None,
"Security Policy None is not a valid choice");
}
this.messageBuilder = new MessageBuilder({
name: "client",
privateKey: this.getPrivateKey() || undefined,
securityMode: this.securityMode
public setSecurity(securityMode: MessageSecurityMode, securityPolicy: SecurityPolicy) {
assert(this.securityMode === MessageSecurityMode.Invalid, "security already set");
this.securityPolicy = coerceSecurityPolicy(securityPolicy);
this.securityMode = coerceMessageSecurityMode(securityMode);
assert(this.securityPolicy !== SecurityPolicy.Invalid);
assert(this.securityMode !== MessageSecurityMode.Invalid);
}