@allthings/sdk 6.2.0-1 → 6.2.0-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.
package/dist/lib.esm.js CHANGED
@@ -1,13 +1,82 @@
1
+ import { SSMClient, GetParametersCommand, GetParameterCommand } from '@aws-sdk/client-ssm';
1
2
  import querystring from 'query-string';
2
3
  import fetch from 'cross-fetch';
3
4
  import Bottleneck from 'bottleneck';
4
- import util from 'util';
5
- import stream from 'stream';
6
- import path from 'path';
7
- import http from 'http';
8
- import https from 'https';
9
- import url from 'url';
10
- import fs from 'fs';
5
+ import require$$1 from 'util';
6
+ import require$$0$1 from 'stream';
7
+ import require$$1$1 from 'path';
8
+ import require$$3 from 'http';
9
+ import require$$4 from 'https';
10
+ import require$$5 from 'url';
11
+ import require$$6 from 'fs';
12
+
13
+ var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ const DEFAULT_CLIENT_CONFIG = {
25
+ clientConfig: DEFAULT_AWS_CONFIGURATION,
26
+ onlyDefault: false,
27
+ prefix: process.env.SSM_PARAM_PATH,
28
+ };
29
+ const getSecrets = async (ssm, config, params, defaultValue = '') => {
30
+ var _a, _b;
31
+ if (config.onlyDefault) {
32
+ return [defaultValue];
33
+ }
34
+ try {
35
+ const parameters = await ssm.send(new GetParametersCommand({
36
+ Names: params.map((param) => config.prefix + param),
37
+ WithDecryption: true,
38
+ }));
39
+ return ((_b = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.Parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => { var _a; return (_a = parameter.Value) !== null && _a !== void 0 ? _a : defaultValue; })) !== null && _b !== void 0 ? _b : [defaultValue]);
40
+ }
41
+ catch (e) {
42
+ if (config.logger) {
43
+ config.logger(e);
44
+ }
45
+ return [defaultValue];
46
+ }
47
+ };
48
+ const getSecret = async (ssm, config, param, defaultValue = '') => {
49
+ var _a, _b;
50
+ if (config.onlyDefault) {
51
+ return defaultValue;
52
+ }
53
+ try {
54
+ const parameter = await ssm.send(new GetParameterCommand({
55
+ Name: config.prefix + param,
56
+ WithDecryption: true,
57
+ }));
58
+ return (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.Parameter) === null || _a === void 0 ? void 0 : _a.Value) !== null && _b !== void 0 ? _b : defaultValue;
59
+ }
60
+ catch (e) {
61
+ if (config.logger) {
62
+ config.logger(e);
63
+ }
64
+ return defaultValue;
65
+ }
66
+ };
67
+ const parameterStore = (userConfig) => {
68
+ const _a = Object.assign(Object.assign({}, DEFAULT_CLIENT_CONFIG), userConfig), { clientConfig } = _a, config = __rest$5(_a, ["clientConfig"]);
69
+ const ssm = new SSMClient(clientConfig);
70
+ return {
71
+ getSecret: (param, defaultValue) => getSecret(ssm, config, param, defaultValue),
72
+ getSecrets: (params, defaultValue) => getSecrets(ssm, config, params, defaultValue),
73
+ };
74
+ };
75
+
76
+ const DEFAULT_AWS_CONFIGURATION = {
77
+ region: 'eu-central-2',
78
+ };
79
+ var index = { parameterStore };
11
80
 
12
81
  function createTokenStore(initialToken) {
13
82
  const token = new Map(Object.entries(initialToken || {}));
@@ -18,7 +87,7 @@ function createTokenStore(initialToken) {
18
87
  };
19
88
  }
20
89
 
21
- const version = "6.2.0-1";
90
+ const version = "6.2.0-3";
22
91
 
23
92
  const REST_API_URL = 'https://api.allthings.me';
24
93
  const OAUTH_URL = 'https://accounts.allthings.me';
@@ -847,11 +916,15 @@ async function put(request, method, body, returnRawResultObject, headers) {
847
916
  return request('put', method, { body, headers }, returnRawResultObject);
848
917
  }
849
918
 
850
- var Stream$2 = stream.Stream;
919
+ function getDefaultExportFromCjs (x) {
920
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
921
+ }
851
922
 
923
+ var Stream$2 = require$$0$1.Stream;
924
+ var util$2 = require$$1;
852
925
 
853
- var delayed_stream = DelayedStream;
854
- function DelayedStream() {
926
+ var delayed_stream = DelayedStream$1;
927
+ function DelayedStream$1() {
855
928
  this.source = null;
856
929
  this.dataSize = 0;
857
930
  this.maxDataSize = 1024 * 1024;
@@ -861,9 +934,9 @@ function DelayedStream() {
861
934
  this._released = false;
862
935
  this._bufferedEvents = [];
863
936
  }
864
- util.inherits(DelayedStream, Stream$2);
937
+ util$2.inherits(DelayedStream$1, Stream$2);
865
938
 
866
- DelayedStream.create = function(source, options) {
939
+ DelayedStream$1.create = function(source, options) {
867
940
  var delayedStream = new this();
868
941
 
869
942
  options = options || {};
@@ -887,7 +960,7 @@ DelayedStream.create = function(source, options) {
887
960
  return delayedStream;
888
961
  };
889
962
 
890
- Object.defineProperty(DelayedStream.prototype, 'readable', {
963
+ Object.defineProperty(DelayedStream$1.prototype, 'readable', {
891
964
  configurable: true,
892
965
  enumerable: true,
893
966
  get: function() {
@@ -895,11 +968,11 @@ Object.defineProperty(DelayedStream.prototype, 'readable', {
895
968
  }
896
969
  });
897
970
 
898
- DelayedStream.prototype.setEncoding = function() {
971
+ DelayedStream$1.prototype.setEncoding = function() {
899
972
  return this.source.setEncoding.apply(this.source, arguments);
900
973
  };
901
974
 
902
- DelayedStream.prototype.resume = function() {
975
+ DelayedStream$1.prototype.resume = function() {
903
976
  if (!this._released) {
904
977
  this.release();
905
978
  }
@@ -907,11 +980,11 @@ DelayedStream.prototype.resume = function() {
907
980
  this.source.resume();
908
981
  };
909
982
 
910
- DelayedStream.prototype.pause = function() {
983
+ DelayedStream$1.prototype.pause = function() {
911
984
  this.source.pause();
912
985
  };
913
986
 
914
- DelayedStream.prototype.release = function() {
987
+ DelayedStream$1.prototype.release = function() {
915
988
  this._released = true;
916
989
 
917
990
  this._bufferedEvents.forEach(function(args) {
@@ -920,13 +993,13 @@ DelayedStream.prototype.release = function() {
920
993
  this._bufferedEvents = [];
921
994
  };
922
995
 
923
- DelayedStream.prototype.pipe = function() {
996
+ DelayedStream$1.prototype.pipe = function() {
924
997
  var r = Stream$2.prototype.pipe.apply(this, arguments);
925
998
  this.resume();
926
999
  return r;
927
1000
  };
928
1001
 
929
- DelayedStream.prototype._handleEmit = function(args) {
1002
+ DelayedStream$1.prototype._handleEmit = function(args) {
930
1003
  if (this._released) {
931
1004
  this.emit.apply(this, args);
932
1005
  return;
@@ -940,7 +1013,7 @@ DelayedStream.prototype._handleEmit = function(args) {
940
1013
  this._bufferedEvents.push(args);
941
1014
  };
942
1015
 
943
- DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
1016
+ DelayedStream$1.prototype._checkIfMaxDataSizeExceeded = function() {
944
1017
  if (this._maxDataSizeExceeded) {
945
1018
  return;
946
1019
  }
@@ -955,11 +1028,12 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
955
1028
  this.emit('error', new Error(message));
956
1029
  };
957
1030
 
958
- var Stream$1 = stream.Stream;
959
-
1031
+ var util$1 = require$$1;
1032
+ var Stream$1 = require$$0$1.Stream;
1033
+ var DelayedStream = delayed_stream;
960
1034
 
961
- var combined_stream = CombinedStream;
962
- function CombinedStream() {
1035
+ var combined_stream = CombinedStream$1;
1036
+ function CombinedStream$1() {
963
1037
  this.writable = false;
964
1038
  this.readable = true;
965
1039
  this.dataSize = 0;
@@ -972,9 +1046,9 @@ function CombinedStream() {
972
1046
  this._insideLoop = false;
973
1047
  this._pendingNext = false;
974
1048
  }
975
- util.inherits(CombinedStream, Stream$1);
1049
+ util$1.inherits(CombinedStream$1, Stream$1);
976
1050
 
977
- CombinedStream.create = function(options) {
1051
+ CombinedStream$1.create = function(options) {
978
1052
  var combinedStream = new this();
979
1053
 
980
1054
  options = options || {};
@@ -985,7 +1059,7 @@ CombinedStream.create = function(options) {
985
1059
  return combinedStream;
986
1060
  };
987
1061
 
988
- CombinedStream.isStreamLike = function(stream) {
1062
+ CombinedStream$1.isStreamLike = function(stream) {
989
1063
  return (typeof stream !== 'function')
990
1064
  && (typeof stream !== 'string')
991
1065
  && (typeof stream !== 'boolean')
@@ -993,12 +1067,12 @@ CombinedStream.isStreamLike = function(stream) {
993
1067
  && (!Buffer.isBuffer(stream));
994
1068
  };
995
1069
 
996
- CombinedStream.prototype.append = function(stream) {
997
- var isStreamLike = CombinedStream.isStreamLike(stream);
1070
+ CombinedStream$1.prototype.append = function(stream) {
1071
+ var isStreamLike = CombinedStream$1.isStreamLike(stream);
998
1072
 
999
1073
  if (isStreamLike) {
1000
- if (!(stream instanceof delayed_stream)) {
1001
- var newStream = delayed_stream.create(stream, {
1074
+ if (!(stream instanceof DelayedStream)) {
1075
+ var newStream = DelayedStream.create(stream, {
1002
1076
  maxDataSize: Infinity,
1003
1077
  pauseStream: this.pauseStreams,
1004
1078
  });
@@ -1017,13 +1091,13 @@ CombinedStream.prototype.append = function(stream) {
1017
1091
  return this;
1018
1092
  };
1019
1093
 
1020
- CombinedStream.prototype.pipe = function(dest, options) {
1094
+ CombinedStream$1.prototype.pipe = function(dest, options) {
1021
1095
  Stream$1.prototype.pipe.call(this, dest, options);
1022
1096
  this.resume();
1023
1097
  return dest;
1024
1098
  };
1025
1099
 
1026
- CombinedStream.prototype._getNext = function() {
1100
+ CombinedStream$1.prototype._getNext = function() {
1027
1101
  this._currentStream = null;
1028
1102
 
1029
1103
  if (this._insideLoop) {
@@ -1042,7 +1116,7 @@ CombinedStream.prototype._getNext = function() {
1042
1116
  }
1043
1117
  };
1044
1118
 
1045
- CombinedStream.prototype._realGetNext = function() {
1119
+ CombinedStream$1.prototype._realGetNext = function() {
1046
1120
  var stream = this._streams.shift();
1047
1121
 
1048
1122
 
@@ -1058,7 +1132,7 @@ CombinedStream.prototype._realGetNext = function() {
1058
1132
 
1059
1133
  var getStream = stream;
1060
1134
  getStream(function(stream) {
1061
- var isStreamLike = CombinedStream.isStreamLike(stream);
1135
+ var isStreamLike = CombinedStream$1.isStreamLike(stream);
1062
1136
  if (isStreamLike) {
1063
1137
  stream.on('data', this._checkDataSize.bind(this));
1064
1138
  this._handleErrors(stream);
@@ -1068,10 +1142,10 @@ CombinedStream.prototype._realGetNext = function() {
1068
1142
  }.bind(this));
1069
1143
  };
1070
1144
 
1071
- CombinedStream.prototype._pipeNext = function(stream) {
1145
+ CombinedStream$1.prototype._pipeNext = function(stream) {
1072
1146
  this._currentStream = stream;
1073
1147
 
1074
- var isStreamLike = CombinedStream.isStreamLike(stream);
1148
+ var isStreamLike = CombinedStream$1.isStreamLike(stream);
1075
1149
  if (isStreamLike) {
1076
1150
  stream.on('end', this._getNext.bind(this));
1077
1151
  stream.pipe(this, {end: false});
@@ -1083,18 +1157,18 @@ CombinedStream.prototype._pipeNext = function(stream) {
1083
1157
  this._getNext();
1084
1158
  };
1085
1159
 
1086
- CombinedStream.prototype._handleErrors = function(stream) {
1160
+ CombinedStream$1.prototype._handleErrors = function(stream) {
1087
1161
  var self = this;
1088
1162
  stream.on('error', function(err) {
1089
1163
  self._emitError(err);
1090
1164
  });
1091
1165
  };
1092
1166
 
1093
- CombinedStream.prototype.write = function(data) {
1167
+ CombinedStream$1.prototype.write = function(data) {
1094
1168
  this.emit('data', data);
1095
1169
  };
1096
1170
 
1097
- CombinedStream.prototype.pause = function() {
1171
+ CombinedStream$1.prototype.pause = function() {
1098
1172
  if (!this.pauseStreams) {
1099
1173
  return;
1100
1174
  }
@@ -1103,7 +1177,7 @@ CombinedStream.prototype.pause = function() {
1103
1177
  this.emit('pause');
1104
1178
  };
1105
1179
 
1106
- CombinedStream.prototype.resume = function() {
1180
+ CombinedStream$1.prototype.resume = function() {
1107
1181
  if (!this._released) {
1108
1182
  this._released = true;
1109
1183
  this.writable = true;
@@ -1114,23 +1188,23 @@ CombinedStream.prototype.resume = function() {
1114
1188
  this.emit('resume');
1115
1189
  };
1116
1190
 
1117
- CombinedStream.prototype.end = function() {
1191
+ CombinedStream$1.prototype.end = function() {
1118
1192
  this._reset();
1119
1193
  this.emit('end');
1120
1194
  };
1121
1195
 
1122
- CombinedStream.prototype.destroy = function() {
1196
+ CombinedStream$1.prototype.destroy = function() {
1123
1197
  this._reset();
1124
1198
  this.emit('close');
1125
1199
  };
1126
1200
 
1127
- CombinedStream.prototype._reset = function() {
1201
+ CombinedStream$1.prototype._reset = function() {
1128
1202
  this.writable = false;
1129
1203
  this._streams = [];
1130
1204
  this._currentStream = null;
1131
1205
  };
1132
1206
 
1133
- CombinedStream.prototype._checkDataSize = function() {
1207
+ CombinedStream$1.prototype._checkDataSize = function() {
1134
1208
  this._updateDataSize();
1135
1209
  if (this.dataSize <= this.maxDataSize) {
1136
1210
  return;
@@ -1141,7 +1215,7 @@ CombinedStream.prototype._checkDataSize = function() {
1141
1215
  this._emitError(new Error(message));
1142
1216
  };
1143
1217
 
1144
- CombinedStream.prototype._updateDataSize = function() {
1218
+ CombinedStream$1.prototype._updateDataSize = function() {
1145
1219
  this.dataSize = 0;
1146
1220
 
1147
1221
  var self = this;
@@ -1158,20 +1232,14 @@ CombinedStream.prototype._updateDataSize = function() {
1158
1232
  }
1159
1233
  };
1160
1234
 
1161
- CombinedStream.prototype._emitError = function(err) {
1235
+ CombinedStream$1.prototype._emitError = function(err) {
1162
1236
  this._reset();
1163
1237
  this.emit('error', err);
1164
1238
  };
1165
1239
 
1166
- function createCommonjsModule(fn, module) {
1167
- return module = { exports: {} }, fn(module, module.exports), module.exports;
1168
- }
1169
-
1170
- function getCjsExportFromNamespace (n) {
1171
- return n && n['default'] || n;
1172
- }
1240
+ var mimeTypes = {};
1173
1241
 
1174
- var db = {
1242
+ var require$$0 = {
1175
1243
  "application/1d-interleaved-parityfec": {
1176
1244
  source: "iana"
1177
1245
  },
@@ -10827,13 +10895,6 @@ var db = {
10827
10895
  }
10828
10896
  };
10829
10897
 
10830
- var db$1 = /*#__PURE__*/Object.freeze({
10831
- __proto__: null,
10832
- default: db
10833
- });
10834
-
10835
- var require$$0 = getCjsExportFromNamespace(db$1);
10836
-
10837
10898
  /*!
10838
10899
  * mime-db
10839
10900
  * Copyright(c) 2014 Jonathan Ong
@@ -10846,204 +10907,204 @@ var require$$0 = getCjsExportFromNamespace(db$1);
10846
10907
 
10847
10908
  var mimeDb = require$$0;
10848
10909
 
10849
- var mimeTypes = createCommonjsModule(function (module, exports) {
10850
-
10851
- /**
10852
- * Module dependencies.
10853
- * @private
10854
- */
10855
-
10856
-
10857
- var extname = path.extname;
10858
-
10859
- /**
10860
- * Module variables.
10861
- * @private
10862
- */
10863
-
10864
- var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
10865
- var TEXT_TYPE_REGEXP = /^text\//i;
10866
-
10867
- /**
10868
- * Module exports.
10869
- * @public
10870
- */
10871
-
10872
- exports.charset = charset;
10873
- exports.charsets = { lookup: charset };
10874
- exports.contentType = contentType;
10875
- exports.extension = extension;
10876
- exports.extensions = Object.create(null);
10877
- exports.lookup = lookup;
10878
- exports.types = Object.create(null);
10879
-
10880
- // Populate the extensions/types maps
10881
- populateMaps(exports.extensions, exports.types);
10882
-
10883
- /**
10884
- * Get the default charset for a MIME type.
10885
- *
10886
- * @param {string} type
10887
- * @return {boolean|string}
10888
- */
10889
-
10890
- function charset (type) {
10891
- if (!type || typeof type !== 'string') {
10892
- return false
10893
- }
10894
-
10895
- // TODO: use media-typer
10896
- var match = EXTRACT_TYPE_REGEXP.exec(type);
10897
- var mime = match && mimeDb[match[1].toLowerCase()];
10898
-
10899
- if (mime && mime.charset) {
10900
- return mime.charset
10901
- }
10902
-
10903
- // default text/* to utf-8
10904
- if (match && TEXT_TYPE_REGEXP.test(match[1])) {
10905
- return 'UTF-8'
10906
- }
10907
-
10908
- return false
10909
- }
10910
-
10911
- /**
10912
- * Create a full Content-Type header given a MIME type or extension.
10913
- *
10914
- * @param {string} str
10915
- * @return {boolean|string}
10916
- */
10917
-
10918
- function contentType (str) {
10919
- // TODO: should this even be in this module?
10920
- if (!str || typeof str !== 'string') {
10921
- return false
10922
- }
10923
-
10924
- var mime = str.indexOf('/') === -1
10925
- ? exports.lookup(str)
10926
- : str;
10927
-
10928
- if (!mime) {
10929
- return false
10930
- }
10931
-
10932
- // TODO: use content-type or other module
10933
- if (mime.indexOf('charset') === -1) {
10934
- var charset = exports.charset(mime);
10935
- if (charset) mime += '; charset=' + charset.toLowerCase();
10936
- }
10937
-
10938
- return mime
10939
- }
10940
-
10941
- /**
10942
- * Get the default extension for a MIME type.
10943
- *
10944
- * @param {string} type
10945
- * @return {boolean|string}
10946
- */
10947
-
10948
- function extension (type) {
10949
- if (!type || typeof type !== 'string') {
10950
- return false
10951
- }
10952
-
10953
- // TODO: use media-typer
10954
- var match = EXTRACT_TYPE_REGEXP.exec(type);
10955
-
10956
- // get extensions
10957
- var exts = match && exports.extensions[match[1].toLowerCase()];
10958
-
10959
- if (!exts || !exts.length) {
10960
- return false
10961
- }
10962
-
10963
- return exts[0]
10964
- }
10965
-
10966
- /**
10967
- * Lookup the MIME type for a file path/extension.
10968
- *
10969
- * @param {string} path
10970
- * @return {boolean|string}
10971
- */
10972
-
10973
- function lookup (path) {
10974
- if (!path || typeof path !== 'string') {
10975
- return false
10976
- }
10977
-
10978
- // get the extension ("ext" or ".ext" or full path)
10979
- var extension = extname('x.' + path)
10980
- .toLowerCase()
10981
- .substr(1);
10982
-
10983
- if (!extension) {
10984
- return false
10985
- }
10986
-
10987
- return exports.types[extension] || false
10988
- }
10989
-
10990
- /**
10991
- * Populate the extensions and types maps.
10992
- * @private
10910
+ /*!
10911
+ * mime-types
10912
+ * Copyright(c) 2014 Jonathan Ong
10913
+ * Copyright(c) 2015 Douglas Christopher Wilson
10914
+ * MIT Licensed
10993
10915
  */
10994
10916
 
10995
- function populateMaps (extensions, types) {
10996
- // source preference (least -> most)
10997
- var preference = ['nginx', 'apache', undefined, 'iana'];
10998
-
10999
- Object.keys(mimeDb).forEach(function forEachMimeType (type) {
11000
- var mime = mimeDb[type];
11001
- var exts = mime.extensions;
11002
-
11003
- if (!exts || !exts.length) {
11004
- return
11005
- }
11006
-
11007
- // mime -> extensions
11008
- extensions[type] = exts;
11009
-
11010
- // extension -> mime
11011
- for (var i = 0; i < exts.length; i++) {
11012
- var extension = exts[i];
11013
-
11014
- if (types[extension]) {
11015
- var from = preference.indexOf(mimeDb[types[extension]].source);
11016
- var to = preference.indexOf(mime.source);
11017
-
11018
- if (types[extension] !== 'application/octet-stream' &&
11019
- (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
11020
- // skip the remapping
11021
- continue
11022
- }
11023
- }
11024
-
11025
- // set the extension -> mime
11026
- types[extension] = type;
11027
- }
11028
- });
11029
- }
11030
- });
11031
- mimeTypes.charset;
11032
- mimeTypes.charsets;
11033
- mimeTypes.contentType;
11034
- mimeTypes.extension;
11035
- mimeTypes.extensions;
11036
- mimeTypes.lookup;
11037
- mimeTypes.types;
11038
-
11039
- var defer_1 = defer;
10917
+ (function (exports) {
10918
+
10919
+ /**
10920
+ * Module dependencies.
10921
+ * @private
10922
+ */
10923
+
10924
+ var db = mimeDb;
10925
+ var extname = require$$1$1.extname;
10926
+
10927
+ /**
10928
+ * Module variables.
10929
+ * @private
10930
+ */
10931
+
10932
+ var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
10933
+ var TEXT_TYPE_REGEXP = /^text\//i;
10934
+
10935
+ /**
10936
+ * Module exports.
10937
+ * @public
10938
+ */
10939
+
10940
+ exports.charset = charset;
10941
+ exports.charsets = { lookup: charset };
10942
+ exports.contentType = contentType;
10943
+ exports.extension = extension;
10944
+ exports.extensions = Object.create(null);
10945
+ exports.lookup = lookup;
10946
+ exports.types = Object.create(null);
10947
+
10948
+ // Populate the extensions/types maps
10949
+ populateMaps(exports.extensions, exports.types);
10950
+
10951
+ /**
10952
+ * Get the default charset for a MIME type.
10953
+ *
10954
+ * @param {string} type
10955
+ * @return {boolean|string}
10956
+ */
10957
+
10958
+ function charset (type) {
10959
+ if (!type || typeof type !== 'string') {
10960
+ return false
10961
+ }
10962
+
10963
+ // TODO: use media-typer
10964
+ var match = EXTRACT_TYPE_REGEXP.exec(type);
10965
+ var mime = match && db[match[1].toLowerCase()];
10966
+
10967
+ if (mime && mime.charset) {
10968
+ return mime.charset
10969
+ }
10970
+
10971
+ // default text/* to utf-8
10972
+ if (match && TEXT_TYPE_REGEXP.test(match[1])) {
10973
+ return 'UTF-8'
10974
+ }
10975
+
10976
+ return false
10977
+ }
10978
+
10979
+ /**
10980
+ * Create a full Content-Type header given a MIME type or extension.
10981
+ *
10982
+ * @param {string} str
10983
+ * @return {boolean|string}
10984
+ */
10985
+
10986
+ function contentType (str) {
10987
+ // TODO: should this even be in this module?
10988
+ if (!str || typeof str !== 'string') {
10989
+ return false
10990
+ }
10991
+
10992
+ var mime = str.indexOf('/') === -1
10993
+ ? exports.lookup(str)
10994
+ : str;
10995
+
10996
+ if (!mime) {
10997
+ return false
10998
+ }
10999
+
11000
+ // TODO: use content-type or other module
11001
+ if (mime.indexOf('charset') === -1) {
11002
+ var charset = exports.charset(mime);
11003
+ if (charset) mime += '; charset=' + charset.toLowerCase();
11004
+ }
11005
+
11006
+ return mime
11007
+ }
11008
+
11009
+ /**
11010
+ * Get the default extension for a MIME type.
11011
+ *
11012
+ * @param {string} type
11013
+ * @return {boolean|string}
11014
+ */
11015
+
11016
+ function extension (type) {
11017
+ if (!type || typeof type !== 'string') {
11018
+ return false
11019
+ }
11020
+
11021
+ // TODO: use media-typer
11022
+ var match = EXTRACT_TYPE_REGEXP.exec(type);
11023
+
11024
+ // get extensions
11025
+ var exts = match && exports.extensions[match[1].toLowerCase()];
11026
+
11027
+ if (!exts || !exts.length) {
11028
+ return false
11029
+ }
11030
+
11031
+ return exts[0]
11032
+ }
11033
+
11034
+ /**
11035
+ * Lookup the MIME type for a file path/extension.
11036
+ *
11037
+ * @param {string} path
11038
+ * @return {boolean|string}
11039
+ */
11040
+
11041
+ function lookup (path) {
11042
+ if (!path || typeof path !== 'string') {
11043
+ return false
11044
+ }
11045
+
11046
+ // get the extension ("ext" or ".ext" or full path)
11047
+ var extension = extname('x.' + path)
11048
+ .toLowerCase()
11049
+ .substr(1);
11050
+
11051
+ if (!extension) {
11052
+ return false
11053
+ }
11054
+
11055
+ return exports.types[extension] || false
11056
+ }
11057
+
11058
+ /**
11059
+ * Populate the extensions and types maps.
11060
+ * @private
11061
+ */
11062
+
11063
+ function populateMaps (extensions, types) {
11064
+ // source preference (least -> most)
11065
+ var preference = ['nginx', 'apache', undefined, 'iana'];
11066
+
11067
+ Object.keys(db).forEach(function forEachMimeType (type) {
11068
+ var mime = db[type];
11069
+ var exts = mime.extensions;
11070
+
11071
+ if (!exts || !exts.length) {
11072
+ return
11073
+ }
11074
+
11075
+ // mime -> extensions
11076
+ extensions[type] = exts;
11077
+
11078
+ // extension -> mime
11079
+ for (var i = 0; i < exts.length; i++) {
11080
+ var extension = exts[i];
11081
+
11082
+ if (types[extension]) {
11083
+ var from = preference.indexOf(db[types[extension]].source);
11084
+ var to = preference.indexOf(mime.source);
11085
+
11086
+ if (types[extension] !== 'application/octet-stream' &&
11087
+ (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
11088
+ // skip the remapping
11089
+ continue
11090
+ }
11091
+ }
11092
+
11093
+ // set the extension -> mime
11094
+ types[extension] = type;
11095
+ }
11096
+ });
11097
+ }
11098
+ } (mimeTypes));
11099
+
11100
+ var defer_1 = defer$1;
11040
11101
 
11041
11102
  /**
11042
11103
  * Runs provided function on next iteration of the event loop
11043
11104
  *
11044
11105
  * @param {function} fn - function to run
11045
11106
  */
11046
- function defer(fn)
11107
+ function defer$1(fn)
11047
11108
  {
11048
11109
  var nextTick = typeof setImmediate == 'function'
11049
11110
  ? setImmediate
@@ -11063,8 +11124,10 @@ function defer(fn)
11063
11124
  }
11064
11125
  }
11065
11126
 
11127
+ var defer = defer_1;
11128
+
11066
11129
  // API
11067
- var async_1 = async;
11130
+ var async_1 = async$2;
11068
11131
 
11069
11132
  /**
11070
11133
  * Runs provided callback asynchronously
@@ -11073,12 +11136,12 @@ var async_1 = async;
11073
11136
  * @param {function} callback - callback to invoke
11074
11137
  * @returns {function} - augmented callback
11075
11138
  */
11076
- function async(callback)
11139
+ function async$2(callback)
11077
11140
  {
11078
11141
  var isAsync = false;
11079
11142
 
11080
11143
  // check if async happened
11081
- defer_1(function() { isAsync = true; });
11144
+ defer(function() { isAsync = true; });
11082
11145
 
11083
11146
  return function async_callback(err, result)
11084
11147
  {
@@ -11088,7 +11151,7 @@ function async(callback)
11088
11151
  }
11089
11152
  else
11090
11153
  {
11091
- defer_1(function nextTick_callback()
11154
+ defer(function nextTick_callback()
11092
11155
  {
11093
11156
  callback(err, result);
11094
11157
  });
@@ -11097,14 +11160,14 @@ function async(callback)
11097
11160
  }
11098
11161
 
11099
11162
  // API
11100
- var abort_1 = abort;
11163
+ var abort_1 = abort$2;
11101
11164
 
11102
11165
  /**
11103
11166
  * Aborts leftover active jobs
11104
11167
  *
11105
11168
  * @param {object} state - current state object
11106
11169
  */
11107
- function abort(state)
11170
+ function abort$2(state)
11108
11171
  {
11109
11172
  Object.keys(state.jobs).forEach(clean.bind(state));
11110
11173
 
@@ -11126,8 +11189,12 @@ function clean(key)
11126
11189
  }
11127
11190
  }
11128
11191
 
11192
+ var async$1 = async_1
11193
+ , abort$1 = abort_1
11194
+ ;
11195
+
11129
11196
  // API
11130
- var iterate_1 = iterate;
11197
+ var iterate_1 = iterate$2;
11131
11198
 
11132
11199
  /**
11133
11200
  * Iterates over each job object
@@ -11137,7 +11204,7 @@ var iterate_1 = iterate;
11137
11204
  * @param {object} state - current job status
11138
11205
  * @param {function} callback - invoked when all elements processed
11139
11206
  */
11140
- function iterate(list, iterator, state, callback)
11207
+ function iterate$2(list, iterator, state, callback)
11141
11208
  {
11142
11209
  // store current index
11143
11210
  var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
@@ -11159,7 +11226,7 @@ function iterate(list, iterator, state, callback)
11159
11226
  // don't process rest of the results
11160
11227
  // stop still active jobs
11161
11228
  // and reset the list
11162
- abort_1(state);
11229
+ abort$1(state);
11163
11230
  }
11164
11231
  else
11165
11232
  {
@@ -11187,12 +11254,12 @@ function runJob(iterator, key, item, callback)
11187
11254
  // allow shortcut if iterator expects only two arguments
11188
11255
  if (iterator.length == 2)
11189
11256
  {
11190
- aborter = iterator(item, async_1(callback));
11257
+ aborter = iterator(item, async$1(callback));
11191
11258
  }
11192
11259
  // otherwise go with full three arguments
11193
11260
  else
11194
11261
  {
11195
- aborter = iterator(item, key, async_1(callback));
11262
+ aborter = iterator(item, key, async$1(callback));
11196
11263
  }
11197
11264
 
11198
11265
  return aborter;
@@ -11236,8 +11303,12 @@ function state(list, sortMethod)
11236
11303
  return initState;
11237
11304
  }
11238
11305
 
11306
+ var abort = abort_1
11307
+ , async = async_1
11308
+ ;
11309
+
11239
11310
  // API
11240
- var terminator_1 = terminator;
11311
+ var terminator_1 = terminator$2;
11241
11312
 
11242
11313
  /**
11243
11314
  * Terminates jobs in the attached state context
@@ -11245,7 +11316,7 @@ var terminator_1 = terminator;
11245
11316
  * @this AsyncKitState#
11246
11317
  * @param {function} callback - final callback to invoke after termination
11247
11318
  */
11248
- function terminator(callback)
11319
+ function terminator$2(callback)
11249
11320
  {
11250
11321
  if (!Object.keys(this.jobs).length)
11251
11322
  {
@@ -11256,12 +11327,17 @@ function terminator(callback)
11256
11327
  this.index = this.size;
11257
11328
 
11258
11329
  // abort jobs
11259
- abort_1(this);
11330
+ abort(this);
11260
11331
 
11261
11332
  // send back results we have so far
11262
- async_1(callback)(null, this.results);
11333
+ async(callback)(null, this.results);
11263
11334
  }
11264
11335
 
11336
+ var iterate$1 = iterate_1
11337
+ , initState$1 = state_1
11338
+ , terminator$1 = terminator_1
11339
+ ;
11340
+
11265
11341
  // Public API
11266
11342
  var parallel_1 = parallel;
11267
11343
 
@@ -11275,11 +11351,11 @@ var parallel_1 = parallel;
11275
11351
  */
11276
11352
  function parallel(list, iterator, callback)
11277
11353
  {
11278
- var state = state_1(list);
11354
+ var state = initState$1(list);
11279
11355
 
11280
11356
  while (state.index < (state['keyedList'] || list).length)
11281
11357
  {
11282
- iterate_1(list, iterator, state, function(error, result)
11358
+ iterate$1(list, iterator, state, function(error, result)
11283
11359
  {
11284
11360
  if (error)
11285
11361
  {
@@ -11298,14 +11374,21 @@ function parallel(list, iterator, callback)
11298
11374
  state.index++;
11299
11375
  }
11300
11376
 
11301
- return terminator_1.bind(state, callback);
11377
+ return terminator$1.bind(state, callback);
11302
11378
  }
11303
11379
 
11380
+ var serialOrdered$2 = {exports: {}};
11381
+
11382
+ var iterate = iterate_1
11383
+ , initState = state_1
11384
+ , terminator = terminator_1
11385
+ ;
11386
+
11304
11387
  // Public API
11305
- var serialOrdered_1 = serialOrdered;
11388
+ serialOrdered$2.exports = serialOrdered$1;
11306
11389
  // sorting helpers
11307
- var ascending_1 = ascending;
11308
- var descending_1 = descending;
11390
+ serialOrdered$2.exports.ascending = ascending;
11391
+ serialOrdered$2.exports.descending = descending;
11309
11392
 
11310
11393
  /**
11311
11394
  * Runs iterator over provided sorted array elements in series
@@ -11316,11 +11399,11 @@ var descending_1 = descending;
11316
11399
  * @param {function} callback - invoked when all elements processed
11317
11400
  * @returns {function} - jobs terminator
11318
11401
  */
11319
- function serialOrdered(list, iterator, sortMethod, callback)
11402
+ function serialOrdered$1(list, iterator, sortMethod, callback)
11320
11403
  {
11321
- var state = state_1(list, sortMethod);
11404
+ var state = initState(list, sortMethod);
11322
11405
 
11323
- iterate_1(list, iterator, state, function iteratorHandler(error, result)
11406
+ iterate(list, iterator, state, function iteratorHandler(error, result)
11324
11407
  {
11325
11408
  if (error)
11326
11409
  {
@@ -11333,7 +11416,7 @@ function serialOrdered(list, iterator, sortMethod, callback)
11333
11416
  // are we there yet?
11334
11417
  if (state.index < (state['keyedList'] || list).length)
11335
11418
  {
11336
- iterate_1(list, iterator, state, iteratorHandler);
11419
+ iterate(list, iterator, state, iteratorHandler);
11337
11420
  return;
11338
11421
  }
11339
11422
 
@@ -11341,7 +11424,7 @@ function serialOrdered(list, iterator, sortMethod, callback)
11341
11424
  callback(null, state.results);
11342
11425
  });
11343
11426
 
11344
- return terminator_1.bind(state, callback);
11427
+ return terminator.bind(state, callback);
11345
11428
  }
11346
11429
 
11347
11430
  /*
@@ -11371,8 +11454,10 @@ function descending(a, b)
11371
11454
  {
11372
11455
  return -1 * ascending(a, b);
11373
11456
  }
11374
- serialOrdered_1.ascending = ascending_1;
11375
- serialOrdered_1.descending = descending_1;
11457
+
11458
+ var serialOrderedExports = serialOrdered$2.exports;
11459
+
11460
+ var serialOrdered = serialOrderedExports;
11376
11461
 
11377
11462
  // Public API
11378
11463
  var serial_1 = serial;
@@ -11387,18 +11472,18 @@ var serial_1 = serial;
11387
11472
  */
11388
11473
  function serial(list, iterator, callback)
11389
11474
  {
11390
- return serialOrdered_1(list, iterator, null, callback);
11475
+ return serialOrdered(list, iterator, null, callback);
11391
11476
  }
11392
11477
 
11393
- var asynckit =
11478
+ var asynckit$1 =
11394
11479
  {
11395
11480
  parallel : parallel_1,
11396
11481
  serial : serial_1,
11397
- serialOrdered : serialOrdered_1
11482
+ serialOrdered : serialOrderedExports
11398
11483
  };
11399
11484
 
11400
11485
  // populates missing values
11401
- var populate = function(dst, src) {
11486
+ var populate$1 = function(dst, src) {
11402
11487
 
11403
11488
  Object.keys(src).forEach(function(prop)
11404
11489
  {
@@ -11408,18 +11493,23 @@ var populate = function(dst, src) {
11408
11493
  return dst;
11409
11494
  };
11410
11495
 
11411
- var parseUrl = url.parse;
11412
-
11413
- var Stream = stream.Stream;
11414
-
11415
-
11416
-
11496
+ var CombinedStream = combined_stream;
11497
+ var util = require$$1;
11498
+ var path = require$$1$1;
11499
+ var http = require$$3;
11500
+ var https = require$$4;
11501
+ var parseUrl = require$$5.parse;
11502
+ var fs = require$$6;
11503
+ var Stream = require$$0$1.Stream;
11504
+ var mime = mimeTypes;
11505
+ var asynckit = asynckit$1;
11506
+ var populate = populate$1;
11417
11507
 
11418
11508
  // Public API
11419
11509
  var form_data = FormData;
11420
11510
 
11421
11511
  // make it a Stream
11422
- util.inherits(FormData, combined_stream);
11512
+ util.inherits(FormData, CombinedStream);
11423
11513
 
11424
11514
  /**
11425
11515
  * Create readable "multipart/form-data" streams.
@@ -11438,7 +11528,7 @@ function FormData(options) {
11438
11528
  this._valueLength = 0;
11439
11529
  this._valuesToMeasure = [];
11440
11530
 
11441
- combined_stream.call(this);
11531
+ CombinedStream.call(this);
11442
11532
 
11443
11533
  options = options || {};
11444
11534
  for (var option in options) {
@@ -11458,7 +11548,7 @@ FormData.prototype.append = function(field, value, options) {
11458
11548
  options = {filename: options};
11459
11549
  }
11460
11550
 
11461
- var append = combined_stream.prototype.append.bind(this);
11551
+ var append = CombinedStream.prototype.append.bind(this);
11462
11552
 
11463
11553
  // all that streamy business can't handle numbers
11464
11554
  if (typeof value == 'number') {
@@ -11653,12 +11743,12 @@ FormData.prototype._getContentType = function(value, options) {
11653
11743
 
11654
11744
  // or try `name` from formidable, browser
11655
11745
  if (!contentType && value.name) {
11656
- contentType = mimeTypes.lookup(value.name);
11746
+ contentType = mime.lookup(value.name);
11657
11747
  }
11658
11748
 
11659
11749
  // or try `path` from fs-, request- streams
11660
11750
  if (!contentType && value.path) {
11661
- contentType = mimeTypes.lookup(value.path);
11751
+ contentType = mime.lookup(value.path);
11662
11752
  }
11663
11753
 
11664
11754
  // or if it's http-reponse
@@ -11668,7 +11758,7 @@ FormData.prototype._getContentType = function(value, options) {
11668
11758
 
11669
11759
  // or guess it from the filepath or filename
11670
11760
  if (!contentType && (options.filepath || options.filename)) {
11671
- contentType = mimeTypes.lookup(options.filepath || options.filename);
11761
+ contentType = mime.lookup(options.filepath || options.filename);
11672
11762
  }
11673
11763
 
11674
11764
  // fallback to the default content type if `value` is not simple value
@@ -11905,6 +11995,8 @@ FormData.prototype.toString = function () {
11905
11995
  return '[object FormData]';
11906
11996
  };
11907
11997
 
11998
+ var FormDataModule = /*@__PURE__*/getDefaultExportFromCjs(form_data);
11999
+
11908
12000
  const GRANT_TYPE$1 = 'client_credentials';
11909
12001
  const castClientOptionsToRequestParams = (clientOptions) => {
11910
12002
  const { scope, clientId, clientSecret } = clientOptions;
@@ -12098,7 +12190,7 @@ function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, httpMetho
12098
12190
  const formData = Object.entries(form).reduce((previous, [name, value]) => {
12099
12191
  previous.append.apply(previous, [name].concat(value));
12100
12192
  return previous;
12101
- }, new form_data());
12193
+ }, new FormDataModule());
12102
12194
  const headers = Object.assign(Object.assign(Object.assign(Object.assign({ accept: 'application/json', authorization: `Bearer ${oauthTokenStore.get('accessToken')}`, 'X-Allthings-Caller': `${options.serviceName
12103
12195
  ? options.serviceName
12104
12196
  : process.env.SEVICE_NAME
@@ -12322,4 +12414,4 @@ var EnumLookupUserType;
12322
12414
  EnumLookupUserType["tenant"] = "tenant";
12323
12415
  })(EnumLookupUserType || (EnumLookupUserType = {}));
12324
12416
 
12325
- export { EnumCommunicationMethodType, EnumCommunicationPreferenceChannel, EnumCountryCode, EnumInputChannel, EnumLocale, EnumLookupUserType, EnumResource, EnumServiceProviderType, EnumTimezone, EnumUnitObjectType, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, EnumUserRelationType, EnumUtilisationPeriodType, createTokenStore, restClient };
12417
+ export { DEFAULT_AWS_CONFIGURATION, DEFAULT_CLIENT_CONFIG as DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, EnumCommunicationMethodType, EnumCommunicationPreferenceChannel, EnumCountryCode, EnumInputChannel, EnumLocale, EnumLookupUserType, EnumResource, EnumServiceProviderType, EnumTimezone, EnumUnitObjectType, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, EnumUserRelationType, EnumUtilisationPeriodType, index as awsClients, createTokenStore, parameterStore, restClient };