@63klabs/cache-data 1.2.2

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 ADDED
@@ -0,0 +1,234 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ > Note: This project is still in beta. Even though changes are tested and breaking changes are avoided, things may break. The latest 1.1.x version is stable.
6
+
7
+ ## 1.1.6 (2025-05-05) Moving to @63Klabs
8
+
9
+ This package has come a long way and is stable. To enhance its longevity I am moving it out of my personal GitHub and NPM accounts an into an organizational account managed by me (chadkluck).
10
+
11
+ ## 1.1.5 (2025-04-08) Security and Optimization for DebugAndLog and utils.sanitize()
12
+
13
+ - Polynomial regular expression used on uncontrolled data in utils.sanitize()
14
+ - Use of externally-controlled format string in DebugAndLog
15
+
16
+ Malformed strings could be passed to `DebugAndLog` and `utils.sanitize()` that could cause unexpected results.
17
+
18
+ `utils.sanitize()` will now only handle strings/stringified objects that are of a maximum length of 200,000 characters to prevent Denial of Service. As a result, objects or strings longer than the maximum length will be returned with the message: "Input exceeds maximum allowed length" rather than sanitized output. This will affect the logging of any objects or text strings that are longer than 200,000 characters when stringified.
19
+
20
+ `utils.sanitize()` is used by DebugAndLog when outputting log data that might contain sensitive information.
21
+
22
+ > Some regular expressions take a long time to match certain input strings to the point where the time it takes to match a string of length n is proportional to nk or even 2n. Such regular expressions can negatively affect performance, or even allow a malicious user to perform a Denial of Service ("DoS") attack by crafting an expensive input string for the regular expression to match.
23
+
24
+ While `DebugAndLog` has also been optimized, there is no change to its results. Internally, it was enhanced to prevent malformed messages that are sent to it.
25
+
26
+ > Functions like the Node.js standard library function util.format accept a format string that is used to format the remaining arguments by providing inline format specifiers. If the format string contains unsanitized input from an untrusted source, then that string may contain unexpected format specifiers that cause garbled output.
27
+
28
+ ## 1.1.4 (2025-03-18) Added XRay sub-segment for API requests
29
+
30
+ - Feature: Added XRay Segment for APIRequest class
31
+
32
+ When using the tools.APIRequest class, each remote request is now annotated and provided meta data.
33
+
34
+ ## 1.1.3 (2025-02-17) Additional Options for Sending Parameters via Query String
35
+
36
+ - Fix v1.1.3: The options property of connection was getting lost when passed to CacheableDataAccess.getData() due to an issue with the way the cache hash Id was calculated.
37
+ - Feature v1.1.2: Added new options to specify how duplicate parameters in a query string should be handled. This allows you to craft your query string to match what your endpoint expects when it parses the query string.
38
+
39
+ ```javascript
40
+ connections.add({
41
+ method: "POST",
42
+ host: "api.chadkluck.net",
43
+ path: "/echo/",
44
+ headers: headers,
45
+ uri: "",
46
+ protocol: "https",
47
+ body: null,
48
+ parameters: {
49
+ greeting: "Hello",
50
+ planets: ["Earth", "Mars"]
51
+ },
52
+ options: {
53
+ timeout: 8000,
54
+ separateDuplicateParameters: false, // default is false
55
+ separateDuplicateParametersAppendToKey: "", // "" "[]", or "0++", "1++"
56
+ combinedDuplicateParameterDelimiter: ','
57
+ }
58
+ })
59
+ ```
60
+
61
+ By default the query string used for the request will be:
62
+
63
+ ```text
64
+ ?greeting=Hello&planets=Earth,Mars
65
+ ```
66
+
67
+ However, by changing `separateDuplicateParameters` to `true` and `separateDuplicateParametersAppendToKey` to `[]`:
68
+
69
+ ```text
70
+ ?greeting=Hello&planets[]=Earth&planets[]=Mars
71
+ ```
72
+
73
+ You can also append an index to the end of the parameter:
74
+
75
+ ```javascript
76
+ options = {
77
+ separateDuplicateParameters: true,
78
+ separateDuplicateParametersAppendToKey: "0++", // "" "[]", or "0++", "1++"
79
+ }
80
+ // ?greeting=Hello&planets0=Earth&planets1=Mars
81
+ ```
82
+
83
+ Similarly, you can start at index 1 instead of 0:
84
+
85
+ ```javascript
86
+ options = {
87
+ separateDuplicateParameters: true,
88
+ separateDuplicateParametersAppendToKey: "1++", // "" "[]", or "0++", "1++"
89
+ }
90
+ // ?greeting=Hello&planets1=Earth&planets2=Mars
91
+ ```
92
+
93
+ ## 1.1.1 (2024-11-25) First Minor Release!
94
+
95
+ There should be no breaking changes, but this is being released as a minor release instead of a patch.
96
+
97
+ - 1.1.0 Enhancement: Shared cache stores are readily available. You can utilize one DynamoDb table and one S3 bucket and share it among your applications. As always, the data encryption key keeps your data secure. As an added feature, each Cache Id is hashed with the application name (Lambda function name) to keep the data separate among applications and instances. (There is currently no support to share cached data among different applications.)
98
+ - 1.1.0 Feature: New Response and ClientRequest classes. In the past you needed to extend the RequestDataModel and RequestInfo classes. While the RequestDataModel and RequestInfo classes are still available, these classes should help with organizing your application and logging. The ClientRequest class can handle incoming parameter validation and route parsing. The Response class can handle assembling the response and logging.
99
+ - 1.1.0 Began restructuring of the library. No noticeable differences on the end user end, but this better organizes the underlying Classes and methods.
100
+ - 1.1.1 Removes Options from the cache identifier so that dynamic timeouts and other options that don't affect the data can be used.
101
+
102
+
103
+ ## 1.0.39 (2024-05-06)
104
+
105
+ 3 of 3 new features added in April are now fully functional and documented. See documentation for AWS X-Ray and AWS Parameters and Secrets Lambda Extension.
106
+
107
+ The experimental feature tools.hashThisData() from v1.0.33 is still experimental and undocumented.
108
+
109
+ - Feature: Added AWS XRay to HTTP, SSM, S3, and DynamoDb requests. Add Lambda environment variable `CacheData_AWSXRayOn` and set to `true` to enable. Check the X-Ray traces using CloudWatch.
110
+ - Feature: Added a switch for experimental tools.hashThisData(). Passing the `useToolsHash: true` property during Cache.init() will use the provided `tools.hashThisData()` function rather than the current hash object package. By default it is `false` and the current hash object function is used.
111
+ - Documentation: Added documentation for both X-Ray and CachedParameterSecret
112
+ - Chore: Updated tests so it would work with chai 5.x
113
+
114
+ ## 1.0.38 (2024-04-29)
115
+
116
+ - Feature: Added experimental tools.CachedSecret, tools.CachedParameterSecret classes for use with the [AWS Parameters and Secrets Lambda Extension](https://aws.amazon.com/blogs/compute/using-the-aws-parameter-and-secrets-lambda-extension-to-cache-parameters-and-secrets/). Usage will be documented in a future release.
117
+
118
+ ## 1.0.37 (2024-04-18)
119
+
120
+ - Fix: [Issue #109 Write to DynamoDb failed for id_hash](https://github.com/chadkluck/npm-chadkluck-cache-data/issues/109)
121
+
122
+ ## 1.0.36 (2024-04-16)
123
+
124
+ - Security: Fixed a security recommendation for generating message log strings for tools.DebugAndLog.x
125
+ - Feature: Added an experimental tools.hashThisData() function for possible future replacement of the dependency object-hash when generating cache-ids.
126
+ - Chore: Bump actions/setup-node from 3 to 4 [Pull ClientRequest #108 Dependabot](https://github.com/chadkluck/npm-chadkluck-cache-data/pull/108)
127
+ - Chore: Bump chai from 4.3.10 to 5.0.0 [Pull ClientRequest #107 Dependabot](https://github.com/chadkluck/npm-chadkluck-cache-data/pull/107)
128
+ - Chore: Reverted chai 5.x back to 4.x and pinned dependency because 5.x doesn't work with node require
129
+
130
+ ## 1.0.33 (2023-09-18)
131
+
132
+ ### Features
133
+
134
+ - Added additional variables to tools.AWS including `tools.AWS.NODE_VER` (see AWS-SDK section in README)
135
+ - Added additional DynamoDb methods:
136
+ - `tools.AWS.dynamo.scan`
137
+ - `tools.AWS.dynamo.delete`
138
+ - `tools.AWS.dynamo.update`
139
+ - `tools.AWS.dynamo.sdk.ScanCommand`
140
+ - `tools.AWS.dynamo.sdk.DeleteCommand`
141
+ - `tools.AWS.dynamo.sdk.UpdateCommand`
142
+
143
+ ## 1.0.32 (2023-09-17)
144
+
145
+ AWS-SDK version 3 is now available for use. This also means cache-data may be installed on Lambda functions using Node 18 or later, but is still backwards compatible with Node 16.
146
+
147
+ This version will not run if the Node version is less than 16. AWS will be deprecating version 16 on Lambda in 2024.
148
+
149
+ ### Features
150
+
151
+ - Fully implemented AWS-SDK version 3 for Node 18 and above. AWS-SDK version 2 will be used for Node 16. (Below Node 16 not supported).
152
+ - To assist in development using the SDKs, DynamoDB, S3, and SSM Parameter Store SDKs are accessible when tools are imported. `tools.AWS.dynamo.sdk`. You can also utilize generic `put` and `get` functions for these resources that will automatically use the proper SDK (See AWS-SDK section in README).
153
+ - Improved error reporting. Stack traces now logged across all tools.
154
+
155
+ ## 1.0.25 (2023-09-13)
156
+
157
+ ### Fix
158
+
159
+ - Mitigation for [Issue #80 Applications hang and time out when reading cached items from S3 (no errors reported)](https://github.com/chadkluck/npm-chadkluck-cache-data/issues/80). Large encrypted cached items may still hang.
160
+
161
+ ### Chores
162
+
163
+ - Bumped some dependencies up.
164
+ - Switched to AWS-SDK version 3 from version 2
165
+
166
+ ## 1.0.24 (2023-09-09)
167
+
168
+ ### Fix
169
+
170
+ - Fix for [Issue #80 Applications hang and time out when reading cached items from S3 (no errors reported)](https://github.com/chadkluck/npm-chadkluck-cache-data/issues/80)
171
+
172
+ ### Chores
173
+
174
+ - Changelog file had info from a different project cluttering up the first half.
175
+ - Bump chai from 4.3.7 to 4.3.8 [Pull ClientRequest #76 Dependabot](https://github.com/chadkluck/npm-chadkluck-cache-data/pull/76)
176
+ - Bump aws-sdk from 2.1440.0 to 2.1445.0 [Pull ClientRequest #75 Dependabot](https://github.com/chadkluck/npm-chadkluck-cache-data/pull/75)
177
+ - Preparing for aws-sdk v3
178
+ - Added lambda-test, sinon, and proxyquire to dev dependencies for testing
179
+ - Bump @aws-sdk/client-s3 from 3.400.0 to 3.405.0 [Pull ClientRequest #77 Dependabot](https://github.com/chadkluck/npm-chadkluck-cache-data/pull/77)
180
+ - Bump @aws-sdk/client-dynamodb from 3.398.0 to 3.405.0 [Pull ClientRequest #79 Dependabot](https://github.com/chadkluck/npm-chadkluck-cache-data/pull/79)
181
+ - Bump aws-sdk from 2.1445.0 to 2.1453.0 [Pull ClientRequest #81 Dependabot](https://github.com/chadkluck/npm-chadkluck-cache-data/pull/81)
182
+
183
+ ## 1.0.22 (2023-08-23)
184
+
185
+ ### Updates
186
+
187
+ - Cache data access object: Added additional debug messages for read/write functions in DynamoDb, S3, and General Cache
188
+ - Improved error message logging for read/write functions in DynamoDb, S3, and General Cache
189
+
190
+ ## 1.0.21 (2023-08-06)
191
+
192
+ ### Fix
193
+
194
+ - Cleaned up an issue that came up when renaming cache policy profile properties to hostId and pathId.
195
+
196
+ ## 1.0.20 (2023-08-04)
197
+
198
+ ### Updates
199
+
200
+ - Bumped package dependencies up for aws-sdk
201
+ - Updated tests to use `api.chadkluck.net/echo` endpoint instead of `labkit.api.63klabs.net` (both are maintained by the script's author).
202
+ - `defaultExpirationInSeconds` and `expirationIsOnInterval` are now accepted aliases for `defaultExpiresInSeconds` and `expiresIsOnInterval` respectively for Connection Cache Profile configuration. [Resolves Issue #71](https://github.com/chadkluck/npm-chadkluck-cache-data/issues/71)
203
+
204
+ ## 1.0.18 (2023-04-03)
205
+
206
+ - Added tools.obfuscate() and tools.sanitize() and now attempts to sanitize objects sent to DebugAndLog. Regular Expression used in the stringified object may be [inspected on RegEx101](https://regex101.com/library/IJp35p)
207
+
208
+ ## 1.0.17 (2023-02-04)
209
+
210
+ - Bumped package dependencies up for aws-sdk and cookiejar
211
+
212
+ ## 1.0.16 (2022-09-14)
213
+
214
+ - Added extra logging information to API errors in tools. Added host and note to the log for better troubleshooting endpoints.
215
+
216
+ ## 1.0.15 (2022-09-08)
217
+
218
+ - Updated dependencies moment-timezone and aws-sdk
219
+
220
+ ## 1.0.10 (2022-04-13)
221
+
222
+ - Added a log entry for a warning if timeout is reached in https get tool.
223
+
224
+ ## 1.0.9 (2022-04-12)
225
+
226
+ - Fixed issue where submitting null header or options to endpoint would fail
227
+
228
+ ## 1.0.8 (2022-04-12)
229
+
230
+ - Updated timeout to [follow https specs](https://nodejs.org/api/http.html#httprequestoptions-callback) and implemented on("timeout")
231
+
232
+ ## 1.0.2 (2022-02-12)
233
+
234
+ - Initial Release
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.