@opra/client 0.16.2 → 0.17.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.
@@ -0,0 +1,470 @@
1
+ import path from 'path-browserify';
2
+ import { s as safeBufferExports } from './safe-buffer-63383356.js';
3
+
4
+ function getDefaultExportFromCjs (x) {
5
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6
+ }
7
+
8
+ var contentDisposition$2 = {exports: {}};
9
+
10
+ /*!
11
+ * content-disposition
12
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
13
+ * MIT Licensed
14
+ */
15
+
16
+ /**
17
+ * Module exports.
18
+ * @public
19
+ */
20
+
21
+ contentDisposition$2.exports = contentDisposition;
22
+ contentDisposition$2.exports.parse = parse;
23
+
24
+ /**
25
+ * Module dependencies.
26
+ * @private
27
+ */
28
+
29
+ var basename = path.basename;
30
+ var Buffer = safeBufferExports.Buffer;
31
+
32
+ /**
33
+ * RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
34
+ * @private
35
+ */
36
+
37
+ var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g; // eslint-disable-line no-control-regex
38
+
39
+ /**
40
+ * RegExp to match percent encoding escape.
41
+ * @private
42
+ */
43
+
44
+ var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
45
+ var HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g;
46
+
47
+ /**
48
+ * RegExp to match non-latin1 characters.
49
+ * @private
50
+ */
51
+
52
+ var NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g;
53
+
54
+ /**
55
+ * RegExp to match quoted-pair in RFC 2616
56
+ *
57
+ * quoted-pair = "\" CHAR
58
+ * CHAR = <any US-ASCII character (octets 0 - 127)>
59
+ * @private
60
+ */
61
+
62
+ var QESC_REGEXP = /\\([\u0000-\u007f])/g; // eslint-disable-line no-control-regex
63
+
64
+ /**
65
+ * RegExp to match chars that must be quoted-pair in RFC 2616
66
+ * @private
67
+ */
68
+
69
+ var QUOTE_REGEXP = /([\\"])/g;
70
+
71
+ /**
72
+ * RegExp for various RFC 2616 grammar
73
+ *
74
+ * parameter = token "=" ( token | quoted-string )
75
+ * token = 1*<any CHAR except CTLs or separators>
76
+ * separators = "(" | ")" | "<" | ">" | "@"
77
+ * | "," | ";" | ":" | "\" | <">
78
+ * | "/" | "[" | "]" | "?" | "="
79
+ * | "{" | "}" | SP | HT
80
+ * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
81
+ * qdtext = <any TEXT except <">>
82
+ * quoted-pair = "\" CHAR
83
+ * CHAR = <any US-ASCII character (octets 0 - 127)>
84
+ * TEXT = <any OCTET except CTLs, but including LWS>
85
+ * LWS = [CRLF] 1*( SP | HT )
86
+ * CRLF = CR LF
87
+ * CR = <US-ASCII CR, carriage return (13)>
88
+ * LF = <US-ASCII LF, linefeed (10)>
89
+ * SP = <US-ASCII SP, space (32)>
90
+ * HT = <US-ASCII HT, horizontal-tab (9)>
91
+ * CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
92
+ * OCTET = <any 8-bit sequence of data>
93
+ * @private
94
+ */
95
+
96
+ 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
97
+ var TEXT_REGEXP = /^[\x20-\x7e\x80-\xff]+$/;
98
+ var TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/;
99
+
100
+ /**
101
+ * RegExp for various RFC 5987 grammar
102
+ *
103
+ * ext-value = charset "'" [ language ] "'" value-chars
104
+ * charset = "UTF-8" / "ISO-8859-1" / mime-charset
105
+ * mime-charset = 1*mime-charsetc
106
+ * mime-charsetc = ALPHA / DIGIT
107
+ * / "!" / "#" / "$" / "%" / "&"
108
+ * / "+" / "-" / "^" / "_" / "`"
109
+ * / "{" / "}" / "~"
110
+ * language = ( 2*3ALPHA [ extlang ] )
111
+ * / 4ALPHA
112
+ * / 5*8ALPHA
113
+ * extlang = *3( "-" 3ALPHA )
114
+ * value-chars = *( pct-encoded / attr-char )
115
+ * pct-encoded = "%" HEXDIG HEXDIG
116
+ * attr-char = ALPHA / DIGIT
117
+ * / "!" / "#" / "$" / "&" / "+" / "-" / "."
118
+ * / "^" / "_" / "`" / "|" / "~"
119
+ * @private
120
+ */
121
+
122
+ 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!#$&+.^_`|~-])+)$/;
123
+
124
+ /**
125
+ * RegExp for various RFC 6266 grammar
126
+ *
127
+ * disposition-type = "inline" | "attachment" | disp-ext-type
128
+ * disp-ext-type = token
129
+ * disposition-parm = filename-parm | disp-ext-parm
130
+ * filename-parm = "filename" "=" value
131
+ * | "filename*" "=" ext-value
132
+ * disp-ext-parm = token "=" value
133
+ * | ext-token "=" ext-value
134
+ * ext-token = <the characters in token, followed by "*">
135
+ * @private
136
+ */
137
+
138
+ var DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/; // eslint-disable-line no-control-regex
139
+
140
+ /**
141
+ * Create an attachment Content-Disposition header.
142
+ *
143
+ * @param {string} [filename]
144
+ * @param {object} [options]
145
+ * @param {string} [options.type=attachment]
146
+ * @param {string|boolean} [options.fallback=true]
147
+ * @return {string}
148
+ * @public
149
+ */
150
+
151
+ function contentDisposition (filename, options) {
152
+ var opts = options || {};
153
+
154
+ // get type
155
+ var type = opts.type || 'attachment';
156
+
157
+ // get parameters
158
+ var params = createparams(filename, opts.fallback);
159
+
160
+ // format into string
161
+ return format(new ContentDisposition(type, params))
162
+ }
163
+
164
+ /**
165
+ * Create parameters object from filename and fallback.
166
+ *
167
+ * @param {string} [filename]
168
+ * @param {string|boolean} [fallback=true]
169
+ * @return {object}
170
+ * @private
171
+ */
172
+
173
+ function createparams (filename, fallback) {
174
+ if (filename === undefined) {
175
+ return
176
+ }
177
+
178
+ var params = {};
179
+
180
+ if (typeof filename !== 'string') {
181
+ throw new TypeError('filename must be a string')
182
+ }
183
+
184
+ // fallback defaults to true
185
+ if (fallback === undefined) {
186
+ fallback = true;
187
+ }
188
+
189
+ if (typeof fallback !== 'string' && typeof fallback !== 'boolean') {
190
+ throw new TypeError('fallback must be a string or boolean')
191
+ }
192
+
193
+ if (typeof fallback === 'string' && NON_LATIN1_REGEXP.test(fallback)) {
194
+ throw new TypeError('fallback must be ISO-8859-1 string')
195
+ }
196
+
197
+ // restrict to file base name
198
+ var name = basename(filename);
199
+
200
+ // determine if name is suitable for quoted string
201
+ var isQuotedString = TEXT_REGEXP.test(name);
202
+
203
+ // generate fallback name
204
+ var fallbackName = typeof fallback !== 'string'
205
+ ? fallback && getlatin1(name)
206
+ : basename(fallback);
207
+ var hasFallback = typeof fallbackName === 'string' && fallbackName !== name;
208
+
209
+ // set extended filename parameter
210
+ if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
211
+ params['filename*'] = name;
212
+ }
213
+
214
+ // set filename parameter
215
+ if (isQuotedString || hasFallback) {
216
+ params.filename = hasFallback
217
+ ? fallbackName
218
+ : name;
219
+ }
220
+
221
+ return params
222
+ }
223
+
224
+ /**
225
+ * Format object to Content-Disposition header.
226
+ *
227
+ * @param {object} obj
228
+ * @param {string} obj.type
229
+ * @param {object} [obj.parameters]
230
+ * @return {string}
231
+ * @private
232
+ */
233
+
234
+ function format (obj) {
235
+ var parameters = obj.parameters;
236
+ var type = obj.type;
237
+
238
+ if (!type || typeof type !== 'string' || !TOKEN_REGEXP.test(type)) {
239
+ throw new TypeError('invalid type')
240
+ }
241
+
242
+ // start with normalized type
243
+ var string = String(type).toLowerCase();
244
+
245
+ // append parameters
246
+ if (parameters && typeof parameters === 'object') {
247
+ var param;
248
+ var params = Object.keys(parameters).sort();
249
+
250
+ for (var i = 0; i < params.length; i++) {
251
+ param = params[i];
252
+
253
+ var val = param.substr(-1) === '*'
254
+ ? ustring(parameters[param])
255
+ : qstring(parameters[param]);
256
+
257
+ string += '; ' + param + '=' + val;
258
+ }
259
+ }
260
+
261
+ return string
262
+ }
263
+
264
+ /**
265
+ * Decode a RFC 5987 field value (gracefully).
266
+ *
267
+ * @param {string} str
268
+ * @return {string}
269
+ * @private
270
+ */
271
+
272
+ function decodefield (str) {
273
+ var match = EXT_VALUE_REGEXP.exec(str);
274
+
275
+ if (!match) {
276
+ throw new TypeError('invalid extended field value')
277
+ }
278
+
279
+ var charset = match[1].toLowerCase();
280
+ var encoded = match[2];
281
+ var value;
282
+
283
+ // to binary string
284
+ var binary = encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode);
285
+
286
+ switch (charset) {
287
+ case 'iso-8859-1':
288
+ value = getlatin1(binary);
289
+ break
290
+ case 'utf-8':
291
+ value = Buffer.from(binary, 'binary').toString('utf8');
292
+ break
293
+ default:
294
+ throw new TypeError('unsupported charset in extended field')
295
+ }
296
+
297
+ return value
298
+ }
299
+
300
+ /**
301
+ * Get ISO-8859-1 version of string.
302
+ *
303
+ * @param {string} val
304
+ * @return {string}
305
+ * @private
306
+ */
307
+
308
+ function getlatin1 (val) {
309
+ // simple Unicode -> ISO-8859-1 transformation
310
+ return String(val).replace(NON_LATIN1_REGEXP, '?')
311
+ }
312
+
313
+ /**
314
+ * Parse Content-Disposition header string.
315
+ *
316
+ * @param {string} string
317
+ * @return {object}
318
+ * @public
319
+ */
320
+
321
+ function parse (string) {
322
+ if (!string || typeof string !== 'string') {
323
+ throw new TypeError('argument string is required')
324
+ }
325
+
326
+ var match = DISPOSITION_TYPE_REGEXP.exec(string);
327
+
328
+ if (!match) {
329
+ throw new TypeError('invalid type format')
330
+ }
331
+
332
+ // normalize type
333
+ var index = match[0].length;
334
+ var type = match[1].toLowerCase();
335
+
336
+ var key;
337
+ var names = [];
338
+ var params = {};
339
+ var value;
340
+
341
+ // calculate index to start at
342
+ index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ';'
343
+ ? index - 1
344
+ : index;
345
+
346
+ // match parameters
347
+ while ((match = PARAM_REGEXP.exec(string))) {
348
+ if (match.index !== index) {
349
+ throw new TypeError('invalid parameter format')
350
+ }
351
+
352
+ index += match[0].length;
353
+ key = match[1].toLowerCase();
354
+ value = match[2];
355
+
356
+ if (names.indexOf(key) !== -1) {
357
+ throw new TypeError('invalid duplicate parameter')
358
+ }
359
+
360
+ names.push(key);
361
+
362
+ if (key.indexOf('*') + 1 === key.length) {
363
+ // decode extended value
364
+ key = key.slice(0, -1);
365
+ value = decodefield(value);
366
+
367
+ // overwrite existing value
368
+ params[key] = value;
369
+ continue
370
+ }
371
+
372
+ if (typeof params[key] === 'string') {
373
+ continue
374
+ }
375
+
376
+ if (value[0] === '"') {
377
+ // remove quotes and escapes
378
+ value = value
379
+ .substr(1, value.length - 2)
380
+ .replace(QESC_REGEXP, '$1');
381
+ }
382
+
383
+ params[key] = value;
384
+ }
385
+
386
+ if (index !== -1 && index !== string.length) {
387
+ throw new TypeError('invalid parameter format')
388
+ }
389
+
390
+ return new ContentDisposition(type, params)
391
+ }
392
+
393
+ /**
394
+ * Percent decode a single character.
395
+ *
396
+ * @param {string} str
397
+ * @param {string} hex
398
+ * @return {string}
399
+ * @private
400
+ */
401
+
402
+ function pdecode (str, hex) {
403
+ return String.fromCharCode(parseInt(hex, 16))
404
+ }
405
+
406
+ /**
407
+ * Percent encode a single character.
408
+ *
409
+ * @param {string} char
410
+ * @return {string}
411
+ * @private
412
+ */
413
+
414
+ function pencode (char) {
415
+ return '%' + String(char)
416
+ .charCodeAt(0)
417
+ .toString(16)
418
+ .toUpperCase()
419
+ }
420
+
421
+ /**
422
+ * Quote a string for HTTP.
423
+ *
424
+ * @param {string} val
425
+ * @return {string}
426
+ * @private
427
+ */
428
+
429
+ function qstring (val) {
430
+ var str = String(val);
431
+
432
+ return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
433
+ }
434
+
435
+ /**
436
+ * Encode a Unicode string for HTTP (RFC 5987).
437
+ *
438
+ * @param {string} val
439
+ * @return {string}
440
+ * @private
441
+ */
442
+
443
+ function ustring (val) {
444
+ var str = String(val);
445
+
446
+ // percent encode as UTF-8
447
+ var encoded = encodeURIComponent(str)
448
+ .replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode);
449
+
450
+ return 'UTF-8\'\'' + encoded
451
+ }
452
+
453
+ /**
454
+ * Class for parsed Content-Disposition header for v8 optimization
455
+ *
456
+ * @public
457
+ * @param {string} type
458
+ * @param {object} parameters
459
+ * @constructor
460
+ */
461
+
462
+ function ContentDisposition (type, parameters) {
463
+ this.type = type;
464
+ this.parameters = parameters;
465
+ }
466
+
467
+ var contentDispositionExports = contentDisposition$2.exports;
468
+ var contentDisposition$1 = /*@__PURE__*/getDefaultExportFromCjs(contentDispositionExports);
469
+
470
+ export { contentDisposition$1 as c, getDefaultExportFromCjs as g };
@@ -0,0 +1,62 @@
1
+ import require$$0 from 'crypto-browserify';
2
+ import { g as getDefaultExportFromCjs } from './content-disposition-65f281a9.js';
3
+
4
+ var cookieSignature$1 = {};
5
+
6
+ /**
7
+ * Module dependencies.
8
+ */
9
+
10
+ (function (exports) {
11
+ var crypto = require$$0;
12
+
13
+ /**
14
+ * Sign the given `val` with `secret`.
15
+ *
16
+ * @param {String} val
17
+ * @param {String} secret
18
+ * @return {String}
19
+ * @api private
20
+ */
21
+
22
+ exports.sign = function(val, secret){
23
+ if ('string' != typeof val) throw new TypeError("Cookie value must be provided as a string.");
24
+ if ('string' != typeof secret) throw new TypeError("Secret string must be provided.");
25
+ return val + '.' + crypto
26
+ .createHmac('sha256', secret)
27
+ .update(val)
28
+ .digest('base64')
29
+ .replace(/\=+$/, '');
30
+ };
31
+
32
+ /**
33
+ * Unsign and decode the given `val` with `secret`,
34
+ * returning `false` if the signature is invalid.
35
+ *
36
+ * @param {String} val
37
+ * @param {String} secret
38
+ * @return {String|Boolean}
39
+ * @api private
40
+ */
41
+
42
+ exports.unsign = function(val, secret){
43
+ if ('string' != typeof val) throw new TypeError("Signed cookie string must be provided.");
44
+ if ('string' != typeof secret) throw new TypeError("Secret string must be provided.");
45
+ var str = val.slice(0, val.lastIndexOf('.'))
46
+ , mac = exports.sign(str, secret);
47
+
48
+ return sha1(mac) == sha1(val) ? str : false;
49
+ };
50
+
51
+ /**
52
+ * Private
53
+ */
54
+
55
+ function sha1(str){
56
+ return crypto.createHash('sha1').update(str).digest('hex');
57
+ }
58
+ } (cookieSignature$1));
59
+
60
+ var cookieSignature = /*@__PURE__*/getDefaultExportFromCjs(cookieSignature$1);
61
+
62
+ export { cookieSignature as c };