Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
import { USER_LOGIN_VALIDATION } from '../constants/user.js'
export function isSafePathSegment(value: unknown): value is string {
return typeof value === 'string' && !!value && value !== '.' && value !== '..' && !value.includes('/') && !value.includes('\\')
}
export function isValidUserLogin(login: unknown): login is string {
return isSafePathSegment(login) && USER_LOGIN_VALIDATION.test(login)
}
export function validateUserId(userId: number): void {
if (!Number.isSafeInteger(userId) || userId <= 0) {
throw new Error('User id must be a positive safe integer')
}
}