@aifabrix/miso-client 1.2.0 → 1.4.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/README.md +55 -0
- package/dist/examples/custom-sensitive-fields.example.d.ts +48 -0
- package/dist/examples/custom-sensitive-fields.example.d.ts.map +1 -0
- package/dist/examples/custom-sensitive-fields.example.js +31 -0
- package/dist/examples/custom-sensitive-fields.example.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +24 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/types/config.types.d.ts +17 -0
- package/dist/src/types/config.types.d.ts.map +1 -1
- package/dist/src/types/config.types.js +28 -0
- package/dist/src/types/config.types.js.map +1 -1
- package/dist/src/utils/config-loader.d.ts.map +1 -1
- package/dist/src/utils/config-loader.js +4 -0
- package/dist/src/utils/config-loader.js.map +1 -1
- package/dist/src/utils/data-masker.d.ts +20 -1
- package/dist/src/utils/data-masker.d.ts.map +1 -1
- package/dist/src/utils/data-masker.js +53 -27
- package/dist/src/utils/data-masker.js.map +1 -1
- package/dist/src/utils/errors.d.ts +16 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +38 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/http-client.d.ts +20 -11
- package/dist/src/utils/http-client.d.ts.map +1 -1
- package/dist/src/utils/http-client.js +153 -107
- package/dist/src/utils/http-client.js.map +1 -1
- package/dist/src/utils/internal-http-client.d.ts +49 -0
- package/dist/src/utils/internal-http-client.d.ts.map +1 -0
- package/dist/src/utils/internal-http-client.js +333 -0
- package/dist/src/utils/internal-http-client.js.map +1 -0
- package/dist/src/utils/sensitive-fields.config.json +67 -0
- package/dist/src/utils/sensitive-fields.loader.d.ts +29 -0
- package/dist/src/utils/sensitive-fields.loader.d.ts.map +1 -0
- package/dist/src/utils/sensitive-fields.loader.js +246 -0
- package/dist/src/utils/sensitive-fields.loader.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Internal HTTP client utility for controller communication
|
|
4
|
+
* This is the base HTTP client without audit/debug logging
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.InternalHttpClient = void 0;
|
|
41
|
+
const axios_1 = __importStar(require("axios"));
|
|
42
|
+
const config_types_1 = require("../types/config.types");
|
|
43
|
+
const errors_1 = require("./errors");
|
|
44
|
+
class InternalHttpClient {
|
|
45
|
+
constructor(config) {
|
|
46
|
+
this.clientToken = null;
|
|
47
|
+
this.tokenExpiresAt = null;
|
|
48
|
+
this.tokenRefreshPromise = null;
|
|
49
|
+
this.config = config;
|
|
50
|
+
this.axios = axios_1.default.create({
|
|
51
|
+
baseURL: config.controllerUrl,
|
|
52
|
+
timeout: 30000,
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json'
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
// Interceptor adds client token (or fetches it if needed)
|
|
58
|
+
this.axios.interceptors.request.use(async (config) => {
|
|
59
|
+
config.headers = config.headers || {};
|
|
60
|
+
// Get client token (fetch if needed)
|
|
61
|
+
const token = await this.getClientToken();
|
|
62
|
+
if (token) {
|
|
63
|
+
config.headers['x-client-token'] = token;
|
|
64
|
+
}
|
|
65
|
+
return config;
|
|
66
|
+
}, (error) => Promise.reject(error));
|
|
67
|
+
// Add response interceptor for error handling
|
|
68
|
+
this.axios.interceptors.response.use((response) => response, (error) => {
|
|
69
|
+
if (error.response?.status === 401) {
|
|
70
|
+
// Enhance error with authentication context
|
|
71
|
+
error.message = 'Authentication failed - token may be invalid';
|
|
72
|
+
// Clear token on 401 to force refresh
|
|
73
|
+
this.clientToken = null;
|
|
74
|
+
this.tokenExpiresAt = null;
|
|
75
|
+
}
|
|
76
|
+
// Note: Don't convert to MisoClientError here - let the method handlers do it
|
|
77
|
+
// This preserves the original error for the try-catch blocks in each method
|
|
78
|
+
return Promise.reject(error);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get client token, fetching if needed
|
|
83
|
+
* Proactively refreshes if token will expire within 60 seconds
|
|
84
|
+
*/
|
|
85
|
+
async getClientToken() {
|
|
86
|
+
const now = new Date();
|
|
87
|
+
// If token exists and not expired (with 60s buffer for proactive refresh), return it
|
|
88
|
+
if (this.clientToken && this.tokenExpiresAt && this.tokenExpiresAt > new Date(now.getTime() + 60000)) {
|
|
89
|
+
return this.clientToken;
|
|
90
|
+
}
|
|
91
|
+
// If refresh is already in progress, wait for it
|
|
92
|
+
if (this.tokenRefreshPromise) {
|
|
93
|
+
return this.tokenRefreshPromise;
|
|
94
|
+
}
|
|
95
|
+
// Fetch new token (either expired or about to expire soon)
|
|
96
|
+
this.tokenRefreshPromise = this.fetchClientToken();
|
|
97
|
+
try {
|
|
98
|
+
const token = await this.tokenRefreshPromise;
|
|
99
|
+
return token;
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
this.tokenRefreshPromise = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Fetch client token from controller
|
|
107
|
+
*/
|
|
108
|
+
async fetchClientToken() {
|
|
109
|
+
try {
|
|
110
|
+
// Create a temporary axios instance without interceptors to avoid recursion
|
|
111
|
+
const tempAxios = axios_1.default.create({
|
|
112
|
+
baseURL: this.config.controllerUrl,
|
|
113
|
+
timeout: 30000,
|
|
114
|
+
headers: {
|
|
115
|
+
'Content-Type': 'application/json',
|
|
116
|
+
'X-Client-Id': this.config.clientId,
|
|
117
|
+
'X-Client-Secret': this.config.clientSecret
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const response = await tempAxios.post('/api/auth/token');
|
|
121
|
+
if (response.data.success && response.data.token) {
|
|
122
|
+
this.clientToken = response.data.token;
|
|
123
|
+
// Set expiration with 30 second buffer before actual expiration
|
|
124
|
+
const expiresIn = response.data.expiresIn - 30;
|
|
125
|
+
this.tokenExpiresAt = new Date(Date.now() + expiresIn * 1000);
|
|
126
|
+
return this.clientToken;
|
|
127
|
+
}
|
|
128
|
+
throw new Error('Failed to get client token: Invalid response');
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
throw new Error('Failed to get client token: ' + (error instanceof Error ? error.message : 'Unknown error'));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Check if error is an AxiosError (supports both instanceof and isAxiosError property)
|
|
136
|
+
*/
|
|
137
|
+
isAxiosError(error) {
|
|
138
|
+
if (error instanceof axios_1.AxiosError) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
// Support for mocked errors in tests
|
|
142
|
+
if (typeof error === 'object' && error !== null && 'isAxiosError' in error) {
|
|
143
|
+
return error.isAxiosError === true;
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Parse error response from AxiosError
|
|
149
|
+
* Attempts to parse structured ErrorResponse, falls back to null if parsing fails
|
|
150
|
+
*/
|
|
151
|
+
parseErrorResponse(error, requestUrl) {
|
|
152
|
+
try {
|
|
153
|
+
// Check if response data exists
|
|
154
|
+
if (!error.response?.data) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const data = error.response.data;
|
|
158
|
+
// If data is already an object, check if it matches ErrorResponse structure
|
|
159
|
+
if (typeof data === 'object' && data !== null) {
|
|
160
|
+
// Normalize statusCode field (support both camelCase and snake_case)
|
|
161
|
+
const normalized = { ...data };
|
|
162
|
+
if (normalized.status_code && !normalized.statusCode) {
|
|
163
|
+
normalized.statusCode = normalized.status_code;
|
|
164
|
+
}
|
|
165
|
+
// Validate using type guard
|
|
166
|
+
if ((0, config_types_1.isErrorResponse)(normalized)) {
|
|
167
|
+
const errorResponse = {
|
|
168
|
+
errors: normalized.errors,
|
|
169
|
+
type: normalized.type,
|
|
170
|
+
title: normalized.title,
|
|
171
|
+
statusCode: normalized.statusCode,
|
|
172
|
+
instance: normalized.instance || requestUrl
|
|
173
|
+
};
|
|
174
|
+
return errorResponse;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// If data is a string, try to parse as JSON
|
|
178
|
+
if (typeof data === 'string') {
|
|
179
|
+
try {
|
|
180
|
+
const parsed = JSON.parse(data);
|
|
181
|
+
const normalized = parsed;
|
|
182
|
+
if (normalized.status_code && !normalized.statusCode) {
|
|
183
|
+
normalized.statusCode = normalized.status_code;
|
|
184
|
+
}
|
|
185
|
+
if ((0, config_types_1.isErrorResponse)(normalized)) {
|
|
186
|
+
const errorResponse = {
|
|
187
|
+
errors: normalized.errors,
|
|
188
|
+
type: normalized.type,
|
|
189
|
+
title: normalized.title,
|
|
190
|
+
statusCode: normalized.statusCode,
|
|
191
|
+
instance: normalized.instance || requestUrl
|
|
192
|
+
};
|
|
193
|
+
return errorResponse;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
// JSON parse failed, return null
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
// Any parsing error, return null
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Create MisoClientError from AxiosError
|
|
210
|
+
* Parses structured error response if available, falls back to errorBody
|
|
211
|
+
*/
|
|
212
|
+
createMisoClientError(error, requestUrl) {
|
|
213
|
+
// Extract status code
|
|
214
|
+
const statusCode = error.response?.status;
|
|
215
|
+
// Try to parse structured error response
|
|
216
|
+
const errorResponse = this.parseErrorResponse(error, requestUrl);
|
|
217
|
+
// Extract errorBody for backward compatibility
|
|
218
|
+
let errorBody;
|
|
219
|
+
if (error.response?.data && typeof error.response.data === 'object') {
|
|
220
|
+
errorBody = error.response.data;
|
|
221
|
+
}
|
|
222
|
+
// Generate default message
|
|
223
|
+
let message = error.message || 'Request failed';
|
|
224
|
+
if (error.response) {
|
|
225
|
+
message = error.response.statusText || `Request failed with status code ${statusCode}`;
|
|
226
|
+
}
|
|
227
|
+
// Create MisoClientError (convert null to undefined)
|
|
228
|
+
return new errors_1.MisoClientError(message, errorResponse || undefined, errorBody, statusCode);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get access to internal axios instance (for interceptors)
|
|
232
|
+
*/
|
|
233
|
+
getAxiosInstance() {
|
|
234
|
+
return this.axios;
|
|
235
|
+
}
|
|
236
|
+
async get(url, config) {
|
|
237
|
+
try {
|
|
238
|
+
const response = await this.axios.get(url, config);
|
|
239
|
+
return response.data;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
if (this.isAxiosError(error)) {
|
|
243
|
+
const requestUrl = error.config?.url || url;
|
|
244
|
+
throw this.createMisoClientError(error, requestUrl);
|
|
245
|
+
}
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async post(url, data, config) {
|
|
250
|
+
try {
|
|
251
|
+
const response = await this.axios.post(url, data, config);
|
|
252
|
+
return response.data;
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
if (this.isAxiosError(error)) {
|
|
256
|
+
const requestUrl = error.config?.url || url;
|
|
257
|
+
throw this.createMisoClientError(error, requestUrl);
|
|
258
|
+
}
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async put(url, data, config) {
|
|
263
|
+
try {
|
|
264
|
+
const response = await this.axios.put(url, data, config);
|
|
265
|
+
return response.data;
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
if (this.isAxiosError(error)) {
|
|
269
|
+
const requestUrl = error.config?.url || url;
|
|
270
|
+
throw this.createMisoClientError(error, requestUrl);
|
|
271
|
+
}
|
|
272
|
+
throw error;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async delete(url, config) {
|
|
276
|
+
try {
|
|
277
|
+
const response = await this.axios.delete(url, config);
|
|
278
|
+
return response.data;
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
if (this.isAxiosError(error)) {
|
|
282
|
+
const requestUrl = error.config?.url || url;
|
|
283
|
+
throw this.createMisoClientError(error, requestUrl);
|
|
284
|
+
}
|
|
285
|
+
throw error;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
// Generic method for all requests (uses client credentials)
|
|
289
|
+
async request(method, url, data, config) {
|
|
290
|
+
switch (method) {
|
|
291
|
+
case 'GET':
|
|
292
|
+
return this.get(url, config);
|
|
293
|
+
case 'POST':
|
|
294
|
+
return this.post(url, data, config);
|
|
295
|
+
case 'PUT':
|
|
296
|
+
return this.put(url, data, config);
|
|
297
|
+
case 'DELETE':
|
|
298
|
+
return this.delete(url, config);
|
|
299
|
+
default:
|
|
300
|
+
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// For requests that need Bearer token (user auth)
|
|
304
|
+
// IMPORTANT: Client token is sent as x-client-token header (via interceptor)
|
|
305
|
+
// User token is sent as Authorization: Bearer header (this method parameter)
|
|
306
|
+
// These are two separate tokens for different purposes
|
|
307
|
+
async authenticatedRequest(method, url, token, // User authentication token (sent as Bearer token)
|
|
308
|
+
data, config) {
|
|
309
|
+
const requestConfig = {
|
|
310
|
+
...config,
|
|
311
|
+
headers: {
|
|
312
|
+
...config?.headers,
|
|
313
|
+
// Add Bearer token for user authentication
|
|
314
|
+
// x-client-token is automatically added by interceptor (not a Bearer token)
|
|
315
|
+
Authorization: `Bearer ${token}`
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
switch (method) {
|
|
319
|
+
case 'GET':
|
|
320
|
+
return this.get(url, requestConfig);
|
|
321
|
+
case 'POST':
|
|
322
|
+
return this.post(url, data, requestConfig);
|
|
323
|
+
case 'PUT':
|
|
324
|
+
return this.put(url, data, requestConfig);
|
|
325
|
+
case 'DELETE':
|
|
326
|
+
return this.delete(url, requestConfig);
|
|
327
|
+
default:
|
|
328
|
+
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
exports.InternalHttpClient = InternalHttpClient;
|
|
333
|
+
//# sourceMappingURL=internal-http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-http-client.js","sourceRoot":"","sources":["../../../src/utils/internal-http-client.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAMe;AACf,wDAA8G;AAC9G,qCAA2C;AAE3C,MAAa,kBAAkB;IAO7B,YAAY,MAAwB;QAJ5B,gBAAW,GAAkB,IAAI,CAAC;QAClC,mBAAc,GAAgB,IAAI,CAAC;QACnC,wBAAmB,GAA2B,IAAI,CAAC;QAGzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,KAAK,GAAG,eAAK,CAAC,MAAM,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC,aAAa;YAC7B,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,0DAA0D;QAC1D,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CACjC,KAAK,EAAE,MAAkC,EAAE,EAAE;YAC3C,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;YAEtC,qCAAqC;YACrC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC;YAC3C,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,CAAC,KAAiB,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAC7C,CAAC;QAEF,8CAA8C;QAC9C,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG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M,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF;AA7UD,gDA6UC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"description": "ISO 27001 compliant sensitive fields configuration for data masking",
|
|
4
|
+
"categories": {
|
|
5
|
+
"authentication": [
|
|
6
|
+
"password",
|
|
7
|
+
"passwd",
|
|
8
|
+
"pwd",
|
|
9
|
+
"secret",
|
|
10
|
+
"token",
|
|
11
|
+
"key",
|
|
12
|
+
"auth",
|
|
13
|
+
"authorization",
|
|
14
|
+
"cookie",
|
|
15
|
+
"session",
|
|
16
|
+
"apiKey",
|
|
17
|
+
"accessToken",
|
|
18
|
+
"refreshToken"
|
|
19
|
+
],
|
|
20
|
+
"pii": [
|
|
21
|
+
"email",
|
|
22
|
+
"emailAddress",
|
|
23
|
+
"phone",
|
|
24
|
+
"phoneNumber",
|
|
25
|
+
"telephone",
|
|
26
|
+
"mobile",
|
|
27
|
+
"cellPhone",
|
|
28
|
+
"ssn",
|
|
29
|
+
"socialSecurityNumber",
|
|
30
|
+
"taxId",
|
|
31
|
+
"taxIdentification"
|
|
32
|
+
],
|
|
33
|
+
"financial": [
|
|
34
|
+
"creditCard",
|
|
35
|
+
"cc",
|
|
36
|
+
"cardNumber",
|
|
37
|
+
"cvv",
|
|
38
|
+
"cvv2",
|
|
39
|
+
"cvc",
|
|
40
|
+
"pin",
|
|
41
|
+
"bankAccount",
|
|
42
|
+
"bankAccountNumber",
|
|
43
|
+
"routingNumber",
|
|
44
|
+
"iban",
|
|
45
|
+
"swift",
|
|
46
|
+
"accountNumber"
|
|
47
|
+
],
|
|
48
|
+
"security": [
|
|
49
|
+
"otp",
|
|
50
|
+
"oneTimePassword",
|
|
51
|
+
"privateKey",
|
|
52
|
+
"publicKey",
|
|
53
|
+
"encryptionKey",
|
|
54
|
+
"decryptionKey"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"fieldPatterns": [
|
|
58
|
+
"password",
|
|
59
|
+
"secret",
|
|
60
|
+
"token",
|
|
61
|
+
"key",
|
|
62
|
+
"ssn",
|
|
63
|
+
"creditcard",
|
|
64
|
+
"bankaccount",
|
|
65
|
+
"accountnumber"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensitive fields configuration loader
|
|
3
|
+
* Loads ISO 27001 compliant sensitive fields from JSON configuration file
|
|
4
|
+
*/
|
|
5
|
+
export interface SensitiveFieldsConfig {
|
|
6
|
+
version: string;
|
|
7
|
+
description: string;
|
|
8
|
+
categories: {
|
|
9
|
+
authentication: string[];
|
|
10
|
+
pii: string[];
|
|
11
|
+
financial: string[];
|
|
12
|
+
security: string[];
|
|
13
|
+
};
|
|
14
|
+
fieldPatterns: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Load sensitive fields configuration from JSON file
|
|
18
|
+
* Supports Node.js (fs) and browser environments (falls back to defaults in browser)
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadSensitiveFieldsConfig(customPath?: string): Set<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Get field patterns for pattern matching
|
|
23
|
+
*/
|
|
24
|
+
export declare function getFieldPatterns(customPath?: string): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Get all sensitive fields as array (for DataMasker)
|
|
27
|
+
*/
|
|
28
|
+
export declare function getSensitiveFieldsArray(customPath?: string): string[];
|
|
29
|
+
//# sourceMappingURL=sensitive-fields.loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive-fields.loader.d.ts","sourceRoot":"","sources":["../../../src/utils/sensitive-fields.loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QACV,cAAc,EAAE,MAAM,EAAE,CAAC;QACzB,GAAG,EAAE,MAAM,EAAE,CAAC;QACd,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAgED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CA6E1E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAmD9D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAGrE"}
|