27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import { PacketDeviceNew } from "../providers/ProtocolProvider/protocol/packets/packet.device.new";
|
|
import { usePacket } from "../providers/ProtocolProvider/usePacket";
|
|
import { useSendSystemMessage } from "../providers/SystemAccountsProvider/useSendSystemMessage";
|
|
import { dotCenterIfNeeded } from "../utils/utils";
|
|
|
|
const messageTemplate = `
|
|
**Attempt to login from a new device**
|
|
|
|
We detected a login to your account from **{ip}** a new device **by seed phrase**. If this was you, you can safely ignore this message.
|
|
|
|
**Arch:** {os}
|
|
**IP:** {ip}
|
|
**Device:** {device}
|
|
**ID:** {deviceId}`;
|
|
|
|
export function useDeviceMessage() {
|
|
const send = useSendSystemMessage("safe");
|
|
|
|
usePacket(0x09, (packet: PacketDeviceNew) => {
|
|
send(messageTemplate
|
|
.replaceAll("{ip}", packet.getIpAddress())
|
|
.replaceAll("{device}", packet.getDevice().deviceName)
|
|
.replaceAll("{os}", packet.getDevice().deviceOs)
|
|
.replaceAll("{deviceId}", dotCenterIfNeeded(packet.getDevice().deviceId, 12, 4))
|
|
);
|
|
}, []);
|
|
} |