All files / lib/Model SharingACL.js

63.63% Statements 7/11
100% Branches 0/0
42.85% Functions 3/7
63.63% Lines 7/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  3x 3x       2x   3x                                                                       2x     3x     3x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SharingACL = void 0;
class SharingACL {
    _permission;
    constructor(_permission) {
        this._permission = _permission;
    }
    static permissions = {
        READ: 0x01,
        WRITE: 0x02,
        FILES: 0x04,
        HISTORY: 0x08,
        OWNER: 0x80,
    };
    /**
     * Checks if a user has the given permission/s
     * @param permission
     */
    hasPermission(permission) {
        return permission === (this.permission & permission);
    }
    ;
    /**
     * Adds a permission to a user, leaving any other permissions intact
     * @param permission
     */
    addPermission(permission) {
        this._permission = this.permission | permission;
    }
    ;
    /**
     * Removes a given permission from the item, leaving any other intact
     * @param permission
     */
    removePermission(permission) {
        this._permission = this.permission & ~permission;
    }
    ;
    togglePermission(permission) {
        this._permission ^= permission;
    }
    ;
    getAccessLevel() {
        return this.permission;
    }
    get permission() {
        return this._permission;
    }
}
exports.SharingACL = SharingACL;