forked from Authress/authress-sdk.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (35 loc) · 1.82 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
const httpClient = require('./src/httpClient');
const AccessRecordsApi = require('./src/accessRecordsApi');
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');
class AuthressClient {
constructor(settings, tokenProvider) {
this.settings = settings || {};
this.tokenProvider = typeof tokenProvider === 'string' ? new ServiceClientTokenProvider(tokenProvider, this.settings.baseUrl) : tokenProvider;
this.httpClient = new httpClient(this.settings.baseUrl, this.tokenProvider);
this.accessRecords = new AccessRecordsApi(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);
}
setToken(token) {
this.httpClient.tokenProvider = () => token;
}
}
const TokenVerifier = require('./src/tokenVerifier');
const UnauthorizedError = require('./src/unauthorizedError');
module.exports = { AuthressClient, ServiceClientTokenProvider, UnauthorizedError, TokenVerifier };