-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathAdapter.ts
55 lines (42 loc) · 1.44 KB
/
Adapter.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import {
AdapterDependencies,
AdapterContent,
updateOptions,
} from './src/Options';
import {SecurityAdapter} from './src/adapters/SecurityAdapter';
import {ApigatewayAdapter, DefaultApigatewayAdapter} from './src/adapters/ApigatewayAdapter';
import {ServiceAccount} from './src/serviceaccount/ServiceAccount';
import {DefaultMiddlewareAdapter, MiddlewareAdapter} from './src/adapters/MiddlewareAdapter';
import {JWKS} from './src/jwks/JWKS';
export interface KeycloakAdapter {
getDefaultAdapter(): SecurityAdapter;
getAPIGateWayAdapter(): ApigatewayAdapter;
getExpressMiddlewareAdapter(): MiddlewareAdapter;
getAWSLambdaAdapter(): ApigatewayAdapter;
getServiceAccount():ServiceAccount;
getJWKS():JWKS;
}
export default class DefaultKeycloakAdapter implements KeycloakAdapter {
options: AdapterContent;
constructor(options: AdapterDependencies) {
this.options = updateOptions(options);
}
getJWKS(): JWKS {
return this.options.jwks;
}
getServiceAccount(): ServiceAccount {
return this.options.serviceAccount;
}
getAPIGateWayAdapter(): ApigatewayAdapter {
return new DefaultApigatewayAdapter(this.options);
}
getAWSLambdaAdapter(): ApigatewayAdapter {
return this.getAPIGateWayAdapter();
}
getDefaultAdapter(): SecurityAdapter {
return this.options.securityAdapter;
}
getExpressMiddlewareAdapter(): MiddlewareAdapter {
return new DefaultMiddlewareAdapter(this.options);
}
}