-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathoptions.js
More file actions
327 lines (324 loc) · 7.38 KB
/
options.js
File metadata and controls
327 lines (324 loc) · 7.38 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
const fs = require('fs')
const path = require('path')
const validUrl = require('valid-url')
module.exports = [
// {
// abbr: 'v',
// flag: true,
// help: 'Print the logs to console\n'
// },
{
name: 'root',
help: "Root folder to serve (default: './data')",
question: 'Path to the folder you want to serve. Default is',
default: './data',
prompt: true,
filter: (value) => path.resolve(value)
},
{
name: 'port',
help: 'SSL port to use',
question: 'SSL port to run on. Default is',
default: '8443',
prompt: true
},
{
name: 'serverUri',
question: 'Solid server uri (with protocol, hostname and port)',
help: "Solid server uri (default: 'https://localhost:8443')",
default: 'https://localhost:8443',
validate: validUri,
prompt: true
},
{
name: 'webid',
help: 'Enable WebID authentication and access control (uses HTTPS)',
flag: true,
default: true,
question: 'Enable WebID authentication',
prompt: true
},
{
name: 'mount',
help: "Serve on a specific URL path (default: '/')",
question: 'Serve Solid on URL path',
default: '/',
prompt: true
},
{
name: 'config-path',
question: 'Path to the config directory (for example: /etc/solid-server)',
default: './config',
prompt: true
},
{
name: 'db-path',
question: 'Path to the server metadata db directory (for users/apps etc)',
default: './.db',
prompt: true
},
{
name: 'auth',
help: 'Pick an authentication strategy for WebID: `tls` or `oidc`',
question: 'Select authentication strategy',
type: 'list',
choices: [
'WebID-OpenID Connect'
],
prompt: false,
default: 'WebID-OpenID Connect',
filter: (value) => {
if (value === 'WebID-OpenID Connect') return 'oidc'
},
when: (answers) => {
return answers.webid
}
},
{
name: 'certificate-header',
question: 'Accept client certificates through this HTTP header (for reverse proxies)',
default: '',
prompt: false
},
{
name: 'useOwner',
question: 'Do you already have a WebID?',
type: 'confirm',
default: false,
hide: true
},
{
name: 'owner',
help: 'Set the owner of the storage (overwrites the root ACL file)',
question: 'Your webid (to overwrite the root ACL with)',
prompt: false,
validate: function (value) {
if (value === '' || !value.startsWith('http')) {
return 'Enter a valid Webid'
}
return true
},
when: function (answers) {
return answers.useOwner
}
},
{
name: 'ssl-key',
help: 'Path to the SSL private key in PEM format',
validate: validPath,
prompt: true
},
{
name: 'ssl-cert',
help: 'Path to the SSL certificate key in PEM format',
validate: validPath,
prompt: true
},
{
name: 'no-reject-unauthorized',
help: 'Accept self-signed certificates',
flag: true,
default: false,
prompt: false
},
{
name: 'multiuser',
help: 'Enable multi-user mode',
question: 'Enable multi-user mode',
flag: true,
default: false,
prompt: true
},
{
name: 'idp',
help: 'Obsolete; use --multiuser',
prompt: false
},
{
name: 'no-live',
help: 'Disable live support through WebSockets',
flag: true,
default: false
},
// {
// full: 'default-app',
// help: 'URI to use as a default app for resources (default: https://linkeddata.github.io/warp/#/list/)'
// },
{
name: 'useCorsProxy',
help: 'Do you want to have a CORS proxy endpoint?',
flag: true,
prompt: true,
hide: true
},
{
name: 'proxy',
help: 'Obsolete; use --corsProxy',
prompt: false
},
{
name: 'corsProxy',
help: 'Serve the CORS proxy on this path',
when: function (answers) {
return answers.useCorsProxy
},
default: '/proxy',
prompt: true
},
{
name: 'authProxy',
help: 'Object with path/server pairs to reverse proxy',
default: {},
prompt: false,
hide: true
},
{
name: 'suppress-data-browser',
help: 'Suppress provision of a data browser',
flag: true,
prompt: false,
default: false,
hide: false
},
{
name: 'data-browser-path',
help: 'An HTML file which is sent to allow users to browse the data (eg using mashlib.js)',
question: 'Path of data viewer page (defaults to using mashlib)',
validate: validPath,
default: 'default',
prompt: false
},
{
name: 'suffix-acl',
full: 'suffix-acl',
help: "Suffix for acl files (default: '.acl')",
default: '.acl',
prompt: false
},
{
name: 'suffix-meta',
full: 'suffix-meta',
help: "Suffix for metadata files (default: '.meta')",
default: '.meta',
prompt: false
},
{
name: 'secret',
help: 'Secret used to sign the session ID cookie (e.g. "your secret phrase")',
question: 'Session secret for cookie',
default: 'random',
prompt: false,
filter: function (value) {
if (value === '' || value === 'random') {
return
}
return value
}
},
// {
// full: 'no-error-pages',
// flag: true,
// help: 'Disable custom error pages (use Node.js default pages instead)'
// },
{
name: 'error-pages',
help: 'Folder from which to look for custom error pages files (files must be named <error-code>.html -- eg. 500.html)',
validate: validPath,
prompt: false
},
{
name: 'force-user',
help: 'Force a WebID to always be logged in (useful when offline)'
},
{
name: 'strict-origin',
help: 'Enforce same origin policy in the ACL',
flag: true,
default: false,
prompt: false
},
{
name: 'useEmail',
help: 'Do you want to set up an email service?',
flag: true,
prompt: true,
default: false
},
{
name: 'email-host',
help: 'Host of your email service',
prompt: true,
default: 'smtp.gmail.com',
when: (answers) => {
return answers.useEmail
}
},
{
name: 'email-port',
help: 'Port of your email service',
prompt: true,
default: '465',
when: (answers) => {
return answers.useEmail
}
},
{
name: 'email-auth-user',
help: 'User of your email service',
prompt: true,
when: (answers) => {
return answers.useEmail
},
validate: (value) => {
if (!value || value === '') {
return 'You must enter this information'
}
return true
}
},
{
name: 'email-auth-pass',
help: 'Password of your email service',
type: 'password',
prompt: true,
when: (answers) => {
return answers.useEmail
}
},
{
name: 'useApiApps',
help: 'Do you want to load your default apps on /api/apps?',
flag: true,
prompt: false,
default: true
},
{
name: 'api-apps',
help: 'Path to the folder to mount on /api/apps',
prompt: true,
validate: validPath,
when: (answers) => {
return answers.useApiApps
}
}
]
function validPath (value) {
if (value === 'default') {
return Promise.resolve(true)
}
if (!value || value === '') {
return Promise.resolve('You must enter a valid path')
}
return new Promise((resolve) => {
fs.stat(value, function (err) {
if (err) return resolve('Nothing found at this path')
return resolve(true)
})
})
}
function validUri (value) {
if (!validUrl.isUri(value)) {
return 'Enter a valid uri (with protocol)'
}
return true
}