swagger-client 3.29.3 → 3.29.4

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.
@@ -6193,16 +6193,69 @@ exports.serialize = serialize;
6193
6193
  */
6194
6194
 
6195
6195
  var __toString = Object.prototype.toString
6196
+ var __hasOwnProperty = Object.prototype.hasOwnProperty
6196
6197
 
6197
6198
  /**
6198
- * RegExp to match field-content in RFC 7230 sec 3.2
6199
+ * RegExp to match cookie-name in RFC 6265 sec 4.1.1
6200
+ * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
6201
+ * which has been replaced by the token definition in RFC 7230 appendix B.
6199
6202
  *
6200
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
6201
- * field-vchar = VCHAR / obs-text
6202
- * obs-text = %x80-FF
6203
+ * cookie-name = token
6204
+ * token = 1*tchar
6205
+ * tchar = "!" / "#" / "$" / "%" / "&" / "'" /
6206
+ * "*" / "+" / "-" / "." / "^" / "_" /
6207
+ * "`" / "|" / "~" / DIGIT / ALPHA
6203
6208
  */
6204
6209
 
6205
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
6210
+ var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
6211
+
6212
+ /**
6213
+ * RegExp to match cookie-value in RFC 6265 sec 4.1.1
6214
+ *
6215
+ * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
6216
+ * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
6217
+ * ; US-ASCII characters excluding CTLs,
6218
+ * ; whitespace DQUOTE, comma, semicolon,
6219
+ * ; and backslash
6220
+ */
6221
+
6222
+ var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
6223
+
6224
+ /**
6225
+ * RegExp to match domain-value in RFC 6265 sec 4.1.1
6226
+ *
6227
+ * domain-value = <subdomain>
6228
+ * ; defined in [RFC1034], Section 3.5, as
6229
+ * ; enhanced by [RFC1123], Section 2.1
6230
+ * <subdomain> = <label> | <subdomain> "." <label>
6231
+ * <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
6232
+ * Labels must be 63 characters or less.
6233
+ * 'let-dig' not 'letter' in the first char, per RFC1123
6234
+ * <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
6235
+ * <let-dig-hyp> = <let-dig> | "-"
6236
+ * <let-dig> = <letter> | <digit>
6237
+ * <letter> = any one of the 52 alphabetic characters A through Z in
6238
+ * upper case and a through z in lower case
6239
+ * <digit> = any one of the ten digits 0 through 9
6240
+ *
6241
+ * Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
6242
+ *
6243
+ * > (Note that a leading %x2E ("."), if present, is ignored even though that
6244
+ * character is not permitted, but a trailing %x2E ("."), if present, will
6245
+ * cause the user agent to ignore the attribute.)
6246
+ */
6247
+
6248
+ var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
6249
+
6250
+ /**
6251
+ * RegExp to match path-value in RFC 6265 sec 4.1.1
6252
+ *
6253
+ * path-value = <any CHAR except CTLs or ";">
6254
+ * CHAR = %x01-7F
6255
+ * ; defined in RFC 5234 appendix B.1
6256
+ */
6257
+
6258
+ var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
6206
6259
 
6207
6260
  /**
6208
6261
  * Parse a cookie header.
@@ -6211,107 +6264,128 @@ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
6211
6264
  * The object has the various cookies as keys(names) => values
6212
6265
  *
6213
6266
  * @param {string} str
6214
- * @param {object} [options]
6267
+ * @param {object} [opt]
6215
6268
  * @return {object}
6216
6269
  * @public
6217
6270
  */
6218
6271
 
6219
- function parse(str, options) {
6272
+ function parse(str, opt) {
6220
6273
  if (typeof str !== 'string') {
6221
6274
  throw new TypeError('argument str must be a string');
6222
6275
  }
6223
6276
 
6224
- var obj = {}
6225
- var opt = options || {};
6226
- var dec = opt.decode || decode;
6277
+ var obj = {};
6278
+ var len = str.length;
6279
+ // RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
6280
+ if (len < 2) return obj;
6227
6281
 
6228
- var index = 0
6229
- while (index < str.length) {
6230
- var eqIdx = str.indexOf('=', index)
6282
+ var dec = (opt && opt.decode) || decode;
6283
+ var index = 0;
6284
+ var eqIdx = 0;
6285
+ var endIdx = 0;
6231
6286
 
6232
- // no more cookie pairs
6233
- if (eqIdx === -1) {
6234
- break
6235
- }
6287
+ do {
6288
+ eqIdx = str.indexOf('=', index);
6289
+ if (eqIdx === -1) break; // No more cookie pairs.
6236
6290
 
6237
- var endIdx = str.indexOf(';', index)
6291
+ endIdx = str.indexOf(';', index);
6238
6292
 
6239
6293
  if (endIdx === -1) {
6240
- endIdx = str.length
6241
- } else if (endIdx < eqIdx) {
6294
+ endIdx = len;
6295
+ } else if (eqIdx > endIdx) {
6242
6296
  // backtrack on prior semicolon
6243
- index = str.lastIndexOf(';', eqIdx - 1) + 1
6244
- continue
6297
+ index = str.lastIndexOf(';', eqIdx - 1) + 1;
6298
+ continue;
6245
6299
  }
6246
6300
 
6247
- var key = str.slice(index, eqIdx).trim()
6301
+ var keyStartIdx = startIndex(str, index, eqIdx);
6302
+ var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
6303
+ var key = str.slice(keyStartIdx, keyEndIdx);
6248
6304
 
6249
6305
  // only assign once
6250
- if (undefined === obj[key]) {
6251
- var val = str.slice(eqIdx + 1, endIdx).trim()
6306
+ if (!__hasOwnProperty.call(obj, key)) {
6307
+ var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
6308
+ var valEndIdx = endIndex(str, endIdx, valStartIdx);
6252
6309
 
6253
- // quoted values
6254
- if (val.charCodeAt(0) === 0x22) {
6255
- val = val.slice(1, -1)
6310
+ if (str.charCodeAt(valStartIdx) === 0x22 /* " */ && str.charCodeAt(valEndIdx - 1) === 0x22 /* " */) {
6311
+ valStartIdx++;
6312
+ valEndIdx--;
6256
6313
  }
6257
6314
 
6315
+ var val = str.slice(valStartIdx, valEndIdx);
6258
6316
  obj[key] = tryDecode(val, dec);
6259
6317
  }
6260
6318
 
6261
6319
  index = endIdx + 1
6262
- }
6320
+ } while (index < len);
6263
6321
 
6264
6322
  return obj;
6265
6323
  }
6266
6324
 
6325
+ function startIndex(str, index, max) {
6326
+ do {
6327
+ var code = str.charCodeAt(index);
6328
+ if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index;
6329
+ } while (++index < max);
6330
+ return max;
6331
+ }
6332
+
6333
+ function endIndex(str, index, min) {
6334
+ while (index > min) {
6335
+ var code = str.charCodeAt(--index);
6336
+ if (code !== 0x20 /* */ && code !== 0x09 /* \t */) return index + 1;
6337
+ }
6338
+ return min;
6339
+ }
6340
+
6267
6341
  /**
6268
6342
  * Serialize data into a cookie header.
6269
6343
  *
6270
- * Serialize the a name value pair into a cookie string suitable for
6271
- * http headers. An optional options object specified cookie parameters.
6344
+ * Serialize a name value pair into a cookie string suitable for
6345
+ * http headers. An optional options object specifies cookie parameters.
6272
6346
  *
6273
6347
  * serialize('foo', 'bar', { httpOnly: true })
6274
6348
  * => "foo=bar; httpOnly"
6275
6349
  *
6276
6350
  * @param {string} name
6277
6351
  * @param {string} val
6278
- * @param {object} [options]
6352
+ * @param {object} [opt]
6279
6353
  * @return {string}
6280
6354
  * @public
6281
6355
  */
6282
6356
 
6283
- function serialize(name, val, options) {
6284
- var opt = options || {};
6285
- var enc = opt.encode || encode;
6357
+ function serialize(name, val, opt) {
6358
+ var enc = (opt && opt.encode) || encodeURIComponent;
6286
6359
 
6287
6360
  if (typeof enc !== 'function') {
6288
6361
  throw new TypeError('option encode is invalid');
6289
6362
  }
6290
6363
 
6291
- if (!fieldContentRegExp.test(name)) {
6364
+ if (!cookieNameRegExp.test(name)) {
6292
6365
  throw new TypeError('argument name is invalid');
6293
6366
  }
6294
6367
 
6295
6368
  var value = enc(val);
6296
6369
 
6297
- if (value && !fieldContentRegExp.test(value)) {
6370
+ if (!cookieValueRegExp.test(value)) {
6298
6371
  throw new TypeError('argument val is invalid');
6299
6372
  }
6300
6373
 
6301
6374
  var str = name + '=' + value;
6375
+ if (!opt) return str;
6302
6376
 
6303
6377
  if (null != opt.maxAge) {
6304
- var maxAge = opt.maxAge - 0;
6378
+ var maxAge = Math.floor(opt.maxAge);
6305
6379
 
6306
- if (isNaN(maxAge) || !isFinite(maxAge)) {
6380
+ if (!isFinite(maxAge)) {
6307
6381
  throw new TypeError('option maxAge is invalid')
6308
6382
  }
6309
6383
 
6310
- str += '; Max-Age=' + Math.floor(maxAge);
6384
+ str += '; Max-Age=' + maxAge;
6311
6385
  }
6312
6386
 
6313
6387
  if (opt.domain) {
6314
- if (!fieldContentRegExp.test(opt.domain)) {
6388
+ if (!domainValueRegExp.test(opt.domain)) {
6315
6389
  throw new TypeError('option domain is invalid');
6316
6390
  }
6317
6391
 
@@ -6319,7 +6393,7 @@ function serialize(name, val, options) {
6319
6393
  }
6320
6394
 
6321
6395
  if (opt.path) {
6322
- if (!fieldContentRegExp.test(opt.path)) {
6396
+ if (!pathValueRegExp.test(opt.path)) {
6323
6397
  throw new TypeError('option path is invalid');
6324
6398
  }
6325
6399
 
@@ -6350,8 +6424,7 @@ function serialize(name, val, options) {
6350
6424
 
6351
6425
  if (opt.priority) {
6352
6426
  var priority = typeof opt.priority === 'string'
6353
- ? opt.priority.toLowerCase()
6354
- : opt.priority
6427
+ ? opt.priority.toLowerCase() : opt.priority;
6355
6428
 
6356
6429
  switch (priority) {
6357
6430
  case 'low':
@@ -6406,17 +6479,6 @@ function decode (str) {
6406
6479
  : str
6407
6480
  }
6408
6481
 
6409
- /**
6410
- * URL-encode value.
6411
- *
6412
- * @param {string} val
6413
- * @returns {string}
6414
- */
6415
-
6416
- function encode (val) {
6417
- return encodeURIComponent(val)
6418
- }
6419
-
6420
6482
  /**
6421
6483
  * Determine if value is a Date.
6422
6484
  *
@@ -6425,8 +6487,7 @@ function encode (val) {
6425
6487
  */
6426
6488
 
6427
6489
  function isDate (val) {
6428
- return __toString.call(val) === '[object Date]' ||
6429
- val instanceof Date
6490
+ return __toString.call(val) === '[object Date]';
6430
6491
  }
6431
6492
 
6432
6493
  /**