@vercel/node 1.13.0 → 1.13.1-canary.2
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/dev-server.js +4 -2
- package/dist/index.d.ts +5 -7
- package/dist/index.js +14 -60
- package/package.json +4 -5
- package/dist/bridge.js +0 -242
- package/dist/example-import.d.ts +0 -1
- package/dist/helpers.d.ts +0 -10
- package/dist/helpers.js +0 -906
- package/dist/launcher.js +0 -199
- package/dist/source-map-support.js +0 -3959
package/dist/helpers.js
DELETED
|
@@ -1,906 +0,0 @@
|
|
|
1
|
-
module.exports =
|
|
2
|
-
/******/ (() => { // webpackBootstrap
|
|
3
|
-
/******/ "use strict";
|
|
4
|
-
/******/ var __webpack_modules__ = ({
|
|
5
|
-
|
|
6
|
-
/***/ 534:
|
|
7
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
8
|
-
|
|
9
|
-
/*!
|
|
10
|
-
* content-type
|
|
11
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
12
|
-
* MIT Licensed
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
|
|
19
|
-
*
|
|
20
|
-
* parameter = token "=" ( token / quoted-string )
|
|
21
|
-
* token = 1*tchar
|
|
22
|
-
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
|
|
23
|
-
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
|
|
24
|
-
* / DIGIT / ALPHA
|
|
25
|
-
* ; any VCHAR, except delimiters
|
|
26
|
-
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
|
|
27
|
-
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
|
|
28
|
-
* obs-text = %x80-FF
|
|
29
|
-
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
30
|
-
*/
|
|
31
|
-
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g
|
|
32
|
-
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/
|
|
33
|
-
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6
|
|
37
|
-
*
|
|
38
|
-
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
|
|
39
|
-
* obs-text = %x80-FF
|
|
40
|
-
*/
|
|
41
|
-
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6
|
|
45
|
-
*/
|
|
46
|
-
var QUOTE_REGEXP = /([\\"])/g
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* RegExp to match type in RFC 7231 sec 3.1.1.1
|
|
50
|
-
*
|
|
51
|
-
* media-type = type "/" subtype
|
|
52
|
-
* type = token
|
|
53
|
-
* subtype = token
|
|
54
|
-
*/
|
|
55
|
-
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Module exports.
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
exports.format = format
|
|
63
|
-
exports.parse = parse
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Format object to media type.
|
|
67
|
-
*
|
|
68
|
-
* @param {object} obj
|
|
69
|
-
* @return {string}
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
function format (obj) {
|
|
74
|
-
if (!obj || typeof obj !== 'object') {
|
|
75
|
-
throw new TypeError('argument obj is required')
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var parameters = obj.parameters
|
|
79
|
-
var type = obj.type
|
|
80
|
-
|
|
81
|
-
if (!type || !TYPE_REGEXP.test(type)) {
|
|
82
|
-
throw new TypeError('invalid type')
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
var string = type
|
|
86
|
-
|
|
87
|
-
// append parameters
|
|
88
|
-
if (parameters && typeof parameters === 'object') {
|
|
89
|
-
var param
|
|
90
|
-
var params = Object.keys(parameters).sort()
|
|
91
|
-
|
|
92
|
-
for (var i = 0; i < params.length; i++) {
|
|
93
|
-
param = params[i]
|
|
94
|
-
|
|
95
|
-
if (!TOKEN_REGEXP.test(param)) {
|
|
96
|
-
throw new TypeError('invalid parameter name')
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
string += '; ' + param + '=' + qstring(parameters[param])
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return string
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Parse media type to object.
|
|
108
|
-
*
|
|
109
|
-
* @param {string|object} string
|
|
110
|
-
* @return {Object}
|
|
111
|
-
* @public
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
|
-
function parse (string) {
|
|
115
|
-
if (!string) {
|
|
116
|
-
throw new TypeError('argument string is required')
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// support req/res-like objects as argument
|
|
120
|
-
var header = typeof string === 'object'
|
|
121
|
-
? getcontenttype(string)
|
|
122
|
-
: string
|
|
123
|
-
|
|
124
|
-
if (typeof header !== 'string') {
|
|
125
|
-
throw new TypeError('argument string is required to be a string')
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
var index = header.indexOf(';')
|
|
129
|
-
var type = index !== -1
|
|
130
|
-
? header.substr(0, index).trim()
|
|
131
|
-
: header.trim()
|
|
132
|
-
|
|
133
|
-
if (!TYPE_REGEXP.test(type)) {
|
|
134
|
-
throw new TypeError('invalid media type')
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
var obj = new ContentType(type.toLowerCase())
|
|
138
|
-
|
|
139
|
-
// parse parameters
|
|
140
|
-
if (index !== -1) {
|
|
141
|
-
var key
|
|
142
|
-
var match
|
|
143
|
-
var value
|
|
144
|
-
|
|
145
|
-
PARAM_REGEXP.lastIndex = index
|
|
146
|
-
|
|
147
|
-
while ((match = PARAM_REGEXP.exec(header))) {
|
|
148
|
-
if (match.index !== index) {
|
|
149
|
-
throw new TypeError('invalid parameter format')
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
index += match[0].length
|
|
153
|
-
key = match[1].toLowerCase()
|
|
154
|
-
value = match[2]
|
|
155
|
-
|
|
156
|
-
if (value[0] === '"') {
|
|
157
|
-
// remove quotes and escapes
|
|
158
|
-
value = value
|
|
159
|
-
.substr(1, value.length - 2)
|
|
160
|
-
.replace(QESC_REGEXP, '$1')
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
obj.parameters[key] = value
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (index !== header.length) {
|
|
167
|
-
throw new TypeError('invalid parameter format')
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return obj
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Get content-type from req/res objects.
|
|
176
|
-
*
|
|
177
|
-
* @param {object}
|
|
178
|
-
* @return {Object}
|
|
179
|
-
* @private
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
|
-
function getcontenttype (obj) {
|
|
183
|
-
var header
|
|
184
|
-
|
|
185
|
-
if (typeof obj.getHeader === 'function') {
|
|
186
|
-
// res-like
|
|
187
|
-
header = obj.getHeader('content-type')
|
|
188
|
-
} else if (typeof obj.headers === 'object') {
|
|
189
|
-
// req-like
|
|
190
|
-
header = obj.headers && obj.headers['content-type']
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (typeof header !== 'string') {
|
|
194
|
-
throw new TypeError('content-type header is missing from object')
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return header
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Quote a string if necessary.
|
|
202
|
-
*
|
|
203
|
-
* @param {string} val
|
|
204
|
-
* @return {string}
|
|
205
|
-
* @private
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
function qstring (val) {
|
|
209
|
-
var str = String(val)
|
|
210
|
-
|
|
211
|
-
// no need to quote tokens
|
|
212
|
-
if (TOKEN_REGEXP.test(str)) {
|
|
213
|
-
return str
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (str.length > 0 && !TEXT_REGEXP.test(str)) {
|
|
217
|
-
throw new TypeError('invalid parameter value')
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Class to represent a content type.
|
|
225
|
-
* @private
|
|
226
|
-
*/
|
|
227
|
-
function ContentType (type) {
|
|
228
|
-
this.parameters = Object.create(null)
|
|
229
|
-
this.type = type
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
/***/ }),
|
|
234
|
-
|
|
235
|
-
/***/ 891:
|
|
236
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
237
|
-
|
|
238
|
-
/*!
|
|
239
|
-
* cookie
|
|
240
|
-
* Copyright(c) 2012-2014 Roman Shtylman
|
|
241
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
242
|
-
* MIT Licensed
|
|
243
|
-
*/
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Module exports.
|
|
249
|
-
* @public
|
|
250
|
-
*/
|
|
251
|
-
|
|
252
|
-
exports.parse = parse;
|
|
253
|
-
exports.serialize = serialize;
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Module variables.
|
|
257
|
-
* @private
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
var decode = decodeURIComponent;
|
|
261
|
-
var encode = encodeURIComponent;
|
|
262
|
-
var pairSplitRegExp = /; */;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
266
|
-
*
|
|
267
|
-
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
268
|
-
* field-vchar = VCHAR / obs-text
|
|
269
|
-
* obs-text = %x80-FF
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
|
-
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Parse a cookie header.
|
|
276
|
-
*
|
|
277
|
-
* Parse the given cookie header string into an object
|
|
278
|
-
* The object has the various cookies as keys(names) => values
|
|
279
|
-
*
|
|
280
|
-
* @param {string} str
|
|
281
|
-
* @param {object} [options]
|
|
282
|
-
* @return {object}
|
|
283
|
-
* @public
|
|
284
|
-
*/
|
|
285
|
-
|
|
286
|
-
function parse(str, options) {
|
|
287
|
-
if (typeof str !== 'string') {
|
|
288
|
-
throw new TypeError('argument str must be a string');
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
var obj = {}
|
|
292
|
-
var opt = options || {};
|
|
293
|
-
var pairs = str.split(pairSplitRegExp);
|
|
294
|
-
var dec = opt.decode || decode;
|
|
295
|
-
|
|
296
|
-
for (var i = 0; i < pairs.length; i++) {
|
|
297
|
-
var pair = pairs[i];
|
|
298
|
-
var eq_idx = pair.indexOf('=');
|
|
299
|
-
|
|
300
|
-
// skip things that don't look like key=value
|
|
301
|
-
if (eq_idx < 0) {
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
var key = pair.substr(0, eq_idx).trim()
|
|
306
|
-
var val = pair.substr(++eq_idx, pair.length).trim();
|
|
307
|
-
|
|
308
|
-
// quoted values
|
|
309
|
-
if ('"' == val[0]) {
|
|
310
|
-
val = val.slice(1, -1);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// only assign once
|
|
314
|
-
if (undefined == obj[key]) {
|
|
315
|
-
obj[key] = tryDecode(val, dec);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return obj;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Serialize data into a cookie header.
|
|
324
|
-
*
|
|
325
|
-
* Serialize the a name value pair into a cookie string suitable for
|
|
326
|
-
* http headers. An optional options object specified cookie parameters.
|
|
327
|
-
*
|
|
328
|
-
* serialize('foo', 'bar', { httpOnly: true })
|
|
329
|
-
* => "foo=bar; httpOnly"
|
|
330
|
-
*
|
|
331
|
-
* @param {string} name
|
|
332
|
-
* @param {string} val
|
|
333
|
-
* @param {object} [options]
|
|
334
|
-
* @return {string}
|
|
335
|
-
* @public
|
|
336
|
-
*/
|
|
337
|
-
|
|
338
|
-
function serialize(name, val, options) {
|
|
339
|
-
var opt = options || {};
|
|
340
|
-
var enc = opt.encode || encode;
|
|
341
|
-
|
|
342
|
-
if (typeof enc !== 'function') {
|
|
343
|
-
throw new TypeError('option encode is invalid');
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (!fieldContentRegExp.test(name)) {
|
|
347
|
-
throw new TypeError('argument name is invalid');
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
var value = enc(val);
|
|
351
|
-
|
|
352
|
-
if (value && !fieldContentRegExp.test(value)) {
|
|
353
|
-
throw new TypeError('argument val is invalid');
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
var str = name + '=' + value;
|
|
357
|
-
|
|
358
|
-
if (null != opt.maxAge) {
|
|
359
|
-
var maxAge = opt.maxAge - 0;
|
|
360
|
-
if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
|
|
361
|
-
str += '; Max-Age=' + Math.floor(maxAge);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (opt.domain) {
|
|
365
|
-
if (!fieldContentRegExp.test(opt.domain)) {
|
|
366
|
-
throw new TypeError('option domain is invalid');
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
str += '; Domain=' + opt.domain;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (opt.path) {
|
|
373
|
-
if (!fieldContentRegExp.test(opt.path)) {
|
|
374
|
-
throw new TypeError('option path is invalid');
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
str += '; Path=' + opt.path;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if (opt.expires) {
|
|
381
|
-
if (typeof opt.expires.toUTCString !== 'function') {
|
|
382
|
-
throw new TypeError('option expires is invalid');
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
str += '; Expires=' + opt.expires.toUTCString();
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (opt.httpOnly) {
|
|
389
|
-
str += '; HttpOnly';
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (opt.secure) {
|
|
393
|
-
str += '; Secure';
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (opt.sameSite) {
|
|
397
|
-
var sameSite = typeof opt.sameSite === 'string'
|
|
398
|
-
? opt.sameSite.toLowerCase() : opt.sameSite;
|
|
399
|
-
|
|
400
|
-
switch (sameSite) {
|
|
401
|
-
case true:
|
|
402
|
-
str += '; SameSite=Strict';
|
|
403
|
-
break;
|
|
404
|
-
case 'lax':
|
|
405
|
-
str += '; SameSite=Lax';
|
|
406
|
-
break;
|
|
407
|
-
case 'strict':
|
|
408
|
-
str += '; SameSite=Strict';
|
|
409
|
-
break;
|
|
410
|
-
case 'none':
|
|
411
|
-
str += '; SameSite=None';
|
|
412
|
-
break;
|
|
413
|
-
default:
|
|
414
|
-
throw new TypeError('option sameSite is invalid');
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
return str;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Try decoding a string using a decoding function.
|
|
423
|
-
*
|
|
424
|
-
* @param {string} str
|
|
425
|
-
* @param {function} decode
|
|
426
|
-
* @private
|
|
427
|
-
*/
|
|
428
|
-
|
|
429
|
-
function tryDecode(str, decode) {
|
|
430
|
-
try {
|
|
431
|
-
return decode(str);
|
|
432
|
-
} catch (e) {
|
|
433
|
-
return str;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
/***/ }),
|
|
439
|
-
|
|
440
|
-
/***/ 474:
|
|
441
|
-
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
442
|
-
|
|
443
|
-
/*!
|
|
444
|
-
* etag
|
|
445
|
-
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
446
|
-
* MIT Licensed
|
|
447
|
-
*/
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Module exports.
|
|
453
|
-
* @public
|
|
454
|
-
*/
|
|
455
|
-
|
|
456
|
-
module.exports = etag
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Module dependencies.
|
|
460
|
-
* @private
|
|
461
|
-
*/
|
|
462
|
-
|
|
463
|
-
var crypto = __webpack_require__(417)
|
|
464
|
-
var Stats = __webpack_require__(747).Stats
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Module variables.
|
|
468
|
-
* @private
|
|
469
|
-
*/
|
|
470
|
-
|
|
471
|
-
var toString = Object.prototype.toString
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Generate an entity tag.
|
|
475
|
-
*
|
|
476
|
-
* @param {Buffer|string} entity
|
|
477
|
-
* @return {string}
|
|
478
|
-
* @private
|
|
479
|
-
*/
|
|
480
|
-
|
|
481
|
-
function entitytag (entity) {
|
|
482
|
-
if (entity.length === 0) {
|
|
483
|
-
// fast-path empty
|
|
484
|
-
return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"'
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// compute hash of entity
|
|
488
|
-
var hash = crypto
|
|
489
|
-
.createHash('sha1')
|
|
490
|
-
.update(entity, 'utf8')
|
|
491
|
-
.digest('base64')
|
|
492
|
-
.substring(0, 27)
|
|
493
|
-
|
|
494
|
-
// compute length of entity
|
|
495
|
-
var len = typeof entity === 'string'
|
|
496
|
-
? Buffer.byteLength(entity, 'utf8')
|
|
497
|
-
: entity.length
|
|
498
|
-
|
|
499
|
-
return '"' + len.toString(16) + '-' + hash + '"'
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Create a simple ETag.
|
|
504
|
-
*
|
|
505
|
-
* @param {string|Buffer|Stats} entity
|
|
506
|
-
* @param {object} [options]
|
|
507
|
-
* @param {boolean} [options.weak]
|
|
508
|
-
* @return {String}
|
|
509
|
-
* @public
|
|
510
|
-
*/
|
|
511
|
-
|
|
512
|
-
function etag (entity, options) {
|
|
513
|
-
if (entity == null) {
|
|
514
|
-
throw new TypeError('argument entity is required')
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// support fs.Stats object
|
|
518
|
-
var isStats = isstats(entity)
|
|
519
|
-
var weak = options && typeof options.weak === 'boolean'
|
|
520
|
-
? options.weak
|
|
521
|
-
: isStats
|
|
522
|
-
|
|
523
|
-
// validate argument
|
|
524
|
-
if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) {
|
|
525
|
-
throw new TypeError('argument entity must be string, Buffer, or fs.Stats')
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// generate entity tag
|
|
529
|
-
var tag = isStats
|
|
530
|
-
? stattag(entity)
|
|
531
|
-
: entitytag(entity)
|
|
532
|
-
|
|
533
|
-
return weak
|
|
534
|
-
? 'W/' + tag
|
|
535
|
-
: tag
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Determine if object is a Stats object.
|
|
540
|
-
*
|
|
541
|
-
* @param {object} obj
|
|
542
|
-
* @return {boolean}
|
|
543
|
-
* @api private
|
|
544
|
-
*/
|
|
545
|
-
|
|
546
|
-
function isstats (obj) {
|
|
547
|
-
// genuine fs.Stats
|
|
548
|
-
if (typeof Stats === 'function' && obj instanceof Stats) {
|
|
549
|
-
return true
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
// quack quack
|
|
553
|
-
return obj && typeof obj === 'object' &&
|
|
554
|
-
'ctime' in obj && toString.call(obj.ctime) === '[object Date]' &&
|
|
555
|
-
'mtime' in obj && toString.call(obj.mtime) === '[object Date]' &&
|
|
556
|
-
'ino' in obj && typeof obj.ino === 'number' &&
|
|
557
|
-
'size' in obj && typeof obj.size === 'number'
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Generate a tag for a stat.
|
|
562
|
-
*
|
|
563
|
-
* @param {object} stat
|
|
564
|
-
* @return {string}
|
|
565
|
-
* @private
|
|
566
|
-
*/
|
|
567
|
-
|
|
568
|
-
function stattag (stat) {
|
|
569
|
-
var mtime = stat.mtime.getTime().toString(16)
|
|
570
|
-
var size = stat.size.toString(16)
|
|
571
|
-
|
|
572
|
-
return '"' + size + '-' + mtime + '"'
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
/***/ }),
|
|
577
|
-
|
|
578
|
-
/***/ 508:
|
|
579
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
583
|
-
exports.createServerWithHelpers = exports.sendError = exports.ApiError = void 0;
|
|
584
|
-
const http_1 = __webpack_require__(605);
|
|
585
|
-
function getBodyParser(req, body) {
|
|
586
|
-
return function parseBody() {
|
|
587
|
-
if (!req.headers['content-type']) {
|
|
588
|
-
return undefined;
|
|
589
|
-
}
|
|
590
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
591
|
-
const { parse: parseContentType } = __webpack_require__(534);
|
|
592
|
-
const { type } = parseContentType(req.headers['content-type']);
|
|
593
|
-
if (type === 'application/json') {
|
|
594
|
-
try {
|
|
595
|
-
const str = body.toString();
|
|
596
|
-
return str ? JSON.parse(str) : {};
|
|
597
|
-
}
|
|
598
|
-
catch (error) {
|
|
599
|
-
throw new ApiError(400, 'Invalid JSON');
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
if (type === 'application/octet-stream') {
|
|
603
|
-
return body;
|
|
604
|
-
}
|
|
605
|
-
if (type === 'application/x-www-form-urlencoded') {
|
|
606
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
607
|
-
const { parse: parseQS } = __webpack_require__(191);
|
|
608
|
-
// note: querystring.parse does not produce an iterable object
|
|
609
|
-
// https://nodejs.org/api/querystring.html#querystring_querystring_parse_str_sep_eq_options
|
|
610
|
-
return parseQS(body.toString());
|
|
611
|
-
}
|
|
612
|
-
if (type === 'text/plain') {
|
|
613
|
-
return body.toString();
|
|
614
|
-
}
|
|
615
|
-
return undefined;
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
function getQueryParser({ url = '/' }) {
|
|
619
|
-
return function parseQuery() {
|
|
620
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
621
|
-
const { parse: parseURL } = __webpack_require__(835);
|
|
622
|
-
return parseURL(url, true).query;
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
function getCookieParser(req) {
|
|
626
|
-
return function parseCookie() {
|
|
627
|
-
const header = req.headers.cookie;
|
|
628
|
-
if (!header) {
|
|
629
|
-
return {};
|
|
630
|
-
}
|
|
631
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
632
|
-
const { parse } = __webpack_require__(891);
|
|
633
|
-
return parse(Array.isArray(header) ? header.join(';') : header);
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
function status(res, statusCode) {
|
|
637
|
-
res.statusCode = statusCode;
|
|
638
|
-
return res;
|
|
639
|
-
}
|
|
640
|
-
function redirect(res, statusOrUrl, url) {
|
|
641
|
-
if (typeof statusOrUrl === 'string') {
|
|
642
|
-
url = statusOrUrl;
|
|
643
|
-
statusOrUrl = 307;
|
|
644
|
-
}
|
|
645
|
-
if (typeof statusOrUrl !== 'number' || typeof url !== 'string') {
|
|
646
|
-
throw new Error(`Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').`);
|
|
647
|
-
}
|
|
648
|
-
res.writeHead(statusOrUrl, { Location: url }).end();
|
|
649
|
-
return res;
|
|
650
|
-
}
|
|
651
|
-
function setCharset(type, charset) {
|
|
652
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
653
|
-
const { parse, format } = __webpack_require__(534);
|
|
654
|
-
const parsed = parse(type);
|
|
655
|
-
parsed.parameters.charset = charset;
|
|
656
|
-
return format(parsed);
|
|
657
|
-
}
|
|
658
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
659
|
-
function createETag(body, encoding) {
|
|
660
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
661
|
-
const etag = __webpack_require__(474);
|
|
662
|
-
const buf = !Buffer.isBuffer(body) ? Buffer.from(body, encoding) : body;
|
|
663
|
-
return etag(buf, { weak: true });
|
|
664
|
-
}
|
|
665
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
666
|
-
function send(req, res, body) {
|
|
667
|
-
let chunk = body;
|
|
668
|
-
let encoding;
|
|
669
|
-
switch (typeof chunk) {
|
|
670
|
-
// string defaulting to html
|
|
671
|
-
case 'string':
|
|
672
|
-
if (!res.getHeader('content-type')) {
|
|
673
|
-
res.setHeader('content-type', 'text/html');
|
|
674
|
-
}
|
|
675
|
-
break;
|
|
676
|
-
case 'boolean':
|
|
677
|
-
case 'number':
|
|
678
|
-
case 'object':
|
|
679
|
-
if (chunk === null) {
|
|
680
|
-
chunk = '';
|
|
681
|
-
}
|
|
682
|
-
else if (Buffer.isBuffer(chunk)) {
|
|
683
|
-
if (!res.getHeader('content-type')) {
|
|
684
|
-
res.setHeader('content-type', 'application/octet-stream');
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
else {
|
|
688
|
-
return json(req, res, chunk);
|
|
689
|
-
}
|
|
690
|
-
break;
|
|
691
|
-
}
|
|
692
|
-
// write strings in utf-8
|
|
693
|
-
if (typeof chunk === 'string') {
|
|
694
|
-
encoding = 'utf8';
|
|
695
|
-
// reflect this in content-type
|
|
696
|
-
const type = res.getHeader('content-type');
|
|
697
|
-
if (typeof type === 'string') {
|
|
698
|
-
res.setHeader('content-type', setCharset(type, 'utf-8'));
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
// populate Content-Length
|
|
702
|
-
let len;
|
|
703
|
-
if (chunk !== undefined) {
|
|
704
|
-
if (Buffer.isBuffer(chunk)) {
|
|
705
|
-
// get length of Buffer
|
|
706
|
-
len = chunk.length;
|
|
707
|
-
}
|
|
708
|
-
else if (typeof chunk === 'string') {
|
|
709
|
-
if (chunk.length < 1000) {
|
|
710
|
-
// just calculate length small chunk
|
|
711
|
-
len = Buffer.byteLength(chunk, encoding);
|
|
712
|
-
}
|
|
713
|
-
else {
|
|
714
|
-
// convert chunk to Buffer and calculate
|
|
715
|
-
const buf = Buffer.from(chunk, encoding);
|
|
716
|
-
len = buf.length;
|
|
717
|
-
chunk = buf;
|
|
718
|
-
encoding = undefined;
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
else {
|
|
722
|
-
throw new Error('`body` is not a valid string, object, boolean, number, Stream, or Buffer');
|
|
723
|
-
}
|
|
724
|
-
if (len !== undefined) {
|
|
725
|
-
res.setHeader('content-length', len);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
// populate ETag
|
|
729
|
-
let etag;
|
|
730
|
-
if (!res.getHeader('etag') &&
|
|
731
|
-
len !== undefined &&
|
|
732
|
-
(etag = createETag(chunk, encoding))) {
|
|
733
|
-
res.setHeader('etag', etag);
|
|
734
|
-
}
|
|
735
|
-
// strip irrelevant headers
|
|
736
|
-
if (204 === res.statusCode || 304 === res.statusCode) {
|
|
737
|
-
res.removeHeader('Content-Type');
|
|
738
|
-
res.removeHeader('Content-Length');
|
|
739
|
-
res.removeHeader('Transfer-Encoding');
|
|
740
|
-
chunk = '';
|
|
741
|
-
}
|
|
742
|
-
if (req.method === 'HEAD') {
|
|
743
|
-
// skip body for HEAD
|
|
744
|
-
res.end();
|
|
745
|
-
}
|
|
746
|
-
else if (encoding) {
|
|
747
|
-
// respond with encoding
|
|
748
|
-
res.end(chunk, encoding);
|
|
749
|
-
}
|
|
750
|
-
else {
|
|
751
|
-
// respond without encoding
|
|
752
|
-
res.end(chunk);
|
|
753
|
-
}
|
|
754
|
-
return res;
|
|
755
|
-
}
|
|
756
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
757
|
-
function json(req, res, jsonBody) {
|
|
758
|
-
const body = JSON.stringify(jsonBody);
|
|
759
|
-
// content-type
|
|
760
|
-
if (!res.getHeader('content-type')) {
|
|
761
|
-
res.setHeader('content-type', 'application/json; charset=utf-8');
|
|
762
|
-
}
|
|
763
|
-
return send(req, res, body);
|
|
764
|
-
}
|
|
765
|
-
class ApiError extends Error {
|
|
766
|
-
constructor(statusCode, message) {
|
|
767
|
-
super(message);
|
|
768
|
-
this.statusCode = statusCode;
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
exports.ApiError = ApiError;
|
|
772
|
-
function sendError(res, statusCode, message) {
|
|
773
|
-
res.statusCode = statusCode;
|
|
774
|
-
res.statusMessage = message;
|
|
775
|
-
res.end();
|
|
776
|
-
}
|
|
777
|
-
exports.sendError = sendError;
|
|
778
|
-
function setLazyProp(req, prop, getter) {
|
|
779
|
-
const opts = { configurable: true, enumerable: true };
|
|
780
|
-
const optsReset = { ...opts, writable: true };
|
|
781
|
-
Object.defineProperty(req, prop, {
|
|
782
|
-
...opts,
|
|
783
|
-
get: () => {
|
|
784
|
-
const value = getter();
|
|
785
|
-
// we set the property on the object to avoid recalculating it
|
|
786
|
-
Object.defineProperty(req, prop, { ...optsReset, value });
|
|
787
|
-
return value;
|
|
788
|
-
},
|
|
789
|
-
set: value => {
|
|
790
|
-
Object.defineProperty(req, prop, { ...optsReset, value });
|
|
791
|
-
},
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
function createServerWithHelpers(handler, bridge) {
|
|
795
|
-
const server = new http_1.Server(async (_req, _res) => {
|
|
796
|
-
const req = _req;
|
|
797
|
-
const res = _res;
|
|
798
|
-
try {
|
|
799
|
-
const reqId = req.headers['x-now-bridge-request-id'];
|
|
800
|
-
// don't expose this header to the client
|
|
801
|
-
delete req.headers['x-now-bridge-request-id'];
|
|
802
|
-
if (typeof reqId !== 'string') {
|
|
803
|
-
throw new ApiError(500, 'Internal Server Error');
|
|
804
|
-
}
|
|
805
|
-
const event = bridge.consumeEvent(reqId);
|
|
806
|
-
setLazyProp(req, 'cookies', getCookieParser(req));
|
|
807
|
-
setLazyProp(req, 'query', getQueryParser(req));
|
|
808
|
-
setLazyProp(req, 'body', getBodyParser(req, event.body));
|
|
809
|
-
res.status = statusCode => status(res, statusCode);
|
|
810
|
-
res.redirect = (statusOrUrl, url) => redirect(res, statusOrUrl, url);
|
|
811
|
-
res.send = body => send(req, res, body);
|
|
812
|
-
res.json = jsonBody => json(req, res, jsonBody);
|
|
813
|
-
await handler(req, res);
|
|
814
|
-
}
|
|
815
|
-
catch (err) {
|
|
816
|
-
if (err instanceof ApiError) {
|
|
817
|
-
sendError(res, err.statusCode, err.message);
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
820
|
-
throw err;
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
});
|
|
824
|
-
return server;
|
|
825
|
-
}
|
|
826
|
-
exports.createServerWithHelpers = createServerWithHelpers;
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
/***/ }),
|
|
830
|
-
|
|
831
|
-
/***/ 417:
|
|
832
|
-
/***/ ((module) => {
|
|
833
|
-
|
|
834
|
-
module.exports = require("crypto");
|
|
835
|
-
|
|
836
|
-
/***/ }),
|
|
837
|
-
|
|
838
|
-
/***/ 747:
|
|
839
|
-
/***/ ((module) => {
|
|
840
|
-
|
|
841
|
-
module.exports = require("fs");
|
|
842
|
-
|
|
843
|
-
/***/ }),
|
|
844
|
-
|
|
845
|
-
/***/ 605:
|
|
846
|
-
/***/ ((module) => {
|
|
847
|
-
|
|
848
|
-
module.exports = require("http");
|
|
849
|
-
|
|
850
|
-
/***/ }),
|
|
851
|
-
|
|
852
|
-
/***/ 191:
|
|
853
|
-
/***/ ((module) => {
|
|
854
|
-
|
|
855
|
-
module.exports = require("querystring");
|
|
856
|
-
|
|
857
|
-
/***/ }),
|
|
858
|
-
|
|
859
|
-
/***/ 835:
|
|
860
|
-
/***/ ((module) => {
|
|
861
|
-
|
|
862
|
-
module.exports = require("url");
|
|
863
|
-
|
|
864
|
-
/***/ })
|
|
865
|
-
|
|
866
|
-
/******/ });
|
|
867
|
-
/************************************************************************/
|
|
868
|
-
/******/ // The module cache
|
|
869
|
-
/******/ var __webpack_module_cache__ = {};
|
|
870
|
-
/******/
|
|
871
|
-
/******/ // The require function
|
|
872
|
-
/******/ function __webpack_require__(moduleId) {
|
|
873
|
-
/******/ // Check if module is in cache
|
|
874
|
-
/******/ if(__webpack_module_cache__[moduleId]) {
|
|
875
|
-
/******/ return __webpack_module_cache__[moduleId].exports;
|
|
876
|
-
/******/ }
|
|
877
|
-
/******/ // Create a new module (and put it into the cache)
|
|
878
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
879
|
-
/******/ // no module.id needed
|
|
880
|
-
/******/ // no module.loaded needed
|
|
881
|
-
/******/ exports: {}
|
|
882
|
-
/******/ };
|
|
883
|
-
/******/
|
|
884
|
-
/******/ // Execute the module function
|
|
885
|
-
/******/ var threw = true;
|
|
886
|
-
/******/ try {
|
|
887
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
888
|
-
/******/ threw = false;
|
|
889
|
-
/******/ } finally {
|
|
890
|
-
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
|
891
|
-
/******/ }
|
|
892
|
-
/******/
|
|
893
|
-
/******/ // Return the exports of the module
|
|
894
|
-
/******/ return module.exports;
|
|
895
|
-
/******/ }
|
|
896
|
-
/******/
|
|
897
|
-
/************************************************************************/
|
|
898
|
-
/******/ /* webpack/runtime/compat */
|
|
899
|
-
/******/
|
|
900
|
-
/******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/
|
|
901
|
-
/******/ // module exports must be returned from runtime so entry inlining is disabled
|
|
902
|
-
/******/ // startup
|
|
903
|
-
/******/ // Load entry module and return exports
|
|
904
|
-
/******/ return __webpack_require__(508);
|
|
905
|
-
/******/ })()
|
|
906
|
-
;
|