-
-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathoptions.js
137 lines (133 loc) · 4.05 KB
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
const optionKindMap = {
dataCallback: ['READFUNCTION', 'HEADERFUNCTION', 'WRITEFUNCTION'],
progressCallback: ['PROGRESSFUNCTION', 'XFERINFOFUNCTION'],
stringList: [
'CONNECT_TO',
'HTTP200ALIASES',
'HTTPHEADER',
'MAIL_RCPT',
'PROXYHEADER',
'POSTQUOTE',
'PREQUOTE',
'QUOTE',
'RESOLVE',
'TELNETOPTIONS',
],
blob: [
'CAINFO_BLOB',
'ISSUERCERT_BLOB',
'SSLKEY_BLOB',
'SSLCERT_BLOB',
'PROXY_CAINFO_BLOB',
'PROXY_SSLCERT_BLOB',
'PROXY_SSLCERT',
'PROXY_SSLKEY_BLOB',
],
other: [
'CHUNK_BGN_FUNCTION',
'CHUNK_END_FUNCTION',
'DEBUGFUNCTION',
'FNMATCH_FUNCTION',
'HSTSREADFUNCTION',
'HSTSWRITEFUNCTION',
'PREREQFUNCTION',
'SEEKFUNCTION',
'TRAILERFUNCTION',
'SHARE',
'HTTPPOST',
// enums
'FTP_SSL_CCC',
'FTP_FILEMETHOD',
'GSSAPI_DELEGATION',
'HEADEROPT',
'HTTP_VERSION',
'IPRESOLVE',
'NETRC',
'PROTOCOLS',
'PROXY_SSL_OPTIONS',
'PROXYTYPE',
'REDIR_PROTOCOLS',
'RTSP_REQUEST',
'SSH_AUTH_TYPES',
'SSL_OPTIONS',
'SSLVERSION',
'TIMECONDITION',
'USE_SSL',
'HSTS_CTRL',
// @TODO ADD REMAINING OPTIONS WE HAVE ENUM FOR
],
}
const optionKindValueMap = {
dataCallback:
'((this: EasyNativeBinding, data: Buffer, size: number, nmemb: number) => number)',
progressCallback:
'((this: EasyNativeBinding, dltotal: number,dlnow: number,ultotal: number,ulnow: number) => number | CurlProgressFunc)',
stringList: 'string[]',
blob: 'ArrayBuffer | Buffer | string',
/* @TODO Add type definitions, they are on Curl.chunk */
CHUNK_BGN_FUNCTION:
'((this: EasyNativeBinding, fileInfo: FileInfo, remains: number) => CurlChunk)',
/* @TODO Add type definitions, they are on Curl.chunk */
CHUNK_END_FUNCTION: '((this: EasyNativeBinding) => CurlChunk)',
/* @TODO Add type definitions, they are on Curl.info.debug */
DEBUGFUNCTION:
'((this: EasyNativeBinding, type: CurlInfoDebug, data: Buffer) => 0)',
/* @TODO Add type definitions, they are on Curl.fnmatchfunc */
FNMATCH_FUNCTION:
'((this: EasyNativeBinding, pattern: string, value: string) => CurlFnMatchFunc)',
HSTSREADFUNCTION:
'((this: EasyNativeBinding) => null | CurlHstsCacheEntry | CurlHstsCacheEntry[])',
HSTSWRITEFUNCTION:
'((this: EasyNativeBinding, cacheEntry: CurlHstsCacheEntry, cacheCount: CurlHstsCacheCount) => any)',
PREREQFUNCTION:
'((this: EasyNativeBinding, connPrimaryIp: string, connLocalIp: string, connPrimaryPort: number, conLocalPort: number) => CurlPreReqFunc)',
HTTPPOST: 'HttpPostField[]',
TRAILERFUNCTION: '((this: EasyNativeBinding) => string[] | false)',
/* @TODO Add CURL_SEEKFUNC_* type definitions */
SEEKFUNCTION:
'((this: EasyNativeBinding, offset: number, origin: number) => number)',
SHARE: 'Share',
// enums
FTP_SSL_CCC: 'CurlFtpSsl',
FTP_FILEMETHOD: 'CurlFtpMethod',
GSSAPI_DELEGATION: 'CurlGssApi',
HEADEROPT: 'CurlHeader',
HTTP_VERSION: 'CurlHttpVersion',
IPRESOLVE: 'CurlIpResolve',
NETRC: 'CurlNetrc',
PROTOCOLS: 'CurlProtocol',
PROXY_SSL_OPTIONS: 'CurlSslOpt',
PROXYTYPE: 'CurlProxy',
REDIR_PROTOCOLS: 'CurlProtocol',
RTSP_REQUEST: 'CurlRtspRequest',
SSH_AUTH_TYPES: 'CurlSshAuth',
SSL_OPTIONS: 'CurlSslOpt',
SSLVERSION: 'CurlSslVersion',
TIMECONDITION: 'CurlTimeCond',
USE_SSL: 'CurlUseSsl',
HSTS_CTRL: 'CurlHsts',
_: 'string | number | boolean',
}
const optionExtraDescriptionValueMap = Object.fromEntries(
Object.entries({
HSTSREADFUNCTION: [
'',
'You can either return a single `CurlHstsReadCallbackResult` object or an array of `CurlHstsReadCallbackResult` objects.',
'If returning an array, the callback will only be called once per request.',
'If returning a single object, the callback will be called multiple times until `null` is returned.',
],
}).map(([key, value]) => {
return [
key,
`\n*\n${(Array.isArray(value)
? value.join('\n * ')
: `* ${value}`
).trim()}`,
]
}),
)
module.exports = {
optionKindMap,
optionKindValueMap,
optionExtraDescriptionValueMap,
}