index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. export class AuthenticationLoader {
  11. constructor() {
  12. this.handlers = [];
  13. }
  14. addAuthenticationHandler(authenticationHandler) {
  15. this.handlers.push(authenticationHandler);
  16. }
  17. tryLogin(username, password, totpCode) {
  18. return __awaiter(this, void 0, void 0, function* () {
  19. for (let i of this.handlers) {
  20. const result = yield i.tryLogin(username, password, totpCode);
  21. if (result !== null)
  22. return result;
  23. }
  24. return false;
  25. });
  26. }
  27. needTotp(username) {
  28. return __awaiter(this, void 0, void 0, function* () {
  29. for (let i of this.handlers) {
  30. const result = yield i.needTotp(username);
  31. if (result !== null)
  32. return result;
  33. }
  34. return false;
  35. });
  36. }
  37. }
  38. //# sourceMappingURL=index.js.map