sckim

package.json is updated

Showing 60 changed files with 3454 additions and 1706 deletions
## 6.8.3 (05 Nov 2019)
### Bug fix
* Add exception handler in middleware (#153)
### Feature
* Flex Message Update 1 (#173)
* Support friend statistics API (#161)
### Misc
* Update dependencies (#174)
## 6.8.2 (08 Aug 2019)
### Bug fix
* Fix LINEThings Scenario Execution Event Types (#158)
## 6.8.1 (29 Jul 2019)
### Bug fix
* Fix a type wrong in Template Message (#163)
### Feature
* Get `X-LINE-Request-Id` by using `responseData['x-line-request-id']` (#151 #157)
## 6.8.0 (25 Jun 2019)
### Feature
* Add new parameter in push/reply/multicast/broadcast API to catch up the newest bot API (#147)
* Add new APIs in bot API (#147)
- Get the target limit for additional messages
- Get number of messages sent this month
- Get number of sent broadcast messages
- Send broadcast message
### Breaking changes
* Deprecate Node 6 and start to support Node 12 (#139)
* Remove polyfills for Node 6 (#149)
### Type
* Add LINE Things Event (#150)
### Misc
* Update axios and other dependencies by running `npm audit fix` to fix vulnerabilities. (#148 #154)
## 6.7.0 (18 Apr 2019)
### Feature
* Add alt URL field to URI action (#135)
* Implement (un)linkRichMenuToMultipleUsers (#135)
### Type
* Fix typo in a type (#124)
## 6.6.0 (4 Mar 2019)
### Feature
* Add DeviceLinkEvent / DeviceUnlinkEvent (#123)
### Type
* Fix FlexSpacer to have optional 'size' property (#122)
### Misc
* Run `npm audit fix` to fix minor dependency vulnerability.
## 6.5.0 (16 Feb 2019)
### Feature
* Add APIs to get number of sent messages (#116)
* Add account link event (#117)
### Misc
* Fix a typo in doc (#119)
## 6.4.0 (19 Nov 2018)
### Feature
......
# line-bot-sdk-nodejs
# LINE Messaging API SDK for nodejs
[![Travis CI](https://travis-ci.org/line/line-bot-sdk-nodejs.svg?branch=master)](https://travis-ci.org/line/line-bot-sdk-nodejs)
[![npmjs](https://badge.fury.io/js/%40line%2Fbot-sdk.svg)](https://www.npmjs.com/package/@line/bot-sdk)
Node.js SDK for LINE Messaging API
## Getting Started
## Introduction
The LINE Messaging API SDK for nodejs makes it easy to develop bots using LINE Messaging API, and you can create a sample bot within minutes.
### Install
## Documentation
See the official API documentation for more information
- English: https://developers.line.biz/en/docs/messaging-api/overview/
- Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/
line-bot-sdk-nodejs documentation: https://line.github.io/line-bot-sdk-nodejs/#getting-started
## Requirements
* **Node.js** 8 or higher
## Installation
Using [npm](https://www.npmjs.com/):
......@@ -15,30 +28,37 @@ Using [npm](https://www.npmjs.com/):
$ npm install @line/bot-sdk --save
```
### Documentation
For guide, API reference, and other information, please refer to
the [documentation](https://line.github.io/line-bot-sdk-nodejs/).
## Help and media
FAQ: https://developers.line.biz/en/faq/
### LINE Messaging API References
Community Q&A: https://www.line-community.me/questions
Here are links to official references for LINE Messaging API. It is recommended
reading them beforehand.
News: https://developers.line.biz/en/news/
* LINE API Reference [EN](https://developers.line.me/en/docs/messaging-api/reference/) [JA](https://developers.line.me/ja/docs/messaging-api/reference/)
* LINE Developers - Messaging API
* [Overview](https://developers.line.me/messaging-api/overview)
* [Getting started](https://developers.line.me/messaging-api/getting-started)
* [Joining groups and rooms](https://developers.line.me/messaging-api/joining-groups-and-rooms)
Twitter: @LINE_DEV
## Requirements
## Versioning
This project respects semantic versioning
* **Node.js** 6 or higher
See http://semver.org/
## Contributing
Please check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution.
## License
[Apache License Version 2.0](LICENSE)
```
Copyright (C) 2016 LINE Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
......
......@@ -5,9 +5,11 @@ export default class Client {
config: Types.ClientConfig;
private http;
constructor(config: Types.ClientConfig);
pushMessage(to: string, messages: Types.Message | Types.Message[]): Promise<any>;
replyMessage(replyToken: string, messages: Types.Message | Types.Message[]): Promise<any>;
multicast(to: string[], messages: Types.Message | Types.Message[]): Promise<any>;
private parseHTTPResponse;
pushMessage(to: string, messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
replyMessage(replyToken: string, messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
multicast(to: string[], messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
broadcast(messages: Types.Message | Types.Message[], notificationDisabled?: boolean): Promise<Types.MessageAPIResponseBase>;
getProfile(userId: string): Promise<Types.Profile>;
private getChatMemberProfile;
getGroupMemberProfile(groupId: string, userId: string): Promise<Types.Profile>;
......@@ -25,6 +27,8 @@ export default class Client {
getRichMenuIdOfUser(userId: string): Promise<string>;
linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>;
unlinkRichMenuFromUser(userId: string): Promise<any>;
linkRichMenuToMultipleUsers(richMenuId: string, userIds: string[]): Promise<any>;
unlinkRichMenusFromMultipleUsers(userIds: string[]): Promise<any>;
getRichMenuImage(richMenuId: string): Promise<Readable>;
setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>;
getRichMenuList(): Promise<Array<Types.RichMenuResponse>>;
......@@ -32,4 +36,23 @@ export default class Client {
getDefaultRichMenuId(): Promise<string>;
deleteDefaultRichMenu(): Promise<{}>;
getLinkToken(userId: string): Promise<string>;
getNumberOfSentReplyMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>;
getNumberOfSentPushMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>;
getNumberOfSentMulticastMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>;
getTargetLimitForAdditionalMessages(): Promise<Types.TargetLimitForAdditionalMessages>;
getNumberOfMessagesSentThisMonth(): Promise<Types.NumberOfMessagesSentThisMonth>;
getNumberOfSentBroadcastMessages(date: string): Promise<Types.NumberOfMessagesSentResponse>;
getNumberOfMessageDeliveries(date: string): Promise<Types.NumberOfMessageDeliveriesResponse>;
getNumberOfFollowers(date: string): Promise<Types.NumberOfFollowersResponse>;
getFriendDemographics(): Promise<Types.FriendDemoGraphics>;
}
export declare class OAuth {
private http;
constructor();
issueAccessToken(client_id: string, client_secret: string): Promise<{
access_token: string;
expires_in: number;
token_type: "Bearer";
}>;
revokeAccessToken(access_token: string): Promise<{}>;
}
......
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const http_1 = require("./http");
const Types = require("./types");
const exceptions_1 = require("./exceptions");
function toArray(maybeArr) {
return Array.isArray(maybeArr) ? maybeArr : [maybeArr];
}
function checkJSON(raw) {
function ensureJSON(raw) {
if (typeof raw === "object") {
return raw;
}
......@@ -13,133 +14,211 @@ function checkJSON(raw) {
throw new exceptions_1.JSONParseError("Failed to parse response body as JSON", raw);
}
}
const API_HOST = process.env.API_BASE_URL || "https://api.line.me/v2/";
const BOT_BASE_URL = process.env.API_BASE_URL || `${API_HOST}bot/`;
const OAUTH_BASE_URL = `${API_HOST}oauth/`;
class Client {
constructor(config) {
if (!config.channelAccessToken) {
throw new Error("no channel access token");
}
this.config = config;
this.http = new http_1.default(process.env.API_BASE_URL || "https://api.line.me/v2/bot/", {
Authorization: "Bearer " + this.config.channelAccessToken,
this.http = new http_1.default({
baseURL: BOT_BASE_URL,
defaultHeaders: {
Authorization: "Bearer " + this.config.channelAccessToken,
},
responseParser: this.parseHTTPResponse.bind(this),
});
}
pushMessage(to, messages) {
parseHTTPResponse(response) {
const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types;
let resBody = Object.assign({}, response.data);
if (response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME]) {
resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] =
response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME];
}
return resBody;
}
pushMessage(to, messages, notificationDisabled = false) {
return this.http.post("/message/push", {
messages: toArray(messages),
to,
notificationDisabled,
});
}
replyMessage(replyToken, messages) {
replyMessage(replyToken, messages, notificationDisabled = false) {
return this.http.post("/message/reply", {
messages: toArray(messages),
replyToken,
notificationDisabled,
});
}
multicast(to, messages) {
async multicast(to, messages, notificationDisabled = false) {
return this.http.post("/message/multicast", {
messages: toArray(messages),
to,
notificationDisabled,
});
}
getProfile(userId) {
return this.http.get(`/profile/${userId}`).then(checkJSON);
async broadcast(messages, notificationDisabled = false) {
return this.http.post("/message/broadcast", {
messages: toArray(messages),
notificationDisabled,
});
}
getChatMemberProfile(chatType, chatId, userId) {
return this.http
.get(`/${chatType}/${chatId}/member/${userId}`)
.then(checkJSON);
async getProfile(userId) {
const profile = await this.http.get(`/profile/${userId}`);
return ensureJSON(profile);
}
getGroupMemberProfile(groupId, userId) {
async getChatMemberProfile(chatType, chatId, userId) {
const profile = await this.http.get(`/${chatType}/${chatId}/member/${userId}`);
return ensureJSON(profile);
}
async getGroupMemberProfile(groupId, userId) {
return this.getChatMemberProfile("group", groupId, userId);
}
getRoomMemberProfile(roomId, userId) {
async getRoomMemberProfile(roomId, userId) {
return this.getChatMemberProfile("room", roomId, userId);
}
getChatMemberIds(chatType, chatId) {
const load = (start) => this.http
.get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null)
.then(checkJSON)
.then((res) => {
if (!res.next) {
return res.memberIds;
}
return load(res.next).then(extraIds => res.memberIds.concat(extraIds));
});
return load();
}
getGroupMemberIds(groupId) {
async getChatMemberIds(chatType, chatId) {
let memberIds = [];
let start;
do {
const res = await this.http.get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null);
ensureJSON(res);
memberIds = memberIds.concat(res.memberIds);
start = res.next;
} while (start);
return memberIds;
}
async getGroupMemberIds(groupId) {
return this.getChatMemberIds("group", groupId);
}
getRoomMemberIds(roomId) {
async getRoomMemberIds(roomId) {
return this.getChatMemberIds("room", roomId);
}
getMessageContent(messageId) {
async getMessageContent(messageId) {
return this.http.getStream(`/message/${messageId}/content`);
}
leaveChat(chatType, chatId) {
return this.http.post(`/${chatType}/${chatId}/leave`);
}
leaveGroup(groupId) {
async leaveGroup(groupId) {
return this.leaveChat("group", groupId);
}
leaveRoom(roomId) {
async leaveRoom(roomId) {
return this.leaveChat("room", roomId);
}
getRichMenu(richMenuId) {
return this.http
.get(`/richmenu/${richMenuId}`)
.then(checkJSON);
async getRichMenu(richMenuId) {
const res = await this.http.get(`/richmenu/${richMenuId}`);
return ensureJSON(res);
}
createRichMenu(richMenu) {
return this.http
.post("/richmenu", richMenu)
.then(checkJSON)
.then(res => res.richMenuId);
async createRichMenu(richMenu) {
const res = await this.http.post("/richmenu", richMenu);
return ensureJSON(res).richMenuId;
}
deleteRichMenu(richMenuId) {
async deleteRichMenu(richMenuId) {
return this.http.delete(`/richmenu/${richMenuId}`);
}
getRichMenuIdOfUser(userId) {
return this.http
.get(`/user/${userId}/richmenu`)
.then(checkJSON)
.then(res => res.richMenuId);
async getRichMenuIdOfUser(userId) {
const res = await this.http.get(`/user/${userId}/richmenu`);
return ensureJSON(res).richMenuId;
}
linkRichMenuToUser(userId, richMenuId) {
async linkRichMenuToUser(userId, richMenuId) {
return this.http.post(`/user/${userId}/richmenu/${richMenuId}`);
}
unlinkRichMenuFromUser(userId) {
async unlinkRichMenuFromUser(userId) {
return this.http.delete(`/user/${userId}/richmenu`);
}
getRichMenuImage(richMenuId) {
async linkRichMenuToMultipleUsers(richMenuId, userIds) {
return this.http.post("/richmenu/bulk/link", {
richMenuId,
userIds,
});
}
async unlinkRichMenusFromMultipleUsers(userIds) {
return this.http.post("/richmenu/bulk/unlink", {
userIds,
});
}
async getRichMenuImage(richMenuId) {
return this.http.getStream(`/richmenu/${richMenuId}/content`);
}
setRichMenuImage(richMenuId, data, contentType) {
async setRichMenuImage(richMenuId, data, contentType) {
return this.http.postBinary(`/richmenu/${richMenuId}/content`, data, contentType);
}
getRichMenuList() {
return this.http
.get(`/richmenu/list`)
.then(checkJSON)
.then(res => res.richmenus);
async getRichMenuList() {
const res = await this.http.get(`/richmenu/list`);
return ensureJSON(res).richmenus;
}
setDefaultRichMenu(richMenuId) {
async setDefaultRichMenu(richMenuId) {
return this.http.post(`/user/all/richmenu/${richMenuId}`);
}
getDefaultRichMenuId() {
return this.http
.get("/user/all/richmenu")
.then(checkJSON)
.then(res => res.richMenuId);
async getDefaultRichMenuId() {
const res = await this.http.get("/user/all/richmenu");
return ensureJSON(res).richMenuId;
}
deleteDefaultRichMenu() {
async deleteDefaultRichMenu() {
return this.http.delete("/user/all/richmenu");
}
getLinkToken(userId) {
return this.http
.post(`/user/${userId}/linkToken`)
.then(checkJSON)
.then(res => res.linkToken);
async getLinkToken(userId) {
const res = await this.http.post(`/user/${userId}/linkToken`);
return ensureJSON(res).linkToken;
}
async getNumberOfSentReplyMessages(date) {
const res = await this.http.get(`/message/delivery/reply?date=${date}`);
return ensureJSON(res);
}
async getNumberOfSentPushMessages(date) {
const res = await this.http.get(`/message/delivery/push?date=${date}`);
return ensureJSON(res);
}
async getNumberOfSentMulticastMessages(date) {
const res = await this.http.get(`/message/delivery/multicast?date=${date}`);
return ensureJSON(res);
}
async getTargetLimitForAdditionalMessages() {
const res = await this.http.get("/message/quota");
return ensureJSON(res);
}
async getNumberOfMessagesSentThisMonth() {
const res = await this.http.get("/message/quota/consumption");
return ensureJSON(res);
}
async getNumberOfSentBroadcastMessages(date) {
const res = await this.http.get(`/message/delivery/broadcast?date=${date}`);
return ensureJSON(res);
}
async getNumberOfMessageDeliveries(date) {
const res = await this.http.get(`/insight/message/delivery?date=${date}`);
return ensureJSON(res);
}
async getNumberOfFollowers(date) {
const res = await this.http.get(`/insight/followers?date=${date}`);
return ensureJSON(res);
}
async getFriendDemographics() {
const res = await this.http.get(`/insight/demographic`);
return ensureJSON(res);
}
}
exports.default = Client;
class OAuth {
constructor() {
this.http = new http_1.default({
baseURL: OAUTH_BASE_URL,
});
}
issueAccessToken(client_id, client_secret) {
return this.http.postForm("/accessToken", {
grant_type: "client_credentials",
client_id,
client_secret,
});
}
revokeAccessToken(access_token) {
return this.http.postForm("/revoke", { access_token });
}
}
exports.OAuth = OAuth;
......
/// <reference types="node" />
import { AxiosResponse } from "axios";
import { Readable } from "stream";
declare type httpClientConfig = {
baseURL?: string;
defaultHeaders?: any;
responseParser?: <T>(res: AxiosResponse) => T;
};
export default class HTTPClient {
private instance;
constructor(baseURL?: string, defaultHeaders?: any);
private config;
constructor(config?: httpClientConfig);
get<T>(url: string, params?: any): Promise<T>;
getStream(url: string, params?: any): Promise<Readable>;
post<T>(url: string, data?: any): Promise<T>;
post<T>(url: string, body?: any): Promise<T>;
postForm<T>(url: string, body?: any): Promise<T>;
postBinary<T>(url: string, data: Buffer | Readable, contentType?: string): Promise<T>;
delete<T>(url: string, params?: any): Promise<T>;
private wrapError;
}
export {};
......
......@@ -4,9 +4,12 @@ const axios_1 = require("axios");
const stream_1 = require("stream");
const exceptions_1 = require("./exceptions");
const fileType = require("file-type");
const qs = require("querystring");
const pkg = require("../package.json");
class HTTPClient {
constructor(baseURL, defaultHeaders) {
constructor(config = {}) {
this.config = config;
const { baseURL, defaultHeaders } = config;
this.instance = axios_1.default.create({
baseURL,
headers: Object.assign({}, defaultHeaders, {
......@@ -15,27 +18,40 @@ class HTTPClient {
});
this.instance.interceptors.response.use(res => res, err => Promise.reject(this.wrapError(err)));
}
get(url, params) {
return this.instance.get(url, { params }).then(res => res.data);
async get(url, params) {
const res = await this.instance.get(url, { params });
return res.data;
}
getStream(url, params) {
return this.instance
.get(url, { params, responseType: "stream" })
.then(res => res.data);
async getStream(url, params) {
const res = await this.instance.get(url, {
params,
responseType: "stream",
});
return res.data;
}
post(url, data) {
return this.instance
.post(url, data, { headers: { "Content-Type": "application/json" } })
.then(res => res.data);
async post(url, body) {
const res = await this.instance.post(url, body, {
headers: { "Content-Type": "application/json" },
});
const { responseParser } = this.config;
if (responseParser)
return responseParser(res);
else
return res.data;
}
postBinary(url, data, contentType) {
let getBuffer;
if (Buffer.isBuffer(data)) {
getBuffer = Promise.resolve(data);
}
else {
getBuffer = new Promise((resolve, reject) => {
if (data instanceof stream_1.Readable) {
async postForm(url, body) {
const res = await this.instance.post(url, qs.stringify(body), {
headers: { "Content-Type": "application/x-www-form-urlencoded" },
});
return res.data;
}
async postBinary(url, data, contentType) {
const buffer = await (async () => {
if (Buffer.isBuffer(data)) {
return data;
}
else if (data instanceof stream_1.Readable) {
return new Promise((resolve, reject) => {
const buffers = [];
let size = 0;
data.on("data", (chunk) => {
......@@ -44,25 +60,23 @@ class HTTPClient {
});
data.on("end", () => resolve(Buffer.concat(buffers, size)));
data.on("error", reject);
}
else {
reject(new Error("invalid data type for postBinary"));
}
});
}
return getBuffer.then(data => {
return this.instance
.post(url, data, {
headers: {
"Content-Type": contentType || fileType(data).mime,
"Content-Length": data.length,
},
})
.then(res => res.data);
});
}
else {
throw new Error("invalid data type for postBinary");
}
})();
const res = await this.instance.post(url, buffer, {
headers: {
"Content-Type": contentType || fileType(buffer).mime,
"Content-Length": buffer.length,
},
});
return res.data;
}
delete(url, params) {
return this.instance.delete(url, { params }).then(res => res.data);
async delete(url, params) {
const res = await this.instance.delete(url, { params });
return res.data;
}
wrapError(err) {
if (err.response) {
......
import Client from "./client";
import Client, { OAuth } from "./client";
import middleware from "./middleware";
import validateSignature from "./validate-signature";
export { Client, middleware, validateSignature };
export { Client, middleware, validateSignature, OAuth };
export * from "./exceptions";
export * from "./types";
......
......@@ -5,9 +5,11 @@ function __export(m) {
Object.defineProperty(exports, "__esModule", { value: true });
const client_1 = require("./client");
exports.Client = client_1.default;
exports.OAuth = client_1.OAuth;
const middleware_1 = require("./middleware");
exports.middleware = middleware_1.default;
const validate_signature_1 = require("./validate-signature");
exports.validateSignature = validate_signature_1.default;
// re-export exceptions and types
__export(require("./exceptions"));
__export(require("./types"));
......
......@@ -6,5 +6,5 @@ export declare type Request = http.IncomingMessage & {
};
export declare type Response = http.ServerResponse;
export declare type NextCallback = (err?: Error) => void;
export declare type Middleware = (req: Request, res: Response, next: NextCallback) => void;
export declare type Middleware = (req: Request, res: Response, next: NextCallback) => void | Promise<void>;
export default function middleware(config: Types.MiddlewareConfig): Middleware;
......
......@@ -11,7 +11,7 @@ function middleware(config) {
throw new Error("no channel secret");
}
const secret = config.channelSecret;
return (req, res, next) => {
const _middleware = async (req, res, next) => {
// header names are lower-cased
// https://nodejs.org/api/http.html#http_message_headers
const signature = req.headers["x-line-signature"];
......@@ -19,34 +19,34 @@ function middleware(config) {
next(new exceptions_1.SignatureValidationFailed("no signature"));
return;
}
let getBody;
if (isValidBody(req.rawBody)) {
// rawBody is provided in Google Cloud Functions and others
getBody = Promise.resolve(req.rawBody);
}
else if (isValidBody(req.body)) {
getBody = Promise.resolve(req.body);
}
else {
// body may not be parsed yet, parse it to a buffer
getBody = new Promise(resolve => {
body_parser_1.raw({ type: "*/*" })(req, res, () => resolve(req.body));
});
}
getBody.then(body => {
if (!validate_signature_1.default(body, secret, signature)) {
next(new exceptions_1.SignatureValidationFailed("signature validation failed", signature));
return;
const body = await (async () => {
if (isValidBody(req.rawBody)) {
// rawBody is provided in Google Cloud Functions and others
return req.rawBody;
}
const strBody = Buffer.isBuffer(body) ? body.toString() : body;
try {
req.body = JSON.parse(strBody);
next();
else if (isValidBody(req.body)) {
return req.body;
}
catch (err) {
next(new exceptions_1.JSONParseError(err.message, strBody));
else {
// body may not be parsed yet, parse it to a buffer
return new Promise((resolve, reject) => body_parser_1.raw({ type: "*/*" })(req, res, (error) => error ? reject(error) : resolve(req.body)));
}
});
})();
if (!validate_signature_1.default(body, secret, signature)) {
next(new exceptions_1.SignatureValidationFailed("signature validation failed", signature));
return;
}
const strBody = Buffer.isBuffer(body) ? body.toString() : body;
try {
req.body = JSON.parse(strBody);
next();
}
catch (err) {
next(new exceptions_1.JSONParseError(err.message, strBody));
}
};
return (req, res, next) => {
_middleware(req, res, next).catch(next);
};
}
exports.default = middleware;
......
......@@ -17,7 +17,7 @@ export declare type Profile = {
/**
* Request body which is sent by webhook.
*
* @see [Request body](https://developers.line.me/en/reference/messaging-api/#request-body)
* @see [Request body](https://developers.line.biz/en/reference/messaging-api/#request-body)
*/
export declare type WebhookRequestBody = {
/**
......@@ -32,9 +32,9 @@ export declare type WebhookRequestBody = {
/**
* JSON objects which contain events generated on the LINE Platform.
*
* @see [Webhook event objects](https://developers.line.me/en/reference/messaging-api/#webhook-event-objects)
* @see [Webhook event objects](https://developers.line.biz/en/reference/messaging-api/#webhook-event-objects)
*/
export declare type WebhookEvent = MessageEvent | FollowEvent | UnfollowEvent | JoinEvent | LeaveEvent | MemberJoinEvent | MemberLeaveEvent | PostbackEvent | BeaconEvent;
export declare type WebhookEvent = MessageEvent | FollowEvent | UnfollowEvent | JoinEvent | LeaveEvent | MemberJoinEvent | MemberLeaveEvent | PostbackEvent | BeaconEvent | AccountLinkEvent | DeviceLinkEvent | DeviceUnlinkEvent | LINEThingsScenarioExecutionEvent;
export declare type EventBase = {
/**
* Time of the event in milliseconds
......@@ -56,9 +56,9 @@ export declare type Group = {
/**
* ID of the source user.
*
* Only included in [message events](https://developers.line.me/en/reference/messaging-api/#message-event).
* Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
* Not included if the user has not agreed to the
* [Official Accounts Terms of Use](https://developers.line.me/en/docs/messaging-api/user-consent/).
* [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
*/
userId?: string;
};
......@@ -68,9 +68,9 @@ export declare type Room = {
/**
* ID of the source user.
*
* Only included in [message events](https://developers.line.me/en/reference/messaging-api/#message-event).
* Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
* Not included if the user has not agreed to the
* [Official Accounts Terms of Use](https://developers.line.me/en/docs/messaging-api/user-consent/).
* [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
*/
userId?: string;
};
......@@ -83,7 +83,7 @@ export declare type ReplyableEvent = EventBase & {
* The `message` property contains a message object which corresponds with the
* message type. You can reply to message events.
*
* @see [Message event](https://developers.line.me/en/reference/messaging-api/#message-event)
* @see [Message event](https://developers.line.biz/en/reference/messaging-api/#message-event)
*/
export declare type MessageEvent = {
type: "message";
......@@ -150,7 +150,7 @@ export declare type MemberLeaveEvent = {
} & EventBase;
/**
* Event object for when a user performs an action on a
* [template message](https://developers.line.me/en/reference/messaging-api/#template-messages).
* [template message](https://developers.line.biz/en/reference/messaging-api/#template-messages).
*/
export declare type PostbackEvent = {
type: "postback";
......@@ -158,7 +158,7 @@ export declare type PostbackEvent = {
} & ReplyableEvent;
/**
* Event object for when a user enters or leaves the range of a
* [LINE Beacon](https://developers.line.me/en/docs/messaging-api/using-beacons/).
* [LINE Beacon](https://developers.line.biz/en/docs/messaging-api/using-beacons/).
*/
export declare type BeaconEvent = ReplyableEvent & {
type: "beacon";
......@@ -179,6 +179,119 @@ export declare type BeaconEvent = ReplyableEvent & {
dm?: string;
};
};
/**
* Event object for when a user has linked his/her LINE account with a provider's service account.
*/
export declare type AccountLinkEvent = ReplyableEvent & {
type: "accountLink";
link: {
result: "ok" | "failed";
/**
* Specified nonce when verifying the user ID
*/
nonce: string;
};
};
/**
* Indicates that a LINE Things-compatible device has been linked with LINE by a user operation.
* For more information, see [Receiving device link events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#link-event).
*/
export declare type DeviceLinkEvent = ReplyableEvent & {
type: "things";
things: {
/**
* Device ID of the LINE Things-compatible device that was linked with LINE
*/
deviceId: string;
type: "link";
};
};
/**
* Indicates that a LINE Things-compatible device has been unlinked from LINE by a user operation.
* For more information, see [Receiving device unlink events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#unlink-event).
*/
export declare type DeviceUnlinkEvent = ReplyableEvent & {
type: "things";
things: {
/**
* Device ID of the LINE Things-compatible device that was unlinked with LINE
*/
deviceId: string;
type: "unlink";
};
};
export declare type LINEThingsScenarioExecutionEvent = ReplyableEvent & {
type: "things";
things: {
type: "scenarioResult";
/**
* Device ID of the device that executed the scenario
*/
deviceId: string;
result: {
/**
* Scenario ID executed
*/
scenarioId: string;
/**
* Revision number of the scenario set containing the executed scenario
*/
revision: number;
/**
* Timestamp for when execution of scenario action started (milliseconds, LINE app time)
*/
startTime: number;
/**
* Timestamp for when execution of scenario was completed (milliseconds, LINE app time)
*/
endtime: number;
/**
* Scenario execution completion status
* See also [things.resultCode definitions](https://developers.line.biz/en/reference/messaging-api/#things-resultcode).
*/
resultCode: "success" | "gatt_error" | "runtime_error";
/**
* Execution result of individual operations specified in action
* Note that an array of actions specified in a scenario has the following characteristics
* - The actions defined in a scenario are performed sequentially, from top to bottom.
* - Each action produces some result when executed.
* Even actions that do not generate data, such as `SLEEP`, return an execution result of type `void`.
* The number of items in an action array may be 0.
*
* Therefore, things.actionResults has the following properties:
* - The number of items in the array matches the number of actions defined in the scenario.
* - The order of execution results matches the order in which actions are performed.
* That is, in a scenario set with multiple `GATT_READ` actions,
* the results are returned in the order in which each individual `GATT_READ` action was performed.
* - If 0 actions are defined in the scenario, the number of items in things.actionResults will be 0.
*/
actionResults: Array<LINEThingsActionResult>;
/**
* Data contained in notification
* The value is Base64-encoded binary data.
* Only included for scenarios where `trigger.type = BLE_NOTIFICATION`.
*/
bleNotificationPayload?: string;
/**
* Error reason
*/
errorReason?: string;
};
};
};
export declare type LINEThingsActionResult = {
/**
* `void`, `binary`
* Depends on `type` of the executed action.
* This property is always included if `things.actionResults` is not empty.
*/
type: "void" | "binary";
/**
* Base64-encoded binary data
* This property is always included when `things.actionResults[].type` is `binary`.
*/
data?: string;
};
export declare type EventMessage = TextEventMessage | ImageEventMessage | VideoEventMessage | AudioEventMessage | LocationEventMessage | FileEventMessage | StickerEventMessage;
export declare type EventMessageBase = {
id: string;
......@@ -260,7 +373,7 @@ export declare type LocationEventMessage = {
/**
* Message object which contains the sticker data sent from the source.
* For a list of basic LINE stickers and sticker IDs, see
* [sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf).
* [sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
export declare type StickerEventMessage = {
type: "sticker";
......@@ -271,9 +384,9 @@ export declare type Postback = {
data: string;
/**
* Object with the date and time selected by a user through a
* [datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action).
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
* Only returned for postback actions via a
* [datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action).
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
* The `full-date`, `time-hour`, and `time-minute` formats follow the
* [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt).
*/
......@@ -295,25 +408,25 @@ export declare type Postback = {
/**
* JSON object which contains the contents of the message you send.
*
* @see [Message objects](https://developers.line.me/en/reference/messaging-api/#message-objects)
* @see [Message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects)
*/
export declare type Message = TextMessage | ImageMessage | VideoMessage | AudioMessage | LocationMessage | StickerMessage | ImageMapMessage | TemplateMessage | FlexMessage;
/**
* @see [Common properties for messages](https://developers.line.me/en/reference/messaging-api/#common-properties-for-messages)
* @see [Common properties for messages](https://developers.line.biz/en/reference/messaging-api/#common-properties-for-messages)
*/
export declare type MessageCommon = {
/**
* For the quick reply feature.
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
* For more information, see [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
*
* If the user receives multiple
* [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects),
* [message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects),
* the quickReply property of the last message object is displayed.
*/
quickReply?: QuickReply;
};
/**
* @see [Text message](https://developers.line.me/en/reference/messaging-api/#text-message)
* @see [Text message](https://developers.line.biz/en/reference/messaging-api/#text-message)
*/
export declare type TextMessage = MessageCommon & {
type: "text";
......@@ -322,14 +435,14 @@ export declare type TextMessage = MessageCommon & {
*
* - Unicode emoji
* - LINE original emoji
* ([Unicode codepoint table for LINE original emoji](https://developers.line.me/media/messaging-api/emoji-list.pdf))
* ([Unicode codepoint table for LINE original emoji](https://developers.line.biz/media/messaging-api/emoji-list.pdf))
*
* Max: 2000 characters
*/
text: string;
};
/**
* @see [Image message](https://developers.line.me/en/reference/messaging-api/#image-message)
* @see [Image message](https://developers.line.biz/en/reference/messaging-api/#image-message)
*/
export declare type ImageMessage = MessageCommon & {
type: "image";
......@@ -353,7 +466,7 @@ export declare type ImageMessage = MessageCommon & {
previewImageUrl: string;
};
/**
* @see [Video message](https://developers.line.me/en/reference/messaging-api/#video-message)
* @see [Video message](https://developers.line.biz/en/reference/messaging-api/#video-message)
*/
export declare type VideoMessage = MessageCommon & {
type: "video";
......@@ -379,7 +492,7 @@ export declare type VideoMessage = MessageCommon & {
previewImageUrl: string;
};
/**
* @see [Audio message](https://developers.line.me/en/reference/messaging-api/#audio-message)
* @see [Audio message](https://developers.line.biz/en/reference/messaging-api/#audio-message)
*/
export declare type AudioMessage = MessageCommon & {
type: "audio";
......@@ -398,7 +511,7 @@ export declare type AudioMessage = MessageCommon & {
duration: number;
};
/**
* @see [Location message](https://developers.line.me/en/reference/messaging-api/#location-message)
* @see [Location message](https://developers.line.biz/en/reference/messaging-api/#location-message)
*/
export declare type LocationMessage = MessageCommon & {
type: "location";
......@@ -414,31 +527,31 @@ export declare type LocationMessage = MessageCommon & {
longitude: number;
};
/**
* @see [Sticker message](https://developers.line.me/en/reference/messaging-api/#sticker-message)
* @see [Sticker message](https://developers.line.biz/en/reference/messaging-api/#sticker-message)
*/
export declare type StickerMessage = MessageCommon & {
type: "sticker";
/**
* Package ID for a set of stickers.
* For information on package IDs, see the
* [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf).
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
packageId: string;
/**
* Sticker ID.
* For a list of sticker IDs for stickers that can be sent with the Messaging
* API, see the
* [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf).
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
stickerId: string;
};
/**
* @see [Imagemap message](https://developers.line.me/en/reference/messaging-api/#imagemap-message)
* @see [Imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message)
*/
export declare type ImageMapMessage = MessageCommon & {
type: "imagemap";
/**
* [Base URL](https://developers.line.me/en/reference/messaging-api/#base-url) of image
* [Base URL](https://developers.line.biz/en/reference/messaging-api/#base-url) of image
* (Max: 1000 characters, **HTTPS**)
*/
baseUrl: string;
......@@ -448,7 +561,7 @@ export declare type ImageMapMessage = MessageCommon & {
altText: string;
baseSize: Size;
/**
* Video to play inside a image map messagea
* Video to play inside a image map messages
*/
video?: {
/**
......@@ -489,16 +602,16 @@ export declare type ImageMapMessage = MessageCommon & {
/**
* Template messages are messages with predefined layouts which you can
* customize. For more information, see
* [template messages](https://developers.line.me/en/docs/messaging-api/message-types/#template-messages).
* [template messages](https://developers.line.biz/en/docs/messaging-api/message-types/#template-messages).
*
* The following template types are available:
*
* - [Buttons](https://developers.line.me/en/reference/messaging-api/#buttons)
* - [Confirm](https://developers.line.me/en/reference/messaging-api/#confirm)
* - [Carousel](https://developers.line.me/en/reference/messaging-api/#carousel)
* - [Image carousel](https://developers.line.me/en/reference/messaging-api/#image-carousel)
* - [Buttons](https://developers.line.biz/en/reference/messaging-api/#buttons)
* - [Confirm](https://developers.line.biz/en/reference/messaging-api/#confirm)
* - [Carousel](https://developers.line.biz/en/reference/messaging-api/#carousel)
* - [Image carousel](https://developers.line.biz/en/reference/messaging-api/#image-carousel)
*
* @see [Template messages](https://developers.line.me/en/reference/messaging-api/#template-messages)
* @see [Template messages](https://developers.line.biz/en/reference/messaging-api/#template-messages)
*/
export declare type TemplateMessage = MessageCommon & {
type: "template";
......@@ -515,9 +628,9 @@ export declare type TemplateMessage = MessageCommon & {
* Flex Messages are messages with a customizable layout.
* You can customize the layout freely by combining multiple elements.
* For more information, see
* [Using Flex Messages](https://developers.line.me/en/docs/messaging-api/using-flex-messages/).
* [Using Flex Messages](https://developers.line.biz/en/docs/messaging-api/using-flex-messages/).
*
* @see [Flex messages](https://developers.line.me/en/reference/messaging-api/#flex-message)
* @see [Flex messages](https://developers.line.biz/en/reference/messaging-api/#flex-message)
*/
export declare type FlexMessage = MessageCommon & {
type: "flex";
......@@ -530,7 +643,7 @@ export declare type FlexMessage = MessageCommon & {
* When a region is tapped, the user is redirected to the URI specified in
* `uri` and the message specified in `message` is sent.
*
* @see [Imagemap action objects](https://developers.line.me/en/reference/messaging-api/#imagemap-action-objects)
* @see [Imagemap action objects](https://developers.line.biz/en/reference/messaging-api/#imagemap-action-objects)
*/
export declare type ImageMapAction = ImageMapURIAction | ImageMapMessageAction;
export declare type ImageMapActionBase = {
......@@ -572,10 +685,10 @@ export declare type Area = {
/**
* A container is the top-level structure of a Flex Message. Here are the types of containers available.
*
* - [Bubble](https://developers.line.me/en/reference/messaging-api/#bubble)
* - [Carousel](https://developers.line.me/en/reference/messaging-api/#f-carousel)
* - [Bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
* - [Carousel](https://developers.line.biz/en/reference/messaging-api/#f-carousel)
*
* See [Flex Message elements](https://developers.line.me/en/docs/messaging-api/flex-message-elements/)
* See [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
* for the containers' JSON data samples and usage.
*/
export declare type FlexContainer = FlexBubble | FlexCarousel;
......@@ -584,10 +697,11 @@ export declare type FlexContainer = FlexBubble | FlexCarousel;
* blocks: header, hero, body, and footer.
*
* For more information about using each block, see
* [Block](https://developers.line.me/en/docs/messaging-api/flex-message-elements/#block).
* [Block](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/#block).
*/
export declare type FlexBubble = {
type: "bubble";
size?: "nano" | "micro" | "kilo" | "mega" | "giga";
/**
* Text directionality and the order of components in horizontal boxes in the
* container. Specify one of the following values:
......@@ -599,10 +713,11 @@ export declare type FlexBubble = {
*/
direction?: "ltr" | "rtl";
header?: FlexBox;
hero?: FlexImage;
hero?: FlexBox | FlexImage;
body?: FlexBox;
footer?: FlexBox;
styles?: FlexBubbleStyle;
action?: Action;
};
export declare type FlexBubbleStyle = {
header?: FlexBlockStyle;
......@@ -638,21 +753,22 @@ export declare type FlexCarousel = {
* Components are objects that compose a Flex Message container. Here are the
* types of components available:
*
* - [Box](https://developers.line.me/en/reference/messaging-api/#box)
* - [Button](https://developers.line.me/en/reference/messaging-api/#button)
* - [Filler](https://developers.line.me/en/reference/messaging-api/#filler)
* - [Icon](https://developers.line.me/en/reference/messaging-api/#icon)
* - [Image](https://developers.line.me/en/reference/messaging-api/#f-image)
* - [Separator](https://developers.line.me/en/reference/messaging-api/#separator)
* - [Spacer](https://developers.line.me/en/reference/messaging-api/#spacer)
* - [Text](https://developers.line.me/en/reference/messaging-api/#f-text)
* - [Box](https://developers.line.biz/en/reference/messaging-api/#box)
* - [Button](https://developers.line.biz/en/reference/messaging-api/#button)
* - [Image](https://developers.line.biz/en/reference/messaging-api/#f-image)
* - [Icon](https://developers.line.biz/en/reference/messaging-api/#icon)
* - [Text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* - [Span](https://developers.line.biz/en/reference/messaging-api/#span)
* - [Separator](https://developers.line.biz/en/reference/messaging-api/#separator)
* - [Filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* - [Spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
*
* See the followings for the components' JSON data samples and usage.
*
* - [Flex Message elements](https://developers.line.me/en/docs/messaging-api/flex-message-elements/)
* - [Flex Message layout](https://developers.line.me/en/docs/messaging-api/flex-message-layout/)
* - [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
* - [Flex Message layout](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/)
*/
export declare type FlexComponent = FlexBox | FlexButton | FlexFiller | FlexIcon | FlexImage | FlexSeparator | FlexSpacer | FlexText;
export declare type FlexComponent = FlexBox | FlexButton | FlexImage | FlexIcon | FlexText | FlexSpan | FlexSeparator | FlexFiller | FlexSpacer;
/**
* This is a component that defines the layout of child components.
* You can also include a box in a box.
......@@ -663,39 +779,71 @@ export declare type FlexBox = {
* The placement style of components in this box. Specify one of the following values:
*
* - `horizontal`: Components are placed horizontally. The `direction`
* property of the [bubble](https://developers.line.me/en/reference/messaging-api/#bubble)
* property of the [bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
* container specifies the order.
* - `vertical`: Components are placed vertically from top to bottom.
* - `baseline`: Components are placed in the same way as `horizontal` is
* specified except the baselines of the components are aligned.
*
* For more information, see
* [Types of box layouts](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#box-layout-types).
* [Types of box layouts](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-layout-types).
*/
layout: "horizontal" | "vertical" | "baseline";
/**
* Components in this box. Here are the types of components available:
*
* - When the `layout` property is `horizontal` or `vertical`:
* + [Box](https://developers.line.me/en/reference/messaging-api/#box)
* + [button](https://developers.line.me/en/reference/messaging-api/#button)
* + [filler](https://developers.line.me/en/reference/messaging-api/#filler)
* + [image](https://developers.line.me/en/reference/messaging-api/#f-image)
* + [separator](https://developers.line.me/en/reference/messaging-api/#separator)
* + [text](https://developers.line.me/en/reference/messaging-api/#f-text)
* + [Box](https://developers.line.biz/en/reference/messaging-api/#box)
* + [button](https://developers.line.biz/en/reference/messaging-api/#button)
* + [image](https://developers.line.biz/en/reference/messaging-api/#f-image)
* + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* + [separator](https://developers.line.biz/en/reference/messaging-api/#separator)
* + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
* - When the `layout` property is `baseline`:
* + [filler](https://developers.line.me/en/reference/messaging-api/#filler)
* + [icon](https://developers.line.me/en/reference/messaging-api/#icon)
* + [text](https://developers.line.me/en/reference/messaging-api/#f-text)
* + [icon](https://developers.line.biz/en/reference/messaging-api/#icon)
* + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
*/
contents: FlexComponent[];
/**
* Background color of the block. In addition to the RGB color, an alpha
* channel (transparency) can also be set. Use a hexadecimal color code.
* (Example:#RRGGBBAA) The default value is `#00000000`.
*/
backgroundColor?: string;
/**
* Color of box border. Use a hexadecimal color code.
*/
borderColor?: string;
/**
* Width of box border. You can specify a value in pixels or any one of none,
* light, normal, medium, semi-bold, or bold. none does not render a border
* while the others become wider in the order of listing.
*/
borderWidth?: string | "none" | "light" | "normal" | "medium" | "semi-bold" | "bold";
/**
* Radius at the time of rounding the corners of the border. You can specify a
* value in pixels or any one of `none`, `xs`, `sm`, `md`, `lg`, `xl`, or `xxl`. none does not
* round the corner while the others increase in radius in the order of listing. The default value is none.
*/
cornerRadius?: string | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Width of the box. For more information, see [Width of a box](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-width) in the API documentation.
*/
width?: string;
/**
* Height of the box. For more information, see [Height of a box](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-height) in the API documentation.
*/
height?: string;
/**
* The ratio of the width or height of this box within the parent box. The
* default value for the horizontal parent box is `1`, and the default value
* for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
......@@ -720,11 +868,67 @@ export declare type FlexBox = {
*/
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Free space between the borders of this box and the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingAll?: string;
/**
* Free space between the border at the upper end of this box and the upper end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingTop?: string;
/**
* Free space between the border at the lower end of this box and the lower end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingBottom?: string;
/**
* Free space between the border at the left end of this box and the left end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingStart?: string;
/**
* Free space between the border at the right end of this box and the right end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingEnd?: string;
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
} & Offset;
export declare type Offset = {
/**
* Reference position for placing this box. Specify one of the following values:
* - `relative`: Use the previous box as reference.
* - `absolute`: Use the top left of parent element as reference.
*
* The default value is relative.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
position?: "relative" | "absolute";
/**
* The top offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetTop?: string;
/**
* The bottom offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetBottom?: string;
/**
* The left offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetStart?: string;
/**
* The right offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetEnd?: string;
};
/**
* This component draws a button.
......@@ -736,7 +940,7 @@ export declare type FlexButton = {
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action: Action;
/**
......@@ -746,7 +950,7 @@ export declare type FlexButton = {
* value for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
......@@ -794,7 +998,7 @@ export declare type FlexButton = {
* property will be ignored.
*/
gravity?: "top" | "bottom" | "center";
};
} & Offset;
/**
* This is an invisible component to fill extra space between components.
*
......@@ -803,6 +1007,10 @@ export declare type FlexButton = {
*/
export declare type FlexFiller = {
type: "filler";
/**
* The ratio of the width or height of this component within the parent box. For more information, see [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
};
/**
* This component draws an icon.
......@@ -840,7 +1048,7 @@ export declare type FlexIcon = {
* Aspect ratio of the icon. The default value is `1:1`.
*/
aspectRatio?: "1:1" | "2:1" | "3:1";
};
} & Offset;
/**
* This component draws an image.
*/
......@@ -862,7 +1070,7 @@ export declare type FlexImage = {
* value for the vertical parent box is `0`.
*
* - For more information, see
* [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
......@@ -928,10 +1136,10 @@ export declare type FlexImage = {
backgroundColor?: string;
/**
* Action performed when this button is tapped.
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
};
} & Offset;
/**
* This component draws a separator between components in the parent box.
*/
......@@ -965,19 +1173,23 @@ export declare type FlexSpacer = {
* The size increases in the order of listing.
* The default value is `md`.
*/
size: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
};
export declare type FlexText = {
type: "text";
text: string;
/**
* Array of spans. Be sure to set either one of the `text` property or `contents` property. If you set the `contents` property, `text` is ignored.
*/
contents?: FlexSpan[];
/**
* The ratio of the width or height of this box within the parent box.
*
* The default value for the horizontal parent box is `1`, and the default
* value for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
......@@ -1048,9 +1260,67 @@ export declare type FlexText = {
color?: string;
/**
* Action performed when this text is tapped.
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
/**
* Style of the text. Specify one of the following values:
* - `normal`: Normal
* - `italic`: Italic
*
* The default value is `normal`.
*/
style?: string;
/**
* Decoration of the text. Specify one of the following values:
* `none`: No decoration
* `underline`: Underline
* `line-through`: Strikethrough
*
* The default value is `none`.
*/
decoration?: string;
} & Offset;
/**
* This component renders multiple text strings with different designs in one row. You can specify the color, size, weight, and decoration for the font. Span is set to `contents` property in [Text](https://developers.line.biz/en/reference/messaging-api/#f-text).
*/
export declare type FlexSpan = {
type: "span";
/**
* Text. If the `wrap` property of the parent text is set to `true`, you can use a new line character (`\n`) to begin on a new line.
*/
text: string;
/**
* Font color. Use a hexadecimal color code.
*/
color?: string;
/**
* Font size. You can specify one of the following values: `xxs`, `xs`, `sm`, `md`, `lg`, `xl`, `xxl`, `3xl`, `4xl`, or `5xl`. The size increases in the order of listing. The default value is `md`.
*/
size?: string;
/**
* Font weight. You can specify one of the following values: `regular` or `bold`. Specifying `bold` makes the font bold. The default value is `regular`.
*/
weight?: string;
/**
* Style of the text. Specify one of the following values:
* - `normal`: Normal
* - `italic`: Italic
*
* The default value is `normal`.
*/
style?: string;
/**
* Decoration of the text. Specify one of the following values:
* `none`: No decoration
* `underline`: Underline
* `line-through`: Strikethrough
*
* The default value is `none`.
*
* Note: The decoration set in the `decoration` property of the [text](https://developers.line.biz/en/reference/messaging-api/#f-text) cannot be overwritten by the `decoration` property of the span.
*/
decoration?: string;
};
export declare type TemplateContent = TemplateButtons | TemplateConfirm | TemplateCarousel | TemplateImageCarousel;
/**
......@@ -1218,7 +1488,7 @@ export declare type TemplateImageCarousel = {
/**
* Array of columns (Max: 10)
*/
columns: TemplateImageColumn;
columns: TemplateImageColumn[];
};
export declare type TemplateImageColumn = {
/**
......@@ -1242,12 +1512,12 @@ export declare type TemplateImageColumn = {
* These properties are used for the quick reply.
*
* For more information, see
* [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
* [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
*/
export declare type QuickReply = {
/**
* This is a container that contains
* [quick reply buttons](https://developers.line.me/en/reference/messaging-api/#quick-reply-button-object).
* [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
*
* Array of objects (Max: 13)
*/
......@@ -1257,7 +1527,7 @@ export declare type QuickReply = {
* This is a quick reply option that is displayed as a button.
*
* For more information, see
* [quick reply buttons](https://developers.line.me/en/reference/messaging-api/#quick-reply-button-object).
* [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
*/
export declare type QuickReplyItem = {
type: "action";
......@@ -1272,9 +1542,9 @@ export declare type QuickReplyItem = {
* There is no limit on the image size. If the `action` property has the
* following actions with empty `imageUrl`:
*
* - [camera action](https://developers.line.me/en/reference/messaging-api/#camera-action)
* - [camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action)
* - [location action](https://developers.line.me/en/reference/messaging-api/#location-action)
* - [camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*
* the default icon is displayed.
*/
......@@ -1282,33 +1552,39 @@ export declare type QuickReplyItem = {
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*
* The following is a list of the available actions:
*
* - [Postback action](https://developers.line.me/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.me/en/reference/messaging-api/#message-action)
* - [Datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.me/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.me/en/reference/messaging-api/#location-action)
* - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
* - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*/
action: Action;
};
/**
* These are types of actions for your bot to take when a user taps a button or an image in a message.
*
* - [Postback action](https://developers.line.me/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.me/en/reference/messaging-api/#message-action)
* - [URI action](https://developers.line.me/en/reference/messaging-api/#uri-action)
* - [Datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.me/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.me/en/reference/messaging-api/#location-action)
* - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
* - [URI action](https://developers.line.biz/en/reference/messaging-api/#uri-action)
* - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*/
export declare type Action<ExtraFields = {
label: string;
}> = (PostbackAction | MessageAction | URIAction | DatetimePickerAction) & ExtraFields;
}> = (PostbackAction | MessageAction | URIAction | DatetimePickerAction | {
type: "camera";
} | {
type: "cameraRoll";
} | {
type: "location";
}) & ExtraFields;
/**
* When a control associated with this action is tapped, a postback event is
* returned via webhook with the specified string in the data property.
......@@ -1363,10 +1639,24 @@ export declare type URIAction = {
* Must start with `http`, `https`, or `tel`.
*/
uri: string;
altUri?: AltURI;
};
/**
* URI opened on LINE for macOS and Windows when the action is performed (Max: 1000 characters)
* If the altUri.desktop property is set, the uri property is ignored on LINE for macOS and Windows.
* The available schemes are http, https, line, and tel.
* For more information about the LINE URL scheme, see Using the LINE URL scheme.
* This property is supported on the following version of LINE.
*
* LINE 5.12.0 or later for macOS and Windows
* Note: The altUri.desktop property is supported only when you set URI actions in Flex Messages.
*/
export declare type AltURI = {
desktop: string;
};
/**
* When a control associated with this action is tapped, a
* [postback event](https://developers.line.me/en/reference/messaging-api/#postback-event)
* [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event)
* is returned via webhook with the date and time selected by the user from the
* date and time selection dialog.
*
......@@ -1414,21 +1704,21 @@ export declare type Size = {
/**
* Rich menus consist of either of these objects.
*
* - [Rich menu object](https://developers.line.me/en/reference/messaging-api/#rich-menu-object)
* - [Rich menu object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-object)
* without the rich menu ID. Use this object when you
* [create a rich menu](https://developers.line.me/en/reference/messaging-api/#create-rich-menu).
* - [Rich menu response object](https://developers.line.me/en/reference/messaging-api/#rich-menu-response-object)
* [create a rich menu](https://developers.line.biz/en/reference/messaging-api/#create-rich-menu).
* - [Rich menu response object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-response-object)
* with the rich menu ID. This object is returned when you
* [get a rich menu](https://developers.line.me/en/reference/messaging-api/#get-rich-menu)
* or [get a list of rich menus](https://developers.line.me/en/reference/messaging-api/#get-rich-menu-list).
* [get a rich menu](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu)
* or [get a list of rich menus](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list).
*
* [Area objects](https://developers.line.me/en/reference/messaging-api/#area-object) and
* [action objects](https://developers.line.me/en/reference/messaging-api/#action-objects)
* [Area objects](https://developers.line.biz/en/reference/messaging-api/#area-object) and
* [action objects](https://developers.line.biz/en/reference/messaging-api/#action-objects)
* are included in these objects.
*/
export declare type RichMenu = {
/**
* [`size` object](https://developers.line.me/en/reference/messaging-api/#size-object)
* [`size` object](https://developers.line.biz/en/reference/messaging-api/#size-object)
* which contains the width and height of the rich menu displayed in the chat.
* Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px.
*/
......@@ -1451,7 +1741,7 @@ export declare type RichMenu = {
*/
chatBarText: string;
/**
* Array of [area objects](https://developers.line.me/en/reference/messaging-api/#area-object)
* Array of [area objects](https://developers.line.biz/en/reference/messaging-api/#area-object)
* which define the coordinates and size of tappable areas
* (Max: 20 area objects)
*/
......@@ -1463,3 +1753,145 @@ export declare type RichMenu = {
export declare type RichMenuResponse = {
richMenuId: string;
} & RichMenu;
export declare type NumberOfMessagesSentResponse = InsightStatisticsResponse & {
/**
* The number of messages sent with the Messaging API on the date specified in date.
* The response has this property only when the value of status is `ready`.
*/
success?: number;
};
export declare type TargetLimitForAdditionalMessages = {
/**
* One of the following values to indicate whether a target limit is set or not.
* - `none`: This indicates that a target limit is not set.
* - `limited`: This indicates that a target limit is set.
*/
type: "none" | "limited";
/**
* The target limit for additional messages in the current month.
* This property is returned when the `type` property has a value of `limited`.
*/
value?: number;
};
export declare type NumberOfMessagesSentThisMonth = {
/**
* The number of sent messages in the current month
*/
totalUsage: number;
};
export declare const LINE_REQUEST_ID_HTTP_HEADER_NAME = "x-line-request-id";
export declare type MessageAPIResponseBase = {
[LINE_REQUEST_ID_HTTP_HEADER_NAME]?: string;
};
export declare type InsightStatisticsResponse = {
/**
* Calculation status. One of:
* - `ready`: Calculation has finished; the numbers are up-to-date.
* - `unready`: We haven't finished calculating the number of sent messages for the specified `date`. Calculation usually takes about a day. Please try again later.
* - `out_of_service`: The specified `date` is earlier than the date on which we first started calculating sent messages. Different APIs have different date. Check them at the [document](https://developers.line.biz/en/reference/messaging-api/).
*/
status: "ready" | "unready" | "out_of_service";
};
export declare type NumberOfMessageDeliveries = InsightStatisticsResponse & {
/**
* Number of push messages sent to **all** of this LINE official account's friends (broadcast messages).
*/
broadcast: number;
/**
* Number of push messages sent to **some** of this LINE official account's friends, based on specific attributes (targeted/segmented messages).
*/
targeting: number;
/**
* Number of auto-response messages sent.
*/
autoResponse: number;
/**
* Number of greeting messages sent.
*/
welcomeResponse: number;
/**
* Number of messages sent from LINE Official Account Manager [Chat screen](https://www.linebiz.com/jp-en/manual/OfficialAccountManager/chats/screens/).
*/
chat: number;
/**
* Number of broadcast messages sent with the [Send broadcast message](https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message) Messaging API operation.
*/
apiBroadcast: number;
/**
* Number of push messages sent with the [Send push message](https://developers.line.biz/en/reference/messaging-api/#send-push-message) Messaging API operation.
*/
apiPush: number;
/**
* Number of multicast messages sent with the [Send multicast message](https://developers.line.biz/en/reference/messaging-api/#send-multicast-message) Messaging API operation.
*/
apiMulticast: number;
/**
* Number of replies sent with the [Send reply message](https://developers.line.biz/en/reference/messaging-api/#send-reply-message) Messaging API operation.
*/
apiReply: number;
};
export declare type NumberOfFollowers = InsightStatisticsResponse & {
/**
* The number of times, as of the specified `date`, that a user added this LINE official account as a friend. The number doesn't decrease when a user blocks the account after adding it, or when they delete their own account.
*/
followers: Number;
/**
* The number of users, as of the specified `date`, that the official account can reach with messages targeted by gender, age, or area. This number includes users for whom we estimated demographic attributes based on their activity in LINE and LINE-connected services.
*/
targetedReaches: Number;
/**
* The number of users blocking the account as of the specified `date`. The number decreases when a user unblocks the account.
*/
blocks: Number;
};
export declare type NumberOfMessageDeliveriesResponse = InsightStatisticsResponse | NumberOfMessageDeliveries;
export declare type NumberOfFollowersResponse = InsightStatisticsResponse | NumberOfFollowers;
declare type PercentageAble = {
percentage: number;
};
export declare type FriendDemoGraphics = {
/**
* `true` if friend demographic information is available.
*/
available: boolean;
/**
* Percentage per gender
*/
genders?: Array<{
/**
* Gender
*/
gender: "unknown" | "male" | "female";
} & PercentageAble>;
/**
* Percentage per age group
*/
ages?: Array<{
/**
* Age group
*/
age: string;
} & PercentageAble>;
/**
* Percentage per area
*/
areas?: Array<{
area: string;
} & PercentageAble>;
/**
* Percentage by OS
*/
appTypes?: Array<{
appType: "ios" | "android" | "others";
} & PercentageAble>;
/**
* Percentage per friendship duration
*/
subscriptionPeriods?: Array<{
/**
* Friendship duration
*/
subscriptionPeriod: "over365days" | "within365days" | "within180days" | "within90days" | "within30days" | "within7days" | "unknown";
} & PercentageAble>;
};
export {};
......
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LINE_REQUEST_ID_HTTP_HEADER_NAME = "x-line-request-id";
......
......@@ -2,35 +2,13 @@
Object.defineProperty(exports, "__esModule", { value: true });
const crypto_1 = require("crypto");
function s2b(str, encoding) {
if (Buffer.from) {
try {
return Buffer.from(str, encoding);
}
catch (err) {
if (err.name === "TypeError") {
return new Buffer(str, encoding);
}
throw err;
}
}
else {
return new Buffer(str, encoding);
}
return Buffer.from(str, encoding);
}
function safeCompare(a, b) {
if (a.length !== b.length) {
return false;
}
if (crypto_1.timingSafeEqual) {
return crypto_1.timingSafeEqual(a, b);
}
else {
let result = 0;
for (let i = 0; i < a.length; i++) {
result |= a[i] ^ b[i];
}
return result === 0;
}
return crypto_1.timingSafeEqual(a, b);
}
function validateSignature(body, channelSecret, signature) {
return safeCompare(crypto_1.createHmac("SHA256", channelSecret)
......
......@@ -2,12 +2,13 @@ import { Readable } from "stream";
import HTTPClient from "./http";
import * as Types from "./types";
import { JSONParseError } from "./exceptions";
import { AxiosResponse } from "axios";
function toArray<T>(maybeArr: T | T[]): T[] {
return Array.isArray(maybeArr) ? maybeArr : [maybeArr];
}
function checkJSON<T>(raw: T): T {
function ensureJSON<T>(raw: T): T {
if (typeof raw === "object") {
return raw;
} else {
......@@ -16,6 +17,9 @@ function checkJSON<T>(raw: T): T {
}
type ChatType = "group" | "room";
const API_HOST: string = process.env.API_BASE_URL || "https://api.line.me/v2/";
const BOT_BASE_URL: string = process.env.API_BASE_URL || `${API_HOST}bot/`;
const OAUTH_BASE_URL = `${API_HOST}oauth/`;
export default class Client {
public config: Types.ClientConfig;
......@@ -27,101 +31,132 @@ export default class Client {
}
this.config = config;
this.http = new HTTPClient(
process.env.API_BASE_URL || "https://api.line.me/v2/bot/",
{
this.http = new HTTPClient({
baseURL: BOT_BASE_URL,
defaultHeaders: {
Authorization: "Bearer " + this.config.channelAccessToken,
},
);
responseParser: this.parseHTTPResponse.bind(this),
});
}
private parseHTTPResponse(response: AxiosResponse) {
const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types;
let resBody = {
...response.data,
};
if (response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME]) {
resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] =
response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME];
}
return resBody;
}
public pushMessage(
to: string,
messages: Types.Message | Types.Message[],
): Promise<any> {
notificationDisabled: boolean = false,
): Promise<Types.MessageAPIResponseBase> {
return this.http.post("/message/push", {
messages: toArray(messages),
to,
notificationDisabled,
});
}
public replyMessage(
replyToken: string,
messages: Types.Message | Types.Message[],
): Promise<any> {
notificationDisabled: boolean = false,
): Promise<Types.MessageAPIResponseBase> {
return this.http.post("/message/reply", {
messages: toArray(messages),
replyToken,
notificationDisabled,
});
}
public multicast(
public async multicast(
to: string[],
messages: Types.Message | Types.Message[],
): Promise<any> {
notificationDisabled: boolean = false,
): Promise<Types.MessageAPIResponseBase> {
return this.http.post("/message/multicast", {
messages: toArray(messages),
to,
notificationDisabled,
});
}
public getProfile(userId: string): Promise<Types.Profile> {
return this.http.get<Types.Profile>(`/profile/${userId}`).then(checkJSON);
public async broadcast(
messages: Types.Message | Types.Message[],
notificationDisabled: boolean = false,
): Promise<Types.MessageAPIResponseBase> {
return this.http.post("/message/broadcast", {
messages: toArray(messages),
notificationDisabled,
});
}
public async getProfile(userId: string): Promise<Types.Profile> {
const profile = await this.http.get<Types.Profile>(`/profile/${userId}`);
return ensureJSON(profile);
}
private getChatMemberProfile(
private async getChatMemberProfile(
chatType: ChatType,
chatId: string,
userId: string,
): Promise<Types.Profile> {
return this.http
.get<Types.Profile>(`/${chatType}/${chatId}/member/${userId}`)
.then(checkJSON);
const profile = await this.http.get<Types.Profile>(
`/${chatType}/${chatId}/member/${userId}`,
);
return ensureJSON(profile);
}
public getGroupMemberProfile(
public async getGroupMemberProfile(
groupId: string,
userId: string,
): Promise<Types.Profile> {
return this.getChatMemberProfile("group", groupId, userId);
}
public getRoomMemberProfile(
public async getRoomMemberProfile(
roomId: string,
userId: string,
): Promise<Types.Profile> {
return this.getChatMemberProfile("room", roomId, userId);
}
private getChatMemberIds(
private async getChatMemberIds(
chatType: ChatType,
chatId: string,
): Promise<string[]> {
const load = (start?: string): Promise<string[]> =>
this.http
.get(`/${chatType}/${chatId}/members/ids`, start ? { start } : null)
.then(checkJSON)
.then((res: { memberIds: string[]; next?: string }) => {
if (!res.next) {
return res.memberIds;
}
return load(res.next).then(extraIds =>
res.memberIds.concat(extraIds),
);
});
return load();
}
public getGroupMemberIds(groupId: string): Promise<string[]> {
let memberIds: string[] = [];
let start: string;
do {
const res = await this.http.get<{ memberIds: string[]; next?: string }>(
`/${chatType}/${chatId}/members/ids`,
start ? { start } : null,
);
ensureJSON(res);
memberIds = memberIds.concat(res.memberIds);
start = res.next;
} while (start);
return memberIds;
}
public async getGroupMemberIds(groupId: string): Promise<string[]> {
return this.getChatMemberIds("group", groupId);
}
public getRoomMemberIds(roomId: string): Promise<string[]> {
public async getRoomMemberIds(roomId: string): Promise<string[]> {
return this.getChatMemberIds("room", roomId);
}
public getMessageContent(messageId: string): Promise<Readable> {
public async getMessageContent(messageId: string): Promise<Readable> {
return this.http.getStream(`/message/${messageId}/content`);
}
......@@ -129,51 +164,71 @@ export default class Client {
return this.http.post(`/${chatType}/${chatId}/leave`);
}
public leaveGroup(groupId: string): Promise<any> {
public async leaveGroup(groupId: string): Promise<any> {
return this.leaveChat("group", groupId);
}
public leaveRoom(roomId: string): Promise<any> {
public async leaveRoom(roomId: string): Promise<any> {
return this.leaveChat("room", roomId);
}
public getRichMenu(richMenuId: string): Promise<Types.RichMenuResponse> {
return this.http
.get<Types.RichMenuResponse>(`/richmenu/${richMenuId}`)
.then(checkJSON);
public async getRichMenu(
richMenuId: string,
): Promise<Types.RichMenuResponse> {
const res = await this.http.get<Types.RichMenuResponse>(
`/richmenu/${richMenuId}`,
);
return ensureJSON(res);
}
public createRichMenu(richMenu: Types.RichMenu): Promise<string> {
return this.http
.post<any>("/richmenu", richMenu)
.then(checkJSON)
.then(res => res.richMenuId);
public async createRichMenu(richMenu: Types.RichMenu): Promise<string> {
const res = await this.http.post<any>("/richmenu", richMenu);
return ensureJSON(res).richMenuId;
}
public deleteRichMenu(richMenuId: string): Promise<any> {
public async deleteRichMenu(richMenuId: string): Promise<any> {
return this.http.delete(`/richmenu/${richMenuId}`);
}
public getRichMenuIdOfUser(userId: string): Promise<string> {
return this.http
.get<any>(`/user/${userId}/richmenu`)
.then(checkJSON)
.then(res => res.richMenuId);
public async getRichMenuIdOfUser(userId: string): Promise<string> {
const res = await this.http.get<any>(`/user/${userId}/richmenu`);
return ensureJSON(res).richMenuId;
}
public linkRichMenuToUser(userId: string, richMenuId: string): Promise<any> {
public async linkRichMenuToUser(
userId: string,
richMenuId: string,
): Promise<any> {
return this.http.post(`/user/${userId}/richmenu/${richMenuId}`);
}
public unlinkRichMenuFromUser(userId: string): Promise<any> {
public async unlinkRichMenuFromUser(userId: string): Promise<any> {
return this.http.delete(`/user/${userId}/richmenu`);
}
public getRichMenuImage(richMenuId: string): Promise<Readable> {
public async linkRichMenuToMultipleUsers(
richMenuId: string,
userIds: string[],
): Promise<any> {
return this.http.post("/richmenu/bulk/link", {
richMenuId,
userIds,
});
}
public async unlinkRichMenusFromMultipleUsers(
userIds: string[],
): Promise<any> {
return this.http.post("/richmenu/bulk/unlink", {
userIds,
});
}
public async getRichMenuImage(richMenuId: string): Promise<Readable> {
return this.http.getStream(`/richmenu/${richMenuId}/content`);
}
public setRichMenuImage(
public async setRichMenuImage(
richMenuId: string,
data: Buffer | Readable,
contentType?: string,
......@@ -185,32 +240,134 @@ export default class Client {
);
}
public getRichMenuList(): Promise<Array<Types.RichMenuResponse>> {
return this.http
.get<any>(`/richmenu/list`)
.then(checkJSON)
.then(res => res.richmenus);
public async getRichMenuList(): Promise<Array<Types.RichMenuResponse>> {
const res = await this.http.get<any>(`/richmenu/list`);
return ensureJSON(res).richmenus;
}
public setDefaultRichMenu(richMenuId: string): Promise<{}> {
public async setDefaultRichMenu(richMenuId: string): Promise<{}> {
return this.http.post(`/user/all/richmenu/${richMenuId}`);
}
public getDefaultRichMenuId(): Promise<string> {
return this.http
.get<any>("/user/all/richmenu")
.then(checkJSON)
.then(res => res.richMenuId);
public async getDefaultRichMenuId(): Promise<string> {
const res = await this.http.get<any>("/user/all/richmenu");
return ensureJSON(res).richMenuId;
}
public deleteDefaultRichMenu(): Promise<{}> {
public async deleteDefaultRichMenu(): Promise<{}> {
return this.http.delete("/user/all/richmenu");
}
public getLinkToken(userId: string): Promise<string> {
return this.http
.post<any>(`/user/${userId}/linkToken`)
.then(checkJSON)
.then(res => res.linkToken);
public async getLinkToken(userId: string): Promise<string> {
const res = await this.http.post<any>(`/user/${userId}/linkToken`);
return ensureJSON(res).linkToken;
}
public async getNumberOfSentReplyMessages(
date: string,
): Promise<Types.NumberOfMessagesSentResponse> {
const res = await this.http.get<Types.NumberOfMessagesSentResponse>(
`/message/delivery/reply?date=${date}`,
);
return ensureJSON(res);
}
public async getNumberOfSentPushMessages(
date: string,
): Promise<Types.NumberOfMessagesSentResponse> {
const res = await this.http.get<Types.NumberOfMessagesSentResponse>(
`/message/delivery/push?date=${date}`,
);
return ensureJSON(res);
}
public async getNumberOfSentMulticastMessages(
date: string,
): Promise<Types.NumberOfMessagesSentResponse> {
const res = await this.http.get<Types.NumberOfMessagesSentResponse>(
`/message/delivery/multicast?date=${date}`,
);
return ensureJSON(res);
}
public async getTargetLimitForAdditionalMessages(): Promise<
Types.TargetLimitForAdditionalMessages
> {
const res = await this.http.get<Types.TargetLimitForAdditionalMessages>(
"/message/quota",
);
return ensureJSON(res);
}
public async getNumberOfMessagesSentThisMonth(): Promise<
Types.NumberOfMessagesSentThisMonth
> {
const res = await this.http.get<Types.NumberOfMessagesSentThisMonth>(
"/message/quota/consumption",
);
return ensureJSON(res);
}
public async getNumberOfSentBroadcastMessages(
date: string,
): Promise<Types.NumberOfMessagesSentResponse> {
const res = await this.http.get<Types.NumberOfMessagesSentResponse>(
`/message/delivery/broadcast?date=${date}`,
);
return ensureJSON(res);
}
public async getNumberOfMessageDeliveries(
date: string,
): Promise<Types.NumberOfMessageDeliveriesResponse> {
const res = await this.http.get<Types.NumberOfMessageDeliveriesResponse>(
`/insight/message/delivery?date=${date}`,
);
return ensureJSON(res);
}
public async getNumberOfFollowers(
date: string,
): Promise<Types.NumberOfFollowersResponse> {
const res = await this.http.get<Types.NumberOfFollowersResponse>(
`/insight/followers?date=${date}`,
);
return ensureJSON(res);
}
public async getFriendDemographics(): Promise<Types.FriendDemoGraphics> {
const res = await this.http.get<Types.FriendDemoGraphics>(
`/insight/demographic`,
);
return ensureJSON(res);
}
}
export class OAuth {
private http: HTTPClient;
constructor() {
this.http = new HTTPClient({
baseURL: OAUTH_BASE_URL,
});
}
public issueAccessToken(
client_id: string,
client_secret: string,
): Promise<{
access_token: string;
expires_in: number;
token_type: "Bearer";
}> {
return this.http.postForm("/accessToken", {
grant_type: "client_credentials",
client_id,
client_secret,
});
}
public revokeAccessToken(access_token: string): Promise<{}> {
return this.http.postForm("/revoke", { access_token });
}
}
......
import axios, { AxiosInstance, AxiosError } from "axios";
import axios, { AxiosInstance, AxiosError, AxiosResponse } from "axios";
import { Readable } from "stream";
import { HTTPError, ReadError, RequestError } from "./exceptions";
import * as fileType from "file-type";
import * as qs from "querystring";
const pkg = require("../package.json");
type httpClientConfig = {
baseURL?: string;
defaultHeaders?: any;
responseParser?: <T>(res: AxiosResponse) => T;
};
export default class HTTPClient {
private instance: AxiosInstance;
private config: httpClientConfig;
constructor(baseURL?: string, defaultHeaders?: any) {
constructor(config: httpClientConfig = {}) {
this.config = config;
const { baseURL, defaultHeaders } = config;
this.instance = axios.create({
baseURL,
headers: Object.assign({}, defaultHeaders, {
......@@ -22,34 +32,47 @@ export default class HTTPClient {
);
}
public get<T>(url: string, params?: any): Promise<T> {
return this.instance.get(url, { params }).then(res => res.data);
public async get<T>(url: string, params?: any): Promise<T> {
const res = await this.instance.get(url, { params });
return res.data;
}
public getStream(url: string, params?: any): Promise<Readable> {
return this.instance
.get(url, { params, responseType: "stream" })
.then(res => res.data as Readable);
public async getStream(url: string, params?: any): Promise<Readable> {
const res = await this.instance.get(url, {
params,
responseType: "stream",
});
return res.data as Readable;
}
public post<T>(url: string, data?: any): Promise<T> {
return this.instance
.post(url, data, { headers: { "Content-Type": "application/json" } })
.then(res => res.data);
public async post<T>(url: string, body?: any): Promise<T> {
const res = await this.instance.post(url, body, {
headers: { "Content-Type": "application/json" },
});
const { responseParser } = this.config;
if (responseParser) return responseParser<T>(res);
else return res.data;
}
public postBinary<T>(
public async postForm<T>(url: string, body?: any): Promise<T> {
const res = await this.instance.post(url, qs.stringify(body), {
headers: { "Content-Type": "application/x-www-form-urlencoded" },
});
return res.data;
}
public async postBinary<T>(
url: string,
data: Buffer | Readable,
contentType?: string,
): Promise<T> {
let getBuffer: Promise<Buffer>;
if (Buffer.isBuffer(data)) {
getBuffer = Promise.resolve(data);
} else {
getBuffer = new Promise((resolve, reject) => {
if (data instanceof Readable) {
const buffer = await (async (): Promise<Buffer> => {
if (Buffer.isBuffer(data)) {
return data;
} else if (data instanceof Readable) {
return new Promise<Buffer>((resolve, reject) => {
const buffers: Buffer[] = [];
let size = 0;
data.on("data", (chunk: Buffer) => {
......@@ -58,26 +81,25 @@ export default class HTTPClient {
});
data.on("end", () => resolve(Buffer.concat(buffers, size)));
data.on("error", reject);
} else {
reject(new Error("invalid data type for postBinary"));
}
});
}
});
} else {
throw new Error("invalid data type for postBinary");
}
})();
return getBuffer.then(data => {
return this.instance
.post(url, data, {
headers: {
"Content-Type": contentType || fileType(data).mime,
"Content-Length": data.length,
},
})
.then(res => res.data);
const res = await this.instance.post(url, buffer, {
headers: {
"Content-Type": contentType || fileType(buffer).mime,
"Content-Length": buffer.length,
},
});
return res.data;
}
public delete<T>(url: string, params?: any): Promise<T> {
return this.instance.delete(url, { params }).then(res => res.data);
public async delete<T>(url: string, params?: any): Promise<T> {
const res = await this.instance.delete(url, { params });
return res.data;
}
private wrapError(err: AxiosError): Error {
......
import Client from "./client";
import Client, { OAuth } from "./client";
import middleware from "./middleware";
import validateSignature from "./validate-signature";
export { Client, middleware, validateSignature };
export { Client, middleware, validateSignature, OAuth };
// re-export exceptions and types
export * from "./exceptions";
......
......@@ -12,7 +12,7 @@ export type Middleware = (
req: Request,
res: Response,
next: NextCallback,
) => void;
) => void | Promise<void>;
function isValidBody(body?: any): body is string | Buffer {
return (body && typeof body === "string") || Buffer.isBuffer(body);
......@@ -25,7 +25,7 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware {
const secret = config.channelSecret;
return (req, res, next) => {
const _middleware: Middleware = async (req, res, next) => {
// header names are lower-cased
// https://nodejs.org/api/http.html#http_message_headers
const signature = req.headers["x-line-signature"] as string;
......@@ -35,38 +35,39 @@ export default function middleware(config: Types.MiddlewareConfig): Middleware {
return;
}
let getBody: Promise<string | Buffer>;
if (isValidBody((req as any).rawBody)) {
// rawBody is provided in Google Cloud Functions and others
getBody = Promise.resolve((req as any).rawBody);
} else if (isValidBody(req.body)) {
getBody = Promise.resolve(req.body);
} else {
// body may not be parsed yet, parse it to a buffer
getBody = new Promise(resolve => {
raw({ type: "*/*" })(req as any, res as any, () => resolve(req.body));
});
}
getBody.then(body => {
if (!validateSignature(body, secret, signature)) {
next(
new SignatureValidationFailed(
"signature validation failed",
signature,
const body = await (async (): Promise<string | Buffer> => {
if (isValidBody((req as any).rawBody)) {
// rawBody is provided in Google Cloud Functions and others
return (req as any).rawBody;
} else if (isValidBody(req.body)) {
return req.body;
} else {
// body may not be parsed yet, parse it to a buffer
return new Promise<Buffer>((resolve, reject) =>
raw({ type: "*/*" })(req as any, res as any, (error: Error) =>
error ? reject(error) : resolve(req.body),
),
);
return;
}
})();
if (!validateSignature(body, secret, signature)) {
next(
new SignatureValidationFailed("signature validation failed", signature),
);
return;
}
const strBody = Buffer.isBuffer(body) ? body.toString() : body;
const strBody = Buffer.isBuffer(body) ? body.toString() : body;
try {
req.body = JSON.parse(strBody);
next();
} catch (err) {
next(new JSONParseError(err.message, strBody));
}
});
try {
req.body = JSON.parse(strBody);
next();
} catch (err) {
next(new JSONParseError(err.message, strBody));
}
};
return (req, res, next): void => {
(<Promise<void>>_middleware(req, res, next)).catch(next);
};
}
......
......@@ -21,7 +21,7 @@ export type Profile = {
/**
* Request body which is sent by webhook.
*
* @see [Request body](https://developers.line.me/en/reference/messaging-api/#request-body)
* @see [Request body](https://developers.line.biz/en/reference/messaging-api/#request-body)
*/
export type WebhookRequestBody = {
/**
......@@ -38,7 +38,7 @@ export type WebhookRequestBody = {
/**
* JSON objects which contain events generated on the LINE Platform.
*
* @see [Webhook event objects](https://developers.line.me/en/reference/messaging-api/#webhook-event-objects)
* @see [Webhook event objects](https://developers.line.biz/en/reference/messaging-api/#webhook-event-objects)
*/
export type WebhookEvent =
| MessageEvent
......@@ -49,7 +49,11 @@ export type WebhookEvent =
| MemberJoinEvent
| MemberLeaveEvent
| PostbackEvent
| BeaconEvent;
| BeaconEvent
| AccountLinkEvent
| DeviceLinkEvent
| DeviceUnlinkEvent
| LINEThingsScenarioExecutionEvent;
export type EventBase = {
/**
......@@ -72,9 +76,9 @@ export type Group = {
/**
* ID of the source user.
*
* Only included in [message events](https://developers.line.me/en/reference/messaging-api/#message-event).
* Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
* Not included if the user has not agreed to the
* [Official Accounts Terms of Use](https://developers.line.me/en/docs/messaging-api/user-consent/).
* [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
*/
userId?: string;
};
......@@ -85,9 +89,9 @@ export type Room = {
/**
* ID of the source user.
*
* Only included in [message events](https://developers.line.me/en/reference/messaging-api/#message-event).
* Only included in [message events](https://developers.line.biz/en/reference/messaging-api/#message-event).
* Not included if the user has not agreed to the
* [Official Accounts Terms of Use](https://developers.line.me/en/docs/messaging-api/user-consent/).
* [Official Accounts Terms of Use](https://developers.line.biz/en/docs/messaging-api/user-consent/).
*/
userId?: string;
};
......@@ -100,7 +104,7 @@ export type ReplyableEvent = EventBase & { replyToken: string };
* The `message` property contains a message object which corresponds with the
* message type. You can reply to message events.
*
* @see [Message event](https://developers.line.me/en/reference/messaging-api/#message-event)
* @see [Message event](https://developers.line.biz/en/reference/messaging-api/#message-event)
*/
export type MessageEvent = {
type: "message";
......@@ -162,7 +166,7 @@ export type MemberLeaveEvent = {
/**
* Event object for when a user performs an action on a
* [template message](https://developers.line.me/en/reference/messaging-api/#template-messages).
* [template message](https://developers.line.biz/en/reference/messaging-api/#template-messages).
*/
export type PostbackEvent = {
type: "postback";
......@@ -171,7 +175,7 @@ export type PostbackEvent = {
/**
* Event object for when a user enters or leaves the range of a
* [LINE Beacon](https://developers.line.me/en/docs/messaging-api/using-beacons/).
* [LINE Beacon](https://developers.line.biz/en/docs/messaging-api/using-beacons/).
*/
export type BeaconEvent = ReplyableEvent & {
type: "beacon";
......@@ -195,6 +199,125 @@ export type BeaconEvent = ReplyableEvent & {
};
};
/**
* Event object for when a user has linked his/her LINE account with a provider's service account.
*/
export type AccountLinkEvent = ReplyableEvent & {
type: "accountLink";
link: {
result: "ok" | "failed";
/**
* Specified nonce when verifying the user ID
*/
nonce: string;
};
};
/**
* Indicates that a LINE Things-compatible device has been linked with LINE by a user operation.
* For more information, see [Receiving device link events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#link-event).
*/
export type DeviceLinkEvent = ReplyableEvent & {
type: "things";
things: {
/**
* Device ID of the LINE Things-compatible device that was linked with LINE
*/
deviceId: string;
type: "link";
};
};
/**
* Indicates that a LINE Things-compatible device has been unlinked from LINE by a user operation.
* For more information, see [Receiving device unlink events via webhook](https://developers.line.biz/en/docs/line-things/develop-bot/#unlink-event).
*/
export type DeviceUnlinkEvent = ReplyableEvent & {
type: "things";
things: {
/**
* Device ID of the LINE Things-compatible device that was unlinked with LINE
*/
deviceId: string;
type: "unlink";
};
};
export type LINEThingsScenarioExecutionEvent = ReplyableEvent & {
type: "things";
things: {
type: "scenarioResult";
/**
* Device ID of the device that executed the scenario
*/
deviceId: string;
result: {
/**
* Scenario ID executed
*/
scenarioId: string;
/**
* Revision number of the scenario set containing the executed scenario
*/
revision: number;
/**
* Timestamp for when execution of scenario action started (milliseconds, LINE app time)
*/
startTime: number;
/**
* Timestamp for when execution of scenario was completed (milliseconds, LINE app time)
*/
endtime: number;
/**
* Scenario execution completion status
* See also [things.resultCode definitions](https://developers.line.biz/en/reference/messaging-api/#things-resultcode).
*/
resultCode: "success" | "gatt_error" | "runtime_error";
/**
* Execution result of individual operations specified in action
* Note that an array of actions specified in a scenario has the following characteristics
* - The actions defined in a scenario are performed sequentially, from top to bottom.
* - Each action produces some result when executed.
* Even actions that do not generate data, such as `SLEEP`, return an execution result of type `void`.
* The number of items in an action array may be 0.
*
* Therefore, things.actionResults has the following properties:
* - The number of items in the array matches the number of actions defined in the scenario.
* - The order of execution results matches the order in which actions are performed.
* That is, in a scenario set with multiple `GATT_READ` actions,
* the results are returned in the order in which each individual `GATT_READ` action was performed.
* - If 0 actions are defined in the scenario, the number of items in things.actionResults will be 0.
*/
actionResults: Array<LINEThingsActionResult>;
/**
* Data contained in notification
* The value is Base64-encoded binary data.
* Only included for scenarios where `trigger.type = BLE_NOTIFICATION`.
*/
bleNotificationPayload?: string;
/**
* Error reason
*/
errorReason?: string;
};
};
};
export type LINEThingsActionResult = {
/**
* `void`, `binary`
* Depends on `type` of the executed action.
* This property is always included if `things.actionResults` is not empty.
*/
type: "void" | "binary";
/**
* Base64-encoded binary data
* This property is always included when `things.actionResults[].type` is `binary`.
*/
data?: string;
};
export type EventMessage =
| TextEventMessage
| ImageEventMessage
......@@ -292,7 +415,7 @@ export type LocationEventMessage = {
/**
* Message object which contains the sticker data sent from the source.
* For a list of basic LINE stickers and sticker IDs, see
* [sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf).
* [sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
export type StickerEventMessage = {
type: "sticker";
......@@ -304,9 +427,9 @@ export type Postback = {
data: string;
/**
* Object with the date and time selected by a user through a
* [datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action).
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
* Only returned for postback actions via a
* [datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action).
* [datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action).
* The `full-date`, `time-hour`, and `time-minute` formats follow the
* [RFC3339 protocol](https://www.ietf.org/rfc/rfc3339.txt).
*/
......@@ -329,7 +452,7 @@ export type Postback = {
/**
* JSON object which contains the contents of the message you send.
*
* @see [Message objects](https://developers.line.me/en/reference/messaging-api/#message-objects)
* @see [Message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects)
*/
export type Message =
| TextMessage
......@@ -343,22 +466,22 @@ export type Message =
| FlexMessage;
/**
* @see [Common properties for messages](https://developers.line.me/en/reference/messaging-api/#common-properties-for-messages)
* @see [Common properties for messages](https://developers.line.biz/en/reference/messaging-api/#common-properties-for-messages)
*/
export type MessageCommon = {
/**
* For the quick reply feature.
* For more information, see [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
* For more information, see [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
*
* If the user receives multiple
* [message objects](https://developers.line.me/en/reference/messaging-api/#message-objects),
* [message objects](https://developers.line.biz/en/reference/messaging-api/#message-objects),
* the quickReply property of the last message object is displayed.
*/
quickReply?: QuickReply;
};
/**
* @see [Text message](https://developers.line.me/en/reference/messaging-api/#text-message)
* @see [Text message](https://developers.line.biz/en/reference/messaging-api/#text-message)
*/
export type TextMessage = MessageCommon & {
type: "text";
......@@ -367,7 +490,7 @@ export type TextMessage = MessageCommon & {
*
* - Unicode emoji
* - LINE original emoji
* ([Unicode codepoint table for LINE original emoji](https://developers.line.me/media/messaging-api/emoji-list.pdf))
* ([Unicode codepoint table for LINE original emoji](https://developers.line.biz/media/messaging-api/emoji-list.pdf))
*
* Max: 2000 characters
*/
......@@ -375,7 +498,7 @@ export type TextMessage = MessageCommon & {
};
/**
* @see [Image message](https://developers.line.me/en/reference/messaging-api/#image-message)
* @see [Image message](https://developers.line.biz/en/reference/messaging-api/#image-message)
*/
export type ImageMessage = MessageCommon & {
type: "image";
......@@ -400,7 +523,7 @@ export type ImageMessage = MessageCommon & {
};
/**
* @see [Video message](https://developers.line.me/en/reference/messaging-api/#video-message)
* @see [Video message](https://developers.line.biz/en/reference/messaging-api/#video-message)
*/
export type VideoMessage = MessageCommon & {
type: "video";
......@@ -427,7 +550,7 @@ export type VideoMessage = MessageCommon & {
};
/**
* @see [Audio message](https://developers.line.me/en/reference/messaging-api/#audio-message)
* @see [Audio message](https://developers.line.biz/en/reference/messaging-api/#audio-message)
*/
export type AudioMessage = MessageCommon & {
type: "audio";
......@@ -447,7 +570,7 @@ export type AudioMessage = MessageCommon & {
};
/**
* @see [Location message](https://developers.line.me/en/reference/messaging-api/#location-message)
* @see [Location message](https://developers.line.biz/en/reference/messaging-api/#location-message)
*/
export type LocationMessage = MessageCommon & {
type: "location";
......@@ -464,32 +587,32 @@ export type LocationMessage = MessageCommon & {
};
/**
* @see [Sticker message](https://developers.line.me/en/reference/messaging-api/#sticker-message)
* @see [Sticker message](https://developers.line.biz/en/reference/messaging-api/#sticker-message)
*/
export type StickerMessage = MessageCommon & {
type: "sticker";
/**
* Package ID for a set of stickers.
* For information on package IDs, see the
* [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf).
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
packageId: string;
/**
* Sticker ID.
* For a list of sticker IDs for stickers that can be sent with the Messaging
* API, see the
* [Sticker list](https://developers.line.me/media/messaging-api/sticker_list.pdf).
* [Sticker list](https://developers.line.biz/media/messaging-api/sticker_list.pdf).
*/
stickerId: string;
};
/**
* @see [Imagemap message](https://developers.line.me/en/reference/messaging-api/#imagemap-message)
* @see [Imagemap message](https://developers.line.biz/en/reference/messaging-api/#imagemap-message)
*/
export type ImageMapMessage = MessageCommon & {
type: "imagemap";
/**
* [Base URL](https://developers.line.me/en/reference/messaging-api/#base-url) of image
* [Base URL](https://developers.line.biz/en/reference/messaging-api/#base-url) of image
* (Max: 1000 characters, **HTTPS**)
*/
baseUrl: string;
......@@ -499,7 +622,7 @@ export type ImageMapMessage = MessageCommon & {
altText: string;
baseSize: Size;
/**
* Video to play inside a image map messagea
* Video to play inside a image map messages
*/
video?: {
/**
......@@ -541,16 +664,16 @@ export type ImageMapMessage = MessageCommon & {
/**
* Template messages are messages with predefined layouts which you can
* customize. For more information, see
* [template messages](https://developers.line.me/en/docs/messaging-api/message-types/#template-messages).
* [template messages](https://developers.line.biz/en/docs/messaging-api/message-types/#template-messages).
*
* The following template types are available:
*
* - [Buttons](https://developers.line.me/en/reference/messaging-api/#buttons)
* - [Confirm](https://developers.line.me/en/reference/messaging-api/#confirm)
* - [Carousel](https://developers.line.me/en/reference/messaging-api/#carousel)
* - [Image carousel](https://developers.line.me/en/reference/messaging-api/#image-carousel)
* - [Buttons](https://developers.line.biz/en/reference/messaging-api/#buttons)
* - [Confirm](https://developers.line.biz/en/reference/messaging-api/#confirm)
* - [Carousel](https://developers.line.biz/en/reference/messaging-api/#carousel)
* - [Image carousel](https://developers.line.biz/en/reference/messaging-api/#image-carousel)
*
* @see [Template messages](https://developers.line.me/en/reference/messaging-api/#template-messages)
* @see [Template messages](https://developers.line.biz/en/reference/messaging-api/#template-messages)
*/
export type TemplateMessage = MessageCommon & {
type: "template";
......@@ -568,9 +691,9 @@ export type TemplateMessage = MessageCommon & {
* Flex Messages are messages with a customizable layout.
* You can customize the layout freely by combining multiple elements.
* For more information, see
* [Using Flex Messages](https://developers.line.me/en/docs/messaging-api/using-flex-messages/).
* [Using Flex Messages](https://developers.line.biz/en/docs/messaging-api/using-flex-messages/).
*
* @see [Flex messages](https://developers.line.me/en/reference/messaging-api/#flex-message)
* @see [Flex messages](https://developers.line.biz/en/reference/messaging-api/#flex-message)
*/
export type FlexMessage = MessageCommon & {
type: "flex";
......@@ -584,7 +707,7 @@ export type FlexMessage = MessageCommon & {
* When a region is tapped, the user is redirected to the URI specified in
* `uri` and the message specified in `message` is sent.
*
* @see [Imagemap action objects](https://developers.line.me/en/reference/messaging-api/#imagemap-action-objects)
* @see [Imagemap action objects](https://developers.line.biz/en/reference/messaging-api/#imagemap-action-objects)
*/
export type ImageMapAction = ImageMapURIAction | ImageMapMessageAction;
......@@ -631,10 +754,10 @@ export type Area = {
/**
* A container is the top-level structure of a Flex Message. Here are the types of containers available.
*
* - [Bubble](https://developers.line.me/en/reference/messaging-api/#bubble)
* - [Carousel](https://developers.line.me/en/reference/messaging-api/#f-carousel)
* - [Bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
* - [Carousel](https://developers.line.biz/en/reference/messaging-api/#f-carousel)
*
* See [Flex Message elements](https://developers.line.me/en/docs/messaging-api/flex-message-elements/)
* See [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
* for the containers' JSON data samples and usage.
*/
export type FlexContainer = FlexBubble | FlexCarousel;
......@@ -644,10 +767,11 @@ export type FlexContainer = FlexBubble | FlexCarousel;
* blocks: header, hero, body, and footer.
*
* For more information about using each block, see
* [Block](https://developers.line.me/en/docs/messaging-api/flex-message-elements/#block).
* [Block](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/#block).
*/
export type FlexBubble = {
type: "bubble";
size?: "nano" | "micro" | "kilo" | "mega" | "giga";
/**
* Text directionality and the order of components in horizontal boxes in the
* container. Specify one of the following values:
......@@ -659,10 +783,11 @@ export type FlexBubble = {
*/
direction?: "ltr" | "rtl";
header?: FlexBox;
hero?: FlexImage;
hero?: FlexBox | FlexImage;
body?: FlexBox;
footer?: FlexBox;
styles?: FlexBubbleStyle;
action?: Action;
};
export type FlexBubbleStyle = {
......@@ -702,29 +827,31 @@ export type FlexCarousel = {
* Components are objects that compose a Flex Message container. Here are the
* types of components available:
*
* - [Box](https://developers.line.me/en/reference/messaging-api/#box)
* - [Button](https://developers.line.me/en/reference/messaging-api/#button)
* - [Filler](https://developers.line.me/en/reference/messaging-api/#filler)
* - [Icon](https://developers.line.me/en/reference/messaging-api/#icon)
* - [Image](https://developers.line.me/en/reference/messaging-api/#f-image)
* - [Separator](https://developers.line.me/en/reference/messaging-api/#separator)
* - [Spacer](https://developers.line.me/en/reference/messaging-api/#spacer)
* - [Text](https://developers.line.me/en/reference/messaging-api/#f-text)
* - [Box](https://developers.line.biz/en/reference/messaging-api/#box)
* - [Button](https://developers.line.biz/en/reference/messaging-api/#button)
* - [Image](https://developers.line.biz/en/reference/messaging-api/#f-image)
* - [Icon](https://developers.line.biz/en/reference/messaging-api/#icon)
* - [Text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* - [Span](https://developers.line.biz/en/reference/messaging-api/#span)
* - [Separator](https://developers.line.biz/en/reference/messaging-api/#separator)
* - [Filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* - [Spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
*
* See the followings for the components' JSON data samples and usage.
*
* - [Flex Message elements](https://developers.line.me/en/docs/messaging-api/flex-message-elements/)
* - [Flex Message layout](https://developers.line.me/en/docs/messaging-api/flex-message-layout/)
* - [Flex Message elements](https://developers.line.biz/en/docs/messaging-api/flex-message-elements/)
* - [Flex Message layout](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/)
*/
export type FlexComponent =
| FlexBox
| FlexButton
| FlexFiller
| FlexIcon
| FlexImage
| FlexIcon
| FlexText
| FlexSpan
| FlexSeparator
| FlexSpacer
| FlexText;
| FlexFiller
| FlexSpacer;
/**
* This is a component that defines the layout of child components.
......@@ -736,39 +863,78 @@ export type FlexBox = {
* The placement style of components in this box. Specify one of the following values:
*
* - `horizontal`: Components are placed horizontally. The `direction`
* property of the [bubble](https://developers.line.me/en/reference/messaging-api/#bubble)
* property of the [bubble](https://developers.line.biz/en/reference/messaging-api/#bubble)
* container specifies the order.
* - `vertical`: Components are placed vertically from top to bottom.
* - `baseline`: Components are placed in the same way as `horizontal` is
* specified except the baselines of the components are aligned.
*
* For more information, see
* [Types of box layouts](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#box-layout-types).
* [Types of box layouts](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-layout-types).
*/
layout: "horizontal" | "vertical" | "baseline";
/**
* Components in this box. Here are the types of components available:
*
* - When the `layout` property is `horizontal` or `vertical`:
* + [Box](https://developers.line.me/en/reference/messaging-api/#box)
* + [button](https://developers.line.me/en/reference/messaging-api/#button)
* + [filler](https://developers.line.me/en/reference/messaging-api/#filler)
* + [image](https://developers.line.me/en/reference/messaging-api/#f-image)
* + [separator](https://developers.line.me/en/reference/messaging-api/#separator)
* + [text](https://developers.line.me/en/reference/messaging-api/#f-text)
* + [Box](https://developers.line.biz/en/reference/messaging-api/#box)
* + [button](https://developers.line.biz/en/reference/messaging-api/#button)
* + [image](https://developers.line.biz/en/reference/messaging-api/#f-image)
* + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* + [separator](https://developers.line.biz/en/reference/messaging-api/#separator)
* + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
* - When the `layout` property is `baseline`:
* + [filler](https://developers.line.me/en/reference/messaging-api/#filler)
* + [icon](https://developers.line.me/en/reference/messaging-api/#icon)
* + [text](https://developers.line.me/en/reference/messaging-api/#f-text)
* + [icon](https://developers.line.biz/en/reference/messaging-api/#icon)
* + [text](https://developers.line.biz/en/reference/messaging-api/#f-text)
* + [filler](https://developers.line.biz/en/reference/messaging-api/#filler)
* + [spacer (not recommended)](https://developers.line.biz/en/reference/messaging-api/#spacer)
*/
contents: FlexComponent[];
/**
* Background color of the block. In addition to the RGB color, an alpha
* channel (transparency) can also be set. Use a hexadecimal color code.
* (Example:#RRGGBBAA) The default value is `#00000000`.
*/
backgroundColor?: string;
/**
* Color of box border. Use a hexadecimal color code.
*/
borderColor?: string;
/**
* Width of box border. You can specify a value in pixels or any one of none,
* light, normal, medium, semi-bold, or bold. none does not render a border
* while the others become wider in the order of listing.
*/
borderWidth?:
| string
| "none"
| "light"
| "normal"
| "medium"
| "semi-bold"
| "bold";
/**
* Radius at the time of rounding the corners of the border. You can specify a
* value in pixels or any one of `none`, `xs`, `sm`, `md`, `lg`, `xl`, or `xxl`. none does not
* round the corner while the others increase in radius in the order of listing. The default value is none.
*/
cornerRadius?: string | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Width of the box. For more information, see [Width of a box](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-width) in the API documentation.
*/
width?: string;
/**
* Height of the box. For more information, see [Height of a box](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#box-height) in the API documentation.
*/
height?: string;
/**
* The ratio of the width or height of this box within the parent box. The
* default value for the horizontal parent box is `1`, and the default value
* for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
......@@ -793,11 +959,68 @@ export type FlexBox = {
*/
margin?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
/**
* Free space between the borders of this box and the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingAll?: string;
/**
* Free space between the border at the upper end of this box and the upper end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingTop?: string;
/**
* Free space between the border at the lower end of this box and the lower end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingBottom?: string;
/**
* Free space between the border at the left end of this box and the left end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingStart?: string;
/**
* Free space between the border at the right end of this box and the right end of the child element.
* For more information, see [Box padding](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#padding-property) in the API documentation.
*/
paddingEnd?: string;
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
} & Offset;
export type Offset = {
/**
* Reference position for placing this box. Specify one of the following values:
* - `relative`: Use the previous box as reference.
* - `absolute`: Use the top left of parent element as reference.
*
* The default value is relative.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
position?: "relative" | "absolute";
/**
* The top offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetTop?: string;
/**
* The bottom offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetBottom?: string;
/**
* The left offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetStart?: string;
/**
* The right offset.
* For more information, see [Offset](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-offset) in the API documentation.
*/
offsetEnd?: string;
};
/**
......@@ -810,7 +1033,7 @@ export type FlexButton = {
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action: Action;
/**
......@@ -820,7 +1043,7 @@ export type FlexButton = {
* value for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
......@@ -868,7 +1091,7 @@ export type FlexButton = {
* property will be ignored.
*/
gravity?: "top" | "bottom" | "center";
};
} & Offset;
/**
* This is an invisible component to fill extra space between components.
......@@ -878,6 +1101,10 @@ export type FlexButton = {
*/
export type FlexFiller = {
type: "filler";
/**
* The ratio of the width or height of this component within the parent box. For more information, see [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
};
/**
......@@ -926,7 +1153,7 @@ export type FlexIcon = {
* Aspect ratio of the icon. The default value is `1:1`.
*/
aspectRatio?: "1:1" | "2:1" | "3:1";
};
} & Offset;
/**
* This component draws an image.
......@@ -949,7 +1176,7 @@ export type FlexImage = {
* value for the vertical parent box is `0`.
*
* - For more information, see
* [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
......@@ -1038,10 +1265,10 @@ export type FlexImage = {
backgroundColor?: string;
/**
* Action performed when this button is tapped.
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
};
} & Offset;
/**
* This component draws a separator between components in the parent box.
......@@ -1077,20 +1304,24 @@ export type FlexSpacer = {
* The size increases in the order of listing.
* The default value is `md`.
*/
size: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
};
export type FlexText = {
type: "text";
text: string;
/**
* Array of spans. Be sure to set either one of the `text` property or `contents` property. If you set the `contents` property, `text` is ignored.
*/
contents?: FlexSpan[];
/**
* The ratio of the width or height of this box within the parent box.
*
* The default value for the horizontal parent box is `1`, and the default
* value for the vertical parent box is `0`.
*
* For more information, see
* [Width and height of components](https://developers.line.me/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
* [Width and height of components](https://developers.line.biz/en/docs/messaging-api/flex-message-layout/#component-width-and-height).
*/
flex?: number;
/**
......@@ -1171,9 +1402,68 @@ export type FlexText = {
color?: string;
/**
* Action performed when this text is tapped.
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*/
action?: Action;
/**
* Style of the text. Specify one of the following values:
* - `normal`: Normal
* - `italic`: Italic
*
* The default value is `normal`.
*/
style?: string;
/**
* Decoration of the text. Specify one of the following values:
* `none`: No decoration
* `underline`: Underline
* `line-through`: Strikethrough
*
* The default value is `none`.
*/
decoration?: string;
} & Offset;
/**
* This component renders multiple text strings with different designs in one row. You can specify the color, size, weight, and decoration for the font. Span is set to `contents` property in [Text](https://developers.line.biz/en/reference/messaging-api/#f-text).
*/
export type FlexSpan = {
type: "span";
/**
* Text. If the `wrap` property of the parent text is set to `true`, you can use a new line character (`\n`) to begin on a new line.
*/
text: string;
/**
* Font color. Use a hexadecimal color code.
*/
color?: string;
/**
* Font size. You can specify one of the following values: `xxs`, `xs`, `sm`, `md`, `lg`, `xl`, `xxl`, `3xl`, `4xl`, or `5xl`. The size increases in the order of listing. The default value is `md`.
*/
size?: string;
/**
* Font weight. You can specify one of the following values: `regular` or `bold`. Specifying `bold` makes the font bold. The default value is `regular`.
*/
weight?: string;
/**
* Style of the text. Specify one of the following values:
* - `normal`: Normal
* - `italic`: Italic
*
* The default value is `normal`.
*/
style?: string;
/**
* Decoration of the text. Specify one of the following values:
* `none`: No decoration
* `underline`: Underline
* `line-through`: Strikethrough
*
* The default value is `none`.
*
* Note: The decoration set in the `decoration` property of the [text](https://developers.line.biz/en/reference/messaging-api/#f-text) cannot be overwritten by the `decoration` property of the span.
*/
decoration?: string;
};
export type TemplateContent =
......@@ -1351,7 +1641,7 @@ export type TemplateImageCarousel = {
/**
* Array of columns (Max: 10)
*/
columns: TemplateImageColumn;
columns: TemplateImageColumn[];
};
export type TemplateImageColumn = {
......@@ -1375,12 +1665,12 @@ export type TemplateImageColumn = {
* These properties are used for the quick reply.
*
* For more information, see
* [Using quick replies](https://developers.line.me/en/docs/messaging-api/using-quick-reply/).
* [Using quick replies](https://developers.line.biz/en/docs/messaging-api/using-quick-reply/).
*/
export type QuickReply = {
/**
* This is a container that contains
* [quick reply buttons](https://developers.line.me/en/reference/messaging-api/#quick-reply-button-object).
* [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
*
* Array of objects (Max: 13)
*/
......@@ -1391,7 +1681,7 @@ export type QuickReply = {
* This is a quick reply option that is displayed as a button.
*
* For more information, see
* [quick reply buttons](https://developers.line.me/en/reference/messaging-api/#quick-reply-button-object).
* [quick reply buttons](https://developers.line.biz/en/reference/messaging-api/#quick-reply-button-object).
*/
export type QuickReplyItem = {
type: "action";
......@@ -1406,9 +1696,9 @@ export type QuickReplyItem = {
* There is no limit on the image size. If the `action` property has the
* following actions with empty `imageUrl`:
*
* - [camera action](https://developers.line.me/en/reference/messaging-api/#camera-action)
* - [camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action)
* - [location action](https://developers.line.me/en/reference/messaging-api/#location-action)
* - [camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*
* the default icon is displayed.
*/
......@@ -1416,16 +1706,16 @@ export type QuickReplyItem = {
/**
* Action performed when this button is tapped.
*
* Specify an [action object](https://developers.line.me/en/reference/messaging-api/#action-objects).
* Specify an [action object](https://developers.line.biz/en/reference/messaging-api/#action-objects).
*
* The following is a list of the available actions:
*
* - [Postback action](https://developers.line.me/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.me/en/reference/messaging-api/#message-action)
* - [Datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.me/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.me/en/reference/messaging-api/#location-action)
* - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
* - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*/
action: Action;
};
......@@ -1433,19 +1723,22 @@ export type QuickReplyItem = {
/**
* These are types of actions for your bot to take when a user taps a button or an image in a message.
*
* - [Postback action](https://developers.line.me/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.me/en/reference/messaging-api/#message-action)
* - [URI action](https://developers.line.me/en/reference/messaging-api/#uri-action)
* - [Datetime picker action](https://developers.line.me/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.me/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.me/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.me/en/reference/messaging-api/#location-action)
* - [Postback action](https://developers.line.biz/en/reference/messaging-api/#postback-action)
* - [Message action](https://developers.line.biz/en/reference/messaging-api/#message-action)
* - [URI action](https://developers.line.biz/en/reference/messaging-api/#uri-action)
* - [Datetime picker action](https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action)
* - [Camera action](https://developers.line.biz/en/reference/messaging-api/#camera-action)
* - [Camera roll action](https://developers.line.biz/en/reference/messaging-api/#camera-roll-action)
* - [Location action](https://developers.line.biz/en/reference/messaging-api/#location-action)
*/
export type Action<ExtraFields = { label: string }> = (
| PostbackAction
| MessageAction
| URIAction
| DatetimePickerAction) &
| DatetimePickerAction
| { type: "camera" }
| { type: "cameraRoll" }
| { type: "location" }) &
ExtraFields;
/**
......@@ -1504,11 +1797,26 @@ export type URIAction = {
* Must start with `http`, `https`, or `tel`.
*/
uri: string;
altUri?: AltURI;
};
/**
* URI opened on LINE for macOS and Windows when the action is performed (Max: 1000 characters)
* If the altUri.desktop property is set, the uri property is ignored on LINE for macOS and Windows.
* The available schemes are http, https, line, and tel.
* For more information about the LINE URL scheme, see Using the LINE URL scheme.
* This property is supported on the following version of LINE.
*
* LINE 5.12.0 or later for macOS and Windows
* Note: The altUri.desktop property is supported only when you set URI actions in Flex Messages.
*/
export type AltURI = {
desktop: string;
};
/**
* When a control associated with this action is tapped, a
* [postback event](https://developers.line.me/en/reference/messaging-api/#postback-event)
* [postback event](https://developers.line.biz/en/reference/messaging-api/#postback-event)
* is returned via webhook with the date and time selected by the user from the
* date and time selection dialog.
*
......@@ -1558,21 +1866,21 @@ export type Size = {
/**
* Rich menus consist of either of these objects.
*
* - [Rich menu object](https://developers.line.me/en/reference/messaging-api/#rich-menu-object)
* - [Rich menu object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-object)
* without the rich menu ID. Use this object when you
* [create a rich menu](https://developers.line.me/en/reference/messaging-api/#create-rich-menu).
* - [Rich menu response object](https://developers.line.me/en/reference/messaging-api/#rich-menu-response-object)
* [create a rich menu](https://developers.line.biz/en/reference/messaging-api/#create-rich-menu).
* - [Rich menu response object](https://developers.line.biz/en/reference/messaging-api/#rich-menu-response-object)
* with the rich menu ID. This object is returned when you
* [get a rich menu](https://developers.line.me/en/reference/messaging-api/#get-rich-menu)
* or [get a list of rich menus](https://developers.line.me/en/reference/messaging-api/#get-rich-menu-list).
* [get a rich menu](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu)
* or [get a list of rich menus](https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-list).
*
* [Area objects](https://developers.line.me/en/reference/messaging-api/#area-object) and
* [action objects](https://developers.line.me/en/reference/messaging-api/#action-objects)
* [Area objects](https://developers.line.biz/en/reference/messaging-api/#area-object) and
* [action objects](https://developers.line.biz/en/reference/messaging-api/#action-objects)
* are included in these objects.
*/
export type RichMenu = {
/**
* [`size` object](https://developers.line.me/en/reference/messaging-api/#size-object)
* [`size` object](https://developers.line.biz/en/reference/messaging-api/#size-object)
* which contains the width and height of the rich menu displayed in the chat.
* Rich menu images must be one of the following sizes: 2500x1686px or 2500x843px.
*/
......@@ -1595,7 +1903,7 @@ export type RichMenu = {
*/
chatBarText: string;
/**
* Array of [area objects](https://developers.line.me/en/reference/messaging-api/#area-object)
* Array of [area objects](https://developers.line.biz/en/reference/messaging-api/#area-object)
* which define the coordinates and size of tappable areas
* (Max: 20 area objects)
*/
......@@ -1603,3 +1911,177 @@ export type RichMenu = {
};
export type RichMenuResponse = { richMenuId: string } & RichMenu;
export type NumberOfMessagesSentResponse = InsightStatisticsResponse & {
/**
* The number of messages sent with the Messaging API on the date specified in date.
* The response has this property only when the value of status is `ready`.
*/
success?: number;
};
export type TargetLimitForAdditionalMessages = {
/**
* One of the following values to indicate whether a target limit is set or not.
* - `none`: This indicates that a target limit is not set.
* - `limited`: This indicates that a target limit is set.
*/
type: "none" | "limited";
/**
* The target limit for additional messages in the current month.
* This property is returned when the `type` property has a value of `limited`.
*/
value?: number;
};
export type NumberOfMessagesSentThisMonth = {
/**
* The number of sent messages in the current month
*/
totalUsage: number;
};
export const LINE_REQUEST_ID_HTTP_HEADER_NAME = "x-line-request-id";
export type MessageAPIResponseBase = {
[LINE_REQUEST_ID_HTTP_HEADER_NAME]?: string;
};
export type InsightStatisticsResponse = {
/**
* Calculation status. One of:
* - `ready`: Calculation has finished; the numbers are up-to-date.
* - `unready`: We haven't finished calculating the number of sent messages for the specified `date`. Calculation usually takes about a day. Please try again later.
* - `out_of_service`: The specified `date` is earlier than the date on which we first started calculating sent messages. Different APIs have different date. Check them at the [document](https://developers.line.biz/en/reference/messaging-api/).
*/
status: "ready" | "unready" | "out_of_service";
};
export type NumberOfMessageDeliveries = InsightStatisticsResponse & {
/**
* Number of push messages sent to **all** of this LINE official account's friends (broadcast messages).
*/
broadcast: number;
/**
* Number of push messages sent to **some** of this LINE official account's friends, based on specific attributes (targeted/segmented messages).
*/
targeting: number;
/**
* Number of auto-response messages sent.
*/
autoResponse: number;
/**
* Number of greeting messages sent.
*/
welcomeResponse: number;
/**
* Number of messages sent from LINE Official Account Manager [Chat screen](https://www.linebiz.com/jp-en/manual/OfficialAccountManager/chats/screens/).
*/
chat: number;
/**
* Number of broadcast messages sent with the [Send broadcast message](https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message) Messaging API operation.
*/
apiBroadcast: number;
/**
* Number of push messages sent with the [Send push message](https://developers.line.biz/en/reference/messaging-api/#send-push-message) Messaging API operation.
*/
apiPush: number;
/**
* Number of multicast messages sent with the [Send multicast message](https://developers.line.biz/en/reference/messaging-api/#send-multicast-message) Messaging API operation.
*/
apiMulticast: number;
/**
* Number of replies sent with the [Send reply message](https://developers.line.biz/en/reference/messaging-api/#send-reply-message) Messaging API operation.
*/
apiReply: number;
};
export type NumberOfFollowers = InsightStatisticsResponse & {
/**
* The number of times, as of the specified `date`, that a user added this LINE official account as a friend. The number doesn't decrease when a user blocks the account after adding it, or when they delete their own account.
*/
followers: Number;
/**
* The number of users, as of the specified `date`, that the official account can reach with messages targeted by gender, age, or area. This number includes users for whom we estimated demographic attributes based on their activity in LINE and LINE-connected services.
*/
targetedReaches: Number;
/**
* The number of users blocking the account as of the specified `date`. The number decreases when a user unblocks the account.
*/
blocks: Number;
};
export type NumberOfMessageDeliveriesResponse =
| InsightStatisticsResponse
| NumberOfMessageDeliveries;
export type NumberOfFollowersResponse =
| InsightStatisticsResponse
| NumberOfFollowers;
type PercentageAble = {
percentage: number;
};
export type FriendDemoGraphics = {
/**
* `true` if friend demographic information is available.
*/
available: boolean;
/**
* Percentage per gender
*/
genders?: Array<
{
/**
* Gender
*/
gender: "unknown" | "male" | "female";
} & PercentageAble
>;
/**
* Percentage per age group
*/
ages?: Array<
{
/**
* Age group
*/
age: string;
} & PercentageAble
>;
/**
* Percentage per area
*/
areas?: Array<
{
area: string;
} & PercentageAble
>;
/**
* Percentage by OS
*/
appTypes?: Array<
{
appType: "ios" | "android" | "others";
} & PercentageAble
>;
/**
* Percentage per friendship duration
*/
subscriptionPeriods?: Array<
{
/**
* Friendship duration
*/
subscriptionPeriod:
| "over365days"
| "within365days"
| "within180days"
| "within90days"
| "within30days"
| "within7days"
// in case for some rare cases(almost no)
| "unknown";
} & PercentageAble
>;
};
......
import { createHmac, timingSafeEqual } from "crypto";
function s2b(str: string, encoding: string): Buffer {
if (Buffer.from) {
try {
return Buffer.from(str, encoding);
} catch (err) {
if (err.name === "TypeError") {
return new Buffer(str, encoding);
}
throw err;
}
} else {
return new Buffer(str, encoding);
}
return Buffer.from(str, encoding);
}
function safeCompare(a: Buffer, b: Buffer): boolean {
if (a.length !== b.length) {
return false;
}
if (timingSafeEqual) {
return timingSafeEqual(a, b);
} else {
let result = 0;
for (let i = 0; i < a.length; i++) {
result |= a[i] ^ b[i];
}
return result === 0;
}
return timingSafeEqual(a, b);
}
export default function validateSignature(
......
{
"_from": "@line/bot-sdk",
"_id": "@line/bot-sdk@6.4.0",
"_from": "@line/bot-sdk@6.8.3",
"_id": "@line/bot-sdk@6.8.3",
"_inBundle": false,
"_integrity": "sha512-N0FkrqFxTTleOpD6y7DTK8qbMYHr9Q8qZfrAmSYEFAGedM1HLJdbNNkStj5GT+svx+w+/ePF/n7nAEts0aJwkA==",
"_integrity": "sha512-nj2T4CQxw0W/juAlpj0kMTDScOh5QUK6xMCR2dZp+pN8B0vj/c+5uX3TyGB4ijz/NIsehgfKujPgzw7LhtYtJw==",
"_location": "/@line/bot-sdk",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"type": "version",
"registry": true,
"raw": "@line/bot-sdk",
"raw": "@line/bot-sdk@6.8.3",
"name": "@line/bot-sdk",
"escapedName": "@line%2fbot-sdk",
"scope": "@line",
"rawSpec": "",
"rawSpec": "6.8.3",
"saveSpec": null,
"fetchSpec": "latest"
"fetchSpec": "6.8.3"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.4.0.tgz",
"_shasum": "18aa7659da26d3a8487614c74ad9ccb80ec4ca59",
"_spec": "@line/bot-sdk",
"_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot",
"_resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.8.3.tgz",
"_shasum": "0a886461e8c16a8c89091fd5338f6071335636a6",
"_spec": "@line/bot-sdk@6.8.3",
"_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT",
"bugs": {
"url": "https://github.com/line/line-bot-sdk-nodejs/issues"
},
......@@ -32,7 +32,7 @@
"@types/body-parser": "^1.16.8",
"@types/file-type": "^5.2.1",
"@types/node": "^7.0.31",
"axios": "^0.16.2",
"axios": "^0.19.0",
"body-parser": "^1.18.2",
"file-type": "^7.2.0"
},
......@@ -40,19 +40,21 @@
"description": "Node.js SDK for LINE Messaging API",
"devDependencies": {
"@types/express": "^4.0.35",
"@types/finalhandler": "^1.1.0",
"@types/mocha": "^2.2.41",
"del-cli": "^1.1.0",
"express": "^4.16.3",
"finalhandler": "^1.1.2",
"husky": "^0.14.3",
"mocha": "^5.2.0",
"nyc": "^12.0.2",
"nyc": "^14.1.1",
"prettier": "^1.15.2",
"ts-node": "^3.3.0",
"ts-node": "^8.3.0",
"typescript": "^3.1.6",
"vuepress": "^0.14.2"
"vuepress": "^0.14.10"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"files": [
"dist",
......@@ -102,5 +104,5 @@
"test": "API_BASE_URL=http://localhost:1234/ TEST_PORT=1234 TS_NODE_CACHE=0 nyc mocha"
},
"types": "dist/index.d.ts",
"version": "6.4.0"
"version": "6.8.3"
}
......
......@@ -5,12 +5,12 @@
This package contains type definitions for body-parser (https://github.com/expressjs/body-parser).
# Details
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/body-parser
Additional Details
* Last updated: Wed, 25 Apr 2018 00:24:37 GMT
* Dependencies: connect, http, node
* Last updated: Mon, 19 Aug 2019 00:51:08 GMT
* Dependencies: @types/connect, @types/node
* Global values: none
# Credits
These definitions were written by Santi Albo <https://github.com/santialbo>, Vilic Vane <https://github.com/vilic>, Jonathan Häberle <https://github.com/dreampulse>, Gevik Babakhani <https://github.com/blendsdk>, Tomasz Łaziuk <https://github.com/tlaziuk>, Jason Walton <https://github.com/jwalton>.
These definitions were written by Santi Albo <https://github.com/santialbo>, Vilic Vane <https://github.com/vilic>, Jonathan Häberle <https://github.com/dreampulse>, Gevik Babakhani <https://github.com/blendsdk>, Tomasz Łaziuk <https://github.com/tlaziuk>, and Jason Walton <https://github.com/jwalton>.
......
......@@ -7,7 +7,7 @@
// Tomasz Łaziuk <https://github.com/tlaziuk>
// Jason Walton <https://github.com/jwalton>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.3
/// <reference types="node" />
......
{
"_from": "@types/body-parser@^1.16.8",
"_id": "@types/body-parser@1.17.0",
"_id": "@types/body-parser@1.17.1",
"_inBundle": false,
"_integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==",
"_integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==",
"_location": "/@types/body-parser",
"_phantomChildren": {},
"_requested": {
......@@ -19,10 +19,10 @@
"_requiredBy": [
"/@line/bot-sdk"
],
"_resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz",
"_shasum": "9f5c9d9bd04bb54be32d5eb9fc0d8c974e6cf58c",
"_resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz",
"_shasum": "18fcf61768fb5c30ccc508c21d6fd2e8b3bf7897",
"_spec": "@types/body-parser@^1.16.8",
"_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk",
"_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk",
"bugs": {
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
},
......@@ -65,10 +65,12 @@
"name": "@types/body-parser",
"repository": {
"type": "git",
"url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
"url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/body-parser"
},
"scripts": {},
"typeScriptVersion": "2.2",
"typesPublisherContentHash": "d50d69303022e9f76f6d905e480a7dc98120bbcedb696a9722a4a2e9f08473e6",
"version": "1.17.0"
"typeScriptVersion": "2.3",
"types": "index",
"typesPublisherContentHash": "ada1b55777df6de5327f420d23285a5c476895faa88cacf6b80a1a791eef0f67",
"version": "1.17.1"
}
......
......@@ -8,9 +8,9 @@ This package contains type definitions for Node.js (http://nodejs.org/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v7
Additional Details
* Last updated: Thu, 15 Nov 2018 00:16:17 GMT
* Last updated: Wed, 30 Oct 2019 15:44:46 GMT
* Dependencies: none
* Global values: Buffer, NodeJS, SlowBuffer, Symbol, __dirname, __filename, clearImmediate, clearInterval, clearTimeout, console, exports, global, module, process, require, setImmediate, setInterval, setTimeout
# Credits
These definitions were written by Microsoft TypeScript <https://github.com/Microsoft>, DefinitelyTyped <https://github.com/DefinitelyTyped>, Parambir Singh <https://github.com/parambirs>, Christian Vaagland Tellnes <https://github.com/tellnes>, Wilco Bakker <https://github.com/WilcoBakker>, Sebastian Silbermann <https://github.com/eps1lon>, Hoàng Văn Khải <https://github.com/KSXGitHub>, Sander Koenders <https://github.com/Archcry>.
These definitions were written by Microsoft TypeScript <https://github.com/Microsoft>, DefinitelyTyped <https://github.com/DefinitelyTyped>, Parambir Singh <https://github.com/parambirs>, Christian Vaagland Tellnes <https://github.com/tellnes>, Wilco Bakker <https://github.com/WilcoBakker>, Sebastian Silbermann <https://github.com/eps1lon>, Hoàng Văn Khải <https://github.com/KSXGitHub>, Sander Koenders <https://github.com/Archcry>, and Jordi Oliveras Rovira <https://github.com/j-oliveras>.
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
{
"_from": "@types/node@^7.0.31",
"_id": "@types/node@7.10.2",
"_id": "@types/node@7.10.9",
"_inBundle": false,
"_integrity": "sha512-RO4ig5taKmcrU4Rex8ojG1gpwFkjddzug9iPQSDvbewHN9vDpcFewevkaOK+KT+w1LeZnxbgOyfXwV4pxsQ4GQ==",
"_integrity": "sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw==",
"_location": "/@types/node",
"_phantomChildren": {},
"_requested": {
......@@ -22,10 +22,10 @@
"/@types/connect",
"/@types/file-type"
],
"_resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.2.tgz",
"_shasum": "a98845168012d7a63a84d50e738829da43bdb0de",
"_resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.9.tgz",
"_shasum": "4343e3b009f8cf5e1ed685e36097b74b4101e880",
"_spec": "@types/node@^7.0.31",
"_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk",
"_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk",
"bugs": {
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
},
......@@ -62,6 +62,10 @@
{
"name": "Sander Koenders",
"url": "https://github.com/Archcry"
},
{
"name": "Jordi Oliveras Rovira",
"url": "https://github.com/j-oliveras"
}
],
"dependencies": {},
......@@ -73,11 +77,19 @@
"name": "@types/node",
"repository": {
"type": "git",
"url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
"url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/node"
},
"scripts": {},
"typeScriptVersion": "2.0",
"types": "index",
"typesPublisherContentHash": "55896a12ed8765c021f335913ef256ce4eb8ac2fc4b0c93611d7ce514e2906ea",
"version": "7.10.2"
"typesPublisherContentHash": "0c534d9103600d73c97ec8a474420c4d9262b941ae93e66c175cb27e62683e84",
"typesVersions": {
">=3.2.0-0": {
"*": [
"ts3.2/*"
]
}
},
"version": "7.10.9"
}
......
// NOTE: These definitions support NodeJS and TypeScript 3.2.
// NOTE: TypeScript version-specific augmentations can be found in the following paths:
// - ~/base.d.ts - Shared definitions common to all TypeScript versions
// - ~/index.d.ts - Definitions specific to TypeScript 2.1
// - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2
// Reference required types from the default lib:
/// <reference lib="es2016" />
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
// tslint:disable-next-line:no-bad-reference
/// <reference path="../base.d.ts" />
// TypeScript 3.2-specific augmentations:
# Changelog
### 0.19.0 (May 30, 2019)
Fixes and Functionality:
- Unzip response body only for statuses != 204 ([#1129](https://github.com/axios/axios/pull/1129)) - drawski
- Destroy stream on exceeding maxContentLength (fixes [#1098](https://github.com/axios/axios/issue/1098)) ([#1485](https://github.com/axios/axios/pull/1485)) - Gadzhi Gadzhiev
- Makes Axios error generic to use AxiosResponse ([#1738](https://github.com/axios/axios/pull/1738)) - Suman Lama
- Fixing Mocha tests by locking follow-redirects version to 1.5.10 ([#1993](https://github.com/axios/axios/pull/1993)) - grumblerchester
- Allow uppercase methods in typings. ([#1781](https://github.com/axios/axios/pull/1781)) - Ken Powers
- Fixing .eslintrc without extension ([#1789](https://github.com/axios/axios/pull/1789)) - Manoel
- Consistent coding style ([#1787](https://github.com/axios/axios/pull/1787)) - Ali Servet Donmez
- Fixing building url with hash mark ([#1771](https://github.com/axios/axios/pull/1771)) - Anatoly Ryabov
- This commit fix building url with hash map (fragment identifier) when parameters are present: they must not be added after `#`, because client cut everything after `#`
- Preserve HTTP method when following redirect ([#1758](https://github.com/axios/axios/pull/1758)) - Rikki Gibson
- Add `getUri` signature to TypeScript definition. ([#1736](https://github.com/axios/axios/pull/1736)) - Alexander Trauzzi
- Adding isAxiosError flag to errors thrown by axios ([#1419](https://github.com/axios/axios/pull/1419)) - Ayush Gupta
- Fix failing SauceLabs tests by updating configuration - Emily Morehouse
Documentation:
- Add information about auth parameter to README ([#2166](https://github.com/axios/axios/pull/2166)) - xlaguna
- Add DELETE to list of methods that allow data as a config option ([#2169](https://github.com/axios/axios/pull/2169)) - Daniela Borges Matos de Carvalho
- Update ECOSYSTEM.md - Add Axios Endpoints ([#2176](https://github.com/axios/axios/pull/2176)) - Renan
- Add r2curl in ECOSYSTEM ([#2141](https://github.com/axios/axios/pull/2141)) - 유용우 / CX
- Update README.md - Add instructions for installing with yarn ([#2036](https://github.com/axios/axios/pull/2036)) - Victor Hermes
- Fixing spacing for README.md ([#2066](https://github.com/axios/axios/pull/2066)) - Josh McCarty
- Update README.md. - Change `.then` to `.finally` in example code ([#2090](https://github.com/axios/axios/pull/2090)) - Omar Cai
- Clarify what values responseType can have in Node ([#2121](https://github.com/axios/axios/pull/2121)) - Tyler Breisacher
- docs(ECOSYSTEM): add axios-api-versioning ([#2020](https://github.com/axios/axios/pull/2020)) - Weffe
- It seems that `responseType: 'blob'` doesn't actually work in Node (when I tried using it, response.data was a string, not a Blob, since Node doesn't have Blobs), so this clarifies that this option should only be used in the browser
- Add issue templates - Emily Morehouse
- Update README.md. - Add Querystring library note ([#1896](https://github.com/axios/axios/pull/1896)) - Dmitriy Eroshenko
- Add react-hooks-axios to Libraries section of ECOSYSTEM.md ([#1925](https://github.com/axios/axios/pull/1925)) - Cody Chan
- Clarify in README that default timeout is 0 (no timeout) ([#1750](https://github.com/axios/axios/pull/1750)) - Ben Standefer
### 0.19.0-beta.1 (Aug 9, 2018)
**NOTE:** This is a beta version of this release. There may be functionality that is broken in
certain browsers, though we suspect that builds are hanging and not erroring. See
https://saucelabs.com/u/axios for the most up-to-date information.
New Functionality:
- Add getUri method ([#1712](https://github.com/axios/axios/issues/1712))
- Add support for no_proxy env variable ([#1693](https://github.com/axios/axios/issues/1693))
- Add toJSON to decorated Axios errors to faciliate serialization ([#1625](https://github.com/axios/axios/issues/1625))
- Add second then on axios call ([#1623](https://github.com/axios/axios/issues/1623))
- Typings: allow custom return types
- Add option to specify character set in responses (with http adapter)
Fixes:
- Fix Keep defaults local to instance ([#385](https://github.com/axios/axios/issues/385))
- Correctly catch exception in http test ([#1475](https://github.com/axios/axios/issues/1475))
- Fix accept header normalization ([#1698](https://github.com/axios/axios/issues/1698))
- Fix http adapter to allow HTTPS connections via HTTP ([#959](https://github.com/axios/axios/issues/959))
- Fix Removes usage of deprecated Buffer constructor. ([#1555](https://github.com/axios/axios/issues/1555), [#1622](https://github.com/axios/axios/issues/1622))
- Fix defaults to use httpAdapter if available ([#1285](https://github.com/axios/axios/issues/1285))
- Fixing defaults to use httpAdapter if available
- Use a safer, cross-platform method to detect the Node environment
- Fix Reject promise if request is cancelled by the browser ([#537](https://github.com/axios/axios/issues/537))
- [Typescript] Fix missing type parameters on delete/head methods
- [NS]: Send `false` flag isStandardBrowserEnv for Nativescript
- Fix missing type parameters on delete/head
- Fix Default method for an instance always overwritten by get
- Fix type error when socketPath option in AxiosRequestConfig
- Capture errors on request data streams
- Decorate resolve and reject to clear timeout in all cases
Huge thanks to everyone who contributed to this release via code (authors listed
below) or via reviews and triaging on GitHub:
- Andrew Scott <ascott18@gmail.com>
- Anthony Gauthier <antho325@hotmail.com>
- arpit <arpit2438735@gmail.com>
- ascott18
- Benedikt Rötsch <axe312ger@users.noreply.github.com>
- Chance Dickson <me@chancedickson.com>
- Dave Stewart <info@davestewart.co.uk>
- Deric Cain <deric.cain@gmail.com>
- Guillaume Briday <guillaumebriday@gmail.com>
- Jacob Wejendorp <jacob@wejendorp.dk>
- Jim Lynch <mrdotjim@gmail.com>
- johntron
- Justin Beckwith <beckwith@google.com>
- Justin Beckwith <justin.beckwith@gmail.com>
- Khaled Garbaya <khaledgarbaya@gmail.com>
- Lim Jing Rong <jjingrong@users.noreply.github.com>
- Mark van den Broek <mvdnbrk@gmail.com>
- Martti Laine <martti@codeclown.net>
- mattridley
- mattridley <matt.r@joinblink.com>
- Nicolas Del Valle <nicolas.delvalle@gmail.com>
- Nilegfx
- pbarbiero
- Rikki Gibson <rikkigibson@gmail.com>
- Sako Hartounian <sakohartounian@yahoo.com>
- Shane Fitzpatrick <fitzpasd@gmail.com>
- Stephan Schneider <stephanschndr@gmail.com>
- Steven <steven@ceriously.com>
- Tim Garthwaite <tim.garthwaite@jibo.com>
- Tim Johns <timjohns@yahoo.com>
- Yutaro Miyazaki <yutaro@studio-rubbish.com>
### 0.18.0 (Feb 19, 2018)
- Adding support for UNIX Sockets when running with Node.js ([#1070](https://github.com/axios/axios/pull/1070))
- Fixing typings ([#1177](https://github.com/axios/axios/pull/1177)):
- AxiosRequestConfig.proxy: allows type false
- AxiosProxyConfig: added auth field
- Adding function signature in AxiosInstance interface so AxiosInstance can be invoked ([#1192](https://github.com/axios/axios/pull/1192), [#1254](https://github.com/axios/axios/pull/1254))
- Allowing maxContentLength to pass through to redirected calls as maxBodyLength in follow-redirects config ([#1287](https://github.com/axios/axios/pull/1287))
- Fixing configuration when using an instance - method can now be set ([#1342](https://github.com/axios/axios/pull/1342))
### 0.17.1 (Nov 11, 2017)
- Fixing issue with web workers ([#1160](https://github.com/axios/axios/pull/1160))
- Allowing overriding transport ([#1080](https://github.com/axios/axios/pull/1080))
- Updating TypeScript typings ([#1165](https://github.com/axios/axios/pull/1165), [#1125](https://github.com/axios/axios/pull/1125), [#1131](https://github.com/axios/axios/pull/1131))
### 0.17.0 (Oct 21, 2017)
- **BREAKING** Fixing issue with `baseURL` and interceptors ([#950](https://github.com/axios/axios/pull/950))
- **BREAKING** Improving handing of duplicate headers ([#874](https://github.com/axios/axios/pull/874))
- Adding support for disabling proxies ([#691](https://github.com/axios/axios/pull/691))
- Updating TypeScript typings with generic type parameters ([#1061](https://github.com/axios/axios/pull/1061))
### 0.16.2 (Jun 3, 2017)
- Fixing issue with including `buffer` in bundle ([#887](https://github.com/mzabriskie/axios/pull/887))
- Including underlying request in errors ([#830](https://github.com/mzabriskie/axios/pull/830))
- Convert `method` to lowercase ([#930](https://github.com/mzabriskie/axios/pull/930))
- Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887))
- Including underlying request in errors ([#830](https://github.com/axios/axios/pull/830))
- Convert `method` to lowercase ([#930](https://github.com/axios/axios/pull/930))
### 0.16.1 (Apr 8, 2017)
- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/mzabriskie/axios/pull/828))
- Updating `follow-redirects` dependency ([#829](https://github.com/mzabriskie/axios/pull/829))
- Adding support for passing `Buffer` in node ([#773](https://github.com/mzabriskie/axios/pull/773))
- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/axios/axios/pull/828))
- Updating `follow-redirects` dependency ([#829](https://github.com/axios/axios/pull/829))
- Adding support for passing `Buffer` in node ([#773](https://github.com/axios/axios/pull/773))
### 0.16.0 (Mar 31, 2017)
- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/mzabriskie/axios/issues/480))
- Adding `options` shortcut method ([#461](https://github.com/mzabriskie/axios/pull/461))
- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/mzabriskie/axios/pull/654))
- Improving React Native detection ([#731](https://github.com/mzabriskie/axios/pull/731))
- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/mzabriskie/axios/pull/581))
- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/mzabriskie/axios/pull/561))
- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/axios/axios/issues/480))
- Adding `options` shortcut method ([#461](https://github.com/axios/axios/pull/461))
- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/axios/axios/pull/654))
- Improving React Native detection ([#731](https://github.com/axios/axios/pull/731))
- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/axios/axios/pull/581))
- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/axios/axios/pull/561))
### 0.15.3 (Nov 27, 2016)
- Fixing issue with custom instances and global defaults ([#443](https://github.com/mzabriskie/axios/issues/443))
- Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/mzabriskie/axios/issues/519))
- Adding `get`, `head`, and `delete` to `defaults.headers` ([#509](https://github.com/mzabriskie/axios/issues/509))
- Fixing issue with `btoa` and IE ([#507](https://github.com/mzabriskie/axios/issues/507))
- Adding support for proxy authentication ([#483](https://github.com/mzabriskie/axios/pull/483))
- Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/mzabriskie/axios/pull/493))
- Fixing proxy issues ([#491](https://github.com/mzabriskie/axios/pull/491))
- Fixing issue with custom instances and global defaults ([#443](https://github.com/axios/axios/issues/443))
- Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/axios/axios/issues/519))
- Adding `get`, `head`, and `delete` to `defaults.headers` ([#509](https://github.com/axios/axios/issues/509))
- Fixing issue with `btoa` and IE ([#507](https://github.com/axios/axios/issues/507))
- Adding support for proxy authentication ([#483](https://github.com/axios/axios/pull/483))
- Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/axios/axios/pull/493))
- Fixing proxy issues ([#491](https://github.com/axios/axios/pull/491))
### 0.15.2 (Oct 17, 2016)
- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/mzabriskie/axios/issues/482))
- Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/axios/axios/issues/482))
### 0.15.1 (Oct 14, 2016)
- Fixing issue with UMD ([#485](https://github.com/mzabriskie/axios/issues/485))
- Fixing issue with UMD ([#485](https://github.com/axios/axios/issues/485))
### 0.15.0 (Oct 10, 2016)
- Adding cancellation support ([#452](https://github.com/mzabriskie/axios/pull/452))
- Moving default adapter to global defaults ([#437](https://github.com/mzabriskie/axios/pull/437))
- Fixing issue with `file` URI scheme ([#440](https://github.com/mzabriskie/axios/pull/440))
- Fixing issue with `params` objects that have no prototype ([#445](https://github.com/mzabriskie/axios/pull/445))
- Adding cancellation support ([#452](https://github.com/axios/axios/pull/452))
- Moving default adapter to global defaults ([#437](https://github.com/axios/axios/pull/437))
- Fixing issue with `file` URI scheme ([#440](https://github.com/axios/axios/pull/440))
- Fixing issue with `params` objects that have no prototype ([#445](https://github.com/axios/axios/pull/445))
### 0.14.0 (Aug 27, 2016)
- **BREAKING** Updating TypeScript definitions ([#419](https://github.com/mzabriskie/axios/pull/419))
- **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/mzabriskie/axios/pull/387))
- **BREAKING** Splitting `progress` event handlers into `onUploadProgress` and `onDownloadProgress` ([#423](https://github.com/mzabriskie/axios/pull/423))
- Adding support for `http_proxy` and `https_proxy` environment variables ([#366](https://github.com/mzabriskie/axios/pull/366))
- Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/mzabriskie/axios/pull/397))
- Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/mzabriskie/axios/pull/406))
- **BREAKING** Updating TypeScript definitions ([#419](https://github.com/axios/axios/pull/419))
- **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/axios/axios/pull/387))
- **BREAKING** Splitting `progress` event handlers into `onUploadProgress` and `onDownloadProgress` ([#423](https://github.com/axios/axios/pull/423))
- Adding support for `http_proxy` and `https_proxy` environment variables ([#366](https://github.com/axios/axios/pull/366))
- Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/axios/axios/pull/397))
- Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/axios/axios/pull/406))
### 0.13.1 (Jul 16, 2016)
- Fixing issue with response data not being transformed on error ([#378](https://github.com/mzabriskie/axios/issues/378))
- Fixing issue with response data not being transformed on error ([#378](https://github.com/axios/axios/issues/378))
### 0.13.0 (Jul 13, 2016)
- **BREAKING** Improved error handling ([#345](https://github.com/mzabriskie/axios/pull/345))
- **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/mzabriskie/axios/commit/10eb23865101f9347570552c04e9d6211376e25e))
- **BREAKING** Request adapters now return a `Promise` ([157efd5](https://github.com/mzabriskie/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a))
- Fixing issue with `withCredentials` not being overwritten ([#343](https://github.com/mzabriskie/axios/issues/343))
- Fixing regression with request transformer being called before request interceptor ([#352](https://github.com/mzabriskie/axios/issues/352))
- Fixing custom instance defaults ([#341](https://github.com/mzabriskie/axios/issues/341))
- Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/mzabriskie/axios/issues/217))
- **BREAKING** Improved error handling ([#345](https://github.com/axios/axios/pull/345))
- **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e))
- **BREAKING** Request adapters now return a `Promise` ([157efd5](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a))
- Fixing issue with `withCredentials` not being overwritten ([#343](https://github.com/axios/axios/issues/343))
- Fixing regression with request transformer being called before request interceptor ([#352](https://github.com/axios/axios/issues/352))
- Fixing custom instance defaults ([#341](https://github.com/axios/axios/issues/341))
- Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/axios/axios/issues/217))
### 0.12.0 (May 31, 2016)
- Adding support for `URLSearchParams` ([#317](https://github.com/mzabriskie/axios/pull/317))
- Adding `maxRedirects` option ([#307](https://github.com/mzabriskie/axios/pull/307))
- Adding support for `URLSearchParams` ([#317](https://github.com/axios/axios/pull/317))
- Adding `maxRedirects` option ([#307](https://github.com/axios/axios/pull/307))
### 0.11.1 (May 17, 2016)
- Fixing IE CORS support ([#313](https://github.com/mzabriskie/axios/pull/313))
- Fixing detection of `FormData` ([#325](https://github.com/mzabriskie/axios/pull/325))
- Adding `Axios` class to exports ([#321](https://github.com/mzabriskie/axios/pull/321))
- Fixing IE CORS support ([#313](https://github.com/axios/axios/pull/313))
- Fixing detection of `FormData` ([#325](https://github.com/axios/axios/pull/325))
- Adding `Axios` class to exports ([#321](https://github.com/axios/axios/pull/321))
### 0.11.0 (Apr 26, 2016)
- Adding support for Stream with HTTP adapter ([#296](https://github.com/mzabriskie/axios/pull/296))
- Adding support for custom HTTP status code error ranges ([#308](https://github.com/mzabriskie/axios/pull/308))
- Fixing issue with ArrayBuffer ([#299](https://github.com/mzabriskie/axios/pull/299))
- Adding support for Stream with HTTP adapter ([#296](https://github.com/axios/axios/pull/296))
- Adding support for custom HTTP status code error ranges ([#308](https://github.com/axios/axios/pull/308))
- Fixing issue with ArrayBuffer ([#299](https://github.com/axios/axios/pull/299))
### 0.10.0 (Apr 20, 2016)
- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/mzabriskie/axios/pull/250))
- Fixing basic auth for HTTP adapter ([#252](https://github.com/mzabriskie/axios/pull/252))
- Fixing request timeout for XHR adapter ([#227](https://github.com/mzabriskie/axios/pull/227))
- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/mzabriskie/axios/pull/249))
- Fixing IE9 cross domain requests ([#251](https://github.com/mzabriskie/axios/pull/251))
- Adding `maxContentLength` option ([#275](https://github.com/mzabriskie/axios/pull/275))
- Fixing XHR support for WebWorker environment ([#279](https://github.com/mzabriskie/axios/pull/279))
- Adding request instance to response ([#200](https://github.com/mzabriskie/axios/pull/200))
- Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/axios/axios/pull/250))
- Fixing basic auth for HTTP adapter ([#252](https://github.com/axios/axios/pull/252))
- Fixing request timeout for XHR adapter ([#227](https://github.com/axios/axios/pull/227))
- Fixing IE8 support by using `onreadystatechange` instead of `onload` ([#249](https://github.com/axios/axios/pull/249))
- Fixing IE9 cross domain requests ([#251](https://github.com/axios/axios/pull/251))
- Adding `maxContentLength` option ([#275](https://github.com/axios/axios/pull/275))
- Fixing XHR support for WebWorker environment ([#279](https://github.com/axios/axios/pull/279))
- Adding request instance to response ([#200](https://github.com/axios/axios/pull/200))
### 0.9.1 (Jan 24, 2016)
- Improving handling of request timeout in node ([#124](https://github.com/mzabriskie/axios/issues/124))
- Fixing network errors not rejecting ([#205](https://github.com/mzabriskie/axios/pull/205))
- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/mzabriskie/axios/issues/201))
- Fixing host/port when following redirects ([#198](https://github.com/mzabriskie/axios/pull/198))
- Improving handling of request timeout in node ([#124](https://github.com/axios/axios/issues/124))
- Fixing network errors not rejecting ([#205](https://github.com/axios/axios/pull/205))
- Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/axios/axios/issues/201))
- Fixing host/port when following redirects ([#198](https://github.com/axios/axios/pull/198))
### 0.9.0 (Jan 18, 2016)
- Adding support for custom adapters
- Fixing Content-Type header being removed when data is false ([#195](https://github.com/mzabriskie/axios/pull/195))
- Improving XDomainRequest implementation ([#185](https://github.com/mzabriskie/axios/pull/185))
- Improving config merging and order of precedence ([#183](https://github.com/mzabriskie/axios/pull/183))
- Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/mzabriskie/axios/pull/182))
- Fixing Content-Type header being removed when data is false ([#195](https://github.com/axios/axios/pull/195))
- Improving XDomainRequest implementation ([#185](https://github.com/axios/axios/pull/185))
- Improving config merging and order of precedence ([#183](https://github.com/axios/axios/pull/183))
- Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/axios/axios/pull/182))
### 0.8.1 (Dec 14, 2015)
- Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/mzabriskie/axios/pull/168))
- Fixing error with format of basic auth header ([#178](https://github.com/mzabriskie/axios/pull/173))
- Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/mzabriskie/axios/pull/174))
- Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/axios/axios/pull/168))
- Fixing error with format of basic auth header ([#178](https://github.com/axios/axios/pull/173))
- Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/axios/axios/pull/174))
### 0.8.0 (Dec 11, 2015)
- Adding support for creating instances of axios ([#123](https://github.com/mzabriskie/axios/pull/123))
- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/mzabriskie/axios/pull/128))
- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/mzabriskie/axios/pull/121))
- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/mzabriskie/axios/pull/127))
- Adding support for following redirects in node ([#146](https://github.com/mzabriskie/axios/pull/146))
- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/mzabriskie/axios/pull/149))
- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/mzabriskie/axios/pull/140))
- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/mzabriskie/axios/pull/167))
- Adding support for baseURL option ([#160](https://github.com/mzabriskie/axios/pull/160))
- Adding support for creating instances of axios ([#123](https://github.com/axios/axios/pull/123))
- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/axios/axios/pull/128))
- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/axios/axios/pull/121))
- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/axios/axios/pull/127))
- Adding support for following redirects in node ([#146](https://github.com/axios/axios/pull/146))
- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/axios/axios/pull/149))
- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/axios/axios/pull/140))
- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/axios/axios/pull/167))
- Adding support for baseURL option ([#160](https://github.com/axios/axios/pull/160))
### 0.7.0 (Sep 29, 2015)
- Fixing issue with minified bundle in IE8 ([#87](https://github.com/mzabriskie/axios/pull/87))
- Adding support for passing agent in node ([#102](https://github.com/mzabriskie/axios/pull/102))
- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/mzabriskie/axios/pull/106))
- Fixing typescript definition ([#105](https://github.com/mzabriskie/axios/pull/105))
- Fixing default timeout config for node ([#112](https://github.com/mzabriskie/axios/pull/112))
- Adding support for use in web workers, and react-native ([#70](https://github.com/mzabriskie/axios/issue/70)), ([#98](https://github.com/mzabriskie/axios/pull/98))
- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/mzabriskie/axios/issues/116))
- Fixing issue with minified bundle in IE8 ([#87](https://github.com/axios/axios/pull/87))
- Adding support for passing agent in node ([#102](https://github.com/axios/axios/pull/102))
- Adding support for returning result from `axios.spread` for chaining ([#106](https://github.com/axios/axios/pull/106))
- Fixing typescript definition ([#105](https://github.com/axios/axios/pull/105))
- Fixing default timeout config for node ([#112](https://github.com/axios/axios/pull/112))
- Adding support for use in web workers, and react-native ([#70](https://github.com/axios/axios/issue/70)), ([#98](https://github.com/axios/axios/pull/98))
- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/axios/axios/issues/116))
### 0.6.0 (Sep 21, 2015)
- Removing deprecated success/error aliases
- Fixing issue with array params not being properly encoded ([#49](https://github.com/mzabriskie/axios/pull/49))
- Fixing issue with User-Agent getting overridden ([#69](https://github.com/mzabriskie/axios/issues/69))
- Adding support for timeout config ([#56](https://github.com/mzabriskie/axios/issues/56))
- Fixing issue with array params not being properly encoded ([#49](https://github.com/axios/axios/pull/49))
- Fixing issue with User-Agent getting overridden ([#69](https://github.com/axios/axios/issues/69))
- Adding support for timeout config ([#56](https://github.com/axios/axios/issues/56))
- Removing es6-promise dependency
- Fixing issue preventing `length` to be used as a parameter ([#91](https://github.com/mzabriskie/axios/pull/91))
- Fixing issue with IE8 ([#85](https://github.com/mzabriskie/axios/pull/85))
- Fixing issue preventing `length` to be used as a parameter ([#91](https://github.com/axios/axios/pull/91))
- Fixing issue with IE8 ([#85](https://github.com/axios/axios/pull/85))
- Converting build to UMD
### 0.5.4 (Apr 08, 2015)
- Fixing issue with FormData not being sent ([#53](https://github.com/mzabriskie/axios/issues/53))
- Fixing issue with FormData not being sent ([#53](https://github.com/axios/axios/issues/53))
### 0.5.3 (Apr 07, 2015)
- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/mzabriskie/axios/issues/55))
- Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/axios/axios/issues/55))
### 0.5.2 (Mar 13, 2015)
- Adding support for `statusText` in response ([#46](https://github.com/mzabriskie/axios/issues/46))
- Adding support for `statusText` in response ([#46](https://github.com/axios/axios/issues/46))
### 0.5.1 (Mar 10, 2015)
- Fixing issue using strict mode ([#45](https://github.com/mzabriskie/axios/issues/45))
- Fixing issue with standalone build ([#47](https://github.com/mzabriskie/axios/issues/47))
- Fixing issue using strict mode ([#45](https://github.com/axios/axios/issues/45))
- Fixing issue with standalone build ([#47](https://github.com/axios/axios/issues/47))
### 0.5.0 (Jan 23, 2015)
- Adding support for intercepetors ([#14](https://github.com/mzabriskie/axios/issues/14))
- Adding support for intercepetors ([#14](https://github.com/axios/axios/issues/14))
- Updating es6-promise dependency
### 0.4.2 (Dec 10, 2014)
- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/mzabriskie/axios/issues/22))
- Adding support for TypeScript ([#25](https://github.com/mzabriskie/axios/issues/25))
- Fixing issue with standalone build ([#29](https://github.com/mzabriskie/axios/issues/29))
- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/mzabriskie/axios/issues/30))
- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/axios/axios/issues/22))
- Adding support for TypeScript ([#25](https://github.com/axios/axios/issues/25))
- Fixing issue with standalone build ([#29](https://github.com/axios/axios/issues/29))
- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/axios/axios/issues/30))
### 0.4.1 (Oct 15, 2014)
- Adding error handling to request for node.js ([#18](https://github.com/mzabriskie/axios/issues/18))
- Adding error handling to request for node.js ([#18](https://github.com/axios/axios/issues/18))
### 0.4.0 (Oct 03, 2014)
- Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/mzabriskie/axios/issues/10))
- Adding support for utf-8 for node.js ([#13](https://github.com/mzabriskie/axios/issues/13))
- Adding support for SSL for node.js ([#12](https://github.com/mzabriskie/axios/issues/12))
- Fixing incorrect `Content-Type` header ([#9](https://github.com/mzabriskie/axios/issues/9))
- Adding standalone build without bundled es6-promise ([#11](https://github.com/mzabriskie/axios/issues/11))
- Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/axios/axios/issues/10))
- Adding support for utf-8 for node.js ([#13](https://github.com/axios/axios/issues/13))
- Adding support for SSL for node.js ([#12](https://github.com/axios/axios/issues/12))
- Fixing incorrect `Content-Type` header ([#9](https://github.com/axios/axios/issues/9))
- Adding standalone build without bundled es6-promise ([#11](https://github.com/axios/axios/issues/11))
- Deprecating `success`/`error` in favor of `then`/`catch`
### 0.3.1 (Sep 16, 2014)
- Fixing missing post body when using node.js ([#3](https://github.com/mzabriskie/axios/issues/3))
- Fixing missing post body when using node.js ([#3](https://github.com/axios/axios/issues/3))
### 0.3.0 (Sep 16, 2014)
- Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/mzabriskie/axios/issues/8))
- Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/mzabriskie/axios/issues/6))
- Fixing issue with `all` not working ([#7](https://github.com/mzabriskie/axios/issues/7))
- Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/axios/axios/issues/8))
- Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/axios/axios/issues/6))
- Fixing issue with `all` not working ([#7](https://github.com/axios/axios/issues/7))
### 0.2.2 (Sep 14, 2014)
- Fixing bundling with browserify ([#4](https://github.com/mzabriskie/axios/issues/4))
- Fixing bundling with browserify ([#4](https://github.com/axios/axios/issues/4))
### 0.2.1 (Sep 12, 2014)
......@@ -214,7 +341,7 @@
### 0.2.0 (Sep 12, 2014)
- Adding support for `all` and `spread`
- Adding support for node.js ([#1](https://github.com/mzabriskie/axios/issues/1))
- Adding support for node.js ([#1](https://github.com/axios/axios/issues/1))
### 0.1.0 (Aug 29, 2014)
......
Copyright (c) 2014 Matt Zabriskie
Copyright (c) 2014-present Matt Zabriskie
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
# axios
[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios)
[![build status](https://img.shields.io/travis/mzabriskie/axios.svg?style=flat-square)](https://travis-ci.org/mzabriskie/axios)
[![build status](https://img.shields.io/travis/axios/axios.svg?style=flat-square)](https://travis-ci.org/axios/axios)
[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios)
[![install size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)
[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios)
[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios)
[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
Promise based HTTP client for the browser and node.js
......@@ -23,7 +25,7 @@ Promise based HTTP client for the browser and node.js
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |
--- | --- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
[![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios)
......@@ -41,6 +43,12 @@ Using bower:
$ bower install axios
```
Using yarn:
```bash
$ yarn add axios
```
Using cdn:
```html
......@@ -52,13 +60,20 @@ Using cdn:
Performing a `GET` request
```js
const axios = require('axios');
// Make a request for a user with a given ID
axios.get('/user?ID=12345')
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
// Optionally the request above could also be done as
......@@ -72,9 +87,25 @@ axios.get('/user', {
})
.catch(function (error) {
console.log(error);
});
})
.then(function () {
// always executed
});
// Want to use async/await? Add the `async` keyword to your outer function/method.
async function getUser() {
try {
const response = await axios.get('/user?ID=12345');
console.log(response);
} catch (error) {
console.error(error);
}
}
```
> **NOTE:** `async/await` is part of ECMAScript 2017 and is not supported in Internet
> Explorer and older browsers, so use with caution.
Performing a `POST` request
```js
......@@ -128,13 +159,13 @@ axios({
```js
// GET request for remote image
axios({
method:'get',
url:'http://bit.ly/2mTM3nY',
responseType:'stream'
method: 'get',
url: 'http://bit.ly/2mTM3nY',
responseType: 'stream'
})
.then(function(response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});
.then(function (response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});
```
##### axios(url[, config])
......@@ -174,7 +205,7 @@ You can create a new instance of axios with a custom config.
##### axios.create([config])
```js
var instance = axios.create({
const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'}
......@@ -193,6 +224,7 @@ The available instance methods are listed below. The specified config will be me
##### axios#post(url[, data[, config]])
##### axios#put(url[, data[, config]])
##### axios#patch(url[, data[, config]])
##### axios#getUri([config])
## Request Config
......@@ -212,10 +244,11 @@ These are the available config options for making requests. Only the `url` is re
baseURL: 'https://some-domain.com/api/',
// `transformRequest` allows changes to the request data before it is sent to the server
// This is only applicable for request methods 'PUT', 'POST', and 'PATCH'
// This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE'
// The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
// FormData or Stream
transformRequest: [function (data) {
// You may modify the headers object.
transformRequest: [function (data, headers) {
// Do whatever you want to transform the data
return data;
......@@ -240,7 +273,7 @@ These are the available config options for making requests. Only the `url` is re
// `paramsSerializer` is an optional function in charge of serializing `params`
// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
paramsSerializer: function(params) {
paramsSerializer: function (params) {
return Qs.stringify(params, {arrayFormat: 'brackets'})
},
......@@ -256,7 +289,7 @@ These are the available config options for making requests. Only the `url` is re
// `timeout` specifies the number of milliseconds before the request times out.
// If the request takes longer than `timeout`, the request will be aborted.
timeout: 1000,
timeout: 1000, // default is `0` (no timeout)
// `withCredentials` indicates whether or not cross-site Access-Control requests
// should be made using credentials
......@@ -271,15 +304,22 @@ These are the available config options for making requests. Only the `url` is re
// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.
// This will set an `Authorization` header, overwriting any existing
// `Authorization` custom headers you have set using `headers`.
// Please note that only HTTP Basic auth is configurable through this parameter.
// For Bearer tokens and such, use `Authorization` custom headers instead.
auth: {
username: 'janedoe',
password: 's00pers3cret'
},
// `responseType` indicates the type of data that the server will respond with
// options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'
// options are: 'arraybuffer', 'document', 'json', 'text', 'stream'
// browser only: 'blob'
responseType: 'json', // default
// `responseEncoding` indicates encoding to use for decoding responses
// Note: Ignored for `responseType` of 'stream' or client-side requests
responseEncoding: 'utf8', // default
// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token
xsrfCookieName: 'XSRF-TOKEN', // default
......@@ -296,7 +336,7 @@ These are the available config options for making requests. Only the `url` is re
// Do whatever you want with the native progress event
},
// `maxContentLength` defines the max size of the http response content allowed
// `maxContentLength` defines the max size of the http response content in bytes allowed
maxContentLength: 2000,
// `validateStatus` defines whether to resolve or reject the promise for a given
......@@ -311,13 +351,24 @@ These are the available config options for making requests. Only the `url` is re
// If set to 0, no redirects will be followed.
maxRedirects: 5, // default
// `socketPath` defines a UNIX Socket to be used in node.js.
// e.g. '/var/run/docker.sock' to send requests to the docker daemon.
// Only either `socketPath` or `proxy` can be specified.
// If both are specified, `socketPath` is used.
socketPath: null, // default
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
// and https requests, respectively, in node.js. This allows options to be added like
// `keepAlive` that are not enabled by default.
httpAgent: new http.Agent({ keepAlive: true }),
httpsAgent: new https.Agent({ keepAlive: true }),
// 'proxy' defines the hostname and port of the proxy server
// 'proxy' defines the hostname and port of the proxy server.
// You can also define your proxy using the conventional `http_proxy` and
// `https_proxy` environment variables. If you are using environment variables
// for your proxy configuration, you can also define a `no_proxy` environment
// variable as a comma-separated list of domains that should not be proxied.
// Use `false` to disable proxies, ignoring environment variables.
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
// supplies credentials.
// This will set an `Proxy-Authorization` header, overwriting any existing
......@@ -371,7 +422,7 @@ When using `then`, you will receive the response as follows:
```js
axios.get('/user/12345')
.then(function(response) {
.then(function (response) {
console.log(response.data);
console.log(response.status);
console.log(response.statusText);
......@@ -398,7 +449,7 @@ axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded
```js
// Set config defaults when creating the instance
var instance = axios.create({
const instance = axios.create({
baseURL: 'https://api.example.com'
});
......@@ -408,15 +459,15 @@ instance.defaults.headers.common['Authorization'] = AUTH_TOKEN;
### Config order of precedence
Config will be merged with an order of precedence. The order is library defaults found in `lib/defaults.js`, then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example.
Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example.
```js
// Create an instance using the config defaults provided by the library
// At this point the timeout config value is `0` as is the default for the library
var instance = axios.create();
const instance = axios.create();
// Override timeout default for the library
// Now all requests will wait 2.5 seconds before timing out
// Now all requests using this instance will wait 2.5 seconds before timing out
instance.defaults.timeout = 2500;
// Override timeout for this request as it's known to take a long time
......@@ -452,14 +503,14 @@ axios.interceptors.response.use(function (response) {
If you may need to remove an interceptor later you can.
```js
var myInterceptor = axios.interceptors.request.use(function () {/*...*/});
const myInterceptor = axios.interceptors.request.use(function () {/*...*/});
axios.interceptors.request.eject(myInterceptor);
```
You can add interceptors to a custom instance of axios.
```js
var instance = axios.create();
const instance = axios.create();
instance.interceptors.request.use(function () {/*...*/});
```
......@@ -506,12 +557,12 @@ You can cancel a request using a *cancel token*.
You can create a cancel token using the `CancelToken.source` factory as shown below:
```js
var CancelToken = axios.CancelToken;
var source = CancelToken.source();
const CancelToken = axios.CancelToken;
const source = CancelToken.source();
axios.get('/user/12345', {
cancelToken: source.token
}).catch(function(thrown) {
}).catch(function (thrown) {
if (axios.isCancel(thrown)) {
console.log('Request canceled', thrown.message);
} else {
......@@ -519,6 +570,12 @@ axios.get('/user/12345', {
}
});
axios.post('/user/12345', {
name: 'new name'
}, {
cancelToken: source.token
})
// cancel the request (the message parameter is optional)
source.cancel('Operation canceled by the user.');
```
......@@ -526,8 +583,8 @@ source.cancel('Operation canceled by the user.');
You can also create a cancel token by passing an executor function to the `CancelToken` constructor:
```js
var CancelToken = axios.CancelToken;
var cancel;
const CancelToken = axios.CancelToken;
let cancel;
axios.get('/user/12345', {
cancelToken: new CancelToken(function executor(c) {
......@@ -551,31 +608,48 @@ By default, axios serializes JavaScript objects to `JSON`. To send data in the `
In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API as follows:
```js
var params = new URLSearchParams();
const params = new URLSearchParams();
params.append('param1', 'value1');
params.append('param2', 'value2');
axios.post('/foo', params);
```
> Note that `URLSearchParams` is not supported by all browsers, but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment).
> Note that `URLSearchParams` is not supported by all browsers (see [caniuse.com](http://www.caniuse.com/#feat=urlsearchparams)), but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment).
Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library:
```js
var qs = require('qs');
const qs = require('qs');
axios.post('/foo', qs.stringify({ 'bar': 123 }));
```
Or in another way (ES6),
```js
import qs from 'qs';
const data = { 'bar': 123 };
const options = {
method: 'POST',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
data: qs.stringify(data),
url,
};
axios(options);
```
### Node.js
In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows:
```js
var querystring = require('querystring');
const querystring = require('querystring');
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
```
You can also use the `qs` library.
You can also use the [`qs`](https://github.com/ljharb/qs) library.
###### NOTE
The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has known issues with that use case (https://github.com/nodejs/node-v0.x-archive/issues/1665).
## Semver
......@@ -595,11 +669,11 @@ axios.get('/user?ID=12345');
## Resources
* [Changelog](https://github.com/mzabriskie/axios/blob/master/CHANGELOG.md)
* [Upgrade Guide](https://github.com/mzabriskie/axios/blob/master/UPGRADE_GUIDE.md)
* [Ecosystem](https://github.com/mzabriskie/axios/blob/master/ECOSYSTEM.md)
* [Contributing Guide](https://github.com/mzabriskie/axios/blob/master/CONTRIBUTING.md)
* [Code of Conduct](https://github.com/mzabriskie/axios/blob/master/CODE_OF_CONDUCT.md)
* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md)
* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md)
* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md)
* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md)
## Credits
......
......@@ -115,8 +115,8 @@ function myAdapter(config) {
```
See the related commits for more details:
- [Response transformers](https://github.com/mzabriskie/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
- [Request adapter Promise](https://github.com/mzabriskie/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
- [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
- [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
### 0.5.x -> 0.6.0
......@@ -135,7 +135,7 @@ This will polyfill the global environment, and only needs to be done once.
#### `axios.success`/`axios.error`
The `success`, and `error` aliases were deprectated in [0.4.0](https://github.com/mzabriskie/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively.
The `success`, and `error` aliases were deprectated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively.
```js
axios.get('some/url')
......
/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */
/* axios v0.19.0 | (c) 2019 by Matt Zabriskie */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
......@@ -53,20 +53,21 @@ return /******/ (function(modules) { // webpackBootstrap
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(1);
/***/ },
/***/ }),
/* 1 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
var bind = __webpack_require__(3);
var Axios = __webpack_require__(5);
var defaults = __webpack_require__(6);
var mergeConfig = __webpack_require__(22);
var defaults = __webpack_require__(11);
/**
* Create an instance of Axios
......@@ -95,13 +96,13 @@ return /******/ (function(modules) { // webpackBootstrap
// Factory for creating new instances
axios.create = function create(instanceConfig) {
return createInstance(utils.merge(defaults, instanceConfig));
return createInstance(mergeConfig(axios.defaults, instanceConfig));
};
// Expose Cancel & CancelToken
axios.Cancel = __webpack_require__(23);
axios.CancelToken = __webpack_require__(24);
axios.isCancel = __webpack_require__(20);
axios.isCancel = __webpack_require__(10);
// Expose all/spread
axios.all = function all(promises) {
......@@ -115,9 +116,9 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports.default = axios;
/***/ },
/***/ }),
/* 2 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
'use strict';
......@@ -298,9 +299,13 @@ return /******/ (function(modules) { // webpackBootstrap
*
* react-native:
* navigator.product -> 'ReactNative'
* nativescript
* navigator.product -> 'NativeScript' or 'NS'
*/
function isStandardBrowserEnv() {
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
navigator.product === 'NativeScript' ||
navigator.product === 'NS')) {
return false;
}
return (
......@@ -328,7 +333,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
// Force an array if not already something iterable
if (typeof obj !== 'object' && !isArray(obj)) {
if (typeof obj !== 'object') {
/*eslint no-param-reassign:0*/
obj = [obj];
}
......@@ -382,6 +387,32 @@ return /******/ (function(modules) { // webpackBootstrap
}
/**
* Function equal to merge with the difference being that no reference
* to original objects is kept.
*
* @see merge
* @param {Object} obj1 Object to merge
* @returns {Object} Result of all merge properties
*/
function deepMerge(/* obj1, obj2, obj3, ... */) {
var result = {};
function assignValue(val, key) {
if (typeof result[key] === 'object' && typeof val === 'object') {
result[key] = deepMerge(result[key], val);
} else if (typeof val === 'object') {
result[key] = deepMerge({}, val);
} else {
result[key] = val;
}
}
for (var i = 0, l = arguments.length; i < l; i++) {
forEach(arguments[i], assignValue);
}
return result;
}
/**
* Extends object a by mutably adding to it the properties of object b.
*
* @param {Object} a The object to be extended
......@@ -419,14 +450,15 @@ return /******/ (function(modules) { // webpackBootstrap
isStandardBrowserEnv: isStandardBrowserEnv,
forEach: forEach,
merge: merge,
deepMerge: deepMerge,
extend: extend,
trim: trim
};
/***/ },
/***/ }),
/* 3 */
/***/ function(module, exports) {
/***/ (function(module, exports) {
'use strict';
......@@ -441,45 +473,34 @@ return /******/ (function(modules) { // webpackBootstrap
};
/***/ },
/***/ }),
/* 4 */
/***/ function(module, exports) {
/***/ (function(module, exports) {
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
// The _isBuffer check is for Safari 5-7 support, because it's missing
// Object.prototype.constructor. Remove this eventually
module.exports = function (obj) {
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
}
function isBuffer (obj) {
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
}
// For Node v0.10 support. Remove this eventually.
function isSlowBuffer (obj) {
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
module.exports = function isBuffer (obj) {
return obj != null && obj.constructor != null &&
typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
}
/***/ },
/***/ }),
/* 5 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var defaults = __webpack_require__(6);
var utils = __webpack_require__(2);
var InterceptorManager = __webpack_require__(17);
var dispatchRequest = __webpack_require__(18);
var isAbsoluteURL = __webpack_require__(21);
var combineURLs = __webpack_require__(22);
var buildURL = __webpack_require__(6);
var InterceptorManager = __webpack_require__(7);
var dispatchRequest = __webpack_require__(8);
var mergeConfig = __webpack_require__(22);
/**
* Create a new instance of Axios
......@@ -503,18 +524,14 @@ return /******/ (function(modules) { // webpackBootstrap
/*eslint no-param-reassign:0*/
// Allow for axios('example/url'[, config]) a la fetch API
if (typeof config === 'string') {
config = utils.merge({
url: arguments[0]
}, arguments[1]);
config = arguments[1] || {};
config.url = arguments[0];
} else {
config = config || {};
}
config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
config.method = config.method.toLowerCase();
// Support baseURL config
if (config.baseURL && !isAbsoluteURL(config.url)) {
config.url = combineURLs(config.baseURL, config.url);
}
config = mergeConfig(this.defaults, config);
config.method = config.method ? config.method.toLowerCase() : 'get';
// Hook up interceptors middleware
var chain = [dispatchRequest, undefined];
......@@ -535,6 +552,11 @@ return /******/ (function(modules) { // webpackBootstrap
return promise;
};
Axios.prototype.getUri = function getUri(config) {
config = mergeConfig(this.defaults, config);
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
};
// Provide aliases for supported request methods
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
/*eslint func-names:0*/
......@@ -560,180 +582,433 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = Axios;
/***/ },
/***/ }),
/* 6 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
var normalizeHeaderName = __webpack_require__(7);
var DEFAULT_CONTENT_TYPE = {
'Content-Type': 'application/x-www-form-urlencoded'
};
function setContentTypeIfUnset(headers, value) {
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
headers['Content-Type'] = value;
}
function encode(val) {
return encodeURIComponent(val).
replace(/%40/gi, '@').
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
replace(/%20/g, '+').
replace(/%5B/gi, '[').
replace(/%5D/gi, ']');
}
function getDefaultAdapter() {
var adapter;
if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = __webpack_require__(8);
} else if (typeof process !== 'undefined') {
// For node use HTTP adapter
adapter = __webpack_require__(8);
/**
* Build a URL by appending params to the end
*
* @param {string} url The base of the url (e.g., http://www.google.com)
* @param {object} [params] The params to be appended
* @returns {string} The formatted url
*/
module.exports = function buildURL(url, params, paramsSerializer) {
/*eslint no-param-reassign:0*/
if (!params) {
return url;
}
return adapter;
}
var defaults = {
adapter: getDefaultAdapter(),
var serializedParams;
if (paramsSerializer) {
serializedParams = paramsSerializer(params);
} else if (utils.isURLSearchParams(params)) {
serializedParams = params.toString();
} else {
var parts = [];
transformRequest: [function transformRequest(data, headers) {
normalizeHeaderName(headers, 'Content-Type');
if (utils.isFormData(data) ||
utils.isArrayBuffer(data) ||
utils.isBuffer(data) ||
utils.isStream(data) ||
utils.isFile(data) ||
utils.isBlob(data)
) {
return data;
}
if (utils.isArrayBufferView(data)) {
return data.buffer;
}
if (utils.isURLSearchParams(data)) {
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
return data.toString();
}
if (utils.isObject(data)) {
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
return JSON.stringify(data);
}
return data;
}],
utils.forEach(params, function serialize(val, key) {
if (val === null || typeof val === 'undefined') {
return;
}
transformResponse: [function transformResponse(data) {
/*eslint no-param-reassign:0*/
if (typeof data === 'string') {
try {
data = JSON.parse(data);
} catch (e) { /* Ignore */ }
}
return data;
}],
if (utils.isArray(val)) {
key = key + '[]';
} else {
val = [val];
}
timeout: 0,
utils.forEach(val, function parseValue(v) {
if (utils.isDate(v)) {
v = v.toISOString();
} else if (utils.isObject(v)) {
v = JSON.stringify(v);
}
parts.push(encode(key) + '=' + encode(v));
});
});
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
serializedParams = parts.join('&');
}
maxContentLength: -1,
if (serializedParams) {
var hashmarkIndex = url.indexOf('#');
if (hashmarkIndex !== -1) {
url = url.slice(0, hashmarkIndex);
}
validateStatus: function validateStatus(status) {
return status >= 200 && status < 300;
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
}
};
defaults.headers = {
common: {
'Accept': 'application/json, text/plain, */*'
}
return url;
};
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
defaults.headers[method] = {};
});
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
});
module.exports = defaults;
/***/ },
/***/ }),
/* 7 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
module.exports = function normalizeHeaderName(headers, normalizedName) {
utils.forEach(headers, function processHeader(value, name) {
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
headers[normalizedName] = value;
delete headers[name];
function InterceptorManager() {
this.handlers = [];
}
/**
* Add a new interceptor to the stack
*
* @param {Function} fulfilled The function to handle `then` for a `Promise`
* @param {Function} rejected The function to handle `reject` for a `Promise`
*
* @return {Number} An ID used to remove interceptor later
*/
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
this.handlers.push({
fulfilled: fulfilled,
rejected: rejected
});
return this.handlers.length - 1;
};
/**
* Remove an interceptor from the stack
*
* @param {Number} id The ID that was returned by `use`
*/
InterceptorManager.prototype.eject = function eject(id) {
if (this.handlers[id]) {
this.handlers[id] = null;
}
};
/**
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become `null` calling `eject`.
*
* @param {Function} fn The function to call for each interceptor
*/
InterceptorManager.prototype.forEach = function forEach(fn) {
utils.forEach(this.handlers, function forEachHandler(h) {
if (h !== null) {
fn(h);
}
});
};
module.exports = InterceptorManager;
/***/ },
/***/ }),
/* 8 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
var settle = __webpack_require__(9);
var buildURL = __webpack_require__(12);
var parseHeaders = __webpack_require__(13);
var isURLSameOrigin = __webpack_require__(14);
var createError = __webpack_require__(10);
var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15);
var transformData = __webpack_require__(9);
var isCancel = __webpack_require__(10);
var defaults = __webpack_require__(11);
var isAbsoluteURL = __webpack_require__(20);
var combineURLs = __webpack_require__(21);
module.exports = function xhrAdapter(config) {
return new Promise(function dispatchXhrRequest(resolve, reject) {
var requestData = config.data;
var requestHeaders = config.headers;
/**
* Throws a `Cancel` if cancellation has been requested.
*/
function throwIfCancellationRequested(config) {
if (config.cancelToken) {
config.cancelToken.throwIfRequested();
}
}
if (utils.isFormData(requestData)) {
delete requestHeaders['Content-Type']; // Let the browser set it
}
/**
* Dispatch a request to the server using the configured adapter.
*
* @param {object} config The config that is to be used for the request
* @returns {Promise} The Promise to be fulfilled
*/
module.exports = function dispatchRequest(config) {
throwIfCancellationRequested(config);
var request = new XMLHttpRequest();
var loadEvent = 'onreadystatechange';
var xDomain = false;
// For IE 8/9 CORS support
// Only supports POST and GET calls and doesn't returns the response headers.
// DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
if (("production") !== 'test' &&
typeof window !== 'undefined' &&
window.XDomainRequest && !('withCredentials' in request) &&
!isURLSameOrigin(config.url)) {
request = new window.XDomainRequest();
loadEvent = 'onload';
xDomain = true;
request.onprogress = function handleProgress() {};
request.ontimeout = function handleTimeout() {};
}
// Support baseURL config
if (config.baseURL && !isAbsoluteURL(config.url)) {
config.url = combineURLs(config.baseURL, config.url);
}
// HTTP basic authentication
if (config.auth) {
var username = config.auth.username || '';
var password = config.auth.password || '';
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
}
// Ensure headers exist
config.headers = config.headers || {};
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
// Transform request data
config.data = transformData(
config.data,
config.headers,
config.transformRequest
);
// Set the request timeout in MS
request.timeout = config.timeout;
// Flatten headers
config.headers = utils.merge(
config.headers.common || {},
config.headers[config.method] || {},
config.headers || {}
);
// Listen for ready state
request[loadEvent] = function handleLoad() {
if (!request || (request.readyState !== 4 && !xDomain)) {
return;
}
utils.forEach(
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
function cleanHeaderConfig(method) {
delete config.headers[method];
}
);
var adapter = config.adapter || defaults.adapter;
return adapter(config).then(function onAdapterResolution(response) {
throwIfCancellationRequested(config);
// Transform response data
response.data = transformData(
response.data,
response.headers,
config.transformResponse
);
return response;
}, function onAdapterRejection(reason) {
if (!isCancel(reason)) {
throwIfCancellationRequested(config);
// Transform response data
if (reason && reason.response) {
reason.response.data = transformData(
reason.response.data,
reason.response.headers,
config.transformResponse
);
}
}
return Promise.reject(reason);
});
};
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
/**
* Transform the data for a request or a response
*
* @param {Object|String} data The data to be transformed
* @param {Array} headers The headers for the request or response
* @param {Array|Function} fns A single function or Array of functions
* @returns {*} The resulting transformed data
*/
module.exports = function transformData(data, headers, fns) {
/*eslint no-param-reassign:0*/
utils.forEach(fns, function transform(fn) {
data = fn(data, headers);
});
return data;
};
/***/ }),
/* 10 */
/***/ (function(module, exports) {
'use strict';
module.exports = function isCancel(value) {
return !!(value && value.__CANCEL__);
};
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
var normalizeHeaderName = __webpack_require__(12);
var DEFAULT_CONTENT_TYPE = {
'Content-Type': 'application/x-www-form-urlencoded'
};
function setContentTypeIfUnset(headers, value) {
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
headers['Content-Type'] = value;
}
}
function getDefaultAdapter() {
var adapter;
// Only Node.JS has a process variable that is of [[Class]] process
if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
// For node use HTTP adapter
adapter = __webpack_require__(13);
} else if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = __webpack_require__(13);
}
return adapter;
}
var defaults = {
adapter: getDefaultAdapter(),
transformRequest: [function transformRequest(data, headers) {
normalizeHeaderName(headers, 'Accept');
normalizeHeaderName(headers, 'Content-Type');
if (utils.isFormData(data) ||
utils.isArrayBuffer(data) ||
utils.isBuffer(data) ||
utils.isStream(data) ||
utils.isFile(data) ||
utils.isBlob(data)
) {
return data;
}
if (utils.isArrayBufferView(data)) {
return data.buffer;
}
if (utils.isURLSearchParams(data)) {
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
return data.toString();
}
if (utils.isObject(data)) {
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
return JSON.stringify(data);
}
return data;
}],
transformResponse: [function transformResponse(data) {
/*eslint no-param-reassign:0*/
if (typeof data === 'string') {
try {
data = JSON.parse(data);
} catch (e) { /* Ignore */ }
}
return data;
}],
/**
* A timeout in milliseconds to abort a request. If set to 0 (default) a
* timeout is not created.
*/
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: function validateStatus(status) {
return status >= 200 && status < 300;
}
};
defaults.headers = {
common: {
'Accept': 'application/json, text/plain, */*'
}
};
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
defaults.headers[method] = {};
});
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
});
module.exports = defaults;
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
module.exports = function normalizeHeaderName(headers, normalizedName) {
utils.forEach(headers, function processHeader(value, name) {
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
headers[normalizedName] = value;
delete headers[name];
}
});
};
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
var settle = __webpack_require__(14);
var buildURL = __webpack_require__(6);
var parseHeaders = __webpack_require__(17);
var isURLSameOrigin = __webpack_require__(18);
var createError = __webpack_require__(15);
module.exports = function xhrAdapter(config) {
return new Promise(function dispatchXhrRequest(resolve, reject) {
var requestData = config.data;
var requestHeaders = config.headers;
if (utils.isFormData(requestData)) {
delete requestHeaders['Content-Type']; // Let the browser set it
}
var request = new XMLHttpRequest();
// HTTP basic authentication
if (config.auth) {
var username = config.auth.username || '';
var password = config.auth.password || '';
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
}
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
// Set the request timeout in MS
request.timeout = config.timeout;
// Listen for ready state
request.onreadystatechange = function handleLoad() {
if (!request || request.readyState !== 4) {
return;
}
// The request errored out and we didn't get a response, this will be
// handled by onerror instead
......@@ -748,9 +1023,8 @@ return /******/ (function(modules) { // webpackBootstrap
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
var response = {
data: responseData,
// IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)
status: request.status === 1223 ? 204 : request.status,
statusText: request.status === 1223 ? 'No Content' : request.statusText,
status: request.status,
statusText: request.statusText,
headers: responseHeaders,
config: config,
request: request
......@@ -762,6 +1036,18 @@ return /******/ (function(modules) { // webpackBootstrap
request = null;
};
// Handle browser request cancellation (as opposed to a manual cancellation)
request.onabort = function handleAbort() {
if (!request) {
return;
}
reject(createError('Request aborted', config, 'ECONNABORTED', request));
// Clean up request
request = null;
};
// Handle low level network errors
request.onerror = function handleError() {
// Real errors are hidden from us by the browser
......@@ -785,12 +1071,12 @@ return /******/ (function(modules) { // webpackBootstrap
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.
if (utils.isStandardBrowserEnv()) {
var cookies = __webpack_require__(16);
var cookies = __webpack_require__(19);
// Add xsrf header
var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
cookies.read(config.xsrfCookieName) :
undefined;
cookies.read(config.xsrfCookieName) :
undefined;
if (xsrfValue) {
requestHeaders[config.xsrfHeaderName] = xsrfValue;
......@@ -862,13 +1148,13 @@ return /******/ (function(modules) { // webpackBootstrap
};
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var createError = __webpack_require__(10);
var createError = __webpack_require__(15);
/**
* Resolve or reject a Promise based on response status.
......@@ -879,8 +1165,7 @@ return /******/ (function(modules) { // webpackBootstrap
*/
module.exports = function settle(resolve, reject, response) {
var validateStatus = response.config.validateStatus;
// Note: status is not exposed by XDomainRequest
if (!response.status || !validateStatus || validateStatus(response.status)) {
if (!validateStatus || validateStatus(response.status)) {
resolve(response);
} else {
reject(createError(
......@@ -894,13 +1179,13 @@ return /******/ (function(modules) { // webpackBootstrap
};
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var enhanceError = __webpack_require__(11);
var enhanceError = __webpack_require__(16);
/**
* Create an Error with the specified message, config, error code, request and response.
......@@ -918,9 +1203,9 @@ return /******/ (function(modules) { // webpackBootstrap
};
/***/ },
/* 11 */
/***/ function(module, exports) {
/***/ }),
/* 16 */
/***/ (function(module, exports) {
'use strict';
......@@ -939,106 +1224,62 @@ return /******/ (function(modules) { // webpackBootstrap
if (code) {
error.code = code;
}
error.request = request;
error.response = response;
error.isAxiosError = true;
error.toJSON = function() {
return {
// Standard
message: this.message,
name: this.name,
// Microsoft
description: this.description,
number: this.number,
// Mozilla
fileName: this.fileName,
lineNumber: this.lineNumber,
columnNumber: this.columnNumber,
stack: this.stack,
// Axios
config: this.config,
code: this.code
};
};
return error;
};
/***/ },
/* 12 */
/***/ function(module, exports, __webpack_require__) {
/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
function encode(val) {
return encodeURIComponent(val).
replace(/%40/gi, '@').
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
replace(/%20/g, '+').
replace(/%5B/gi, '[').
replace(/%5D/gi, ']');
}
// Headers whose duplicates are ignored by node
// c.f. https://nodejs.org/api/http.html#http_message_headers
var ignoreDuplicateOf = [
'age', 'authorization', 'content-length', 'content-type', 'etag',
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
'referer', 'retry-after', 'user-agent'
];
/**
* Build a URL by appending params to the end
* Parse headers into an object
*
* @param {string} url The base of the url (e.g., http://www.google.com)
* @param {object} [params] The params to be appended
* @returns {string} The formatted url
*/
module.exports = function buildURL(url, params, paramsSerializer) {
/*eslint no-param-reassign:0*/
if (!params) {
return url;
}
var serializedParams;
if (paramsSerializer) {
serializedParams = paramsSerializer(params);
} else if (utils.isURLSearchParams(params)) {
serializedParams = params.toString();
} else {
var parts = [];
utils.forEach(params, function serialize(val, key) {
if (val === null || typeof val === 'undefined') {
return;
}
if (utils.isArray(val)) {
key = key + '[]';
}
if (!utils.isArray(val)) {
val = [val];
}
utils.forEach(val, function parseValue(v) {
if (utils.isDate(v)) {
v = v.toISOString();
} else if (utils.isObject(v)) {
v = JSON.stringify(v);
}
parts.push(encode(key) + '=' + encode(v));
});
});
serializedParams = parts.join('&');
}
if (serializedParams) {
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
}
return url;
};
/***/ },
/* 13 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
/**
* Parse headers into an object
*
* ```
* Date: Wed, 27 Aug 2014 08:58:49 GMT
* Content-Type: application/json
* Connection: keep-alive
* Transfer-Encoding: chunked
* ```
*
* @param {String} headers Headers needing to be parsed
* @returns {Object} Headers parsed into an object
* ```
* Date: Wed, 27 Aug 2014 08:58:49 GMT
* Content-Type: application/json
* Connection: keep-alive
* Transfer-Encoding: chunked
* ```
*
* @param {String} headers Headers needing to be parsed
* @returns {Object} Headers parsed into an object
*/
module.exports = function parseHeaders(headers) {
var parsed = {};
......@@ -1054,7 +1295,14 @@ return /******/ (function(modules) { // webpackBootstrap
val = utils.trim(line.substr(i + 1));
if (key) {
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
return;
}
if (key === 'set-cookie') {
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
} else {
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
}
}
});
......@@ -1062,9 +1310,9 @@ return /******/ (function(modules) { // webpackBootstrap
};
/***/ },
/* 14 */
/***/ function(module, exports, __webpack_require__) {
/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
......@@ -1075,112 +1323,70 @@ return /******/ (function(modules) { // webpackBootstrap
// Standard browser envs have full support of the APIs needed to test
// whether the request URL is of the same origin as current location.
(function standardBrowserEnv() {
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originURL;
(function standardBrowserEnv() {
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originURL;
/**
/**
* Parse a URL to discover it's components
*
* @param {String} url The URL to be parsed
* @returns {Object}
*/
function resolveURL(url) {
var href = url;
function resolveURL(url) {
var href = url;
if (msie) {
if (msie) {
// IE needs attribute set twice to normalize properties
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
urlParsingNode.setAttribute('href', href);
urlParsingNode.setAttribute('href', href);
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname :
'/' + urlParsingNode.pathname
};
}
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname :
'/' + urlParsingNode.pathname
};
}
originURL = resolveURL(window.location.href);
originURL = resolveURL(window.location.href);
/**
/**
* Determine if a URL shares the same origin as the current location
*
* @param {String} requestURL The URL to test
* @returns {boolean} True if URL shares the same origin, otherwise false
*/
return function isURLSameOrigin(requestURL) {
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
return (parsed.protocol === originURL.protocol &&
return function isURLSameOrigin(requestURL) {
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
return (parsed.protocol === originURL.protocol &&
parsed.host === originURL.host);
};
})() :
};
})() :
// Non standard browser envs (web workers, react-native) lack needed support.
(function nonStandardBrowserEnv() {
return function isURLSameOrigin() {
return true;
};
})()
(function nonStandardBrowserEnv() {
return function isURLSameOrigin() {
return true;
};
})()
);
/***/ },
/* 15 */
/***/ function(module, exports) {
'use strict';
// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
function E() {
this.message = 'String contains an invalid character';
}
E.prototype = new Error;
E.prototype.code = 5;
E.prototype.name = 'InvalidCharacterError';
function btoa(input) {
var str = String(input);
var output = '';
for (
// initialize result and counter
var block, charCode, idx = 0, map = chars;
// if the next str index does not exist:
// change the mapping table to "="
// check if d has no fractional digits
str.charAt(idx | 0) || (map = '=', idx % 1);
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
) {
charCode = str.charCodeAt(idx += 3 / 4);
if (charCode > 0xFF) {
throw new E();
}
block = block << 8 | charCode;
}
return output;
}
module.exports = btoa;
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
......@@ -1190,236 +1396,56 @@ return /******/ (function(modules) { // webpackBootstrap
utils.isStandardBrowserEnv() ?
// Standard browser envs support document.cookie
(function standardBrowserEnv() {
return {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
(function standardBrowserEnv() {
return {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
if (secure === true) {
cookie.push('secure');
}
if (secure === true) {
cookie.push('secure');
}
document.cookie = cookie.join('; ');
},
document.cookie = cookie.join('; ');
},
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
}
};
})() :
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
}
};
})() :
// Non standard browser env (web workers, react-native) lack needed support.
(function nonStandardBrowserEnv() {
return {
write: function write() {},
read: function read() { return null; },
remove: function remove() {}
};
})()
(function nonStandardBrowserEnv() {
return {
write: function write() {},
read: function read() { return null; },
remove: function remove() {}
};
})()
);
/***/ },
/* 17 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
function InterceptorManager() {
this.handlers = [];
}
/**
* Add a new interceptor to the stack
*
* @param {Function} fulfilled The function to handle `then` for a `Promise`
* @param {Function} rejected The function to handle `reject` for a `Promise`
*
* @return {Number} An ID used to remove interceptor later
*/
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
this.handlers.push({
fulfilled: fulfilled,
rejected: rejected
});
return this.handlers.length - 1;
};
/**
* Remove an interceptor from the stack
*
* @param {Number} id The ID that was returned by `use`
*/
InterceptorManager.prototype.eject = function eject(id) {
if (this.handlers[id]) {
this.handlers[id] = null;
}
};
/**
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become `null` calling `eject`.
*
* @param {Function} fn The function to call for each interceptor
*/
InterceptorManager.prototype.forEach = function forEach(fn) {
utils.forEach(this.handlers, function forEachHandler(h) {
if (h !== null) {
fn(h);
}
});
};
module.exports = InterceptorManager;
/***/ },
/* 18 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
var transformData = __webpack_require__(19);
var isCancel = __webpack_require__(20);
var defaults = __webpack_require__(6);
/**
* Throws a `Cancel` if cancellation has been requested.
*/
function throwIfCancellationRequested(config) {
if (config.cancelToken) {
config.cancelToken.throwIfRequested();
}
}
/**
* Dispatch a request to the server using the configured adapter.
*
* @param {object} config The config that is to be used for the request
* @returns {Promise} The Promise to be fulfilled
*/
module.exports = function dispatchRequest(config) {
throwIfCancellationRequested(config);
// Ensure headers exist
config.headers = config.headers || {};
// Transform request data
config.data = transformData(
config.data,
config.headers,
config.transformRequest
);
// Flatten headers
config.headers = utils.merge(
config.headers.common || {},
config.headers[config.method] || {},
config.headers || {}
);
utils.forEach(
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
function cleanHeaderConfig(method) {
delete config.headers[method];
}
);
var adapter = config.adapter || defaults.adapter;
return adapter(config).then(function onAdapterResolution(response) {
throwIfCancellationRequested(config);
// Transform response data
response.data = transformData(
response.data,
response.headers,
config.transformResponse
);
return response;
}, function onAdapterRejection(reason) {
if (!isCancel(reason)) {
throwIfCancellationRequested(config);
// Transform response data
if (reason && reason.response) {
reason.response.data = transformData(
reason.response.data,
reason.response.headers,
config.transformResponse
);
}
}
return Promise.reject(reason);
});
};
/***/ },
/* 19 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
/**
* Transform the data for a request or a response
*
* @param {Object|String} data The data to be transformed
* @param {Array} headers The headers for the request or response
* @param {Array|Function} fns A single function or Array of functions
* @returns {*} The resulting transformed data
*/
module.exports = function transformData(data, headers, fns) {
/*eslint no-param-reassign:0*/
utils.forEach(fns, function transform(fn) {
data = fn(data, headers);
});
return data;
};
/***/ },
/***/ }),
/* 20 */
/***/ function(module, exports) {
'use strict';
module.exports = function isCancel(value) {
return !!(value && value.__CANCEL__);
};
/***/ },
/* 21 */
/***/ function(module, exports) {
/***/ (function(module, exports) {
'use strict';
......@@ -1437,9 +1463,9 @@ return /******/ (function(modules) { // webpackBootstrap
};
/***/ },
/* 22 */
/***/ function(module, exports) {
/***/ }),
/* 21 */
/***/ (function(module, exports) {
'use strict';
......@@ -1457,9 +1483,66 @@ return /******/ (function(modules) { // webpackBootstrap
};
/***/ },
/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(2);
/**
* Config-specific merge-function which creates a new config-object
* by merging two configuration objects together.
*
* @param {Object} config1
* @param {Object} config2
* @returns {Object} New object resulting from merging config2 to config1
*/
module.exports = function mergeConfig(config1, config2) {
// eslint-disable-next-line no-param-reassign
config2 = config2 || {};
var config = {};
utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
}
});
utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
if (utils.isObject(config2[prop])) {
config[prop] = utils.deepMerge(config1[prop], config2[prop]);
} else if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (utils.isObject(config1[prop])) {
config[prop] = utils.deepMerge(config1[prop]);
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
utils.forEach([
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
'socketPath'
], function defaultToConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
return config;
};
/***/ }),
/* 23 */
/***/ function(module, exports) {
/***/ (function(module, exports) {
'use strict';
......@@ -1482,9 +1565,9 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = Cancel;
/***/ },
/***/ }),
/* 24 */
/***/ function(module, exports, __webpack_require__) {
/***/ (function(module, exports, __webpack_require__) {
'use strict';
......@@ -1545,9 +1628,9 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = CancelToken;
/***/ },
/***/ }),
/* 25 */
/***/ function(module, exports) {
/***/ (function(module, exports) {
'use strict';
......@@ -1578,7 +1661,7 @@ return /******/ (function(modules) { // webpackBootstrap
};
/***/ }
/***/ })
/******/ ])
});
;
......
This diff could not be displayed because it is too large.
/* axios v0.16.2 | (c) 2017 by Matt Zabriskie */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new s(e),n=i(s.prototype.request,t);return o.extend(n,s.prototype,t),o.extend(n,t),n}var o=n(2),i=n(3),s=n(5),u=n(6),a=r(u);a.Axios=s,a.create=function(e){return r(o.merge(u,e))},a.Cancel=n(23),a.CancelToken=n(24),a.isCancel=n(20),a.all=function(e){return Promise.all(e)},a.spread=n(25),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";function r(e){return"[object Array]"===R.call(e)}function o(e){return"[object ArrayBuffer]"===R.call(e)}function i(e){return"undefined"!=typeof FormData&&e instanceof FormData}function s(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function u(e){return"string"==typeof e}function a(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===R.call(e)}function d(e){return"[object File]"===R.call(e)}function l(e){return"[object Blob]"===R.call(e)}function h(e){return"[object Function]"===R.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function w(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function v(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function g(e,t){if(null!==e&&"undefined"!=typeof e)if("object"==typeof e||r(e)||(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}function x(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=x(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;n<r;n++)g(arguments[n],e);return t}function b(e,t,n){return g(t,function(t,r){n&&"function"==typeof t?e[r]=E(t,n):e[r]=t}),e}var E=n(3),C=n(4),R=Object.prototype.toString;e.exports={isArray:r,isArrayBuffer:o,isBuffer:C,isFormData:i,isArrayBufferView:s,isString:u,isNumber:a,isObject:f,isUndefined:c,isDate:p,isFile:d,isBlob:l,isFunction:h,isStream:m,isURLSearchParams:y,isStandardBrowserEnv:v,forEach:g,merge:x,extend:b,trim:w}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function r(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}/*!
/* axios v0.19.0 | (c) 2019 by Matt Zabriskie */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new i(e),n=s(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var o=n(2),s=n(3),i=n(5),a=n(22),u=n(11),c=r(u);c.Axios=i,c.create=function(e){return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(10),c.all=function(e){return Promise.all(e)},c.spread=n(25),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";function r(e){return"[object Array]"===j.call(e)}function o(e){return"[object ArrayBuffer]"===j.call(e)}function s(e){return"undefined"!=typeof FormData&&e instanceof FormData}function i(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function a(e){return"string"==typeof e}function u(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===j.call(e)}function d(e){return"[object File]"===j.call(e)}function l(e){return"[object Blob]"===j.call(e)}function h(e){return"[object Function]"===j.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function g(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function x(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.call(null,e[s],s,e)}function w(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=w(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;n<r;n++)v(arguments[n],e);return t}function b(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=b(t[n],e):"object"==typeof e?t[n]=b({},e):t[n]=e}for(var t={},n=0,r=arguments.length;n<r;n++)v(arguments[n],e);return t}function E(e,t,n){return v(t,function(t,r){n&&"function"==typeof t?e[r]=S(t,n):e[r]=t}),e}var S=n(3),R=n(4),j=Object.prototype.toString;e.exports={isArray:r,isArrayBuffer:o,isBuffer:R,isFormData:s,isArrayBufferView:i,isString:a,isNumber:u,isObject:f,isUndefined:c,isDate:p,isFile:d,isBlob:l,isFunction:h,isStream:m,isURLSearchParams:y,isStandardBrowserEnv:x,forEach:v,merge:w,deepMerge:b,extend:E,trim:g}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t){/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
e.exports=function(e){return null!=e&&(n(e)||r(e)||!!e._isBuffer)}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new s,response:new s}}var o=n(6),i=n(2),s=n(17),u=n(18),a=n(21),c=n(22);r.prototype.request=function(e){"string"==typeof e&&(e=i.merge({url:arguments[0]},arguments[1])),e=i.merge(o,this.defaults,{method:"get"},e),e.method=e.method.toLowerCase(),e.baseURL&&!a(e.url)&&(e.url=c(e.baseURL,e.url));var t=[u,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},i.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(i.merge(n||{},{method:e,url:t}))}}),i.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(i.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e,t){!i.isUndefined(e)&&i.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof XMLHttpRequest?e=n(8):"undefined"!=typeof process&&(e=n(8)),e}var i=n(2),s=n(7),u={"Content-Type":"application/x-www-form-urlencoded"},a={adapter:o(),transformRequest:[function(e,t){return s(t,"Content-Type"),i.isFormData(e)||i.isArrayBuffer(e)||i.isBuffer(e)||i.isStream(e)||i.isFile(e)||i.isBlob(e)?e:i.isArrayBufferView(e)?e.buffer:i.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):i.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};a.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(e){a.headers[e]={}}),i.forEach(["post","put","patch"],function(e){a.headers[e]=i.merge(u)}),e.exports=a},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(9),i=n(12),s=n(13),u=n(14),a=n(10),c="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(15);e.exports=function(e){return new Promise(function(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest,h="onreadystatechange",m=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in l||u(e.url)||(l=new window.XDomainRequest,h="onload",m=!0,l.onprogress=function(){},l.ontimeout=function(){}),e.auth){var y=e.auth.username||"",w=e.auth.password||"";d.Authorization="Basic "+c(y+":"+w)}if(l.open(e.method.toUpperCase(),i(e.url,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l[h]=function(){if(l&&(4===l.readyState||m)&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in l?s(l.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?l.response:l.responseText,i={data:r,status:1223===l.status?204:l.status,statusText:1223===l.status?"No Content":l.statusText,headers:n,config:e,request:l};o(t,f,i),l=null}},l.onerror=function(){f(a("Network Error",e,null,l)),l=null},l.ontimeout=function(){f(a("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",l)),l=null},r.isStandardBrowserEnv()){var v=n(16),g=(e.withCredentials||u(e.url))&&e.xsrfCookieName?v.read(e.xsrfCookieName):void 0;g&&(d[e.xsrfHeaderName]=g)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),e.withCredentials&&(l.withCredentials=!0),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),f(e),l=null)}),void 0===p&&(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(10);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(11);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e}},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(o.isURLSearchParams(t))i=t.toString();else{var s=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)&&(t+="[]"),o.isArray(e)||(e=[e]),o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),s.push(r(t)+"="+r(e))}))}),i=s.join("&")}return i&&(e+=(e.indexOf("?")===-1?"?":"&")+i),e}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e){var t,n,o,i={};return e?(r.forEach(e.split("\n"),function(e){o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t&&(i[t]=i[t]?i[t]+", "+n:n)}),i):i}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t){"use strict";function n(){this.message="String contains an invalid character"}function r(e){for(var t,r,i=String(e),s="",u=0,a=o;i.charAt(0|u)||(a="=",u%1);s+=a.charAt(63&t>>8-u%1*8)){if(r=i.charCodeAt(u+=.75),r>255)throw new n;t=t<<8|r}return s}var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.prototype=new Error,n.prototype.code=5,n.prototype.name="InvalidCharacterError",e.exports=r},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,i,s){var u=[];u.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&u.push("expires="+new Date(n).toGMTString()),r.isString(o)&&u.push("path="+o),r.isString(i)&&u.push("domain="+i),s===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),i=n(19),s=n(20),u=n(6);e.exports=function(e){r(e),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||u.adapter;return t(e).then(function(t){return r(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return s(t)||(r(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new i,response:new i}}var o=n(2),s=n(6),i=n(7),a=n(8),u=n(22);r.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=u(this.defaults,e),e.method=e.method?e.method.toLowerCase():"get";var t=[a,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},r.prototype.getUri=function(e){return e=u(this.defaults,e),s(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},o.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))}}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var s;if(n)s=n(t);else if(o.isURLSearchParams(t))s=t.toString();else{var i=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),i.push(r(t)+"="+r(e))}))}),s=i.join("&")}if(s){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),s=n(9),i=n(10),a=n(11),u=n(20),c=n(21);e.exports=function(e){r(e),e.baseURL&&!u(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=s(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||a.adapter;return t(e).then(function(t){return r(e),t.data=s(t.data,t.headers,e.transformResponse),t},function(t){return i(t)||(r(e),t&&t.response&&(t.response.data=s(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function r(e,t){!s.isUndefined(e)&&s.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?e=n(13):"undefined"!=typeof XMLHttpRequest&&(e=n(13)),e}var s=n(2),i=n(12),a={"Content-Type":"application/x-www-form-urlencoded"},u={adapter:o(),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),s.isFormData(e)||s.isArrayBuffer(e)||s.isBuffer(e)||s.isStream(e)||s.isFile(e)||s.isBlob(e)?e:s.isArrayBufferView(e)?e.buffer:s.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):s.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},s.forEach(["delete","get","head"],function(e){u.headers[e]={}}),s.forEach(["post","put","patch"],function(e){u.headers[e]=s.merge(a)}),e.exports=u},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(14),s=n(6),i=n(17),a=n(18),u=n(15);e.exports=function(e){return new Promise(function(t,c){var f=e.data,p=e.headers;r.isFormData(f)&&delete p["Content-Type"];var d=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",h=e.auth.password||"";p.Authorization="Basic "+btoa(l+":"+h)}if(d.open(e.method.toUpperCase(),s(e.url,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,d.onreadystatechange=function(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in d?i(d.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?d.response:d.responseText,s={data:r,status:d.status,statusText:d.statusText,headers:n,config:e,request:d};o(t,c,s),d=null}},d.onabort=function(){d&&(c(u("Request aborted",e,"ECONNABORTED",d)),d=null)},d.onerror=function(){c(u("Network Error",e,null,d)),d=null},d.ontimeout=function(){c(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",d)),d=null},r.isStandardBrowserEnv()){var m=n(19),y=(e.withCredentials||a(e.url))&&e.xsrfCookieName?m.read(e.xsrfCookieName):void 0;y&&(p[e.xsrfHeaderName]=y)}if("setRequestHeader"in d&&r.forEach(p,function(e,t){"undefined"==typeof f&&"content-type"===t.toLowerCase()?delete p[t]:d.setRequestHeader(t,e)}),e.withCredentials&&(d.withCredentials=!0),e.responseType)try{d.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){d&&(d.abort(),c(e),d=null)}),void 0===f&&(f=null),d.send(f)})}},function(e,t,n){"use strict";var r=n(15);e.exports=function(e,t,n){var o=n.config.validateStatus;!o||o(n.status)?e(n):t(r("Request failed with status code "+n.status,n.config,null,n.request,n))}},function(e,t,n){"use strict";var r=n(16);e.exports=function(e,t,n,o,s){var i=new Error(e);return r(i,t,n,o,s)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,s,i={};return e?(r.forEach(e.split("\n"),function(e){if(s=e.indexOf(":"),t=r.trim(e.substr(0,s)).toLowerCase(),n=r.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?i[t]=(i[t]?i[t]:[]).concat([n]):i[t]=i[t]?i[t]+", "+n:n}}),i):i}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){t=t||{};var n={};return r.forEach(["url","method","params","data"],function(e){"undefined"!=typeof t[e]&&(n[e]=t[e])}),r.forEach(["headers","auth","proxy"],function(o){r.isObject(t[o])?n[o]=r.deepMerge(e[o],t[o]):"undefined"!=typeof t[o]?n[o]=t[o]:r.isObject(e[o])?n[o]=r.deepMerge(e[o]):"undefined"!=typeof e[o]&&(n[o]=e[o])}),r.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],function(r){"undefined"!=typeof t[r]?n[r]=t[r]:"undefined"!=typeof e[r]&&(n[r]=e[r])}),n}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
//# sourceMappingURL=axios.min.map
\ No newline at end of file
......
This diff could not be displayed because it is too large.
export interface AxiosTransformer {
(data: any): any;
(data: any, headers?: any): any;
}
export interface AxiosAdapter {
(config: AxiosRequestConfig): AxiosPromise;
(config: AxiosRequestConfig): AxiosPromise<any>;
}
export interface AxiosBasicCredentials {
......@@ -14,11 +14,33 @@ export interface AxiosBasicCredentials {
export interface AxiosProxyConfig {
host: string;
port: number;
}
auth?: {
username: string;
password:string;
};
protocol?: string;
}
export type Method =
| 'get' | 'GET'
| 'delete' | 'DELETE'
| 'head' | 'HEAD'
| 'options' | 'OPTIONS'
| 'post' | 'POST'
| 'put' | 'PUT'
| 'patch' | 'PATCH'
export type ResponseType =
| 'arraybuffer'
| 'blob'
| 'document'
| 'json'
| 'text'
| 'stream'
export interface AxiosRequestConfig {
url?: string;
method?: string;
method?: Method;
baseURL?: string;
transformRequest?: AxiosTransformer | AxiosTransformer[];
transformResponse?: AxiosTransformer | AxiosTransformer[];
......@@ -30,7 +52,7 @@ export interface AxiosRequestConfig {
withCredentials?: boolean;
adapter?: AxiosAdapter;
auth?: AxiosBasicCredentials;
responseType?: string;
responseType?: ResponseType;
xsrfCookieName?: string;
xsrfHeaderName?: string;
onUploadProgress?: (progressEvent: any) => void;
......@@ -38,27 +60,31 @@ export interface AxiosRequestConfig {
maxContentLength?: number;
validateStatus?: (status: number) => boolean;
maxRedirects?: number;
socketPath?: string | null;
httpAgent?: any;
httpsAgent?: any;
proxy?: AxiosProxyConfig;
proxy?: AxiosProxyConfig | false;
cancelToken?: CancelToken;
}
export interface AxiosResponse {
data: any;
export interface AxiosResponse<T = any> {
data: T;
status: number;
statusText: string;
headers: any;
config: AxiosRequestConfig;
request?: any;
}
export interface AxiosError extends Error {
export interface AxiosError<T = any> extends Error {
config: AxiosRequestConfig;
code?: string;
response?: AxiosResponse;
request?: any;
response?: AxiosResponse<T>;
isAxiosError: boolean;
}
export interface AxiosPromise extends Promise<AxiosResponse> {
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
}
export interface CancelStatic {
......@@ -90,28 +116,29 @@ export interface CancelTokenSource {
}
export interface AxiosInterceptorManager<V> {
use(onFulfilled: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any): number;
eject(id: number): void;
}
export interface AxiosInstance {
(config: AxiosRequestConfig): AxiosPromise;
(url: string, config?: AxiosRequestConfig): AxiosPromise;
defaults: AxiosRequestConfig;
interceptors: {
request: AxiosInterceptorManager<AxiosRequestConfig>;
response: AxiosInterceptorManager<AxiosResponse>;
};
request(config: AxiosRequestConfig): AxiosPromise;
get(url: string, config?: AxiosRequestConfig): AxiosPromise;
delete(url: string, config?: AxiosRequestConfig): AxiosPromise;
head(url: string, config?: AxiosRequestConfig): AxiosPromise;
post(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
put(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
patch(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise;
getUri(config?: AxiosRequestConfig): string;
request<T = any, R = AxiosResponse<T>> (config: AxiosRequestConfig): Promise<R>;
get<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
delete<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
head<T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig): Promise<R>;
post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig): Promise<R>;
}
export interface AxiosStatic extends AxiosInstance {
(config: AxiosRequestConfig): AxiosPromise;
(url: string, config?: AxiosRequestConfig): AxiosPromise;
create(config?: AxiosRequestConfig): AxiosInstance;
Cancel: CancelStatic;
CancelToken: CancelTokenStatic;
......
......@@ -13,17 +13,26 @@ var pkg = require('./../../package.json');
var createError = require('../core/createError');
var enhanceError = require('../core/enhanceError');
var isHttps = /https:?/;
/*eslint consistent-return:0*/
module.exports = function httpAdapter(config) {
return new Promise(function dispatchHttpRequest(resolve, reject) {
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
var timer;
var resolve = function resolve(value) {
clearTimeout(timer);
resolvePromise(value);
};
var reject = function reject(value) {
clearTimeout(timer);
rejectPromise(value);
};
var data = config.data;
var headers = config.headers;
var timer;
var aborted = false;
// Set User-Agent (required by some servers)
// Only set header if it hasn't been set in config
// See https://github.com/mzabriskie/axios/issues/69
// See https://github.com/axios/axios/issues/69
if (!headers['User-Agent'] && !headers['user-agent']) {
headers['User-Agent'] = 'axios/' + pkg.version;
}
......@@ -32,9 +41,9 @@ module.exports = function httpAdapter(config) {
if (Buffer.isBuffer(data)) {
// Nothing to do...
} else if (utils.isArrayBuffer(data)) {
data = new Buffer(new Uint8Array(data));
data = Buffer.from(new Uint8Array(data));
} else if (utils.isString(data)) {
data = new Buffer(data, 'utf-8');
data = Buffer.from(data, 'utf-8');
} else {
return reject(createError(
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
......@@ -69,36 +78,69 @@ module.exports = function httpAdapter(config) {
delete headers.Authorization;
}
var isHttps = protocol === 'https:';
var agent = isHttps ? config.httpsAgent : config.httpAgent;
var isHttpsRequest = isHttps.test(protocol);
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
var options = {
hostname: parsed.hostname,
port: parsed.port,
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
method: config.method,
method: config.method.toUpperCase(),
headers: headers,
agent: agent,
auth: auth
};
if (config.socketPath) {
options.socketPath = config.socketPath;
} else {
options.hostname = parsed.hostname;
options.port = parsed.port;
}
var proxy = config.proxy;
if (!proxy) {
if (!proxy && proxy !== false) {
var proxyEnv = protocol.slice(0, -1) + '_proxy';
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
if (proxyUrl) {
var parsedProxyUrl = url.parse(proxyUrl);
proxy = {
host: parsedProxyUrl.hostname,
port: parsedProxyUrl.port
};
if (parsedProxyUrl.auth) {
var proxyUrlAuth = parsedProxyUrl.auth.split(':');
proxy.auth = {
username: proxyUrlAuth[0],
password: proxyUrlAuth[1]
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
var shouldProxy = true;
if (noProxyEnv) {
var noProxy = noProxyEnv.split(',').map(function trim(s) {
return s.trim();
});
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
if (!proxyElement) {
return false;
}
if (proxyElement === '*') {
return true;
}
if (proxyElement[0] === '.' &&
parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement &&
proxyElement.match(/\./g).length === parsed.hostname.match(/\./g).length) {
return true;
}
return parsed.hostname === proxyElement;
});
}
if (shouldProxy) {
proxy = {
host: parsedProxyUrl.hostname,
port: parsedProxyUrl.port
};
if (parsedProxyUrl.auth) {
var proxyUrlAuth = parsedProxyUrl.auth.split(':');
proxy.auth = {
username: proxyUrlAuth[0],
password: proxyUrlAuth[1]
};
}
}
}
}
......@@ -112,28 +154,31 @@ module.exports = function httpAdapter(config) {
// Basic proxy authorization
if (proxy.auth) {
var base64 = new Buffer(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
}
}
var transport;
if (config.maxRedirects === 0) {
transport = isHttps ? https : http;
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
if (config.transport) {
transport = config.transport;
} else if (config.maxRedirects === 0) {
transport = isHttpsProxy ? https : http;
} else {
if (config.maxRedirects) {
options.maxRedirects = config.maxRedirects;
}
transport = isHttps ? httpsFollow : httpFollow;
transport = isHttpsProxy ? httpsFollow : httpFollow;
}
if (config.maxContentLength && config.maxContentLength > -1) {
options.maxBodyLength = config.maxContentLength;
}
// Create the request
var req = transport.request(options, function handleResponse(res) {
if (aborted) return;
// Response has been received so kill timer that handles request timeout
clearTimeout(timer);
timer = null;
if (req.aborted) return;
// uncompress the response body transparently if required
var stream = res;
......@@ -143,7 +188,7 @@ module.exports = function httpAdapter(config) {
case 'compress':
case 'deflate':
// add the unzipper to the body stream processing pipeline
stream = stream.pipe(zlib.createUnzip());
stream = (res.statusCode === 204) ? stream : stream.pipe(zlib.createUnzip());
// remove the content-encoding in order to not confuse downstream operations
delete res.headers['content-encoding'];
......@@ -171,20 +216,21 @@ module.exports = function httpAdapter(config) {
// make sure the content length is not over the maxContentLength if specified
if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
stream.destroy();
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
config, null, lastRequest));
}
});
stream.on('error', function handleStreamError(err) {
if (aborted) return;
if (req.aborted) return;
reject(enhanceError(err, config, null, lastRequest));
});
stream.on('end', function handleStreamEnd() {
var responseData = Buffer.concat(responseBuffer);
if (config.responseType !== 'arraybuffer') {
responseData = responseData.toString('utf8');
responseData = responseData.toString(config.responseEncoding);
}
response.data = responseData;
......@@ -195,35 +241,33 @@ module.exports = function httpAdapter(config) {
// Handle errors
req.on('error', function handleRequestError(err) {
if (aborted) return;
if (req.aborted) return;
reject(enhanceError(err, config, null, req));
});
// Handle request timeout
if (config.timeout && !timer) {
if (config.timeout) {
timer = setTimeout(function handleRequestTimeout() {
req.abort();
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
aborted = true;
}, config.timeout);
}
if (config.cancelToken) {
// Handle cancellation
config.cancelToken.promise.then(function onCanceled(cancel) {
if (aborted) {
return;
}
if (req.aborted) return;
req.abort();
reject(cancel);
aborted = true;
});
}
// Send the request
if (utils.isStream(data)) {
data.pipe(req);
data.on('error', function handleStreamError(err) {
reject(enhanceError(err, config, null, req));
}).pipe(req);
} else {
req.end(data);
}
......
......@@ -6,7 +6,6 @@ var buildURL = require('./../helpers/buildURL');
var parseHeaders = require('./../helpers/parseHeaders');
var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
var createError = require('../core/createError');
var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
module.exports = function xhrAdapter(config) {
return new Promise(function dispatchXhrRequest(resolve, reject) {
......@@ -18,22 +17,6 @@ module.exports = function xhrAdapter(config) {
}
var request = new XMLHttpRequest();
var loadEvent = 'onreadystatechange';
var xDomain = false;
// For IE 8/9 CORS support
// Only supports POST and GET calls and doesn't returns the response headers.
// DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
if (process.env.NODE_ENV !== 'test' &&
typeof window !== 'undefined' &&
window.XDomainRequest && !('withCredentials' in request) &&
!isURLSameOrigin(config.url)) {
request = new window.XDomainRequest();
loadEvent = 'onload';
xDomain = true;
request.onprogress = function handleProgress() {};
request.ontimeout = function handleTimeout() {};
}
// HTTP basic authentication
if (config.auth) {
......@@ -48,8 +31,8 @@ module.exports = function xhrAdapter(config) {
request.timeout = config.timeout;
// Listen for ready state
request[loadEvent] = function handleLoad() {
if (!request || (request.readyState !== 4 && !xDomain)) {
request.onreadystatechange = function handleLoad() {
if (!request || request.readyState !== 4) {
return;
}
......@@ -66,9 +49,8 @@ module.exports = function xhrAdapter(config) {
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
var response = {
data: responseData,
// IE sends 1223 instead of 204 (https://github.com/mzabriskie/axios/issues/201)
status: request.status === 1223 ? 204 : request.status,
statusText: request.status === 1223 ? 'No Content' : request.statusText,
status: request.status,
statusText: request.statusText,
headers: responseHeaders,
config: config,
request: request
......@@ -80,6 +62,18 @@ module.exports = function xhrAdapter(config) {
request = null;
};
// Handle browser request cancellation (as opposed to a manual cancellation)
request.onabort = function handleAbort() {
if (!request) {
return;
}
reject(createError('Request aborted', config, 'ECONNABORTED', request));
// Clean up request
request = null;
};
// Handle low level network errors
request.onerror = function handleError() {
// Real errors are hidden from us by the browser
......@@ -107,8 +101,8 @@ module.exports = function xhrAdapter(config) {
// Add xsrf header
var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
cookies.read(config.xsrfCookieName) :
undefined;
cookies.read(config.xsrfCookieName) :
undefined;
if (xsrfValue) {
requestHeaders[config.xsrfHeaderName] = xsrfValue;
......
......@@ -3,6 +3,7 @@
var utils = require('./utils');
var bind = require('./helpers/bind');
var Axios = require('./core/Axios');
var mergeConfig = require('./core/mergeConfig');
var defaults = require('./defaults');
/**
......@@ -32,7 +33,7 @@ axios.Axios = Axios;
// Factory for creating new instances
axios.create = function create(instanceConfig) {
return createInstance(utils.merge(defaults, instanceConfig));
return createInstance(mergeConfig(axios.defaults, instanceConfig));
};
// Expose Cancel & CancelToken
......
'use strict';
var defaults = require('./../defaults');
var utils = require('./../utils');
var buildURL = require('../helpers/buildURL');
var InterceptorManager = require('./InterceptorManager');
var dispatchRequest = require('./dispatchRequest');
var isAbsoluteURL = require('./../helpers/isAbsoluteURL');
var combineURLs = require('./../helpers/combineURLs');
var mergeConfig = require('./mergeConfig');
/**
* Create a new instance of Axios
......@@ -29,18 +28,14 @@ Axios.prototype.request = function request(config) {
/*eslint no-param-reassign:0*/
// Allow for axios('example/url'[, config]) a la fetch API
if (typeof config === 'string') {
config = utils.merge({
url: arguments[0]
}, arguments[1]);
config = arguments[1] || {};
config.url = arguments[0];
} else {
config = config || {};
}
config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
config.method = config.method.toLowerCase();
// Support baseURL config
if (config.baseURL && !isAbsoluteURL(config.url)) {
config.url = combineURLs(config.baseURL, config.url);
}
config = mergeConfig(this.defaults, config);
config.method = config.method ? config.method.toLowerCase() : 'get';
// Hook up interceptors middleware
var chain = [dispatchRequest, undefined];
......@@ -61,6 +56,11 @@ Axios.prototype.request = function request(config) {
return promise;
};
Axios.prototype.getUri = function getUri(config) {
config = mergeConfig(this.defaults, config);
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
};
// Provide aliases for supported request methods
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
/*eslint func-names:0*/
......
......@@ -4,6 +4,8 @@ var utils = require('./../utils');
var transformData = require('./transformData');
var isCancel = require('../cancel/isCancel');
var defaults = require('../defaults');
var isAbsoluteURL = require('./../helpers/isAbsoluteURL');
var combineURLs = require('./../helpers/combineURLs');
/**
* Throws a `Cancel` if cancellation has been requested.
......@@ -23,6 +25,11 @@ function throwIfCancellationRequested(config) {
module.exports = function dispatchRequest(config) {
throwIfCancellationRequested(config);
// Support baseURL config
if (config.baseURL && !isAbsoluteURL(config.url)) {
config.url = combineURLs(config.baseURL, config.url);
}
// Ensure headers exist
config.headers = config.headers || {};
......
......@@ -15,7 +15,28 @@ module.exports = function enhanceError(error, config, code, request, response) {
if (code) {
error.code = code;
}
error.request = request;
error.response = response;
error.isAxiosError = true;
error.toJSON = function() {
return {
// Standard
message: this.message,
name: this.name,
// Microsoft
description: this.description,
number: this.number,
// Mozilla
fileName: this.fileName,
lineNumber: this.lineNumber,
columnNumber: this.columnNumber,
stack: this.stack,
// Axios
config: this.config,
code: this.code
};
};
return error;
};
......
'use strict';
var utils = require('../utils');
/**
* Config-specific merge-function which creates a new config-object
* by merging two configuration objects together.
*
* @param {Object} config1
* @param {Object} config2
* @returns {Object} New object resulting from merging config2 to config1
*/
module.exports = function mergeConfig(config1, config2) {
// eslint-disable-next-line no-param-reassign
config2 = config2 || {};
var config = {};
utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
}
});
utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
if (utils.isObject(config2[prop])) {
config[prop] = utils.deepMerge(config1[prop], config2[prop]);
} else if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (utils.isObject(config1[prop])) {
config[prop] = utils.deepMerge(config1[prop]);
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
utils.forEach([
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
'socketPath'
], function defaultToConfig2(prop) {
if (typeof config2[prop] !== 'undefined') {
config[prop] = config2[prop];
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
}
});
return config;
};
......@@ -11,8 +11,7 @@ var createError = require('./createError');
*/
module.exports = function settle(resolve, reject, response) {
var validateStatus = response.config.validateStatus;
// Note: status is not exposed by XDomainRequest
if (!response.status || !validateStatus || validateStatus(response.status)) {
if (!validateStatus || validateStatus(response.status)) {
resolve(response);
} else {
reject(createError(
......
......@@ -15,12 +15,13 @@ function setContentTypeIfUnset(headers, value) {
function getDefaultAdapter() {
var adapter;
if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = require('./adapters/xhr');
} else if (typeof process !== 'undefined') {
// Only Node.JS has a process variable that is of [[Class]] process
if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
// For node use HTTP adapter
adapter = require('./adapters/http');
} else if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = require('./adapters/xhr');
}
return adapter;
}
......@@ -29,6 +30,7 @@ var defaults = {
adapter: getDefaultAdapter(),
transformRequest: [function transformRequest(data, headers) {
normalizeHeaderName(headers, 'Accept');
normalizeHeaderName(headers, 'Content-Type');
if (utils.isFormData(data) ||
utils.isArrayBuffer(data) ||
......@@ -63,6 +65,10 @@ var defaults = {
return data;
}],
/**
* A timeout in milliseconds to abort a request. If set to 0 (default) a
* timeout is not created.
*/
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
......
'use strict';
// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
function E() {
this.message = 'String contains an invalid character';
}
E.prototype = new Error;
E.prototype.code = 5;
E.prototype.name = 'InvalidCharacterError';
function btoa(input) {
var str = String(input);
var output = '';
for (
// initialize result and counter
var block, charCode, idx = 0, map = chars;
// if the next str index does not exist:
// change the mapping table to "="
// check if d has no fractional digits
str.charAt(idx | 0) || (map = '=', idx % 1);
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
) {
charCode = str.charCodeAt(idx += 3 / 4);
if (charCode > 0xFF) {
throw new E();
}
block = block << 8 | charCode;
}
return output;
}
module.exports = btoa;
......@@ -41,9 +41,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
if (utils.isArray(val)) {
key = key + '[]';
}
if (!utils.isArray(val)) {
} else {
val = [val];
}
......@@ -61,6 +59,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
}
if (serializedParams) {
var hashmarkIndex = url.indexOf('#');
if (hashmarkIndex !== -1) {
url = url.slice(0, hashmarkIndex);
}
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
}
......
......@@ -6,48 +6,48 @@ module.exports = (
utils.isStandardBrowserEnv() ?
// Standard browser envs support document.cookie
(function standardBrowserEnv() {
return {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
(function standardBrowserEnv() {
return {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString());
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
if (secure === true) {
cookie.push('secure');
}
document.cookie = cookie.join('; ');
},
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
}
if (utils.isString(path)) {
cookie.push('path=' + path);
}
if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
if (secure === true) {
cookie.push('secure');
}
document.cookie = cookie.join('; ');
},
read: function read(name) {
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
remove: function remove(name) {
this.write(name, '', Date.now() - 86400000);
}
};
})() :
};
})() :
// Non standard browser env (web workers, react-native) lack needed support.
(function nonStandardBrowserEnv() {
return {
write: function write() {},
read: function read() { return null; },
remove: function remove() {}
};
})()
(function nonStandardBrowserEnv() {
return {
write: function write() {},
read: function read() { return null; },
remove: function remove() {}
};
})()
);
......
......@@ -7,62 +7,62 @@ module.exports = (
// Standard browser envs have full support of the APIs needed to test
// whether the request URL is of the same origin as current location.
(function standardBrowserEnv() {
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originURL;
(function standardBrowserEnv() {
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originURL;
/**
/**
* Parse a URL to discover it's components
*
* @param {String} url The URL to be parsed
* @returns {Object}
*/
function resolveURL(url) {
var href = url;
function resolveURL(url) {
var href = url;
if (msie) {
if (msie) {
// IE needs attribute set twice to normalize properties
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
urlParsingNode.setAttribute('href', href);
urlParsingNode.setAttribute('href', href);
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname :
'/' + urlParsingNode.pathname
};
}
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname :
'/' + urlParsingNode.pathname
};
}
originURL = resolveURL(window.location.href);
originURL = resolveURL(window.location.href);
/**
/**
* Determine if a URL shares the same origin as the current location
*
* @param {String} requestURL The URL to test
* @returns {boolean} True if URL shares the same origin, otherwise false
*/
return function isURLSameOrigin(requestURL) {
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
return (parsed.protocol === originURL.protocol &&
return function isURLSameOrigin(requestURL) {
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
return (parsed.protocol === originURL.protocol &&
parsed.host === originURL.host);
};
})() :
};
})() :
// Non standard browser envs (web workers, react-native) lack needed support.
(function nonStandardBrowserEnv() {
return function isURLSameOrigin() {
return true;
};
})()
(function nonStandardBrowserEnv() {
return function isURLSameOrigin() {
return true;
};
})()
);
......
......@@ -2,6 +2,15 @@
var utils = require('./../utils');
// Headers whose duplicates are ignored by node
// c.f. https://nodejs.org/api/http.html#http_message_headers
var ignoreDuplicateOf = [
'age', 'authorization', 'content-length', 'content-type', 'etag',
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
'referer', 'retry-after', 'user-agent'
];
/**
* Parse headers into an object
*
......@@ -29,7 +38,14 @@ module.exports = function parseHeaders(headers) {
val = utils.trim(line.substr(i + 1));
if (key) {
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
return;
}
if (key === 'set-cookie') {
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
} else {
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
}
}
});
......
......@@ -177,9 +177,13 @@ function trim(str) {
*
* react-native:
* navigator.product -> 'ReactNative'
* nativescript
* navigator.product -> 'NativeScript' or 'NS'
*/
function isStandardBrowserEnv() {
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
navigator.product === 'NativeScript' ||
navigator.product === 'NS')) {
return false;
}
return (
......@@ -207,7 +211,7 @@ function forEach(obj, fn) {
}
// Force an array if not already something iterable
if (typeof obj !== 'object' && !isArray(obj)) {
if (typeof obj !== 'object') {
/*eslint no-param-reassign:0*/
obj = [obj];
}
......@@ -261,6 +265,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
}
/**
* Function equal to merge with the difference being that no reference
* to original objects is kept.
*
* @see merge
* @param {Object} obj1 Object to merge
* @returns {Object} Result of all merge properties
*/
function deepMerge(/* obj1, obj2, obj3, ... */) {
var result = {};
function assignValue(val, key) {
if (typeof result[key] === 'object' && typeof val === 'object') {
result[key] = deepMerge(result[key], val);
} else if (typeof val === 'object') {
result[key] = deepMerge({}, val);
} else {
result[key] = val;
}
}
for (var i = 0, l = arguments.length; i < l; i++) {
forEach(arguments[i], assignValue);
}
return result;
}
/**
* Extends object a by mutably adding to it the properties of object b.
*
* @param {Object} a The object to be extended
......@@ -298,6 +328,7 @@ module.exports = {
isStandardBrowserEnv: isStandardBrowserEnv,
forEach: forEach,
merge: merge,
deepMerge: deepMerge,
extend: extend,
trim: trim
};
......
{
"_from": "axios@^0.16.2",
"_id": "axios@0.16.2",
"_from": "axios@^0.19.0",
"_id": "axios@0.19.0",
"_inBundle": false,
"_integrity": "sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=",
"_integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
"_location": "/axios",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "axios@^0.16.2",
"raw": "axios@^0.19.0",
"name": "axios",
"escapedName": "axios",
"rawSpec": "^0.16.2",
"rawSpec": "^0.19.0",
"saveSpec": null,
"fetchSpec": "^0.16.2"
"fetchSpec": "^0.19.0"
},
"_requiredBy": [
"/@line/bot-sdk"
],
"_resolved": "https://registry.npmjs.org/axios/-/axios-0.16.2.tgz",
"_shasum": "ba4f92f17167dfbab40983785454b9ac149c3c6d",
"_spec": "axios@^0.16.2",
"_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\@line\\bot-sdk",
"_resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
"_shasum": "8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8",
"_spec": "axios@^0.19.0",
"_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\@line\\bot-sdk",
"author": {
"name": "Matt Zabriskie"
},
......@@ -29,53 +29,59 @@
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
},
"bugs": {
"url": "https://github.com/mzabriskie/axios/issues"
"url": "https://github.com/axios/axios/issues"
},
"bundleDependencies": false,
"bundlesize": [
{
"path": "./dist/axios.min.js",
"threshold": "5kB"
}
],
"dependencies": {
"follow-redirects": "^1.2.3",
"is-buffer": "^1.1.5"
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
},
"deprecated": false,
"description": "Promise based HTTP client for the browser and node.js",
"devDependencies": {
"coveralls": "^2.11.9",
"es6-promise": "^4.0.5",
"grunt": "^1.0.1",
"bundlesize": "^0.17.0",
"coveralls": "^3.0.0",
"es6-promise": "^4.2.4",
"grunt": "^1.0.2",
"grunt-banner": "^0.6.0",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-nodeunit": "^1.0.0",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-eslint": "^19.0.0",
"grunt-eslint": "^20.1.0",
"grunt-karma": "^2.0.0",
"grunt-ts": "^6.0.0-beta.3",
"grunt-mocha-test": "^0.13.3",
"grunt-ts": "^6.0.0-beta.19",
"grunt-webpack": "^1.0.18",
"istanbul-instrumenter-loader": "^1.0.0",
"jasmine-core": "^2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "^1.0.2",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-jasmine": "^1.1.1",
"karma-jasmine-ajax": "^0.1.13",
"karma-opera-launcher": "^1.0.0",
"karma-phantomjs-launcher": "^1.0.0",
"karma-safari-launcher": "^1.0.0",
"karma-sauce-launcher": "^1.1.0",
"karma-sauce-launcher": "^1.2.0",
"karma-sinon": "^1.0.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"load-grunt-tasks": "^3.5.2",
"minimist": "^1.2.0",
"phantomjs-prebuilt": "^2.1.7",
"sinon": "^1.17.4",
"typescript": "^2.0.3",
"url-search-params": "^0.6.1",
"mocha": "^5.2.0",
"sinon": "^4.5.0",
"typescript": "^2.8.1",
"url-search-params": "^0.10.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},
"homepage": "https://github.com/mzabriskie/axios",
"homepage": "https://github.com/axios/axios",
"keywords": [
"xhr",
"http",
......@@ -88,18 +94,19 @@
"name": "axios",
"repository": {
"type": "git",
"url": "git+https://github.com/mzabriskie/axios.git"
"url": "git+https://github.com/axios/axios.git"
},
"scripts": {
"build": "NODE_ENV=production grunt build",
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"examples": "node ./examples/server.js",
"fix": "eslint --fix lib/**/*.js",
"postversion": "git push && git push --tags",
"preversion": "npm test",
"start": "node ./sandbox/server.js",
"test": "grunt test",
"test": "grunt test && bundlesize",
"version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"
},
"typings": "./index.d.ts",
"version": "0.16.2"
"version": "0.19.0"
}
......
......@@ -28,12 +28,15 @@ It's future-proof and works in node too!
npm install is-buffer
```
[Get supported is-buffer with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-is-buffer?utm_source=npm-is-buffer&utm_medium=referral&utm_campaign=readme)
## usage
```js
var isBuffer = require('is-buffer')
isBuffer(new Buffer(4)) // true
isBuffer(Buffer.alloc(4)) //true
isBuffer(undefined) // false
isBuffer(null) // false
......
declare function isBuffer(obj: any): boolean
export = isBuffer
......@@ -5,17 +5,7 @@
* @license MIT
*/
// The _isBuffer check is for Safari 5-7 support, because it's missing
// Object.prototype.constructor. Remove this eventually
module.exports = function (obj) {
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
}
function isBuffer (obj) {
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
}
// For Node v0.10 support. Remove this eventually.
function isSlowBuffer (obj) {
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
module.exports = function isBuffer (obj) {
return obj != null && obj.constructor != null &&
typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
}
......
{
"_from": "is-buffer@^1.1.5",
"_id": "is-buffer@1.1.6",
"_from": "is-buffer@^2.0.2",
"_id": "is-buffer@2.0.4",
"_inBundle": false,
"_integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
"_integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==",
"_location": "/is-buffer",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "is-buffer@^1.1.5",
"raw": "is-buffer@^2.0.2",
"name": "is-buffer",
"escapedName": "is-buffer",
"rawSpec": "^1.1.5",
"rawSpec": "^2.0.2",
"saveSpec": null,
"fetchSpec": "^1.1.5"
"fetchSpec": "^2.0.2"
},
"_requiredBy": [
"/axios"
],
"_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"_shasum": "efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be",
"_spec": "is-buffer@^1.1.5",
"_where": "C:\\Users\\KSI\\Desktop\\3-2\\OSS\\LineBot\\node_modules\\axios",
"_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
"_shasum": "3e572f23c8411a5cfd9557c849e3665e0b290623",
"_spec": "is-buffer@^2.0.2",
"_where": "C:\\Users\\SEUNGCHAN\\Desktop\\LINEBOT\\node_modules\\axios",
"author": {
"name": "Feross Aboukhadijeh",
"email": "feross@feross.org",
"url": "http://feross.org/"
"url": "https://feross.org"
},
"bugs": {
"url": "https://github.com/feross/is-buffer/issues"
......@@ -35,27 +35,30 @@
"deprecated": false,
"description": "Determine if an object is a Buffer",
"devDependencies": {
"airtap": "^2.0.3",
"standard": "*",
"tape": "^4.0.0",
"zuul": "^3.0.0"
"tape": "^4.11.0"
},
"engines": {
"node": ">=4"
},
"homepage": "https://github.com/feross/is-buffer#readme",
"keywords": [
"arraybuffer",
"browser",
"browser buffer",
"browserify",
"buffer",
"buffers",
"type",
"core buffer",
"browser buffer",
"browserify",
"typed array",
"uint32array",
"int16array",
"int32array",
"dataview",
"float32array",
"float64array",
"browser",
"arraybuffer",
"dataview"
"int16array",
"int32array",
"type",
"typed array",
"uint32array"
],
"license": "MIT",
"main": "index.js",
......@@ -66,12 +69,9 @@
},
"scripts": {
"test": "standard && npm run test-node && npm run test-browser",
"test-browser": "zuul -- test/*.js",
"test-browser-local": "zuul --local -- test/*.js",
"test-browser": "airtap -- test/*.js",
"test-browser-local": "airtap --local -- test/*.js",
"test-node": "tape test/*.js"
},
"testling": {
"files": "test/*.js"
},
"version": "1.1.6"
"version": "2.0.4"
}
......
var isBuffer = require('../')
var test = require('tape')
test('is-buffer', function (t) {
t.equal(isBuffer(Buffer.alloc(4)), true, 'new Buffer(4)')
t.equal(isBuffer(Buffer.allocUnsafeSlow(100)), true, 'SlowBuffer(100)')
t.equal(isBuffer(undefined), false, 'undefined')
t.equal(isBuffer(null), false, 'null')
t.equal(isBuffer(''), false, 'empty string')
t.equal(isBuffer(true), false, 'true')
t.equal(isBuffer(false), false, 'false')
t.equal(isBuffer(0), false, '0')
t.equal(isBuffer(1), false, '1')
t.equal(isBuffer(1.0), false, '1.0')
t.equal(isBuffer('string'), false, 'string')
t.equal(isBuffer({}), false, '{}')
t.equal(isBuffer([]), false, '[]')
t.equal(isBuffer(function foo () {}), false, 'function foo () {}')
t.equal(isBuffer({ isBuffer: null }), false, '{ isBuffer: null }')
t.equal(isBuffer({ isBuffer: function () { throw new Error() } }), false, '{ isBuffer: function () { throw new Error() } }')
t.end()
})
......@@ -5,22 +5,22 @@
"requires": true,
"dependencies": {
"@line/bot-sdk": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.4.0.tgz",
"integrity": "sha512-N0FkrqFxTTleOpD6y7DTK8qbMYHr9Q8qZfrAmSYEFAGedM1HLJdbNNkStj5GT+svx+w+/ePF/n7nAEts0aJwkA==",
"version": "6.8.3",
"resolved": "https://registry.npmjs.org/@line/bot-sdk/-/bot-sdk-6.8.3.tgz",
"integrity": "sha512-nj2T4CQxw0W/juAlpj0kMTDScOh5QUK6xMCR2dZp+pN8B0vj/c+5uX3TyGB4ijz/NIsehgfKujPgzw7LhtYtJw==",
"requires": {
"@types/body-parser": "^1.16.8",
"@types/file-type": "^5.2.1",
"@types/node": "^7.0.31",
"axios": "^0.16.2",
"axios": "^0.19.0",
"body-parser": "^1.18.2",
"file-type": "^7.2.0"
}
},
"@types/body-parser": {
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz",
"integrity": "sha512-a2+YeUjPkztKJu5aIF2yArYFQQp8d51wZ7DavSHjFuY1mqVgidGyzEQ41JIVNy82fXj8yPgy2vJmfIywgESW6w==",
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.1.tgz",
"integrity": "sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==",
"requires": {
"@types/connect": "*",
"@types/node": "*"
......@@ -43,9 +43,9 @@
}
},
"@types/node": {
"version": "7.10.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.2.tgz",
"integrity": "sha512-RO4ig5taKmcrU4Rex8ojG1gpwFkjddzug9iPQSDvbewHN9vDpcFewevkaOK+KT+w1LeZnxbgOyfXwV4pxsQ4GQ=="
"version": "7.10.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.9.tgz",
"integrity": "sha512-usSpgoUsRtO5xNV5YEPU8PPnHisFx8u0rokj1BPVn/hDF7zwUDzVLiuKZM38B7z8V2111Fj6kd4rGtQFUZpNOw=="
},
"accepts": {
"version": "1.3.5",
......@@ -62,12 +62,12 @@
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
},
"axios": {
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.16.2.tgz",
"integrity": "sha1-uk+S8XFn37q0CYN4VFS5rBScPG0=",
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
"integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
"requires": {
"follow-redirects": "^1.2.3",
"is-buffer": "^1.1.5"
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
}
},
"body-parser": {
......@@ -264,9 +264,9 @@
"integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4="
},
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
"integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
},
"media-typer": {
"version": "0.3.0",
......
......@@ -10,7 +10,7 @@
"author": "강수인",
"license": "MIT",
"dependencies": {
"@line/bot-sdk": "^6.4.0",
"@line/bot-sdk": "^6.8.3",
"express": "^4.16.4"
}
}
......