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

messaging-api-messenger

Package Overview
Dependencies
Maintainers
3
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messaging-api-messenger - npm Package Compare versions

Comparing version 0.5.12 to 0.5.13

4

lib/MessengerClient.js

@@ -59,2 +59,3 @@ 'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};

function extractVersion(version) {

@@ -1253,2 +1254,3 @@ if (version.startsWith('v')) {

/**

@@ -1387,3 +1389,3 @@ * Messenger Code API

return this.sendAttachmentFormData(recipient, attachment, file, options);};this.sendTemplate = (recipient, payload, options) => this.sendAttachment(recipient, { type: 'template', payload }, options);this.sendButtonTemplate = (recipient, text, buttons, options) => this.sendTemplate(recipient, { template_type: 'button', text, buttons }, options);this.sendGenericTemplate = (recipient, elements, options = {}) => this.sendTemplate(recipient, { template_type: 'generic', elements, image_aspect_ratio: options.image_aspect_ratio || 'horizontal' }, (0, _lodash2.default)(options, ['image_aspect_ratio']));this.sendListTemplate = (recipient, elements, buttons, options = {}) => this.sendTemplate(recipient, { template_type: 'list', elements, buttons, top_element_style: options.top_element_style || 'large' }, (0, _lodash2.default)(options, ['top_element_style']));this.sendOpenGraphTemplate = (recipient, elements, options) => this.sendTemplate(recipient, { template_type: 'open_graph', elements }, options);this.sendReceiptTemplate = (recipient, attrs, options) => this.sendTemplate(recipient, _extends({ template_type: 'receipt' }, attrs), options);this.sendMediaTemplate = (recipient, elements, options) => this.sendTemplate(recipient, { template_type: 'media', elements }, options);this.sendAirlineBoardingPassTemplate = (recipient, attrs, options) => this.sendTemplate(recipient, _extends({ template_type: 'airline_boardingpass' }, attrs), options);this.sendAirlineCheckinTemplate = (recipient, attrs, options) => this.sendTemplate(recipient, _extends({ template_type: 'airline_checkin' }, attrs), options);this.sendAirlineItineraryTemplate = (recipient, attrs, options) => this.sendTemplate(recipient, _extends({ template_type: 'airline_itinerary' }, attrs), options);this.sendAirlineFlightUpdateTemplate = (recipient, attrs, options) => this.sendTemplate(recipient, _extends({ template_type: 'airline_update' }, attrs), options);this.sendQuickReplies = (recipient, textOrAttachment, quickReplies, options) => {(0, _warning2.default)(false, '`sendQuickReplies` is deprecated. Use send message methods with `options.quick_replies` instead.');validateQuickReplies(quickReplies);return this.sendMessage(recipient, _extends({}, textOrAttachment, { quick_replies: quickReplies }), options);};this.sendSenderAction = (idOrRecipient, action) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody({ recipient, sender_action: action });};this.markSeen = recipient => this.sendSenderAction(recipient, 'mark_seen');this.typingOn = recipient => this.sendSenderAction(recipient, 'typing_on');this.typingOff = recipient => this.sendSenderAction(recipient, 'typing_off');this.sendBatch = batch => {(0, _invariant2.default)(batch.length <= 50, 'limit the number of requests which can be in a batch to 50');const bodyEncodedbatch = batch.map(item => {if (item.body) {return _extends({}, item, { body: Object.keys(item.body).map(key => {// $FlowFixMe item.body should not possible as undefined.
const val = item.body[key];return `${encodeURIComponent(key)}=${encodeURIComponent(typeof val === 'object' ? JSON.stringify(val) : val)}`;}).join('&') });}return item;});return _axios2.default.post('https://graph.facebook.com/', { access_token: this._accessToken, batch: bodyEncodedbatch }).then(res => res.data);};this.createMessageCreative = (messages = []) => this._axios.post(`/me/message_creatives?access_token=${this._accessToken}`, { messages }).then(res => res.data, handleError);this.sendBroadcastMessage = (messageCreativeId, options = {}) => this._axios.post(`/me/broadcast_messages?access_token=${this._accessToken}`, _extends({ message_creative_id: messageCreativeId }, options)).then(res => res.data, handleError);this.sendSponsoredMessage = (adAccountId, message) => this._axios.post(`/act_${adAccountId}/sponsored_message_ads?access_token=${this._accessToken}`, message).then(res => res.data, handleError);this.createLabel = name => this._axios.post(`/me/custom_labels?access_token=${this._accessToken}`, { name }).then(res => res.data, handleError);this.associateLabel = (userId, labelId) => this._axios.post(`/${labelId}/label?access_token=${this._accessToken}`, { user: userId }).then(res => res.data, handleError);this.dissociateLabel = (userId, labelId) => this._axios.delete(`/${labelId}/label?access_token=${this._accessToken}`, { data: { user: userId } }).then(res => res.data, handleError);this.getAssociatedLabels = userId => this._axios.get(`/${userId}/custom_labels?access_token=${this._accessToken}`).then(res => res.data, handleError);this.getLabelDetails = (labelId, options = {}) => {const fields = options.fields ? options.fields.join(',') : 'name';return this._axios.get(`/${labelId}?fields=${fields}&access_token=${this._accessToken}`).then(res => res.data, handleError);};this.getLabelList = (options = {}) => {const fields = options.fields ? options.fields.join(',') : 'name';return this._axios.get(`/me/custom_labels?fields=${fields}&access_token=${this._accessToken}`).then(res => res.data, handleError);};this.deleteLabel = labelId => this._axios.delete(`/${labelId}?access_token=${this._accessToken}`).then(res => res.data, handleError);this.startReachEstimation = customLabelId => this._axios.post(`/broadcast_reach_estimations?access_token=${this._accessToken}`, { custom_label_id: customLabelId }).then(res => res.data, handleError);this.getReachEstimate = reachEstimationId => this._axios.post(`/${reachEstimationId}?access_token=${this._accessToken}`).then(res => res.data, handleError);this.getBroadcastMessagesSent = broadcastId => this._axios.post(`/${broadcastId}/insights/messages_sent?access_token=${this._accessToken}`).then(res => res.data.data, handleError);this.uploadAttachment = (type, attachment) => {const args = [];if (typeof attachment === 'string') {args.push({ message: { attachment: { type, payload: { url: attachment, is_reusable: true } } } });} else {const form = new _formData2.default();form.append('message', JSON.stringify({ attachment: { type, payload: { is_reusable: true } } }));form.append('filedata', attachment);args.push(form, { headers: form.getHeaders() });}return this._axios.post(`/me/message_attachments?access_token=${this._accessToken}`, ...args).then(res => res.data, handleError);};this.uploadAudio = attachment => this.uploadAttachment('audio', attachment);this.uploadImage = attachment => this.uploadAttachment('image', attachment);this.uploadVideo = attachment => this.uploadAttachment('video', attachment);this.uploadFile = attachment => this.uploadAttachment('file', attachment);this.generateMessengerCode = (options = {}) => this._axios.post(`/me/messenger_codes?access_token=${this._accessToken}`, _extends({ type: 'standard' }, options)).then(res => res.data, handleError);this.passThreadControl = (recipientId, targetAppId, metadata) => this._axios.post(`/me/pass_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, target_app_id: targetAppId, metadata }).then(res => res.data, handleError);this.passThreadControlToPageInbox = (recipientId, metadata) => this.passThreadControl(recipientId, 263902037430900, metadata);this.takeThreadControl = (recipientId, metadata) => this._axios.post(`/me/take_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, metadata }).then(res => res.data, handleError);this.getSecondaryReceivers = () => this._axios.get(`/me/secondary_receivers?fields=id,name&access_token=${this._accessToken}`).then(res => res.data.data, handleError);this.getInsights = (metrics, options = {}) => this._axios.get(`/me/insights/?${_querystring2.default.stringify(_extends({ metric: metrics.join(','), access_token: this._accessToken }, options))}`).then(res => res.data.data, handleError);this.getDailyUniqueActiveThreadCounts = () => this.getInsights(['page_messages_active_threads_unique']);this.getBlockedConversations = () => this.getInsights(['page_messages_blocked_conversations_unique']);this.getReportedConversations = () => this.getInsights(['page_messages_reported_conversations_unique']);this.getReportedConversationsByReportType = () => this.getInsights(['page_messages_blocked_conversations_unique']);this.getDailyUniqueConversationCounts = () => {(0, _warning2.default)(false, 'page_messages_feedback_by_action_unique is deprecated as of November 7, 2017.\nThis metric will be removed in Graph API v2.12.');return this.getInsights(['page_messages_feedback_by_action_unique']);};this.setNLPConfigs = (config = {}) => this._axios.post(`/me/nlp_configs?${_querystring2.default.stringify(config)}`, { access_token: this._accessToken }).then(res => res.data, handleError);this.enableNLP = () => this.setNLPConfigs({ nlp_enabled: true });this.disableNLP = () => this.setNLPConfigs({ nlp_enabled: false });this.logCustomEvents = ({ appId, pageId, userId, events }) =>
const val = item.body[key];return `${encodeURIComponent(key)}=${encodeURIComponent(typeof val === 'object' ? JSON.stringify(val) : val)}`;}).join('&') });}return item;});return _axios2.default.post('https://graph.facebook.com/', { access_token: this._accessToken, batch: bodyEncodedbatch }).then(res => res.data);};this.createMessageCreative = (messages = []) => this._axios.post(`/me/message_creatives?access_token=${this._accessToken}`, { messages }).then(res => res.data, handleError);this.sendBroadcastMessage = (messageCreativeId, options = {}) => this._axios.post(`/me/broadcast_messages?access_token=${this._accessToken}`, _extends({ message_creative_id: messageCreativeId }, options)).then(res => res.data, handleError);this.sendSponsoredMessage = (adAccountId, message) => this._axios.post(`/act_${adAccountId}/sponsored_message_ads?access_token=${this._accessToken}`, message).then(res => res.data, handleError);this.createLabel = name => this._axios.post(`/me/custom_labels?access_token=${this._accessToken}`, { name }).then(res => res.data, handleError);this.associateLabel = (userId, labelId) => this._axios.post(`/${labelId}/label?access_token=${this._accessToken}`, { user: userId }).then(res => res.data, handleError);this.dissociateLabel = (userId, labelId) => this._axios.delete(`/${labelId}/label?access_token=${this._accessToken}`, { data: { user: userId } }).then(res => res.data, handleError);this.getAssociatedLabels = userId => this._axios.get(`/${userId}/custom_labels?access_token=${this._accessToken}`).then(res => res.data, handleError);this.getLabelDetails = (labelId, options = {}) => {const fields = options.fields ? options.fields.join(',') : 'name';return this._axios.get(`/${labelId}?fields=${fields}&access_token=${this._accessToken}`).then(res => res.data, handleError);};this.getLabelList = (options = {}) => {const fields = options.fields ? options.fields.join(',') : 'name';return this._axios.get(`/me/custom_labels?fields=${fields}&access_token=${this._accessToken}`).then(res => res.data, handleError);};this.deleteLabel = labelId => this._axios.delete(`/${labelId}?access_token=${this._accessToken}`).then(res => res.data, handleError);this.startReachEstimation = customLabelId => this._axios.post(`/broadcast_reach_estimations?access_token=${this._accessToken}`, { custom_label_id: customLabelId }).then(res => res.data, handleError);this.getReachEstimate = reachEstimationId => this._axios.post(`/${reachEstimationId}?access_token=${this._accessToken}`).then(res => res.data, handleError);this.getBroadcastMessagesSent = broadcastId => this._axios.post(`/${broadcastId}/insights/messages_sent?access_token=${this._accessToken}`).then(res => res.data.data, handleError);this.uploadAttachment = (type, attachment, options) => {const args = [];if (typeof attachment === 'string') {args.push({ message: { attachment: { type, payload: { url: attachment, is_reusable: true } } } });} else {const form = new _formData2.default();form.append('message', JSON.stringify({ attachment: { type, payload: { is_reusable: true } } }));form.append('filedata', attachment, options);args.push(form, { headers: form.getHeaders() });}return this._axios.post(`/me/message_attachments?access_token=${this._accessToken}`, ...args).then(res => res.data, handleError);};this.uploadAudio = (attachment, options) => this.uploadAttachment('audio', attachment, options);this.uploadImage = (attachment, options) => this.uploadAttachment('image', attachment, options);this.uploadVideo = (attachment, options) => this.uploadAttachment('video', attachment, options);this.uploadFile = (attachment, options) => this.uploadAttachment('file', attachment, options);this.generateMessengerCode = (options = {}) => this._axios.post(`/me/messenger_codes?access_token=${this._accessToken}`, _extends({ type: 'standard' }, options)).then(res => res.data, handleError);this.passThreadControl = (recipientId, targetAppId, metadata) => this._axios.post(`/me/pass_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, target_app_id: targetAppId, metadata }).then(res => res.data, handleError);this.passThreadControlToPageInbox = (recipientId, metadata) => this.passThreadControl(recipientId, 263902037430900, metadata);this.takeThreadControl = (recipientId, metadata) => this._axios.post(`/me/take_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, metadata }).then(res => res.data, handleError);this.getSecondaryReceivers = () => this._axios.get(`/me/secondary_receivers?fields=id,name&access_token=${this._accessToken}`).then(res => res.data.data, handleError);this.getInsights = (metrics, options = {}) => this._axios.get(`/me/insights/?${_querystring2.default.stringify(_extends({ metric: metrics.join(','), access_token: this._accessToken }, options))}`).then(res => res.data.data, handleError);this.getDailyUniqueActiveThreadCounts = () => this.getInsights(['page_messages_active_threads_unique']);this.getBlockedConversations = () => this.getInsights(['page_messages_blocked_conversations_unique']);this.getReportedConversations = () => this.getInsights(['page_messages_reported_conversations_unique']);this.getReportedConversationsByReportType = () => this.getInsights(['page_messages_blocked_conversations_unique']);this.getDailyUniqueConversationCounts = () => {(0, _warning2.default)(false, 'page_messages_feedback_by_action_unique is deprecated as of November 7, 2017.\nThis metric will be removed in Graph API v2.12.');return this.getInsights(['page_messages_feedback_by_action_unique']);};this.setNLPConfigs = (config = {}) => this._axios.post(`/me/nlp_configs?${_querystring2.default.stringify(config)}`, { access_token: this._accessToken }).then(res => res.data, handleError);this.enableNLP = () => this.setNLPConfigs({ nlp_enabled: true });this.disableNLP = () => this.setNLPConfigs({ nlp_enabled: false });this.logCustomEvents = ({ appId, pageId, userId, events }) =>

@@ -1390,0 +1392,0 @@

{
"name": "messaging-api-messenger",
"description": "Messaging API client for Messenger",
"version": "0.5.12",
"version": "0.5.13",
"engines": {

@@ -6,0 +6,0 @@ "node": ">=6"

@@ -21,2 +21,3 @@ /* @flow */

SendOption,
UploadOption,
TemplateButton,

@@ -1198,3 +1199,4 @@ MenuItem,

type: 'audio' | 'image' | 'video' | 'file',
attachment: string | FileData
attachment: string | FileData,
options?: UploadOption
) => {

@@ -1230,3 +1232,3 @@ const args = [];

form.append('filedata', attachment);
form.append('filedata', attachment, options);

@@ -1246,10 +1248,10 @@ args.push(form, {

uploadAudio = (attachment: string | FileData) =>
this.uploadAttachment('audio', attachment);
uploadImage = (attachment: string | FileData) =>
this.uploadAttachment('image', attachment);
uploadVideo = (attachment: string | FileData) =>
this.uploadAttachment('video', attachment);
uploadFile = (attachment: string | FileData) =>
this.uploadAttachment('file', attachment);
uploadAudio = (attachment: string | FileData, options?: UploadOption) =>
this.uploadAttachment('audio', attachment, options);
uploadImage = (attachment: string | FileData, options?: UploadOption) =>
this.uploadAttachment('image', attachment, options);
uploadVideo = (attachment: string | FileData, options?: UploadOption) =>
this.uploadAttachment('video', attachment, options);
uploadFile = (attachment: string | FileData, options?: UploadOption) =>
this.uploadAttachment('file', attachment, options);

@@ -1256,0 +1258,0 @@ /**

@@ -89,2 +89,6 @@ /* @flow */

export type UploadOption = {
filename?: string,
};
export type TemplateButton = {

@@ -91,0 +95,0 @@ type: string,

Sorry, the diff of this file is too big to display

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