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