-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
51 lines (44 loc) · 2.2 KB
/
index.js
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
const httpClient = require('./src/httpClient');
const AccessRecordsApi = require('./src/accessRecordsApi');
const InvitesApi = require('./src/invitesApi');
const UserPermissionsApi = require('./src/userPermissionsApi');
const UsersApi = require('./src/usersApi');
const ServiceClientsApi = require('./src/serviceClientsApi');
const ResourcesApi = require('./src/resourcesApi');
const AccountsApi = require('./src/accountsApi');
const RolesApi = require('./src/rolesApi');
const ConnectionsApi = require('./src/connectionsApi');
const ExtensionsApi = require('./src/extensionsApi');
const TenantsApi = require('./src/tenantsApi');
const ServiceClientTokenProvider = require('./src/serviceClientTokenProvider');
const TokenVerifier = require('./src/tokenVerifier');
class AuthressClient {
constructor(settings, tokenProvider) {
this.settings = settings || {};
this.tokenProvider = typeof tokenProvider === 'string' ? new ServiceClientTokenProvider(tokenProvider, this.settings.baseUrl || this.settings.authressApiUrl) : tokenProvider;
this.httpClient = new httpClient(this.settings.baseUrl || this.settings.authressApiUrl, this.tokenProvider, this.settings.userAgent);
this.accessRecords = new AccessRecordsApi(this.httpClient);
this.invites = new InvitesApi(this.httpClient);
this.serviceClients = new ServiceClientsApi(this.httpClient);
this.userPermissions = new UserPermissionsApi(this.httpClient);
this.users = new UsersApi(this.httpClient);
this.resources = new ResourcesApi(this.httpClient);
this.accounts = new AccountsApi(this.httpClient);
this.roles = new RolesApi(this.httpClient);
this.connections = new ConnectionsApi(this.httpClient);
this.extensions = new ExtensionsApi(this.httpClient);
this.tenants = new TenantsApi(this.httpClient);
}
/**
* Deprecated: Will be removed in library version 4.0
*/
setToken(token) {
this.httpClient.tokenProvider = () => token;
}
verifyToken(token) {
return TokenVerifier(this.httpClient, token);
}
}
const UnauthorizedError = require('./src/unauthorizedError');
const ApiError = require('./src/apiError');
module.exports = { AuthressClient, ServiceClientTokenProvider, UnauthorizedError, ApiError, TokenVerifier };