@allthings/sdk 6.6.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/cli.js +1313 -1209
- package/dist/lib.cjs.js +1313 -1257
- package/dist/lib.esm.js +1314 -1256
- package/dist/lib.umd.min.js +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/rest/methods/conversation.d.ts +1 -0
- package/dist/src/rest/methods/file.d.ts +1 -0
- package/dist/src/rest/methods/group.d.ts +3 -2
- package/dist/src/rest/methods/property.d.ts +2 -1
- package/dist/src/rest/methods/registrationCode.d.ts +1 -0
- package/dist/src/rest/methods/ticket.d.ts +1 -0
- package/dist/src/rest/methods/unit.d.ts +1 -0
- package/dist/src/rest/methods/user.d.ts +8 -0
- package/dist/src/rest/methods/utilisationPeriod.d.ts +2 -1
- package/dist/src/utils/upload.d.ts +1 -0
- package/dist/test/helpers.d.ts +1 -0
- package/package.json +9 -11
- package/dist/src/aws/index.d.ts +0 -2
- package/dist/src/aws/parameterStore.d.ts +0 -16
- package/dist/src/aws/parameterStore.test.d.ts +0 -1
package/dist/lib.cjs.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var clientSsm = require('@aws-sdk/client-ssm');
|
|
4
3
|
var querystring = require('query-string');
|
|
5
4
|
var fetch = require('cross-fetch');
|
|
6
5
|
var Bottleneck = require('bottleneck');
|
|
@@ -12,7 +11,16 @@ var require$$4 = require('https');
|
|
|
12
11
|
var require$$5 = require('url');
|
|
13
12
|
var require$$6 = require('fs');
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
function createTokenStore(initialToken) {
|
|
15
|
+
const token = new Map(Object.entries(initialToken || {}));
|
|
16
|
+
return {
|
|
17
|
+
get: (key) => token.get(key),
|
|
18
|
+
reset: () => token.clear(),
|
|
19
|
+
set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const version = "7.0.0";
|
|
16
24
|
|
|
17
25
|
const REST_API_URL = 'https://api.allthings.me';
|
|
18
26
|
const OAUTH_URL = 'https://accounts.allthings.me';
|
|
@@ -34,81 +42,6 @@ const DEFAULT_API_WRAPPER_OPTIONS = {
|
|
|
34
42
|
username: process.env.ALLTHINGS_OAUTH_USERNAME,
|
|
35
43
|
};
|
|
36
44
|
const USER_AGENT = `Allthings Node SDK REST Client/${version}`;
|
|
37
|
-
const DEFAULT_AWS_CONFIGURATION = {
|
|
38
|
-
region: 'eu-central-2',
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
|
|
42
|
-
var t = {};
|
|
43
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
44
|
-
t[p] = s[p];
|
|
45
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
46
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
47
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
48
|
-
t[p[i]] = s[p[i]];
|
|
49
|
-
}
|
|
50
|
-
return t;
|
|
51
|
-
};
|
|
52
|
-
const DEFAULT_CLIENT_CONFIG = {
|
|
53
|
-
clientConfig: DEFAULT_AWS_CONFIGURATION,
|
|
54
|
-
onlyDefault: false,
|
|
55
|
-
prefix: process.env.SSM_PARAM_PATH,
|
|
56
|
-
};
|
|
57
|
-
const getSecrets = async (ssm, config, params, defaultValue) => {
|
|
58
|
-
var _a, _b;
|
|
59
|
-
if (config.onlyDefault) {
|
|
60
|
-
return [defaultValue];
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
const parameters = await ssm.send(new clientSsm.GetParametersCommand({
|
|
64
|
-
Names: params.map((param) => `${config.prefix ? config.prefix : ''}${param}`),
|
|
65
|
-
WithDecryption: true,
|
|
66
|
-
}));
|
|
67
|
-
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]);
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
if (config.logger) {
|
|
71
|
-
config.logger(e);
|
|
72
|
-
}
|
|
73
|
-
return [defaultValue];
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const getSecret = async (ssm, config, param, defaultValue) => {
|
|
77
|
-
var _a, _b;
|
|
78
|
-
if (config.onlyDefault) {
|
|
79
|
-
return defaultValue;
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
const parameter = await ssm.send(new clientSsm.GetParameterCommand({
|
|
83
|
-
Name: `${config.prefix ? config.prefix : ''}${param}`,
|
|
84
|
-
WithDecryption: true,
|
|
85
|
-
}));
|
|
86
|
-
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;
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
if (config.logger) {
|
|
90
|
-
config.logger(e);
|
|
91
|
-
}
|
|
92
|
-
return defaultValue;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const parameterStore = (userConfig) => {
|
|
96
|
-
const _a = Object.assign(Object.assign({}, DEFAULT_CLIENT_CONFIG), userConfig), { clientConfig } = _a, config = __rest$5(_a, ["clientConfig"]);
|
|
97
|
-
const ssm = new clientSsm.SSMClient(clientConfig);
|
|
98
|
-
return {
|
|
99
|
-
getSecret: (param, defaultValue = '') => getSecret(ssm, config, param, defaultValue),
|
|
100
|
-
getSecrets: (params, defaultValue = '') => getSecrets(ssm, config, params, defaultValue),
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
function createTokenStore(initialToken) {
|
|
105
|
-
const token = new Map(Object.entries(initialToken || {}));
|
|
106
|
-
return {
|
|
107
|
-
get: (key) => token.get(key),
|
|
108
|
-
reset: () => token.clear(),
|
|
109
|
-
set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
45
|
|
|
113
46
|
const RESPONSE_TYPE$1 = 'code';
|
|
114
47
|
const GRANT_TYPE$3 = 'authorization_code';
|
|
@@ -920,322 +853,338 @@ function getDefaultExportFromCjs (x) {
|
|
|
920
853
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
921
854
|
}
|
|
922
855
|
|
|
923
|
-
var
|
|
924
|
-
var
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
856
|
+
var delayed_stream;
|
|
857
|
+
var hasRequiredDelayed_stream;
|
|
858
|
+
|
|
859
|
+
function requireDelayed_stream () {
|
|
860
|
+
if (hasRequiredDelayed_stream) return delayed_stream;
|
|
861
|
+
hasRequiredDelayed_stream = 1;
|
|
862
|
+
var Stream = require$$0$1.Stream;
|
|
863
|
+
var util = require$$1;
|
|
864
|
+
|
|
865
|
+
delayed_stream = DelayedStream;
|
|
866
|
+
function DelayedStream() {
|
|
867
|
+
this.source = null;
|
|
868
|
+
this.dataSize = 0;
|
|
869
|
+
this.maxDataSize = 1024 * 1024;
|
|
870
|
+
this.pauseStream = true;
|
|
871
|
+
|
|
872
|
+
this._maxDataSizeExceeded = false;
|
|
873
|
+
this._released = false;
|
|
874
|
+
this._bufferedEvents = [];
|
|
875
|
+
}
|
|
876
|
+
util.inherits(DelayedStream, Stream);
|
|
938
877
|
|
|
939
|
-
DelayedStream
|
|
940
|
-
|
|
878
|
+
DelayedStream.create = function(source, options) {
|
|
879
|
+
var delayedStream = new this();
|
|
941
880
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
881
|
+
options = options || {};
|
|
882
|
+
for (var option in options) {
|
|
883
|
+
delayedStream[option] = options[option];
|
|
884
|
+
}
|
|
946
885
|
|
|
947
|
-
|
|
886
|
+
delayedStream.source = source;
|
|
948
887
|
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
888
|
+
var realEmit = source.emit;
|
|
889
|
+
source.emit = function() {
|
|
890
|
+
delayedStream._handleEmit(arguments);
|
|
891
|
+
return realEmit.apply(source, arguments);
|
|
892
|
+
};
|
|
954
893
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
894
|
+
source.on('error', function() {});
|
|
895
|
+
if (delayedStream.pauseStream) {
|
|
896
|
+
source.pause();
|
|
897
|
+
}
|
|
959
898
|
|
|
960
|
-
|
|
961
|
-
};
|
|
899
|
+
return delayedStream;
|
|
900
|
+
};
|
|
962
901
|
|
|
963
|
-
Object.defineProperty(DelayedStream
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
});
|
|
902
|
+
Object.defineProperty(DelayedStream.prototype, 'readable', {
|
|
903
|
+
configurable: true,
|
|
904
|
+
enumerable: true,
|
|
905
|
+
get: function() {
|
|
906
|
+
return this.source.readable;
|
|
907
|
+
}
|
|
908
|
+
});
|
|
970
909
|
|
|
971
|
-
DelayedStream
|
|
972
|
-
|
|
973
|
-
};
|
|
910
|
+
DelayedStream.prototype.setEncoding = function() {
|
|
911
|
+
return this.source.setEncoding.apply(this.source, arguments);
|
|
912
|
+
};
|
|
974
913
|
|
|
975
|
-
DelayedStream
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
914
|
+
DelayedStream.prototype.resume = function() {
|
|
915
|
+
if (!this._released) {
|
|
916
|
+
this.release();
|
|
917
|
+
}
|
|
979
918
|
|
|
980
|
-
|
|
981
|
-
};
|
|
919
|
+
this.source.resume();
|
|
920
|
+
};
|
|
982
921
|
|
|
983
|
-
DelayedStream
|
|
984
|
-
|
|
985
|
-
};
|
|
922
|
+
DelayedStream.prototype.pause = function() {
|
|
923
|
+
this.source.pause();
|
|
924
|
+
};
|
|
986
925
|
|
|
987
|
-
DelayedStream
|
|
988
|
-
|
|
926
|
+
DelayedStream.prototype.release = function() {
|
|
927
|
+
this._released = true;
|
|
989
928
|
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
};
|
|
929
|
+
this._bufferedEvents.forEach(function(args) {
|
|
930
|
+
this.emit.apply(this, args);
|
|
931
|
+
}.bind(this));
|
|
932
|
+
this._bufferedEvents = [];
|
|
933
|
+
};
|
|
995
934
|
|
|
996
|
-
DelayedStream
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
};
|
|
935
|
+
DelayedStream.prototype.pipe = function() {
|
|
936
|
+
var r = Stream.prototype.pipe.apply(this, arguments);
|
|
937
|
+
this.resume();
|
|
938
|
+
return r;
|
|
939
|
+
};
|
|
1001
940
|
|
|
1002
|
-
DelayedStream
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
941
|
+
DelayedStream.prototype._handleEmit = function(args) {
|
|
942
|
+
if (this._released) {
|
|
943
|
+
this.emit.apply(this, args);
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
1007
946
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
947
|
+
if (args[0] === 'data') {
|
|
948
|
+
this.dataSize += args[1].length;
|
|
949
|
+
this._checkIfMaxDataSizeExceeded();
|
|
950
|
+
}
|
|
1012
951
|
|
|
1013
|
-
|
|
1014
|
-
};
|
|
952
|
+
this._bufferedEvents.push(args);
|
|
953
|
+
};
|
|
1015
954
|
|
|
1016
|
-
DelayedStream
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
if (this.dataSize <= this.maxDataSize) {
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
955
|
+
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
956
|
+
if (this._maxDataSizeExceeded) {
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
1024
959
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
this.emit('error', new Error(message));
|
|
1029
|
-
};
|
|
960
|
+
if (this.dataSize <= this.maxDataSize) {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
1030
963
|
|
|
1031
|
-
|
|
1032
|
-
var
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
this.writable = false;
|
|
1038
|
-
this.readable = true;
|
|
1039
|
-
this.dataSize = 0;
|
|
1040
|
-
this.maxDataSize = 2 * 1024 * 1024;
|
|
1041
|
-
this.pauseStreams = true;
|
|
1042
|
-
|
|
1043
|
-
this._released = false;
|
|
1044
|
-
this._streams = [];
|
|
1045
|
-
this._currentStream = null;
|
|
1046
|
-
this._insideLoop = false;
|
|
1047
|
-
this._pendingNext = false;
|
|
964
|
+
this._maxDataSizeExceeded = true;
|
|
965
|
+
var message =
|
|
966
|
+
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.';
|
|
967
|
+
this.emit('error', new Error(message));
|
|
968
|
+
};
|
|
969
|
+
return delayed_stream;
|
|
1048
970
|
}
|
|
1049
|
-
util$1.inherits(CombinedStream$1, Stream$1);
|
|
1050
|
-
|
|
1051
|
-
CombinedStream$1.create = function(options) {
|
|
1052
|
-
var combinedStream = new this();
|
|
1053
971
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
972
|
+
var combined_stream;
|
|
973
|
+
var hasRequiredCombined_stream;
|
|
974
|
+
|
|
975
|
+
function requireCombined_stream () {
|
|
976
|
+
if (hasRequiredCombined_stream) return combined_stream;
|
|
977
|
+
hasRequiredCombined_stream = 1;
|
|
978
|
+
var util = require$$1;
|
|
979
|
+
var Stream = require$$0$1.Stream;
|
|
980
|
+
var DelayedStream = requireDelayed_stream();
|
|
981
|
+
|
|
982
|
+
combined_stream = CombinedStream;
|
|
983
|
+
function CombinedStream() {
|
|
984
|
+
this.writable = false;
|
|
985
|
+
this.readable = true;
|
|
986
|
+
this.dataSize = 0;
|
|
987
|
+
this.maxDataSize = 2 * 1024 * 1024;
|
|
988
|
+
this.pauseStreams = true;
|
|
989
|
+
|
|
990
|
+
this._released = false;
|
|
991
|
+
this._streams = [];
|
|
992
|
+
this._currentStream = null;
|
|
993
|
+
this._insideLoop = false;
|
|
994
|
+
this._pendingNext = false;
|
|
995
|
+
}
|
|
996
|
+
util.inherits(CombinedStream, Stream);
|
|
1058
997
|
|
|
1059
|
-
|
|
1060
|
-
|
|
998
|
+
CombinedStream.create = function(options) {
|
|
999
|
+
var combinedStream = new this();
|
|
1061
1000
|
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
&& (typeof stream !== 'number')
|
|
1067
|
-
&& (!Buffer.isBuffer(stream));
|
|
1068
|
-
};
|
|
1069
|
-
|
|
1070
|
-
CombinedStream$1.prototype.append = function(stream) {
|
|
1071
|
-
var isStreamLike = CombinedStream$1.isStreamLike(stream);
|
|
1072
|
-
|
|
1073
|
-
if (isStreamLike) {
|
|
1074
|
-
if (!(stream instanceof DelayedStream)) {
|
|
1075
|
-
var newStream = DelayedStream.create(stream, {
|
|
1076
|
-
maxDataSize: Infinity,
|
|
1077
|
-
pauseStream: this.pauseStreams,
|
|
1078
|
-
});
|
|
1079
|
-
stream.on('data', this._checkDataSize.bind(this));
|
|
1080
|
-
stream = newStream;
|
|
1081
|
-
}
|
|
1001
|
+
options = options || {};
|
|
1002
|
+
for (var option in options) {
|
|
1003
|
+
combinedStream[option] = options[option];
|
|
1004
|
+
}
|
|
1082
1005
|
|
|
1083
|
-
|
|
1006
|
+
return combinedStream;
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
CombinedStream.isStreamLike = function(stream) {
|
|
1010
|
+
return (typeof stream !== 'function')
|
|
1011
|
+
&& (typeof stream !== 'string')
|
|
1012
|
+
&& (typeof stream !== 'boolean')
|
|
1013
|
+
&& (typeof stream !== 'number')
|
|
1014
|
+
&& (!Buffer.isBuffer(stream));
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
CombinedStream.prototype.append = function(stream) {
|
|
1018
|
+
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1019
|
+
|
|
1020
|
+
if (isStreamLike) {
|
|
1021
|
+
if (!(stream instanceof DelayedStream)) {
|
|
1022
|
+
var newStream = DelayedStream.create(stream, {
|
|
1023
|
+
maxDataSize: Infinity,
|
|
1024
|
+
pauseStream: this.pauseStreams,
|
|
1025
|
+
});
|
|
1026
|
+
stream.on('data', this._checkDataSize.bind(this));
|
|
1027
|
+
stream = newStream;
|
|
1028
|
+
}
|
|
1084
1029
|
|
|
1085
|
-
|
|
1086
|
-
stream.pause();
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1030
|
+
this._handleErrors(stream);
|
|
1089
1031
|
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
}
|
|
1032
|
+
if (this.pauseStreams) {
|
|
1033
|
+
stream.pause();
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1093
1036
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
return dest;
|
|
1098
|
-
};
|
|
1037
|
+
this._streams.push(stream);
|
|
1038
|
+
return this;
|
|
1039
|
+
};
|
|
1099
1040
|
|
|
1100
|
-
CombinedStream
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
return; // defer call
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
this._insideLoop = true;
|
|
1109
|
-
try {
|
|
1110
|
-
do {
|
|
1111
|
-
this._pendingNext = false;
|
|
1112
|
-
this._realGetNext();
|
|
1113
|
-
} while (this._pendingNext);
|
|
1114
|
-
} finally {
|
|
1115
|
-
this._insideLoop = false;
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1041
|
+
CombinedStream.prototype.pipe = function(dest, options) {
|
|
1042
|
+
Stream.prototype.pipe.call(this, dest, options);
|
|
1043
|
+
this.resume();
|
|
1044
|
+
return dest;
|
|
1045
|
+
};
|
|
1118
1046
|
|
|
1119
|
-
CombinedStream
|
|
1120
|
-
|
|
1047
|
+
CombinedStream.prototype._getNext = function() {
|
|
1048
|
+
this._currentStream = null;
|
|
1121
1049
|
|
|
1050
|
+
if (this._insideLoop) {
|
|
1051
|
+
this._pendingNext = true;
|
|
1052
|
+
return; // defer call
|
|
1053
|
+
}
|
|
1122
1054
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1055
|
+
this._insideLoop = true;
|
|
1056
|
+
try {
|
|
1057
|
+
do {
|
|
1058
|
+
this._pendingNext = false;
|
|
1059
|
+
this._realGetNext();
|
|
1060
|
+
} while (this._pendingNext);
|
|
1061
|
+
} finally {
|
|
1062
|
+
this._insideLoop = false;
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1127
1065
|
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
return;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
var getStream = stream;
|
|
1134
|
-
getStream(function(stream) {
|
|
1135
|
-
var isStreamLike = CombinedStream$1.isStreamLike(stream);
|
|
1136
|
-
if (isStreamLike) {
|
|
1137
|
-
stream.on('data', this._checkDataSize.bind(this));
|
|
1138
|
-
this._handleErrors(stream);
|
|
1139
|
-
}
|
|
1066
|
+
CombinedStream.prototype._realGetNext = function() {
|
|
1067
|
+
var stream = this._streams.shift();
|
|
1140
1068
|
|
|
1141
|
-
this._pipeNext(stream);
|
|
1142
|
-
}.bind(this));
|
|
1143
|
-
};
|
|
1144
1069
|
|
|
1145
|
-
|
|
1146
|
-
|
|
1070
|
+
if (typeof stream == 'undefined') {
|
|
1071
|
+
this.end();
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1147
1074
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
return;
|
|
1153
|
-
}
|
|
1075
|
+
if (typeof stream !== 'function') {
|
|
1076
|
+
this._pipeNext(stream);
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1154
1079
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1080
|
+
var getStream = stream;
|
|
1081
|
+
getStream(function(stream) {
|
|
1082
|
+
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1083
|
+
if (isStreamLike) {
|
|
1084
|
+
stream.on('data', this._checkDataSize.bind(this));
|
|
1085
|
+
this._handleErrors(stream);
|
|
1086
|
+
}
|
|
1159
1087
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
self._emitError(err);
|
|
1164
|
-
});
|
|
1165
|
-
};
|
|
1088
|
+
this._pipeNext(stream);
|
|
1089
|
+
}.bind(this));
|
|
1090
|
+
};
|
|
1166
1091
|
|
|
1167
|
-
CombinedStream
|
|
1168
|
-
|
|
1169
|
-
};
|
|
1092
|
+
CombinedStream.prototype._pipeNext = function(stream) {
|
|
1093
|
+
this._currentStream = stream;
|
|
1170
1094
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1095
|
+
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1096
|
+
if (isStreamLike) {
|
|
1097
|
+
stream.on('end', this._getNext.bind(this));
|
|
1098
|
+
stream.pipe(this, {end: false});
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1175
1101
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1102
|
+
var value = stream;
|
|
1103
|
+
this.write(value);
|
|
1104
|
+
this._getNext();
|
|
1105
|
+
};
|
|
1179
1106
|
|
|
1180
|
-
CombinedStream
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1107
|
+
CombinedStream.prototype._handleErrors = function(stream) {
|
|
1108
|
+
var self = this;
|
|
1109
|
+
stream.on('error', function(err) {
|
|
1110
|
+
self._emitError(err);
|
|
1111
|
+
});
|
|
1112
|
+
};
|
|
1186
1113
|
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
};
|
|
1114
|
+
CombinedStream.prototype.write = function(data) {
|
|
1115
|
+
this.emit('data', data);
|
|
1116
|
+
};
|
|
1190
1117
|
|
|
1191
|
-
CombinedStream
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
}
|
|
1118
|
+
CombinedStream.prototype.pause = function() {
|
|
1119
|
+
if (!this.pauseStreams) {
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1195
1122
|
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
};
|
|
1123
|
+
if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause();
|
|
1124
|
+
this.emit('pause');
|
|
1125
|
+
};
|
|
1200
1126
|
|
|
1201
|
-
CombinedStream
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1127
|
+
CombinedStream.prototype.resume = function() {
|
|
1128
|
+
if (!this._released) {
|
|
1129
|
+
this._released = true;
|
|
1130
|
+
this.writable = true;
|
|
1131
|
+
this._getNext();
|
|
1132
|
+
}
|
|
1206
1133
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1134
|
+
if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume();
|
|
1135
|
+
this.emit('resume');
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1138
|
+
CombinedStream.prototype.end = function() {
|
|
1139
|
+
this._reset();
|
|
1140
|
+
this.emit('end');
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
CombinedStream.prototype.destroy = function() {
|
|
1144
|
+
this._reset();
|
|
1145
|
+
this.emit('close');
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
CombinedStream.prototype._reset = function() {
|
|
1149
|
+
this.writable = false;
|
|
1150
|
+
this._streams = [];
|
|
1151
|
+
this._currentStream = null;
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
CombinedStream.prototype._checkDataSize = function() {
|
|
1155
|
+
this._updateDataSize();
|
|
1156
|
+
if (this.dataSize <= this.maxDataSize) {
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1212
1159
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
};
|
|
1160
|
+
var message =
|
|
1161
|
+
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.';
|
|
1162
|
+
this._emitError(new Error(message));
|
|
1163
|
+
};
|
|
1217
1164
|
|
|
1218
|
-
CombinedStream
|
|
1219
|
-
|
|
1165
|
+
CombinedStream.prototype._updateDataSize = function() {
|
|
1166
|
+
this.dataSize = 0;
|
|
1220
1167
|
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1168
|
+
var self = this;
|
|
1169
|
+
this._streams.forEach(function(stream) {
|
|
1170
|
+
if (!stream.dataSize) {
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1226
1173
|
|
|
1227
|
-
|
|
1228
|
-
|
|
1174
|
+
self.dataSize += stream.dataSize;
|
|
1175
|
+
});
|
|
1229
1176
|
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
};
|
|
1177
|
+
if (this._currentStream && this._currentStream.dataSize) {
|
|
1178
|
+
this.dataSize += this._currentStream.dataSize;
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1234
1181
|
|
|
1235
|
-
CombinedStream
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
};
|
|
1182
|
+
CombinedStream.prototype._emitError = function(err) {
|
|
1183
|
+
this._reset();
|
|
1184
|
+
this.emit('error', err);
|
|
1185
|
+
};
|
|
1186
|
+
return combined_stream;
|
|
1187
|
+
}
|
|
1239
1188
|
|
|
1240
1189
|
var mimeTypes = {};
|
|
1241
1190
|
|
|
@@ -11949,11 +11898,19 @@ var require$$0 = {
|
|
|
11949
11898
|
* MIT Licensed
|
|
11950
11899
|
*/
|
|
11951
11900
|
|
|
11952
|
-
|
|
11953
|
-
|
|
11954
|
-
*/
|
|
11901
|
+
var mimeDb;
|
|
11902
|
+
var hasRequiredMimeDb;
|
|
11955
11903
|
|
|
11956
|
-
|
|
11904
|
+
function requireMimeDb () {
|
|
11905
|
+
if (hasRequiredMimeDb) return mimeDb;
|
|
11906
|
+
hasRequiredMimeDb = 1;
|
|
11907
|
+
/**
|
|
11908
|
+
* Module exports.
|
|
11909
|
+
*/
|
|
11910
|
+
|
|
11911
|
+
mimeDb = require$$0;
|
|
11912
|
+
return mimeDb;
|
|
11913
|
+
}
|
|
11957
11914
|
|
|
11958
11915
|
/*!
|
|
11959
11916
|
* mime-types
|
|
@@ -11962,1088 +11919,1189 @@ var mimeDb = require$$0;
|
|
|
11962
11919
|
* MIT Licensed
|
|
11963
11920
|
*/
|
|
11964
11921
|
|
|
11965
|
-
|
|
11922
|
+
var hasRequiredMimeTypes;
|
|
11923
|
+
|
|
11924
|
+
function requireMimeTypes () {
|
|
11925
|
+
if (hasRequiredMimeTypes) return mimeTypes;
|
|
11926
|
+
hasRequiredMimeTypes = 1;
|
|
11927
|
+
(function (exports) {
|
|
11928
|
+
|
|
11929
|
+
/**
|
|
11930
|
+
* Module dependencies.
|
|
11931
|
+
* @private
|
|
11932
|
+
*/
|
|
11933
|
+
|
|
11934
|
+
var db = requireMimeDb();
|
|
11935
|
+
var extname = require$$1$1.extname;
|
|
11936
|
+
|
|
11937
|
+
/**
|
|
11938
|
+
* Module variables.
|
|
11939
|
+
* @private
|
|
11940
|
+
*/
|
|
11941
|
+
|
|
11942
|
+
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
11943
|
+
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
11944
|
+
|
|
11945
|
+
/**
|
|
11946
|
+
* Module exports.
|
|
11947
|
+
* @public
|
|
11948
|
+
*/
|
|
11949
|
+
|
|
11950
|
+
exports.charset = charset;
|
|
11951
|
+
exports.charsets = { lookup: charset };
|
|
11952
|
+
exports.contentType = contentType;
|
|
11953
|
+
exports.extension = extension;
|
|
11954
|
+
exports.extensions = Object.create(null);
|
|
11955
|
+
exports.lookup = lookup;
|
|
11956
|
+
exports.types = Object.create(null);
|
|
11957
|
+
|
|
11958
|
+
// Populate the extensions/types maps
|
|
11959
|
+
populateMaps(exports.extensions, exports.types);
|
|
11960
|
+
|
|
11961
|
+
/**
|
|
11962
|
+
* Get the default charset for a MIME type.
|
|
11963
|
+
*
|
|
11964
|
+
* @param {string} type
|
|
11965
|
+
* @return {boolean|string}
|
|
11966
|
+
*/
|
|
11967
|
+
|
|
11968
|
+
function charset (type) {
|
|
11969
|
+
if (!type || typeof type !== 'string') {
|
|
11970
|
+
return false
|
|
11971
|
+
}
|
|
11972
|
+
|
|
11973
|
+
// TODO: use media-typer
|
|
11974
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
11975
|
+
var mime = match && db[match[1].toLowerCase()];
|
|
11976
|
+
|
|
11977
|
+
if (mime && mime.charset) {
|
|
11978
|
+
return mime.charset
|
|
11979
|
+
}
|
|
11980
|
+
|
|
11981
|
+
// default text/* to utf-8
|
|
11982
|
+
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
|
11983
|
+
return 'UTF-8'
|
|
11984
|
+
}
|
|
11985
|
+
|
|
11986
|
+
return false
|
|
11987
|
+
}
|
|
11988
|
+
|
|
11989
|
+
/**
|
|
11990
|
+
* Create a full Content-Type header given a MIME type or extension.
|
|
11991
|
+
*
|
|
11992
|
+
* @param {string} str
|
|
11993
|
+
* @return {boolean|string}
|
|
11994
|
+
*/
|
|
11995
|
+
|
|
11996
|
+
function contentType (str) {
|
|
11997
|
+
// TODO: should this even be in this module?
|
|
11998
|
+
if (!str || typeof str !== 'string') {
|
|
11999
|
+
return false
|
|
12000
|
+
}
|
|
12001
|
+
|
|
12002
|
+
var mime = str.indexOf('/') === -1
|
|
12003
|
+
? exports.lookup(str)
|
|
12004
|
+
: str;
|
|
12005
|
+
|
|
12006
|
+
if (!mime) {
|
|
12007
|
+
return false
|
|
12008
|
+
}
|
|
12009
|
+
|
|
12010
|
+
// TODO: use content-type or other module
|
|
12011
|
+
if (mime.indexOf('charset') === -1) {
|
|
12012
|
+
var charset = exports.charset(mime);
|
|
12013
|
+
if (charset) mime += '; charset=' + charset.toLowerCase();
|
|
12014
|
+
}
|
|
12015
|
+
|
|
12016
|
+
return mime
|
|
12017
|
+
}
|
|
12018
|
+
|
|
12019
|
+
/**
|
|
12020
|
+
* Get the default extension for a MIME type.
|
|
12021
|
+
*
|
|
12022
|
+
* @param {string} type
|
|
12023
|
+
* @return {boolean|string}
|
|
12024
|
+
*/
|
|
12025
|
+
|
|
12026
|
+
function extension (type) {
|
|
12027
|
+
if (!type || typeof type !== 'string') {
|
|
12028
|
+
return false
|
|
12029
|
+
}
|
|
12030
|
+
|
|
12031
|
+
// TODO: use media-typer
|
|
12032
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
12033
|
+
|
|
12034
|
+
// get extensions
|
|
12035
|
+
var exts = match && exports.extensions[match[1].toLowerCase()];
|
|
12036
|
+
|
|
12037
|
+
if (!exts || !exts.length) {
|
|
12038
|
+
return false
|
|
12039
|
+
}
|
|
12040
|
+
|
|
12041
|
+
return exts[0]
|
|
12042
|
+
}
|
|
12043
|
+
|
|
12044
|
+
/**
|
|
12045
|
+
* Lookup the MIME type for a file path/extension.
|
|
12046
|
+
*
|
|
12047
|
+
* @param {string} path
|
|
12048
|
+
* @return {boolean|string}
|
|
12049
|
+
*/
|
|
12050
|
+
|
|
12051
|
+
function lookup (path) {
|
|
12052
|
+
if (!path || typeof path !== 'string') {
|
|
12053
|
+
return false
|
|
12054
|
+
}
|
|
12055
|
+
|
|
12056
|
+
// get the extension ("ext" or ".ext" or full path)
|
|
12057
|
+
var extension = extname('x.' + path)
|
|
12058
|
+
.toLowerCase()
|
|
12059
|
+
.substr(1);
|
|
12060
|
+
|
|
12061
|
+
if (!extension) {
|
|
12062
|
+
return false
|
|
12063
|
+
}
|
|
12064
|
+
|
|
12065
|
+
return exports.types[extension] || false
|
|
12066
|
+
}
|
|
12067
|
+
|
|
12068
|
+
/**
|
|
12069
|
+
* Populate the extensions and types maps.
|
|
12070
|
+
* @private
|
|
12071
|
+
*/
|
|
12072
|
+
|
|
12073
|
+
function populateMaps (extensions, types) {
|
|
12074
|
+
// source preference (least -> most)
|
|
12075
|
+
var preference = ['nginx', 'apache', undefined, 'iana'];
|
|
12076
|
+
|
|
12077
|
+
Object.keys(db).forEach(function forEachMimeType (type) {
|
|
12078
|
+
var mime = db[type];
|
|
12079
|
+
var exts = mime.extensions;
|
|
12080
|
+
|
|
12081
|
+
if (!exts || !exts.length) {
|
|
12082
|
+
return
|
|
12083
|
+
}
|
|
12084
|
+
|
|
12085
|
+
// mime -> extensions
|
|
12086
|
+
extensions[type] = exts;
|
|
12087
|
+
|
|
12088
|
+
// extension -> mime
|
|
12089
|
+
for (var i = 0; i < exts.length; i++) {
|
|
12090
|
+
var extension = exts[i];
|
|
12091
|
+
|
|
12092
|
+
if (types[extension]) {
|
|
12093
|
+
var from = preference.indexOf(db[types[extension]].source);
|
|
12094
|
+
var to = preference.indexOf(mime.source);
|
|
12095
|
+
|
|
12096
|
+
if (types[extension] !== 'application/octet-stream' &&
|
|
12097
|
+
(from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
|
|
12098
|
+
// skip the remapping
|
|
12099
|
+
continue
|
|
12100
|
+
}
|
|
12101
|
+
}
|
|
12102
|
+
|
|
12103
|
+
// set the extension -> mime
|
|
12104
|
+
types[extension] = type;
|
|
12105
|
+
}
|
|
12106
|
+
});
|
|
12107
|
+
}
|
|
12108
|
+
} (mimeTypes));
|
|
12109
|
+
return mimeTypes;
|
|
12110
|
+
}
|
|
11966
12111
|
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
* @private
|
|
11970
|
-
*/
|
|
12112
|
+
var defer_1;
|
|
12113
|
+
var hasRequiredDefer;
|
|
11971
12114
|
|
|
11972
|
-
|
|
11973
|
-
|
|
12115
|
+
function requireDefer () {
|
|
12116
|
+
if (hasRequiredDefer) return defer_1;
|
|
12117
|
+
hasRequiredDefer = 1;
|
|
12118
|
+
defer_1 = defer;
|
|
11974
12119
|
|
|
11975
12120
|
/**
|
|
11976
|
-
*
|
|
11977
|
-
*
|
|
12121
|
+
* Runs provided function on next iteration of the event loop
|
|
12122
|
+
*
|
|
12123
|
+
* @param {function} fn - function to run
|
|
11978
12124
|
*/
|
|
12125
|
+
function defer(fn)
|
|
12126
|
+
{
|
|
12127
|
+
var nextTick = typeof setImmediate == 'function'
|
|
12128
|
+
? setImmediate
|
|
12129
|
+
: (
|
|
12130
|
+
typeof process == 'object' && typeof process.nextTick == 'function'
|
|
12131
|
+
? process.nextTick
|
|
12132
|
+
: null
|
|
12133
|
+
);
|
|
12134
|
+
|
|
12135
|
+
if (nextTick)
|
|
12136
|
+
{
|
|
12137
|
+
nextTick(fn);
|
|
12138
|
+
}
|
|
12139
|
+
else
|
|
12140
|
+
{
|
|
12141
|
+
setTimeout(fn, 0);
|
|
12142
|
+
}
|
|
12143
|
+
}
|
|
12144
|
+
return defer_1;
|
|
12145
|
+
}
|
|
11979
12146
|
|
|
11980
|
-
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
/**
|
|
11984
|
-
* Module exports.
|
|
11985
|
-
* @public
|
|
11986
|
-
*/
|
|
12147
|
+
var async_1;
|
|
12148
|
+
var hasRequiredAsync;
|
|
11987
12149
|
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
exports.extensions = Object.create(null);
|
|
11993
|
-
exports.lookup = lookup;
|
|
11994
|
-
exports.types = Object.create(null);
|
|
12150
|
+
function requireAsync () {
|
|
12151
|
+
if (hasRequiredAsync) return async_1;
|
|
12152
|
+
hasRequiredAsync = 1;
|
|
12153
|
+
var defer = requireDefer();
|
|
11995
12154
|
|
|
11996
|
-
//
|
|
11997
|
-
|
|
12155
|
+
// API
|
|
12156
|
+
async_1 = async;
|
|
11998
12157
|
|
|
11999
12158
|
/**
|
|
12000
|
-
*
|
|
12159
|
+
* Runs provided callback asynchronously
|
|
12160
|
+
* even if callback itself is not
|
|
12001
12161
|
*
|
|
12002
|
-
* @param
|
|
12003
|
-
* @
|
|
12162
|
+
* @param {function} callback - callback to invoke
|
|
12163
|
+
* @returns {function} - augmented callback
|
|
12004
12164
|
*/
|
|
12165
|
+
function async(callback)
|
|
12166
|
+
{
|
|
12167
|
+
var isAsync = false;
|
|
12168
|
+
|
|
12169
|
+
// check if async happened
|
|
12170
|
+
defer(function() { isAsync = true; });
|
|
12171
|
+
|
|
12172
|
+
return function async_callback(err, result)
|
|
12173
|
+
{
|
|
12174
|
+
if (isAsync)
|
|
12175
|
+
{
|
|
12176
|
+
callback(err, result);
|
|
12177
|
+
}
|
|
12178
|
+
else
|
|
12179
|
+
{
|
|
12180
|
+
defer(function nextTick_callback()
|
|
12181
|
+
{
|
|
12182
|
+
callback(err, result);
|
|
12183
|
+
});
|
|
12184
|
+
}
|
|
12185
|
+
};
|
|
12186
|
+
}
|
|
12187
|
+
return async_1;
|
|
12188
|
+
}
|
|
12005
12189
|
|
|
12006
|
-
|
|
12007
|
-
|
|
12008
|
-
return false
|
|
12009
|
-
}
|
|
12010
|
-
|
|
12011
|
-
// TODO: use media-typer
|
|
12012
|
-
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
12013
|
-
var mime = match && db[match[1].toLowerCase()];
|
|
12190
|
+
var abort_1;
|
|
12191
|
+
var hasRequiredAbort;
|
|
12014
12192
|
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
12193
|
+
function requireAbort () {
|
|
12194
|
+
if (hasRequiredAbort) return abort_1;
|
|
12195
|
+
hasRequiredAbort = 1;
|
|
12196
|
+
// API
|
|
12197
|
+
abort_1 = abort;
|
|
12018
12198
|
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12199
|
+
/**
|
|
12200
|
+
* Aborts leftover active jobs
|
|
12201
|
+
*
|
|
12202
|
+
* @param {object} state - current state object
|
|
12203
|
+
*/
|
|
12204
|
+
function abort(state)
|
|
12205
|
+
{
|
|
12206
|
+
Object.keys(state.jobs).forEach(clean.bind(state));
|
|
12023
12207
|
|
|
12024
|
-
|
|
12208
|
+
// reset leftover jobs
|
|
12209
|
+
state.jobs = {};
|
|
12025
12210
|
}
|
|
12026
12211
|
|
|
12027
12212
|
/**
|
|
12028
|
-
*
|
|
12213
|
+
* Cleans up leftover job by invoking abort function for the provided job id
|
|
12029
12214
|
*
|
|
12030
|
-
* @
|
|
12031
|
-
* @
|
|
12215
|
+
* @this state
|
|
12216
|
+
* @param {string|number} key - job id to abort
|
|
12032
12217
|
*/
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12037
|
-
|
|
12218
|
+
function clean(key)
|
|
12219
|
+
{
|
|
12220
|
+
if (typeof this.jobs[key] == 'function')
|
|
12221
|
+
{
|
|
12222
|
+
this.jobs[key]();
|
|
12038
12223
|
}
|
|
12224
|
+
}
|
|
12225
|
+
return abort_1;
|
|
12226
|
+
}
|
|
12039
12227
|
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
: str;
|
|
12228
|
+
var iterate_1;
|
|
12229
|
+
var hasRequiredIterate;
|
|
12043
12230
|
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12231
|
+
function requireIterate () {
|
|
12232
|
+
if (hasRequiredIterate) return iterate_1;
|
|
12233
|
+
hasRequiredIterate = 1;
|
|
12234
|
+
var async = requireAsync()
|
|
12235
|
+
, abort = requireAbort()
|
|
12236
|
+
;
|
|
12047
12237
|
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
var charset = exports.charset(mime);
|
|
12051
|
-
if (charset) mime += '; charset=' + charset.toLowerCase();
|
|
12052
|
-
}
|
|
12053
|
-
|
|
12054
|
-
return mime
|
|
12055
|
-
}
|
|
12238
|
+
// API
|
|
12239
|
+
iterate_1 = iterate;
|
|
12056
12240
|
|
|
12057
12241
|
/**
|
|
12058
|
-
*
|
|
12242
|
+
* Iterates over each job object
|
|
12059
12243
|
*
|
|
12060
|
-
* @param {
|
|
12061
|
-
* @
|
|
12244
|
+
* @param {array|object} list - array or object (named list) to iterate over
|
|
12245
|
+
* @param {function} iterator - iterator to run
|
|
12246
|
+
* @param {object} state - current job status
|
|
12247
|
+
* @param {function} callback - invoked when all elements processed
|
|
12062
12248
|
*/
|
|
12249
|
+
function iterate(list, iterator, state, callback)
|
|
12250
|
+
{
|
|
12251
|
+
// store current index
|
|
12252
|
+
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
|
12253
|
+
|
|
12254
|
+
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
|
|
12255
|
+
{
|
|
12256
|
+
// don't repeat yourself
|
|
12257
|
+
// skip secondary callbacks
|
|
12258
|
+
if (!(key in state.jobs))
|
|
12259
|
+
{
|
|
12260
|
+
return;
|
|
12261
|
+
}
|
|
12063
12262
|
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
return false
|
|
12067
|
-
}
|
|
12068
|
-
|
|
12069
|
-
// TODO: use media-typer
|
|
12070
|
-
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
12071
|
-
|
|
12072
|
-
// get extensions
|
|
12073
|
-
var exts = match && exports.extensions[match[1].toLowerCase()];
|
|
12263
|
+
// clean up jobs
|
|
12264
|
+
delete state.jobs[key];
|
|
12074
12265
|
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12266
|
+
if (error)
|
|
12267
|
+
{
|
|
12268
|
+
// don't process rest of the results
|
|
12269
|
+
// stop still active jobs
|
|
12270
|
+
// and reset the list
|
|
12271
|
+
abort(state);
|
|
12272
|
+
}
|
|
12273
|
+
else
|
|
12274
|
+
{
|
|
12275
|
+
state.results[key] = output;
|
|
12276
|
+
}
|
|
12078
12277
|
|
|
12079
|
-
|
|
12278
|
+
// return salvaged results
|
|
12279
|
+
callback(error, state.results);
|
|
12280
|
+
});
|
|
12080
12281
|
}
|
|
12081
12282
|
|
|
12082
12283
|
/**
|
|
12083
|
-
*
|
|
12284
|
+
* Runs iterator over provided job element
|
|
12084
12285
|
*
|
|
12085
|
-
* @param
|
|
12086
|
-
* @
|
|
12286
|
+
* @param {function} iterator - iterator to invoke
|
|
12287
|
+
* @param {string|number} key - key/index of the element in the list of jobs
|
|
12288
|
+
* @param {mixed} item - job description
|
|
12289
|
+
* @param {function} callback - invoked after iterator is done with the job
|
|
12290
|
+
* @returns {function|mixed} - job abort function or something else
|
|
12087
12291
|
*/
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12292
|
+
function runJob(iterator, key, item, callback)
|
|
12293
|
+
{
|
|
12294
|
+
var aborter;
|
|
12295
|
+
|
|
12296
|
+
// allow shortcut if iterator expects only two arguments
|
|
12297
|
+
if (iterator.length == 2)
|
|
12298
|
+
{
|
|
12299
|
+
aborter = iterator(item, async(callback));
|
|
12092
12300
|
}
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
.substr(1);
|
|
12098
|
-
|
|
12099
|
-
if (!extension) {
|
|
12100
|
-
return false
|
|
12301
|
+
// otherwise go with full three arguments
|
|
12302
|
+
else
|
|
12303
|
+
{
|
|
12304
|
+
aborter = iterator(item, key, async(callback));
|
|
12101
12305
|
}
|
|
12102
12306
|
|
|
12103
|
-
return
|
|
12307
|
+
return aborter;
|
|
12104
12308
|
}
|
|
12309
|
+
return iterate_1;
|
|
12310
|
+
}
|
|
12105
12311
|
|
|
12106
|
-
|
|
12107
|
-
|
|
12108
|
-
* @private
|
|
12109
|
-
*/
|
|
12110
|
-
|
|
12111
|
-
function populateMaps (extensions, types) {
|
|
12112
|
-
// source preference (least -> most)
|
|
12113
|
-
var preference = ['nginx', 'apache', undefined, 'iana'];
|
|
12312
|
+
var state_1;
|
|
12313
|
+
var hasRequiredState;
|
|
12114
12314
|
|
|
12115
|
-
|
|
12116
|
-
|
|
12117
|
-
|
|
12315
|
+
function requireState () {
|
|
12316
|
+
if (hasRequiredState) return state_1;
|
|
12317
|
+
hasRequiredState = 1;
|
|
12318
|
+
// API
|
|
12319
|
+
state_1 = state;
|
|
12118
12320
|
|
|
12119
|
-
|
|
12120
|
-
|
|
12321
|
+
/**
|
|
12322
|
+
* Creates initial state object
|
|
12323
|
+
* for iteration over list
|
|
12324
|
+
*
|
|
12325
|
+
* @param {array|object} list - list to iterate over
|
|
12326
|
+
* @param {function|null} sortMethod - function to use for keys sort,
|
|
12327
|
+
* or `null` to keep them as is
|
|
12328
|
+
* @returns {object} - initial state object
|
|
12329
|
+
*/
|
|
12330
|
+
function state(list, sortMethod)
|
|
12331
|
+
{
|
|
12332
|
+
var isNamedList = !Array.isArray(list)
|
|
12333
|
+
, initState =
|
|
12334
|
+
{
|
|
12335
|
+
index : 0,
|
|
12336
|
+
keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
|
|
12337
|
+
jobs : {},
|
|
12338
|
+
results : isNamedList ? {} : [],
|
|
12339
|
+
size : isNamedList ? Object.keys(list).length : list.length
|
|
12121
12340
|
}
|
|
12341
|
+
;
|
|
12342
|
+
|
|
12343
|
+
if (sortMethod)
|
|
12344
|
+
{
|
|
12345
|
+
// sort array keys based on it's values
|
|
12346
|
+
// sort object's keys just on own merit
|
|
12347
|
+
initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
|
|
12348
|
+
{
|
|
12349
|
+
return sortMethod(list[a], list[b]);
|
|
12350
|
+
});
|
|
12351
|
+
}
|
|
12122
12352
|
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
for (var i = 0; i < exts.length; i++) {
|
|
12128
|
-
var extension = exts[i];
|
|
12353
|
+
return initState;
|
|
12354
|
+
}
|
|
12355
|
+
return state_1;
|
|
12356
|
+
}
|
|
12129
12357
|
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
var to = preference.indexOf(mime.source);
|
|
12358
|
+
var terminator_1;
|
|
12359
|
+
var hasRequiredTerminator;
|
|
12133
12360
|
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12361
|
+
function requireTerminator () {
|
|
12362
|
+
if (hasRequiredTerminator) return terminator_1;
|
|
12363
|
+
hasRequiredTerminator = 1;
|
|
12364
|
+
var abort = requireAbort()
|
|
12365
|
+
, async = requireAsync()
|
|
12366
|
+
;
|
|
12140
12367
|
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
}
|
|
12144
|
-
});
|
|
12145
|
-
}
|
|
12146
|
-
} (mimeTypes));
|
|
12147
|
-
|
|
12148
|
-
var defer_1 = defer$1;
|
|
12368
|
+
// API
|
|
12369
|
+
terminator_1 = terminator;
|
|
12149
12370
|
|
|
12150
|
-
/**
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
: null
|
|
12163
|
-
);
|
|
12164
|
-
|
|
12165
|
-
if (nextTick)
|
|
12166
|
-
{
|
|
12167
|
-
nextTick(fn);
|
|
12168
|
-
}
|
|
12169
|
-
else
|
|
12170
|
-
{
|
|
12171
|
-
setTimeout(fn, 0);
|
|
12172
|
-
}
|
|
12173
|
-
}
|
|
12371
|
+
/**
|
|
12372
|
+
* Terminates jobs in the attached state context
|
|
12373
|
+
*
|
|
12374
|
+
* @this AsyncKitState#
|
|
12375
|
+
* @param {function} callback - final callback to invoke after termination
|
|
12376
|
+
*/
|
|
12377
|
+
function terminator(callback)
|
|
12378
|
+
{
|
|
12379
|
+
if (!Object.keys(this.jobs).length)
|
|
12380
|
+
{
|
|
12381
|
+
return;
|
|
12382
|
+
}
|
|
12174
12383
|
|
|
12175
|
-
|
|
12384
|
+
// fast forward iteration index
|
|
12385
|
+
this.index = this.size;
|
|
12176
12386
|
|
|
12177
|
-
//
|
|
12178
|
-
|
|
12387
|
+
// abort jobs
|
|
12388
|
+
abort(this);
|
|
12179
12389
|
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
|
|
12183
|
-
|
|
12184
|
-
* @param {function} callback - callback to invoke
|
|
12185
|
-
* @returns {function} - augmented callback
|
|
12186
|
-
*/
|
|
12187
|
-
function async$2(callback)
|
|
12188
|
-
{
|
|
12189
|
-
var isAsync = false;
|
|
12190
|
-
|
|
12191
|
-
// check if async happened
|
|
12192
|
-
defer(function() { isAsync = true; });
|
|
12193
|
-
|
|
12194
|
-
return function async_callback(err, result)
|
|
12195
|
-
{
|
|
12196
|
-
if (isAsync)
|
|
12197
|
-
{
|
|
12198
|
-
callback(err, result);
|
|
12199
|
-
}
|
|
12200
|
-
else
|
|
12201
|
-
{
|
|
12202
|
-
defer(function nextTick_callback()
|
|
12203
|
-
{
|
|
12204
|
-
callback(err, result);
|
|
12205
|
-
});
|
|
12206
|
-
}
|
|
12207
|
-
};
|
|
12390
|
+
// send back results we have so far
|
|
12391
|
+
async(callback)(null, this.results);
|
|
12392
|
+
}
|
|
12393
|
+
return terminator_1;
|
|
12208
12394
|
}
|
|
12209
12395
|
|
|
12210
|
-
|
|
12211
|
-
var
|
|
12396
|
+
var parallel_1;
|
|
12397
|
+
var hasRequiredParallel;
|
|
12212
12398
|
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
|
|
12220
|
-
Object.keys(state.jobs).forEach(clean.bind(state));
|
|
12399
|
+
function requireParallel () {
|
|
12400
|
+
if (hasRequiredParallel) return parallel_1;
|
|
12401
|
+
hasRequiredParallel = 1;
|
|
12402
|
+
var iterate = requireIterate()
|
|
12403
|
+
, initState = requireState()
|
|
12404
|
+
, terminator = requireTerminator()
|
|
12405
|
+
;
|
|
12221
12406
|
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
}
|
|
12407
|
+
// Public API
|
|
12408
|
+
parallel_1 = parallel;
|
|
12225
12409
|
|
|
12226
|
-
/**
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
function
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12410
|
+
/**
|
|
12411
|
+
* Runs iterator over provided array elements in parallel
|
|
12412
|
+
*
|
|
12413
|
+
* @param {array|object} list - array or object (named list) to iterate over
|
|
12414
|
+
* @param {function} iterator - iterator to run
|
|
12415
|
+
* @param {function} callback - invoked when all elements processed
|
|
12416
|
+
* @returns {function} - jobs terminator
|
|
12417
|
+
*/
|
|
12418
|
+
function parallel(list, iterator, callback)
|
|
12419
|
+
{
|
|
12420
|
+
var state = initState(list);
|
|
12421
|
+
|
|
12422
|
+
while (state.index < (state['keyedList'] || list).length)
|
|
12423
|
+
{
|
|
12424
|
+
iterate(list, iterator, state, function(error, result)
|
|
12425
|
+
{
|
|
12426
|
+
if (error)
|
|
12427
|
+
{
|
|
12428
|
+
callback(error, result);
|
|
12429
|
+
return;
|
|
12430
|
+
}
|
|
12239
12431
|
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12432
|
+
// looks like it's the last one
|
|
12433
|
+
if (Object.keys(state.jobs).length === 0)
|
|
12434
|
+
{
|
|
12435
|
+
callback(null, state.results);
|
|
12436
|
+
return;
|
|
12437
|
+
}
|
|
12438
|
+
});
|
|
12243
12439
|
|
|
12244
|
-
|
|
12245
|
-
|
|
12440
|
+
state.index++;
|
|
12441
|
+
}
|
|
12246
12442
|
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
* @param {function} iterator - iterator to run
|
|
12252
|
-
* @param {object} state - current job status
|
|
12253
|
-
* @param {function} callback - invoked when all elements processed
|
|
12254
|
-
*/
|
|
12255
|
-
function iterate$2(list, iterator, state, callback)
|
|
12256
|
-
{
|
|
12257
|
-
// store current index
|
|
12258
|
-
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
|
12259
|
-
|
|
12260
|
-
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
|
|
12261
|
-
{
|
|
12262
|
-
// don't repeat yourself
|
|
12263
|
-
// skip secondary callbacks
|
|
12264
|
-
if (!(key in state.jobs))
|
|
12265
|
-
{
|
|
12266
|
-
return;
|
|
12267
|
-
}
|
|
12443
|
+
return terminator.bind(state, callback);
|
|
12444
|
+
}
|
|
12445
|
+
return parallel_1;
|
|
12446
|
+
}
|
|
12268
12447
|
|
|
12269
|
-
|
|
12270
|
-
delete state.jobs[key];
|
|
12448
|
+
var serialOrdered = {exports: {}};
|
|
12271
12449
|
|
|
12272
|
-
|
|
12273
|
-
{
|
|
12274
|
-
// don't process rest of the results
|
|
12275
|
-
// stop still active jobs
|
|
12276
|
-
// and reset the list
|
|
12277
|
-
abort$1(state);
|
|
12278
|
-
}
|
|
12279
|
-
else
|
|
12280
|
-
{
|
|
12281
|
-
state.results[key] = output;
|
|
12282
|
-
}
|
|
12450
|
+
var hasRequiredSerialOrdered;
|
|
12283
12451
|
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12452
|
+
function requireSerialOrdered () {
|
|
12453
|
+
if (hasRequiredSerialOrdered) return serialOrdered.exports;
|
|
12454
|
+
hasRequiredSerialOrdered = 1;
|
|
12455
|
+
var iterate = requireIterate()
|
|
12456
|
+
, initState = requireState()
|
|
12457
|
+
, terminator = requireTerminator()
|
|
12458
|
+
;
|
|
12288
12459
|
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
* @param {mixed} item - job description
|
|
12295
|
-
* @param {function} callback - invoked after iterator is done with the job
|
|
12296
|
-
* @returns {function|mixed} - job abort function or something else
|
|
12297
|
-
*/
|
|
12298
|
-
function runJob(iterator, key, item, callback)
|
|
12299
|
-
{
|
|
12300
|
-
var aborter;
|
|
12301
|
-
|
|
12302
|
-
// allow shortcut if iterator expects only two arguments
|
|
12303
|
-
if (iterator.length == 2)
|
|
12304
|
-
{
|
|
12305
|
-
aborter = iterator(item, async$1(callback));
|
|
12306
|
-
}
|
|
12307
|
-
// otherwise go with full three arguments
|
|
12308
|
-
else
|
|
12309
|
-
{
|
|
12310
|
-
aborter = iterator(item, key, async$1(callback));
|
|
12311
|
-
}
|
|
12312
|
-
|
|
12313
|
-
return aborter;
|
|
12314
|
-
}
|
|
12460
|
+
// Public API
|
|
12461
|
+
serialOrdered.exports = serialOrdered$1;
|
|
12462
|
+
// sorting helpers
|
|
12463
|
+
serialOrdered.exports.ascending = ascending;
|
|
12464
|
+
serialOrdered.exports.descending = descending;
|
|
12315
12465
|
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12336
|
-
results : isNamedList ? {} : [],
|
|
12337
|
-
size : isNamedList ? Object.keys(list).length : list.length
|
|
12338
|
-
}
|
|
12339
|
-
;
|
|
12340
|
-
|
|
12341
|
-
if (sortMethod)
|
|
12342
|
-
{
|
|
12343
|
-
// sort array keys based on it's values
|
|
12344
|
-
// sort object's keys just on own merit
|
|
12345
|
-
initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
|
|
12346
|
-
{
|
|
12347
|
-
return sortMethod(list[a], list[b]);
|
|
12348
|
-
});
|
|
12349
|
-
}
|
|
12466
|
+
/**
|
|
12467
|
+
* Runs iterator over provided sorted array elements in series
|
|
12468
|
+
*
|
|
12469
|
+
* @param {array|object} list - array or object (named list) to iterate over
|
|
12470
|
+
* @param {function} iterator - iterator to run
|
|
12471
|
+
* @param {function} sortMethod - custom sort function
|
|
12472
|
+
* @param {function} callback - invoked when all elements processed
|
|
12473
|
+
* @returns {function} - jobs terminator
|
|
12474
|
+
*/
|
|
12475
|
+
function serialOrdered$1(list, iterator, sortMethod, callback)
|
|
12476
|
+
{
|
|
12477
|
+
var state = initState(list, sortMethod);
|
|
12478
|
+
|
|
12479
|
+
iterate(list, iterator, state, function iteratorHandler(error, result)
|
|
12480
|
+
{
|
|
12481
|
+
if (error)
|
|
12482
|
+
{
|
|
12483
|
+
callback(error, result);
|
|
12484
|
+
return;
|
|
12485
|
+
}
|
|
12350
12486
|
|
|
12351
|
-
|
|
12352
|
-
}
|
|
12487
|
+
state.index++;
|
|
12353
12488
|
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
|
|
12489
|
+
// are we there yet?
|
|
12490
|
+
if (state.index < (state['keyedList'] || list).length)
|
|
12491
|
+
{
|
|
12492
|
+
iterate(list, iterator, state, iteratorHandler);
|
|
12493
|
+
return;
|
|
12494
|
+
}
|
|
12357
12495
|
|
|
12358
|
-
//
|
|
12359
|
-
|
|
12496
|
+
// done here
|
|
12497
|
+
callback(null, state.results);
|
|
12498
|
+
});
|
|
12360
12499
|
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
*
|
|
12364
|
-
* @this AsyncKitState#
|
|
12365
|
-
* @param {function} callback - final callback to invoke after termination
|
|
12366
|
-
*/
|
|
12367
|
-
function terminator$2(callback)
|
|
12368
|
-
{
|
|
12369
|
-
if (!Object.keys(this.jobs).length)
|
|
12370
|
-
{
|
|
12371
|
-
return;
|
|
12372
|
-
}
|
|
12500
|
+
return terminator.bind(state, callback);
|
|
12501
|
+
}
|
|
12373
12502
|
|
|
12374
|
-
|
|
12375
|
-
|
|
12503
|
+
/*
|
|
12504
|
+
* -- Sort methods
|
|
12505
|
+
*/
|
|
12376
12506
|
|
|
12377
|
-
|
|
12378
|
-
|
|
12507
|
+
/**
|
|
12508
|
+
* sort helper to sort array elements in ascending order
|
|
12509
|
+
*
|
|
12510
|
+
* @param {mixed} a - an item to compare
|
|
12511
|
+
* @param {mixed} b - an item to compare
|
|
12512
|
+
* @returns {number} - comparison result
|
|
12513
|
+
*/
|
|
12514
|
+
function ascending(a, b)
|
|
12515
|
+
{
|
|
12516
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
12517
|
+
}
|
|
12379
12518
|
|
|
12380
|
-
|
|
12381
|
-
|
|
12519
|
+
/**
|
|
12520
|
+
* sort helper to sort array elements in descending order
|
|
12521
|
+
*
|
|
12522
|
+
* @param {mixed} a - an item to compare
|
|
12523
|
+
* @param {mixed} b - an item to compare
|
|
12524
|
+
* @returns {number} - comparison result
|
|
12525
|
+
*/
|
|
12526
|
+
function descending(a, b)
|
|
12527
|
+
{
|
|
12528
|
+
return -1 * ascending(a, b);
|
|
12529
|
+
}
|
|
12530
|
+
return serialOrdered.exports;
|
|
12382
12531
|
}
|
|
12383
12532
|
|
|
12384
|
-
var
|
|
12385
|
-
|
|
12386
|
-
, terminator$1 = terminator_1
|
|
12387
|
-
;
|
|
12388
|
-
|
|
12389
|
-
// Public API
|
|
12390
|
-
var parallel_1 = parallel;
|
|
12391
|
-
|
|
12392
|
-
/**
|
|
12393
|
-
* Runs iterator over provided array elements in parallel
|
|
12394
|
-
*
|
|
12395
|
-
* @param {array|object} list - array or object (named list) to iterate over
|
|
12396
|
-
* @param {function} iterator - iterator to run
|
|
12397
|
-
* @param {function} callback - invoked when all elements processed
|
|
12398
|
-
* @returns {function} - jobs terminator
|
|
12399
|
-
*/
|
|
12400
|
-
function parallel(list, iterator, callback)
|
|
12401
|
-
{
|
|
12402
|
-
var state = initState$1(list);
|
|
12403
|
-
|
|
12404
|
-
while (state.index < (state['keyedList'] || list).length)
|
|
12405
|
-
{
|
|
12406
|
-
iterate$1(list, iterator, state, function(error, result)
|
|
12407
|
-
{
|
|
12408
|
-
if (error)
|
|
12409
|
-
{
|
|
12410
|
-
callback(error, result);
|
|
12411
|
-
return;
|
|
12412
|
-
}
|
|
12533
|
+
var serial_1;
|
|
12534
|
+
var hasRequiredSerial;
|
|
12413
12535
|
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
return;
|
|
12419
|
-
}
|
|
12420
|
-
});
|
|
12536
|
+
function requireSerial () {
|
|
12537
|
+
if (hasRequiredSerial) return serial_1;
|
|
12538
|
+
hasRequiredSerial = 1;
|
|
12539
|
+
var serialOrdered = requireSerialOrdered();
|
|
12421
12540
|
|
|
12422
|
-
|
|
12423
|
-
|
|
12541
|
+
// Public API
|
|
12542
|
+
serial_1 = serial;
|
|
12424
12543
|
|
|
12425
|
-
|
|
12544
|
+
/**
|
|
12545
|
+
* Runs iterator over provided array elements in series
|
|
12546
|
+
*
|
|
12547
|
+
* @param {array|object} list - array or object (named list) to iterate over
|
|
12548
|
+
* @param {function} iterator - iterator to run
|
|
12549
|
+
* @param {function} callback - invoked when all elements processed
|
|
12550
|
+
* @returns {function} - jobs terminator
|
|
12551
|
+
*/
|
|
12552
|
+
function serial(list, iterator, callback)
|
|
12553
|
+
{
|
|
12554
|
+
return serialOrdered(list, iterator, null, callback);
|
|
12555
|
+
}
|
|
12556
|
+
return serial_1;
|
|
12426
12557
|
}
|
|
12427
12558
|
|
|
12428
|
-
var
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
serialOrdered
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
* Runs iterator over provided sorted array elements in series
|
|
12443
|
-
*
|
|
12444
|
-
* @param {array|object} list - array or object (named list) to iterate over
|
|
12445
|
-
* @param {function} iterator - iterator to run
|
|
12446
|
-
* @param {function} sortMethod - custom sort function
|
|
12447
|
-
* @param {function} callback - invoked when all elements processed
|
|
12448
|
-
* @returns {function} - jobs terminator
|
|
12449
|
-
*/
|
|
12450
|
-
function serialOrdered$1(list, iterator, sortMethod, callback)
|
|
12451
|
-
{
|
|
12452
|
-
var state = initState(list, sortMethod);
|
|
12453
|
-
|
|
12454
|
-
iterate(list, iterator, state, function iteratorHandler(error, result)
|
|
12455
|
-
{
|
|
12456
|
-
if (error)
|
|
12457
|
-
{
|
|
12458
|
-
callback(error, result);
|
|
12459
|
-
return;
|
|
12460
|
-
}
|
|
12559
|
+
var asynckit;
|
|
12560
|
+
var hasRequiredAsynckit;
|
|
12561
|
+
|
|
12562
|
+
function requireAsynckit () {
|
|
12563
|
+
if (hasRequiredAsynckit) return asynckit;
|
|
12564
|
+
hasRequiredAsynckit = 1;
|
|
12565
|
+
asynckit =
|
|
12566
|
+
{
|
|
12567
|
+
parallel : requireParallel(),
|
|
12568
|
+
serial : requireSerial(),
|
|
12569
|
+
serialOrdered : requireSerialOrdered()
|
|
12570
|
+
};
|
|
12571
|
+
return asynckit;
|
|
12572
|
+
}
|
|
12461
12573
|
|
|
12462
|
-
|
|
12574
|
+
var populate;
|
|
12575
|
+
var hasRequiredPopulate;
|
|
12463
12576
|
|
|
12464
|
-
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
|
|
12468
|
-
|
|
12469
|
-
}
|
|
12577
|
+
function requirePopulate () {
|
|
12578
|
+
if (hasRequiredPopulate) return populate;
|
|
12579
|
+
hasRequiredPopulate = 1;
|
|
12580
|
+
// populates missing values
|
|
12581
|
+
populate = function(dst, src) {
|
|
12470
12582
|
|
|
12471
|
-
|
|
12472
|
-
|
|
12473
|
-
|
|
12583
|
+
Object.keys(src).forEach(function(prop)
|
|
12584
|
+
{
|
|
12585
|
+
dst[prop] = dst[prop] || src[prop];
|
|
12586
|
+
});
|
|
12474
12587
|
|
|
12475
|
-
|
|
12588
|
+
return dst;
|
|
12589
|
+
};
|
|
12590
|
+
return populate;
|
|
12476
12591
|
}
|
|
12477
12592
|
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12593
|
+
var form_data;
|
|
12594
|
+
var hasRequiredForm_data;
|
|
12595
|
+
|
|
12596
|
+
function requireForm_data () {
|
|
12597
|
+
if (hasRequiredForm_data) return form_data;
|
|
12598
|
+
hasRequiredForm_data = 1;
|
|
12599
|
+
var CombinedStream = requireCombined_stream();
|
|
12600
|
+
var util = require$$1;
|
|
12601
|
+
var path = require$$1$1;
|
|
12602
|
+
var http = require$$3;
|
|
12603
|
+
var https = require$$4;
|
|
12604
|
+
var parseUrl = require$$5.parse;
|
|
12605
|
+
var fs = require$$6;
|
|
12606
|
+
var Stream = require$$0$1.Stream;
|
|
12607
|
+
var mime = requireMimeTypes();
|
|
12608
|
+
var asynckit = requireAsynckit();
|
|
12609
|
+
var populate = requirePopulate();
|
|
12610
|
+
|
|
12611
|
+
// Public API
|
|
12612
|
+
form_data = FormData;
|
|
12613
|
+
|
|
12614
|
+
// make it a Stream
|
|
12615
|
+
util.inherits(FormData, CombinedStream);
|
|
12481
12616
|
|
|
12482
|
-
/**
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
{
|
|
12491
|
-
|
|
12492
|
-
|
|
12617
|
+
/**
|
|
12618
|
+
* Create readable "multipart/form-data" streams.
|
|
12619
|
+
* Can be used to submit forms
|
|
12620
|
+
* and file uploads to other web applications.
|
|
12621
|
+
*
|
|
12622
|
+
* @constructor
|
|
12623
|
+
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
|
12624
|
+
*/
|
|
12625
|
+
function FormData(options) {
|
|
12626
|
+
if (!(this instanceof FormData)) {
|
|
12627
|
+
return new FormData(options);
|
|
12628
|
+
}
|
|
12493
12629
|
|
|
12494
|
-
|
|
12495
|
-
|
|
12496
|
-
|
|
12497
|
-
* @param {mixed} a - an item to compare
|
|
12498
|
-
* @param {mixed} b - an item to compare
|
|
12499
|
-
* @returns {number} - comparison result
|
|
12500
|
-
*/
|
|
12501
|
-
function descending(a, b)
|
|
12502
|
-
{
|
|
12503
|
-
return -1 * ascending(a, b);
|
|
12504
|
-
}
|
|
12630
|
+
this._overheadLength = 0;
|
|
12631
|
+
this._valueLength = 0;
|
|
12632
|
+
this._valuesToMeasure = [];
|
|
12505
12633
|
|
|
12506
|
-
|
|
12634
|
+
CombinedStream.call(this);
|
|
12507
12635
|
|
|
12508
|
-
|
|
12636
|
+
options = options || {};
|
|
12637
|
+
for (var option in options) {
|
|
12638
|
+
this[option] = options[option];
|
|
12639
|
+
}
|
|
12640
|
+
}
|
|
12509
12641
|
|
|
12510
|
-
|
|
12511
|
-
|
|
12642
|
+
FormData.LINE_BREAK = '\r\n';
|
|
12643
|
+
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
|
|
12512
12644
|
|
|
12513
|
-
|
|
12514
|
-
* Runs iterator over provided array elements in series
|
|
12515
|
-
*
|
|
12516
|
-
* @param {array|object} list - array or object (named list) to iterate over
|
|
12517
|
-
* @param {function} iterator - iterator to run
|
|
12518
|
-
* @param {function} callback - invoked when all elements processed
|
|
12519
|
-
* @returns {function} - jobs terminator
|
|
12520
|
-
*/
|
|
12521
|
-
function serial(list, iterator, callback)
|
|
12522
|
-
{
|
|
12523
|
-
return serialOrdered(list, iterator, null, callback);
|
|
12524
|
-
}
|
|
12645
|
+
FormData.prototype.append = function(field, value, options) {
|
|
12525
12646
|
|
|
12526
|
-
|
|
12527
|
-
{
|
|
12528
|
-
parallel : parallel_1,
|
|
12529
|
-
serial : serial_1,
|
|
12530
|
-
serialOrdered : serialOrderedExports
|
|
12531
|
-
};
|
|
12647
|
+
options = options || {};
|
|
12532
12648
|
|
|
12533
|
-
//
|
|
12534
|
-
|
|
12649
|
+
// allow filename as single option
|
|
12650
|
+
if (typeof options == 'string') {
|
|
12651
|
+
options = {filename: options};
|
|
12652
|
+
}
|
|
12535
12653
|
|
|
12536
|
-
|
|
12537
|
-
{
|
|
12538
|
-
dst[prop] = dst[prop] || src[prop];
|
|
12539
|
-
});
|
|
12654
|
+
var append = CombinedStream.prototype.append.bind(this);
|
|
12540
12655
|
|
|
12541
|
-
|
|
12542
|
-
|
|
12656
|
+
// all that streamy business can't handle numbers
|
|
12657
|
+
if (typeof value == 'number') {
|
|
12658
|
+
value = '' + value;
|
|
12659
|
+
}
|
|
12543
12660
|
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12549
|
-
|
|
12550
|
-
|
|
12551
|
-
var Stream = require$$0$1.Stream;
|
|
12552
|
-
var mime = mimeTypes;
|
|
12553
|
-
var asynckit = asynckit$1;
|
|
12554
|
-
var populate = populate$1;
|
|
12555
|
-
|
|
12556
|
-
// Public API
|
|
12557
|
-
var form_data = FormData;
|
|
12558
|
-
|
|
12559
|
-
// make it a Stream
|
|
12560
|
-
util.inherits(FormData, CombinedStream);
|
|
12561
|
-
|
|
12562
|
-
/**
|
|
12563
|
-
* Create readable "multipart/form-data" streams.
|
|
12564
|
-
* Can be used to submit forms
|
|
12565
|
-
* and file uploads to other web applications.
|
|
12566
|
-
*
|
|
12567
|
-
* @constructor
|
|
12568
|
-
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
|
12569
|
-
*/
|
|
12570
|
-
function FormData(options) {
|
|
12571
|
-
if (!(this instanceof FormData)) {
|
|
12572
|
-
return new FormData(options);
|
|
12573
|
-
}
|
|
12661
|
+
// https://github.com/felixge/node-form-data/issues/38
|
|
12662
|
+
if (Array.isArray(value)) {
|
|
12663
|
+
// Please convert your array into string
|
|
12664
|
+
// the way web server expects it
|
|
12665
|
+
this._error(new Error('Arrays are not supported.'));
|
|
12666
|
+
return;
|
|
12667
|
+
}
|
|
12574
12668
|
|
|
12575
|
-
|
|
12576
|
-
|
|
12577
|
-
|
|
12669
|
+
var header = this._multiPartHeader(field, value, options);
|
|
12670
|
+
var footer = this._multiPartFooter();
|
|
12671
|
+
|
|
12672
|
+
append(header);
|
|
12673
|
+
append(value);
|
|
12674
|
+
append(footer);
|
|
12675
|
+
|
|
12676
|
+
// pass along options.knownLength
|
|
12677
|
+
this._trackLength(header, value, options);
|
|
12678
|
+
};
|
|
12679
|
+
|
|
12680
|
+
FormData.prototype._trackLength = function(header, value, options) {
|
|
12681
|
+
var valueLength = 0;
|
|
12682
|
+
|
|
12683
|
+
// used w/ getLengthSync(), when length is known.
|
|
12684
|
+
// e.g. for streaming directly from a remote server,
|
|
12685
|
+
// w/ a known file a size, and not wanting to wait for
|
|
12686
|
+
// incoming file to finish to get its size.
|
|
12687
|
+
if (options.knownLength != null) {
|
|
12688
|
+
valueLength += +options.knownLength;
|
|
12689
|
+
} else if (Buffer.isBuffer(value)) {
|
|
12690
|
+
valueLength = value.length;
|
|
12691
|
+
} else if (typeof value === 'string') {
|
|
12692
|
+
valueLength = Buffer.byteLength(value);
|
|
12693
|
+
}
|
|
12578
12694
|
|
|
12579
|
-
|
|
12695
|
+
this._valueLength += valueLength;
|
|
12580
12696
|
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12584
|
-
|
|
12585
|
-
}
|
|
12697
|
+
// @check why add CRLF? does this account for custom/multiple CRLFs?
|
|
12698
|
+
this._overheadLength +=
|
|
12699
|
+
Buffer.byteLength(header) +
|
|
12700
|
+
FormData.LINE_BREAK.length;
|
|
12586
12701
|
|
|
12587
|
-
|
|
12588
|
-
|
|
12702
|
+
// empty or either doesn't have path or not an http response or not a stream
|
|
12703
|
+
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) {
|
|
12704
|
+
return;
|
|
12705
|
+
}
|
|
12589
12706
|
|
|
12590
|
-
|
|
12707
|
+
// no need to bother with the length
|
|
12708
|
+
if (!options.knownLength) {
|
|
12709
|
+
this._valuesToMeasure.push(value);
|
|
12710
|
+
}
|
|
12711
|
+
};
|
|
12591
12712
|
|
|
12592
|
-
|
|
12713
|
+
FormData.prototype._lengthRetriever = function(value, callback) {
|
|
12593
12714
|
|
|
12594
|
-
|
|
12595
|
-
if (typeof options == 'string') {
|
|
12596
|
-
options = {filename: options};
|
|
12597
|
-
}
|
|
12715
|
+
if (value.hasOwnProperty('fd')) {
|
|
12598
12716
|
|
|
12599
|
-
|
|
12717
|
+
// take read range into a account
|
|
12718
|
+
// `end` = Infinity –> read file till the end
|
|
12719
|
+
//
|
|
12720
|
+
// TODO: Looks like there is bug in Node fs.createReadStream
|
|
12721
|
+
// it doesn't respect `end` options without `start` options
|
|
12722
|
+
// Fix it when node fixes it.
|
|
12723
|
+
// https://github.com/joyent/node/issues/7819
|
|
12724
|
+
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
|
12600
12725
|
|
|
12601
|
-
|
|
12602
|
-
|
|
12603
|
-
|
|
12604
|
-
|
|
12726
|
+
// when end specified
|
|
12727
|
+
// no need to calculate range
|
|
12728
|
+
// inclusive, starts with 0
|
|
12729
|
+
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
|
12605
12730
|
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12610
|
-
this._error(new Error('Arrays are not supported.'));
|
|
12611
|
-
return;
|
|
12612
|
-
}
|
|
12731
|
+
// not that fast snoopy
|
|
12732
|
+
} else {
|
|
12733
|
+
// still need to fetch file size from fs
|
|
12734
|
+
fs.stat(value.path, function(err, stat) {
|
|
12613
12735
|
|
|
12614
|
-
|
|
12615
|
-
var footer = this._multiPartFooter();
|
|
12736
|
+
var fileSize;
|
|
12616
12737
|
|
|
12617
|
-
|
|
12618
|
-
|
|
12619
|
-
|
|
12738
|
+
if (err) {
|
|
12739
|
+
callback(err);
|
|
12740
|
+
return;
|
|
12741
|
+
}
|
|
12620
12742
|
|
|
12621
|
-
|
|
12622
|
-
|
|
12623
|
-
|
|
12743
|
+
// update final size based on the range options
|
|
12744
|
+
fileSize = stat.size - (value.start ? value.start : 0);
|
|
12745
|
+
callback(null, fileSize);
|
|
12746
|
+
});
|
|
12747
|
+
}
|
|
12624
12748
|
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
|
|
12628
|
-
|
|
12629
|
-
|
|
12630
|
-
|
|
12631
|
-
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12641
|
-
|
|
12642
|
-
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12749
|
+
// or http response
|
|
12750
|
+
} else if (value.hasOwnProperty('httpVersion')) {
|
|
12751
|
+
callback(null, +value.headers['content-length']);
|
|
12752
|
+
|
|
12753
|
+
// or request stream http://github.com/mikeal/request
|
|
12754
|
+
} else if (value.hasOwnProperty('httpModule')) {
|
|
12755
|
+
// wait till response come back
|
|
12756
|
+
value.on('response', function(response) {
|
|
12757
|
+
value.pause();
|
|
12758
|
+
callback(null, +response.headers['content-length']);
|
|
12759
|
+
});
|
|
12760
|
+
value.resume();
|
|
12761
|
+
|
|
12762
|
+
// something else
|
|
12763
|
+
} else {
|
|
12764
|
+
callback('Unknown stream');
|
|
12765
|
+
}
|
|
12766
|
+
};
|
|
12767
|
+
|
|
12768
|
+
FormData.prototype._multiPartHeader = function(field, value, options) {
|
|
12769
|
+
// custom header specified (as string)?
|
|
12770
|
+
// it becomes responsible for boundary
|
|
12771
|
+
// (e.g. to handle extra CRLFs on .NET servers)
|
|
12772
|
+
if (typeof options.header == 'string') {
|
|
12773
|
+
return options.header;
|
|
12774
|
+
}
|
|
12651
12775
|
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
this._valuesToMeasure.push(value);
|
|
12655
|
-
}
|
|
12656
|
-
};
|
|
12776
|
+
var contentDisposition = this._getContentDisposition(value, options);
|
|
12777
|
+
var contentType = this._getContentType(value, options);
|
|
12657
12778
|
|
|
12658
|
-
|
|
12779
|
+
var contents = '';
|
|
12780
|
+
var headers = {
|
|
12781
|
+
// add custom disposition as third element or keep it two elements if not
|
|
12782
|
+
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
|
12783
|
+
// if no content type. allow it to be empty array
|
|
12784
|
+
'Content-Type': [].concat(contentType || [])
|
|
12785
|
+
};
|
|
12659
12786
|
|
|
12660
|
-
|
|
12787
|
+
// allow custom headers.
|
|
12788
|
+
if (typeof options.header == 'object') {
|
|
12789
|
+
populate(headers, options.header);
|
|
12790
|
+
}
|
|
12661
12791
|
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
// it doesn't respect `end` options without `start` options
|
|
12667
|
-
// Fix it when node fixes it.
|
|
12668
|
-
// https://github.com/joyent/node/issues/7819
|
|
12669
|
-
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
|
12792
|
+
var header;
|
|
12793
|
+
for (var prop in headers) {
|
|
12794
|
+
if (!headers.hasOwnProperty(prop)) continue;
|
|
12795
|
+
header = headers[prop];
|
|
12670
12796
|
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12797
|
+
// skip nullish headers.
|
|
12798
|
+
if (header == null) {
|
|
12799
|
+
continue;
|
|
12800
|
+
}
|
|
12675
12801
|
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12802
|
+
// convert all headers to arrays.
|
|
12803
|
+
if (!Array.isArray(header)) {
|
|
12804
|
+
header = [header];
|
|
12805
|
+
}
|
|
12680
12806
|
|
|
12681
|
-
|
|
12807
|
+
// add non-empty headers.
|
|
12808
|
+
if (header.length) {
|
|
12809
|
+
contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK;
|
|
12810
|
+
}
|
|
12811
|
+
}
|
|
12682
12812
|
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12813
|
+
return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
|
|
12814
|
+
};
|
|
12815
|
+
|
|
12816
|
+
FormData.prototype._getContentDisposition = function(value, options) {
|
|
12817
|
+
|
|
12818
|
+
var filename
|
|
12819
|
+
, contentDisposition
|
|
12820
|
+
;
|
|
12821
|
+
|
|
12822
|
+
if (typeof options.filepath === 'string') {
|
|
12823
|
+
// custom filepath for relative paths
|
|
12824
|
+
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
|
12825
|
+
} else if (options.filename || value.name || value.path) {
|
|
12826
|
+
// custom filename take precedence
|
|
12827
|
+
// formidable and the browser add a name property
|
|
12828
|
+
// fs- and request- streams have path property
|
|
12829
|
+
filename = path.basename(options.filename || value.name || value.path);
|
|
12830
|
+
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
|
12831
|
+
// or try http response
|
|
12832
|
+
filename = path.basename(value.client._httpMessage.path || '');
|
|
12833
|
+
}
|
|
12687
12834
|
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
});
|
|
12692
|
-
}
|
|
12835
|
+
if (filename) {
|
|
12836
|
+
contentDisposition = 'filename="' + filename + '"';
|
|
12837
|
+
}
|
|
12693
12838
|
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
callback(null, +value.headers['content-length']);
|
|
12839
|
+
return contentDisposition;
|
|
12840
|
+
};
|
|
12697
12841
|
|
|
12698
|
-
|
|
12699
|
-
} else if (value.hasOwnProperty('httpModule')) {
|
|
12700
|
-
// wait till response come back
|
|
12701
|
-
value.on('response', function(response) {
|
|
12702
|
-
value.pause();
|
|
12703
|
-
callback(null, +response.headers['content-length']);
|
|
12704
|
-
});
|
|
12705
|
-
value.resume();
|
|
12842
|
+
FormData.prototype._getContentType = function(value, options) {
|
|
12706
12843
|
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
|
-
callback('Unknown stream');
|
|
12710
|
-
}
|
|
12711
|
-
};
|
|
12844
|
+
// use custom content-type above all
|
|
12845
|
+
var contentType = options.contentType;
|
|
12712
12846
|
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
if (typeof options.header == 'string') {
|
|
12718
|
-
return options.header;
|
|
12719
|
-
}
|
|
12720
|
-
|
|
12721
|
-
var contentDisposition = this._getContentDisposition(value, options);
|
|
12722
|
-
var contentType = this._getContentType(value, options);
|
|
12723
|
-
|
|
12724
|
-
var contents = '';
|
|
12725
|
-
var headers = {
|
|
12726
|
-
// add custom disposition as third element or keep it two elements if not
|
|
12727
|
-
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
|
12728
|
-
// if no content type. allow it to be empty array
|
|
12729
|
-
'Content-Type': [].concat(contentType || [])
|
|
12730
|
-
};
|
|
12731
|
-
|
|
12732
|
-
// allow custom headers.
|
|
12733
|
-
if (typeof options.header == 'object') {
|
|
12734
|
-
populate(headers, options.header);
|
|
12735
|
-
}
|
|
12736
|
-
|
|
12737
|
-
var header;
|
|
12738
|
-
for (var prop in headers) {
|
|
12739
|
-
if (!headers.hasOwnProperty(prop)) continue;
|
|
12740
|
-
header = headers[prop];
|
|
12741
|
-
|
|
12742
|
-
// skip nullish headers.
|
|
12743
|
-
if (header == null) {
|
|
12744
|
-
continue;
|
|
12745
|
-
}
|
|
12847
|
+
// or try `name` from formidable, browser
|
|
12848
|
+
if (!contentType && value.name) {
|
|
12849
|
+
contentType = mime.lookup(value.name);
|
|
12850
|
+
}
|
|
12746
12851
|
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12852
|
+
// or try `path` from fs-, request- streams
|
|
12853
|
+
if (!contentType && value.path) {
|
|
12854
|
+
contentType = mime.lookup(value.path);
|
|
12855
|
+
}
|
|
12751
12856
|
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
}
|
|
12857
|
+
// or if it's http-reponse
|
|
12858
|
+
if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) {
|
|
12859
|
+
contentType = value.headers['content-type'];
|
|
12860
|
+
}
|
|
12757
12861
|
|
|
12758
|
-
|
|
12759
|
-
|
|
12862
|
+
// or guess it from the filepath or filename
|
|
12863
|
+
if (!contentType && (options.filepath || options.filename)) {
|
|
12864
|
+
contentType = mime.lookup(options.filepath || options.filename);
|
|
12865
|
+
}
|
|
12760
12866
|
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
;
|
|
12766
|
-
|
|
12767
|
-
if (typeof options.filepath === 'string') {
|
|
12768
|
-
// custom filepath for relative paths
|
|
12769
|
-
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
|
12770
|
-
} else if (options.filename || value.name || value.path) {
|
|
12771
|
-
// custom filename take precedence
|
|
12772
|
-
// formidable and the browser add a name property
|
|
12773
|
-
// fs- and request- streams have path property
|
|
12774
|
-
filename = path.basename(options.filename || value.name || value.path);
|
|
12775
|
-
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
|
12776
|
-
// or try http response
|
|
12777
|
-
filename = path.basename(value.client._httpMessage.path || '');
|
|
12778
|
-
}
|
|
12779
|
-
|
|
12780
|
-
if (filename) {
|
|
12781
|
-
contentDisposition = 'filename="' + filename + '"';
|
|
12782
|
-
}
|
|
12783
|
-
|
|
12784
|
-
return contentDisposition;
|
|
12785
|
-
};
|
|
12867
|
+
// fallback to the default content type if `value` is not simple value
|
|
12868
|
+
if (!contentType && typeof value == 'object') {
|
|
12869
|
+
contentType = FormData.DEFAULT_CONTENT_TYPE;
|
|
12870
|
+
}
|
|
12786
12871
|
|
|
12787
|
-
|
|
12872
|
+
return contentType;
|
|
12873
|
+
};
|
|
12788
12874
|
|
|
12789
|
-
|
|
12790
|
-
|
|
12875
|
+
FormData.prototype._multiPartFooter = function() {
|
|
12876
|
+
return function(next) {
|
|
12877
|
+
var footer = FormData.LINE_BREAK;
|
|
12791
12878
|
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12879
|
+
var lastPart = (this._streams.length === 0);
|
|
12880
|
+
if (lastPart) {
|
|
12881
|
+
footer += this._lastBoundary();
|
|
12882
|
+
}
|
|
12796
12883
|
|
|
12797
|
-
|
|
12798
|
-
|
|
12799
|
-
|
|
12800
|
-
}
|
|
12884
|
+
next(footer);
|
|
12885
|
+
}.bind(this);
|
|
12886
|
+
};
|
|
12801
12887
|
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
}
|
|
12888
|
+
FormData.prototype._lastBoundary = function() {
|
|
12889
|
+
return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
|
|
12890
|
+
};
|
|
12806
12891
|
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12892
|
+
FormData.prototype.getHeaders = function(userHeaders) {
|
|
12893
|
+
var header;
|
|
12894
|
+
var formHeaders = {
|
|
12895
|
+
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
|
12896
|
+
};
|
|
12811
12897
|
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12898
|
+
for (header in userHeaders) {
|
|
12899
|
+
if (userHeaders.hasOwnProperty(header)) {
|
|
12900
|
+
formHeaders[header.toLowerCase()] = userHeaders[header];
|
|
12901
|
+
}
|
|
12902
|
+
}
|
|
12816
12903
|
|
|
12817
|
-
|
|
12818
|
-
};
|
|
12904
|
+
return formHeaders;
|
|
12905
|
+
};
|
|
12819
12906
|
|
|
12820
|
-
FormData.prototype.
|
|
12821
|
-
|
|
12822
|
-
|
|
12907
|
+
FormData.prototype.setBoundary = function(boundary) {
|
|
12908
|
+
this._boundary = boundary;
|
|
12909
|
+
};
|
|
12823
12910
|
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12911
|
+
FormData.prototype.getBoundary = function() {
|
|
12912
|
+
if (!this._boundary) {
|
|
12913
|
+
this._generateBoundary();
|
|
12914
|
+
}
|
|
12828
12915
|
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
};
|
|
12916
|
+
return this._boundary;
|
|
12917
|
+
};
|
|
12832
12918
|
|
|
12833
|
-
FormData.prototype.
|
|
12834
|
-
|
|
12835
|
-
|
|
12919
|
+
FormData.prototype.getBuffer = function() {
|
|
12920
|
+
var dataBuffer = new Buffer.alloc( 0 );
|
|
12921
|
+
var boundary = this.getBoundary();
|
|
12836
12922
|
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
|
12841
|
-
};
|
|
12923
|
+
// Create the form content. Add Line breaks to the end of data.
|
|
12924
|
+
for (var i = 0, len = this._streams.length; i < len; i++) {
|
|
12925
|
+
if (typeof this._streams[i] !== 'function') {
|
|
12842
12926
|
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12927
|
+
// Add content to the buffer.
|
|
12928
|
+
if(Buffer.isBuffer(this._streams[i])) {
|
|
12929
|
+
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
|
12930
|
+
}else {
|
|
12931
|
+
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
|
12932
|
+
}
|
|
12848
12933
|
|
|
12849
|
-
|
|
12850
|
-
|
|
12934
|
+
// Add break after content.
|
|
12935
|
+
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
|
12936
|
+
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
|
12937
|
+
}
|
|
12938
|
+
}
|
|
12939
|
+
}
|
|
12851
12940
|
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
};
|
|
12941
|
+
// Add the footer and return the Buffer object.
|
|
12942
|
+
return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
|
|
12943
|
+
};
|
|
12855
12944
|
|
|
12856
|
-
FormData.prototype.
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12945
|
+
FormData.prototype._generateBoundary = function() {
|
|
12946
|
+
// This generates a 50 character boundary similar to those used by Firefox.
|
|
12947
|
+
// They are optimized for boyer-moore parsing.
|
|
12948
|
+
var boundary = '--------------------------';
|
|
12949
|
+
for (var i = 0; i < 24; i++) {
|
|
12950
|
+
boundary += Math.floor(Math.random() * 10).toString(16);
|
|
12951
|
+
}
|
|
12860
12952
|
|
|
12861
|
-
|
|
12862
|
-
};
|
|
12953
|
+
this._boundary = boundary;
|
|
12954
|
+
};
|
|
12863
12955
|
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
for (var i = 0, len = this._streams.length; i < len; i++) {
|
|
12870
|
-
if (typeof this._streams[i] !== 'function') {
|
|
12871
|
-
|
|
12872
|
-
// Add content to the buffer.
|
|
12873
|
-
if(Buffer.isBuffer(this._streams[i])) {
|
|
12874
|
-
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
|
12875
|
-
}else {
|
|
12876
|
-
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
|
12877
|
-
}
|
|
12878
|
-
|
|
12879
|
-
// Add break after content.
|
|
12880
|
-
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
|
12881
|
-
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
|
12882
|
-
}
|
|
12883
|
-
}
|
|
12884
|
-
}
|
|
12956
|
+
// Note: getLengthSync DOESN'T calculate streams length
|
|
12957
|
+
// As workaround one can calculate file size manually
|
|
12958
|
+
// and add it as knownLength option
|
|
12959
|
+
FormData.prototype.getLengthSync = function() {
|
|
12960
|
+
var knownLength = this._overheadLength + this._valueLength;
|
|
12885
12961
|
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12962
|
+
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
|
12963
|
+
// so it basically checks if there is any value added to the form
|
|
12964
|
+
if (this._streams.length) {
|
|
12965
|
+
knownLength += this._lastBoundary().length;
|
|
12966
|
+
}
|
|
12889
12967
|
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12968
|
+
// https://github.com/form-data/form-data/issues/40
|
|
12969
|
+
if (!this.hasKnownLength()) {
|
|
12970
|
+
// Some async length retrievers are present
|
|
12971
|
+
// therefore synchronous length calculation is false.
|
|
12972
|
+
// Please use getLength(callback) to get proper length
|
|
12973
|
+
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
|
12974
|
+
}
|
|
12897
12975
|
|
|
12898
|
-
|
|
12899
|
-
};
|
|
12976
|
+
return knownLength;
|
|
12977
|
+
};
|
|
12900
12978
|
|
|
12901
|
-
//
|
|
12902
|
-
//
|
|
12903
|
-
//
|
|
12904
|
-
FormData.prototype.
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
|
12908
|
-
// so it basically checks if there is any value added to the form
|
|
12909
|
-
if (this._streams.length) {
|
|
12910
|
-
knownLength += this._lastBoundary().length;
|
|
12911
|
-
}
|
|
12912
|
-
|
|
12913
|
-
// https://github.com/form-data/form-data/issues/40
|
|
12914
|
-
if (!this.hasKnownLength()) {
|
|
12915
|
-
// Some async length retrievers are present
|
|
12916
|
-
// therefore synchronous length calculation is false.
|
|
12917
|
-
// Please use getLength(callback) to get proper length
|
|
12918
|
-
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
|
12919
|
-
}
|
|
12920
|
-
|
|
12921
|
-
return knownLength;
|
|
12922
|
-
};
|
|
12979
|
+
// Public API to check if length of added values is known
|
|
12980
|
+
// https://github.com/form-data/form-data/issues/196
|
|
12981
|
+
// https://github.com/form-data/form-data/issues/262
|
|
12982
|
+
FormData.prototype.hasKnownLength = function() {
|
|
12983
|
+
var hasKnownLength = true;
|
|
12923
12984
|
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
FormData.prototype.hasKnownLength = function() {
|
|
12928
|
-
var hasKnownLength = true;
|
|
12985
|
+
if (this._valuesToMeasure.length) {
|
|
12986
|
+
hasKnownLength = false;
|
|
12987
|
+
}
|
|
12929
12988
|
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
}
|
|
12989
|
+
return hasKnownLength;
|
|
12990
|
+
};
|
|
12933
12991
|
|
|
12934
|
-
|
|
12935
|
-
|
|
12992
|
+
FormData.prototype.getLength = function(cb) {
|
|
12993
|
+
var knownLength = this._overheadLength + this._valueLength;
|
|
12936
12994
|
|
|
12937
|
-
|
|
12938
|
-
|
|
12995
|
+
if (this._streams.length) {
|
|
12996
|
+
knownLength += this._lastBoundary().length;
|
|
12997
|
+
}
|
|
12939
12998
|
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12999
|
+
if (!this._valuesToMeasure.length) {
|
|
13000
|
+
process.nextTick(cb.bind(this, null, knownLength));
|
|
13001
|
+
return;
|
|
13002
|
+
}
|
|
12943
13003
|
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
13004
|
+
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
|
|
13005
|
+
if (err) {
|
|
13006
|
+
cb(err);
|
|
13007
|
+
return;
|
|
13008
|
+
}
|
|
12948
13009
|
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
return;
|
|
12953
|
-
}
|
|
13010
|
+
values.forEach(function(length) {
|
|
13011
|
+
knownLength += length;
|
|
13012
|
+
});
|
|
12954
13013
|
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
13014
|
+
cb(null, knownLength);
|
|
13015
|
+
});
|
|
13016
|
+
};
|
|
13017
|
+
|
|
13018
|
+
FormData.prototype.submit = function(params, cb) {
|
|
13019
|
+
var request
|
|
13020
|
+
, options
|
|
13021
|
+
, defaults = {method: 'post'}
|
|
13022
|
+
;
|
|
13023
|
+
|
|
13024
|
+
// parse provided url if it's string
|
|
13025
|
+
// or treat it as options object
|
|
13026
|
+
if (typeof params == 'string') {
|
|
13027
|
+
|
|
13028
|
+
params = parseUrl(params);
|
|
13029
|
+
options = populate({
|
|
13030
|
+
port: params.port,
|
|
13031
|
+
path: params.pathname,
|
|
13032
|
+
host: params.hostname,
|
|
13033
|
+
protocol: params.protocol
|
|
13034
|
+
}, defaults);
|
|
13035
|
+
|
|
13036
|
+
// use custom params
|
|
13037
|
+
} else {
|
|
13038
|
+
|
|
13039
|
+
options = populate(params, defaults);
|
|
13040
|
+
// if no port provided use default one
|
|
13041
|
+
if (!options.port) {
|
|
13042
|
+
options.port = options.protocol == 'https:' ? 443 : 80;
|
|
13043
|
+
}
|
|
13044
|
+
}
|
|
12958
13045
|
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
};
|
|
13046
|
+
// put that good code in getHeaders to some use
|
|
13047
|
+
options.headers = this.getHeaders(params.headers);
|
|
12962
13048
|
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
// parse provided url if it's string
|
|
12970
|
-
// or treat it as options object
|
|
12971
|
-
if (typeof params == 'string') {
|
|
12972
|
-
|
|
12973
|
-
params = parseUrl(params);
|
|
12974
|
-
options = populate({
|
|
12975
|
-
port: params.port,
|
|
12976
|
-
path: params.pathname,
|
|
12977
|
-
host: params.hostname,
|
|
12978
|
-
protocol: params.protocol
|
|
12979
|
-
}, defaults);
|
|
12980
|
-
|
|
12981
|
-
// use custom params
|
|
12982
|
-
} else {
|
|
12983
|
-
|
|
12984
|
-
options = populate(params, defaults);
|
|
12985
|
-
// if no port provided use default one
|
|
12986
|
-
if (!options.port) {
|
|
12987
|
-
options.port = options.protocol == 'https:' ? 443 : 80;
|
|
12988
|
-
}
|
|
12989
|
-
}
|
|
12990
|
-
|
|
12991
|
-
// put that good code in getHeaders to some use
|
|
12992
|
-
options.headers = this.getHeaders(params.headers);
|
|
12993
|
-
|
|
12994
|
-
// https if specified, fallback to http in any other case
|
|
12995
|
-
if (options.protocol == 'https:') {
|
|
12996
|
-
request = https.request(options);
|
|
12997
|
-
} else {
|
|
12998
|
-
request = http.request(options);
|
|
12999
|
-
}
|
|
13000
|
-
|
|
13001
|
-
// get content length and fire away
|
|
13002
|
-
this.getLength(function(err, length) {
|
|
13003
|
-
if (err && err !== 'Unknown stream') {
|
|
13004
|
-
this._error(err);
|
|
13005
|
-
return;
|
|
13006
|
-
}
|
|
13049
|
+
// https if specified, fallback to http in any other case
|
|
13050
|
+
if (options.protocol == 'https:') {
|
|
13051
|
+
request = https.request(options);
|
|
13052
|
+
} else {
|
|
13053
|
+
request = http.request(options);
|
|
13054
|
+
}
|
|
13007
13055
|
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13056
|
+
// get content length and fire away
|
|
13057
|
+
this.getLength(function(err, length) {
|
|
13058
|
+
if (err && err !== 'Unknown stream') {
|
|
13059
|
+
this._error(err);
|
|
13060
|
+
return;
|
|
13061
|
+
}
|
|
13012
13062
|
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13063
|
+
// add content length
|
|
13064
|
+
if (length) {
|
|
13065
|
+
request.setHeader('Content-Length', length);
|
|
13066
|
+
}
|
|
13016
13067
|
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13068
|
+
this.pipe(request);
|
|
13069
|
+
if (cb) {
|
|
13070
|
+
var onResponse;
|
|
13020
13071
|
|
|
13021
|
-
|
|
13022
|
-
|
|
13072
|
+
var callback = function (error, responce) {
|
|
13073
|
+
request.removeListener('error', callback);
|
|
13074
|
+
request.removeListener('response', onResponse);
|
|
13023
13075
|
|
|
13024
|
-
|
|
13076
|
+
return cb.call(this, error, responce);
|
|
13077
|
+
};
|
|
13025
13078
|
|
|
13026
|
-
|
|
13027
|
-
request.on('response', onResponse);
|
|
13028
|
-
}
|
|
13029
|
-
}.bind(this));
|
|
13079
|
+
onResponse = callback.bind(this, null);
|
|
13030
13080
|
|
|
13031
|
-
|
|
13032
|
-
|
|
13081
|
+
request.on('error', callback);
|
|
13082
|
+
request.on('response', onResponse);
|
|
13083
|
+
}
|
|
13084
|
+
}.bind(this));
|
|
13033
13085
|
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
this.error = err;
|
|
13037
|
-
this.pause();
|
|
13038
|
-
this.emit('error', err);
|
|
13039
|
-
}
|
|
13040
|
-
};
|
|
13086
|
+
return request;
|
|
13087
|
+
};
|
|
13041
13088
|
|
|
13042
|
-
FormData.prototype.
|
|
13043
|
-
|
|
13044
|
-
|
|
13089
|
+
FormData.prototype._error = function(err) {
|
|
13090
|
+
if (!this.error) {
|
|
13091
|
+
this.error = err;
|
|
13092
|
+
this.pause();
|
|
13093
|
+
this.emit('error', err);
|
|
13094
|
+
}
|
|
13095
|
+
};
|
|
13096
|
+
|
|
13097
|
+
FormData.prototype.toString = function () {
|
|
13098
|
+
return '[object FormData]';
|
|
13099
|
+
};
|
|
13100
|
+
return form_data;
|
|
13101
|
+
}
|
|
13045
13102
|
|
|
13046
|
-
var
|
|
13103
|
+
var form_dataExports = requireForm_data();
|
|
13104
|
+
var FormDataModule = /*@__PURE__*/getDefaultExportFromCjs(form_dataExports);
|
|
13047
13105
|
|
|
13048
13106
|
const GRANT_TYPE$1 = 'client_credentials';
|
|
13049
13107
|
const castClientOptionsToRequestParams = (clientOptions) => {
|
|
@@ -13462,7 +13520,5 @@ exports.EnumLookupUserType = void 0;
|
|
|
13462
13520
|
EnumLookupUserType["tenant"] = "tenant";
|
|
13463
13521
|
})(exports.EnumLookupUserType || (exports.EnumLookupUserType = {}));
|
|
13464
13522
|
|
|
13465
|
-
exports.DEFAULT_PARAMETER_STORE_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG;
|
|
13466
13523
|
exports.createTokenStore = createTokenStore;
|
|
13467
|
-
exports.parameterStore = parameterStore;
|
|
13468
13524
|
exports.restClient = restClient;
|