export function computePadding(size, modulo) {
    return (modulo - (size % modulo)) % modulo;
}
export function senderIdToUserId(senderId) {
    if (senderId >= 0x80) {
        senderId += 0xFF00;
    }
    return senderId;
}
export function userIdToSenderId(userId) {
    if (userId > 0xFFFF) {
        throw new Error("Invalid user id. Should be between 0 and " + 0xFFFF); // TODO custom error
    }
    if ((userId > 0x7F) && (userId < 0xFF80)) {
        throw new Error("Invalid user id. Should be between 0 and " + 0 + " and " + 0x7F + " or " + 0xFFFF + " and " + 0xFF80);
    } // TODO custom error
    return 0xFF & userId;
}
export function usernameToSenderId(username) {
    switch (username) {
        case "IoTize":
            return 0xFD;
        case "admin":
            return userIdToSenderId(0xFFFF); // TODO constant
        case "anonymous":
            return userIdToSenderId(0x0);
        case "supervisor":
            return userIdToSenderId(0xFFFE);
        default:
            return 0;
    }
}
// function createCredentialsFromCurrentSessionData() {
//     const authSessionState = this.tap.auth.sessionStateSnapshot;
//     const authSessionData = this.tap.auth.sessionDataSnapshot;
//     console.info('Session data: ', authSessionState);
//     if (!authSessionData.serverKey || !authSessionData.storedKey || !authSessionState.name) {
//         throw SinglePacketError.authSessionRequiredToEncryptSinglePacket();
//     }
//     return SinglePacketEncryptionOptionsBuilder.fromCurrentSessionData({
//         username: authSessionState.name,
//         serverKey: authSessionData.serverKey,
//         storedKey: authSessionData.storedKey
//     });
// }
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bpb3RpemUvdGFwL3NlcnZpY2UvaW1wbC9zaW5nbGUtcGFja2V0LyIsInNvdXJjZXMiOlsibGliL2N1c3RvbS91dGlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sVUFBVSxjQUFjLENBQUMsSUFBWSxFQUFFLE1BQWM7SUFDdkQsT0FBTyxDQUFDLE1BQU0sR0FBRyxDQUFDLElBQUksR0FBRyxNQUFNLENBQUMsQ0FBQyxH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