auth_provider.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.AuthProvider = exports.AuthContext = void 0;
  4. const error_1 = require("../../error");
  5. /** Context used during authentication */
  6. class AuthContext {
  7. constructor(connection, credentials, options) {
  8. this.connection = connection;
  9. this.credentials = credentials;
  10. this.options = options;
  11. }
  12. }
  13. exports.AuthContext = AuthContext;
  14. class AuthProvider {
  15. /**
  16. * Prepare the handshake document before the initial handshake.
  17. *
  18. * @param handshakeDoc - The document used for the initial handshake on a connection
  19. * @param authContext - Context for authentication flow
  20. */
  21. prepare(handshakeDoc, authContext, callback) {
  22. callback(undefined, handshakeDoc);
  23. }
  24. /**
  25. * Authenticate
  26. *
  27. * @param context - A shared context for authentication flow
  28. * @param callback - The callback to return the result from the authentication
  29. */
  30. auth(context, callback) {
  31. // TODO(NODE-3483): Replace this with MongoMethodOverrideError
  32. callback(new error_1.MongoRuntimeError('`auth` method must be overridden by subclass'));
  33. }
  34. }
  35. exports.AuthProvider = AuthProvider;
  36. //# sourceMappingURL=auth_provider.js.map