@optimizely-opal/opal-tool-ocp-sdk 1.0.0-OCP-1442.5 → 1.0.0-OCP-1449.1
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 +114 -72
- package/dist/auth/AuthUtils.d.ts +12 -5
- package/dist/auth/AuthUtils.d.ts.map +1 -1
- package/dist/auth/AuthUtils.js +80 -25
- package/dist/auth/AuthUtils.js.map +1 -1
- package/dist/auth/AuthUtils.test.js +161 -117
- package/dist/auth/AuthUtils.test.js.map +1 -1
- package/dist/function/GlobalToolFunction.d.ts +1 -1
- package/dist/function/GlobalToolFunction.d.ts.map +1 -1
- package/dist/function/GlobalToolFunction.js +17 -4
- package/dist/function/GlobalToolFunction.js.map +1 -1
- package/dist/function/GlobalToolFunction.test.js +54 -8
- package/dist/function/GlobalToolFunction.test.js.map +1 -1
- package/dist/function/ToolFunction.d.ts +1 -1
- package/dist/function/ToolFunction.d.ts.map +1 -1
- package/dist/function/ToolFunction.js +24 -4
- package/dist/function/ToolFunction.js.map +1 -1
- package/dist/function/ToolFunction.test.js +260 -8
- package/dist/function/ToolFunction.test.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logging/ToolLogger.d.ts.map +1 -1
- package/dist/logging/ToolLogger.js +13 -12
- package/dist/logging/ToolLogger.js.map +1 -1
- package/dist/logging/ToolLogger.test.js +171 -0
- package/dist/logging/ToolLogger.test.js.map +1 -1
- package/dist/service/Service.d.ts +88 -2
- package/dist/service/Service.d.ts.map +1 -1
- package/dist/service/Service.js +227 -55
- package/dist/service/Service.js.map +1 -1
- package/dist/service/Service.test.js +464 -36
- package/dist/service/Service.test.js.map +1 -1
- package/dist/types/ToolError.d.ts +59 -0
- package/dist/types/ToolError.d.ts.map +1 -0
- package/dist/types/ToolError.js +79 -0
- package/dist/types/ToolError.js.map +1 -0
- package/dist/types/ToolError.test.d.ts +2 -0
- package/dist/types/ToolError.test.d.ts.map +1 -0
- package/dist/types/ToolError.test.js +161 -0
- package/dist/types/ToolError.test.js.map +1 -0
- package/dist/validation/ParameterValidator.d.ts +5 -16
- package/dist/validation/ParameterValidator.d.ts.map +1 -1
- package/dist/validation/ParameterValidator.js +10 -3
- package/dist/validation/ParameterValidator.js.map +1 -1
- package/dist/validation/ParameterValidator.test.js +186 -146
- package/dist/validation/ParameterValidator.test.js.map +1 -1
- package/package.json +1 -1
- package/src/auth/AuthUtils.test.ts +176 -157
- package/src/auth/AuthUtils.ts +96 -33
- package/src/function/GlobalToolFunction.test.ts +54 -8
- package/src/function/GlobalToolFunction.ts +26 -6
- package/src/function/ToolFunction.test.ts +274 -8
- package/src/function/ToolFunction.ts +33 -7
- package/src/index.ts +1 -0
- package/src/logging/ToolLogger.test.ts +184 -0
- package/src/logging/ToolLogger.ts +13 -12
- package/src/service/Service.test.ts +577 -34
- package/src/service/Service.ts +286 -54
- package/src/types/ToolError.test.ts +192 -0
- package/src/types/ToolError.ts +95 -0
- package/src/validation/ParameterValidator.test.ts +185 -158
- package/src/validation/ParameterValidator.ts +17 -20
|
@@ -64,8 +64,8 @@ export class ToolLogger {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
if (typeof data === 'string') {
|
|
67
|
-
return data.length >
|
|
68
|
-
? `${data.substring(0,
|
|
67
|
+
return data.length > this.MAX_PARAM_LENGTH
|
|
68
|
+
? `${data.substring(0, this.MAX_PARAM_LENGTH)}... (truncated, ${data.length} chars total)`
|
|
69
69
|
: data;
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -74,10 +74,10 @@ export class ToolLogger {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (Array.isArray(data)) {
|
|
77
|
-
const truncated = data.slice(0,
|
|
78
|
-
const result = truncated.map((item) =>
|
|
79
|
-
if (data.length >
|
|
80
|
-
result.push(`... (${data.length -
|
|
77
|
+
const truncated = data.slice(0, this.MAX_ARRAY_ITEMS);
|
|
78
|
+
const result = truncated.map((item) => this.redactSensitiveData(item, maxDepth));
|
|
79
|
+
if (data.length > this.MAX_ARRAY_ITEMS) {
|
|
80
|
+
result.push(`... (${data.length - this.MAX_ARRAY_ITEMS} more items truncated)`);
|
|
81
81
|
}
|
|
82
82
|
return result;
|
|
83
83
|
}
|
|
@@ -86,12 +86,12 @@ export class ToolLogger {
|
|
|
86
86
|
const result: any = {};
|
|
87
87
|
for (const [key, value] of Object.entries(data)) {
|
|
88
88
|
// Check if this field contains sensitive data
|
|
89
|
-
const isSensitive =
|
|
89
|
+
const isSensitive = this.isSensitiveField(key);
|
|
90
90
|
|
|
91
91
|
if (isSensitive) {
|
|
92
92
|
result[key] = '[REDACTED]';
|
|
93
93
|
} else {
|
|
94
|
-
result[key] =
|
|
94
|
+
result[key] = this.redactSensitiveData(value, maxDepth - 1);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
return result;
|
|
@@ -105,7 +105,7 @@ export class ToolLogger {
|
|
|
105
105
|
*/
|
|
106
106
|
private static isSensitiveField(fieldName: string): boolean {
|
|
107
107
|
const lowerKey = fieldName.toLowerCase();
|
|
108
|
-
return
|
|
108
|
+
return this.SENSITIVE_FIELDS.some((sensitiveField) =>
|
|
109
109
|
lowerKey.includes(sensitiveField)
|
|
110
110
|
);
|
|
111
111
|
}
|
|
@@ -118,7 +118,7 @@ export class ToolLogger {
|
|
|
118
118
|
return null;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
return
|
|
121
|
+
return this.redactSensitiveData(params);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
@@ -146,7 +146,8 @@ export class ToolLogger {
|
|
|
146
146
|
const requestLog = {
|
|
147
147
|
event: 'opal_tool_request',
|
|
148
148
|
path: req.path,
|
|
149
|
-
|
|
149
|
+
method: req.method,
|
|
150
|
+
parameters: this.createParameterSummary(params)
|
|
150
151
|
};
|
|
151
152
|
|
|
152
153
|
// Log with Zaius audience so developers only see requests for accounts they have access to
|
|
@@ -167,7 +168,7 @@ export class ToolLogger {
|
|
|
167
168
|
duration: processingTimeMs ? `${processingTimeMs}ms` : undefined,
|
|
168
169
|
status: response.status,
|
|
169
170
|
contentType: response.headers?.get('content-type') || 'unknown',
|
|
170
|
-
contentLength:
|
|
171
|
+
contentLength: this.calculateContentLength(response),
|
|
171
172
|
success: response.status >= 200 && response.status < 300
|
|
172
173
|
};
|
|
173
174
|
|