Socket
Socket
Sign inDemoInstall

fca-utils

Package Overview
Dependencies
186
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

11

lib/index.d.ts

@@ -12,2 +12,10 @@ /// <reference types="node" />

}>;
export type SendAttachment = (attachment: string | {
title: string;
url_or_path: string;
}, reply: boolean) => Promise<{
threadID: string;
messageID: string;
timestamp: number;
}>;
export type EventMessage = Pick<IFCAU_ListenMessage, Extract<keyof IFCAU_ListenMessage, 'type'>> extends infer R ? Extract<IFCAU_ListenMessage, {

@@ -32,2 +40,3 @@ type: "event";

reply: SendMessage;
sendAttachment: SendAttachment;
};

@@ -41,2 +50,3 @@ };

reply: SendMessage;
sendAttachment: SendAttachment;
}) => void): this;

@@ -70,5 +80,4 @@ on(event: 'command', listener: (props: CommandsProps) => void): this;

openServer(port?: number, app?: Express): void;
loginWithEmail(email: string, password: string, options: Partial<IFCAU_Options>): void;
loginWithAppState(EState: string, options: Partial<IFCAU_Options>): void;
}
//# sourceMappingURL=index.d.ts.map
import login from '@xaviabot/fca-unofficial';
import axios from 'axios';
import { createReadStream, existsSync } from 'fs';
import { EventEmitter } from 'events';

@@ -36,3 +38,26 @@ import createHttpsServer from './server.js';

send: (message) => this.#api.sendMessage(message, threadID),
reply: (message) => this.#api.sendMessage(message, threadID, messageID)
reply: (message) => this.#api.sendMessage(message, threadID, messageID),
sendAttachment: async (attachment, reply = false) => {
const imageSource = typeof attachment === "string" ? attachment : attachment.url_or_path;
const msgObj = {
body: typeof attachment === "string" ? "" : attachment.title,
};
const isExists = existsSync(imageSource);
if (!isExists) {
try {
new URL(imageSource);
msgObj.attachment = await axios.get(imageSource, { responseType: 'stream' }).then(res => res.data);
}
catch (err) {
if (err instanceof Error && err.message.includes('Invalid URL'))
throw new Error("Invalid image source, must be a valid URL or path to the file");
else
throw err;
}
}
else {
msgObj.attachment = createReadStream(imageSource);
}
return this.#api.sendMessage(msgObj, threadID, reply ? messageID : undefined);
}
}

@@ -47,7 +72,7 @@ };

}
loginWithEmail(email, password, options) {
login({ email, password }, { ...DEFAULT_OPTIONS, ...options })
.then(api => {
});
}
// loginWithEmail(email: string, password: string, options: Partial<IFCAU_Options>) {
// login({ email, password }, { ...DEFAULT_OPTIONS, ...options })
// .then(api => {
// });
// }
loginWithAppState(EState, options) {

@@ -54,0 +79,0 @@ const appState = getAppstate(EState);

7

package.json
{
"name": "fca-utils",
"version": "0.0.4",
"version": "0.0.5",
"description": "A NodeJS package to help interacting with Facebook Messenger API (fca-unofficial)",

@@ -34,3 +34,3 @@ "main": "lib/index.js",

"dependencies": {
"@xaviabot/fca-unofficial": "^1.3.15",
"@xaviabot/fca-unofficial": "^1.3.18",
"axios": "^1.3.4",

@@ -40,5 +40,4 @@ "cors": "^2.8.5",

"express-rate-limit": "^6.7.0",
"helmet": "^6.0.1",
"node-fetch": "^3.3.1"
"helmet": "^6.0.1"
}
}

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