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
|
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { getCapabilities } from '@nextcloud/capabilities'
export default class Config {
_capabilities: Capabilities
constructor() {
this._capabilities = getCapabilities() as Capabilities
}
/**
* Get default share permissions, if any
*/
get defaultPermissions(): number {
return this._capabilities.files_sharing?.default_permissions
}
/**
* Is public upload allowed on link shares ?
* This covers File request and Full upload/edit option.
*/
get isPublicUploadEnabled(): boolean {
return this._capabilities.files_sharing?.public?.upload === true
}
/**
* Get the federated sharing documentation link
*/
get federatedShareDocLink() {
return window.OC.appConfig.core.federatedCloudShareDoc
}
/**
* Get the default link share expiration date
*/
get defaultExpirationDate(): Date|null {
if (this.isDefaultExpireDateEnabled && this.defaultExpireDate !== null) {
return new Date(new Date().setDate(new Date().getDate() + this.defaultExpireDate))
}
return null
}
/**
* Get the default internal expiration date
*/
get defaultInternalExpirationDate(): Date|null {
if (this.isDefaultInternalExpireDateEnabled && this.defaultInternalExpireDate !== null) {
return new Date(new Date().setDate(new Date().getDate() + this.defaultInternalExpireDate))
}
return null
}
/**
* Get the default remote expiration date
*/
get defaultRemoteExpirationDateString(): Date|null {
if (this.isDefaultRemoteExpireDateEnabled && this.defaultRemoteExpireDate !== null) {
return new Date(new Date().setDate(new Date().getDate() + this.defaultRemoteExpireDate))
}
return null
}
/**
* Are link shares password-enforced ?
*/
get enforcePasswordForPublicLink(): boolean {
return window.OC.appConfig.core.enforcePasswordForPublicLink === true
}
/**
* Is password asked by default on link shares ?
*/
get enableLinkPasswordByDefault(): boolean {
return window.OC.appConfig.core.enableLinkPasswordByDefault === true
}
/**
* Is link shares expiration enforced ?
*/
get isDefaultExpireDateEnforced(): boolean {
return window.OC.appConfig.core.defaultExpireDateEnforced === true
}
/**
* Is there a default expiration date for new link shares ?
*/
get isDefaultExpireDateEnabled(): boolean {
return window.OC.appConfig.core.defaultExpireDateEnabled === true
}
/**
* Is internal shares expiration enforced ?
*/
get isDefaultInternalExpireDateEnforced(): boolean {
return window.OC.appConfig.core.defaultInternalExpireDateEnforced === true
}
/**
* Is there a default expiration date for new internal shares ?
*/
get isDefaultInternalExpireDateEnabled(): boolean {
return window.OC.appConfig.core.defaultInternalExpireDateEnabled === true
}
/**
* Is remote shares expiration enforced ?
*/
get isDefaultRemoteExpireDateEnforced(): boolean {
return window.OC.appConfig.core.defaultRemoteExpireDateEnforced === true
}
/**
* Is there a default expiration date for new remote shares ?
*/
get isDefaultRemoteExpireDateEnabled(): boolean {
return window.OC.appConfig.core.defaultRemoteExpireDateEnabled === true
}
/**
* Are users on this server allowed to send shares to other servers ?
*/
get isRemoteShareAllowed(): boolean {
return window.OC.appConfig.core.remoteShareAllowed === true
}
/**
* Is sharing my mail (link share) enabled ?
*/
get isMailShareAllowed(): boolean {
// eslint-disable-next-line camelcase
return this._capabilities?.files_sharing?.sharebymail?.enabled === true
// eslint-disable-next-line camelcase
&& this._capabilities?.files_sharing?.public?.enabled === true
}
/**
* Get the default days to link shares expiration
*/
get defaultExpireDate(): number|null {
return window.OC.appConfig.core.defaultExpireDate
}
/**
* Get the default days to internal shares expiration
*/
get defaultInternalExpireDate(): number|null {
return window.OC.appConfig.core.defaultInternalExpireDate
}
/**
* Get the default days to remote shares expiration
*/
get defaultRemoteExpireDate(): number|null {
return window.OC.appConfig.core.defaultRemoteExpireDate
}
/**
* Is resharing allowed ?
*/
get isResharingAllowed(): boolean {
return window.OC.appConfig.core.resharingAllowed === true
}
/**
* Is password enforced for mail shares ?
*/
get isPasswordForMailSharesRequired(): boolean {
return this._capabilities.files_sharing?.sharebymail?.password?.enforced === true
}
/**
* Always show the email or userid unique sharee label if enabled by the admin
*/
get shouldAlwaysShowUnique(): boolean {
return this._capabilities.files_sharing?.sharee?.always_show_unique === true
}
/**
* Is sharing with groups allowed ?
*/
get allowGroupSharing(): boolean {
return window.OC.appConfig.core.allowGroupSharing === true
}
/**
* Get the maximum results of a share search
*/
get maxAutocompleteResults(): number {
return parseInt(window.OC.config['sharing.maxAutocompleteResults'], 10) || 25
}
/**
* Get the minimal string length
* to initiate a share search
*/
get minSearchStringLength(): number {
return parseInt(window.OC.config['sharing.minSearchStringLength'], 10) || 0
}
/**
* Get the password policy configuration
*/
get passwordPolicy(): PasswordPolicyCapabilities {
return this._capabilities?.password_policy || {}
}
}
type PasswordPolicyCapabilities = {
enforceNonCommonPassword: boolean
enforceNumericCharacters: boolean
enforceSpecialCharacters: boolean
enforceUpperLowerCase: boolean
minLength: number
}
type FileSharingCapabilities = {
api_enabled: boolean,
public: {
enabled: boolean,
password: {
enforced: boolean,
askForOptionalPassword: boolean
},
expire_date: {
enabled: boolean,
days: number,
enforced: boolean
},
multiple_links: boolean,
expire_date_internal: {
enabled: boolean
},
expire_date_remote: {
enabled: boolean
},
send_mail: boolean,
upload: boolean,
upload_files_drop: boolean
},
resharing: boolean,
user: {
send_mail: boolean,
expire_date: {
enabled: boolean
}
},
group_sharing: boolean,
group: {
enabled: boolean,
expire_date: {
enabled: true
}
},
default_permissions: number,
federation: {
outgoing: boolean,
incoming: boolean,
expire_date: {
enabled: boolean
},
expire_date_supported: {
enabled: boolean
}
},
sharee: {
query_lookup_default: boolean,
always_show_unique: boolean
},
sharebymail: {
enabled: boolean,
send_password_by_mail: boolean,
upload_files_drop: {
enabled: boolean
},
password: {
enabled: boolean,
enforced: boolean
},
expire_date: {
enabled: boolean,
enforced: boolean
}
}
}
type Capabilities = {
files_sharing: FileSharingCapabilities
password_policy: PasswordPolicyCapabilities
}
|