@aifabrix/miso-client 4.4.2 → 4.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +20 -38
- package/dist/api/auth-token.api.d.ts.map +1 -1
- package/dist/api/auth-token.api.js +45 -48
- package/dist/api/auth-token.api.js.map +1 -1
- package/dist/api/logs-create.api.d.ts.map +1 -1
- package/dist/api/logs-create.api.js +37 -50
- package/dist/api/logs-create.api.js.map +1 -1
- package/dist/express/client-token-endpoint.d.ts.map +1 -1
- package/dist/express/client-token-endpoint.js +88 -82
- package/dist/express/client-token-endpoint.js.map +1 -1
- package/dist/express/error-handler.d.ts.map +1 -1
- package/dist/express/error-handler.js +15 -7
- package/dist/express/error-handler.js.map +1 -1
- package/dist/express/error-types.d.ts +8 -1
- package/dist/express/error-types.d.ts.map +1 -1
- package/dist/express/error-types.js +11 -5
- package/dist/express/error-types.js.map +1 -1
- package/dist/express/index.d.ts +1 -1
- package/dist/express/index.d.ts.map +1 -1
- package/dist/express/response-helper.d.ts.map +1 -1
- package/dist/express/response-helper.js +4 -1
- package/dist/express/response-helper.js.map +1 -1
- package/dist/express/validation-helper.d.ts +1 -1
- package/dist/express/validation-helper.d.ts.map +1 -1
- package/dist/express/validation-helper.js +8 -10
- package/dist/express/validation-helper.js.map +1 -1
- package/dist/index.d.ts +3 -354
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -542
- package/dist/index.js.map +1 -1
- package/dist/miso-client.d.ts +82 -0
- package/dist/miso-client.d.ts.map +1 -0
- package/dist/miso-client.js +187 -0
- package/dist/miso-client.js.map +1 -0
- package/dist/sdk-exports.d.ts +56 -0
- package/dist/sdk-exports.d.ts.map +1 -0
- package/dist/sdk-exports.js +105 -0
- package/dist/sdk-exports.js.map +1 -0
- package/dist/services/application-context.service.d.ts +9 -1
- package/dist/services/application-context.service.d.ts.map +1 -1
- package/dist/services/application-context.service.js +46 -60
- package/dist/services/application-context.service.js.map +1 -1
- package/dist/services/auth-cache-helpers.d.ts.map +1 -1
- package/dist/services/auth-cache-helpers.js +4 -6
- package/dist/services/auth-cache-helpers.js.map +1 -1
- package/dist/services/auth-error-handler.d.ts.map +1 -1
- package/dist/services/auth-error-handler.js +12 -1
- package/dist/services/auth-error-handler.js.map +1 -1
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js +9 -13
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/browser-permission.service.d.ts +4 -4
- package/dist/services/browser-permission.service.d.ts.map +1 -1
- package/dist/services/browser-permission.service.js +35 -80
- package/dist/services/browser-permission.service.js.map +1 -1
- package/dist/services/browser-role.service.d.ts +4 -4
- package/dist/services/browser-role.service.d.ts.map +1 -1
- package/dist/services/browser-role.service.js +40 -96
- package/dist/services/browser-role.service.js.map +1 -1
- package/dist/services/cache.service.d.ts +1 -0
- package/dist/services/cache.service.d.ts.map +1 -1
- package/dist/services/cache.service.js +19 -32
- package/dist/services/cache.service.js.map +1 -1
- package/dist/services/logger/logger-context.d.ts +17 -17
- package/dist/services/logger/logger-context.d.ts.map +1 -1
- package/dist/services/logger/logger-context.js +7 -17
- package/dist/services/logger/logger-context.js.map +1 -1
- package/dist/services/logger/logger-http-utils.d.ts +9 -0
- package/dist/services/logger/logger-http-utils.d.ts.map +1 -0
- package/dist/services/logger/logger-http-utils.js +45 -0
- package/dist/services/logger/logger-http-utils.js.map +1 -0
- package/dist/services/logger/logger.service.d.ts +1 -4
- package/dist/services/logger/logger.service.d.ts.map +1 -1
- package/dist/services/logger/logger.service.js +61 -77
- package/dist/services/logger/logger.service.js.map +1 -1
- package/dist/services/permission.service.d.ts.map +1 -1
- package/dist/services/permission.service.js +17 -30
- package/dist/services/permission.service.js.map +1 -1
- package/dist/services/role.service.d.ts.map +1 -1
- package/dist/services/role.service.js +12 -20
- package/dist/services/role.service.js.map +1 -1
- package/dist/services/token-validation.service.js +1 -3
- package/dist/services/token-validation.service.js.map +1 -1
- package/dist/types/config.types.d.ts +1 -0
- package/dist/types/config.types.d.ts.map +1 -1
- package/dist/types/config.types.js.map +1 -1
- package/dist/utils/audit-log-queue.d.ts +3 -0
- package/dist/utils/audit-log-queue.d.ts.map +1 -1
- package/dist/utils/audit-log-queue.js +47 -66
- package/dist/utils/audit-log-queue.js.map +1 -1
- package/dist/utils/client-token-manager.d.ts +0 -7
- package/dist/utils/client-token-manager.d.ts.map +1 -1
- package/dist/utils/client-token-manager.js +40 -46
- package/dist/utils/client-token-manager.js.map +1 -1
- package/dist/utils/config-loader.d.ts +0 -5
- package/dist/utils/config-loader.d.ts.map +1 -1
- package/dist/utils/config-loader.js +14 -11
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/console-logger.d.ts +4 -0
- package/dist/utils/console-logger.d.ts.map +1 -1
- package/dist/utils/console-logger.js +21 -5
- package/dist/utils/console-logger.js.map +1 -1
- package/dist/utils/data-client-audit.d.ts +19 -1
- package/dist/utils/data-client-audit.d.ts.map +1 -1
- package/dist/utils/data-client-audit.js +87 -117
- package/dist/utils/data-client-audit.js.map +1 -1
- package/dist/utils/data-client-auth.d.ts.map +1 -1
- package/dist/utils/data-client-auth.js +139 -95
- package/dist/utils/data-client-auth.js.map +1 -1
- package/dist/utils/data-client-auto-init.d.ts.map +1 -1
- package/dist/utils/data-client-auto-init.js +57 -72
- package/dist/utils/data-client-auto-init.js.map +1 -1
- package/dist/utils/data-client-init.d.ts.map +1 -1
- package/dist/utils/data-client-init.js +3 -3
- package/dist/utils/data-client-init.js.map +1 -1
- package/dist/utils/data-client-oauth.d.ts.map +1 -1
- package/dist/utils/data-client-oauth.js +84 -60
- package/dist/utils/data-client-oauth.js.map +1 -1
- package/dist/utils/data-client-redirect.d.ts.map +1 -1
- package/dist/utils/data-client-redirect.js +75 -98
- package/dist/utils/data-client-redirect.js.map +1 -1
- package/dist/utils/data-client-request.d.ts +24 -5
- package/dist/utils/data-client-request.d.ts.map +1 -1
- package/dist/utils/data-client-request.js +80 -42
- package/dist/utils/data-client-request.js.map +1 -1
- package/dist/utils/data-client-response.d.ts +63 -15
- package/dist/utils/data-client-response.d.ts.map +1 -1
- package/dist/utils/data-client-response.js +89 -33
- package/dist/utils/data-client-response.js.map +1 -1
- package/dist/utils/data-client.d.ts +4 -0
- package/dist/utils/data-client.d.ts.map +1 -1
- package/dist/utils/data-client.js +57 -30
- package/dist/utils/data-client.js.map +1 -1
- package/dist/utils/environment-token.d.ts.map +1 -1
- package/dist/utils/environment-token.js +49 -59
- package/dist/utils/environment-token.js.map +1 -1
- package/dist/utils/error-extractor.d.ts.map +1 -1
- package/dist/utils/error-extractor.js +56 -79
- package/dist/utils/error-extractor.js.map +1 -1
- package/dist/utils/filter-colon.utils.d.ts.map +1 -1
- package/dist/utils/filter-colon.utils.js +34 -45
- package/dist/utils/filter-colon.utils.js.map +1 -1
- package/dist/utils/filter-schema-loader.d.ts +12 -0
- package/dist/utils/filter-schema-loader.d.ts.map +1 -0
- package/dist/utils/filter-schema-loader.js +69 -0
- package/dist/utils/filter-schema-loader.js.map +1 -0
- package/dist/utils/filter-schema.utils.d.ts +1 -14
- package/dist/utils/filter-schema.utils.d.ts.map +1 -1
- package/dist/utils/filter-schema.utils.js +78 -136
- package/dist/utils/filter-schema.utils.js.map +1 -1
- package/dist/utils/filter.utils.d.ts.map +1 -1
- package/dist/utils/filter.utils.js +38 -36
- package/dist/utils/filter.utils.js.map +1 -1
- package/dist/utils/http-client-audit.d.ts.map +1 -1
- package/dist/utils/http-client-audit.js +3 -12
- package/dist/utils/http-client-audit.js.map +1 -1
- package/dist/utils/http-client-masking.d.ts +13 -2
- package/dist/utils/http-client-masking.d.ts.map +1 -1
- package/dist/utils/http-client-masking.js +27 -27
- package/dist/utils/http-client-masking.js.map +1 -1
- package/dist/utils/http-response-validator.d.ts.map +1 -1
- package/dist/utils/http-response-validator.js +8 -3
- package/dist/utils/http-response-validator.js.map +1 -1
- package/dist/utils/internal-http-client.d.ts.map +1 -1
- package/dist/utils/internal-http-client.js +5 -3
- package/dist/utils/internal-http-client.js.map +1 -1
- package/dist/utils/response-validator.d.ts.map +1 -1
- package/dist/utils/response-validator.js +29 -44
- package/dist/utils/response-validator.js.map +1 -1
- package/dist/utils/sensitive-fields.loader.d.ts +0 -7
- package/dist/utils/sensitive-fields.loader.d.ts.map +1 -1
- package/dist/utils/sensitive-fields.loader.js +68 -114
- package/dist/utils/sensitive-fields.loader.js.map +1 -1
- package/dist/utils/token-utils.d.ts.map +1 -1
- package/dist/utils/token-utils.js +28 -37
- package/dist/utils/token-utils.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Main MisoClient SDK
|
|
3
|
+
* Main MisoClient SDK entry point
|
|
4
4
|
*/
|
|
5
5
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
@@ -17,545 +17,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
17
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const permission_service_1 = require("./services/permission.service");
|
|
25
|
-
const logger_1 = require("./services/logger");
|
|
26
|
-
const redis_service_1 = require("./services/redis.service");
|
|
27
|
-
const cache_service_1 = require("./services/cache.service");
|
|
28
|
-
const http_client_1 = require("./utils/http-client");
|
|
29
|
-
const internal_http_client_1 = require("./utils/internal-http-client");
|
|
30
|
-
const api_1 = require("./api");
|
|
31
|
-
const data_masker_1 = require("./utils/data-masker");
|
|
32
|
-
const auth_strategy_1 = require("./utils/auth-strategy");
|
|
33
|
-
const origin_validator_1 = require("./utils/origin-validator");
|
|
34
|
-
const token_validation_service_1 = require("./services/token-validation.service");
|
|
35
|
-
const encryption_service_1 = require("./services/encryption.service");
|
|
36
|
-
class MisoClient {
|
|
37
|
-
constructor(config) {
|
|
38
|
-
this.initialized = false;
|
|
39
|
-
this.config = config;
|
|
40
|
-
// Initialize DataMasker with custom config path if provided
|
|
41
|
-
if (config.sensitiveFieldsConfig) {
|
|
42
|
-
data_masker_1.DataMasker.setConfigPath(config.sensitiveFieldsConfig);
|
|
43
|
-
}
|
|
44
|
-
// Create InternalHttpClient first (base HTTP functionality)
|
|
45
|
-
const internalClient = new internal_http_client_1.InternalHttpClient(config);
|
|
46
|
-
// Create Redis service
|
|
47
|
-
this.redis = new redis_service_1.RedisService(config.redis);
|
|
48
|
-
// Create LoggerService with InternalHttpClient first (needs httpClient.request() and httpClient.config)
|
|
49
|
-
// InternalHttpClient has these methods, so we can use it directly
|
|
50
|
-
// Type assertion needed because InternalHttpClient has compatible interface with HttpClient
|
|
51
|
-
this.logger = new logger_1.LoggerService(internalClient, this.redis);
|
|
52
|
-
// Create public HttpClient that wraps InternalHttpClient with logger
|
|
53
|
-
this.httpClient = new http_client_1.HttpClient(config, this.logger);
|
|
54
|
-
// Update LoggerService to use the new public HttpClient (for logging)
|
|
55
|
-
// Type assertion needed because httpClient property is private in LoggerService but needs to be updated
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
-
this.logger.httpClient = this.httpClient;
|
|
58
|
-
// Create ApiClient that wraps HttpClient (provides typed API interfaces)
|
|
59
|
-
this.apiClient = new api_1.ApiClient(this.httpClient);
|
|
60
|
-
// Set ApiClient in LoggerService (resolves circular dependency)
|
|
61
|
-
this.logger.setApiClient(this.apiClient);
|
|
62
|
-
// Register LoggerService for unified logging interface
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
64
|
-
const { registerLoggerService } = require("./services/logger/unified-logger.factory");
|
|
65
|
-
registerLoggerService(this.logger);
|
|
66
|
-
// Initialize cache service with Redis support (used by auth, roles and permissions)
|
|
67
|
-
this.cacheService = new cache_service_1.CacheService(this.redis);
|
|
68
|
-
// Create services (pass both httpClient and apiClient for gradual migration)
|
|
69
|
-
this.auth = new auth_service_1.AuthService(this.httpClient, this.apiClient, this.cacheService);
|
|
70
|
-
// Initialize services that use cache
|
|
71
|
-
this.roles = new role_service_1.RoleService(this.httpClient, this.apiClient, this.cacheService);
|
|
72
|
-
this.permissions = new permission_service_1.PermissionService(this.httpClient, this.apiClient, this.cacheService);
|
|
73
|
-
// Initialize token validation service
|
|
74
|
-
this.tokenValidation = new token_validation_service_1.TokenValidationService(config.keycloak);
|
|
75
|
-
// Initialize encryption service with encryption key from config
|
|
76
|
-
this.encryptionService = new encryption_service_1.EncryptionService(this.apiClient, this.config.encryptionKey);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Initialize the client (connect to Redis if configured)
|
|
80
|
-
*/
|
|
81
|
-
async initialize() {
|
|
82
|
-
if (this.initialized) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
await this.redis.connect();
|
|
87
|
-
this.initialized = true;
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
// Redis connection failed, continue with controller fallback mode
|
|
91
|
-
this.initialized = true; // Still mark as initialized for fallback mode
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Disconnect from Redis
|
|
96
|
-
*/
|
|
97
|
-
async disconnect() {
|
|
98
|
-
await this.redis.disconnect();
|
|
99
|
-
this.initialized = false;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Check if client is initialized
|
|
103
|
-
*/
|
|
104
|
-
isInitialized() {
|
|
105
|
-
return this.initialized;
|
|
106
|
-
}
|
|
107
|
-
// ==================== AUTHENTICATION METHODS ====================
|
|
108
|
-
/**
|
|
109
|
-
* Extract Bearer token from request headers
|
|
110
|
-
* Supports common request object patterns (Express, Fastify, Next.js)
|
|
111
|
-
*/
|
|
112
|
-
getToken(req) {
|
|
113
|
-
const authHeader = req.headers.authorization;
|
|
114
|
-
if (!authHeader) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
// Support "Bearer <token>" format
|
|
118
|
-
if (authHeader.startsWith("Bearer ")) {
|
|
119
|
-
return authHeader.substring(7);
|
|
120
|
-
}
|
|
121
|
-
// If no Bearer prefix, assume the whole header is the token
|
|
122
|
-
return authHeader;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Validate request origin against configured allowed origins
|
|
126
|
-
* Uses allowedOrigins from client configuration if not provided
|
|
127
|
-
*
|
|
128
|
-
* @param req - Express Request object
|
|
129
|
-
* @param allowedOrigins - Optional array of allowed origins (defaults to config.allowedOrigins)
|
|
130
|
-
* @returns Validation result with valid flag and optional error message
|
|
131
|
-
*/
|
|
132
|
-
validateOrigin(req, allowedOrigins) {
|
|
133
|
-
const origins = allowedOrigins ?? this.config.allowedOrigins;
|
|
134
|
-
return (0, origin_validator_1.validateOrigin)(req, origins);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Get environment token using client credentials.
|
|
138
|
-
* @returns Environment token string or empty string on failure.
|
|
139
|
-
*/
|
|
140
|
-
async getEnvironmentToken() {
|
|
141
|
-
return this.auth.getEnvironmentToken();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Initiate login flow and return login URL for browser redirect.
|
|
145
|
-
* @param params - Login parameters.
|
|
146
|
-
* @param params.redirect - Final destination URL after authentication.
|
|
147
|
-
* @param params.state - Optional CSRF protection token.
|
|
148
|
-
* @returns Login response with loginUrl and state.
|
|
149
|
-
*/
|
|
150
|
-
async login(params) {
|
|
151
|
-
return this.auth.login(params);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Validate token with controller.
|
|
155
|
-
* @param token - User JWT token.
|
|
156
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
157
|
-
* @returns True if token is valid, otherwise false.
|
|
158
|
-
*/
|
|
159
|
-
async validateToken(token, authStrategy) {
|
|
160
|
-
return this.auth.validateToken(token, authStrategy);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Get user information from token.
|
|
164
|
-
* @param token - User JWT token.
|
|
165
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
166
|
-
* @returns User info or null when not available.
|
|
167
|
-
*/
|
|
168
|
-
async getUser(token, authStrategy) {
|
|
169
|
-
return this.auth.getUser(token, authStrategy);
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get user information from GET /api/v1/auth/user endpoint.
|
|
173
|
-
* @param token - User JWT token.
|
|
174
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
175
|
-
* @returns User info or null when not available.
|
|
176
|
-
*/
|
|
177
|
-
async getUserInfo(token, authStrategy) {
|
|
178
|
-
return this.auth.getUserInfo(token, authStrategy);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Check if user is authenticated.
|
|
182
|
-
* @param token - User JWT token.
|
|
183
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
184
|
-
* @returns True if authenticated, otherwise false.
|
|
185
|
-
*/
|
|
186
|
-
async isAuthenticated(token, authStrategy) {
|
|
187
|
-
return this.auth.isAuthenticated(token, authStrategy);
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Logout user.
|
|
191
|
-
* @param params - Logout parameters.
|
|
192
|
-
* @param params.token - User JWT token.
|
|
193
|
-
* @returns Logout response.
|
|
194
|
-
*/
|
|
195
|
-
async logout(params) {
|
|
196
|
-
return this.auth.logout(params);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Refresh user access token using refresh token.
|
|
200
|
-
* @param refreshToken - Refresh token.
|
|
201
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
202
|
-
* @returns Refresh token response or null on failure.
|
|
203
|
-
*/
|
|
204
|
-
async refreshToken(refreshToken, authStrategy) {
|
|
205
|
-
return this.auth.refreshToken(refreshToken, authStrategy);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Validate token locally using JWKS (no API call).
|
|
209
|
-
* @param token - User JWT token.
|
|
210
|
-
* @param options - Optional validation options.
|
|
211
|
-
* @returns Validation result.
|
|
212
|
-
*/
|
|
213
|
-
async validateTokenLocal(token, options) {
|
|
214
|
-
return this.tokenValidation.validateTokenLocal(token, options);
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Set or update Keycloak configuration for local validation.
|
|
218
|
-
* @param config - Keycloak configuration.
|
|
219
|
-
*/
|
|
220
|
-
setKeycloakConfig(config) {
|
|
221
|
-
this.tokenValidation.setKeycloakConfig(config);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Clear JWKS cache.
|
|
225
|
-
* @param jwksUri - Optional JWKS URI to clear.
|
|
226
|
-
*/
|
|
227
|
-
clearJwksCache(jwksUri) {
|
|
228
|
-
this.tokenValidation.clearCache(jwksUri);
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Clear validation result cache.
|
|
232
|
-
*/
|
|
233
|
-
clearValidationCache() {
|
|
234
|
-
this.tokenValidation.clearResultCache();
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Clear all token validation caches (JWKS + results).
|
|
238
|
-
*/
|
|
239
|
-
clearAllTokenCaches() {
|
|
240
|
-
this.tokenValidation.clearAllCaches();
|
|
241
|
-
}
|
|
242
|
-
// ==================== ROLE METHODS ====================
|
|
243
|
-
/**
|
|
244
|
-
* Get user roles (cached if Redis available).
|
|
245
|
-
* @param token - User JWT token.
|
|
246
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
247
|
-
* @returns Array of roles.
|
|
248
|
-
*/
|
|
249
|
-
async getRoles(token, authStrategy) {
|
|
250
|
-
return this.roles.getRoles(token, authStrategy);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Check if user has specific role.
|
|
254
|
-
* @param token - User JWT token.
|
|
255
|
-
* @param role - Role to check.
|
|
256
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
257
|
-
* @returns True if user has the role.
|
|
258
|
-
*/
|
|
259
|
-
async hasRole(token, role, authStrategy) {
|
|
260
|
-
return this.roles.hasRole(token, role, authStrategy);
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Check if user has any of the specified roles.
|
|
264
|
-
* @param token - User JWT token.
|
|
265
|
-
* @param roles - Roles to check.
|
|
266
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
267
|
-
* @returns True if user has any of the roles.
|
|
268
|
-
*/
|
|
269
|
-
async hasAnyRole(token, roles, authStrategy) {
|
|
270
|
-
return this.roles.hasAnyRole(token, roles, authStrategy);
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Check if user has all of the specified roles.
|
|
274
|
-
* @param token - User JWT token.
|
|
275
|
-
* @param roles - Roles to check.
|
|
276
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
277
|
-
* @returns True if user has all roles.
|
|
278
|
-
*/
|
|
279
|
-
async hasAllRoles(token, roles, authStrategy) {
|
|
280
|
-
return this.roles.hasAllRoles(token, roles, authStrategy);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Force refresh roles from controller (bypass cache).
|
|
284
|
-
* @param token - User JWT token.
|
|
285
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
286
|
-
* @returns Array of roles.
|
|
287
|
-
*/
|
|
288
|
-
async refreshRoles(token, authStrategy) {
|
|
289
|
-
return this.roles.refreshRoles(token, authStrategy);
|
|
290
|
-
}
|
|
291
|
-
// ==================== PERMISSION METHODS ====================
|
|
292
|
-
/**
|
|
293
|
-
* Get user permissions (cached if Redis available).
|
|
294
|
-
* @param token - User JWT token.
|
|
295
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
296
|
-
* @returns Array of permissions.
|
|
297
|
-
*/
|
|
298
|
-
async getPermissions(token, authStrategy) {
|
|
299
|
-
return this.permissions.getPermissions(token, authStrategy);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Check if user has specific permission.
|
|
303
|
-
* @param token - User JWT token.
|
|
304
|
-
* @param permission - Permission to check.
|
|
305
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
306
|
-
* @returns True if user has permission.
|
|
307
|
-
*/
|
|
308
|
-
async hasPermission(token, permission, authStrategy) {
|
|
309
|
-
return this.permissions.hasPermission(token, permission, authStrategy);
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Check if user has any of the specified permissions.
|
|
313
|
-
* @param token - User JWT token.
|
|
314
|
-
* @param permissions - Permissions to check.
|
|
315
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
316
|
-
* @returns True if user has any permission.
|
|
317
|
-
*/
|
|
318
|
-
async hasAnyPermission(token, permissions, authStrategy) {
|
|
319
|
-
return this.permissions.hasAnyPermission(token, permissions, authStrategy);
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Check if user has all of the specified permissions.
|
|
323
|
-
* @param token - User JWT token.
|
|
324
|
-
* @param permissions - Permissions to check.
|
|
325
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
326
|
-
* @returns True if user has all permissions.
|
|
327
|
-
*/
|
|
328
|
-
async hasAllPermissions(token, permissions, authStrategy) {
|
|
329
|
-
return this.permissions.hasAllPermissions(token, permissions, authStrategy);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Force refresh permissions from controller (bypass cache).
|
|
333
|
-
* @param token - User JWT token.
|
|
334
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
335
|
-
* @returns Array of permissions.
|
|
336
|
-
*/
|
|
337
|
-
async refreshPermissions(token, authStrategy) {
|
|
338
|
-
return this.permissions.refreshPermissions(token, authStrategy);
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* Clear cached permissions for a user.
|
|
342
|
-
* @param token - User JWT token.
|
|
343
|
-
* @param authStrategy - Optional authentication strategy override.
|
|
344
|
-
*/
|
|
345
|
-
async clearPermissionsCache(token, authStrategy) {
|
|
346
|
-
return this.permissions.clearPermissionsCache(token, authStrategy);
|
|
347
|
-
}
|
|
348
|
-
// ==================== LOGGING METHODS ====================
|
|
349
|
-
/**
|
|
350
|
-
* Get logger service for application logging
|
|
351
|
-
*/
|
|
352
|
-
get log() {
|
|
353
|
-
return this.logger;
|
|
354
|
-
}
|
|
355
|
-
// ==================== ENCRYPTION METHODS ====================
|
|
356
|
-
/**
|
|
357
|
-
* Get encryption service for security parameter management
|
|
358
|
-
* Provides encrypt/decrypt methods that call the controller
|
|
359
|
-
*/
|
|
360
|
-
get encryption() {
|
|
361
|
-
return this.encryptionService;
|
|
362
|
-
}
|
|
363
|
-
// ==================== CACHE METHODS ====================
|
|
364
|
-
/**
|
|
365
|
-
* Get cache service for generic caching
|
|
366
|
-
*/
|
|
367
|
-
get cache() {
|
|
368
|
-
return this.cacheService;
|
|
369
|
-
}
|
|
370
|
-
// ==================== APPLICATION STATUS METHODS (server-side) ====================
|
|
371
|
-
/**
|
|
372
|
-
* Update the current application's status and URLs (server-side only).
|
|
373
|
-
* Uses client credentials or provided authStrategy.
|
|
374
|
-
* When envKey is omitted, resolves from application context (client token / clientId).
|
|
375
|
-
*
|
|
376
|
-
* @param body - Update request (status, url, internalUrl, port)
|
|
377
|
-
* @param options - Optional envKey and authStrategy; if envKey omitted, uses context (throws if context missing)
|
|
378
|
-
* @returns Update response with success and optional application data
|
|
379
|
-
*/
|
|
380
|
-
async updateMyApplicationStatus(body, options) {
|
|
381
|
-
const envKey = options?.envKey ??
|
|
382
|
-
this.logger.getApplicationContextService().getApplicationContext()
|
|
383
|
-
.environment;
|
|
384
|
-
if (!envKey) {
|
|
385
|
-
throw new Error('updateMyApplicationStatus requires envKey or application context (client token/clientId with environment). Neither was available.');
|
|
386
|
-
}
|
|
387
|
-
return this.apiClient.applications.updateSelfStatus(envKey, body, options?.authStrategy);
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Get any application's status and URLs (without configuration).
|
|
391
|
-
* Uses client credentials or provided authStrategy.
|
|
392
|
-
*
|
|
393
|
-
* @param envKey - Environment key
|
|
394
|
-
* @param appKey - Application key
|
|
395
|
-
* @param authStrategy - Optional authentication strategy override
|
|
396
|
-
* @returns Application status response with metadata
|
|
397
|
-
*/
|
|
398
|
-
async getApplicationStatus(envKey, appKey, authStrategy) {
|
|
399
|
-
return this.apiClient.applications.getApplicationStatus(envKey, appKey, authStrategy);
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Get the current application's status and URLs (server-side only).
|
|
403
|
-
* Uses envKey and appKey from application context when not provided.
|
|
404
|
-
*
|
|
405
|
-
* @param options - Optional envKey and appKey; if omitted, uses context
|
|
406
|
-
* @param authStrategy - Optional authentication strategy override
|
|
407
|
-
* @returns Application status response with metadata
|
|
408
|
-
*/
|
|
409
|
-
async getMyApplicationStatus(options, authStrategy) {
|
|
410
|
-
const context = this.logger.getApplicationContextService().getApplicationContext();
|
|
411
|
-
const envKey = options?.envKey ?? context.environment;
|
|
412
|
-
const appKey = options?.appKey ?? context.application;
|
|
413
|
-
if (!envKey || !appKey) {
|
|
414
|
-
throw new Error('getMyApplicationStatus requires envKey and appKey or application context (client token/clientId). Neither was fully available.');
|
|
415
|
-
}
|
|
416
|
-
return this.apiClient.applications.getApplicationStatus(envKey, appKey, authStrategy);
|
|
417
|
-
}
|
|
418
|
-
// ==================== UTILITY METHODS ====================
|
|
419
|
-
/**
|
|
420
|
-
* Get current configuration
|
|
421
|
-
*/
|
|
422
|
-
getConfig() {
|
|
423
|
-
return { ...this.config };
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Check if Redis is connected.
|
|
427
|
-
* @returns True if Redis connection is active.
|
|
428
|
-
*/
|
|
429
|
-
isRedisConnected() {
|
|
430
|
-
return this.redis.isConnected();
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Make request with authentication strategy.
|
|
434
|
-
* @param method - HTTP method.
|
|
435
|
-
* @param url - Request URL.
|
|
436
|
-
* @param authStrategy - Authentication strategy to use.
|
|
437
|
-
* @param data - Optional request data.
|
|
438
|
-
* @param config - Optional Axios config overrides.
|
|
439
|
-
* @returns Parsed response data.
|
|
440
|
-
*/
|
|
441
|
-
async requestWithAuthStrategy(method, url, authStrategy, data, config) {
|
|
442
|
-
return this.httpClient.requestWithAuthStrategy(method, url, authStrategy, data, config);
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Create authentication strategy helper.
|
|
446
|
-
* @param methods - Auth methods in priority order.
|
|
447
|
-
* @param bearerToken - Optional bearer token.
|
|
448
|
-
* @param apiKey - Optional API key.
|
|
449
|
-
* @returns Authentication strategy.
|
|
450
|
-
*/
|
|
451
|
-
createAuthStrategy(methods, bearerToken, apiKey) {
|
|
452
|
-
return { methods, bearerToken, apiKey };
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Get default authentication strategy.
|
|
456
|
-
* @param bearerToken - Optional bearer token.
|
|
457
|
-
* @returns Default authentication strategy.
|
|
458
|
-
*/
|
|
459
|
-
getDefaultAuthStrategy(bearerToken) {
|
|
460
|
-
return auth_strategy_1.AuthStrategyHandler.getDefaultStrategy(bearerToken);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
exports.MisoClient = MisoClient;
|
|
464
|
-
// Export types
|
|
465
|
-
__exportStar(require("./types/config.types"), exports);
|
|
466
|
-
__exportStar(require("./types/filter.types"), exports);
|
|
467
|
-
__exportStar(require("./types/filter-schema.types"), exports);
|
|
468
|
-
// Export detectAuthMethodFromHeaders helper for advanced usage
|
|
469
|
-
var http_error_handler_1 = require("./utils/http-error-handler");
|
|
470
|
-
Object.defineProperty(exports, "detectAuthMethodFromHeaders", { enumerable: true, get: function () { return http_error_handler_1.detectAuthMethodFromHeaders; } });
|
|
471
|
-
// Export services for advanced usage
|
|
472
|
-
var auth_service_2 = require("./services/auth.service");
|
|
473
|
-
Object.defineProperty(exports, "AuthService", { enumerable: true, get: function () { return auth_service_2.AuthService; } });
|
|
474
|
-
var role_service_2 = require("./services/role.service");
|
|
475
|
-
Object.defineProperty(exports, "RoleService", { enumerable: true, get: function () { return role_service_2.RoleService; } });
|
|
476
|
-
var permission_service_2 = require("./services/permission.service");
|
|
477
|
-
Object.defineProperty(exports, "PermissionService", { enumerable: true, get: function () { return permission_service_2.PermissionService; } });
|
|
478
|
-
var browser_permission_service_1 = require("./services/browser-permission.service");
|
|
479
|
-
Object.defineProperty(exports, "BrowserPermissionService", { enumerable: true, get: function () { return browser_permission_service_1.BrowserPermissionService; } });
|
|
480
|
-
var browser_role_service_1 = require("./services/browser-role.service");
|
|
481
|
-
Object.defineProperty(exports, "BrowserRoleService", { enumerable: true, get: function () { return browser_role_service_1.BrowserRoleService; } });
|
|
482
|
-
var logger_2 = require("./services/logger");
|
|
483
|
-
Object.defineProperty(exports, "LoggerService", { enumerable: true, get: function () { return logger_2.LoggerService; } });
|
|
484
|
-
var redis_service_2 = require("./services/redis.service");
|
|
485
|
-
Object.defineProperty(exports, "RedisService", { enumerable: true, get: function () { return redis_service_2.RedisService; } });
|
|
486
|
-
var cache_service_2 = require("./services/cache.service");
|
|
487
|
-
Object.defineProperty(exports, "CacheService", { enumerable: true, get: function () { return cache_service_2.CacheService; } });
|
|
488
|
-
var http_client_2 = require("./utils/http-client");
|
|
489
|
-
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return http_client_2.HttpClient; } });
|
|
490
|
-
// Export unified logging interface
|
|
491
|
-
var unified_logger_factory_1 = require("./services/logger/unified-logger.factory");
|
|
492
|
-
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return unified_logger_factory_1.getLogger; } });
|
|
493
|
-
var logger_3 = require("./services/logger");
|
|
494
|
-
Object.defineProperty(exports, "LoggerContextStorage", { enumerable: true, get: function () { return logger_3.LoggerContextStorage; } });
|
|
495
|
-
// Export utilities
|
|
496
|
-
var config_loader_1 = require("./utils/config-loader");
|
|
497
|
-
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_loader_1.loadConfig; } });
|
|
498
|
-
var origin_validator_2 = require("./utils/origin-validator");
|
|
499
|
-
Object.defineProperty(exports, "validateOrigin", { enumerable: true, get: function () { return origin_validator_2.validateOrigin; } });
|
|
500
|
-
var environment_token_1 = require("./utils/environment-token");
|
|
501
|
-
Object.defineProperty(exports, "getEnvironmentToken", { enumerable: true, get: function () { return environment_token_1.getEnvironmentToken; } });
|
|
502
|
-
var token_utils_1 = require("./utils/token-utils");
|
|
503
|
-
Object.defineProperty(exports, "extractClientTokenInfo", { enumerable: true, get: function () { return token_utils_1.extractClientTokenInfo; } });
|
|
504
|
-
var controller_url_resolver_1 = require("./utils/controller-url-resolver");
|
|
505
|
-
Object.defineProperty(exports, "resolveControllerUrl", { enumerable: true, get: function () { return controller_url_resolver_1.resolveControllerUrl; } });
|
|
506
|
-
Object.defineProperty(exports, "resolveKeycloakUrl", { enumerable: true, get: function () { return controller_url_resolver_1.resolveKeycloakUrl; } });
|
|
507
|
-
Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return controller_url_resolver_1.isBrowser; } });
|
|
508
|
-
Object.defineProperty(exports, "validateUrl", { enumerable: true, get: function () { return controller_url_resolver_1.validateUrl; } });
|
|
509
|
-
var logging_helpers_1 = require("./utils/logging-helpers");
|
|
510
|
-
Object.defineProperty(exports, "extractLoggingContext", { enumerable: true, get: function () { return logging_helpers_1.extractLoggingContext; } });
|
|
511
|
-
var request_context_1 = require("./utils/request-context");
|
|
512
|
-
Object.defineProperty(exports, "extractRequestContext", { enumerable: true, get: function () { return request_context_1.extractRequestContext; } });
|
|
513
|
-
// Export pagination, filter, sort utilities
|
|
514
|
-
__exportStar(require("./utils/pagination.utils"), exports);
|
|
515
|
-
__exportStar(require("./utils/filter.utils"), exports);
|
|
516
|
-
__exportStar(require("./utils/filter-schema.utils"), exports);
|
|
517
|
-
__exportStar(require("./utils/sort.utils"), exports);
|
|
518
|
-
// Export error classes and utilities
|
|
519
|
-
var errors_1 = require("./utils/errors");
|
|
520
|
-
Object.defineProperty(exports, "MisoClientError", { enumerable: true, get: function () { return errors_1.MisoClientError; } });
|
|
521
|
-
Object.defineProperty(exports, "ApiErrorException", { enumerable: true, get: function () { return errors_1.ApiErrorException; } });
|
|
522
|
-
Object.defineProperty(exports, "transformError", { enumerable: true, get: function () { return errors_1.transformError; } });
|
|
523
|
-
Object.defineProperty(exports, "handleApiError", { enumerable: true, get: function () { return errors_1.handleApiError; } });
|
|
524
|
-
// Export encryption service and types
|
|
525
|
-
var encryption_service_2 = require("./services/encryption.service");
|
|
526
|
-
Object.defineProperty(exports, "EncryptionService", { enumerable: true, get: function () { return encryption_service_2.EncryptionService; } });
|
|
527
|
-
var encryption_error_1 = require("./utils/encryption-error");
|
|
528
|
-
Object.defineProperty(exports, "EncryptionError", { enumerable: true, get: function () { return encryption_error_1.EncryptionError; } });
|
|
529
|
-
var applications_types_1 = require("./api/types/applications.types");
|
|
530
|
-
Object.defineProperty(exports, "APPLICATION_STATUS_VALUES", { enumerable: true, get: function () { return applications_types_1.APPLICATION_STATUS_VALUES; } });
|
|
531
|
-
// Express utilities (v2.1.0+)
|
|
532
|
-
// Export everything except ErrorResponse to avoid conflict with config.types ErrorResponse
|
|
533
|
-
var express_1 = require("./express");
|
|
534
|
-
Object.defineProperty(exports, "ResponseHelper", { enumerable: true, get: function () { return express_1.ResponseHelper; } });
|
|
535
|
-
Object.defineProperty(exports, "injectResponseHelpers", { enumerable: true, get: function () { return express_1.injectResponseHelpers; } });
|
|
536
|
-
Object.defineProperty(exports, "asyncHandler", { enumerable: true, get: function () { return express_1.asyncHandler; } });
|
|
537
|
-
Object.defineProperty(exports, "asyncHandlerNamed", { enumerable: true, get: function () { return express_1.asyncHandlerNamed; } });
|
|
538
|
-
Object.defineProperty(exports, "ValidationHelper", { enumerable: true, get: function () { return express_1.ValidationHelper; } });
|
|
539
|
-
Object.defineProperty(exports, "AppError", { enumerable: true, get: function () { return express_1.AppError; } });
|
|
540
|
-
Object.defineProperty(exports, "createSuccessResponse", { enumerable: true, get: function () { return express_1.createSuccessResponse; } });
|
|
541
|
-
Object.defineProperty(exports, "createErrorResponse", { enumerable: true, get: function () { return express_1.createErrorResponse; } });
|
|
542
|
-
Object.defineProperty(exports, "setErrorLogger", { enumerable: true, get: function () { return express_1.setErrorLogger; } });
|
|
543
|
-
Object.defineProperty(exports, "handleRouteError", { enumerable: true, get: function () { return express_1.handleRouteError; } });
|
|
544
|
-
Object.defineProperty(exports, "getErrorTypeUri", { enumerable: true, get: function () { return express_1.getErrorTypeUri; } });
|
|
545
|
-
Object.defineProperty(exports, "getErrorTitle", { enumerable: true, get: function () { return express_1.getErrorTitle; } });
|
|
546
|
-
Object.defineProperty(exports, "sendErrorResponse", { enumerable: true, get: function () { return express_1.sendErrorResponse; } });
|
|
547
|
-
Object.defineProperty(exports, "createClientTokenEndpoint", { enumerable: true, get: function () { return express_1.createClientTokenEndpoint; } });
|
|
548
|
-
Object.defineProperty(exports, "hasConfig", { enumerable: true, get: function () { return express_1.hasConfig; } });
|
|
549
|
-
Object.defineProperty(exports, "loggerContextMiddleware", { enumerable: true, get: function () { return express_1.loggerContextMiddleware; } });
|
|
550
|
-
// Export DataClient browser wrapper
|
|
551
|
-
var data_client_1 = require("./utils/data-client");
|
|
552
|
-
Object.defineProperty(exports, "DataClient", { enumerable: true, get: function () { return data_client_1.DataClient; } });
|
|
553
|
-
Object.defineProperty(exports, "dataClient", { enumerable: true, get: function () { return data_client_1.dataClient; } });
|
|
554
|
-
// Export DataClient auto-initialization helper
|
|
555
|
-
var data_client_auto_init_1 = require("./utils/data-client-auto-init");
|
|
556
|
-
Object.defineProperty(exports, "autoInitializeDataClient", { enumerable: true, get: function () { return data_client_auto_init_1.autoInitializeDataClient; } });
|
|
557
|
-
Object.defineProperty(exports, "getCachedDataClientConfig", { enumerable: true, get: function () { return data_client_auto_init_1.getCachedDataClientConfig; } });
|
|
558
|
-
// Token validation service (for advanced usage)
|
|
559
|
-
var token_validation_service_2 = require("./services/token-validation.service");
|
|
560
|
-
Object.defineProperty(exports, "TokenValidationService", { enumerable: true, get: function () { return token_validation_service_2.TokenValidationService; } });
|
|
20
|
+
exports.MisoClient = void 0;
|
|
21
|
+
var miso_client_1 = require("./miso-client");
|
|
22
|
+
Object.defineProperty(exports, "MisoClient", { enumerable: true, get: function () { return miso_client_1.MisoClient; } });
|
|
23
|
+
__exportStar(require("./sdk-exports"), exports);
|
|
561
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,gDAA8B"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MisoClient SDK class - main entry point
|
|
3
|
+
*/
|
|
4
|
+
import { LoggerService } from "./services/logger";
|
|
5
|
+
import { CacheService } from "./services/cache.service";
|
|
6
|
+
import { MisoClientConfig, UserInfo, AuthStrategy } from "./types/config.types";
|
|
7
|
+
import { OriginValidationResult } from "./utils/origin-validator";
|
|
8
|
+
import { Request } from "express";
|
|
9
|
+
import { EncryptionService } from "./services/encryption.service";
|
|
10
|
+
import { TokenValidationOptions, TokenValidationResult, KeycloakConfig } from "./types/token-validation.types";
|
|
11
|
+
import type { UpdateSelfStatusRequest, UpdateSelfStatusResponse, ApplicationStatusResponse } from "./api/types/applications.types";
|
|
12
|
+
export declare class MisoClient {
|
|
13
|
+
private config;
|
|
14
|
+
private httpClient;
|
|
15
|
+
private apiClient;
|
|
16
|
+
private redis;
|
|
17
|
+
private auth;
|
|
18
|
+
private roles;
|
|
19
|
+
private permissions;
|
|
20
|
+
private logger;
|
|
21
|
+
private cacheService;
|
|
22
|
+
private tokenValidation;
|
|
23
|
+
private encryptionService;
|
|
24
|
+
private initialized;
|
|
25
|
+
constructor(config: MisoClientConfig);
|
|
26
|
+
initialize(): Promise<void>;
|
|
27
|
+
disconnect(): Promise<void>;
|
|
28
|
+
isInitialized(): boolean;
|
|
29
|
+
getToken(req: {
|
|
30
|
+
headers: {
|
|
31
|
+
authorization?: string;
|
|
32
|
+
};
|
|
33
|
+
}): string | null;
|
|
34
|
+
validateOrigin(req: Request, allowedOrigins?: string[]): OriginValidationResult;
|
|
35
|
+
getEnvironmentToken(): Promise<string>;
|
|
36
|
+
login(params: {
|
|
37
|
+
redirect: string;
|
|
38
|
+
state?: string;
|
|
39
|
+
}): Promise<import("./types/config.types").LoginResponse>;
|
|
40
|
+
validateToken(token: string, authStrategy?: AuthStrategy): Promise<boolean>;
|
|
41
|
+
getUser(token: string, authStrategy?: AuthStrategy): Promise<UserInfo | null>;
|
|
42
|
+
getUserInfo(token: string, authStrategy?: AuthStrategy): Promise<UserInfo | null>;
|
|
43
|
+
isAuthenticated(token: string, authStrategy?: AuthStrategy): Promise<boolean>;
|
|
44
|
+
logout(params: {
|
|
45
|
+
token: string;
|
|
46
|
+
}): Promise<import("./types/config.types").LogoutResponse>;
|
|
47
|
+
refreshToken(refreshToken: string, authStrategy?: AuthStrategy): Promise<import("./types/config.types").RefreshTokenResponse | null>;
|
|
48
|
+
validateTokenLocal(token: string, options?: TokenValidationOptions): Promise<TokenValidationResult>;
|
|
49
|
+
setKeycloakConfig(config: KeycloakConfig): void;
|
|
50
|
+
clearJwksCache(jwksUri?: string): void;
|
|
51
|
+
clearValidationCache(): void;
|
|
52
|
+
clearAllTokenCaches(): void;
|
|
53
|
+
getRoles(token: string, authStrategy?: AuthStrategy): Promise<string[]>;
|
|
54
|
+
hasRole(token: string, role: string, authStrategy?: AuthStrategy): Promise<boolean>;
|
|
55
|
+
hasAnyRole(token: string, roles: string[], authStrategy?: AuthStrategy): Promise<boolean>;
|
|
56
|
+
hasAllRoles(token: string, roles: string[], authStrategy?: AuthStrategy): Promise<boolean>;
|
|
57
|
+
refreshRoles(token: string, authStrategy?: AuthStrategy): Promise<string[]>;
|
|
58
|
+
getPermissions(token: string, authStrategy?: AuthStrategy): Promise<string[]>;
|
|
59
|
+
hasPermission(token: string, permission: string, authStrategy?: AuthStrategy): Promise<boolean>;
|
|
60
|
+
hasAnyPermission(token: string, permissions: string[], authStrategy?: AuthStrategy): Promise<boolean>;
|
|
61
|
+
hasAllPermissions(token: string, permissions: string[], authStrategy?: AuthStrategy): Promise<boolean>;
|
|
62
|
+
refreshPermissions(token: string, authStrategy?: AuthStrategy): Promise<string[]>;
|
|
63
|
+
clearPermissionsCache(token: string, authStrategy?: AuthStrategy): Promise<void>;
|
|
64
|
+
get log(): LoggerService;
|
|
65
|
+
get encryption(): EncryptionService;
|
|
66
|
+
get cache(): CacheService;
|
|
67
|
+
updateMyApplicationStatus(body: UpdateSelfStatusRequest, options?: {
|
|
68
|
+
envKey?: string;
|
|
69
|
+
authStrategy?: AuthStrategy;
|
|
70
|
+
}): Promise<UpdateSelfStatusResponse>;
|
|
71
|
+
getApplicationStatus(envKey: string, appKey: string, authStrategy?: AuthStrategy): Promise<ApplicationStatusResponse>;
|
|
72
|
+
getMyApplicationStatus(options?: {
|
|
73
|
+
envKey?: string;
|
|
74
|
+
appKey?: string;
|
|
75
|
+
}, authStrategy?: AuthStrategy): Promise<ApplicationStatusResponse>;
|
|
76
|
+
getConfig(): MisoClientConfig;
|
|
77
|
+
isRedisConnected(): boolean;
|
|
78
|
+
requestWithAuthStrategy<T>(method: "GET" | "POST" | "PUT" | "DELETE", url: string, authStrategy: AuthStrategy, data?: unknown, config?: import("axios").AxiosRequestConfig): Promise<T>;
|
|
79
|
+
createAuthStrategy(methods: ("bearer" | "client-token" | "client-credentials" | "api-key")[], bearerToken?: string, apiKey?: string): AuthStrategy;
|
|
80
|
+
getDefaultAuthStrategy(bearerToken?: string): AuthStrategy;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=miso-client.d.ts.map
|