newrelic 9.9.0 → 9.10.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/NEWS.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### v9.10.0 (2023-02-09)
2
+
3
+ * Exposed a method on [API](https://newrelic.github.io/node-newrelic/API.html#obfuscateSql) to obfuscate sql: `newrelic.obfuscateSql`.
4
+
5
+ * Add support for [Multi Value Parameters](https://aws.amazon.com/blogs/compute/support-for-multi-value-parameters-in-amazon-api-gateway) from API Gateway and ALB events for Lambdas (Thank you @Engerim for your contribution 🙏🏻)
6
+
1
7
  ### v9.9.0 (2023-02-06)
2
8
  * Added support for url obfuscation using regex (Thanks for your contribution @matewilk)
3
9
  * For Distributed Tracing, this means that:
@@ -40,6 +40,7 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
40
40
  * [async](#async)
41
41
  * [c8](#c8)
42
42
  * [chai](#chai)
43
+ * [clean-jsdoc-theme](#clean-jsdoc-theme)
43
44
  * [commander](#commander)
44
45
  * [eslint-config-prettier](#eslint-config-prettier)
45
46
  * [eslint-plugin-disable](#eslint-plugin-disable)
@@ -57,7 +58,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
57
58
  * [lint-staged](#lint-staged)
58
59
  * [lockfile-lint](#lockfile-lint)
59
60
  * [memcached](#memcached)
60
- * [minami](#minami)
61
61
  * [nock](#nock)
62
62
  * [prettier](#prettier)
63
63
  * [proxyquire](#proxyquire)
@@ -74,7 +74,6 @@ code, the source code can be found at [https://github.com/newrelic/node-newrelic
74
74
  **[optionalDependencies](#optionalDependencies)**
75
75
 
76
76
  * [@contrast/fn-inspect](#contrastfn-inspect)
77
- * [@newrelic/native-metrics](#newrelicnative-metrics)
78
77
 
79
78
  **[Additional Licenses](#additional-licenses)**
80
79
 
@@ -1367,7 +1366,7 @@ SOFTWARE.
1367
1366
 
1368
1367
  ### @newrelic/eslint-config
1369
1368
 
1370
- This product includes source derived from [@newrelic/eslint-config](https://github.com/newrelic/eslint-config-newrelic) ([v0.2.0](https://github.com/newrelic/eslint-config-newrelic/tree/v0.2.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/eslint-config-newrelic/blob/v0.2.0/LICENSE):
1369
+ This product includes source derived from [@newrelic/eslint-config](https://github.com/newrelic/eslint-config-newrelic) ([v0.3.0](https://github.com/newrelic/eslint-config-newrelic/tree/v0.3.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/eslint-config-newrelic/blob/v0.3.0/LICENSE):
1371
1370
 
1372
1371
  ```
1373
1372
  Apache License
@@ -2175,6 +2174,35 @@ SOFTWARE.
2175
2174
 
2176
2175
  ```
2177
2176
 
2177
+ ### clean-jsdoc-theme
2178
+
2179
+ This product includes source derived from [clean-jsdoc-theme](https://github.com/ankitskvmdam/clean-jsdoc-theme) ([v4.2.4](https://github.com/ankitskvmdam/clean-jsdoc-theme/tree/v4.2.4)), distributed under the [MIT License](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/v4.2.4/LICENSE):
2180
+
2181
+ ```
2182
+ MIT License
2183
+
2184
+ Copyright (c) 2019-2022 Ankit Kumar (अंकित कुमार)
2185
+
2186
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2187
+ of this software and associated documentation files (the "Software"), to deal
2188
+ in the Software without restriction, including without limitation the rights
2189
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2190
+ copies of the Software, and to permit persons to whom the Software is
2191
+ furnished to do so, subject to the following conditions:
2192
+
2193
+ The above copyright notice and this permission notice shall be included in all
2194
+ copies or substantial portions of the Software.
2195
+
2196
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2197
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2198
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2199
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2200
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2201
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2202
+ SOFTWARE.
2203
+
2204
+ ```
2205
+
2178
2206
  ### commander
2179
2207
 
2180
2208
  This product includes source derived from [commander](https://github.com/tj/commander.js) ([v7.2.0](https://github.com/tj/commander.js/tree/v7.2.0)), distributed under the [MIT License](https://github.com/tj/commander.js/blob/v7.2.0/LICENSE):
@@ -2373,7 +2401,7 @@ OTHER DEALINGS IN THE SOFTWARE.
2373
2401
 
2374
2402
  ### eslint-plugin-sonarjs
2375
2403
 
2376
- This product includes source derived from [eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs) ([v0.15.0](https://github.com/SonarSource/eslint-plugin-sonarjs/tree/v0.15.0)), distributed under the [LGPL-3.0 License](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/v0.15.0/LICENSE):
2404
+ This product includes source derived from [eslint-plugin-sonarjs](https://github.com/SonarSource/eslint-plugin-sonarjs) ([v0.18.0](https://github.com/SonarSource/eslint-plugin-sonarjs/tree/v0.18.0)), distributed under the [LGPL-3.0 License](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/v0.18.0/LICENSE):
2377
2405
 
2378
2406
  ```
2379
2407
  GNU LESSER GENERAL PUBLIC LICENSE
@@ -3041,75 +3069,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3041
3069
  THE SOFTWARE.
3042
3070
  ```
3043
3071
 
3044
- ### minami
3045
-
3046
- This product includes source derived from [minami](https://github.com/Nijikokun/minami) ([v1.2.3](https://github.com/Nijikokun/minami/tree/v1.2.3)), distributed under the [Apache-2.0 License](https://github.com/Nijikokun/minami/blob/v1.2.3/LICENSE):
3047
-
3048
- ```
3049
- # License
3050
-
3051
- Minami is free software, licensed under the Apache License, Version 2.0 (the
3052
- "License"). Commercial and non-commercial use are permitted in compliance with
3053
- the License.
3054
-
3055
- Copyright (c) 2014-2015 Nijiko Yonskai <nijikokun@gmail.com> and the
3056
- [contributors to Minami](https://github.com/Nijikokun/minami/graphs/contributors).
3057
- All rights reserved.
3058
-
3059
- You may obtain a copy of the License at:
3060
- http://www.apache.org/licenses/LICENSE-2.0
3061
-
3062
- In addition, a copy of the License is included with this distribution.
3063
-
3064
- As stated in Section 7, "Disclaimer of Warranty," of the License:
3065
-
3066
- > Licensor provides the Work (and each Contributor provides its Contributions)
3067
- > on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
3068
- > express or implied, including, without limitation, any warranties or
3069
- > conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
3070
- > PARTICULAR PURPOSE. You are solely responsible for determining the
3071
- > appropriateness of using or redistributing the Work and assume any risks
3072
- > associated with Your exercise of permissions under this License.
3073
-
3074
- The source code for JSDoc 3 is available at:
3075
- https://github.com/Nijikokun/minami
3076
-
3077
- # Third-Party Software
3078
-
3079
- Minami includes or depends upon the following third-party software, either in
3080
- whole or in part. Each third-party software package is provided under its own
3081
- license.
3082
-
3083
- ## JSDoc 3
3084
-
3085
- JSDoc 3 is free software, licensed under the Apache License, Version 2.0 (the
3086
- "License"). Commercial and non-commercial use are permitted in compliance with
3087
- the License.
3088
-
3089
- Copyright (c) 2011-2015 Michael Mathews <micmath@gmail.com> and the
3090
- [contributors to JSDoc](https://github.com/jsdoc3/jsdoc/graphs/contributors).
3091
- All rights reserved.
3092
-
3093
- You may obtain a copy of the License at:
3094
- http://www.apache.org/licenses/LICENSE-2.0
3095
-
3096
- In addition, a copy of the License is included with this distribution.
3097
-
3098
- As stated in Section 7, "Disclaimer of Warranty," of the License:
3099
-
3100
- > Licensor provides the Work (and each Contributor provides its Contributions)
3101
- > on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
3102
- > express or implied, including, without limitation, any warranties or
3103
- > conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
3104
- > PARTICULAR PURPOSE. You are solely responsible for determining the
3105
- > appropriateness of using or redistributing the Work and assume any risks
3106
- > associated with Your exercise of permissions under this License.
3107
-
3108
- The source code for JSDoc 3 is available at:
3109
- https://github.com/jsdoc3/jsdoc
3110
-
3111
- ```
3112
-
3113
3072
  ### nock
3114
3073
 
3115
3074
  This product includes source derived from [nock](https://github.com/nock/nock) ([v11.8.0](https://github.com/nock/nock/tree/v11.8.0)), distributed under the [MIT License](https://github.com/nock/nock/blob/v11.8.0/LICENSE):
@@ -9493,215 +9452,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9493
9452
 
9494
9453
  ```
9495
9454
 
9496
- ### @newrelic/native-metrics
9497
-
9498
- This product includes source derived from [@newrelic/native-metrics](https://github.com/newrelic/node-native-metrics) ([v9.0.0](https://github.com/newrelic/node-native-metrics/tree/v9.0.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-native-metrics/blob/v9.0.0/LICENSE):
9499
-
9500
- ```
9501
- Apache License
9502
- Version 2.0, January 2004
9503
- http://www.apache.org/licenses/
9504
-
9505
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
9506
-
9507
- 1. Definitions.
9508
-
9509
- "License" shall mean the terms and conditions for use, reproduction,
9510
- and distribution as defined by Sections 1 through 9 of this document.
9511
-
9512
- "Licensor" shall mean the copyright owner or entity authorized by
9513
- the copyright owner that is granting the License.
9514
-
9515
- "Legal Entity" shall mean the union of the acting entity and all
9516
- other entities that control, are controlled by, or are under common
9517
- control with that entity. For the purposes of this definition,
9518
- "control" means (i) the power, direct or indirect, to cause the
9519
- direction or management of such entity, whether by contract or
9520
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
9521
- outstanding shares, or (iii) beneficial ownership of such entity.
9522
-
9523
- "You" (or "Your") shall mean an individual or Legal Entity
9524
- exercising permissions granted by this License.
9525
-
9526
- "Source" form shall mean the preferred form for making modifications,
9527
- including but not limited to software source code, documentation
9528
- source, and configuration files.
9529
-
9530
- "Object" form shall mean any form resulting from mechanical
9531
- transformation or translation of a Source form, including but
9532
- not limited to compiled object code, generated documentation,
9533
- and conversions to other media types.
9534
-
9535
- "Work" shall mean the work of authorship, whether in Source or
9536
- Object form, made available under the License, as indicated by a
9537
- copyright notice that is included in or attached to the work
9538
- (an example is provided in the Appendix below).
9539
-
9540
- "Derivative Works" shall mean any work, whether in Source or Object
9541
- form, that is based on (or derived from) the Work and for which the
9542
- editorial revisions, annotations, elaborations, or other modifications
9543
- represent, as a whole, an original work of authorship. For the purposes
9544
- of this License, Derivative Works shall not include works that remain
9545
- separable from, or merely link (or bind by name) to the interfaces of,
9546
- the Work and Derivative Works thereof.
9547
-
9548
- "Contribution" shall mean any work of authorship, including
9549
- the original version of the Work and any modifications or additions
9550
- to that Work or Derivative Works thereof, that is intentionally
9551
- submitted to Licensor for inclusion in the Work by the copyright owner
9552
- or by an individual or Legal Entity authorized to submit on behalf of
9553
- the copyright owner. For the purposes of this definition, "submitted"
9554
- means any form of electronic, verbal, or written communication sent
9555
- to the Licensor or its representatives, including but not limited to
9556
- communication on electronic mailing lists, source code control systems,
9557
- and issue tracking systems that are managed by, or on behalf of, the
9558
- Licensor for the purpose of discussing and improving the Work, but
9559
- excluding communication that is conspicuously marked or otherwise
9560
- designated in writing by the copyright owner as "Not a Contribution."
9561
-
9562
- "Contributor" shall mean Licensor and any individual or Legal Entity
9563
- on behalf of whom a Contribution has been received by Licensor and
9564
- subsequently incorporated within the Work.
9565
-
9566
- 2. Grant of Copyright License. Subject to the terms and conditions of
9567
- this License, each Contributor hereby grants to You a perpetual,
9568
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
9569
- copyright license to reproduce, prepare Derivative Works of,
9570
- publicly display, publicly perform, sublicense, and distribute the
9571
- Work and such Derivative Works in Source or Object form.
9572
-
9573
- 3. Grant of Patent License. Subject to the terms and conditions of
9574
- this License, each Contributor hereby grants to You a perpetual,
9575
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
9576
- (except as stated in this section) patent license to make, have made,
9577
- use, offer to sell, sell, import, and otherwise transfer the Work,
9578
- where such license applies only to those patent claims licensable
9579
- by such Contributor that are necessarily infringed by their
9580
- Contribution(s) alone or by combination of their Contribution(s)
9581
- with the Work to which such Contribution(s) was submitted. If You
9582
- institute patent litigation against any entity (including a
9583
- cross-claim or counterclaim in a lawsuit) alleging that the Work
9584
- or a Contribution incorporated within the Work constitutes direct
9585
- or contributory patent infringement, then any patent licenses
9586
- granted to You under this License for that Work shall terminate
9587
- as of the date such litigation is filed.
9588
-
9589
- 4. Redistribution. You may reproduce and distribute copies of the
9590
- Work or Derivative Works thereof in any medium, with or without
9591
- modifications, and in Source or Object form, provided that You
9592
- meet the following conditions:
9593
-
9594
- (a) You must give any other recipients of the Work or
9595
- Derivative Works a copy of this License; and
9596
-
9597
- (b) You must cause any modified files to carry prominent notices
9598
- stating that You changed the files; and
9599
-
9600
- (c) You must retain, in the Source form of any Derivative Works
9601
- that You distribute, all copyright, patent, trademark, and
9602
- attribution notices from the Source form of the Work,
9603
- excluding those notices that do not pertain to any part of
9604
- the Derivative Works; and
9605
-
9606
- (d) If the Work includes a "NOTICE" text file as part of its
9607
- distribution, then any Derivative Works that You distribute must
9608
- include a readable copy of the attribution notices contained
9609
- within such NOTICE file, excluding those notices that do not
9610
- pertain to any part of the Derivative Works, in at least one
9611
- of the following places: within a NOTICE text file distributed
9612
- as part of the Derivative Works; within the Source form or
9613
- documentation, if provided along with the Derivative Works; or,
9614
- within a display generated by the Derivative Works, if and
9615
- wherever such third-party notices normally appear. The contents
9616
- of the NOTICE file are for informational purposes only and
9617
- do not modify the License. You may add Your own attribution
9618
- notices within Derivative Works that You distribute, alongside
9619
- or as an addendum to the NOTICE text from the Work, provided
9620
- that such additional attribution notices cannot be construed
9621
- as modifying the License.
9622
-
9623
- You may add Your own copyright statement to Your modifications and
9624
- may provide additional or different license terms and conditions
9625
- for use, reproduction, or distribution of Your modifications, or
9626
- for any such Derivative Works as a whole, provided Your use,
9627
- reproduction, and distribution of the Work otherwise complies with
9628
- the conditions stated in this License.
9629
-
9630
- 5. Submission of Contributions. Unless You explicitly state otherwise,
9631
- any Contribution intentionally submitted for inclusion in the Work
9632
- by You to the Licensor shall be under the terms and conditions of
9633
- this License, without any additional terms or conditions.
9634
- Notwithstanding the above, nothing herein shall supersede or modify
9635
- the terms of any separate license agreement you may have executed
9636
- with Licensor regarding such Contributions.
9637
-
9638
- 6. Trademarks. This License does not grant permission to use the trade
9639
- names, trademarks, service marks, or product names of the Licensor,
9640
- except as required for reasonable and customary use in describing the
9641
- origin of the Work and reproducing the content of the NOTICE file.
9642
-
9643
- 7. Disclaimer of Warranty. Unless required by applicable law or
9644
- agreed to in writing, Licensor provides the Work (and each
9645
- Contributor provides its Contributions) on an "AS IS" BASIS,
9646
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
9647
- implied, including, without limitation, any warranties or conditions
9648
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
9649
- PARTICULAR PURPOSE. You are solely responsible for determining the
9650
- appropriateness of using or redistributing the Work and assume any
9651
- risks associated with Your exercise of permissions under this License.
9652
-
9653
- 8. Limitation of Liability. In no event and under no legal theory,
9654
- whether in tort (including negligence), contract, or otherwise,
9655
- unless required by applicable law (such as deliberate and grossly
9656
- negligent acts) or agreed to in writing, shall any Contributor be
9657
- liable to You for damages, including any direct, indirect, special,
9658
- incidental, or consequential damages of any character arising as a
9659
- result of this License or out of the use or inability to use the
9660
- Work (including but not limited to damages for loss of goodwill,
9661
- work stoppage, computer failure or malfunction, or any and all
9662
- other commercial damages or losses), even if such Contributor
9663
- has been advised of the possibility of such damages.
9664
-
9665
- 9. Accepting Warranty or Additional Liability. While redistributing
9666
- the Work or Derivative Works thereof, You may choose to offer,
9667
- and charge a fee for, acceptance of support, warranty, indemnity,
9668
- or other liability obligations and/or rights consistent with this
9669
- License. However, in accepting such obligations, You may act only
9670
- on Your own behalf and on Your sole responsibility, not on behalf
9671
- of any other Contributor, and only if You agree to indemnify,
9672
- defend, and hold each Contributor harmless for any liability
9673
- incurred by, or claims asserted against, such Contributor by reason
9674
- of your accepting any such warranty or additional liability.
9675
-
9676
- END OF TERMS AND CONDITIONS
9677
-
9678
- APPENDIX: How to apply the Apache License to your work.
9679
-
9680
- To apply the Apache License to your work, attach the following
9681
- boilerplate notice, with the fields enclosed by brackets "[]"
9682
- replaced with your own identifying information. (Don't include
9683
- the brackets!) The text should be enclosed in the appropriate
9684
- comment syntax for the file format. We also recommend that a
9685
- file or class name and description of purpose be included on the
9686
- same "printed page" as the copyright notice for easier
9687
- identification within third-party archives.
9688
-
9689
- Copyright [yyyy] [name of copyright owner]
9690
-
9691
- Licensed under the Apache License, Version 2.0 (the "License");
9692
- you may not use this file except in compliance with the License.
9693
- You may obtain a copy of the License at
9694
-
9695
- http://www.apache.org/licenses/LICENSE-2.0
9696
-
9697
- Unless required by applicable law or agreed to in writing, software
9698
- distributed under the License is distributed on an "AS IS" BASIS,
9699
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9700
- See the License for the specific language governing permissions and
9701
- limitations under the License.
9702
-
9703
- ```
9704
-
9705
9455
  ## Additional Licenses
9706
9456
 
9707
9457
  ### Symantec
package/api.js CHANGED
@@ -27,6 +27,7 @@ const {
27
27
  const ATTR_DEST = require('./lib/config/attribute-filter').DESTINATIONS
28
28
  const MODULE_TYPE = require('./lib/shim/constants').MODULE_TYPE
29
29
  const NAMES = require('./lib/metrics/names')
30
+ const obfuscate = require('./lib/util/sql/obfuscate')
30
31
 
31
32
  /*
32
33
  *
@@ -646,7 +647,7 @@ function _generateRUMHeader(options = {}, metadata, loader) {
646
647
  * @param {object} config agent configuration settings
647
648
  * @param {Transaction} transaction the active transaction or null
648
649
  * @param {boolean} allowTransactionlessInjection whether or not to allow the Browser Agent to be injected when there is no active transaction
649
- * @returns {{ isValidConfig: boolean, failureIdx?: number, quietMode?: boolean }} object containing validation results
650
+ * @returns {{ isValidConfig: boolean, failureIdx: number, quietMode: boolean }} object containing validation results
650
651
  */
651
652
  function validateBrowserMonitoring(config, transaction, allowTransactionlessInjection) {
652
653
  /*
@@ -1669,6 +1670,20 @@ API.prototype.setLambdaHandler = function setLambdaHandler(handler) {
1669
1670
  return this.awsLambda.patchLambdaHandler(handler)
1670
1671
  }
1671
1672
 
1673
+ /**
1674
+ * Obfuscates SQL for a given database engine.
1675
+ *
1676
+ * @param {string} sql sql statement
1677
+ * @param {string} dialect engine of the sql (mysql, postgres, cassandra, oracle)
1678
+ * @returns {string} sql that obfuscates raw values
1679
+ */
1680
+ API.prototype.obfuscateSql = function obfuscateSql(sql, dialect) {
1681
+ const metric = this.agent.metrics.getOrCreateMetric(NAMES.SUPPORTABILITY.API + '/obfuscateSql')
1682
+ metric.incrementCallCount()
1683
+
1684
+ return obfuscate(sql, dialect)
1685
+ }
1686
+
1672
1687
  /**
1673
1688
  * Function for removing invalid attribute key/value pairs from an object
1674
1689
  *
@@ -7,19 +7,21 @@
7
7
 
8
8
  /**
9
9
  * This class captures data needed to construct a web transaction from
10
- * a API Gateway Lambda proxy request. This is to be used with the setWebRequest
10
+ * an API Gateway Lambda proxy request. This is to be used with the setWebRequest
11
11
  * method.
12
12
  */
13
13
  class LambdaProxyWebRequest {
14
14
  constructor(event) {
15
- this.headers = event.headers
15
+ const lowerCaseHeaders = normalizeHeaders(event, true)
16
+
17
+ this.headers = normalizeHeaders(event)
16
18
  this.url = {
17
19
  path: event.path,
18
- port: event.headers['X-Forwarded-Port'],
19
- requestParameters: event.queryStringParameters
20
+ port: lowerCaseHeaders['x-forwarded-port'],
21
+ requestParameters: normalizeQueryStringParameters(event)
20
22
  }
21
23
  this.method = event.httpMethod
22
- this.transportType = event.headers['X-Forwarded-Proto']
24
+ this.transportType = lowerCaseHeaders['x-forwarded-proto']
23
25
  }
24
26
  }
25
27
 
@@ -30,11 +32,53 @@ class LambdaProxyWebRequest {
30
32
  */
31
33
  class LambdaProxyWebResponse {
32
34
  constructor(lambdaResponse) {
33
- this.headers = lambdaResponse.headers
35
+ this.headers = normalizeHeaders(lambdaResponse)
34
36
  this.statusCode = lambdaResponse.statusCode
35
37
  }
36
38
  }
37
39
 
40
+ /**
41
+ * normalizes query string parameters either from multi value query string parameters or normal query string parameters to a
42
+ * key map with comma separated strings
43
+ *
44
+ * @param {object} event The event with query string to normalize
45
+ * @returns {Object<string, string>} The normalized query string map
46
+ */
47
+ function normalizeQueryStringParameters(event) {
48
+ if (!event.multiValueQueryStringParameters) {
49
+ return event.queryStringParameters
50
+ }
51
+ return Object.fromEntries(
52
+ Object.entries(event.multiValueQueryStringParameters).map(([param, value]) => {
53
+ if (Array.isArray(value)) {
54
+ return [param, value.join(',')]
55
+ }
56
+ return [param, value]
57
+ })
58
+ )
59
+ }
60
+
61
+ /**
62
+ * normalizes headers either from multi value headers or normal headers to a
63
+ * lowercase key map with comma separated string
64
+ *
65
+ * @param {object} event The event with headers to normalize
66
+ * @param {boolean} lowerCaseKey Whether to lowercase the header names or not
67
+ * @returns {Object<string, string>} The normalized headers map
68
+ */
69
+ function normalizeHeaders(event, lowerCaseKey = false) {
70
+ return Object.fromEntries(
71
+ Object.entries(event.multiValueHeaders ?? event.headers).map(([headerKey, headerValue]) => {
72
+ const newKey = lowerCaseKey ? headerKey.toLowerCase() : headerKey
73
+
74
+ if (Array.isArray(headerValue)) {
75
+ return [newKey, headerValue.join(',')]
76
+ }
77
+ return [newKey, headerValue]
78
+ })
79
+ )
80
+ }
81
+
38
82
  /**
39
83
  * Determines if Lambda event appears to be a valid Lambda Proxy event.
40
84
  *
@@ -43,14 +87,13 @@ class LambdaProxyWebResponse {
43
87
  * to create a web transaction.
44
88
  */
45
89
  function isLambdaProxyEvent(event) {
46
- return !!(event.path && event.headers && event.httpMethod)
90
+ return !!(event.path && (event.headers ?? event.multiValueHeaders) && event.httpMethod)
47
91
  }
48
92
 
49
93
  /**
50
94
  * Determines if Lambda event appears to be a valid Lambda Proxy response.
51
95
  *
52
- * @param {object} event The response to inspect.
53
- * @param response
96
+ * @param {object} response The response to inspect.
54
97
  * @returns {boolean} Whether the given object contains fields necessary
55
98
  * to create a web transaction.
56
99
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "9.9.0",
3
+ "version": "9.10.0",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -179,10 +179,10 @@
179
179
  "newrelic-naming-rules": "./bin/test-naming-rules.js"
180
180
  },
181
181
  "dependencies": {
182
- "@grpc/grpc-js": "^1.7.3",
183
- "@grpc/proto-loader": "^0.7.3",
184
- "@newrelic/aws-sdk": "^5.0.0",
185
- "@newrelic/koa": "^7.0.0",
182
+ "@grpc/grpc-js": "^1.8.4",
183
+ "@grpc/proto-loader": "^0.7.4",
184
+ "@newrelic/aws-sdk": "^5.0.2",
185
+ "@newrelic/koa": "^7.1.1",
186
186
  "@newrelic/superagent": "^6.0.0",
187
187
  "@tyriar/fibonacci-heap": "^2.0.7",
188
188
  "concat-stream": "^2.0.0",
@@ -198,7 +198,7 @@
198
198
  "@newrelic/native-metrics": "^9.0.0"
199
199
  },
200
200
  "devDependencies": {
201
- "@newrelic/eslint-config": "^0.2.0",
201
+ "@newrelic/eslint-config": "^0.3.0",
202
202
  "@newrelic/newrelic-oss-cli": "^0.1.2",
203
203
  "@newrelic/proxy": "^2.0.0",
204
204
  "@newrelic/test-utilities": "^7.2.0",
@@ -208,6 +208,7 @@
208
208
  "async": "^3.2.4",
209
209
  "c8": "^7.12.0",
210
210
  "chai": "^4.1.2",
211
+ "clean-jsdoc-theme": "^4.2.4",
211
212
  "commander": "^7.0.0",
212
213
  "eslint": "^8.24.0",
213
214
  "eslint-config-prettier": "^8.3.0",
@@ -216,7 +217,7 @@
216
217
  "eslint-plugin-jsdoc": "^39.3.6",
217
218
  "eslint-plugin-node": "^11.1.0",
218
219
  "eslint-plugin-prettier": "^3.4.0",
219
- "eslint-plugin-sonarjs": "^0.15.0",
220
+ "eslint-plugin-sonarjs": "^0.18.0",
220
221
  "express": "*",
221
222
  "glob": "^7.1.2",
222
223
  "got": "^11.8.5",
@@ -225,7 +226,6 @@
225
226
  "lint-staged": "^11.0.0",
226
227
  "lockfile-lint": "^4.9.6",
227
228
  "memcached": ">=0.2.8",
228
- "minami": "^1.2.3",
229
229
  "nock": "11.8.0",
230
230
  "prettier": "^2.3.2",
231
231
  "proxyquire": "^1.8.0",