@digipair/skill-s3 0.94.0-8 → 0.95.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.
Files changed (47) hide show
  1. package/index.cjs.js +72 -0
  2. package/index.d.ts +1 -0
  3. package/index.esm.js +65 -0
  4. package/libs/skill-s3/src/index.d.ts +1 -0
  5. package/{dist → libs/skill-s3}/src/lib/skill-s3.d.ts +0 -1
  6. package/package.json +6 -20
  7. package/README.md +0 -7
  8. package/dist/index.cjs.js +0 -22
  9. package/dist/index.cjs10.js +0 -1581
  10. package/dist/index.cjs11.js +0 -2639
  11. package/dist/index.cjs2.js +0 -25
  12. package/dist/index.cjs3.js +0 -39239
  13. package/dist/index.cjs4.js +0 -450
  14. package/dist/index.cjs5.js +0 -3698
  15. package/dist/index.cjs6.js +0 -433
  16. package/dist/index.cjs7.js +0 -706
  17. package/dist/index.cjs8.js +0 -1691
  18. package/dist/index.cjs9.js +0 -1515
  19. package/dist/index.esm.js +0 -13
  20. package/dist/index.esm10.js +0 -1577
  21. package/dist/index.esm11.js +0 -2619
  22. package/dist/index.esm2.js +0 -13
  23. package/dist/index.esm3.js +0 -39118
  24. package/dist/index.esm4.js +0 -447
  25. package/dist/index.esm5.js +0 -3676
  26. package/dist/index.esm6.js +0 -431
  27. package/dist/index.esm7.js +0 -704
  28. package/dist/index.esm8.js +0 -1689
  29. package/dist/index.esm9.js +0 -1504
  30. package/dist/loadSso.cjs.js +0 -2092
  31. package/dist/loadSso.esm.js +0 -2089
  32. package/dist/noAuth.cjs.js +0 -167
  33. package/dist/noAuth.esm.js +0 -165
  34. package/dist/package.cjs.js +0 -187
  35. package/dist/package.esm.js +0 -184
  36. package/dist/parseJsonBody.cjs.js +0 -257
  37. package/dist/parseJsonBody.esm.js +0 -252
  38. package/dist/parseKnownFiles.cjs.js +0 -250
  39. package/dist/parseKnownFiles.esm.js +0 -248
  40. package/dist/src/index.d.ts +0 -2
  41. package/dist/src/index.d.ts.map +0 -1
  42. package/dist/src/lib/skill-s3.d.ts.map +0 -1
  43. package/dist/src/lib/skill-s3.spec.d.ts +0 -2
  44. package/dist/src/lib/skill-s3.spec.d.ts.map +0 -1
  45. /package/{dist/index.d.ts → index.cjs.d.ts} +0 -0
  46. /package/{dist/schema.fr.json → schema.fr.json} +0 -0
  47. /package/{dist/schema.json → schema.json} +0 -0
@@ -1,1581 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index.cjs3.js');
4
- require('os');
5
- require('path');
6
- require('crypto');
7
- var parseKnownFiles = require('./parseKnownFiles.cjs.js');
8
- var fs = require('fs');
9
- require('buffer');
10
- require('stream');
11
- require('node:stream');
12
- require('http');
13
- require('https');
14
- require('http2');
15
- require('zlib');
16
- require('process');
17
-
18
- function _assert_this_initialized(self) {
19
- if (self === void 0) {
20
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
21
- }
22
- return self;
23
- }
24
- function _class_call_check(instance, Constructor) {
25
- if (!(instance instanceof Constructor)) {
26
- throw new TypeError("Cannot call a class as a function");
27
- }
28
- }
29
- function _get_prototype_of(o) {
30
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
31
- return o.__proto__ || Object.getPrototypeOf(o);
32
- };
33
- return _get_prototype_of(o);
34
- }
35
- function _inherits(subClass, superClass) {
36
- if (typeof superClass !== "function" && superClass !== null) {
37
- throw new TypeError("Super expression must either be null or a function");
38
- }
39
- subClass.prototype = Object.create(superClass && superClass.prototype, {
40
- constructor: {
41
- value: subClass,
42
- writable: true,
43
- configurable: true
44
- }
45
- });
46
- if (superClass) _set_prototype_of(subClass, superClass);
47
- }
48
- function _possible_constructor_return(self, call) {
49
- if (call && (_type_of(call) === "object" || typeof call === "function")) {
50
- return call;
51
- }
52
- return _assert_this_initialized(self);
53
- }
54
- function _set_prototype_of(o, p) {
55
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
56
- o.__proto__ = p;
57
- return o;
58
- };
59
- return _set_prototype_of(o, p);
60
- }
61
- function _type_of(obj) {
62
- "@swc/helpers - typeof";
63
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
64
- }
65
- function _is_native_reflect_construct() {
66
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
67
- if (Reflect.construct.sham) return false;
68
- if (typeof Proxy === "function") return true;
69
- try {
70
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
71
- return true;
72
- } catch (e) {
73
- return false;
74
- }
75
- }
76
- function _create_super(Derived) {
77
- var hasNativeReflectConstruct = _is_native_reflect_construct();
78
- return function _createSuperInternal() {
79
- var Super = _get_prototype_of(Derived), result;
80
- if (hasNativeReflectConstruct) {
81
- var NewTarget = _get_prototype_of(this).constructor;
82
- result = Reflect.construct(Super, arguments, NewTarget);
83
- } else {
84
- result = Super.apply(this, arguments);
85
- }
86
- return _possible_constructor_return(this, result);
87
- };
88
- }
89
- var TokenProviderError = /*#__PURE__*/ function(ProviderError) {
90
- _inherits(TokenProviderError, ProviderError);
91
- var _super = _create_super(TokenProviderError);
92
- function TokenProviderError(message) {
93
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
94
- _class_call_check(this, TokenProviderError);
95
- var _this;
96
- _this = _super.call(this, message, options);
97
- _this.name = "TokenProviderError";
98
- Object.setPrototypeOf(_assert_this_initialized(_this), TokenProviderError.prototype);
99
- return _this;
100
- }
101
- return TokenProviderError;
102
- }(index.ProviderError);
103
-
104
- function _array_like_to_array(arr, len) {
105
- if (len == null || len > arr.length) len = arr.length;
106
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
107
- return arr2;
108
- }
109
- function _array_with_holes(arr) {
110
- if (Array.isArray(arr)) return arr;
111
- }
112
- function _define_property$2(obj, key, value) {
113
- if (key in obj) {
114
- Object.defineProperty(obj, key, {
115
- value: value,
116
- enumerable: true,
117
- configurable: true,
118
- writable: true
119
- });
120
- } else {
121
- obj[key] = value;
122
- }
123
- return obj;
124
- }
125
- function _iterable_to_array_limit(arr, i) {
126
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
127
- if (_i == null) return;
128
- var _arr = [];
129
- var _n = true;
130
- var _d = false;
131
- var _s, _e;
132
- try {
133
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
134
- _arr.push(_s.value);
135
- if (i && _arr.length === i) break;
136
- }
137
- } catch (err) {
138
- _d = true;
139
- _e = err;
140
- } finally{
141
- try {
142
- if (!_n && _i["return"] != null) _i["return"]();
143
- } finally{
144
- if (_d) throw _e;
145
- }
146
- }
147
- return _arr;
148
- }
149
- function _non_iterable_rest() {
150
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
151
- }
152
- function _object_spread$2(target) {
153
- for(var i = 1; i < arguments.length; i++){
154
- var source = arguments[i] != null ? arguments[i] : {};
155
- var ownKeys = Object.keys(source);
156
- if (typeof Object.getOwnPropertySymbols === "function") {
157
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
158
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
159
- }));
160
- }
161
- ownKeys.forEach(function(key) {
162
- _define_property$2(target, key, source[key]);
163
- });
164
- }
165
- return target;
166
- }
167
- function ownKeys$1(object, enumerableOnly) {
168
- var keys = Object.keys(object);
169
- if (Object.getOwnPropertySymbols) {
170
- var symbols = Object.getOwnPropertySymbols(object);
171
- keys.push.apply(keys, symbols);
172
- }
173
- return keys;
174
- }
175
- function _object_spread_props$1(target, source) {
176
- source = source != null ? source : {};
177
- if (Object.getOwnPropertyDescriptors) {
178
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
179
- } else {
180
- ownKeys$1(Object(source)).forEach(function(key) {
181
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
182
- });
183
- }
184
- return target;
185
- }
186
- function _sliced_to_array(arr, i) {
187
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
188
- }
189
- function _unsupported_iterable_to_array(o, minLen) {
190
- if (!o) return;
191
- if (typeof o === "string") return _array_like_to_array(o, minLen);
192
- var n = Object.prototype.toString.call(o).slice(8, -1);
193
- if (n === "Object" && o.constructor) n = o.constructor.name;
194
- if (n === "Map" || n === "Set") return Array.from(n);
195
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
196
- }
197
- var getSsoSessionData = function(data) {
198
- return Object.entries(data).filter(function(param) {
199
- var _param = _sliced_to_array(param, 1), key = _param[0];
200
- return key.startsWith(index.IniSectionType.SSO_SESSION + index.CONFIG_PREFIX_SEPARATOR);
201
- }).reduce(function(acc, param) {
202
- var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
203
- return _object_spread_props$1(_object_spread$2({}, acc), _define_property$2({}, key.substring(key.indexOf(index.CONFIG_PREFIX_SEPARATOR) + 1), value));
204
- }, {});
205
- };
206
-
207
- function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
208
- try {
209
- var info = gen[key](arg);
210
- var value = info.value;
211
- } catch (error) {
212
- reject(error);
213
- return;
214
- }
215
- if (info.done) {
216
- resolve(value);
217
- } else {
218
- Promise.resolve(value).then(_next, _throw);
219
- }
220
- }
221
- function _async_to_generator$5(fn) {
222
- return function() {
223
- var self = this, args = arguments;
224
- return new Promise(function(resolve, reject) {
225
- var gen = fn.apply(self, args);
226
- function _next(value) {
227
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
228
- }
229
- function _throw(err) {
230
- asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
231
- }
232
- _next(undefined);
233
- });
234
- };
235
- }
236
- function _ts_generator$5(thisArg, body) {
237
- var f, y, t, g, _ = {
238
- label: 0,
239
- sent: function() {
240
- if (t[0] & 1) throw t[1];
241
- return t[1];
242
- },
243
- trys: [],
244
- ops: []
245
- };
246
- return g = {
247
- next: verb(0),
248
- "throw": verb(1),
249
- "return": verb(2)
250
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
251
- return this;
252
- }), g;
253
- function verb(n) {
254
- return function(v) {
255
- return step([
256
- n,
257
- v
258
- ]);
259
- };
260
- }
261
- function step(op) {
262
- if (f) throw new TypeError("Generator is already executing.");
263
- while(_)try {
264
- 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;
265
- if (y = 0, t) op = [
266
- op[0] & 2,
267
- t.value
268
- ];
269
- switch(op[0]){
270
- case 0:
271
- case 1:
272
- t = op;
273
- break;
274
- case 4:
275
- _.label++;
276
- return {
277
- value: op[1],
278
- done: false
279
- };
280
- case 5:
281
- _.label++;
282
- y = op[1];
283
- op = [
284
- 0
285
- ];
286
- continue;
287
- case 7:
288
- op = _.ops.pop();
289
- _.trys.pop();
290
- continue;
291
- default:
292
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
293
- _ = 0;
294
- continue;
295
- }
296
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
297
- _.label = op[1];
298
- break;
299
- }
300
- if (op[0] === 6 && _.label < t[1]) {
301
- _.label = t[1];
302
- t = op;
303
- break;
304
- }
305
- if (t && _.label < t[2]) {
306
- _.label = t[2];
307
- _.ops.push(op);
308
- break;
309
- }
310
- if (t[2]) _.ops.pop();
311
- _.trys.pop();
312
- continue;
313
- }
314
- op = body.call(thisArg, _);
315
- } catch (e) {
316
- op = [
317
- 6,
318
- e
319
- ];
320
- y = 0;
321
- } finally{
322
- f = t = 0;
323
- }
324
- if (op[0] & 5) throw op[1];
325
- return {
326
- value: op[0] ? op[1] : void 0,
327
- done: true
328
- };
329
- }
330
- }
331
- var swallowError = function() {
332
- return {};
333
- };
334
- var loadSsoSessionData = function() {
335
- var _ref = _async_to_generator$5(function() {
336
- var init, _init_configFilepath;
337
- var _arguments = arguments;
338
- return _ts_generator$5(this, function(_state) {
339
- init = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {};
340
- return [
341
- 2,
342
- index.slurpFile((_init_configFilepath = init.configFilepath) !== null && _init_configFilepath !== void 0 ? _init_configFilepath : index.getConfigFilepath()).then(index.parseIni).then(getSsoSessionData).catch(swallowError)
343
- ];
344
- });
345
- });
346
- return function loadSsoSessionData() {
347
- return _ref.apply(this, arguments);
348
- };
349
- }();
350
-
351
- var isSsoProfile = function(arg) {
352
- return arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string");
353
- };
354
-
355
- var EXPIRE_WINDOW_MS = 5 * 60 * 1000;
356
- var REFRESH_MESSAGE = "To refresh this SSO session run 'aws sso login' with the corresponding profile.";
357
-
358
- function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
359
- try {
360
- var info = gen[key](arg);
361
- var value = info.value;
362
- } catch (error) {
363
- reject(error);
364
- return;
365
- }
366
- if (info.done) {
367
- resolve(value);
368
- } else {
369
- Promise.resolve(value).then(_next, _throw);
370
- }
371
- }
372
- function _async_to_generator$4(fn) {
373
- return function() {
374
- var self = this, args = arguments;
375
- return new Promise(function(resolve, reject) {
376
- var gen = fn.apply(self, args);
377
- function _next(value) {
378
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
379
- }
380
- function _throw(err) {
381
- asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
382
- }
383
- _next(undefined);
384
- });
385
- };
386
- }
387
- function _ts_generator$4(thisArg, body) {
388
- var f, y, t, g, _ = {
389
- label: 0,
390
- sent: function() {
391
- if (t[0] & 1) throw t[1];
392
- return t[1];
393
- },
394
- trys: [],
395
- ops: []
396
- };
397
- return g = {
398
- next: verb(0),
399
- "throw": verb(1),
400
- "return": verb(2)
401
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
402
- return this;
403
- }), g;
404
- function verb(n) {
405
- return function(v) {
406
- return step([
407
- n,
408
- v
409
- ]);
410
- };
411
- }
412
- function step(op) {
413
- if (f) throw new TypeError("Generator is already executing.");
414
- while(_)try {
415
- 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;
416
- if (y = 0, t) op = [
417
- op[0] & 2,
418
- t.value
419
- ];
420
- switch(op[0]){
421
- case 0:
422
- case 1:
423
- t = op;
424
- break;
425
- case 4:
426
- _.label++;
427
- return {
428
- value: op[1],
429
- done: false
430
- };
431
- case 5:
432
- _.label++;
433
- y = op[1];
434
- op = [
435
- 0
436
- ];
437
- continue;
438
- case 7:
439
- op = _.ops.pop();
440
- _.trys.pop();
441
- continue;
442
- default:
443
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
444
- _ = 0;
445
- continue;
446
- }
447
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
448
- _.label = op[1];
449
- break;
450
- }
451
- if (op[0] === 6 && _.label < t[1]) {
452
- _.label = t[1];
453
- t = op;
454
- break;
455
- }
456
- if (t && _.label < t[2]) {
457
- _.label = t[2];
458
- _.ops.push(op);
459
- break;
460
- }
461
- if (t[2]) _.ops.pop();
462
- _.trys.pop();
463
- continue;
464
- }
465
- op = body.call(thisArg, _);
466
- } catch (e) {
467
- op = [
468
- 6,
469
- e
470
- ];
471
- y = 0;
472
- } finally{
473
- f = t = 0;
474
- }
475
- if (op[0] & 5) throw op[1];
476
- return {
477
- value: op[0] ? op[1] : void 0,
478
- done: true
479
- };
480
- }
481
- }
482
- var getSsoOidcClient = function() {
483
- var _ref = _async_to_generator$4(function(ssoRegion) {
484
- var init, _init_clientConfig, _init_clientConfig1, _init_parentClientConfig, SSOOIDCClient, _init_clientConfig2, _init_clientConfig_logger, ssoOidcClient;
485
- var _arguments = arguments;
486
- return _ts_generator$4(this, function(_state) {
487
- switch(_state.label){
488
- case 0:
489
- init = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
490
- return [
491
- 4,
492
- Promise.resolve().then(function () { return require('./index.cjs11.js'); })
493
- ];
494
- case 1:
495
- SSOOIDCClient = _state.sent().SSOOIDCClient;
496
- ssoOidcClient = new SSOOIDCClient(Object.assign({}, (_init_clientConfig2 = init.clientConfig) !== null && _init_clientConfig2 !== void 0 ? _init_clientConfig2 : {}, {
497
- region: ssoRegion !== null && ssoRegion !== void 0 ? ssoRegion : (_init_clientConfig = init.clientConfig) === null || _init_clientConfig === void 0 ? void 0 : _init_clientConfig.region,
498
- logger: (_init_clientConfig_logger = (_init_clientConfig1 = init.clientConfig) === null || _init_clientConfig1 === void 0 ? void 0 : _init_clientConfig1.logger) !== null && _init_clientConfig_logger !== void 0 ? _init_clientConfig_logger : (_init_parentClientConfig = init.parentClientConfig) === null || _init_parentClientConfig === void 0 ? void 0 : _init_parentClientConfig.logger
499
- }));
500
- return [
501
- 2,
502
- ssoOidcClient
503
- ];
504
- }
505
- });
506
- });
507
- return function getSsoOidcClient(ssoRegion) {
508
- return _ref.apply(this, arguments);
509
- };
510
- }();
511
-
512
- function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
513
- try {
514
- var info = gen[key](arg);
515
- var value = info.value;
516
- } catch (error) {
517
- reject(error);
518
- return;
519
- }
520
- if (info.done) {
521
- resolve(value);
522
- } else {
523
- Promise.resolve(value).then(_next, _throw);
524
- }
525
- }
526
- function _async_to_generator$3(fn) {
527
- return function() {
528
- var self = this, args = arguments;
529
- return new Promise(function(resolve, reject) {
530
- var gen = fn.apply(self, args);
531
- function _next(value) {
532
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
533
- }
534
- function _throw(err) {
535
- asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
536
- }
537
- _next(undefined);
538
- });
539
- };
540
- }
541
- function _ts_generator$3(thisArg, body) {
542
- var f, y, t, g, _ = {
543
- label: 0,
544
- sent: function() {
545
- if (t[0] & 1) throw t[1];
546
- return t[1];
547
- },
548
- trys: [],
549
- ops: []
550
- };
551
- return g = {
552
- next: verb(0),
553
- "throw": verb(1),
554
- "return": verb(2)
555
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
556
- return this;
557
- }), g;
558
- function verb(n) {
559
- return function(v) {
560
- return step([
561
- n,
562
- v
563
- ]);
564
- };
565
- }
566
- function step(op) {
567
- if (f) throw new TypeError("Generator is already executing.");
568
- while(_)try {
569
- 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;
570
- if (y = 0, t) op = [
571
- op[0] & 2,
572
- t.value
573
- ];
574
- switch(op[0]){
575
- case 0:
576
- case 1:
577
- t = op;
578
- break;
579
- case 4:
580
- _.label++;
581
- return {
582
- value: op[1],
583
- done: false
584
- };
585
- case 5:
586
- _.label++;
587
- y = op[1];
588
- op = [
589
- 0
590
- ];
591
- continue;
592
- case 7:
593
- op = _.ops.pop();
594
- _.trys.pop();
595
- continue;
596
- default:
597
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
598
- _ = 0;
599
- continue;
600
- }
601
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
602
- _.label = op[1];
603
- break;
604
- }
605
- if (op[0] === 6 && _.label < t[1]) {
606
- _.label = t[1];
607
- t = op;
608
- break;
609
- }
610
- if (t && _.label < t[2]) {
611
- _.label = t[2];
612
- _.ops.push(op);
613
- break;
614
- }
615
- if (t[2]) _.ops.pop();
616
- _.trys.pop();
617
- continue;
618
- }
619
- op = body.call(thisArg, _);
620
- } catch (e) {
621
- op = [
622
- 6,
623
- e
624
- ];
625
- y = 0;
626
- } finally{
627
- f = t = 0;
628
- }
629
- if (op[0] & 5) throw op[1];
630
- return {
631
- value: op[0] ? op[1] : void 0,
632
- done: true
633
- };
634
- }
635
- }
636
- var getNewSsoOidcToken = function() {
637
- var _ref = _async_to_generator$3(function(ssoToken, ssoRegion) {
638
- var init, CreateTokenCommand, ssoOidcClient;
639
- var _arguments = arguments;
640
- return _ts_generator$3(this, function(_state) {
641
- switch(_state.label){
642
- case 0:
643
- init = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
644
- return [
645
- 4,
646
- Promise.resolve().then(function () { return require('./index.cjs11.js'); })
647
- ];
648
- case 1:
649
- CreateTokenCommand = _state.sent().CreateTokenCommand;
650
- return [
651
- 4,
652
- getSsoOidcClient(ssoRegion, init)
653
- ];
654
- case 2:
655
- ssoOidcClient = _state.sent();
656
- return [
657
- 2,
658
- ssoOidcClient.send(new CreateTokenCommand({
659
- clientId: ssoToken.clientId,
660
- clientSecret: ssoToken.clientSecret,
661
- refreshToken: ssoToken.refreshToken,
662
- grantType: "refresh_token"
663
- }))
664
- ];
665
- }
666
- });
667
- });
668
- return function getNewSsoOidcToken(ssoToken, ssoRegion) {
669
- return _ref.apply(this, arguments);
670
- };
671
- }();
672
-
673
- var validateTokenExpiry = function(token) {
674
- if (token.expiration && token.expiration.getTime() < Date.now()) {
675
- throw new TokenProviderError("Token is expired. ".concat(REFRESH_MESSAGE), false);
676
- }
677
- };
678
-
679
- var validateTokenKey = function(key, value) {
680
- var forRefresh = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
681
- if (typeof value === "undefined") {
682
- throw new TokenProviderError("Value not present for '".concat(key, "' in SSO Token").concat(forRefresh ? ". Cannot refresh" : "", ". ").concat(REFRESH_MESSAGE), false);
683
- }
684
- };
685
-
686
- var writeFile = fs.promises.writeFile;
687
- var writeSSOTokenToFile = function(id, ssoToken) {
688
- var tokenFilepath = index.getSSOTokenFilepath(id);
689
- var tokenString = JSON.stringify(ssoToken, null, 2);
690
- return writeFile(tokenFilepath, tokenString);
691
- };
692
-
693
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
694
- try {
695
- var info = gen[key](arg);
696
- var value = info.value;
697
- } catch (error) {
698
- reject(error);
699
- return;
700
- }
701
- if (info.done) {
702
- resolve(value);
703
- } else {
704
- Promise.resolve(value).then(_next, _throw);
705
- }
706
- }
707
- function _async_to_generator$2(fn) {
708
- return function() {
709
- var self = this, args = arguments;
710
- return new Promise(function(resolve, reject) {
711
- var gen = fn.apply(self, args);
712
- function _next(value) {
713
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
714
- }
715
- function _throw(err) {
716
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
717
- }
718
- _next(undefined);
719
- });
720
- };
721
- }
722
- function _define_property$1(obj, key, value) {
723
- if (key in obj) {
724
- Object.defineProperty(obj, key, {
725
- value: value,
726
- enumerable: true,
727
- configurable: true,
728
- writable: true
729
- });
730
- } else {
731
- obj[key] = value;
732
- }
733
- return obj;
734
- }
735
- function _object_spread$1(target) {
736
- for(var i = 1; i < arguments.length; i++){
737
- var source = arguments[i] != null ? arguments[i] : {};
738
- var ownKeys = Object.keys(source);
739
- if (typeof Object.getOwnPropertySymbols === "function") {
740
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
741
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
742
- }));
743
- }
744
- ownKeys.forEach(function(key) {
745
- _define_property$1(target, key, source[key]);
746
- });
747
- }
748
- return target;
749
- }
750
- function ownKeys(object, enumerableOnly) {
751
- var keys = Object.keys(object);
752
- if (Object.getOwnPropertySymbols) {
753
- var symbols = Object.getOwnPropertySymbols(object);
754
- keys.push.apply(keys, symbols);
755
- }
756
- return keys;
757
- }
758
- function _object_spread_props(target, source) {
759
- source = source != null ? source : {};
760
- if (Object.getOwnPropertyDescriptors) {
761
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
762
- } else {
763
- ownKeys(Object(source)).forEach(function(key) {
764
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
765
- });
766
- }
767
- return target;
768
- }
769
- function _ts_generator$2(thisArg, body) {
770
- var f, y, t, g, _ = {
771
- label: 0,
772
- sent: function() {
773
- if (t[0] & 1) throw t[1];
774
- return t[1];
775
- },
776
- trys: [],
777
- ops: []
778
- };
779
- return g = {
780
- next: verb(0),
781
- "throw": verb(1),
782
- "return": verb(2)
783
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
784
- return this;
785
- }), g;
786
- function verb(n) {
787
- return function(v) {
788
- return step([
789
- n,
790
- v
791
- ]);
792
- };
793
- }
794
- function step(op) {
795
- if (f) throw new TypeError("Generator is already executing.");
796
- while(_)try {
797
- 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;
798
- if (y = 0, t) op = [
799
- op[0] & 2,
800
- t.value
801
- ];
802
- switch(op[0]){
803
- case 0:
804
- case 1:
805
- t = op;
806
- break;
807
- case 4:
808
- _.label++;
809
- return {
810
- value: op[1],
811
- done: false
812
- };
813
- case 5:
814
- _.label++;
815
- y = op[1];
816
- op = [
817
- 0
818
- ];
819
- continue;
820
- case 7:
821
- op = _.ops.pop();
822
- _.trys.pop();
823
- continue;
824
- default:
825
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
826
- _ = 0;
827
- continue;
828
- }
829
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
830
- _.label = op[1];
831
- break;
832
- }
833
- if (op[0] === 6 && _.label < t[1]) {
834
- _.label = t[1];
835
- t = op;
836
- break;
837
- }
838
- if (t && _.label < t[2]) {
839
- _.label = t[2];
840
- _.ops.push(op);
841
- break;
842
- }
843
- if (t[2]) _.ops.pop();
844
- _.trys.pop();
845
- continue;
846
- }
847
- op = body.call(thisArg, _);
848
- } catch (e) {
849
- op = [
850
- 6,
851
- e
852
- ];
853
- y = 0;
854
- } finally{
855
- f = t = 0;
856
- }
857
- if (op[0] & 5) throw op[1];
858
- return {
859
- value: op[0] ? op[1] : void 0,
860
- done: true
861
- };
862
- }
863
- }
864
- var lastRefreshAttemptTime = new Date(0);
865
- var fromSso = function() {
866
- var _init = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
867
- return /*#__PURE__*/ _async_to_generator$2(function() {
868
- var callerClientConfig, _init_logger, init, profiles, _init_profile, profileName, profile, ssoSessionName, ssoSessions, ssoSession, _i, _iter, ssoSessionRequiredKey, ssoRegion, ssoToken, accessToken, expiresAt, existingToken, newSsoOidcToken, newTokenExpiration;
869
- var _arguments = arguments;
870
- return _ts_generator$2(this, function(_state) {
871
- switch(_state.label){
872
- case 0:
873
- callerClientConfig = (_arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}).callerClientConfig;
874
- init = _object_spread_props(_object_spread$1({}, _init), {
875
- parentClientConfig: _object_spread$1({}, callerClientConfig, _init.parentClientConfig)
876
- });
877
- (_init_logger = init.logger) === null || _init_logger === void 0 ? void 0 : _init_logger.debug("@aws-sdk/token-providers - fromSso");
878
- return [
879
- 4,
880
- parseKnownFiles.parseKnownFiles(init)
881
- ];
882
- case 1:
883
- profiles = _state.sent();
884
- profileName = index.getProfileName({
885
- profile: (_init_profile = init.profile) !== null && _init_profile !== void 0 ? _init_profile : callerClientConfig === null || callerClientConfig === void 0 ? void 0 : callerClientConfig.profile
886
- });
887
- profile = profiles[profileName];
888
- if (!profile) {
889
- throw new TokenProviderError("Profile '".concat(profileName, "' could not be found in shared credentials file."), false);
890
- } else if (!profile["sso_session"]) {
891
- throw new TokenProviderError("Profile '".concat(profileName, "' is missing required property 'sso_session'."));
892
- }
893
- ssoSessionName = profile["sso_session"];
894
- return [
895
- 4,
896
- loadSsoSessionData(init)
897
- ];
898
- case 2:
899
- ssoSessions = _state.sent();
900
- ssoSession = ssoSessions[ssoSessionName];
901
- if (!ssoSession) {
902
- throw new TokenProviderError("Sso session '".concat(ssoSessionName, "' could not be found in shared credentials file."), false);
903
- }
904
- for(_i = 0, _iter = [
905
- "sso_start_url",
906
- "sso_region"
907
- ]; _i < _iter.length; _i++){
908
- ssoSessionRequiredKey = _iter[_i];
909
- if (!ssoSession[ssoSessionRequiredKey]) {
910
- throw new TokenProviderError("Sso session '".concat(ssoSessionName, "' is missing required property '").concat(ssoSessionRequiredKey, "'."), false);
911
- }
912
- }
913
- ssoSession["sso_start_url"];
914
- ssoRegion = ssoSession["sso_region"];
915
- _state.label = 3;
916
- case 3:
917
- _state.trys.push([
918
- 3,
919
- 5,
920
- ,
921
- 6
922
- ]);
923
- return [
924
- 4,
925
- index.getSSOTokenFromFile(ssoSessionName)
926
- ];
927
- case 4:
928
- ssoToken = _state.sent();
929
- return [
930
- 3,
931
- 6
932
- ];
933
- case 5:
934
- _state.sent();
935
- throw new TokenProviderError("The SSO session token associated with profile=".concat(profileName, " was not found or is invalid. ").concat(REFRESH_MESSAGE), false);
936
- case 6:
937
- validateTokenKey("accessToken", ssoToken.accessToken);
938
- validateTokenKey("expiresAt", ssoToken.expiresAt);
939
- accessToken = ssoToken.accessToken, expiresAt = ssoToken.expiresAt;
940
- existingToken = {
941
- token: accessToken,
942
- expiration: new Date(expiresAt)
943
- };
944
- if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
945
- return [
946
- 2,
947
- existingToken
948
- ];
949
- }
950
- if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1000) {
951
- validateTokenExpiry(existingToken);
952
- return [
953
- 2,
954
- existingToken
955
- ];
956
- }
957
- validateTokenKey("clientId", ssoToken.clientId, true);
958
- validateTokenKey("clientSecret", ssoToken.clientSecret, true);
959
- validateTokenKey("refreshToken", ssoToken.refreshToken, true);
960
- _state.label = 7;
961
- case 7:
962
- _state.trys.push([
963
- 7,
964
- 13,
965
- ,
966
- 14
967
- ]);
968
- lastRefreshAttemptTime.setTime(Date.now());
969
- return [
970
- 4,
971
- getNewSsoOidcToken(ssoToken, ssoRegion, init)
972
- ];
973
- case 8:
974
- newSsoOidcToken = _state.sent();
975
- validateTokenKey("accessToken", newSsoOidcToken.accessToken);
976
- validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
977
- newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1000);
978
- _state.label = 9;
979
- case 9:
980
- _state.trys.push([
981
- 9,
982
- 11,
983
- ,
984
- 12
985
- ]);
986
- return [
987
- 4,
988
- writeSSOTokenToFile(ssoSessionName, _object_spread_props(_object_spread$1({}, ssoToken), {
989
- accessToken: newSsoOidcToken.accessToken,
990
- expiresAt: newTokenExpiration.toISOString(),
991
- refreshToken: newSsoOidcToken.refreshToken
992
- }))
993
- ];
994
- case 10:
995
- _state.sent();
996
- return [
997
- 3,
998
- 12
999
- ];
1000
- case 11:
1001
- _state.sent();
1002
- return [
1003
- 3,
1004
- 12
1005
- ];
1006
- case 12:
1007
- return [
1008
- 2,
1009
- {
1010
- token: newSsoOidcToken.accessToken,
1011
- expiration: newTokenExpiration
1012
- }
1013
- ];
1014
- case 13:
1015
- _state.sent();
1016
- validateTokenExpiry(existingToken);
1017
- return [
1018
- 2,
1019
- existingToken
1020
- ];
1021
- case 14:
1022
- return [
1023
- 2
1024
- ];
1025
- }
1026
- });
1027
- });
1028
- };
1029
-
1030
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
1031
- try {
1032
- var info = gen[key](arg);
1033
- var value = info.value;
1034
- } catch (error) {
1035
- reject(error);
1036
- return;
1037
- }
1038
- if (info.done) {
1039
- resolve(value);
1040
- } else {
1041
- Promise.resolve(value).then(_next, _throw);
1042
- }
1043
- }
1044
- function _async_to_generator$1(fn) {
1045
- return function() {
1046
- var self = this, args = arguments;
1047
- return new Promise(function(resolve, reject) {
1048
- var gen = fn.apply(self, args);
1049
- function _next(value) {
1050
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
1051
- }
1052
- function _throw(err) {
1053
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
1054
- }
1055
- _next(undefined);
1056
- });
1057
- };
1058
- }
1059
- function _define_property(obj, key, value) {
1060
- if (key in obj) {
1061
- Object.defineProperty(obj, key, {
1062
- value: value,
1063
- enumerable: true,
1064
- configurable: true,
1065
- writable: true
1066
- });
1067
- } else {
1068
- obj[key] = value;
1069
- }
1070
- return obj;
1071
- }
1072
- function _object_spread(target) {
1073
- for(var i = 1; i < arguments.length; i++){
1074
- var source = arguments[i] != null ? arguments[i] : {};
1075
- var ownKeys = Object.keys(source);
1076
- if (typeof Object.getOwnPropertySymbols === "function") {
1077
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1078
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1079
- }));
1080
- }
1081
- ownKeys.forEach(function(key) {
1082
- _define_property(target, key, source[key]);
1083
- });
1084
- }
1085
- return target;
1086
- }
1087
- function _ts_generator$1(thisArg, body) {
1088
- var f, y, t, g, _ = {
1089
- label: 0,
1090
- sent: function() {
1091
- if (t[0] & 1) throw t[1];
1092
- return t[1];
1093
- },
1094
- trys: [],
1095
- ops: []
1096
- };
1097
- return g = {
1098
- next: verb(0),
1099
- "throw": verb(1),
1100
- "return": verb(2)
1101
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1102
- return this;
1103
- }), g;
1104
- function verb(n) {
1105
- return function(v) {
1106
- return step([
1107
- n,
1108
- v
1109
- ]);
1110
- };
1111
- }
1112
- function step(op) {
1113
- if (f) throw new TypeError("Generator is already executing.");
1114
- while(_)try {
1115
- 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;
1116
- if (y = 0, t) op = [
1117
- op[0] & 2,
1118
- t.value
1119
- ];
1120
- switch(op[0]){
1121
- case 0:
1122
- case 1:
1123
- t = op;
1124
- break;
1125
- case 4:
1126
- _.label++;
1127
- return {
1128
- value: op[1],
1129
- done: false
1130
- };
1131
- case 5:
1132
- _.label++;
1133
- y = op[1];
1134
- op = [
1135
- 0
1136
- ];
1137
- continue;
1138
- case 7:
1139
- op = _.ops.pop();
1140
- _.trys.pop();
1141
- continue;
1142
- default:
1143
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1144
- _ = 0;
1145
- continue;
1146
- }
1147
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1148
- _.label = op[1];
1149
- break;
1150
- }
1151
- if (op[0] === 6 && _.label < t[1]) {
1152
- _.label = t[1];
1153
- t = op;
1154
- break;
1155
- }
1156
- if (t && _.label < t[2]) {
1157
- _.label = t[2];
1158
- _.ops.push(op);
1159
- break;
1160
- }
1161
- if (t[2]) _.ops.pop();
1162
- _.trys.pop();
1163
- continue;
1164
- }
1165
- op = body.call(thisArg, _);
1166
- } catch (e) {
1167
- op = [
1168
- 6,
1169
- e
1170
- ];
1171
- y = 0;
1172
- } finally{
1173
- f = t = 0;
1174
- }
1175
- if (op[0] & 5) throw op[1];
1176
- return {
1177
- value: op[0] ? op[1] : void 0,
1178
- done: true
1179
- };
1180
- }
1181
- }
1182
- var SHOULD_FAIL_CREDENTIAL_CHAIN = false;
1183
- var resolveSSOCredentials = function() {
1184
- var _ref = _async_to_generator$1(function(param) {
1185
- var ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, profile, logger, token, refreshMessage, _token, e, accessToken, _ref, SSOClient, GetRoleCredentialsCommand, _clientConfig_logger, _clientConfig_region, sso, ssoResp, e2, tmp, _ref1, accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId, credentials;
1186
- return _ts_generator$1(this, function(_state) {
1187
- switch(_state.label){
1188
- case 0:
1189
- ssoStartUrl = param.ssoStartUrl, ssoSession = param.ssoSession, ssoAccountId = param.ssoAccountId, ssoRegion = param.ssoRegion, ssoRoleName = param.ssoRoleName, ssoClient = param.ssoClient, clientConfig = param.clientConfig, parentClientConfig = param.parentClientConfig, profile = param.profile, logger = param.logger;
1190
- refreshMessage = "To refresh this SSO session run aws sso login with the corresponding profile.";
1191
- if (!ssoSession) return [
1192
- 3,
1193
- 5
1194
- ];
1195
- _state.label = 1;
1196
- case 1:
1197
- _state.trys.push([
1198
- 1,
1199
- 3,
1200
- ,
1201
- 4
1202
- ]);
1203
- return [
1204
- 4,
1205
- fromSso({
1206
- profile: profile
1207
- })()
1208
- ];
1209
- case 2:
1210
- _token = _state.sent();
1211
- token = {
1212
- accessToken: _token.token,
1213
- expiresAt: new Date(_token.expiration).toISOString()
1214
- };
1215
- return [
1216
- 3,
1217
- 4
1218
- ];
1219
- case 3:
1220
- e = _state.sent();
1221
- throw new index.CredentialsProviderError(e.message, {
1222
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1223
- logger: logger
1224
- });
1225
- case 4:
1226
- return [
1227
- 3,
1228
- 8
1229
- ];
1230
- case 5:
1231
- _state.trys.push([
1232
- 5,
1233
- 7,
1234
- ,
1235
- 8
1236
- ]);
1237
- return [
1238
- 4,
1239
- index.getSSOTokenFromFile(ssoStartUrl)
1240
- ];
1241
- case 6:
1242
- token = _state.sent();
1243
- return [
1244
- 3,
1245
- 8
1246
- ];
1247
- case 7:
1248
- _state.sent();
1249
- throw new index.CredentialsProviderError("The SSO session associated with this profile is invalid. ".concat(refreshMessage), {
1250
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1251
- logger: logger
1252
- });
1253
- case 8:
1254
- if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
1255
- throw new index.CredentialsProviderError("The SSO session associated with this profile has expired. ".concat(refreshMessage), {
1256
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1257
- logger: logger
1258
- });
1259
- }
1260
- accessToken = token.accessToken;
1261
- return [
1262
- 4,
1263
- Promise.resolve().then(function () { return require('./loadSso.cjs.js'); })
1264
- ];
1265
- case 9:
1266
- _ref = _state.sent(), SSOClient = _ref.SSOClient, GetRoleCredentialsCommand = _ref.GetRoleCredentialsCommand;
1267
- sso = ssoClient || new SSOClient(Object.assign({}, clientConfig !== null && clientConfig !== void 0 ? clientConfig : {}, {
1268
- logger: (_clientConfig_logger = clientConfig === null || clientConfig === void 0 ? void 0 : clientConfig.logger) !== null && _clientConfig_logger !== void 0 ? _clientConfig_logger : parentClientConfig === null || parentClientConfig === void 0 ? void 0 : parentClientConfig.logger,
1269
- region: (_clientConfig_region = clientConfig === null || clientConfig === void 0 ? void 0 : clientConfig.region) !== null && _clientConfig_region !== void 0 ? _clientConfig_region : ssoRegion
1270
- }));
1271
- _state.label = 10;
1272
- case 10:
1273
- _state.trys.push([
1274
- 10,
1275
- 12,
1276
- ,
1277
- 13
1278
- ]);
1279
- return [
1280
- 4,
1281
- sso.send(new GetRoleCredentialsCommand({
1282
- accountId: ssoAccountId,
1283
- roleName: ssoRoleName,
1284
- accessToken: accessToken
1285
- }))
1286
- ];
1287
- case 11:
1288
- ssoResp = _state.sent();
1289
- return [
1290
- 3,
1291
- 13
1292
- ];
1293
- case 12:
1294
- e2 = _state.sent();
1295
- throw new index.CredentialsProviderError(e2, {
1296
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1297
- logger: logger
1298
- });
1299
- case 13:
1300
- tmp = ssoResp.roleCredentials, _ref1 = tmp === void 0 ? {} : tmp, accessKeyId = _ref1.accessKeyId, secretAccessKey = _ref1.secretAccessKey, sessionToken = _ref1.sessionToken, expiration = _ref1.expiration, credentialScope = _ref1.credentialScope, accountId = _ref1.accountId;
1301
- if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
1302
- throw new index.CredentialsProviderError("SSO returns an invalid temporary credential.", {
1303
- tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
1304
- logger: logger
1305
- });
1306
- }
1307
- credentials = _object_spread({
1308
- accessKeyId: accessKeyId,
1309
- secretAccessKey: secretAccessKey,
1310
- sessionToken: sessionToken,
1311
- expiration: new Date(expiration)
1312
- }, credentialScope && {
1313
- credentialScope: credentialScope
1314
- }, accountId && {
1315
- accountId: accountId
1316
- });
1317
- if (ssoSession) {
1318
- index.setCredentialFeature(credentials, "CREDENTIALS_SSO", "s");
1319
- } else {
1320
- index.setCredentialFeature(credentials, "CREDENTIALS_SSO_LEGACY", "u");
1321
- }
1322
- return [
1323
- 2,
1324
- credentials
1325
- ];
1326
- }
1327
- });
1328
- });
1329
- return function resolveSSOCredentials(_) {
1330
- return _ref.apply(this, arguments);
1331
- };
1332
- }();
1333
-
1334
- var validateSsoProfile = function(profile, logger) {
1335
- var sso_start_url = profile.sso_start_url, sso_account_id = profile.sso_account_id, sso_region = profile.sso_region, sso_role_name = profile.sso_role_name;
1336
- if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
1337
- throw new index.CredentialsProviderError('Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", ' + '"sso_region", "sso_role_name", "sso_start_url". Got '.concat(Object.keys(profile).join(", "), "\nReference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html"), {
1338
- tryNextLink: false,
1339
- logger: logger
1340
- });
1341
- }
1342
- return profile;
1343
- };
1344
-
1345
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1346
- try {
1347
- var info = gen[key](arg);
1348
- var value = info.value;
1349
- } catch (error) {
1350
- reject(error);
1351
- return;
1352
- }
1353
- if (info.done) {
1354
- resolve(value);
1355
- } else {
1356
- Promise.resolve(value).then(_next, _throw);
1357
- }
1358
- }
1359
- function _async_to_generator(fn) {
1360
- return function() {
1361
- var self = this, args = arguments;
1362
- return new Promise(function(resolve, reject) {
1363
- var gen = fn.apply(self, args);
1364
- function _next(value) {
1365
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1366
- }
1367
- function _throw(err) {
1368
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1369
- }
1370
- _next(undefined);
1371
- });
1372
- };
1373
- }
1374
- function _ts_generator(thisArg, body) {
1375
- var f, y, t, g, _ = {
1376
- label: 0,
1377
- sent: function() {
1378
- if (t[0] & 1) throw t[1];
1379
- return t[1];
1380
- },
1381
- trys: [],
1382
- ops: []
1383
- };
1384
- return g = {
1385
- next: verb(0),
1386
- "throw": verb(1),
1387
- "return": verb(2)
1388
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1389
- return this;
1390
- }), g;
1391
- function verb(n) {
1392
- return function(v) {
1393
- return step([
1394
- n,
1395
- v
1396
- ]);
1397
- };
1398
- }
1399
- function step(op) {
1400
- if (f) throw new TypeError("Generator is already executing.");
1401
- while(_)try {
1402
- 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;
1403
- if (y = 0, t) op = [
1404
- op[0] & 2,
1405
- t.value
1406
- ];
1407
- switch(op[0]){
1408
- case 0:
1409
- case 1:
1410
- t = op;
1411
- break;
1412
- case 4:
1413
- _.label++;
1414
- return {
1415
- value: op[1],
1416
- done: false
1417
- };
1418
- case 5:
1419
- _.label++;
1420
- y = op[1];
1421
- op = [
1422
- 0
1423
- ];
1424
- continue;
1425
- case 7:
1426
- op = _.ops.pop();
1427
- _.trys.pop();
1428
- continue;
1429
- default:
1430
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1431
- _ = 0;
1432
- continue;
1433
- }
1434
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1435
- _.label = op[1];
1436
- break;
1437
- }
1438
- if (op[0] === 6 && _.label < t[1]) {
1439
- _.label = t[1];
1440
- t = op;
1441
- break;
1442
- }
1443
- if (t && _.label < t[2]) {
1444
- _.label = t[2];
1445
- _.ops.push(op);
1446
- break;
1447
- }
1448
- if (t[2]) _.ops.pop();
1449
- _.trys.pop();
1450
- continue;
1451
- }
1452
- op = body.call(thisArg, _);
1453
- } catch (e) {
1454
- op = [
1455
- 6,
1456
- e
1457
- ];
1458
- y = 0;
1459
- } finally{
1460
- f = t = 0;
1461
- }
1462
- if (op[0] & 5) throw op[1];
1463
- return {
1464
- value: op[0] ? op[1] : void 0,
1465
- done: true
1466
- };
1467
- }
1468
- }
1469
- var fromSSO = function() {
1470
- var init = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1471
- return /*#__PURE__*/ _async_to_generator(function() {
1472
- var callerClientConfig, _init_logger, ssoStartUrl, ssoAccountId, ssoRegion, ssoRoleName, ssoSession, ssoClient, _init_profile, profileName, profiles, profile, ssoSessions, session, conflictMsg, _validateSsoProfile, sso_start_url, sso_account_id, sso_region, sso_role_name, sso_session;
1473
- var _arguments = arguments;
1474
- return _ts_generator(this, function(_state) {
1475
- switch(_state.label){
1476
- case 0:
1477
- callerClientConfig = (_arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}).callerClientConfig;
1478
- (_init_logger = init.logger) === null || _init_logger === void 0 ? void 0 : _init_logger.debug("@aws-sdk/credential-provider-sso - fromSSO");
1479
- ssoStartUrl = init.ssoStartUrl, ssoAccountId = init.ssoAccountId, ssoRegion = init.ssoRegion, ssoRoleName = init.ssoRoleName, ssoSession = init.ssoSession;
1480
- ssoClient = init.ssoClient;
1481
- profileName = index.getProfileName({
1482
- profile: (_init_profile = init.profile) !== null && _init_profile !== void 0 ? _init_profile : callerClientConfig === null || callerClientConfig === void 0 ? void 0 : callerClientConfig.profile
1483
- });
1484
- if (!(!ssoStartUrl && !ssoAccountId && !ssoRegion && !ssoRoleName && !ssoSession)) return [
1485
- 3,
1486
- 4
1487
- ];
1488
- return [
1489
- 4,
1490
- parseKnownFiles.parseKnownFiles(init)
1491
- ];
1492
- case 1:
1493
- profiles = _state.sent();
1494
- profile = profiles[profileName];
1495
- if (!profile) {
1496
- throw new index.CredentialsProviderError("Profile ".concat(profileName, " was not found."), {
1497
- logger: init.logger
1498
- });
1499
- }
1500
- if (!isSsoProfile(profile)) {
1501
- throw new index.CredentialsProviderError("Profile ".concat(profileName, " is not configured with SSO credentials."), {
1502
- logger: init.logger
1503
- });
1504
- }
1505
- if (!(profile === null || profile === void 0 ? void 0 : profile.sso_session)) return [
1506
- 3,
1507
- 3
1508
- ];
1509
- return [
1510
- 4,
1511
- loadSsoSessionData(init)
1512
- ];
1513
- case 2:
1514
- ssoSessions = _state.sent();
1515
- session = ssoSessions[profile.sso_session];
1516
- conflictMsg = " configurations in profile ".concat(profileName, " and sso-session ").concat(profile.sso_session);
1517
- if (ssoRegion && ssoRegion !== session.sso_region) {
1518
- throw new index.CredentialsProviderError("Conflicting SSO region" + conflictMsg, {
1519
- tryNextLink: false,
1520
- logger: init.logger
1521
- });
1522
- }
1523
- if (ssoStartUrl && ssoStartUrl !== session.sso_start_url) {
1524
- throw new index.CredentialsProviderError("Conflicting SSO start_url" + conflictMsg, {
1525
- tryNextLink: false,
1526
- logger: init.logger
1527
- });
1528
- }
1529
- profile.sso_region = session.sso_region;
1530
- profile.sso_start_url = session.sso_start_url;
1531
- _state.label = 3;
1532
- case 3:
1533
- _validateSsoProfile = validateSsoProfile(profile, init.logger), sso_start_url = _validateSsoProfile.sso_start_url, sso_account_id = _validateSsoProfile.sso_account_id, sso_region = _validateSsoProfile.sso_region, sso_role_name = _validateSsoProfile.sso_role_name, sso_session = _validateSsoProfile.sso_session;
1534
- return [
1535
- 2,
1536
- resolveSSOCredentials({
1537
- ssoStartUrl: sso_start_url,
1538
- ssoSession: sso_session,
1539
- ssoAccountId: sso_account_id,
1540
- ssoRegion: sso_region,
1541
- ssoRoleName: sso_role_name,
1542
- ssoClient: ssoClient,
1543
- clientConfig: init.clientConfig,
1544
- parentClientConfig: init.parentClientConfig,
1545
- profile: profileName
1546
- })
1547
- ];
1548
- case 4:
1549
- if (!ssoStartUrl || !ssoAccountId || !ssoRegion || !ssoRoleName) {
1550
- throw new index.CredentialsProviderError("Incomplete configuration. The fromSSO() argument hash must include " + '"ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"', {
1551
- tryNextLink: false,
1552
- logger: init.logger
1553
- });
1554
- } else {
1555
- return [
1556
- 2,
1557
- resolveSSOCredentials({
1558
- ssoStartUrl: ssoStartUrl,
1559
- ssoSession: ssoSession,
1560
- ssoAccountId: ssoAccountId,
1561
- ssoRegion: ssoRegion,
1562
- ssoRoleName: ssoRoleName,
1563
- ssoClient: ssoClient,
1564
- clientConfig: init.clientConfig,
1565
- parentClientConfig: init.parentClientConfig,
1566
- profile: profileName
1567
- })
1568
- ];
1569
- }
1570
- case 5:
1571
- return [
1572
- 2
1573
- ];
1574
- }
1575
- });
1576
- });
1577
- };
1578
-
1579
- exports.fromSSO = fromSSO;
1580
- exports.isSsoProfile = isSsoProfile;
1581
- exports.validateSsoProfile = validateSsoProfile;