New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fritz-callmonitor

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fritz-callmonitor - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

23

dist/fritz-callmonitor.d.ts
/// <reference types="node" />
import { EventEmitter } from "events";
export declare class CallMonitor extends EventEmitter {
private host;
private port;
private _reader;
private _connected;
private _socket;
private readonly host;
private readonly port;
private readonly _socket;
constructor(host: string);

@@ -14,2 +12,3 @@ constructor(host: string, port: number);

private processLine(line);
on(event: "phone", listener: (data: PhoneEvent) => void): this;
on(event: "call", listener: (data: CallEvent) => void): this;

@@ -20,3 +19,3 @@ on(event: "ring", listener: (data: RingEvent) => void): this;

on(event: string, listener: Function): this;
private createEvent(eventType, date, connectionId, line, splitLines);
private createEvent(eventKind, date, connectionId, line, splitLines);
private parseLine(line);

@@ -29,6 +28,6 @@ private static eventTypeFromString(ev);

connectionId: number;
originalData: string;
rawData: string;
}
export interface RingEvent extends PhoneEventBase {
eventType: EventType.Ring;
kind: EventKind.Ring;
caller: string;

@@ -38,3 +37,3 @@ callee: string;

export interface CallEvent extends PhoneEventBase {
eventType: EventType.Call;
kind: EventKind.Call;
extension: string;

@@ -45,3 +44,3 @@ caller: string;

export interface PickUpEvent extends PhoneEventBase {
eventType: EventType.PickUp;
kind: EventKind.PickUp;
extension: string;

@@ -51,6 +50,6 @@ phoneNumber: string;

export interface HangUpEvent extends PhoneEventBase {
eventType: EventType.HangUp;
kind: EventKind.HangUp;
callDuration: number;
}
export declare const enum EventType {
export declare const enum EventKind {
Call = 0,

@@ -57,0 +56,0 @@ Ring = 1,

@@ -11,16 +11,17 @@ "use strict";

this.port = port;
this._connected = false;
this._socket = new net_1.Socket();
}
connect() {
if (this._connected)
return;
this._socket = net_1.connect(this.port, this.host);
this._socket.on("connect", args => this.emit("connect", args));
this._socket.on("end", args => this.emit("end", args));
this._socket.on("timeout", args => this.emit("timeout", args));
this._socket.on("error", err => this.emit("error", err));
this._socket.on("close", args => this.emit("close", args));
this._reader = byline_1.createStream(this._socket, { encoding: "utf-8" });
this._reader.on("data", (l) => this.processLine(l));
this._connected = true;
const s = this._socket;
s.connect(this.port, this.host);
s.on("connect", args => {
const reader = byline_1.createStream(this._socket, { encoding: "utf-8" });
reader.on("data", (l) => this.processLine(l));
s.once("end", _ => reader.end());
this.emit("connect", args);
});
s.on("end", args => this.emit("end", args));
s.on("timeout", args => this.emit("timeout", args));
s.on("error", err => this.emit("error", err));
s.on("close", args => this.emit("close", args));
}

@@ -34,7 +35,8 @@ end() {

return false;
switch (data.eventType) {
case 1: return super.emit("ring", data);
case 0: return super.emit("call", data);
case 2: return super.emit("pickup", data);
case 4: return super.emit("hangup", data);
this.emit("phone", data);
switch (data.kind) {
case 1: return this.emit("ring", data);
case 0: return this.emit("call", data);
case 2: return this.emit("pickup", data);
case 4: return this.emit("hangup", data);
default: return false;

@@ -46,40 +48,33 @@ }

}
createEvent(eventType, date, connectionId, line, splitLines) {
switch (eventType) {
createEvent(eventKind, date, connectionId, line, splitLines) {
const res = {
rawData: line,
date: date,
connectionId: connectionId,
};
switch (eventKind) {
case 4:
return {
eventType: eventType,
originalData: line,
date: date,
connectionId: connectionId,
return Object.assign(res, {
kind: eventKind,
callDuration: parseInt(splitLines[3])
};
});
case 0:
return {
eventType: eventType,
originalData: line,
date: date,
connectionId: connectionId,
return Object.assign(res, {
kind: eventKind,
extension: splitLines[3],
caller: splitLines[4],
callee: splitLines[5]
};
});
case 2:
return {
eventType: eventType,
originalData: line,
date: date,
connectionId: connectionId,
return Object.assign(res, {
kind: eventKind,
extension: splitLines[3],
phoneNumber: splitLines[4]
};
});
case 1:
return {
eventType: eventType,
originalData: line,
date: date,
connectionId: connectionId,
return Object.assign(res, {
kind: eventKind,
caller: splitLines[3],
callee: splitLines[4]
};
});
}

@@ -86,0 +81,0 @@ }

{
"name": "fritz-callmonitor",
"version": "2.0.0",
"version": "3.0.0",
"description": "Provides a node.js wrapper for the call monitor api of the AVM Fritz!Box. Written in TypeScript.",

@@ -5,0 +5,0 @@ "main": "dist/lib.js",

@@ -20,9 +20,9 @@ # fritz-callmonitor

import fb = require("fritz-callmonitor");
import { CallMonitor, EventKind } from "fritz-callmonitor";
var cm = new fb.CallMonitor("192.168.178.1", 1012);
const cm = new CallMonitor("192.168.178.1", 1012);
cm.on("ring", rr => {
console.dir(rr);
console.log(rr.caller + " calling...");
console.dir(rr);
console.log(`${rr.caller} calling...`);
});

@@ -34,2 +34,12 @@

cm.on("phone", evt => {
// gets called on every phone event
switch(evt.kind) {
case EventKind.Ring:
case EventKind.Call:
console.log(`${evt.caller} -> ${evt.callee}`);
break;
}
});
cm.on("close", () => console.log("Connection closed."));

@@ -36,0 +46,0 @@ cm.on("connect", () => console.log("Connected to device."));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc