Socket
Socket
Sign inDemoInstall

@huskiesio/bot

Package Overview
Dependencies
257
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.2

33

dts/chat/HCBotChat.d.ts

@@ -7,13 +7,36 @@ /**

*/
import { IHCBotChat, IHCBotChatHistory, IHCBotChatOnMessageHandler, IHCBotThread } from "../types";
export declare class HCBotChat implements IHCBotChat {
/// <reference types="node" />
import { IHCBotChatHistory, IHCBotThread } from "../types";
import { Socket } from "../HuskyChatBot";
declare type HCBotChatOnReceivedParam = {
threadId: string;
senderId: string;
payload: Buffer;
timestamp: number;
};
declare type HCBotChatOnSentParam = {
threadId: string;
senderId: string;
payload: Buffer;
timestamp: number;
};
declare type HCBotChatOnReceivedHandler = (message: HCBotChatOnReceivedParam) => Promise<void>;
declare type HCBotChatOnSentHandler = (message: HCBotChatOnSentParam) => Promise<void>;
export declare class HCBotChat {
private readonly _history;
private _onReceived;
private _onSent;
constructor();
private _onThreadUpdated;
constructor(socket: Socket);
history(): IHCBotChatHistory;
onReceived(handler: IHCBotChatOnMessageHandler): void;
onSent(handler: IHCBotChatOnMessageHandler): void;
onReceived(handler: HCBotChatOnReceivedHandler): void;
onSent(handler: HCBotChatOnSentHandler): void;
onThreadUpdated(handler: (threadId: string) => Promise<void>): void;
threads(): Promise<IHCBotThread[]>;
send(thread: (string | IHCBotThread), payload: string): Promise<string>;
handleChatMessageReceived(message: HCBotChatOnReceivedParam): Promise<void>;
handleChatMessageSent(message: HCBotChatOnSentParam): Promise<void>;
handleThreadUpdated(threadId: string): Promise<void>;
getThreadForId(threadId: string): Promise<IHCBotThread>;
}
export {};

4

dts/crypto/HCBotCrypto.d.ts

@@ -1,2 +0,1 @@

/// <reference types="node" />
/**

@@ -8,3 +7,5 @@ * Elijah Cobb

*/
/// <reference types="node" />
import { IHCBotCrypto, IHCBotCryptoKeyPair, IHCBotUser } from "../types";
import { Socket } from "..";
export interface IHCBotCryptoKeys {

@@ -15,2 +16,3 @@ user: () => IHCBotCryptoKeyPair;

export declare class HCBotCrypto implements IHCBotCrypto {
constructor(socket: Socket);
decrypt(data: Buffer): Promise<Buffer>;

@@ -17,0 +19,0 @@ encrypt(data: Buffer, user: IHCBotUser): Promise<Buffer>;

@@ -8,3 +8,5 @@ /**

import { IHCBotDirectory, IHCBotUser } from "../types";
import { Socket } from "../HuskyChatBot";
export declare class HCBotDirectory implements IHCBotDirectory {
constructor(socket: Socket);
friends(): Promise<IHCBotUser[]>;

@@ -11,0 +13,0 @@ getUser(username: string): Promise<IHCBotUser>;

@@ -7,3 +7,2 @@ /**

*/
import { IHCBot } from "./types";
import { HCBotInfo } from "./info/HCBotInfo";

@@ -13,3 +12,8 @@ import { HCBotDirectory } from "./directory/HCBotDirectory";

import { HCBotChat } from "./chat/HCBotChat";
export declare class HuskyChatBot implements IHCBot {
import { CommandSocket } from "@command-socket/node-client";
import { HCCSServerCommands, HCCSBotCommands } from "@huskiesio/types";
interface SocketProps {
}
export declare type Socket = CommandSocket<HCCSBotCommands, HCCSServerCommands, SocketProps>;
export declare class HuskyChatBot {
private readonly _chat;

@@ -19,2 +23,3 @@ private readonly _crypto;

private readonly _info;
private readonly socket;
private constructor();

@@ -25,3 +30,6 @@ chat(): HCBotChat;

info(): HCBotInfo;
kill(): Promise<void>;
private static init;
static signIn(username: string, password: string): Promise<HuskyChatBot>;
}
export {};

@@ -1,16 +0,10 @@

/**
* Elijah Cobb
* elijah@elijahcobb.com
* elijahcobb.com
* github.com/elijahjcobb
*/
import { IHCBotInfo } from "../types";
import { HCBotInfoServer } from "./HCBotInfoServer";
import { HCBotInfoMe } from "./HCBotInfoMe";
export declare class HCBotInfo implements IHCBotInfo {
import { Socket } from "../HuskyChatBot";
export declare class HCBotInfo {
private readonly _me;
private readonly _server;
constructor();
constructor(socket: Socket);
me(): HCBotInfoMe;
server(): HCBotInfoServer;
}

@@ -7,16 +7,23 @@ /**

*/
import { IHCBotInfoMe } from "../types";
/// <reference types="node" />
import { HCBotInfoMeAvatar } from "./HCBotInfoMeAvatar";
export declare class HCBotInfoMe implements IHCBotInfoMe {
private readonly _firstName;
private readonly _lastName;
private readonly _userId;
private readonly _username;
import { Socket } from "../HuskyChatBot";
export declare class HCBotInfoMe {
private _firstName;
private _lastName;
private _userId;
private _username;
private _publicKey;
private _updatedAt;
private _createdAt;
private readonly _avatar;
constructor();
firstName(): string;
lastName(): string;
userId(): string;
private readonly socket;
constructor(socket: Socket);
private fetchSelf;
firstName(): Promise<string>;
lastName(): Promise<string>;
userId(): Promise<string>;
username(): Promise<string>;
publicKey(): Promise<Buffer>;
avatar(): HCBotInfoMeAvatar;
username(): string;
}

@@ -1,3 +0,1 @@

/// <reference types="node" />
import { IHCBotGetterSetter } from "../types";
/**

@@ -9,5 +7,9 @@ * Elijah Cobb

*/
/// <reference types="node" />
import { IHCBotGetterSetter } from "../types";
import { Socket } from "../HuskyChatBot";
export declare class HCBotInfoMeAvatar implements IHCBotGetterSetter<Buffer> {
constructor(socket: Socket);
get(): Promise<Buffer>;
set(value: Buffer): Promise<void>;
}

@@ -8,6 +8,7 @@ /**

import { IHCBotInfoServer } from "../types";
import { Socket } from "../HuskyChatBot";
export declare class HCBotInfoServer implements IHCBotInfoServer {
private readonly _domain;
private readonly _ip;
constructor();
constructor(socket: Socket);
domain(): string;

@@ -14,0 +15,0 @@ ip(): string;

@@ -1,7 +0,1 @@

/**
* Elijah Cobb
* elijah@elijahcobb.com
* elijahcobb.com
* github.com/elijahjcobb
*/
/// <reference types="node" />

@@ -8,0 +2,0 @@ export interface ISiObject {

@@ -9,4 +9,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
;
class HCBotChat {
constructor() {
constructor(socket) {
this._history = {};

@@ -17,6 +18,20 @@ }

onSent(handler) { this._onSent = handler; }
onThreadUpdated(handler) { this._onThreadUpdated = handler; }
async threads() { return []; }
async send(thread, payload) { return ""; }
async handleChatMessageReceived(message) {
if (this._onReceived)
this._onReceived(message);
}
async handleChatMessageSent(message) {
if (this._onSent)
this._onSent(message);
}
async handleThreadUpdated(threadId) {
if (this._onThreadUpdated)
this._onThreadUpdated(threadId);
}
async getThreadForId(threadId) { return {}; }
}
exports.HCBotChat = HCBotChat;
//# sourceMappingURL=HCBotChat.js.map
"use strict";
/**
* Elijah Cobb
* elijah@elijahcobb.com
* elijahcobb.com
* github.com/elijahjcobb
*/
Object.defineProperty(exports, "__esModule", { value: true });
class HCBotCrypto {
constructor(socket) {
}
async decrypt(data) { return Buffer.alloc(0, 0); }

@@ -5,0 +13,0 @@ async encrypt(data, user) { return Buffer.alloc(0, 0); }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class HCBotDirectory {
constructor(socket) {
}
async friends() { return []; }

@@ -5,0 +7,0 @@ async getUser(username) { return {}; }

@@ -13,8 +13,11 @@ "use strict";

const HCBotChat_1 = require("./chat/HCBotChat");
const node_client_1 = require("@command-socket/node-client");
const core_1 = require("@command-socket/core");
class HuskyChatBot {
constructor() {
this._chat = new HCBotChat_1.HCBotChat();
this._crypto = new HCBotCrypto_1.HCBotCrypto();
this._directory = new HCBotDirectory_1.HCBotDirectory();
this._info = new HCBotInfo_1.HCBotInfo();
constructor(socket) {
this.socket = socket;
this._chat = new HCBotChat_1.HCBotChat(socket);
this._crypto = new HCBotCrypto_1.HCBotCrypto(socket);
this._directory = new HCBotDirectory_1.HCBotDirectory(socket);
this._info = new HCBotInfo_1.HCBotInfo(socket);
}

@@ -25,5 +28,18 @@ chat() { return this._chat; }

info() { return this._info; }
static async signIn(username, password) { return new HuskyChatBot(); }
kill() { return this.socket.close(); }
static async init() {
const commandRegistry = new core_1.CommandRegistry();
const socket = await node_client_1.CommandSocket.create("ws://localhost:3000", commandRegistry);
const bot = new HuskyChatBot(socket);
commandRegistry.addCommand("chat message received", bot._chat.handleChatMessageReceived);
commandRegistry.addCommand("chat message sent", bot._chat.handleChatMessageSent);
commandRegistry.addCommand("thread updated", bot._chat.handleThreadUpdated);
return bot;
}
static async signIn(username, password) {
const bot = await HuskyChatBot.init();
return bot;
}
}
exports.HuskyChatBot = HuskyChatBot;
//# sourceMappingURL=HuskyChatBot.js.map

@@ -6,5 +6,5 @@ "use strict";

class HCBotInfo {
constructor() {
this._me = new HCBotInfoMe_1.HCBotInfoMe();
this._server = new HCBotInfoServer_1.HCBotInfoServer();
constructor(socket) {
this._me = new HCBotInfoMe_1.HCBotInfoMe(socket);
this._server = new HCBotInfoServer_1.HCBotInfoServer(socket);
}

@@ -11,0 +11,0 @@ me() { return this._me; }

"use strict";
/**
* Elijah Cobb
* elijah@elijahcobb.com
* elijahcobb.com
* github.com/elijahjcobb
*/
Object.defineProperty(exports, "__esModule", { value: true });
const HCBotInfoMeAvatar_1 = require("./HCBotInfoMeAvatar");
class HCBotInfoMe {
constructor() {
this._firstName = "";
this._lastName = "";
this._userId = "";
this._username = "";
this._avatar = new HCBotInfoMeAvatar_1.HCBotInfoMeAvatar();
constructor(socket) {
this.socket = socket;
this._avatar = new HCBotInfoMeAvatar_1.HCBotInfoMeAvatar(socket);
}
firstName() { return this._firstName; }
lastName() { return this._lastName; }
userId() { return this._userId; }
async fetchSelf() {
const me = await this.socket.invoke("user me", undefined);
this._firstName = me.firstName;
this._lastName = me.lastName;
this._publicKey = me.publicKey;
this._username = me.username;
this._userId = me.id;
this._updatedAt = me.updatedAt;
this._createdAt = me.createdAt;
}
async firstName() {
if (this._firstName === undefined)
await this.fetchSelf();
if (this._firstName === undefined)
throw new Error("Unable to fetch information");
return this._firstName;
}
async lastName() {
if (this._lastName === undefined)
await this.fetchSelf();
if (this._lastName === undefined)
throw new Error("Unable to fetch information");
return this._lastName;
}
async userId() {
if (this._userId === undefined)
await this.fetchSelf();
if (this._userId === undefined)
throw new Error("Unable to fetch information");
return this._userId;
}
async username() {
if (this._username === undefined)
await this.fetchSelf();
if (this._username === undefined)
throw new Error("Unable to fetch information");
return this._username;
}
async publicKey() {
if (this._publicKey === undefined)
await this.fetchSelf();
if (this._publicKey === undefined)
throw new Error("Unable to fetch information");
return this._publicKey;
}
avatar() { return this._avatar; }
username() { return this._username; }
}
exports.HCBotInfoMe = HCBotInfoMe;
//# sourceMappingURL=HCBotInfoMe.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**

@@ -9,3 +8,6 @@ * Elijah Cobb

*/
Object.defineProperty(exports, "__esModule", { value: true });
class HCBotInfoMeAvatar {
constructor(socket) {
}
async get() {

@@ -12,0 +14,0 @@ return Buffer.alloc(0, 0);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class HCBotInfoServer {
constructor() {
constructor(socket) {
this._domain = "";

@@ -6,0 +6,0 @@ this._ip = "";

@@ -12,9 +12,4 @@ "use strict";

const bot = await index_1.HuskyChatBot.signIn("", "");
await bot.chat().onReceived(async (message) => {
});
await bot.chat().onSent(async (message) => {
});
await bot.chat().threads();
await bot.chat().send("", "");
bot.info().me().firstName();
})();
//# sourceMappingURL=playground.js.map
"use strict";
/**
* Elijah Cobb
* elijah@elijahcobb.com
* elijahcobb.com
* github.com/elijahjcobb
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
{
"name": "@huskiesio/bot",
"version": "0.2.0",
"description": "A package to build a bot for the huskies.io chat application.",
"keywords": [],
"main": "js/index",
"types": "dts/index",
"files": [
"js",
"dts"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"prepublishOnly": "npm run compile",
"compile": "npm run clean && /usr/local/bin/tsc -p tsconfig.json",
"watch": "tsc -w -p .",
"clean": "rm -rf js && rm -rf dts",
"start": "node js/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/huskiesio/bot.git"
},
"publishConfig": {
"access": "public"
},
"author": "Elijah Cobb <elijah@elijahcobb.com> (https://elijahcobb.com/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/huskiesio/bot/issues"
},
"homepage": "https://github.com/huskiesio/bot#readme",
"dependencies": {
"@command-socket/node-client": "latest",
"@element-ts/krypton": "latest",
"@huskiesio/types": "latest"
},
"devDependencies": {
"@types/node": "latest",
"typescript": "latest",
"tslint": "latest",
"jest": "latest",
"@types/jest": "latest"
}
"name": "@huskiesio/bot",
"version": "0.2.2",
"description": "A package to build a bot for the huskies.io chat application.",
"keywords": [],
"main": "js/index",
"types": "dts/index",
"files": [
"js",
"dts"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"prepublishOnly": "npm run compile",
"compile": "npm run clean && /usr/local/bin/tsc -p tsconfig.json",
"watch": "tsc -w -p .",
"clean": "rm -rf js && rm -rf dts",
"start": "node js/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/huskiesio/bot.git"
},
"publishConfig": {
"access": "public"
},
"author": "Elijah Cobb <elijah@elijahcobb.com> (https://elijahcobb.com/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/huskiesio/bot/issues"
},
"homepage": "https://github.com/huskiesio/bot#readme",
"dependencies": {
"@command-socket/node-client": "latest",
"@element-ts/krypton": "latest",
"@huskiesio/types": "latest",
"@types/ws": "latest",
"@types/mongodb": "latest"
},
"devDependencies": {
"@types/node": "latest",
"typescript": "latest",
"tslint": "latest",
"jest": "latest",
"@types/jest": "latest"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc