@opra/client 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/cjs/content-disposition-c51e31ba.js +473 -0
  2. package/cjs/cookie-signature-590f02de.js +68 -0
  3. package/cjs/index.min.mjs +10439 -9069
  4. package/cjs/{mime-db-49f150d0.js → mime-db-c6221216.js} +13 -5
  5. package/cjs/mime-types-1472f038.js +205 -0
  6. package/cjs/safe-buffer-22554edb.js +83 -0
  7. package/esm/content-disposition-da32da5d.js +471 -0
  8. package/esm/cookie-signature-40f74d13.js +66 -0
  9. package/esm/index.min.mjs +10439 -8950
  10. package/esm/{mime-db-d0f15d8f.js → mime-db-95975a69.js} +13 -5
  11. package/esm/mime-types-f653a5df.js +203 -0
  12. package/esm/safe-buffer-9b74695b.js +81 -0
  13. package/package.json +6 -7
  14. package/{typings → types}/common/document/factory/import-resource-class.d.ts +1 -0
  15. package/{typings → types}/common/document/resource/collection.d.ts +10 -10
  16. package/{typings → types}/common/document/resource/singleton.d.ts +4 -4
  17. package/{typings → types}/common/schema/resource/collection.interface.d.ts +6 -6
  18. package/{typings → types}/common/url/opra-url.d.ts +3 -3
  19. package/{typings → types}/http/http-client.d.ts +2 -2
  20. package/{typings → types}/http/http-collection-node.d.ts +4 -4
  21. package/cjs/content-disposition-d575fee5.js +0 -473
  22. package/cjs/cookie-signature-3e974173.js +0 -64
  23. package/cjs/mime-types-6e2bdb57.js +0 -201
  24. package/cjs/safe-buffer-8acd60c7.js +0 -78
  25. package/esm/content-disposition-65f281a9.js +0 -470
  26. package/esm/cookie-signature-bf274b6b.js +0 -62
  27. package/esm/mime-types-79c091fd.js +0 -199
  28. package/esm/safe-buffer-63383356.js +0 -76
  29. package/{typings → types}/client-error.d.ts +0 -0
  30. package/{typings → types}/common/document/api-document.d.ts +0 -0
  31. package/{typings → types}/common/document/constants.d.ts +0 -0
  32. package/{typings → types}/common/document/data-type/api-field.d.ts +0 -0
  33. package/{typings → types}/common/document/data-type/builtin/any.type.d.ts +0 -0
  34. package/{typings → types}/common/document/data-type/builtin/base64.type.d.ts +0 -0
  35. package/{typings → types}/common/document/data-type/builtin/bigint.type.d.ts +0 -0
  36. package/{typings → types}/common/document/data-type/builtin/boolean.type.d.ts +0 -0
  37. package/{typings → types}/common/document/data-type/builtin/date.type.d.ts +0 -0
  38. package/{typings → types}/common/document/data-type/builtin/guid.type.d.ts +0 -0
  39. package/{typings → types}/common/document/data-type/builtin/index.d.ts +0 -0
  40. package/{typings → types}/common/document/data-type/builtin/integer.type.d.ts +0 -0
  41. package/{typings → types}/common/document/data-type/builtin/number.type.d.ts +0 -0
  42. package/{typings → types}/common/document/data-type/builtin/object.type.d.ts +0 -0
  43. package/{typings → types}/common/document/data-type/builtin/string.type.d.ts +0 -0
  44. package/{typings → types}/common/document/data-type/builtin/time.type.d.ts +0 -0
  45. package/{typings → types}/common/document/data-type/builtin/timestamp.type.d.ts +0 -0
  46. package/{typings → types}/common/document/data-type/complex-type.d.ts +0 -0
  47. package/{typings → types}/common/document/data-type/data-type.d.ts +0 -0
  48. package/{typings → types}/common/document/data-type/enum-type.d.ts +0 -0
  49. package/{typings → types}/common/document/data-type/mapped-type.d.ts +0 -0
  50. package/{typings → types}/common/document/data-type/simple-type.d.ts +0 -0
  51. package/{typings → types}/common/document/data-type/union-type.d.ts +0 -0
  52. package/{typings → types}/common/document/factory/add-references.d.ts +0 -0
  53. package/{typings → types}/common/document/factory/create-document.d.ts +0 -0
  54. package/{typings → types}/common/document/factory/factory.d.ts +0 -0
  55. package/{typings → types}/common/document/factory/import-type-class.d.ts +0 -0
  56. package/{typings → types}/common/document/factory/index.d.ts +0 -0
  57. package/{typings → types}/common/document/factory/process-resources.d.ts +0 -0
  58. package/{typings → types}/common/document/factory/process-types.d.ts +0 -0
  59. package/{typings → types}/common/document/index.d.ts +0 -0
  60. package/{typings → types}/common/document/resource/resource.d.ts +0 -0
  61. package/{typings → types}/common/document/utils/inspect.util.d.ts +0 -0
  62. package/{typings → types}/common/document/utils/string-compare.util.d.ts +0 -0
  63. package/{typings → types}/common/exception/enums/issue-severity.enum.d.ts +0 -0
  64. package/{typings → types}/common/exception/error-issue.d.ts +0 -0
  65. package/{typings → types}/common/exception/http-errors/bad-request.error.d.ts +0 -0
  66. package/{typings → types}/common/exception/http-errors/failed-dependency.error.d.ts +0 -0
  67. package/{typings → types}/common/exception/http-errors/forbidden.error.d.ts +0 -0
  68. package/{typings → types}/common/exception/http-errors/internal-server.error.d.ts +0 -0
  69. package/{typings → types}/common/exception/http-errors/method-not-allowed.error.d.ts +0 -0
  70. package/{typings → types}/common/exception/http-errors/not-acceptable.error.d.ts +0 -0
  71. package/{typings → types}/common/exception/http-errors/not-found.error.d.ts +0 -0
  72. package/{typings → types}/common/exception/http-errors/unauthorized.error.d.ts +0 -0
  73. package/{typings → types}/common/exception/http-errors/unprocessable-entity.error.d.ts +0 -0
  74. package/{typings → types}/common/exception/index.d.ts +0 -0
  75. package/{typings → types}/common/exception/opra-exception.d.ts +0 -0
  76. package/{typings → types}/common/exception/resource-errors/resource-conflict.error.d.ts +0 -0
  77. package/{typings → types}/common/exception/resource-errors/resource-not-found.error.d.ts +0 -0
  78. package/{typings → types}/common/exception/wrap-exception.d.ts +0 -0
  79. package/{typings → types}/common/filter/antlr/OpraFilterLexer.d.ts +0 -0
  80. package/{typings → types}/common/filter/antlr/OpraFilterListener.d.ts +0 -0
  81. package/{typings → types}/common/filter/antlr/OpraFilterParser.d.ts +0 -0
  82. package/{typings → types}/common/filter/antlr/OpraFilterVisitor.d.ts +0 -0
  83. package/{typings → types}/common/filter/ast/abstract/ast.d.ts +0 -0
  84. package/{typings → types}/common/filter/ast/abstract/expression.d.ts +0 -0
  85. package/{typings → types}/common/filter/ast/abstract/literal.d.ts +0 -0
  86. package/{typings → types}/common/filter/ast/abstract/term.d.ts +0 -0
  87. package/{typings → types}/common/filter/ast/expressions/arithmetic-expression.d.ts +0 -0
  88. package/{typings → types}/common/filter/ast/expressions/array-expression.d.ts +0 -0
  89. package/{typings → types}/common/filter/ast/expressions/comparison-expression.d.ts +0 -0
  90. package/{typings → types}/common/filter/ast/expressions/logical-expression.d.ts +0 -0
  91. package/{typings → types}/common/filter/ast/expressions/parentheses-expression.d.ts +0 -0
  92. package/{typings → types}/common/filter/ast/index.d.ts +0 -0
  93. package/{typings → types}/common/filter/ast/terms/boolean-literal.d.ts +0 -0
  94. package/{typings → types}/common/filter/ast/terms/date-literal.d.ts +0 -0
  95. package/{typings → types}/common/filter/ast/terms/external-constant.d.ts +0 -0
  96. package/{typings → types}/common/filter/ast/terms/null-literal.d.ts +0 -0
  97. package/{typings → types}/common/filter/ast/terms/number-literal.d.ts +0 -0
  98. package/{typings → types}/common/filter/ast/terms/qualified-identifier.d.ts +0 -0
  99. package/{typings → types}/common/filter/ast/terms/string-literal.d.ts +0 -0
  100. package/{typings → types}/common/filter/ast/terms/time-literal.d.ts +0 -0
  101. package/{typings → types}/common/filter/build.d.ts +0 -0
  102. package/{typings → types}/common/filter/errors.d.ts +0 -0
  103. package/{typings → types}/common/filter/filter-tree-visitor.d.ts +0 -0
  104. package/{typings → types}/common/filter/index.d.ts +0 -0
  105. package/{typings → types}/common/filter/opra-error-listener.d.ts +0 -0
  106. package/{typings → types}/common/filter/parse.d.ts +0 -0
  107. package/{typings → types}/common/filter/utils.d.ts +0 -0
  108. package/{typings → types}/common/helpers/function-utils.d.ts +0 -0
  109. package/{typings → types}/common/helpers/get-stack-filename.d.ts +0 -0
  110. package/{typings → types}/common/helpers/index.d.ts +0 -0
  111. package/{typings → types}/common/helpers/is-url.d.ts +0 -0
  112. package/{typings → types}/common/helpers/mixin-utils.d.ts +0 -0
  113. package/{typings → types}/common/helpers/object-utils.d.ts +0 -0
  114. package/{typings → types}/common/helpers/path-to-object-tree.d.ts +0 -0
  115. package/{typings → types}/common/helpers/responsive-map.d.ts +0 -0
  116. package/{typings → types}/common/helpers/type-guards.d.ts +0 -0
  117. package/{typings → types}/common/http/codecs/boolean-codec.d.ts +0 -0
  118. package/{typings → types}/common/http/codecs/date-codec.d.ts +0 -0
  119. package/{typings → types}/common/http/codecs/filter-codec.d.ts +0 -0
  120. package/{typings → types}/common/http/codecs/integer-codec.d.ts +0 -0
  121. package/{typings → types}/common/http/codecs/number-codec.d.ts +0 -0
  122. package/{typings → types}/common/http/codecs/string-codec.d.ts +0 -0
  123. package/{typings → types}/common/http/enums/http-headers-codes.enum.d.ts +0 -0
  124. package/{typings → types}/common/http/enums/http-status-codes.enum.d.ts +0 -0
  125. package/{typings → types}/common/http/enums/http-status-messages.d.ts +0 -0
  126. package/{typings → types}/common/http/http-headers.d.ts +0 -0
  127. package/{typings → types}/common/http/http-message.host.d.ts +0 -0
  128. package/{typings → types}/common/http/http-params.d.ts +0 -0
  129. package/{typings → types}/common/http/http-request-message.d.ts +0 -0
  130. package/{typings → types}/common/http/http-response-message.d.ts +0 -0
  131. package/{typings → types}/common/http/index.d.ts +0 -0
  132. package/{typings → types}/common/http/interfaces/client-http-headers.interface.d.ts +0 -0
  133. package/{typings → types}/common/http/interfaces/cookie-options.interface.d.ts +0 -0
  134. package/{typings → types}/common/http/interfaces/server-http-headers.interface.d.ts +0 -0
  135. package/{typings → types}/common/http/multipart/batch-multipart.d.ts +0 -0
  136. package/{typings → types}/common/http/multipart/http-request-content.d.ts +0 -0
  137. package/{typings → types}/common/http/multipart/http-response-content.d.ts +0 -0
  138. package/{typings → types}/common/http/multipart/index.d.ts +0 -0
  139. package/{typings → types}/common/i18n/i18n.d.ts +0 -0
  140. package/{typings → types}/common/i18n/index.d.ts +0 -0
  141. package/{typings → types}/common/i18n/string-utils.d.ts +0 -0
  142. package/{typings → types}/common/i18n/translate.d.ts +0 -0
  143. package/{typings → types}/common/index.d.ts +0 -0
  144. package/{typings → types}/common/schema/constants.d.ts +0 -0
  145. package/{typings → types}/common/schema/data-type/complex-type.interface.d.ts +0 -0
  146. package/{typings → types}/common/schema/data-type/data-type.interface.d.ts +0 -0
  147. package/{typings → types}/common/schema/data-type/enum-type.interface.d.ts +0 -0
  148. package/{typings → types}/common/schema/data-type/field.interface.d.ts +0 -0
  149. package/{typings → types}/common/schema/data-type/mapped-type.interface.d.ts +0 -0
  150. package/{typings → types}/common/schema/data-type/simple-type.interface.d.ts +0 -0
  151. package/{typings → types}/common/schema/data-type/union-type.interface.d.ts +0 -0
  152. package/{typings → types}/common/schema/document.interface.d.ts +0 -0
  153. package/{typings → types}/common/schema/index.d.ts +0 -0
  154. package/{typings → types}/common/schema/resource/container.interface.d.ts +0 -0
  155. package/{typings → types}/common/schema/resource/endpoint.interface.d.ts +0 -0
  156. package/{typings → types}/common/schema/resource/resource.interface.d.ts +0 -0
  157. package/{typings → types}/common/schema/resource/singleton.interface.d.ts +2 -2
  158. /package/{typings → types}/common/schema/type-guards.d.ts +0 -0
  159. /package/{typings → types}/common/types.d.ts +0 -0
  160. /package/{typings → types}/common/url/index.d.ts +0 -0
  161. /package/{typings → types}/common/url/opra-url-path-component.d.ts +0 -0
  162. /package/{typings → types}/common/url/opra-url-path.d.ts +0 -0
  163. /package/{typings → types}/common/url/utils/decode-path-component.d.ts +0 -0
  164. /package/{typings → types}/common/url/utils/encode-path-component.d.ts +0 -0
  165. /package/{typings → types}/common/utils/path-utils.d.ts +0 -0
  166. /package/{typings → types}/constants.d.ts +0 -0
  167. /package/{typings → types}/http/batch-request.d.ts +0 -0
  168. /package/{typings → types}/http/http-request-observable.d.ts +0 -0
  169. /package/{typings → types}/http/http-request.d.ts +0 -0
  170. /package/{typings → types}/http/http-response.d.ts +0 -0
  171. /package/{typings → types}/http/http-service-base.d.ts +0 -0
  172. /package/{typings → types}/http/http-singleton-node.d.ts +0 -0
  173. /package/{typings → types}/http/http-types.d.ts +0 -0
  174. /package/{typings → types}/index.d.ts +0 -0
@@ -0,0 +1,473 @@
1
+ 'use strict';
2
+
3
+ var require$$4 = require('path-browserify');
4
+ var safeBuffer = require('./safe-buffer-22554edb.js');
5
+
6
+ var contentDisposition = {exports: {}};
7
+
8
+ /*!
9
+ * content-disposition
10
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
11
+ * MIT Licensed
12
+ */
13
+
14
+ var hasRequiredContentDisposition;
15
+
16
+ function requireContentDisposition () {
17
+ if (hasRequiredContentDisposition) return contentDisposition.exports;
18
+ hasRequiredContentDisposition = 1;
19
+
20
+ /**
21
+ * Module exports.
22
+ * @public
23
+ */
24
+
25
+ contentDisposition.exports = contentDisposition$1;
26
+ contentDisposition.exports.parse = parse;
27
+
28
+ /**
29
+ * Module dependencies.
30
+ * @private
31
+ */
32
+
33
+ var basename = require$$4.basename;
34
+ var Buffer = safeBuffer.requireSafeBuffer().Buffer;
35
+
36
+ /**
37
+ * RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
38
+ * @private
39
+ */
40
+
41
+ var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g; // eslint-disable-line no-control-regex
42
+
43
+ /**
44
+ * RegExp to match percent encoding escape.
45
+ * @private
46
+ */
47
+
48
+ var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
49
+ var HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g;
50
+
51
+ /**
52
+ * RegExp to match non-latin1 characters.
53
+ * @private
54
+ */
55
+
56
+ var NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g;
57
+
58
+ /**
59
+ * RegExp to match quoted-pair in RFC 2616
60
+ *
61
+ * quoted-pair = "\" CHAR
62
+ * CHAR = <any US-ASCII character (octets 0 - 127)>
63
+ * @private
64
+ */
65
+
66
+ var QESC_REGEXP = /\\([\u0000-\u007f])/g; // eslint-disable-line no-control-regex
67
+
68
+ /**
69
+ * RegExp to match chars that must be quoted-pair in RFC 2616
70
+ * @private
71
+ */
72
+
73
+ var QUOTE_REGEXP = /([\\"])/g;
74
+
75
+ /**
76
+ * RegExp for various RFC 2616 grammar
77
+ *
78
+ * parameter = token "=" ( token | quoted-string )
79
+ * token = 1*<any CHAR except CTLs or separators>
80
+ * separators = "(" | ")" | "<" | ">" | "@"
81
+ * | "," | ";" | ":" | "\" | <">
82
+ * | "/" | "[" | "]" | "?" | "="
83
+ * | "{" | "}" | SP | HT
84
+ * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
85
+ * qdtext = <any TEXT except <">>
86
+ * quoted-pair = "\" CHAR
87
+ * CHAR = <any US-ASCII character (octets 0 - 127)>
88
+ * TEXT = <any OCTET except CTLs, but including LWS>
89
+ * LWS = [CRLF] 1*( SP | HT )
90
+ * CRLF = CR LF
91
+ * CR = <US-ASCII CR, carriage return (13)>
92
+ * LF = <US-ASCII LF, linefeed (10)>
93
+ * SP = <US-ASCII SP, space (32)>
94
+ * HT = <US-ASCII HT, horizontal-tab (9)>
95
+ * CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
96
+ * OCTET = <any 8-bit sequence of data>
97
+ * @private
98
+ */
99
+
100
+ var PARAM_REGEXP = /;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g; // eslint-disable-line no-control-regex
101
+ var TEXT_REGEXP = /^[\x20-\x7e\x80-\xff]+$/;
102
+ var TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/;
103
+
104
+ /**
105
+ * RegExp for various RFC 5987 grammar
106
+ *
107
+ * ext-value = charset "'" [ language ] "'" value-chars
108
+ * charset = "UTF-8" / "ISO-8859-1" / mime-charset
109
+ * mime-charset = 1*mime-charsetc
110
+ * mime-charsetc = ALPHA / DIGIT
111
+ * / "!" / "#" / "$" / "%" / "&"
112
+ * / "+" / "-" / "^" / "_" / "`"
113
+ * / "{" / "}" / "~"
114
+ * language = ( 2*3ALPHA [ extlang ] )
115
+ * / 4ALPHA
116
+ * / 5*8ALPHA
117
+ * extlang = *3( "-" 3ALPHA )
118
+ * value-chars = *( pct-encoded / attr-char )
119
+ * pct-encoded = "%" HEXDIG HEXDIG
120
+ * attr-char = ALPHA / DIGIT
121
+ * / "!" / "#" / "$" / "&" / "+" / "-" / "."
122
+ * / "^" / "_" / "`" / "|" / "~"
123
+ * @private
124
+ */
125
+
126
+ var EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/;
127
+
128
+ /**
129
+ * RegExp for various RFC 6266 grammar
130
+ *
131
+ * disposition-type = "inline" | "attachment" | disp-ext-type
132
+ * disp-ext-type = token
133
+ * disposition-parm = filename-parm | disp-ext-parm
134
+ * filename-parm = "filename" "=" value
135
+ * | "filename*" "=" ext-value
136
+ * disp-ext-parm = token "=" value
137
+ * | ext-token "=" ext-value
138
+ * ext-token = <the characters in token, followed by "*">
139
+ * @private
140
+ */
141
+
142
+ var DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/; // eslint-disable-line no-control-regex
143
+
144
+ /**
145
+ * Create an attachment Content-Disposition header.
146
+ *
147
+ * @param {string} [filename]
148
+ * @param {object} [options]
149
+ * @param {string} [options.type=attachment]
150
+ * @param {string|boolean} [options.fallback=true]
151
+ * @return {string}
152
+ * @public
153
+ */
154
+
155
+ function contentDisposition$1 (filename, options) {
156
+ var opts = options || {};
157
+
158
+ // get type
159
+ var type = opts.type || 'attachment';
160
+
161
+ // get parameters
162
+ var params = createparams(filename, opts.fallback);
163
+
164
+ // format into string
165
+ return format(new ContentDisposition(type, params))
166
+ }
167
+
168
+ /**
169
+ * Create parameters object from filename and fallback.
170
+ *
171
+ * @param {string} [filename]
172
+ * @param {string|boolean} [fallback=true]
173
+ * @return {object}
174
+ * @private
175
+ */
176
+
177
+ function createparams (filename, fallback) {
178
+ if (filename === undefined) {
179
+ return
180
+ }
181
+
182
+ var params = {};
183
+
184
+ if (typeof filename !== 'string') {
185
+ throw new TypeError('filename must be a string')
186
+ }
187
+
188
+ // fallback defaults to true
189
+ if (fallback === undefined) {
190
+ fallback = true;
191
+ }
192
+
193
+ if (typeof fallback !== 'string' && typeof fallback !== 'boolean') {
194
+ throw new TypeError('fallback must be a string or boolean')
195
+ }
196
+
197
+ if (typeof fallback === 'string' && NON_LATIN1_REGEXP.test(fallback)) {
198
+ throw new TypeError('fallback must be ISO-8859-1 string')
199
+ }
200
+
201
+ // restrict to file base name
202
+ var name = basename(filename);
203
+
204
+ // determine if name is suitable for quoted string
205
+ var isQuotedString = TEXT_REGEXP.test(name);
206
+
207
+ // generate fallback name
208
+ var fallbackName = typeof fallback !== 'string'
209
+ ? fallback && getlatin1(name)
210
+ : basename(fallback);
211
+ var hasFallback = typeof fallbackName === 'string' && fallbackName !== name;
212
+
213
+ // set extended filename parameter
214
+ if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
215
+ params['filename*'] = name;
216
+ }
217
+
218
+ // set filename parameter
219
+ if (isQuotedString || hasFallback) {
220
+ params.filename = hasFallback
221
+ ? fallbackName
222
+ : name;
223
+ }
224
+
225
+ return params
226
+ }
227
+
228
+ /**
229
+ * Format object to Content-Disposition header.
230
+ *
231
+ * @param {object} obj
232
+ * @param {string} obj.type
233
+ * @param {object} [obj.parameters]
234
+ * @return {string}
235
+ * @private
236
+ */
237
+
238
+ function format (obj) {
239
+ var parameters = obj.parameters;
240
+ var type = obj.type;
241
+
242
+ if (!type || typeof type !== 'string' || !TOKEN_REGEXP.test(type)) {
243
+ throw new TypeError('invalid type')
244
+ }
245
+
246
+ // start with normalized type
247
+ var string = String(type).toLowerCase();
248
+
249
+ // append parameters
250
+ if (parameters && typeof parameters === 'object') {
251
+ var param;
252
+ var params = Object.keys(parameters).sort();
253
+
254
+ for (var i = 0; i < params.length; i++) {
255
+ param = params[i];
256
+
257
+ var val = param.substr(-1) === '*'
258
+ ? ustring(parameters[param])
259
+ : qstring(parameters[param]);
260
+
261
+ string += '; ' + param + '=' + val;
262
+ }
263
+ }
264
+
265
+ return string
266
+ }
267
+
268
+ /**
269
+ * Decode a RFC 5987 field value (gracefully).
270
+ *
271
+ * @param {string} str
272
+ * @return {string}
273
+ * @private
274
+ */
275
+
276
+ function decodefield (str) {
277
+ var match = EXT_VALUE_REGEXP.exec(str);
278
+
279
+ if (!match) {
280
+ throw new TypeError('invalid extended field value')
281
+ }
282
+
283
+ var charset = match[1].toLowerCase();
284
+ var encoded = match[2];
285
+ var value;
286
+
287
+ // to binary string
288
+ var binary = encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode);
289
+
290
+ switch (charset) {
291
+ case 'iso-8859-1':
292
+ value = getlatin1(binary);
293
+ break
294
+ case 'utf-8':
295
+ value = Buffer.from(binary, 'binary').toString('utf8');
296
+ break
297
+ default:
298
+ throw new TypeError('unsupported charset in extended field')
299
+ }
300
+
301
+ return value
302
+ }
303
+
304
+ /**
305
+ * Get ISO-8859-1 version of string.
306
+ *
307
+ * @param {string} val
308
+ * @return {string}
309
+ * @private
310
+ */
311
+
312
+ function getlatin1 (val) {
313
+ // simple Unicode -> ISO-8859-1 transformation
314
+ return String(val).replace(NON_LATIN1_REGEXP, '?')
315
+ }
316
+
317
+ /**
318
+ * Parse Content-Disposition header string.
319
+ *
320
+ * @param {string} string
321
+ * @return {object}
322
+ * @public
323
+ */
324
+
325
+ function parse (string) {
326
+ if (!string || typeof string !== 'string') {
327
+ throw new TypeError('argument string is required')
328
+ }
329
+
330
+ var match = DISPOSITION_TYPE_REGEXP.exec(string);
331
+
332
+ if (!match) {
333
+ throw new TypeError('invalid type format')
334
+ }
335
+
336
+ // normalize type
337
+ var index = match[0].length;
338
+ var type = match[1].toLowerCase();
339
+
340
+ var key;
341
+ var names = [];
342
+ var params = {};
343
+ var value;
344
+
345
+ // calculate index to start at
346
+ index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ';'
347
+ ? index - 1
348
+ : index;
349
+
350
+ // match parameters
351
+ while ((match = PARAM_REGEXP.exec(string))) {
352
+ if (match.index !== index) {
353
+ throw new TypeError('invalid parameter format')
354
+ }
355
+
356
+ index += match[0].length;
357
+ key = match[1].toLowerCase();
358
+ value = match[2];
359
+
360
+ if (names.indexOf(key) !== -1) {
361
+ throw new TypeError('invalid duplicate parameter')
362
+ }
363
+
364
+ names.push(key);
365
+
366
+ if (key.indexOf('*') + 1 === key.length) {
367
+ // decode extended value
368
+ key = key.slice(0, -1);
369
+ value = decodefield(value);
370
+
371
+ // overwrite existing value
372
+ params[key] = value;
373
+ continue
374
+ }
375
+
376
+ if (typeof params[key] === 'string') {
377
+ continue
378
+ }
379
+
380
+ if (value[0] === '"') {
381
+ // remove quotes and escapes
382
+ value = value
383
+ .substr(1, value.length - 2)
384
+ .replace(QESC_REGEXP, '$1');
385
+ }
386
+
387
+ params[key] = value;
388
+ }
389
+
390
+ if (index !== -1 && index !== string.length) {
391
+ throw new TypeError('invalid parameter format')
392
+ }
393
+
394
+ return new ContentDisposition(type, params)
395
+ }
396
+
397
+ /**
398
+ * Percent decode a single character.
399
+ *
400
+ * @param {string} str
401
+ * @param {string} hex
402
+ * @return {string}
403
+ * @private
404
+ */
405
+
406
+ function pdecode (str, hex) {
407
+ return String.fromCharCode(parseInt(hex, 16))
408
+ }
409
+
410
+ /**
411
+ * Percent encode a single character.
412
+ *
413
+ * @param {string} char
414
+ * @return {string}
415
+ * @private
416
+ */
417
+
418
+ function pencode (char) {
419
+ return '%' + String(char)
420
+ .charCodeAt(0)
421
+ .toString(16)
422
+ .toUpperCase()
423
+ }
424
+
425
+ /**
426
+ * Quote a string for HTTP.
427
+ *
428
+ * @param {string} val
429
+ * @return {string}
430
+ * @private
431
+ */
432
+
433
+ function qstring (val) {
434
+ var str = String(val);
435
+
436
+ return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
437
+ }
438
+
439
+ /**
440
+ * Encode a Unicode string for HTTP (RFC 5987).
441
+ *
442
+ * @param {string} val
443
+ * @return {string}
444
+ * @private
445
+ */
446
+
447
+ function ustring (val) {
448
+ var str = String(val);
449
+
450
+ // percent encode as UTF-8
451
+ var encoded = encodeURIComponent(str)
452
+ .replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode);
453
+
454
+ return 'UTF-8\'\'' + encoded
455
+ }
456
+
457
+ /**
458
+ * Class for parsed Content-Disposition header for v8 optimization
459
+ *
460
+ * @public
461
+ * @param {string} type
462
+ * @param {object} parameters
463
+ * @constructor
464
+ */
465
+
466
+ function ContentDisposition (type, parameters) {
467
+ this.type = type;
468
+ this.parameters = parameters;
469
+ }
470
+ return contentDisposition.exports;
471
+ }
472
+
473
+ exports.requireContentDisposition = requireContentDisposition;
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('crypto-browserify');
4
+
5
+ var cookieSignature = {};
6
+
7
+ /**
8
+ * Module dependencies.
9
+ */
10
+
11
+ var hasRequiredCookieSignature;
12
+
13
+ function requireCookieSignature () {
14
+ if (hasRequiredCookieSignature) return cookieSignature;
15
+ hasRequiredCookieSignature = 1;
16
+ (function (exports) {
17
+ var crypto = require$$0;
18
+
19
+ /**
20
+ * Sign the given `val` with `secret`.
21
+ *
22
+ * @param {String} val
23
+ * @param {String} secret
24
+ * @return {String}
25
+ * @api private
26
+ */
27
+
28
+ exports.sign = function(val, secret){
29
+ if ('string' != typeof val) throw new TypeError("Cookie value must be provided as a string.");
30
+ if ('string' != typeof secret) throw new TypeError("Secret string must be provided.");
31
+ return val + '.' + crypto
32
+ .createHmac('sha256', secret)
33
+ .update(val)
34
+ .digest('base64')
35
+ .replace(/\=+$/, '');
36
+ };
37
+
38
+ /**
39
+ * Unsign and decode the given `val` with `secret`,
40
+ * returning `false` if the signature is invalid.
41
+ *
42
+ * @param {String} val
43
+ * @param {String} secret
44
+ * @return {String|Boolean}
45
+ * @api private
46
+ */
47
+
48
+ exports.unsign = function(val, secret){
49
+ if ('string' != typeof val) throw new TypeError("Signed cookie string must be provided.");
50
+ if ('string' != typeof secret) throw new TypeError("Secret string must be provided.");
51
+ var str = val.slice(0, val.lastIndexOf('.'))
52
+ , mac = exports.sign(str, secret);
53
+
54
+ return sha1(mac) == sha1(val) ? str : false;
55
+ };
56
+
57
+ /**
58
+ * Private
59
+ */
60
+
61
+ function sha1(str){
62
+ return crypto.createHash('sha1').update(str).digest('hex');
63
+ }
64
+ } (cookieSignature));
65
+ return cookieSignature;
66
+ }
67
+
68
+ exports.requireCookieSignature = requireCookieSignature;