@opensearch-project/opensearch 2.7.0 → 2.8.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 CHANGED
@@ -9,19 +9,26 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
9
9
  ### Deprecated
10
10
  ### Removed
11
11
  ### Fixed
12
+ ### Security
12
13
 
13
- ## [2.7.0]
14
+ ## [2.8.0]
14
15
  ### Added
16
+ - Added `@opensearch-project/opensearch/aws-v3` import ([758](https://github.com/opensearch-project/opensearch-js/pull/758)).
17
+ ### Dependencies
18
+ - Bumps `@types/node` from 20.12.5 to 20.12.7
19
+ - Bumps `semver` from 5.7.1 to 7.6.0
20
+ - Bumps `dedent` from 1.5.1 to 1.5.3
21
+ ### Changed
22
+ - Disabled fail_ci_if_error for upload coverage step in coverage workflow ([#755](https://github.com/opensearch-project/opensearch-js/issues/755)
23
+
24
+ ## [2.7.0]
15
25
  ### Dependencies
16
26
  - Bumps `@aws-sdk/types` from 3.523.0 to 3.535.0
17
27
  - Bumps `simple-git` from 3.22.0 to 3.24.0
18
28
  - Bumps `@types/node` from 20.11.25 to 20.12.5
19
29
  - Bumps `@babel/eslint-parser` from 7.23.10 to 7.24.1
20
30
  ### Changed
21
- - Added `search_pipeline` ([716](https://github.com/opensearch-project/opensearch-js/pull/716))
22
- ### Deprecated
23
- ### Removed
24
- ### Fixed
31
+ - Added `search_pipeline` ([#716](https://github.com/opensearch-project/opensearch-js/pull/716))
25
32
 
26
33
  ## [2.6.0]
27
34
  ### Added
@@ -39,12 +46,10 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
39
46
  - Updated integration tests to use strong password in OS 2.12 and up ([#707](https://github.com/opensearch-project/opensearch-js/pull/707))
40
47
  - Simplified client creation in the guides ([#707](https://github.com/opensearch-project/opensearch-js/pull/707))
41
48
  - Corrected `guides/bulk.md` ([#616](https://github.com/opensearch-project/opensearch-js/issues/616))
42
- ### Deprecated
43
49
  ### Removed
44
50
  - Removed AutoHeal([#707](https://github.com/opensearch-project/opensearch-js/pull/707))
45
51
  ### Fixed
46
52
  - Make optional fields optional in `MappingGenericProperty` ([708](https://github.com/opensearch-project/opensearch-js/pull/708))
47
- ### Security
48
53
 
49
54
  ## [2.5.0]
50
55
  ### Added
@@ -72,8 +77,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
72
77
  - Bumps `eslint-config-prettier` from 9.0.0 to 9.1.0
73
78
  - Bumps `ora` from 7.0.1 to 8.0.1
74
79
  - Bumps `simple-git` from 3.21.0 to 3.22.0
75
- ### Changed
76
- ### Deprecated
77
80
  ### Removed
78
81
  - Removed fixture lines that git-secrets wrongly flagged as passwords/secrets ([654](https://github.com/opensearch-project/opensearch-js/pull/645))
79
82
  ### Fixed
@@ -101,11 +104,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
101
104
  ### Changed
102
105
  - Make handling of long numerals an option that is disabled by default ([#557](https://github.com/opensearch-project/opensearch-js/pull/557))
103
106
  - Add `enableLongNumeralSupport` to the type definition for `ClientOptions` ([#598](https://github.com/opensearch-project/opensearch-js/pull/598))
104
- ### Deprecated
105
- ### Removed
106
107
  ### Fixed
107
108
  - Fix wrong documentation for file serach.md regarding `search_after` param ([#584](https://github.com/opensearch-project/opensearch-js/pull/584))
108
- ### Security
109
109
 
110
110
  ## [2.3.0]
111
111
 
@@ -126,24 +126,18 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
126
126
  - Implemented Docker Image caching for `integration-unreleased` workflow ([#387](https://github.com/opensearch-project/opensearch-js/issues/387))
127
127
  - Add upgrading NPM to all workflows running older Node.js versions ([#545](https://github.com/opensearch-project/opensearch-js/issues/545))
128
128
  - Upgrade and secure the backport workflow ([#547](https://github.com/opensearch-project/opensearch-js/issues/547))
129
- ### Deprecated
130
- ### Removed
131
129
  ### Fixed
132
130
  - Fixed malformed `bundler.yml` ([#497](https://github.com/opensearch-project/opensearch-js/pull/497))
133
- ### Security
134
131
 
135
132
  ## [2.2.1]
136
133
 
137
134
  ### Added
138
-
139
135
  - Add release details to releasing.md ([319](https://github.com/opensearch-project/opensearch-js/pull/319))
140
136
  - Added Amazon OpenSearch Serverless in user_guide ([#372](https://github.com/opensearch-project/opensearch-js/issues/372))
141
137
  - Add guidelines on installing yarn, dependencies; instructions on running ESLint in developer_guide ([#439](https://github.com/opensearch-project/opensearch-js/issues/435))
142
138
  - Added pull_request_template ([440](https://github.com/opensearch-project/opensearch-js/pull/440))
143
139
  - Added guide for Search ([#473](https://github.com/opensearch-project/opensearch-js/pull/489))
144
-
145
140
  ### Dependencies
146
-
147
141
  - Bumps `aws4` from 1.11.0 to 1.12.0
148
142
  - Bumps `minimist` from 1.2.6 to 1.2.8
149
143
  - Bumps `tsd` from 0.24.1 to 0.27.0
@@ -165,37 +159,26 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
165
159
  - Bumps `prettier` from 2.8.4 to 2.8.7
166
160
  - Bumps `jsdoc` from 4.0.0 to 4.0.2
167
161
  - Bumps `@babel/eslint-parser` from 7.19.1 to 7.21.3
168
-
169
162
  ### Changed
170
-
171
163
  - Remove test artifacts from gh_pages workflow ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
172
164
  - Make fields in `BulkOperation` optional to match OpenSearch Bulk API requirements ([#378](https://github.com/opensearch-project/opensearch-js/pull/378))
173
165
  - Remove guidance on using npm and switch completely to yarn in developer_guide ([#439](https://github.com/opensearch-project/opensearch-js/issues/435))
174
166
  - Change coverage, compatability, integration, integration with unreleased Open Search, node ci, bundler tests not to run on documentation change ([441](https://github.com/opensearch-project/opensearch-js/pull/441))
175
167
  - Change the Windows yarn installation troubleshoot steps ([455](https://github.com/opensearch-project/opensearch-js/issues/455))
176
168
  - Make `callback` arg in `BaseConnectionPool`, `CloudConnectionPool` and `ConnectionPool` optional ([#451](https://github.com/opensearch-project/opensearch-js/pull/451))
177
-
178
169
  ### Deprecated
179
-
180
170
  - Remove deprecation warnings in bulk.test.js ([#434](https://github.com/opensearch-project/opensearch-js/issues/434))
181
-
182
171
  ### Removed
183
-
184
172
  - Remove waitCluster in Integration Tests ([#422](https://github.com/opensearch-project/opensearch-js/issues/422))
185
-
186
173
  ### Fixed
187
-
188
174
  - Added missing types for AwsSigv4SignerOptions.service ([#377](https://github.com/opensearch-project/opensearch-js/pull/377))
189
175
  - Fixed deprecated folder mapping "./" in the "exports" field module resolution ([#416](https://github.com/opensearch-project/opensearch-js/pull/416))
190
176
 
191
- ### Security
192
-
193
177
  - [CVE-2022-25912] Bumps simple-git from 3.4.0 to 3.15.0 ([#341](https://github.com/opensearch-project/opensearch-js/pull/341))
194
178
 
195
179
  ## [2.2.0]
196
180
 
197
181
  ### Added
198
-
199
182
  - Add release details to releasing.md ([319](https://github.com/opensearch-project/opensearch-js/pull/319))
200
183
  - Allow overriding the aws service identifier in AwsSigv4Signer ([333](https://github.com/opensearch-project/opensearch-js/pull/333))
201
184
  - Added skip-changelog label ([339](https://github.com/opensearch-project/opensearch-js/pull/339))
@@ -209,9 +192,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
209
192
  - Fixed typos in `ConnectionPool` ([#427](https://github.com/opensearch-project/opensearch-js/pull/427))
210
193
  - Added the solution for the possible error during yarn installation on Windows OS ([#435](https://github.com/opensearch-project/opensearch-js/issues/435))
211
194
  - Added missing `createConnection` method type definition in `BaseConnectionPool` )([#490](https://github.com/opensearch-project/opensearch-js/pull/490))
212
-
213
195
  ### Dependencies
214
-
215
196
  - Bumps `xmlbuilder2` from 2.4.1 to 3.0.2
216
197
  - Bumps `minimatch` from 3.0.4 to 3.1.2
217
198
  - Bumps `eslint` from 7.32.0 to 8.32.0
@@ -224,36 +205,18 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
224
205
  - Bumps `hpagent` from 0.1.2 to 1.2.0
225
206
  - Bumps `eslint-config-prettier` from 8.5.0 to 8.6.0
226
207
  - Bumps `rimraf` from 3.0.2 to 4.1.1
227
-
228
- ### Dependencies
229
-
230
208
  ### Changed
231
-
232
209
  - Remove test artifacts from gh_pages workflow ([#335](https://github.com/opensearch-project/opensearch-js/issues/335))
233
210
  - Make `TimeoutError` and `RequestAbortedError` classes' `meta` argument optional ([#478](https://github.com/opensearch-project/opensearch-js/pull/478/))
234
-
235
- ### Deprecated
236
-
237
- ### Removed
238
-
239
- ### Fixed
240
-
241
211
  ### Security
242
-
243
212
  - [CVE-2022-25912] Bumps simple-git from 3.4.0 to 3.15.0 ([#341](https://github.com/opensearch-project/opensearch-js/pull/341))
244
213
 
245
214
  ## [2.1.0]
246
-
247
215
  ### Added
248
-
249
216
  - Github workflow for changelog verification ([#306](https://github.com/opensearch-project/opensearch-js/pull/306))
250
217
  - Add GitHub and Jenkins release workflow ([#317](https://github.com/opensearch-project/opensearch-js/pull/317))
251
-
252
218
  ### Dependencies
253
-
254
219
  - Bumps `tsd` from 0.22.0 to 0.24.1
255
220
  - Bumps `semver` from 7.3.7 to 7.3.8
256
-
257
221
  ### Fixed
258
-
259
222
  - Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))
package/USER_GUIDE.md CHANGED
@@ -90,7 +90,9 @@ const client = new Client({
90
90
  ```javascript
91
91
  const { defaultProvider } = require('@aws-sdk/credential-provider-node'); // V3 SDK.
92
92
  const { Client } = require('@opensearch-project/opensearch');
93
- const { AwsSigv4Signer } = require('@opensearch-project/opensearch/aws');
93
+ const { AwsSigv4Signer } = require('@opensearch-project/opensearch/aws-v3'); // use aws-v3 import path if you are using aws-sdk v3
94
+ // Unlike the import path in the v2 example above that lazy loads both aws-sdk v3 credential providers & entire aws-sdk v2 if available
95
+ // This will only lazy load the aws-sdk v3 credential providers
94
96
 
95
97
  const client = new Client({
96
98
  ...AwsSigv4Signer({
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * The OpenSearch Contributors require contributions made to
6
+ * this file be licensed under the Apache-2.0 license or a
7
+ * compatible open source license.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+ const AwsSigv4SignerError = require('./errors');
13
+ const { giveAwsV4Signer, giveAwsCredentialProviderLoader } = require('./shared');
14
+
15
+ const getAwsSDKCredentialsProvider = async () => {
16
+ try {
17
+ const awsV3 = await import('@aws-sdk/credential-provider-node');
18
+ if (typeof awsV3.defaultProvider === 'function') {
19
+ return awsV3.defaultProvider();
20
+ }
21
+ } catch (err) {
22
+ throw new AwsSigv4SignerError(
23
+ "Missing '@aws-sdk/credential-provider-node' module. Install it as a dependency."
24
+ );
25
+ }
26
+ };
27
+
28
+ const AwsSigv4Signer = giveAwsV4Signer(
29
+ giveAwsCredentialProviderLoader(getAwsSDKCredentialsProvider)
30
+ );
31
+
32
+ module.exports = AwsSigv4Signer;
@@ -9,12 +9,8 @@
9
9
  */
10
10
 
11
11
  'use strict';
12
- const Connection = require('../Connection');
13
- const Transport = require('../Transport');
14
- const aws4 = require('aws4');
15
12
  const AwsSigv4SignerError = require('./errors');
16
- const crypto = require('crypto');
17
- const { toMs } = Transport.internals;
13
+ const { giveAwsV4Signer, giveAwsCredentialProviderLoader } = require('./shared');
18
14
 
19
15
  const getAwsSDKCredentialsProvider = async () => {
20
16
  // First try V3
@@ -49,150 +45,8 @@ const getAwsSDKCredentialsProvider = async () => {
49
45
  );
50
46
  };
51
47
 
52
- const awsDefaultCredentialsProvider = () =>
53
- new Promise((resolve, reject) => {
54
- getAwsSDKCredentialsProvider()
55
- .then((provider) => {
56
- provider().then(resolve).catch(reject);
57
- })
58
- .catch((err) => {
59
- reject(err);
60
- });
61
- });
48
+ const AwsSigv4Signer = giveAwsV4Signer(
49
+ giveAwsCredentialProviderLoader(getAwsSDKCredentialsProvider)
50
+ );
62
51
 
63
- function AwsSigv4Signer(opts = {}) {
64
- const credentialsState = {
65
- credentials: null,
66
- };
67
- if (!opts.region) {
68
- throw new AwsSigv4SignerError('Region cannot be empty');
69
- }
70
- if (!opts.service) {
71
- opts.service = 'es';
72
- }
73
- if (typeof opts.getCredentials !== 'function') {
74
- opts.getCredentials = awsDefaultCredentialsProvider;
75
- }
76
-
77
- function buildSignedRequestObject(request = {}) {
78
- request.service = opts.service;
79
- request.region = opts.region;
80
- request.headers = request.headers || {};
81
- request.headers['host'] = request.hostname;
82
-
83
- if (request['auth']) {
84
- const awssigv4Cred = request['auth'];
85
- credentialsState.credentials = {
86
- accessKeyId: awssigv4Cred.credentials.accessKeyId,
87
- secretAccessKey: awssigv4Cred.credentials.secretAccessKey,
88
- sessionToken: awssigv4Cred.credentials.sessionToken,
89
- };
90
- request.region = awssigv4Cred.region;
91
- request.service = awssigv4Cred.service;
92
- delete request['auth'];
93
- }
94
- const signed = aws4.sign(request, credentialsState.credentials);
95
- signed.headers['x-amz-content-sha256'] = crypto
96
- .createHash('sha256')
97
- .update(request.body || '', 'utf8')
98
- .digest('hex');
99
- return signed;
100
- }
101
-
102
- class AwsSigv4SignerConnection extends Connection {
103
- buildRequestObject(params) {
104
- const request = super.buildRequestObject(params);
105
- return buildSignedRequestObject(request);
106
- }
107
- }
108
-
109
- class AwsSigv4SignerTransport extends Transport {
110
- request(params, options = {}, callback = undefined) {
111
- // options is optional so if options is a function, it's the callback.
112
- if (typeof options === 'function') {
113
- callback = options;
114
- options = {};
115
- }
116
-
117
- const currentCredentials = credentialsState.credentials;
118
- /**
119
- * For AWS SDK V3
120
- * Make sure token will expire no earlier than `expiryBufferMs` milliseconds in the future.
121
- */
122
- const expiryBufferMs = toMs(options.requestTimeout || this.requestTimeout);
123
-
124
- let expired = false;
125
- if (!currentCredentials) {
126
- // Credentials haven't been acquired yet.
127
- expired = true;
128
- }
129
- // AWS SDK V2, needsRefresh should be available.
130
- else if (typeof currentCredentials.needsRefresh === 'function') {
131
- expired = currentCredentials.needsRefresh();
132
- }
133
- // AWS SDK V2, alternative to needsRefresh.
134
- else if (currentCredentials.expired === true) {
135
- expired = true;
136
- }
137
- // AWS SDK V2, alternative to needsRefresh and expired.
138
- else if (currentCredentials.expireTime && currentCredentials.expireTime < new Date()) {
139
- expired = true;
140
- }
141
- // AWS SDK V3, Credentials.expiration is a Date object
142
- else if (
143
- currentCredentials.expiration &&
144
- currentCredentials.expiration.getTime() - Date.now() < expiryBufferMs
145
- ) {
146
- expired = true;
147
- }
148
-
149
- if (!expired) {
150
- if (typeof callback === 'undefined') {
151
- return super.request(params, options);
152
- }
153
- super.request(params, options, callback);
154
- return;
155
- }
156
-
157
- // In AWS SDK V2 Credentials.refreshPromise should be available.
158
- if (currentCredentials && typeof currentCredentials.refreshPromise === 'function') {
159
- if (typeof callback === 'undefined') {
160
- return currentCredentials.refreshPromise().then(() => {
161
- return super.request(params, options);
162
- });
163
- } else {
164
- currentCredentials
165
- .refreshPromise()
166
- .then(() => {
167
- super.request(params, options, callback);
168
- })
169
- .catch(callback);
170
- return;
171
- }
172
- }
173
-
174
- // For AWS SDK V3 or when the client has not acquired credentials yet.
175
- if (typeof callback === 'undefined') {
176
- return opts.getCredentials().then((credentials) => {
177
- credentialsState.credentials = credentials;
178
- return super.request(params, options);
179
- });
180
- } else {
181
- opts
182
- .getCredentials()
183
- .then((credentials) => {
184
- credentialsState.credentials = credentials;
185
- super.request(params, options, callback);
186
- })
187
- .catch(callback);
188
- }
189
- }
190
- }
191
-
192
- return {
193
- Transport: AwsSigv4SignerTransport,
194
- Connection: AwsSigv4SignerConnection,
195
- buildSignedRequestObject,
196
- };
197
- }
198
52
  module.exports = AwsSigv4Signer;
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * The OpenSearch Contributors require contributions made to
6
+ * this file be licensed under the Apache-2.0 license or a
7
+ * compatible open source license.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ const AwsSigv4Signer = require('./AwsSigv4Signer-sdk-v3');
14
+ const AwsSigv4SignerError = require('./errors');
15
+
16
+ module.exports = {
17
+ AwsSigv4Signer,
18
+ AwsSigv4SignerError,
19
+ };
@@ -0,0 +1,172 @@
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ *
5
+ * The OpenSearch Contributors require contributions made to
6
+ * this file be licensed under the Apache-2.0 license or a
7
+ * compatible open source license.
8
+ *
9
+ */
10
+
11
+ 'use strict';
12
+ const Connection = require('../Connection');
13
+ const Transport = require('../Transport');
14
+ const aws4 = require('aws4');
15
+ const AwsSigv4SignerError = require('./errors');
16
+ const crypto = require('crypto');
17
+ const { toMs } = Transport.internals;
18
+
19
+ function giveAwsCredentialProviderLoader(getAwsSDKCredentialsProvider) {
20
+ return function loadAwsCredentialProvider() {
21
+ return new Promise((resolve, reject) => {
22
+ getAwsSDKCredentialsProvider()
23
+ .then((provider) => {
24
+ provider().then(resolve).catch(reject);
25
+ })
26
+ .catch((err) => {
27
+ reject(err);
28
+ });
29
+ });
30
+ };
31
+ }
32
+
33
+ function giveAwsV4Signer(awsDefaultCredentialsProvider) {
34
+ return function AwsSigv4Signer(opts = {}) {
35
+ const credentialsState = {
36
+ credentials: null,
37
+ };
38
+ if (!opts.region) {
39
+ throw new AwsSigv4SignerError('Region cannot be empty');
40
+ }
41
+ if (!opts.service) {
42
+ opts.service = 'es';
43
+ }
44
+ if (typeof opts.getCredentials !== 'function') {
45
+ opts.getCredentials = awsDefaultCredentialsProvider;
46
+ }
47
+
48
+ function buildSignedRequestObject(request = {}) {
49
+ request.service = opts.service;
50
+ request.region = opts.region;
51
+ request.headers = request.headers || {};
52
+ request.headers['host'] = request.hostname;
53
+
54
+ if (request['auth']) {
55
+ const awssigv4Cred = request['auth'];
56
+ credentialsState.credentials = {
57
+ accessKeyId: awssigv4Cred.credentials.accessKeyId,
58
+ secretAccessKey: awssigv4Cred.credentials.secretAccessKey,
59
+ sessionToken: awssigv4Cred.credentials.sessionToken,
60
+ };
61
+ request.region = awssigv4Cred.region;
62
+ request.service = awssigv4Cred.service;
63
+ delete request['auth'];
64
+ }
65
+ const signed = aws4.sign(request, credentialsState.credentials);
66
+ signed.headers['x-amz-content-sha256'] = crypto
67
+ .createHash('sha256')
68
+ .update(request.body || '', 'utf8')
69
+ .digest('hex');
70
+ return signed;
71
+ }
72
+
73
+ class AwsSigv4SignerConnection extends Connection {
74
+ buildRequestObject(params) {
75
+ const request = super.buildRequestObject(params);
76
+ return buildSignedRequestObject(request);
77
+ }
78
+ }
79
+
80
+ class AwsSigv4SignerTransport extends Transport {
81
+ request(params, options = {}, callback = undefined) {
82
+ // options is optional so if options is a function, it's the callback.
83
+ if (typeof options === 'function') {
84
+ callback = options;
85
+ options = {};
86
+ }
87
+
88
+ const currentCredentials = credentialsState.credentials;
89
+ /**
90
+ * For AWS SDK V3
91
+ * Make sure token will expire no earlier than `expiryBufferMs` milliseconds in the future.
92
+ */
93
+ const expiryBufferMs = toMs(options.requestTimeout || this.requestTimeout);
94
+
95
+ let expired = false;
96
+ if (!currentCredentials) {
97
+ // Credentials haven't been acquired yet.
98
+ expired = true;
99
+ }
100
+ // AWS SDK V2, needsRefresh should be available.
101
+ else if (typeof currentCredentials.needsRefresh === 'function') {
102
+ expired = currentCredentials.needsRefresh();
103
+ }
104
+ // AWS SDK V2, alternative to needsRefresh.
105
+ else if (currentCredentials.expired === true) {
106
+ expired = true;
107
+ }
108
+ // AWS SDK V2, alternative to needsRefresh and expired.
109
+ else if (currentCredentials.expireTime && currentCredentials.expireTime < new Date()) {
110
+ expired = true;
111
+ }
112
+ // AWS SDK V3, Credentials.expiration is a Date object
113
+ else if (
114
+ currentCredentials.expiration &&
115
+ currentCredentials.expiration.getTime() - Date.now() < expiryBufferMs
116
+ ) {
117
+ expired = true;
118
+ }
119
+
120
+ if (!expired) {
121
+ if (typeof callback === 'undefined') {
122
+ return super.request(params, options);
123
+ }
124
+ super.request(params, options, callback);
125
+ return;
126
+ }
127
+
128
+ // In AWS SDK V2 Credentials.refreshPromise should be available.
129
+ if (currentCredentials && typeof currentCredentials.refreshPromise === 'function') {
130
+ if (typeof callback === 'undefined') {
131
+ return currentCredentials.refreshPromise().then(() => {
132
+ return super.request(params, options);
133
+ });
134
+ } else {
135
+ currentCredentials
136
+ .refreshPromise()
137
+ .then(() => {
138
+ super.request(params, options, callback);
139
+ })
140
+ .catch(callback);
141
+ return;
142
+ }
143
+ }
144
+
145
+ // For AWS SDK V3 or when the client has not acquired credentials yet.
146
+ if (typeof callback === 'undefined') {
147
+ return opts.getCredentials().then((credentials) => {
148
+ credentialsState.credentials = credentials;
149
+ return super.request(params, options);
150
+ });
151
+ } else {
152
+ opts
153
+ .getCredentials()
154
+ .then((credentials) => {
155
+ credentialsState.credentials = credentials;
156
+ super.request(params, options, callback);
157
+ })
158
+ .catch(callback);
159
+ }
160
+ }
161
+ }
162
+
163
+ return {
164
+ Transport: AwsSigv4SignerTransport,
165
+ Connection: AwsSigv4SignerConnection,
166
+ buildSignedRequestObject,
167
+ };
168
+ };
169
+ }
170
+
171
+ module.exports.giveAwsCredentialProviderLoader = giveAwsCredentialProviderLoader;
172
+ module.exports.giveAwsV4Signer = giveAwsV4Signer;
package/package.json CHANGED
@@ -16,6 +16,7 @@
16
16
  "types": "./api/types.d.ts"
17
17
  },
18
18
  "./aws": "./lib/aws/index.js",
19
+ "./aws-v3": "./lib/aws/index-v3.js",
19
20
  "./*": "./*"
20
21
  },
21
22
  "typesVersions": {
@@ -29,7 +30,7 @@
29
30
  }
30
31
  },
31
32
  "homepage": "https://www.opensearch.org/",
32
- "version": "2.7.0",
33
+ "version": "2.8.0",
33
34
  "versionCanary": "7.10.0-canary.6",
34
35
  "keywords": [
35
36
  "opensearch",
@@ -53,7 +54,7 @@
53
54
  "test:coverage-ui": "tap test/{unit,acceptance}/{*,**/*,**/**/*}.test.js --coverage --coverage-report=html --nyc-arg=\"--exclude=api\"",
54
55
  "lint": "eslint .",
55
56
  "lint:fix": "eslint . --fix",
56
- "license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause'",
57
+ "license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;0BSD;ISC;BSD-3-Clause;BSD-2-Clause'",
57
58
  "build-esm": "npx gen-esm-wrapper . index.mjs && eslint --fix index.mjs"
58
59
  },
59
60
  "author": "opensearch-project",