-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (30 loc) · 1.76 KB
/
Copy pathindex.js
File metadata and controls
30 lines (30 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { ActiveDirectoryAuthenticator } from './authenticators/activeDirectoryAuthenticator.js';
import { ADWebAuthAuthenticator } from './authenticators/adWebAuthAuthenticator.js';
import { FunctionAuthenticator } from './authenticators/functionAuthenticator.js';
import { PlainTextAuthenticator } from './authenticators/plainTextAuthenticator.js';
const Authenticators = {
activeDirectory: ActiveDirectoryAuthenticator,
adWebAuth: ADWebAuthAuthenticator,
function: FunctionAuthenticator,
plainText: PlainTextAuthenticator
};
/**
* Factory function to create an authenticator based on the specified type.
* @param authenticatorType - The authenticator to create ('activeDirectory' | 'adWebAuth' | 'function | 'plainText')
* @param authenticatorConfig - The configuration for the authenticator
* @returns An Authenticator instance based on the specified type
* @throws {Error} If the authenticator type is unknown
*/
export function instantiateAuthenticatorByType(authenticatorType, authenticatorConfig) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion, security/detect-object-injection
const Authenticator = Authenticators[authenticatorType];
if (Authenticator === undefined) {
throw new Error(`Unknown authenticator type: ${authenticatorType}`);
}
return new Authenticator(authenticatorConfig);
}
export { BaseAuthenticator } from './authenticators/_baseAuthenticator.js';
export { ActiveDirectoryAuthenticator } from './authenticators/activeDirectoryAuthenticator.js';
export { ADWebAuthAuthenticator } from './authenticators/adWebAuthAuthenticator.js';
export { FunctionAuthenticator } from './authenticators/functionAuthenticator.js';
export { PlainTextAuthenticator } from './authenticators/plainTextAuthenticator.js';