Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const appSecretProof = crypto
.createHmac('sha256', appSecret)
.update(accessToken, 'utf8')
.digest('hex');
// eslint-disable-next-line no-param-reassign
config.url = appendQuery(config.url || '', {
appsecret_proof: appSecretProof,
});
return config;
});
}
this._axios.interceptors.request.use(
createRequestInterceptor({ onRequest: this._onRequest })
);
}
this._token = config.accessToken;
this._onRequest = config.onRequest;
origin = config.origin;
}
// Web API
// https://api.slack.com/web
this._axios = axios.create({
baseURL: `${origin || 'https://slack.com'}/api/`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
});
this._axios.interceptors.request.use(
createRequestInterceptor({ onRequest: this._onRequest })
);
this.chat = {
postMessage: this._postMessage.bind(this),
postEphemeral: this._postEphemeral.bind(this),
update: this._updateMessage.bind(this),
delete: this._deleteMessage.bind(this),
meMessage: this._meMessage.bind(this),
getPermalink: this._getPermalink.bind(this),
scheduleMessage: this._scheduleMessage.bind(this),
deleteScheduledMessage: this._deleteScheduledMessage.bind(this),
unfurl: this._unfurl.bind(this),
scheduledMessages: {
list: this._getScheduledMessages.bind(this),
},
};
url = config.url;
this._onRequest = config.onRequest;
} else {
url = urlOrConfig;
}
// incoming webhooks
// https://api.slack.com/incoming-webhooks
this._axios = axios.create({
baseURL: url,
headers: { 'Content-Type': 'application/json' },
});
this._axios.interceptors.request.use(
createRequestInterceptor({ onRequest: this._onRequest })
);
}
this._token = config.accessToken;
this._onRequest = config.onRequest;
origin = config.origin;
} else {
this._token = accessTokenOrConfig;
}
this._axios = axios.create({
baseURL: `${origin || 'https://api.telegram.org'}/bot${this._token}/`,
headers: {
'Content-Type': 'application/json',
},
});
this._axios.interceptors.request.use(
createRequestInterceptor({
onRequest: this._onRequest,
})
);
}
origin = config.origin;
} else {
this._appId = appIdOrClientConfig;
this._appSecret = appSecret;
this._onRequest = onRequest;
}
this._axios = axios.create({
baseURL: `${origin || 'https://api.weixin.qq.com'}/cgi-bin/`,
headers: {
'Content-Type': 'application/json',
},
});
this._axios.interceptors.request.use(
createRequestInterceptor({
onRequest: this._onRequest,
})
);
}
origin = config.origin;
} else {
this._accessToken = accessTokenOrConfig;
this._channelSecret = channelSecret as string;
}
this._axios = axios.create({
baseURL: `${origin || 'https://api.line.me'}/`,
headers: {
Authorization: `Bearer ${this._accessToken}`,
'Content-Type': 'application/json',
},
});
this._axios.interceptors.request.use(
createRequestInterceptor({ onRequest: this._onRequest })
);
}
} else {
this._token = accessTokenOrConfig;
this._sender = sender as Types.Sender;
this._onRequest = onRequest;
}
this._axios = axios.create({
baseURL: `${origin || 'https://chatapi.viber.com'}/pa/`,
headers: {
'Content-Type': 'application/json',
'X-Viber-Auth-Token': this._token,
},
});
this._axios.interceptors.request.use(
createRequestInterceptor({ onRequest: this._onRequest })
);
}