@aifabrix/miso-client 3.8.2 → 3.9.0
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 +45 -0
- package/dist/index.d.ts +30 -157
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -163
- package/dist/index.js.map +1 -1
- package/dist/services/auth-error-handler.d.ts +21 -0
- package/dist/services/auth-error-handler.d.ts.map +1 -0
- package/dist/services/auth-error-handler.js +68 -0
- package/dist/services/auth-error-handler.js.map +1 -0
- package/dist/services/auth.service.d.ts +0 -1
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js +31 -298
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/logger/logger.service.d.ts +8 -80
- package/dist/services/logger/logger.service.d.ts.map +1 -1
- package/dist/services/logger/logger.service.js +8 -80
- package/dist/services/logger/logger.service.js.map +1 -1
- package/dist/types/filter-schema.types.d.ts +104 -0
- package/dist/types/filter-schema.types.d.ts.map +1 -0
- package/dist/types/filter-schema.types.js +40 -0
- package/dist/types/filter-schema.types.js.map +1 -0
- package/dist/types/filter.types.d.ts +1 -1
- package/dist/types/filter.types.d.ts.map +1 -1
- package/dist/types/filter.types.js.map +1 -1
- package/dist/utils/data-client-auth.d.ts +5 -37
- package/dist/utils/data-client-auth.d.ts.map +1 -1
- package/dist/utils/data-client-auth.js +98 -377
- package/dist/utils/data-client-auth.js.map +1 -1
- package/dist/utils/data-client-init.d.ts +46 -0
- package/dist/utils/data-client-init.d.ts.map +1 -0
- package/dist/utils/data-client-init.js +128 -0
- package/dist/utils/data-client-init.js.map +1 -0
- package/dist/utils/data-client-oauth.d.ts +20 -0
- package/dist/utils/data-client-oauth.d.ts.map +1 -0
- package/dist/utils/data-client-oauth.js +138 -0
- package/dist/utils/data-client-oauth.js.map +1 -0
- package/dist/utils/data-client-permissions.d.ts +63 -0
- package/dist/utils/data-client-permissions.d.ts.map +1 -0
- package/dist/utils/data-client-permissions.js +123 -0
- package/dist/utils/data-client-permissions.js.map +1 -0
- package/dist/utils/data-client-request.d.ts +1 -1
- package/dist/utils/data-client-request.d.ts.map +1 -1
- package/dist/utils/data-client-request.js +27 -235
- package/dist/utils/data-client-request.js.map +1 -1
- package/dist/utils/data-client-response.d.ts +40 -0
- package/dist/utils/data-client-response.d.ts.map +1 -0
- package/dist/utils/data-client-response.js +144 -0
- package/dist/utils/data-client-response.js.map +1 -0
- package/dist/utils/data-client-roles.d.ts +63 -0
- package/dist/utils/data-client-roles.d.ts.map +1 -0
- package/dist/utils/data-client-roles.js +123 -0
- package/dist/utils/data-client-roles.js.map +1 -0
- package/dist/utils/data-client.d.ts +0 -185
- package/dist/utils/data-client.d.ts.map +1 -1
- package/dist/utils/data-client.js +66 -505
- package/dist/utils/data-client.js.map +1 -1
- package/dist/utils/filter-colon.utils.d.ts +26 -0
- package/dist/utils/filter-colon.utils.d.ts.map +1 -0
- package/dist/utils/filter-colon.utils.js +112 -0
- package/dist/utils/filter-colon.utils.js.map +1 -0
- package/dist/utils/filter-schema.utils.d.ts +84 -0
- package/dist/utils/filter-schema.utils.d.ts.map +1 -0
- package/dist/utils/filter-schema.utils.js +381 -0
- package/dist/utils/filter-schema.utils.js.map +1 -0
- package/dist/utils/filter.utils.d.ts +9 -85
- package/dist/utils/filter.utils.d.ts.map +1 -1
- package/dist/utils/filter.utils.js +79 -138
- package/dist/utils/filter.utils.js.map +1 -1
- package/dist/utils/http-error-handler.d.ts +22 -0
- package/dist/utils/http-error-handler.d.ts.map +1 -0
- package/dist/utils/http-error-handler.js +84 -0
- package/dist/utils/http-error-handler.js.map +1 -0
- package/dist/utils/http-response-validator.d.ts +15 -0
- package/dist/utils/http-response-validator.d.ts.map +1 -0
- package/dist/utils/http-response-validator.js +42 -0
- package/dist/utils/http-response-validator.js.map +1 -0
- package/dist/utils/internal-http-client.d.ts +4 -22
- package/dist/utils/internal-http-client.d.ts.map +1 -1
- package/dist/utils/internal-http-client.js +53 -337
- package/dist/utils/internal-http-client.js.map +1 -1
- package/dist/utils/token-utils.d.ts.map +1 -1
- package/dist/utils/token-utils.js +1 -29
- package/dist/utils/token-utils.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,51 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.9.0] - 2026-01-14
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Enhanced Filter System** - Comprehensive filter parsing, validation, and SQL compilation
|
|
13
|
+
- **Dual format parsing**: Support for both colon format (`status:eq:active`) and JSON format (`{"status":{"eq":"active"}}`)
|
|
14
|
+
- **Schema-based validation**: Define filterable fields, allowed operators, and value types per resource
|
|
15
|
+
- **Type coercion**: Automatic value validation and conversion for string, number, boolean, uuid, timestamp, and enum types
|
|
16
|
+
- **SQL compilation**: Generate PostgreSQL-safe parameterized WHERE clauses with `compileFilter()`
|
|
17
|
+
- **Human-readable errors**: RFC 7807 compliant structured error responses with error codes (UNKNOWN_FIELD, INVALID_OPERATOR, INVALID_TYPE, etc.)
|
|
18
|
+
- New `ilike` operator for case-insensitive pattern matching
|
|
19
|
+
- New types: `FilterSchema`, `FilterFieldDefinition`, `FilterError`, `CompiledFilter`
|
|
20
|
+
- New utilities: `validateFilter()`, `coerceValue()`, `compileFilter()`, `createFilterSchema()`
|
|
21
|
+
- Filter meta-schema for validating custom filter schemas (`src/schemas/filter.schema.json`)
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- **Code Size Compliance** - Refactored large files to comply with 500-line guideline
|
|
26
|
+
- `data-client.ts`: 995 → 416 lines (extracted to helper modules)
|
|
27
|
+
- `data-client-request.ts`: 683 → 280 lines
|
|
28
|
+
- `data-client-auth.ts`: 654 → 290 lines
|
|
29
|
+
- `internal-http-client.ts`: 741 → 496 lines
|
|
30
|
+
- `auth.service.ts`: 825 → 462 lines
|
|
31
|
+
- `index.ts`: 681 → 472 lines
|
|
32
|
+
- `logger.service.ts`: 597 → 480 lines
|
|
33
|
+
|
|
34
|
+
- **Console Logging Audit** - Cleaned up debug logging
|
|
35
|
+
- Removed 10 debug `console.log` statements from `token-utils.ts` that could expose sensitive token data
|
|
36
|
+
- All remaining console calls are appropriate error/warning logs or guarded by debug checks
|
|
37
|
+
|
|
38
|
+
### Technical
|
|
39
|
+
|
|
40
|
+
- **New filter utilities**: `src/utils/filter-schema.utils.ts` (497 lines), `src/utils/filter-colon.utils.ts` (119 lines)
|
|
41
|
+
- **New filter types**: `src/types/filter-schema.types.ts` (148 lines)
|
|
42
|
+
- **New helper modules** for DataClient refactoring:
|
|
43
|
+
- `data-client-init.ts` - Initialization logic
|
|
44
|
+
- `data-client-permissions.ts` - Permission helpers
|
|
45
|
+
- `data-client-roles.ts` - Role helpers
|
|
46
|
+
- `data-client-response.ts` - Response processing
|
|
47
|
+
- `data-client-oauth.ts` - OAuth callback handling
|
|
48
|
+
- **New HTTP helpers**: `http-error-handler.ts`, `http-response-validator.ts`
|
|
49
|
+
- **New auth helper**: `auth-error-handler.ts` - Centralized auth error formatting
|
|
50
|
+
- **New tests**: `filter-colon-format.test.ts` (178 lines), `filter-schema.utils.test.ts` (545 lines)
|
|
51
|
+
- **Documentation**: Updated `docs/reference-utilities.md` with filter system examples
|
|
52
|
+
|
|
8
53
|
## [3.8.2] - 2026-01-12
|
|
9
54
|
|
|
10
55
|
### Added
|
package/dist/index.d.ts
CHANGED
|
@@ -50,165 +50,58 @@ export declare class MisoClient {
|
|
|
50
50
|
* @returns Validation result with valid flag and optional error message
|
|
51
51
|
*/
|
|
52
52
|
validateOrigin(req: Request, allowedOrigins?: string[]): OriginValidationResult;
|
|
53
|
-
/**
|
|
54
|
-
* Get environment token using client credentials
|
|
55
|
-
* This is called automatically by HttpClient but can be called manually
|
|
56
|
-
*/
|
|
53
|
+
/** Get environment token using client credentials */
|
|
57
54
|
getEnvironmentToken(): Promise<string>;
|
|
58
|
-
/**
|
|
59
|
-
* Initiate login flow by calling controller
|
|
60
|
-
* Returns the login URL and state for browser redirect or manual navigation
|
|
61
|
-
*
|
|
62
|
-
* Important: Your application only needs to know about your own app URLs and the miso-controller.
|
|
63
|
-
* The miso-controller manages all authentication flows internally, including OAuth callbacks with Keycloak.
|
|
64
|
-
* You don't need to handle OAuth callbacks in your application.
|
|
65
|
-
*
|
|
66
|
-
* @param params - Login parameters
|
|
67
|
-
* @param params.redirect - Required final destination URL in your application where the user should be redirected after successful authentication. This is a URL in your app (e.g., 'https://myapp.com/dashboard'). The miso-controller handles the OAuth callback internally and then redirects the user to this URL.
|
|
68
|
-
* @param params.state - Optional CSRF protection token (auto-generated by controller if omitted)
|
|
69
|
-
* @returns Login response with loginUrl (the Keycloak authentication URL) and state
|
|
70
|
-
*/
|
|
55
|
+
/** Initiate login flow - returns login URL for browser redirect */
|
|
71
56
|
login(params: {
|
|
72
57
|
redirect: string;
|
|
73
58
|
state?: string;
|
|
74
59
|
}): Promise<import("./types/config.types").LoginResponse>;
|
|
75
|
-
/**
|
|
76
|
-
* Validate token with controller
|
|
77
|
-
* @param token - User authentication token
|
|
78
|
-
* @param authStrategy - Optional authentication strategy override
|
|
79
|
-
*/
|
|
60
|
+
/** Validate token with controller */
|
|
80
61
|
validateToken(token: string, authStrategy?: AuthStrategy): Promise<boolean>;
|
|
81
|
-
/**
|
|
82
|
-
* Get user information from token
|
|
83
|
-
* @param token - User authentication token
|
|
84
|
-
* @param authStrategy - Optional authentication strategy override
|
|
85
|
-
*/
|
|
62
|
+
/** Get user information from token */
|
|
86
63
|
getUser(token: string, authStrategy?: AuthStrategy): Promise<UserInfo | null>;
|
|
87
|
-
/**
|
|
88
|
-
* Get user information from GET /api/v1/auth/user endpoint
|
|
89
|
-
* @param token - User authentication token
|
|
90
|
-
* @param authStrategy - Optional authentication strategy override
|
|
91
|
-
*/
|
|
64
|
+
/** Get user information from GET /api/v1/auth/user endpoint */
|
|
92
65
|
getUserInfo(token: string, authStrategy?: AuthStrategy): Promise<UserInfo | null>;
|
|
93
|
-
/**
|
|
94
|
-
* Check if user is authenticated
|
|
95
|
-
* @param token - User authentication token
|
|
96
|
-
* @param authStrategy - Optional authentication strategy override
|
|
97
|
-
*/
|
|
66
|
+
/** Check if user is authenticated */
|
|
98
67
|
isAuthenticated(token: string, authStrategy?: AuthStrategy): Promise<boolean>;
|
|
99
|
-
/**
|
|
100
|
-
* Logout user
|
|
101
|
-
* @param params - Logout parameters
|
|
102
|
-
* @param params.token - Access token to invalidate
|
|
103
|
-
* @returns Logout response with success message
|
|
104
|
-
*/
|
|
68
|
+
/** Logout user */
|
|
105
69
|
logout(params: {
|
|
106
70
|
token: string;
|
|
107
71
|
}): Promise<import("./types/config.types").LogoutResponse>;
|
|
108
|
-
/**
|
|
109
|
-
* Refresh user access token using refresh token
|
|
110
|
-
* @param refreshToken - Refresh token to exchange for new access token
|
|
111
|
-
* @param authStrategy - Optional authentication strategy override
|
|
112
|
-
* @returns New access token, refresh token, and expiration info, or null on error
|
|
113
|
-
*/
|
|
72
|
+
/** Refresh user access token using refresh token */
|
|
114
73
|
refreshToken(refreshToken: string, authStrategy?: AuthStrategy): Promise<import("./types/config.types").RefreshTokenResponse | null>;
|
|
115
|
-
/**
|
|
116
|
-
* Validate token locally using JWKS (no API call to controller)
|
|
117
|
-
* Results are cached for 1 minute, JWKS keys cached for 1 hour
|
|
118
|
-
* @param token - JWT token to validate
|
|
119
|
-
* @param options - Validation options (skipResultCache for high-security)
|
|
120
|
-
* @returns Validation result with payload or error
|
|
121
|
-
*/
|
|
74
|
+
/** Validate token locally using JWKS (no API call) */
|
|
122
75
|
validateTokenLocal(token: string, options?: TokenValidationOptions): Promise<TokenValidationResult>;
|
|
123
|
-
/**
|
|
124
|
-
* Set or update Keycloak configuration for local validation
|
|
125
|
-
* @param config - Keycloak configuration
|
|
126
|
-
*/
|
|
76
|
+
/** Set or update Keycloak configuration for local validation */
|
|
127
77
|
setKeycloakConfig(config: KeycloakConfig): void;
|
|
128
|
-
/**
|
|
129
|
-
* Clear JWKS cache (useful for key rotation scenarios)
|
|
130
|
-
* @param jwksUri - Specific URI to clear, or all if not provided
|
|
131
|
-
*/
|
|
78
|
+
/** Clear JWKS cache */
|
|
132
79
|
clearJwksCache(jwksUri?: string): void;
|
|
133
|
-
/**
|
|
134
|
-
* Clear validation result cache
|
|
135
|
-
*/
|
|
80
|
+
/** Clear validation result cache */
|
|
136
81
|
clearValidationCache(): void;
|
|
137
|
-
/**
|
|
138
|
-
* Clear all token validation caches (JWKS + results)
|
|
139
|
-
*/
|
|
82
|
+
/** Clear all token validation caches (JWKS + results) */
|
|
140
83
|
clearAllTokenCaches(): void;
|
|
141
|
-
/**
|
|
142
|
-
* Get user roles (cached in Redis if available)
|
|
143
|
-
* @param token - User authentication token
|
|
144
|
-
* @param authStrategy - Optional authentication strategy override
|
|
145
|
-
*/
|
|
84
|
+
/** Get user roles (cached if Redis available) */
|
|
146
85
|
getRoles(token: string, authStrategy?: AuthStrategy): Promise<string[]>;
|
|
147
|
-
/**
|
|
148
|
-
* Check if user has specific role
|
|
149
|
-
* @param token - User authentication token
|
|
150
|
-
* @param role - Role to check
|
|
151
|
-
* @param authStrategy - Optional authentication strategy override
|
|
152
|
-
*/
|
|
86
|
+
/** Check if user has specific role */
|
|
153
87
|
hasRole(token: string, role: string, authStrategy?: AuthStrategy): Promise<boolean>;
|
|
154
|
-
/**
|
|
155
|
-
* Check if user has any of the specified roles
|
|
156
|
-
* @param token - User authentication token
|
|
157
|
-
* @param roles - Roles to check
|
|
158
|
-
* @param authStrategy - Optional authentication strategy override
|
|
159
|
-
*/
|
|
88
|
+
/** Check if user has any of the specified roles */
|
|
160
89
|
hasAnyRole(token: string, roles: string[], authStrategy?: AuthStrategy): Promise<boolean>;
|
|
161
|
-
/**
|
|
162
|
-
* Check if user has all of the specified roles
|
|
163
|
-
* @param token - User authentication token
|
|
164
|
-
* @param roles - Roles to check
|
|
165
|
-
* @param authStrategy - Optional authentication strategy override
|
|
166
|
-
*/
|
|
90
|
+
/** Check if user has all of the specified roles */
|
|
167
91
|
hasAllRoles(token: string, roles: string[], authStrategy?: AuthStrategy): Promise<boolean>;
|
|
168
|
-
/**
|
|
169
|
-
* Force refresh roles from controller (bypass cache)
|
|
170
|
-
* @param token - User authentication token
|
|
171
|
-
* @param authStrategy - Optional authentication strategy override
|
|
172
|
-
*/
|
|
92
|
+
/** Force refresh roles from controller (bypass cache) */
|
|
173
93
|
refreshRoles(token: string, authStrategy?: AuthStrategy): Promise<string[]>;
|
|
174
|
-
/**
|
|
175
|
-
* Get user permissions (cached in Redis if available)
|
|
176
|
-
* @param token - User authentication token
|
|
177
|
-
* @param authStrategy - Optional authentication strategy override
|
|
178
|
-
*/
|
|
94
|
+
/** Get user permissions (cached if Redis available) */
|
|
179
95
|
getPermissions(token: string, authStrategy?: AuthStrategy): Promise<string[]>;
|
|
180
|
-
/**
|
|
181
|
-
* Check if user has specific permission
|
|
182
|
-
* @param token - User authentication token
|
|
183
|
-
* @param permission - Permission to check
|
|
184
|
-
* @param authStrategy - Optional authentication strategy override
|
|
185
|
-
*/
|
|
96
|
+
/** Check if user has specific permission */
|
|
186
97
|
hasPermission(token: string, permission: string, authStrategy?: AuthStrategy): Promise<boolean>;
|
|
187
|
-
/**
|
|
188
|
-
* Check if user has any of the specified permissions
|
|
189
|
-
* @param token - User authentication token
|
|
190
|
-
* @param permissions - Permissions to check
|
|
191
|
-
* @param authStrategy - Optional authentication strategy override
|
|
192
|
-
*/
|
|
98
|
+
/** Check if user has any of the specified permissions */
|
|
193
99
|
hasAnyPermission(token: string, permissions: string[], authStrategy?: AuthStrategy): Promise<boolean>;
|
|
194
|
-
/**
|
|
195
|
-
* Check if user has all of the specified permissions
|
|
196
|
-
* @param token - User authentication token
|
|
197
|
-
* @param permissions - Permissions to check
|
|
198
|
-
* @param authStrategy - Optional authentication strategy override
|
|
199
|
-
*/
|
|
100
|
+
/** Check if user has all of the specified permissions */
|
|
200
101
|
hasAllPermissions(token: string, permissions: string[], authStrategy?: AuthStrategy): Promise<boolean>;
|
|
201
|
-
/**
|
|
202
|
-
* Force refresh permissions from controller (bypass cache)
|
|
203
|
-
* @param token - User authentication token
|
|
204
|
-
* @param authStrategy - Optional authentication strategy override
|
|
205
|
-
*/
|
|
102
|
+
/** Force refresh permissions from controller (bypass cache) */
|
|
206
103
|
refreshPermissions(token: string, authStrategy?: AuthStrategy): Promise<string[]>;
|
|
207
|
-
/**
|
|
208
|
-
* Clear cached permissions for a user
|
|
209
|
-
* @param token - User authentication token
|
|
210
|
-
* @param authStrategy - Optional authentication strategy override
|
|
211
|
-
*/
|
|
104
|
+
/** Clear cached permissions for a user */
|
|
212
105
|
clearPermissionsCache(token: string, authStrategy?: AuthStrategy): Promise<void>;
|
|
213
106
|
/**
|
|
214
107
|
* Get logger service for application logging
|
|
@@ -222,40 +115,19 @@ export declare class MisoClient {
|
|
|
222
115
|
* Get current configuration
|
|
223
116
|
*/
|
|
224
117
|
getConfig(): MisoClientConfig;
|
|
225
|
-
/**
|
|
226
|
-
* Check if Redis is connected
|
|
227
|
-
*/
|
|
118
|
+
/** Check if Redis is connected */
|
|
228
119
|
isRedisConnected(): boolean;
|
|
229
|
-
/**
|
|
230
|
-
* Make request with authentication strategy
|
|
231
|
-
* Tries authentication methods in priority order based on strategy
|
|
232
|
-
* @param method - HTTP method
|
|
233
|
-
* @param url - Request URL
|
|
234
|
-
* @param authStrategy - Authentication strategy configuration
|
|
235
|
-
* @param data - Optional request data
|
|
236
|
-
* @param config - Optional Axios request config
|
|
237
|
-
* @returns Response data
|
|
238
|
-
*/
|
|
120
|
+
/** Make request with authentication strategy */
|
|
239
121
|
requestWithAuthStrategy<T>(method: "GET" | "POST" | "PUT" | "DELETE", url: string, authStrategy: AuthStrategy, data?: unknown, config?: import("axios").AxiosRequestConfig): Promise<T>;
|
|
240
|
-
/**
|
|
241
|
-
* Create authentication strategy helper
|
|
242
|
-
* @param methods - Array of authentication methods in priority order
|
|
243
|
-
* @param bearerToken - Optional bearer token
|
|
244
|
-
* @param apiKey - Optional API key
|
|
245
|
-
* @returns Authentication strategy
|
|
246
|
-
*/
|
|
122
|
+
/** Create authentication strategy helper */
|
|
247
123
|
createAuthStrategy(methods: ("bearer" | "client-token" | "client-credentials" | "api-key")[], bearerToken?: string, apiKey?: string): AuthStrategy;
|
|
248
|
-
/**
|
|
249
|
-
* Get default authentication strategy
|
|
250
|
-
* Uses bearer token and client token in that order
|
|
251
|
-
* @param bearerToken - Optional bearer token
|
|
252
|
-
* @returns Default authentication strategy
|
|
253
|
-
*/
|
|
124
|
+
/** Get default authentication strategy */
|
|
254
125
|
getDefaultAuthStrategy(bearerToken?: string): AuthStrategy;
|
|
255
126
|
}
|
|
256
127
|
export * from "./types/config.types";
|
|
257
128
|
export * from "./types/pagination.types";
|
|
258
129
|
export * from "./types/filter.types";
|
|
130
|
+
export * from "./types/filter-schema.types";
|
|
259
131
|
export * from "./types/sort.types";
|
|
260
132
|
export type { ErrorResponse as ErrorResponseFromErrors, ErrorEnvelope, } from "./types/errors.types";
|
|
261
133
|
export { AuthService } from "./services/auth.service";
|
|
@@ -283,6 +155,7 @@ export { extractRequestContext } from "./utils/request-context";
|
|
|
283
155
|
export type { RequestContext } from "./utils/request-context";
|
|
284
156
|
export * from "./utils/pagination.utils";
|
|
285
157
|
export * from "./utils/filter.utils";
|
|
158
|
+
export * from "./utils/filter-schema.utils";
|
|
286
159
|
export * from "./utils/sort.utils";
|
|
287
160
|
export { MisoClientError, ApiErrorException, transformError, handleApiError, } from "./utils/errors";
|
|
288
161
|
export { ResponseHelper, PaginationMeta, injectResponseHelpers, asyncHandler, asyncHandlerNamed, ValidationHelper, AppError, ApiError, ValidationError, ApiResponse, createSuccessResponse, createErrorResponse, ErrorLogger, setErrorLogger, handleRouteError, RBACErrorExtensions, getErrorTypeUri, getErrorTitle, sendErrorResponse, EncryptionUtil, createClientTokenEndpoint, hasConfig, loggerContextMiddleware, } from "./express";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAMxD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAwC,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACxG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACf,MAAM,gCAAgC,CAAC;AAExC,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,eAAe,CAAyB;IAChD,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,EAAE,gBAAgB;IA2DpC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAcjC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC;;OAEG;IACH,aAAa,IAAI,OAAO;IAMxB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE;QAAE,OAAO,EAAE;YAAE,aAAa,CAAC,EAAE,MAAM,CAAA;SAAE,CA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,CAAC;AAGrE,YAAY,EACV,SAAS,EACT,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -129,207 +129,101 @@ class MisoClient {
|
|
|
129
129
|
const origins = allowedOrigins ?? this.config.allowedOrigins;
|
|
130
130
|
return (0, origin_validator_1.validateOrigin)(req, origins);
|
|
131
131
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Get environment token using client credentials
|
|
134
|
-
* This is called automatically by HttpClient but can be called manually
|
|
135
|
-
*/
|
|
132
|
+
/** Get environment token using client credentials */
|
|
136
133
|
async getEnvironmentToken() {
|
|
137
134
|
return this.auth.getEnvironmentToken();
|
|
138
135
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Initiate login flow by calling controller
|
|
141
|
-
* Returns the login URL and state for browser redirect or manual navigation
|
|
142
|
-
*
|
|
143
|
-
* Important: Your application only needs to know about your own app URLs and the miso-controller.
|
|
144
|
-
* The miso-controller manages all authentication flows internally, including OAuth callbacks with Keycloak.
|
|
145
|
-
* You don't need to handle OAuth callbacks in your application.
|
|
146
|
-
*
|
|
147
|
-
* @param params - Login parameters
|
|
148
|
-
* @param params.redirect - Required final destination URL in your application where the user should be redirected after successful authentication. This is a URL in your app (e.g., 'https://myapp.com/dashboard'). The miso-controller handles the OAuth callback internally and then redirects the user to this URL.
|
|
149
|
-
* @param params.state - Optional CSRF protection token (auto-generated by controller if omitted)
|
|
150
|
-
* @returns Login response with loginUrl (the Keycloak authentication URL) and state
|
|
151
|
-
*/
|
|
136
|
+
/** Initiate login flow - returns login URL for browser redirect */
|
|
152
137
|
async login(params) {
|
|
153
138
|
return this.auth.login(params);
|
|
154
139
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Validate token with controller
|
|
157
|
-
* @param token - User authentication token
|
|
158
|
-
* @param authStrategy - Optional authentication strategy override
|
|
159
|
-
*/
|
|
140
|
+
/** Validate token with controller */
|
|
160
141
|
async validateToken(token, authStrategy) {
|
|
161
142
|
return this.auth.validateToken(token, authStrategy);
|
|
162
143
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Get user information from token
|
|
165
|
-
* @param token - User authentication token
|
|
166
|
-
* @param authStrategy - Optional authentication strategy override
|
|
167
|
-
*/
|
|
144
|
+
/** Get user information from token */
|
|
168
145
|
async getUser(token, authStrategy) {
|
|
169
146
|
return this.auth.getUser(token, authStrategy);
|
|
170
147
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Get user information from GET /api/v1/auth/user endpoint
|
|
173
|
-
* @param token - User authentication token
|
|
174
|
-
* @param authStrategy - Optional authentication strategy override
|
|
175
|
-
*/
|
|
148
|
+
/** Get user information from GET /api/v1/auth/user endpoint */
|
|
176
149
|
async getUserInfo(token, authStrategy) {
|
|
177
150
|
return this.auth.getUserInfo(token, authStrategy);
|
|
178
151
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Check if user is authenticated
|
|
181
|
-
* @param token - User authentication token
|
|
182
|
-
* @param authStrategy - Optional authentication strategy override
|
|
183
|
-
*/
|
|
152
|
+
/** Check if user is authenticated */
|
|
184
153
|
async isAuthenticated(token, authStrategy) {
|
|
185
154
|
return this.auth.isAuthenticated(token, authStrategy);
|
|
186
155
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Logout user
|
|
189
|
-
* @param params - Logout parameters
|
|
190
|
-
* @param params.token - Access token to invalidate
|
|
191
|
-
* @returns Logout response with success message
|
|
192
|
-
*/
|
|
156
|
+
/** Logout user */
|
|
193
157
|
async logout(params) {
|
|
194
158
|
return this.auth.logout(params);
|
|
195
159
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Refresh user access token using refresh token
|
|
198
|
-
* @param refreshToken - Refresh token to exchange for new access token
|
|
199
|
-
* @param authStrategy - Optional authentication strategy override
|
|
200
|
-
* @returns New access token, refresh token, and expiration info, or null on error
|
|
201
|
-
*/
|
|
160
|
+
/** Refresh user access token using refresh token */
|
|
202
161
|
async refreshToken(refreshToken, authStrategy) {
|
|
203
162
|
return this.auth.refreshToken(refreshToken, authStrategy);
|
|
204
163
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Validate token locally using JWKS (no API call to controller)
|
|
207
|
-
* Results are cached for 1 minute, JWKS keys cached for 1 hour
|
|
208
|
-
* @param token - JWT token to validate
|
|
209
|
-
* @param options - Validation options (skipResultCache for high-security)
|
|
210
|
-
* @returns Validation result with payload or error
|
|
211
|
-
*/
|
|
164
|
+
/** Validate token locally using JWKS (no API call) */
|
|
212
165
|
async validateTokenLocal(token, options) {
|
|
213
166
|
return this.tokenValidation.validateTokenLocal(token, options);
|
|
214
167
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Set or update Keycloak configuration for local validation
|
|
217
|
-
* @param config - Keycloak configuration
|
|
218
|
-
*/
|
|
168
|
+
/** Set or update Keycloak configuration for local validation */
|
|
219
169
|
setKeycloakConfig(config) {
|
|
220
170
|
this.tokenValidation.setKeycloakConfig(config);
|
|
221
171
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Clear JWKS cache (useful for key rotation scenarios)
|
|
224
|
-
* @param jwksUri - Specific URI to clear, or all if not provided
|
|
225
|
-
*/
|
|
172
|
+
/** Clear JWKS cache */
|
|
226
173
|
clearJwksCache(jwksUri) {
|
|
227
174
|
this.tokenValidation.clearCache(jwksUri);
|
|
228
175
|
}
|
|
229
|
-
/**
|
|
230
|
-
* Clear validation result cache
|
|
231
|
-
*/
|
|
176
|
+
/** Clear validation result cache */
|
|
232
177
|
clearValidationCache() {
|
|
233
178
|
this.tokenValidation.clearResultCache();
|
|
234
179
|
}
|
|
235
|
-
/**
|
|
236
|
-
* Clear all token validation caches (JWKS + results)
|
|
237
|
-
*/
|
|
180
|
+
/** Clear all token validation caches (JWKS + results) */
|
|
238
181
|
clearAllTokenCaches() {
|
|
239
182
|
this.tokenValidation.clearAllCaches();
|
|
240
183
|
}
|
|
241
|
-
// ====================
|
|
242
|
-
/**
|
|
243
|
-
* Get user roles (cached in Redis if available)
|
|
244
|
-
* @param token - User authentication token
|
|
245
|
-
* @param authStrategy - Optional authentication strategy override
|
|
246
|
-
*/
|
|
184
|
+
// ==================== ROLE METHODS ====================
|
|
185
|
+
/** Get user roles (cached if Redis available) */
|
|
247
186
|
async getRoles(token, authStrategy) {
|
|
248
187
|
return this.roles.getRoles(token, authStrategy);
|
|
249
188
|
}
|
|
250
|
-
/**
|
|
251
|
-
* Check if user has specific role
|
|
252
|
-
* @param token - User authentication token
|
|
253
|
-
* @param role - Role to check
|
|
254
|
-
* @param authStrategy - Optional authentication strategy override
|
|
255
|
-
*/
|
|
189
|
+
/** Check if user has specific role */
|
|
256
190
|
async hasRole(token, role, authStrategy) {
|
|
257
191
|
return this.roles.hasRole(token, role, authStrategy);
|
|
258
192
|
}
|
|
259
|
-
/**
|
|
260
|
-
* Check if user has any of the specified roles
|
|
261
|
-
* @param token - User authentication token
|
|
262
|
-
* @param roles - Roles to check
|
|
263
|
-
* @param authStrategy - Optional authentication strategy override
|
|
264
|
-
*/
|
|
193
|
+
/** Check if user has any of the specified roles */
|
|
265
194
|
async hasAnyRole(token, roles, authStrategy) {
|
|
266
195
|
return this.roles.hasAnyRole(token, roles, authStrategy);
|
|
267
196
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Check if user has all of the specified roles
|
|
270
|
-
* @param token - User authentication token
|
|
271
|
-
* @param roles - Roles to check
|
|
272
|
-
* @param authStrategy - Optional authentication strategy override
|
|
273
|
-
*/
|
|
197
|
+
/** Check if user has all of the specified roles */
|
|
274
198
|
async hasAllRoles(token, roles, authStrategy) {
|
|
275
199
|
return this.roles.hasAllRoles(token, roles, authStrategy);
|
|
276
200
|
}
|
|
277
|
-
/**
|
|
278
|
-
* Force refresh roles from controller (bypass cache)
|
|
279
|
-
* @param token - User authentication token
|
|
280
|
-
* @param authStrategy - Optional authentication strategy override
|
|
281
|
-
*/
|
|
201
|
+
/** Force refresh roles from controller (bypass cache) */
|
|
282
202
|
async refreshRoles(token, authStrategy) {
|
|
283
203
|
return this.roles.refreshRoles(token, authStrategy);
|
|
284
204
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
* @param token - User authentication token
|
|
288
|
-
* @param authStrategy - Optional authentication strategy override
|
|
289
|
-
*/
|
|
205
|
+
// ==================== PERMISSION METHODS ====================
|
|
206
|
+
/** Get user permissions (cached if Redis available) */
|
|
290
207
|
async getPermissions(token, authStrategy) {
|
|
291
208
|
return this.permissions.getPermissions(token, authStrategy);
|
|
292
209
|
}
|
|
293
|
-
/**
|
|
294
|
-
* Check if user has specific permission
|
|
295
|
-
* @param token - User authentication token
|
|
296
|
-
* @param permission - Permission to check
|
|
297
|
-
* @param authStrategy - Optional authentication strategy override
|
|
298
|
-
*/
|
|
210
|
+
/** Check if user has specific permission */
|
|
299
211
|
async hasPermission(token, permission, authStrategy) {
|
|
300
212
|
return this.permissions.hasPermission(token, permission, authStrategy);
|
|
301
213
|
}
|
|
302
|
-
/**
|
|
303
|
-
* Check if user has any of the specified permissions
|
|
304
|
-
* @param token - User authentication token
|
|
305
|
-
* @param permissions - Permissions to check
|
|
306
|
-
* @param authStrategy - Optional authentication strategy override
|
|
307
|
-
*/
|
|
214
|
+
/** Check if user has any of the specified permissions */
|
|
308
215
|
async hasAnyPermission(token, permissions, authStrategy) {
|
|
309
216
|
return this.permissions.hasAnyPermission(token, permissions, authStrategy);
|
|
310
217
|
}
|
|
311
|
-
/**
|
|
312
|
-
* Check if user has all of the specified permissions
|
|
313
|
-
* @param token - User authentication token
|
|
314
|
-
* @param permissions - Permissions to check
|
|
315
|
-
* @param authStrategy - Optional authentication strategy override
|
|
316
|
-
*/
|
|
218
|
+
/** Check if user has all of the specified permissions */
|
|
317
219
|
async hasAllPermissions(token, permissions, authStrategy) {
|
|
318
220
|
return this.permissions.hasAllPermissions(token, permissions, authStrategy);
|
|
319
221
|
}
|
|
320
|
-
/**
|
|
321
|
-
* Force refresh permissions from controller (bypass cache)
|
|
322
|
-
* @param token - User authentication token
|
|
323
|
-
* @param authStrategy - Optional authentication strategy override
|
|
324
|
-
*/
|
|
222
|
+
/** Force refresh permissions from controller (bypass cache) */
|
|
325
223
|
async refreshPermissions(token, authStrategy) {
|
|
326
224
|
return this.permissions.refreshPermissions(token, authStrategy);
|
|
327
225
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Clear cached permissions for a user
|
|
330
|
-
* @param token - User authentication token
|
|
331
|
-
* @param authStrategy - Optional authentication strategy override
|
|
332
|
-
*/
|
|
226
|
+
/** Clear cached permissions for a user */
|
|
333
227
|
async clearPermissionsCache(token, authStrategy) {
|
|
334
228
|
return this.permissions.clearPermissionsCache(token, authStrategy);
|
|
335
229
|
}
|
|
@@ -357,45 +251,19 @@ class MisoClient {
|
|
|
357
251
|
getConfig() {
|
|
358
252
|
return { ...this.config };
|
|
359
253
|
}
|
|
360
|
-
/**
|
|
361
|
-
* Check if Redis is connected
|
|
362
|
-
*/
|
|
254
|
+
/** Check if Redis is connected */
|
|
363
255
|
isRedisConnected() {
|
|
364
256
|
return this.redis.isConnected();
|
|
365
257
|
}
|
|
366
|
-
/**
|
|
367
|
-
* Make request with authentication strategy
|
|
368
|
-
* Tries authentication methods in priority order based on strategy
|
|
369
|
-
* @param method - HTTP method
|
|
370
|
-
* @param url - Request URL
|
|
371
|
-
* @param authStrategy - Authentication strategy configuration
|
|
372
|
-
* @param data - Optional request data
|
|
373
|
-
* @param config - Optional Axios request config
|
|
374
|
-
* @returns Response data
|
|
375
|
-
*/
|
|
258
|
+
/** Make request with authentication strategy */
|
|
376
259
|
async requestWithAuthStrategy(method, url, authStrategy, data, config) {
|
|
377
260
|
return this.httpClient.requestWithAuthStrategy(method, url, authStrategy, data, config);
|
|
378
261
|
}
|
|
379
|
-
/**
|
|
380
|
-
* Create authentication strategy helper
|
|
381
|
-
* @param methods - Array of authentication methods in priority order
|
|
382
|
-
* @param bearerToken - Optional bearer token
|
|
383
|
-
* @param apiKey - Optional API key
|
|
384
|
-
* @returns Authentication strategy
|
|
385
|
-
*/
|
|
262
|
+
/** Create authentication strategy helper */
|
|
386
263
|
createAuthStrategy(methods, bearerToken, apiKey) {
|
|
387
|
-
return {
|
|
388
|
-
methods,
|
|
389
|
-
bearerToken,
|
|
390
|
-
apiKey,
|
|
391
|
-
};
|
|
264
|
+
return { methods, bearerToken, apiKey };
|
|
392
265
|
}
|
|
393
|
-
/**
|
|
394
|
-
* Get default authentication strategy
|
|
395
|
-
* Uses bearer token and client token in that order
|
|
396
|
-
* @param bearerToken - Optional bearer token
|
|
397
|
-
* @returns Default authentication strategy
|
|
398
|
-
*/
|
|
266
|
+
/** Get default authentication strategy */
|
|
399
267
|
getDefaultAuthStrategy(bearerToken) {
|
|
400
268
|
return auth_strategy_1.AuthStrategyHandler.getDefaultStrategy(bearerToken);
|
|
401
269
|
}
|
|
@@ -406,6 +274,7 @@ __exportStar(require("./types/config.types"), exports);
|
|
|
406
274
|
// Export pagination, filter, sort types
|
|
407
275
|
__exportStar(require("./types/pagination.types"), exports);
|
|
408
276
|
__exportStar(require("./types/filter.types"), exports);
|
|
277
|
+
__exportStar(require("./types/filter-schema.types"), exports);
|
|
409
278
|
__exportStar(require("./types/sort.types"), exports);
|
|
410
279
|
// Export services for advanced usage
|
|
411
280
|
var auth_service_2 = require("./services/auth.service");
|
|
@@ -453,6 +322,7 @@ Object.defineProperty(exports, "extractRequestContext", { enumerable: true, get:
|
|
|
453
322
|
// Export pagination, filter, sort utilities
|
|
454
323
|
__exportStar(require("./utils/pagination.utils"), exports);
|
|
455
324
|
__exportStar(require("./utils/filter.utils"), exports);
|
|
325
|
+
__exportStar(require("./utils/filter-schema.utils"), exports);
|
|
456
326
|
__exportStar(require("./utils/sort.utils"), exports);
|
|
457
327
|
// Export error classes and utilities
|
|
458
328
|
var errors_1 = require("./utils/errors");
|