@digipair/skill-s3 0.114.1 → 0.114.3

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.
@@ -0,0 +1,434 @@
1
+ import { exec } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import { s as setCredentialFeature, C as CredentialsProviderError, j as getProfileName } from './index.esm3.js';
4
+ import { e as externalDataInterceptor } from './externalDataInterceptor.esm.js';
5
+ import { p as parseKnownFiles } from './parseKnownFiles.esm.js';
6
+ import 'buffer';
7
+ import 'path';
8
+ import 'os';
9
+ import 'fs';
10
+ import 'stream';
11
+ import 'crypto';
12
+ import 'http';
13
+ import 'https';
14
+ import 'process';
15
+ import 'node:fs';
16
+ import 'async_hooks';
17
+ import 'zlib';
18
+ import 'node:stream';
19
+ import './getSSOTokenFromFile.esm.js';
20
+
21
+ function _define_property(obj, key, value) {
22
+ if (key in obj) {
23
+ Object.defineProperty(obj, key, {
24
+ value: value,
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true
28
+ });
29
+ } else {
30
+ obj[key] = value;
31
+ }
32
+ return obj;
33
+ }
34
+ function _object_spread(target) {
35
+ for(var i = 1; i < arguments.length; i++){
36
+ var source = arguments[i] != null ? arguments[i] : {};
37
+ var ownKeys = Object.keys(source);
38
+ if (typeof Object.getOwnPropertySymbols === "function") {
39
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
40
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
41
+ }));
42
+ }
43
+ ownKeys.forEach(function(key) {
44
+ _define_property(target, key, source[key]);
45
+ });
46
+ }
47
+ return target;
48
+ }
49
+ var getValidatedProcessCredentials = function(profileName, data, profiles) {
50
+ var _profiles_profileName;
51
+ if (data.Version !== 1) {
52
+ throw Error("Profile ".concat(profileName, " credential_process did not return Version 1."));
53
+ }
54
+ if (data.AccessKeyId === undefined || data.SecretAccessKey === undefined) {
55
+ throw Error("Profile ".concat(profileName, " credential_process returned invalid credentials."));
56
+ }
57
+ if (data.Expiration) {
58
+ var currentTime = new Date();
59
+ var expireTime = new Date(data.Expiration);
60
+ if (expireTime < currentTime) {
61
+ throw Error("Profile ".concat(profileName, " credential_process returned expired credentials."));
62
+ }
63
+ }
64
+ var accountId = data.AccountId;
65
+ if (!accountId && (profiles === null || profiles === void 0 ? void 0 : (_profiles_profileName = profiles[profileName]) === null || _profiles_profileName === void 0 ? void 0 : _profiles_profileName.aws_account_id)) {
66
+ accountId = profiles[profileName].aws_account_id;
67
+ }
68
+ var credentials = _object_spread({
69
+ accessKeyId: data.AccessKeyId,
70
+ secretAccessKey: data.SecretAccessKey
71
+ }, data.SessionToken && {
72
+ sessionToken: data.SessionToken
73
+ }, data.Expiration && {
74
+ expiration: new Date(data.Expiration)
75
+ }, data.CredentialScope && {
76
+ credentialScope: data.CredentialScope
77
+ }, accountId && {
78
+ accountId: accountId
79
+ });
80
+ setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
81
+ return credentials;
82
+ };
83
+
84
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
85
+ try {
86
+ var info = gen[key](arg);
87
+ var value = info.value;
88
+ } catch (error) {
89
+ reject(error);
90
+ return;
91
+ }
92
+ if (info.done) {
93
+ resolve(value);
94
+ } else {
95
+ Promise.resolve(value).then(_next, _throw);
96
+ }
97
+ }
98
+ function _async_to_generator$1(fn) {
99
+ return function() {
100
+ var self = this, args = arguments;
101
+ return new Promise(function(resolve, reject) {
102
+ var gen = fn.apply(self, args);
103
+ function _next(value) {
104
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
105
+ }
106
+ function _throw(err) {
107
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
108
+ }
109
+ _next(undefined);
110
+ });
111
+ };
112
+ }
113
+ function _ts_generator$1(thisArg, body) {
114
+ var f, y, t, g, _ = {
115
+ label: 0,
116
+ sent: function() {
117
+ if (t[0] & 1) throw t[1];
118
+ return t[1];
119
+ },
120
+ trys: [],
121
+ ops: []
122
+ };
123
+ return g = {
124
+ next: verb(0),
125
+ "throw": verb(1),
126
+ "return": verb(2)
127
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
128
+ return this;
129
+ }), g;
130
+ function verb(n) {
131
+ return function(v) {
132
+ return step([
133
+ n,
134
+ v
135
+ ]);
136
+ };
137
+ }
138
+ function step(op) {
139
+ if (f) throw new TypeError("Generator is already executing.");
140
+ while(_)try {
141
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
142
+ if (y = 0, t) op = [
143
+ op[0] & 2,
144
+ t.value
145
+ ];
146
+ switch(op[0]){
147
+ case 0:
148
+ case 1:
149
+ t = op;
150
+ break;
151
+ case 4:
152
+ _.label++;
153
+ return {
154
+ value: op[1],
155
+ done: false
156
+ };
157
+ case 5:
158
+ _.label++;
159
+ y = op[1];
160
+ op = [
161
+ 0
162
+ ];
163
+ continue;
164
+ case 7:
165
+ op = _.ops.pop();
166
+ _.trys.pop();
167
+ continue;
168
+ default:
169
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
170
+ _ = 0;
171
+ continue;
172
+ }
173
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
174
+ _.label = op[1];
175
+ break;
176
+ }
177
+ if (op[0] === 6 && _.label < t[1]) {
178
+ _.label = t[1];
179
+ t = op;
180
+ break;
181
+ }
182
+ if (t && _.label < t[2]) {
183
+ _.label = t[2];
184
+ _.ops.push(op);
185
+ break;
186
+ }
187
+ if (t[2]) _.ops.pop();
188
+ _.trys.pop();
189
+ continue;
190
+ }
191
+ op = body.call(thisArg, _);
192
+ } catch (e) {
193
+ op = [
194
+ 6,
195
+ e
196
+ ];
197
+ y = 0;
198
+ } finally{
199
+ f = t = 0;
200
+ }
201
+ if (op[0] & 5) throw op[1];
202
+ return {
203
+ value: op[0] ? op[1] : void 0,
204
+ done: true
205
+ };
206
+ }
207
+ }
208
+ var resolveProcessCredentials = function() {
209
+ var _ref = _async_to_generator$1(function(profileName, profiles, logger) {
210
+ var profile, credentialProcess, _externalDataInterceptor_getTokenRecord, _externalDataInterceptor_getTokenRecord_exec, execPromise, stdout, data, error;
211
+ return _ts_generator$1(this, function(_state) {
212
+ switch(_state.label){
213
+ case 0:
214
+ profile = profiles[profileName];
215
+ if (!profiles[profileName]) return [
216
+ 3,
217
+ 7
218
+ ];
219
+ credentialProcess = profile["credential_process"];
220
+ if (!(credentialProcess !== undefined)) return [
221
+ 3,
222
+ 5
223
+ ];
224
+ execPromise = promisify((_externalDataInterceptor_getTokenRecord_exec = externalDataInterceptor === null || externalDataInterceptor === void 0 ? void 0 : (_externalDataInterceptor_getTokenRecord = externalDataInterceptor.getTokenRecord) === null || _externalDataInterceptor_getTokenRecord === void 0 ? void 0 : _externalDataInterceptor_getTokenRecord.call(externalDataInterceptor).exec) !== null && _externalDataInterceptor_getTokenRecord_exec !== void 0 ? _externalDataInterceptor_getTokenRecord_exec : exec);
225
+ _state.label = 1;
226
+ case 1:
227
+ _state.trys.push([
228
+ 1,
229
+ 3,
230
+ ,
231
+ 4
232
+ ]);
233
+ return [
234
+ 4,
235
+ execPromise(credentialProcess)
236
+ ];
237
+ case 2:
238
+ stdout = _state.sent().stdout;
239
+ try {
240
+ data = JSON.parse(stdout.trim());
241
+ } catch (e) {
242
+ throw Error("Profile ".concat(profileName, " credential_process returned invalid JSON."));
243
+ }
244
+ return [
245
+ 2,
246
+ getValidatedProcessCredentials(profileName, data, profiles)
247
+ ];
248
+ case 3:
249
+ error = _state.sent();
250
+ throw new CredentialsProviderError(error.message, {
251
+ logger: logger
252
+ });
253
+ case 4:
254
+ return [
255
+ 3,
256
+ 6
257
+ ];
258
+ case 5:
259
+ throw new CredentialsProviderError("Profile ".concat(profileName, " did not contain credential_process."), {
260
+ logger: logger
261
+ });
262
+ case 6:
263
+ return [
264
+ 3,
265
+ 8
266
+ ];
267
+ case 7:
268
+ throw new CredentialsProviderError("Profile ".concat(profileName, " could not be found in shared credentials file."), {
269
+ logger: logger
270
+ });
271
+ case 8:
272
+ return [
273
+ 2
274
+ ];
275
+ }
276
+ });
277
+ });
278
+ return function resolveProcessCredentials(profileName, profiles, logger) {
279
+ return _ref.apply(this, arguments);
280
+ };
281
+ }();
282
+
283
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
284
+ try {
285
+ var info = gen[key](arg);
286
+ var value = info.value;
287
+ } catch (error) {
288
+ reject(error);
289
+ return;
290
+ }
291
+ if (info.done) {
292
+ resolve(value);
293
+ } else {
294
+ Promise.resolve(value).then(_next, _throw);
295
+ }
296
+ }
297
+ function _async_to_generator(fn) {
298
+ return function() {
299
+ var self = this, args = arguments;
300
+ return new Promise(function(resolve, reject) {
301
+ var gen = fn.apply(self, args);
302
+ function _next(value) {
303
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
304
+ }
305
+ function _throw(err) {
306
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
307
+ }
308
+ _next(undefined);
309
+ });
310
+ };
311
+ }
312
+ function _ts_generator(thisArg, body) {
313
+ var f, y, t, g, _ = {
314
+ label: 0,
315
+ sent: function() {
316
+ if (t[0] & 1) throw t[1];
317
+ return t[1];
318
+ },
319
+ trys: [],
320
+ ops: []
321
+ };
322
+ return g = {
323
+ next: verb(0),
324
+ "throw": verb(1),
325
+ "return": verb(2)
326
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
327
+ return this;
328
+ }), g;
329
+ function verb(n) {
330
+ return function(v) {
331
+ return step([
332
+ n,
333
+ v
334
+ ]);
335
+ };
336
+ }
337
+ function step(op) {
338
+ if (f) throw new TypeError("Generator is already executing.");
339
+ while(_)try {
340
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
341
+ if (y = 0, t) op = [
342
+ op[0] & 2,
343
+ t.value
344
+ ];
345
+ switch(op[0]){
346
+ case 0:
347
+ case 1:
348
+ t = op;
349
+ break;
350
+ case 4:
351
+ _.label++;
352
+ return {
353
+ value: op[1],
354
+ done: false
355
+ };
356
+ case 5:
357
+ _.label++;
358
+ y = op[1];
359
+ op = [
360
+ 0
361
+ ];
362
+ continue;
363
+ case 7:
364
+ op = _.ops.pop();
365
+ _.trys.pop();
366
+ continue;
367
+ default:
368
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
369
+ _ = 0;
370
+ continue;
371
+ }
372
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
373
+ _.label = op[1];
374
+ break;
375
+ }
376
+ if (op[0] === 6 && _.label < t[1]) {
377
+ _.label = t[1];
378
+ t = op;
379
+ break;
380
+ }
381
+ if (t && _.label < t[2]) {
382
+ _.label = t[2];
383
+ _.ops.push(op);
384
+ break;
385
+ }
386
+ if (t[2]) _.ops.pop();
387
+ _.trys.pop();
388
+ continue;
389
+ }
390
+ op = body.call(thisArg, _);
391
+ } catch (e) {
392
+ op = [
393
+ 6,
394
+ e
395
+ ];
396
+ y = 0;
397
+ } finally{
398
+ f = t = 0;
399
+ }
400
+ if (op[0] & 5) throw op[1];
401
+ return {
402
+ value: op[0] ? op[1] : void 0,
403
+ done: true
404
+ };
405
+ }
406
+ }
407
+ var fromProcess = function() {
408
+ var init = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
409
+ return /*#__PURE__*/ _async_to_generator(function() {
410
+ var callerClientConfig, _init_logger, profiles, _init_profile;
411
+ var _arguments = arguments;
412
+ return _ts_generator(this, function(_state) {
413
+ switch(_state.label){
414
+ case 0:
415
+ callerClientConfig = (_arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}).callerClientConfig;
416
+ (_init_logger = init.logger) === null || _init_logger === void 0 ? void 0 : _init_logger.debug("@aws-sdk/credential-provider-process - fromProcess");
417
+ return [
418
+ 4,
419
+ parseKnownFiles(init)
420
+ ];
421
+ case 1:
422
+ profiles = _state.sent();
423
+ return [
424
+ 2,
425
+ resolveProcessCredentials(getProfileName({
426
+ profile: (_init_profile = init.profile) !== null && _init_profile !== void 0 ? _init_profile : callerClientConfig === null || callerClientConfig === void 0 ? void 0 : callerClientConfig.profile
427
+ }), profiles, init.logger)
428
+ ];
429
+ }
430
+ });
431
+ });
432
+ };
433
+
434
+ export { fromProcess };