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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bpb3RpemUvdGFwL3NlcnZpY2UvaW1wbC9zaW5nbGUtcGFja2V0LyIsInNvdXJjZXMiOlsibGliL2N1c3RvbS91dGlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sVUFBVSxjQUFjLENBQUMsSUFBWSxFQUFFLE1BQWM7SUFDdkQsT0FBTyxDQUFDLE1BQU0sR0FBRyxDQUFDLElBQUksR0FBRyxNQUFNLENBQUMsQ0FBQyxHQUF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