Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ebenos/viber-adapter

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ebenos/viber-adapter - npm Package Compare versions

Comparing version 4.0.0-alpha.28 to 4.0.0-alpha.29

52

build/adapter.js

@@ -22,15 +22,15 @@ "use strict";

};
this.webhook = express_1.default();
this.webhook = (0, express_1.default)();
const { route = '/viber/webhook', authToken, welcomeMessage } = options;
this.route = route;
this.authToken = authToken;
this.sender = sender_1.default(this.authToken);
this.sender = (0, sender_1.default)(this.authToken);
this.welcomeMessage = welcomeMessage;
}
initialization() {
this.webhook.use(body_parser_1.json());
this.webhook.use((0, body_parser_1.json)());
this.webhook.post(this.route, viberWebhookFactory(this.routers, this.handlers, this.welcomeMessage));
}
setWebhook(url) {
return requests_1.setWebhook(url + this.route, this.authToken);
return (0, requests_1.setWebhook)(url + this.route, this.authToken);
}

@@ -52,28 +52,31 @@ }

}
function handleTextOnly(m, user, textHandler) {
if (textHandler !== undefined) {
textHandler({ text: m.text }, undefined, user);
function handleTextMessage(m, user, textHandler, routers) {
if (textHandler === undefined) {
console.log('No text handler');
return;
}
console.log('No text handler');
return;
}
function handleTextMessage(m, user, textHandler, routers) {
const text = m.text ? m.text : 'user_send_location';
const location = m.type === 'location' ? m.location : undefined;
let tracking_data;
try {
const parsedTrackingData = JSON.parse(m.tracking_data);
if (tracking_data_1.isPostbackTrackingData(parsedTrackingData)) {
const payload = JSON.stringify({
type: parsedTrackingData.type + m.text.replace(' ', ''),
data: parsedTrackingData.data
});
routerExists(routers.PostbackRouter).objectPayloadHandler(payload, user);
return;
}
handleTextOnly(m, user, textHandler);
return;
// Tracking Data is an object
tracking_data = JSON.parse(m.tracking_data);
}
catch {
handleTextOnly(m, user, textHandler);
// Tracking Data is a string
tracking_data = m.tracking_data;
}
if ((0, tracking_data_1.isPostbackTrackingData)(tracking_data)) {
// Tracking Data is a postback
const payload = JSON.stringify({
type: tracking_data.type,
text,
location,
tracking_data
});
routerExists(routers.PostbackRouter).objectPayloadHandler(payload, user);
return;
}
textHandler({ text, tracking_data, location }, undefined, user);
return;
}

@@ -85,6 +88,7 @@ function viberWebhookFactory(routers, handlers, welcomeMessage) {

case 'text':
case 'location':
handleTextMessage(e.message, user, handlers.text, routers);
return;
default:
if (message_types_1.isMediaMessage(e.message)) {
if ((0, message_types_1.isMediaMessage)(e.message)) {
if (handlers.attachment !== undefined) {

@@ -91,0 +95,0 @@ handlers.attachment(user, e.message);

@@ -12,3 +12,3 @@ "use strict";

};
return viberRequest_1.default('set_webhook', body, authToken);
return (0, viberRequest_1.default)('set_webhook', body, authToken);
}

@@ -21,5 +21,5 @@ exports.setWebhook = setWebhook;

};
return viberRequest_1.default('send_message', body, authToken);
return (0, viberRequest_1.default)('send_message', body, authToken);
}
exports.sendMessage = sendMessage;
//# sourceMappingURL=requests.js.map

@@ -9,3 +9,3 @@ "use strict";

async function viberRequest(path, data, authToken) {
const res = await node_fetch_1.default(viberUrl + path, {
const res = await (0, node_fetch_1.default)(viberUrl + path, {
method: 'POST',

@@ -12,0 +12,0 @@ body: JSON.stringify(data),

@@ -40,2 +40,3 @@ export declare type MessageType = 'text' | 'picture' | 'video' | 'file' | 'sticker' | 'contact' | 'url' | 'location';

type: 'location';
text?: string;
location: {

@@ -42,0 +43,0 @@ lat: number;

@@ -13,3 +13,3 @@ "use strict";

case 'message':
await requests_1.sendMessage(a.id, a.message.serialize(), viberToken);
await (0, requests_1.sendMessage)(a.id, a.message.serialize(), viberToken);
break;

@@ -16,0 +16,0 @@ case 'typing_on':

{
"name": "@ebenos/viber-adapter",
"version": "4.0.0-alpha.28",
"version": "4.0.0-alpha.29",
"description": "Viber adapter for the Ebony framework.",

@@ -31,14 +31,14 @@ "main": "./build/index.js",

"dependencies": {
"@types/body-parser": "^1.19.0",
"@types/express": "^4.17.11",
"@types/node-fetch": "^2.5.8",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"node-fetch": "^2.6.1"
"node-fetch": "^2.6.6"
},
"devDependencies": {
"@ebenos/framework": "^4.0.0-alpha.28"
"@ebenos/framework": "^4.0.0-alpha.29",
"@types/body-parser": "^1.19.2",
"@types/express": "^4.17.13",
"@types/node-fetch": "^2.5.12"
},
"engines": {
"node": ">=8.9.0"
"node": ">=14.0.0"
},

@@ -48,3 +48,3 @@ "files": [

],
"gitHead": "d56f9b1c64cf59fc8ca220609139ccea7b19d425"
"gitHead": "18fd89bfbc610610c8edc8c5ea32a7c616341b11"
}

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc