Copilot commented on code in PR #468:
URL: 
https://github.com/apache/cassandra-nodejs-driver/pull/468#discussion_r3432039087


##########
lib/auth/dse-plain-text-auth-provider.ts:
##########
@@ -15,98 +15,120 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-const util = require('util');
-const { AuthProvider } = require('./provider');
-const BaseDseAuthenticator = require('./base-dse-authenticator');
-const utils = require('../utils');
+
+import utils from "../utils";
+import BaseDseAuthenticator from './base-dse-authenticator';
+import { Authenticator, AuthProvider } from './provider';
 
 const mechanism = utils.allocBufferFromString('PLAIN');
 const separatorBuffer = utils.allocBufferFromArray([0]);
 const initialServerChallenge = 'PLAIN-START';
 
 /**
- * Creates a new instance of <code>DsePlainTextAuthProvider</code>.
  * @classdesc
  * AuthProvider that provides plain text authenticator instances for clients 
to connect
  * to DSE clusters secured with the DseAuthenticator.
- * @param {String} username The username; cannot be <code>null</code>.
- * @param {String} password The password; cannot be <code>null</code>.
- * @param {String} [authorizationId] The optional authorization ID. Providing 
an authorization ID allows the currently
- * authenticated user to act as a different user (a.k.a. proxy authentication).
  * @extends AuthProvider
  * @alias module:auth~DsePlainTextAuthProvider
  * @example
  * const client = new cassandra.Client({
  *   contactPoints: ['h1', 'h2'],
  *   authProvider: new cassandra.auth.DsePlainTextAuthProvider('user', 
'p@ssword1');
  * });
- * @constructor
  */
-function DsePlainTextAuthProvider(username, password, authorizationId) {
-  if (typeof username !== 'string' || typeof password !== 'string') {
-    // Validate for null and undefined
-    throw new TypeError('Username and password must be a string');
+class DsePlainTextAuthProvider extends AuthProvider {
+  private username: string;
+  private password: string;
+  private authorizationId: string;
+  /**
+   * Creates a new instance of <code>DsePlainTextAuthProvider</code>.
+   * @classdesc
+   * AuthProvider that provides plain text authenticator instances for clients 
to connect
+   * to DSE clusters secured with the DseAuthenticator.
+   * @param {String} username The username; cannot be <code>null</code>.
+   * @param {String} password The password; cannot be <code>null</code>.
+   * @param {String} [authorizationId] The optional authorization ID. 
Providing an authorization ID allows the currently
+   * authenticated user to act as a different user (a.k.a. proxy 
authentication).
+   * @extends AuthProvider
+   * @alias module:auth~DsePlainTextAuthProvider
+   * @example
+   * const client = new cassandra.Client({
+   *   contactPoints: ['h1', 'h2'],
+   *   authProvider: new cassandra.auth.DsePlainTextAuthProvider('user', 
'p@ssword1');
+   * });
+   * @constructor
+   */
+  constructor(username: string, password: string, authorizationId?: string) {
+    super();
+    if (typeof username !== 'string' || typeof password !== 'string') {
+      // Validate for null and undefined
+      throw new TypeError('Username and password must be a string');
+    }
+    this.username = username;
+    this.password = password;
+    this.authorizationId = authorizationId;

Review Comment:
   `authorizationId` is optional in the constructor, but it’s assigned to a 
`string` field and then passed through; keeping it possibly-undefined can cause 
TS type errors and diverges from the previous behavior (which defaulted to 
empty string).



##########
lib/geometry/line-string.ts:
##########
@@ -15,185 +15,191 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-const util = require('util');
-const utils = require('../utils');
-const Geometry = require('./geometry');
-const Point = require('./point');
+import util from "util";
+import utils from "../utils";
+import Geometry from "./geometry";
+import Point from "./point";
 
 /**
- * Creates a new {@link LineString} instance.
  * @classdesc
  * A LineString is a one-dimensional object representing a sequence of points 
and the line segments connecting them.
- * @param {...Point}[point] A sequence of [Point]{@link module:geometry~Point} 
items as arguments.
  * @example
  * new LineString(new Point(10.99, 20.02), new Point(14, 26), new Point(34, 
1.2));
- * @constructor
  * @alias module:geometry~LineString
  * @extends {Geometry}
  */
-function LineString(point) {
-  let points = Array.prototype.slice.call(arguments);
-  if (points.length === 1 && Array.isArray(points) && 
Array.isArray(points[0])) {
-    //The first argument is an array of the points
-    points = points[0];
-  }
-  if (points.length === 1) {
-    throw new TypeError('LineString can be either empty or contain 2 or more 
points');
-  }
+class LineString extends Geometry {
+  /** @internal */
+  points: ReadonlyArray<Point>;
+
   /**
-   * Returns a frozen Array of points that represent the line.
-   * @type {Array.<Point>}
+   * Creates a new {@link LineString} instance.
+   * @param {...Point} points A sequence of {@link Point} items as arguments.
    */
-  this.points = Object.freeze(points);
-}
-
-//noinspection JSCheckFunctionSignatures
-util.inherits(LineString, Geometry);
-
-/**
- * Creates a {@link LineString} instance from
- * a <a href="https://en.wikipedia.org/wiki/Well-known_text";>Well-known Text 
(WKT)</a>
- * representation of a line.
- * @param {Buffer} buffer
- * @returns {LineString}
- */
-LineString.fromBuffer = function (buffer) {
-  if (!buffer || buffer.length < 9) {
-    throw new TypeError('A linestring buffer should contain at least 9 bytes');
-  }
-  const endianness = Geometry.getEndianness(buffer.readInt8(0, true));
-  let offset = 1;
-  if (Geometry.readInt32(buffer, endianness, offset) !== 
Geometry.types.LineString) {
-    throw new TypeError('Binary representation was not a LineString');
-  }
-  offset += 4;
-  const length = Geometry.readInt32(buffer, endianness, offset);
-  offset += 4;
-  if (buffer.length !== offset + length * 16) {
-    throw new TypeError(util.format('Length of the buffer does not match %d 
!== %d', buffer.length, offset + length * 8));
-  }
-  const points = new Array(length);
-  for (let i = 0; i < length; i++) {
-    points[i] = new Point(
-      Geometry.readDouble(buffer, endianness, offset),
-      Geometry.readDouble(buffer, endianness, offset + 8));
-    offset += 16;
-  }
-  //noinspection JSCheckFunctionSignatures
-  return new LineString(points);
-};
-
-/**
- * Creates a {@link LineString} instance from
- * a <a href="https://en.wikipedia.org/wiki/Well-known_text";>Well-known Text 
(WKT)</a>
- * representation of a line.
- * @param {String} textValue
- * @returns {LineString}
- */
-LineString.fromString = function (textValue) {
-  const wktRegex = /^LINESTRING ?\(([-0-9. ,]+)\)+$/g;
-  const matches = wktRegex.exec(textValue);
-  if (!matches || matches.length !== 2) {
-    throw new TypeError('Invalid WKT: ' + textValue);
+  constructor(...points: Point[] | Point[][]) {
+    super();
+    if (points.length === 1 && Array.isArray(points) && 
Array.isArray(points[0])) {
+      //The first argument is an array of the points
+      points = points[0];
+    }
+    if (points.length === 1) {
+      throw new TypeError('LineString can be either empty or contain 2 or more 
points');
+    }
+    /**
+     * Returns a frozen Array of points that represent the line.
+     * @type {Array.<Point>}
+     */
+    this.points = Object.freeze(points as Point[]);
   }
-  const points = LineString.parseSegments(matches[1]);
-  return new LineString(points);
-};
 
-/**
- * Internal method that parses a series of WKT points.
- * @param {String} textValue
- * @returns {Array<Point>}
- * @internal
- * @ignore
- */
-LineString.parseSegments = function (textValue) {
-  const points = [];
-  const pointParts = textValue.split(',');
-  for (let i = 0; i < pointParts.length; i++) {
-    const p = pointParts[i].trim();
-    if (p.length === 0) {
-      throw new TypeError('Invalid WKT segment: ' + textValue);
+  /**
+   * Creates a {@link LineString} instance from
+   * a <a href="https://en.wikipedia.org/wiki/Well-known_text";>Well-known Text 
(WKT)</a>
+   * representation of a line.
+   * @param {Buffer} buffer
+   * @returns {LineString}
+   */
+  static fromBuffer(buffer: Buffer): LineString {
+    if (!buffer || buffer.length < 9) {
+      throw new TypeError('A linestring buffer should contain at least 9 
bytes');
     }
-    const xyText = p.split(' ').filter(function (element) {
-      return (element.trim().length > 0);
-    });
-    if (xyText.length !== 2) {
-      throw new TypeError('Invalid WKT segment: ' + textValue);
+    const endianness = Geometry.getEndianness(buffer.readInt8(0));
+    let offset = 1;
+    if (Geometry.readInt32(buffer, endianness, offset) !== 
Geometry.types.LineString) {
+      throw new TypeError('Binary representation was not a LineString');
+    }
+    offset += 4;
+    const length = Geometry.readInt32(buffer, endianness, offset);
+    offset += 4;
+    if (buffer.length !== offset + length * 16) {
+      throw new TypeError(util.format('Length of the buffer does not match %d 
!== %d', buffer.length, offset + length * 8));

Review Comment:
   The error message calculation uses `offset + length * 8`, but each point is 
16 bytes (2 doubles). This makes the reported expected length inconsistent with 
the validation (`length * 16`) and can mislead debugging.



##########
lib/auth/gssapi-client.ts:
##########
@@ -15,22 +15,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+/* eslint-disable @typescript-eslint/no-unused-vars */
+import util from "util";
+import utils from "../utils";
 
-'use strict';
 
-const util = require('util');
-const utils = require('../utils');
 
 /**
  * GSSAPI Client interface.
  * @ignore
+ * @internal
  */
 class GssapiClient {
+  authorizationId: string;

Review Comment:
   `authorizationId` is optional in `createNew()` and callers pass `undefined`, 
but the instance field is typed as required `string`, which can cause TS type 
errors.



##########
lib/auth/dse-gssapi-auth-provider.ts:
##########
@@ -15,135 +15,151 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-const util = require('util');
-const { AuthProvider } = require('./provider');
-const BaseDseAuthenticator = require('./base-dse-authenticator');
-const GssapiClient = require('./gssapi-client');
-const dns = require('dns');
-const utils = require('../utils');
+
+import dns from "dns";
+import utils from "../utils";
+import BaseDseAuthenticator from './base-dse-authenticator';
+import GssapiClient from './gssapi-client';
+import { Authenticator, AuthProvider } from "./provider";
 
 const mechanism = utils.allocBufferFromString('GSSAPI');
 const initialServerChallenge = 'GSSAPI-START';
 const emptyBuffer = utils.allocBuffer(0);
 
 /**
- * Creates a new instance of <code>DseGssapiAuthProvider</code>.
  * @classdesc
  * AuthProvider that provides GSSAPI authenticator instances for clients to 
connect
  * to DSE clusters secured with the DseAuthenticator.
- * @param {Object} [gssOptions] GSSAPI authenticator options
- * @param {String} [gssOptions.authorizationId] The optional authorization ID. 
Providing an authorization ID allows the
- * currently authenticated user to act as a different user (a.k.a. proxy 
authentication).
- * @param {String} [gssOptions.service] The service to use. Defaults to 'dse'.
- * @param {Function} [gssOptions.hostNameResolver] A method to be used to 
resolve the name of the Cassandra node based
- * on the IP Address.  Defaults to [lookupServiceResolver]{@link 
module:auth~DseGssapiAuthProvider.lookupServiceResolver}
- * which resolves the FQDN of the provided IP to generate principals in the 
format of
- * <code>dse/[email protected]</code>.
- * Alternatively, you can use [reverseDnsResolver]{@link 
module:auth~DseGssapiAuthProvider.reverseDnsResolver} to do a
- * reverse DNS lookup or [useIpResolver]{@link 
module:auth~DseGssapiAuthProvider.useIpResolver} to simply use the IP
- * address provided.
- * @param {String} [gssOptions.user] DEPRECATED, it will be removed in future 
versions. For proxy authentication, use
- * <code>authorizationId</code> instead.
  * @example
  * const client = new cassandra.Client({
  *   contactPoints: ['h1', 'h2'],
  *   authProvider: new cassandra.auth.DseGssapiAuthProvider()
  * });
  * @alias module:auth~DseGssapiAuthProvider
- * @constructor
  */
-function DseGssapiAuthProvider(gssOptions) {
-  //load the kerberos at construction time
-  try {
-    // eslint-disable-next-line
-    this._kerberos = require('kerberos');
-  }
-  catch (err) {
-    if (err.code === 'MODULE_NOT_FOUND') {
-      const newErr = new Error('You must install module "kerberos" to use 
GSSAPI auth provider: ' +
-        'https://www.npmjs.com/package/kerberos');
-      newErr.code = err.code;
-      throw newErr;
+class DseGssapiAuthProvider extends AuthProvider {
+  private _kerberos: any;
+  private authorizationId: string;
+  private service: string;
+  private hostNameResolver: Function;
+
+  /**
+   * Creates a new instance of <code>DseGssapiAuthProvider</code>.
+   * @classdesc
+   * AuthProvider that provides GSSAPI authenticator instances for clients to 
connect
+   * to DSE clusters secured with the DseAuthenticator.
+   * @param {Object} [gssOptions] GSSAPI authenticator options
+   * @param {String} [gssOptions.authorizationId] The optional authorization 
ID. Providing an authorization ID allows the
+   * currently authenticated user to act as a different user (a.k.a. proxy 
authentication).
+   * @param {String} [gssOptions.service] The service to use. Defaults to 
'dse'.
+   * @param {Function} [gssOptions.hostNameResolver] A method to be used to 
resolve the name of the Cassandra node based
+   * on the IP Address.  Defaults to [lookupServiceResolver]{@link 
module:auth~DseGssapiAuthProvider.lookupServiceResolver}
+   * which resolves the FQDN of the provided IP to generate principals in the 
format of
+   * <code>dse/[email protected]</code>.
+   * Alternatively, you can use [reverseDnsResolver]{@link 
module:auth~DseGssapiAuthProvider.reverseDnsResolver} to do a
+   * reverse DNS lookup or [useIpResolver]{@link 
module:auth~DseGssapiAuthProvider.useIpResolver} to simply use the IP
+   * address provided.
+   * @param {String} [gssOptions.user] DEPRECATED, it will be removed in 
future versions. For proxy authentication, use
+   * <code>authorizationId</code> instead.
+   * @example
+   * const client = new cassandra.Client({
+   *   contactPoints: ['h1', 'h2'],
+   *   authProvider: new cassandra.auth.DseGssapiAuthProvider()
+   * });
+   * @alias module:auth~DseGssapiAuthProvider
+   * @constructor
+   */
+  constructor(gssOptions: { authorizationId?: string; service?: string; 
hostNameResolver?: Function; user?: string; }) {

Review Comment:
   The constructor parameter is treated as optional (fallbacking to 
`utils.emptyObject`) and the JSDoc examples call it with no args, but the 
signature currently requires `gssOptions`, which is a TS breaking change.



##########
lib/auth/plain-text-auth-provider.ts:
##########
@@ -15,69 +15,82 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-const util = require('util');
 
-const provider = require('./provider');
-const utils = require('../utils');
-const AuthProvider = provider.AuthProvider;
-const Authenticator = provider.Authenticator;
+import utils from "../utils";
+import { Authenticator, AuthProvider } from './provider';
+
 /**
- * Creates a new instance of the Authenticator provider
  * @classdesc Provides plain text [Authenticator]{@link 
module:auth~Authenticator} instances to be used when
  * connecting to a host.
  * @extends module:auth~AuthProvider
  * @example
  * var authProvider = new cassandra.auth.PlainTextAuthProvider('my_user', 
'p@ssword1!');
  * //Set the auth provider in the clientOptions when creating the Client 
instance
  * const client = new Client({ contactPoints: contactPoints, authProvider: 
authProvider });
- * @param {String} username User name in plain text
- * @param {String} password Password in plain text
  * @alias module:auth~PlainTextAuthProvider
- * @constructor
  */
-function PlainTextAuthProvider(username, password) {
-  this.username = username;
-  this.password = password;
-}
+class PlainTextAuthProvider extends AuthProvider {
+  private username: string;
+  private password: string;
 
-util.inherits(PlainTextAuthProvider, AuthProvider);
+  /**
+   * Creates a new instance of the Authenticator provider
+   * @classdesc Provides plain text [Authenticator]{@link 
module:auth~Authenticator} instances to be used when
+   * connecting to a host.
+   * @example
+   * var authProvider = new cassandra.auth.PlainTextAuthProvider('my_user', 
'p@ssword1!');
+   * //Set the auth provider in the clientOptions when creating the Client 
instance
+   * const client = new Client({ contactPoints: contactPoints, authProvider: 
authProvider });
+   * @param {String} username User name in plain text
+   * @param {String} password Password in plain text
+   * @alias module:auth~PlainTextAuthProvider
+   * @constructor
+   */
+  constructor(username: string, password: string) {
+    super();
+    this.username = username;
+    this.password = password;
+  }
 
-/**
- * Returns a new [Authenticator]{@link module:auth~Authenticator} instance to 
be used for plain text authentication.
- * @override
- * @returns {Authenticator}
- */
-PlainTextAuthProvider.prototype.newAuthenticator = function () {
-  return new PlainTextAuthenticator(this.username, this.password);
-};
+  /**
+   * Returns a new [Authenticator]{@link module:auth~Authenticator} instance 
to be used for plain text authentication.
+   * @override
+   * @returns {Authenticator}
+   */
+  newAuthenticator(): Authenticator {
+    return new PlainTextAuthenticator(this.username, this.password);
+  }
+}
 
 /**
- * @ignore
+ * @ignore @internal
  */
-function PlainTextAuthenticator(username, password) {
-  this.username = username;
-  this.password = password;
-}
-
-util.inherits(PlainTextAuthenticator, Authenticator);
+class PlainTextAuthenticator extends Authenticator {
+  username: any;
+  password: any;
+  constructor(username, password) {
+    super();
+    this.username = username;
+    this.password = password;
+  }
 
-PlainTextAuthenticator.prototype.initialResponse = function (callback) {
-  const initialToken = Buffer.concat([
-    utils.allocBufferFromArray([0]),
-    utils.allocBufferFromString(this.username, 'utf8'),
-    utils.allocBufferFromArray([0]),
-    utils.allocBufferFromString(this.password, 'utf8')
-  ]);
-  callback(null, initialToken);
-};
+  initialResponse(callback) {

Review Comment:
   `initialResponse` should be typed consistently with the base `Authenticator` 
contract to avoid implicit-`any` and improve TS checking.



##########
lib/auth/dse-gssapi-auth-provider.ts:
##########
@@ -15,135 +15,151 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-const util = require('util');
-const { AuthProvider } = require('./provider');
-const BaseDseAuthenticator = require('./base-dse-authenticator');
-const GssapiClient = require('./gssapi-client');
-const dns = require('dns');
-const utils = require('../utils');
+
+import dns from "dns";
+import utils from "../utils";
+import BaseDseAuthenticator from './base-dse-authenticator';
+import GssapiClient from './gssapi-client';
+import { Authenticator, AuthProvider } from "./provider";
 
 const mechanism = utils.allocBufferFromString('GSSAPI');
 const initialServerChallenge = 'GSSAPI-START';
 const emptyBuffer = utils.allocBuffer(0);
 
 /**
- * Creates a new instance of <code>DseGssapiAuthProvider</code>.
  * @classdesc
  * AuthProvider that provides GSSAPI authenticator instances for clients to 
connect
  * to DSE clusters secured with the DseAuthenticator.
- * @param {Object} [gssOptions] GSSAPI authenticator options
- * @param {String} [gssOptions.authorizationId] The optional authorization ID. 
Providing an authorization ID allows the
- * currently authenticated user to act as a different user (a.k.a. proxy 
authentication).
- * @param {String} [gssOptions.service] The service to use. Defaults to 'dse'.
- * @param {Function} [gssOptions.hostNameResolver] A method to be used to 
resolve the name of the Cassandra node based
- * on the IP Address.  Defaults to [lookupServiceResolver]{@link 
module:auth~DseGssapiAuthProvider.lookupServiceResolver}
- * which resolves the FQDN of the provided IP to generate principals in the 
format of
- * <code>dse/[email protected]</code>.
- * Alternatively, you can use [reverseDnsResolver]{@link 
module:auth~DseGssapiAuthProvider.reverseDnsResolver} to do a
- * reverse DNS lookup or [useIpResolver]{@link 
module:auth~DseGssapiAuthProvider.useIpResolver} to simply use the IP
- * address provided.
- * @param {String} [gssOptions.user] DEPRECATED, it will be removed in future 
versions. For proxy authentication, use
- * <code>authorizationId</code> instead.
  * @example
  * const client = new cassandra.Client({
  *   contactPoints: ['h1', 'h2'],
  *   authProvider: new cassandra.auth.DseGssapiAuthProvider()
  * });
  * @alias module:auth~DseGssapiAuthProvider
- * @constructor
  */
-function DseGssapiAuthProvider(gssOptions) {
-  //load the kerberos at construction time
-  try {
-    // eslint-disable-next-line
-    this._kerberos = require('kerberos');
-  }
-  catch (err) {
-    if (err.code === 'MODULE_NOT_FOUND') {
-      const newErr = new Error('You must install module "kerberos" to use 
GSSAPI auth provider: ' +
-        'https://www.npmjs.com/package/kerberos');
-      newErr.code = err.code;
-      throw newErr;
+class DseGssapiAuthProvider extends AuthProvider {
+  private _kerberos: any;
+  private authorizationId: string;
+  private service: string;
+  private hostNameResolver: Function;
+
+  /**
+   * Creates a new instance of <code>DseGssapiAuthProvider</code>.
+   * @classdesc
+   * AuthProvider that provides GSSAPI authenticator instances for clients to 
connect
+   * to DSE clusters secured with the DseAuthenticator.
+   * @param {Object} [gssOptions] GSSAPI authenticator options
+   * @param {String} [gssOptions.authorizationId] The optional authorization 
ID. Providing an authorization ID allows the
+   * currently authenticated user to act as a different user (a.k.a. proxy 
authentication).
+   * @param {String} [gssOptions.service] The service to use. Defaults to 
'dse'.
+   * @param {Function} [gssOptions.hostNameResolver] A method to be used to 
resolve the name of the Cassandra node based
+   * on the IP Address.  Defaults to [lookupServiceResolver]{@link 
module:auth~DseGssapiAuthProvider.lookupServiceResolver}
+   * which resolves the FQDN of the provided IP to generate principals in the 
format of
+   * <code>dse/[email protected]</code>.
+   * Alternatively, you can use [reverseDnsResolver]{@link 
module:auth~DseGssapiAuthProvider.reverseDnsResolver} to do a
+   * reverse DNS lookup or [useIpResolver]{@link 
module:auth~DseGssapiAuthProvider.useIpResolver} to simply use the IP
+   * address provided.
+   * @param {String} [gssOptions.user] DEPRECATED, it will be removed in 
future versions. For proxy authentication, use
+   * <code>authorizationId</code> instead.
+   * @example
+   * const client = new cassandra.Client({
+   *   contactPoints: ['h1', 'h2'],
+   *   authProvider: new cassandra.auth.DseGssapiAuthProvider()
+   * });
+   * @alias module:auth~DseGssapiAuthProvider
+   * @constructor
+   */
+  constructor(gssOptions: { authorizationId?: string; service?: string; 
hostNameResolver?: Function; user?: string; }) {
+    super();
+    // Load the kerberos at construction time
+    try {
+      // eslint-disable-next-line
+      this._kerberos = require('kerberos');
+    } catch (err) {
+      if (err.code === 'MODULE_NOT_FOUND') {
+        const newErr = new Error('You must install module "kerberos" to use 
GSSAPI auth provider: ' +
+          'https://www.npmjs.com/package/kerberos');
+        newErr["code"] = err.code;
+        throw newErr;
+      }
+      throw err;
     }
-    throw err;
+    gssOptions = gssOptions || utils.emptyObject;
+    this.authorizationId = gssOptions.authorizationId || gssOptions.user;
+    this.service = gssOptions.service;
+    this.hostNameResolver = gssOptions.hostNameResolver || 
DseGssapiAuthProvider.lookupServiceResolver;
   }
-  gssOptions = gssOptions || utils.emptyObject;
-  this.authorizationId = gssOptions.authorizationId || gssOptions.user;
-  this.service = gssOptions.service;
-  this.hostNameResolver = gssOptions.hostNameResolver || 
DseGssapiAuthProvider.lookupServiceResolver;
-}
-
-util.inherits(DseGssapiAuthProvider, AuthProvider);
 
-/**
- * Returns an Authenticator instance to be used by the driver when connecting 
to a host.
- * @param {String} endpoint The IP address and port number in the format 
ip:port.
- * @param {String} name Authenticator name.
- * @override
- * @returns {Authenticator}
- */
-DseGssapiAuthProvider.prototype.newAuthenticator = function (endpoint, name) {
-  let address = endpoint;
-  if (endpoint.indexOf(':') > 0) {
-    address = endpoint.split(':')[0];
+  /**
+   * Returns an Authenticator instance to be used by the driver when 
connecting to a host.
+   * @param {String} endpoint The IP address and port number in the format 
ip:port.
+   * @param {String} name Authenticator name.
+   * @override
+   * @returns {Authenticator}
+   */
+  newAuthenticator(endpoint: string, name: string): Authenticator {
+    let address = endpoint;
+    if (endpoint.indexOf(':') > 0) {
+      address = endpoint.split(':')[0];
+    }
+    return new GssapiAuthenticator(
+      this._kerberos, address, name, this.authorizationId, this.service, 
this.hostNameResolver);
   }
-  return new GssapiAuthenticator(
-    this._kerberos, address, name, this.authorizationId, this.service, 
this.hostNameResolver);
-};
 
-/**
- * Performs a lookupService query that resolves an IPv4 or IPv6 address to a 
hostname.  This ultimately makes a
- * <code>getnameinfo()</code> system call which depends on the OS to do 
hostname resolution.
- * <p/>
- * <b>Note:</b> Depends on <code>dns.lookupService</code> which was added in 
0.12.  For older versions falls back on
- * [reverseDnsResolver]{@link 
module:auth~DseGssapiAuthProvider.reverseDnsResolver}.
- *
- * @param {String} ip IP address to resolve.
- * @param {Function} callback The callback function with <code>err</code> and 
<code>hostname</code> arguments.
- */
-DseGssapiAuthProvider.lookupServiceResolver = function (ip, callback) {
-  if (!dns.lookupService) {
-    return DseGssapiAuthProvider.reverseDnsResolver(ip, callback);
-  }
-  dns.lookupService(ip, 0, function (err, hostname) {
-    if (err) {
-      return callback(err);
-    }
-    if (!hostname) {
-      //fallback to ip
-      return callback(null, ip);
+  /**
+   * Performs a lookupService query that resolves an IPv4 or IPv6 address to a 
hostname.  This ultimately makes a
+   * <code>getnameinfo()</code> system call which depends on the OS to do 
hostname resolution.
+   * <p/>
+   * <b>Note:</b> Depends on <code>dns.lookupService</code> which was added in 
0.12.  For older versions falls back on
+   * [reverseDnsResolver]{@link 
module:auth~DseGssapiAuthProvider.reverseDnsResolver}.
+   *
+   * @param {String} ip IP address to resolve.
+   * @param {Function} callback The callback function with <code>err</code> 
and <code>hostname</code> arguments.
+   */
+  private static lookupServiceResolver(ip: string, callback: Function) {

Review Comment:
   `lookupServiceResolver` is referenced in the public JSDoc as a selectable 
resolver, but it’s marked `private static`, which prevents TS consumers from 
using it. It should be public (or at least not `private`) to match the 
documented API.



##########
lib/auth/dse-gssapi-auth-provider.ts:
##########
@@ -153,81 +169,95 @@ DseGssapiAuthProvider.useIpResolver = function (ip, 
callback) {
  * @param {String} service
  * @param {Function} hostNameResolver
  * @extends Authenticator
- * @private
+ * @private @internal
  */
-function GssapiAuthenticator(kerberosModule, address, authenticatorName, 
authorizationId, service, hostNameResolver) {
-  BaseDseAuthenticator.call(this, authenticatorName);
-  this.authorizationId = authorizationId;
-  this.address = address;
-  this.client = GssapiClient.createNew(kerberosModule, authorizationId, 
service);
-  this.hostNameResolver = hostNameResolver;
-}
-
-//noinspection JSCheckFunctionSignatures
-util.inherits(GssapiAuthenticator, BaseDseAuthenticator);
+class GssapiAuthenticator extends BaseDseAuthenticator {
+  authorizationId: any;
+  address: any;
+  client: GssapiClient;
+  hostNameResolver: any;
 
-GssapiAuthenticator.prototype.getMechanism = function () {
-  return mechanism;
-};
+  /**
+   * @param {Object} kerberosModule
+   * @param {String} address Host address.
+   * @param {String} authenticatorName
+   * @param {String} authorizationId
+   * @param {String} service
+   * @param {Function} hostNameResolver
+   * @extends Authenticator
+   * @private
+   */
+  constructor(kerberosModule: object, address: string, authenticatorName: 
string, authorizationId: string, service: string, hostNameResolver: Function) {

Review Comment:
   `authorizationId` and `service` are optional upstream (and passed through 
from `DseGssapiAuthProvider`), but this constructor requires them as `string`. 
This creates TS type errors and doesn’t reflect runtime behavior.



##########
lib/auth/gssapi-client.ts:
##########
@@ -49,15 +52,15 @@ class GssapiClient {
    * @param {Function} callback
    * @abstract
    */
-  evaluateChallenge(challenge, callback) {
+  evaluateChallenge(challenge: Buffer, callback: Function) {
     throw new Error('Not implemented');
   }
 
   /**
    * @abstract
    * @param {Function} [callback]
    */
-  shutdown(callback) {
+  shutdown(callback: Function) {

Review Comment:
   JSDoc indicates `shutdown` callback is optional (`[callback]`), but the 
method signature requires it. This is a TS surface/API mismatch.



##########
lib/auth/dse-gssapi-auth-provider.ts:
##########
@@ -15,135 +15,151 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-const util = require('util');
-const { AuthProvider } = require('./provider');
-const BaseDseAuthenticator = require('./base-dse-authenticator');
-const GssapiClient = require('./gssapi-client');
-const dns = require('dns');
-const utils = require('../utils');
+
+import dns from "dns";
+import utils from "../utils";
+import BaseDseAuthenticator from './base-dse-authenticator';
+import GssapiClient from './gssapi-client';
+import { Authenticator, AuthProvider } from "./provider";
 
 const mechanism = utils.allocBufferFromString('GSSAPI');
 const initialServerChallenge = 'GSSAPI-START';
 const emptyBuffer = utils.allocBuffer(0);
 
 /**
- * Creates a new instance of <code>DseGssapiAuthProvider</code>.
  * @classdesc
  * AuthProvider that provides GSSAPI authenticator instances for clients to 
connect
  * to DSE clusters secured with the DseAuthenticator.
- * @param {Object} [gssOptions] GSSAPI authenticator options
- * @param {String} [gssOptions.authorizationId] The optional authorization ID. 
Providing an authorization ID allows the
- * currently authenticated user to act as a different user (a.k.a. proxy 
authentication).
- * @param {String} [gssOptions.service] The service to use. Defaults to 'dse'.
- * @param {Function} [gssOptions.hostNameResolver] A method to be used to 
resolve the name of the Cassandra node based
- * on the IP Address.  Defaults to [lookupServiceResolver]{@link 
module:auth~DseGssapiAuthProvider.lookupServiceResolver}
- * which resolves the FQDN of the provided IP to generate principals in the 
format of
- * <code>dse/[email protected]</code>.
- * Alternatively, you can use [reverseDnsResolver]{@link 
module:auth~DseGssapiAuthProvider.reverseDnsResolver} to do a
- * reverse DNS lookup or [useIpResolver]{@link 
module:auth~DseGssapiAuthProvider.useIpResolver} to simply use the IP
- * address provided.
- * @param {String} [gssOptions.user] DEPRECATED, it will be removed in future 
versions. For proxy authentication, use
- * <code>authorizationId</code> instead.
  * @example
  * const client = new cassandra.Client({
  *   contactPoints: ['h1', 'h2'],
  *   authProvider: new cassandra.auth.DseGssapiAuthProvider()
  * });
  * @alias module:auth~DseGssapiAuthProvider
- * @constructor
  */
-function DseGssapiAuthProvider(gssOptions) {
-  //load the kerberos at construction time
-  try {
-    // eslint-disable-next-line
-    this._kerberos = require('kerberos');
-  }
-  catch (err) {
-    if (err.code === 'MODULE_NOT_FOUND') {
-      const newErr = new Error('You must install module "kerberos" to use 
GSSAPI auth provider: ' +
-        'https://www.npmjs.com/package/kerberos');
-      newErr.code = err.code;
-      throw newErr;
+class DseGssapiAuthProvider extends AuthProvider {
+  private _kerberos: any;
+  private authorizationId: string;
+  private service: string;

Review Comment:
   `authorizationId` and `service` are assigned from optional `gssOptions` 
fields, so they can be `undefined`; keeping them typed as `string` will cause 
TS type errors and forces callers to pass values that were previously optional.



##########
lib/auth/gssapi-client.ts:
##########
@@ -15,22 +15,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+/* eslint-disable @typescript-eslint/no-unused-vars */
+import util from "util";
+import utils from "../utils";
 
-'use strict';
 
-const util = require('util');
-const utils = require('../utils');
 
 /**
  * GSSAPI Client interface.
  * @ignore
+ * @internal
  */
 class GssapiClient {
+  authorizationId: string;
+  service: string;
   /**
    * @param {String} [authorizationId]
    * @param {String} [service]
    */
-  constructor(authorizationId, service) {
+  constructor(authorizationId: string, service: string) {

Review Comment:
   The constructor is declared with required `authorizationId`/`service`, but 
it’s invoked with optional values via `createNew()`. Making the parameters 
optional matches usage and avoids TS errors.



##########
lib/auth/plain-text-auth-provider.ts:
##########
@@ -15,69 +15,82 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-const util = require('util');
 
-const provider = require('./provider');
-const utils = require('../utils');
-const AuthProvider = provider.AuthProvider;
-const Authenticator = provider.Authenticator;
+import utils from "../utils";
+import { Authenticator, AuthProvider } from './provider';
+
 /**
- * Creates a new instance of the Authenticator provider
  * @classdesc Provides plain text [Authenticator]{@link 
module:auth~Authenticator} instances to be used when
  * connecting to a host.
  * @extends module:auth~AuthProvider
  * @example
  * var authProvider = new cassandra.auth.PlainTextAuthProvider('my_user', 
'p@ssword1!');
  * //Set the auth provider in the clientOptions when creating the Client 
instance
  * const client = new Client({ contactPoints: contactPoints, authProvider: 
authProvider });
- * @param {String} username User name in plain text
- * @param {String} password Password in plain text
  * @alias module:auth~PlainTextAuthProvider
- * @constructor
  */
-function PlainTextAuthProvider(username, password) {
-  this.username = username;
-  this.password = password;
-}
+class PlainTextAuthProvider extends AuthProvider {
+  private username: string;
+  private password: string;
 
-util.inherits(PlainTextAuthProvider, AuthProvider);
+  /**
+   * Creates a new instance of the Authenticator provider
+   * @classdesc Provides plain text [Authenticator]{@link 
module:auth~Authenticator} instances to be used when
+   * connecting to a host.
+   * @example
+   * var authProvider = new cassandra.auth.PlainTextAuthProvider('my_user', 
'p@ssword1!');
+   * //Set the auth provider in the clientOptions when creating the Client 
instance
+   * const client = new Client({ contactPoints: contactPoints, authProvider: 
authProvider });
+   * @param {String} username User name in plain text
+   * @param {String} password Password in plain text
+   * @alias module:auth~PlainTextAuthProvider
+   * @constructor
+   */
+  constructor(username: string, password: string) {
+    super();
+    this.username = username;
+    this.password = password;
+  }
 
-/**
- * Returns a new [Authenticator]{@link module:auth~Authenticator} instance to 
be used for plain text authentication.
- * @override
- * @returns {Authenticator}
- */
-PlainTextAuthProvider.prototype.newAuthenticator = function () {
-  return new PlainTextAuthenticator(this.username, this.password);
-};
+  /**
+   * Returns a new [Authenticator]{@link module:auth~Authenticator} instance 
to be used for plain text authentication.
+   * @override
+   * @returns {Authenticator}
+   */
+  newAuthenticator(): Authenticator {
+    return new PlainTextAuthenticator(this.username, this.password);
+  }
+}
 
 /**
- * @ignore
+ * @ignore @internal
  */
-function PlainTextAuthenticator(username, password) {
-  this.username = username;
-  this.password = password;
-}
-
-util.inherits(PlainTextAuthenticator, Authenticator);
+class PlainTextAuthenticator extends Authenticator {
+  username: any;
+  password: any;
+  constructor(username, password) {
+    super();
+    this.username = username;
+    this.password = password;
+  }
 
-PlainTextAuthenticator.prototype.initialResponse = function (callback) {
-  const initialToken = Buffer.concat([
-    utils.allocBufferFromArray([0]),
-    utils.allocBufferFromString(this.username, 'utf8'),
-    utils.allocBufferFromArray([0]),
-    utils.allocBufferFromString(this.password, 'utf8')
-  ]);
-  callback(null, initialToken);
-};
+  initialResponse(callback) {
+    const initialToken = Buffer.concat([
+      utils.allocBufferFromArray([0]),
+      utils.allocBufferFromString(this.username, 'utf8'),
+      utils.allocBufferFromArray([0]),
+      utils.allocBufferFromString(this.password, 'utf8')
+    ]);
+    callback(null, initialToken);
+  }
 
-PlainTextAuthenticator.prototype.evaluateChallenge = function (challenge, 
callback) {
-  //noop
-  callback();
-};
+  evaluateChallenge(challenge, callback) {

Review Comment:
   `challenge` is a `Buffer` per the base contract; typing it avoids 
implicit-`any` and helps catch incorrect calls.



##########
lib/auth/plain-text-auth-provider.ts:
##########
@@ -15,69 +15,82 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-const util = require('util');
 
-const provider = require('./provider');
-const utils = require('../utils');
-const AuthProvider = provider.AuthProvider;
-const Authenticator = provider.Authenticator;
+import utils from "../utils";
+import { Authenticator, AuthProvider } from './provider';
+
 /**
- * Creates a new instance of the Authenticator provider
  * @classdesc Provides plain text [Authenticator]{@link 
module:auth~Authenticator} instances to be used when
  * connecting to a host.
  * @extends module:auth~AuthProvider
  * @example
  * var authProvider = new cassandra.auth.PlainTextAuthProvider('my_user', 
'p@ssword1!');
  * //Set the auth provider in the clientOptions when creating the Client 
instance
  * const client = new Client({ contactPoints: contactPoints, authProvider: 
authProvider });
- * @param {String} username User name in plain text
- * @param {String} password Password in plain text
  * @alias module:auth~PlainTextAuthProvider
- * @constructor
  */
-function PlainTextAuthProvider(username, password) {
-  this.username = username;
-  this.password = password;
-}
+class PlainTextAuthProvider extends AuthProvider {
+  private username: string;
+  private password: string;
 
-util.inherits(PlainTextAuthProvider, AuthProvider);
+  /**
+   * Creates a new instance of the Authenticator provider
+   * @classdesc Provides plain text [Authenticator]{@link 
module:auth~Authenticator} instances to be used when
+   * connecting to a host.
+   * @example
+   * var authProvider = new cassandra.auth.PlainTextAuthProvider('my_user', 
'p@ssword1!');
+   * //Set the auth provider in the clientOptions when creating the Client 
instance
+   * const client = new Client({ contactPoints: contactPoints, authProvider: 
authProvider });
+   * @param {String} username User name in plain text
+   * @param {String} password Password in plain text
+   * @alias module:auth~PlainTextAuthProvider
+   * @constructor
+   */
+  constructor(username: string, password: string) {
+    super();
+    this.username = username;
+    this.password = password;
+  }
 
-/**
- * Returns a new [Authenticator]{@link module:auth~Authenticator} instance to 
be used for plain text authentication.
- * @override
- * @returns {Authenticator}
- */
-PlainTextAuthProvider.prototype.newAuthenticator = function () {
-  return new PlainTextAuthenticator(this.username, this.password);
-};
+  /**
+   * Returns a new [Authenticator]{@link module:auth~Authenticator} instance 
to be used for plain text authentication.
+   * @override
+   * @returns {Authenticator}
+   */
+  newAuthenticator(): Authenticator {
+    return new PlainTextAuthenticator(this.username, this.password);
+  }
+}
 
 /**
- * @ignore
+ * @ignore @internal
  */
-function PlainTextAuthenticator(username, password) {
-  this.username = username;
-  this.password = password;
-}
-
-util.inherits(PlainTextAuthenticator, Authenticator);
+class PlainTextAuthenticator extends Authenticator {
+  username: any;
+  password: any;
+  constructor(username, password) {
+    super();
+    this.username = username;
+    this.password = password;
+  }

Review Comment:
   `PlainTextAuthenticator` stores username/password and immediately treats 
them as strings. Using `any` (and untyped constructor params) weakens 
type-safety and can hide incorrect usage during the TS migration.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to